void LAi_ApplyCharacterBladeDamage(aref attack, aref enemy, float attackDmg, float hitDmg, bool isBlocked)
{
//Åñëè íåóáèâàåìûé, òî íåòðîãàåì åãî
if(CheckAttribute(enemy, "chr_ai.immortal"))
{
if(sti(enemy.chr_ai.immortal) != 0) return;
}
//Ïðèìåíÿåì àáèëèòè
float pBreak = 0.0;
if(IsCharacterPerkOn(attack, "SwordplayProfessional"))
{
pBreak = pBreak + 0.25;
}
// Baste - critical hit check moved down
float kDmg = 1.0;
if(IsCharacterPerkOn(attack, "Rush"))
{
kDmg = 1.5;
pBreak = pBreak + 0.5;
}
if(IsCharacterPerkOn(enemy, "Rush"))
{
pBreak = pBreak + 0.9;
}
isBlocked = isBlocked && CheckAttribute(enemy,"equip.blade") && GetCharacterEquipByGroup(enemy,BLADE_ITEM_TYPE) != "bladeX4";
// PB: Disable blocking for enemies with either no sword or their fists equiped
if(isBlocked)
{
//Âåðîÿòíîñòü ïðîáèâêè
float p = LAi_BladeFindPiercingProbability(attack, enemy, hitDmg);
p = p + pBreak;
//Åñëè øàíñîâ ïðîáèòü íåò, òî íåíàíîñèì ïðîâðåæäåíèÿ
// if(p < 0.0) return; // LDH removed 06Apr09
//Åñëè øàíñîâ ïðîáèòü íåò, òî íåíàíîñèì ïðîâðåæäåíèÿ
if(rand(10000) > p*10000) // if block is NOT pierced
{
// LDH rewrite 06Apr09
if(GetCharacterEquipByGroup(attack, BLADE_ITEM_TYPE) == "bladeX4") // if attacker uses fists, he gets damaged instead
{
if(!LAi_IsImmortal(attack))
{
LAi_ApplyCharacterDamage(attack, 2*rand(makeint(attack.skill.Fencing))); // LDH 0..20
LAi_CheckKillCharacter(attack);
}
// return; // LDH so blocked fists don't damage defender - 11Apr09
}
return;
}
}
//Âû÷èñëÿåì ïîâðåæäåíèå
float dmg = LAi_BladeCalcDamage(attack);
dmg = dmg*kDmg;
//Àòòàêà ñâîåé ãðóïïû
kDmg = 1.0;
if(IsCharacterPerkOn(enemy, "BasicDefense")) kDmg = 0.9;
if(IsCharacterPerkOn(enemy, "AdvancedDefense")) kDmg = 0.8;
if(IsCharacterPerkOn(enemy, "SwordplayProfessional")) kDmg = 0.7; // Baste
dmg = dmg*kDmg;
float damage = LAi_BladeApplySkills(attack, enemy, dmg);
// Baste - critical hit calculation changed -->
float critical = 0.0;
if(IsCharacterPerkOn(attack, "SwordplayProfessional"))
{
if(rand(100) <= 25)
{
critical = damage*2.0;
}
}else{
if(IsCharacterPerkOn(attack, "CriticalHit"))
{
if(rand(100) <= 10)
{
critical = damage*2.0;
}
}
}else{
if(rand(100) <= 5)
{
critical = damage*2.0;
}
}
if(isBlocked)
{
damage = damage*0.3;
}
bool noExp = false;
if(CheckAttribute(attack, "chr_ai.group"))
{
if(CheckAttribute(enemy, "chr_ai.group"))
{
if(attack.chr_ai.group == enemy.chr_ai.group && !CheckAttribute(GetMainCharacter(),"TrainingFight") && !HasSubStr(attack.id,"TrainingFight_") && !HasSubStr(enemy.id,"TrainingFight_"))//MAXIMUS
{
// ccc mar05 REPLOSS tweak added
// PB: I don't think we need this; no harm done = no reploss needed
// LAi_ChangeReputation(attack, - REPLOSS); // ccc rephit for attacking friends
// if(sti(attack.index) == GetMainCharacterIndex()) traceandlog("CHANGE REP for player: " + -REPLOSS + " - attacking friends"); // LDH 19Dec08
damage = 0.0; // dmg = 0.0;
critical = 0.0;
noExp = true;
}
}
}
if(critical > 0.0)
{
if(sti(attack.index) == GetMainCharacterIndex())
{
Log_SetStringToLog(XI_ConvertString("Critical Hit"));
}
}
// Baste <--
// TIH --> do not show XP messages for other characters, its annoying! Aug24'06
bool resetshowXP = false;
if(sti(attack.index) != GetMainCharacterIndex())
{
attack.donotshowXP = true;
resetshowXP = true;
}
// TIH <--
// if(!LAi_IsFightMode(enemy) && attack.equip.blade=="blade5") {damage = damage*(rand(5)+sti(attack.skill.Sneak)+5);} // ccc sneakmod backstab
//Íàíîñèì ïîâðåæäåíèå
// Baste -->
if(critical > 0.0)
{
LAi_ApplyCharacterDamage(enemy, MakeInt(ApplyArmor(enemy, attack, critical, true) + 0.5)); // GreatZen-NK
}
else
{
LAi_ApplyCharacterDamage(enemy, MakeInt(ApplyArmor(enemy, attack, damage, true) + 0.5)); // GreatZen-NK
}
// Baste <--