[Quest API] Added NPC special ability to modify Riposte/Dodge/Parry/Block chance (#1683)

* Update attack.cpp

* u

* Update attack.cpp

* spellchecked
This commit is contained in:
KayenEQ 2021-11-06 21:06:14 -04:00 committed by GitHub
parent 5c7972345a
commit 785926a584
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 95 additions and 62 deletions

View File

@ -396,6 +396,20 @@ bool Mob::AvoidDamage(Mob *other, DamageHitInfo &hit)
counter_dodge = attacker->GetSpecialAbilityParam(COUNTER_AVOID_DAMAGE, 4); counter_dodge = attacker->GetSpecialAbilityParam(COUNTER_AVOID_DAMAGE, 4);
} }
int modify_all = 0;
int modify_riposte = 0;
int modify_block = 0;
int modify_parry = 0;
int modify_dodge = 0;
if (GetSpecialAbility(MODIFY_AVOID_DAMAGE)) {
modify_all = GetSpecialAbilityParam(MODIFY_AVOID_DAMAGE, 0);
modify_riposte = GetSpecialAbilityParam(MODIFY_AVOID_DAMAGE, 1);
modify_block = GetSpecialAbilityParam(MODIFY_AVOID_DAMAGE, 2);
modify_parry = GetSpecialAbilityParam(MODIFY_AVOID_DAMAGE, 3);
modify_dodge = GetSpecialAbilityParam(MODIFY_AVOID_DAMAGE, 4);
}
// riposte -- it may seem crazy, but if the attacker has SPA 173 on them, they are immune to Ripo // riposte -- it may seem crazy, but if the attacker has SPA 173 on them, they are immune to Ripo
bool ImmuneRipo = attacker->aabonuses.RiposteChance || attacker->spellbonuses.RiposteChance || attacker->itembonuses.RiposteChance || attacker->IsEnraged(); bool ImmuneRipo = attacker->aabonuses.RiposteChance || attacker->spellbonuses.RiposteChance || attacker->itembonuses.RiposteChance || attacker->IsEnraged();
// Need to check if we have something in MainHand to actually attack with (or fists) // Need to check if we have something in MainHand to actually attack with (or fists)
@ -420,6 +434,10 @@ bool Mob::AvoidDamage(Mob *other, DamageHitInfo &hit)
float counter = (counter_riposte + counter_all) / 100.0f; float counter = (counter_riposte + counter_all) / 100.0f;
chance -= chance * counter; chance -= chance * counter;
} }
if (modify_riposte || modify_all) {
float npc_modifier = (modify_riposte + modify_all) / 100.0f;
chance += chance * npc_modifier;
}
// AA Slippery Attacks // AA Slippery Attacks
if (hit.hand == EQ::invslot::slotSecondary) { if (hit.hand == EQ::invslot::slotSecondary) {
int slip = aabonuses.OffhandRiposteFail + itembonuses.OffhandRiposteFail + spellbonuses.OffhandRiposteFail; int slip = aabonuses.OffhandRiposteFail + itembonuses.OffhandRiposteFail + spellbonuses.OffhandRiposteFail;
@ -459,6 +477,10 @@ bool Mob::AvoidDamage(Mob *other, DamageHitInfo &hit)
float counter = (counter_block + counter_all) / 100.0f; float counter = (counter_block + counter_all) / 100.0f;
chance -= chance * counter; chance -= chance * counter;
} }
if (modify_block || modify_all) {
float npc_modifier = (modify_block + modify_all) / 100.0f;
chance += chance * npc_modifier;
}
if (zone->random.Roll(chance)) { if (zone->random.Roll(chance)) {
hit.damage_done = DMG_BLOCKED; hit.damage_done = DMG_BLOCKED;
return true; return true;
@ -482,6 +504,10 @@ bool Mob::AvoidDamage(Mob *other, DamageHitInfo &hit)
float counter = (counter_parry + counter_all) / 100.0f; float counter = (counter_parry + counter_all) / 100.0f;
chance -= chance * counter; chance -= chance * counter;
} }
if (modify_parry || modify_all) {
float npc_modifier = (modify_parry + modify_all) / 100.0f;
chance += chance * npc_modifier;
}
if (zone->random.Roll(chance)) { if (zone->random.Roll(chance)) {
hit.damage_done = DMG_PARRIED; hit.damage_done = DMG_PARRIED;
return true; return true;
@ -505,6 +531,10 @@ bool Mob::AvoidDamage(Mob *other, DamageHitInfo &hit)
float counter = (counter_dodge + counter_all) / 100.0f; float counter = (counter_dodge + counter_all) / 100.0f;
chance -= chance * counter; chance -= chance * counter;
} }
if (modify_dodge || modify_all) {
float npc_modifier = (modify_dodge + modify_all) / 100.0f;
chance += chance * npc_modifier;
}
if (zone->random.Roll(chance)) { if (zone->random.Roll(chance)) {
hit.damage_done = DMG_DODGED; hit.damage_done = DMG_DODGED;
return true; return true;

View File

@ -201,14 +201,15 @@ enum {
ALLOW_TO_TANK = 41, ALLOW_TO_TANK = 41,
IGNORE_ROOT_AGGRO_RULES = 42, IGNORE_ROOT_AGGRO_RULES = 42,
CASTING_RESIST_DIFF = 43, CASTING_RESIST_DIFF = 43,
COUNTER_AVOID_DAMAGE = 44, COUNTER_AVOID_DAMAGE = 44, //Modify by percent NPC's opponents chance to riposte, block, parry or dodge individually, or for all skills
PROX_AGGRO = 45, PROX_AGGRO = 45,
IMMUNE_RANGED_ATTACKS = 46, IMMUNE_RANGED_ATTACKS = 46,
IMMUNE_DAMAGE_CLIENT = 47, IMMUNE_DAMAGE_CLIENT = 47,
IMMUNE_DAMAGE_NPC = 48, IMMUNE_DAMAGE_NPC = 48,
IMMUNE_AGGRO_CLIENT = 49, IMMUNE_AGGRO_CLIENT = 49,
IMMUNE_AGGRO_NPC = 50, IMMUNE_AGGRO_NPC = 50,
MAX_SPECIAL_ATTACK = 51 MODIFY_AVOID_DAMAGE = 51, //Modify by percent the NPCs chance to riposte, block, parry or dodge individually, or for all skills
MAX_SPECIAL_ATTACK = 52
}; };
typedef enum { //fear states typedef enum { //fear states

View File

@ -2841,6 +2841,7 @@ luabind::scope lua_register_mob() {
luabind::scope lua_register_special_abilities() { luabind::scope lua_register_special_abilities() {
return luabind::class_<SpecialAbilities>("SpecialAbility") return luabind::class_<SpecialAbilities>("SpecialAbility")
.enum_("constants") .enum_("constants")
[ [
luabind::value("summon", static_cast<int>(SPECATK_SUMMON)), luabind::value("summon", static_cast<int>(SPECATK_SUMMON)),
@ -2891,7 +2892,8 @@ luabind::scope lua_register_special_abilities() {
luabind::value("immune_damage_client", static_cast<int>(IMMUNE_DAMAGE_CLIENT)), luabind::value("immune_damage_client", static_cast<int>(IMMUNE_DAMAGE_CLIENT)),
luabind::value("immune_damage_npc", static_cast<int>(IMMUNE_DAMAGE_NPC)), luabind::value("immune_damage_npc", static_cast<int>(IMMUNE_DAMAGE_NPC)),
luabind::value("immune_aggro_client", static_cast<int>(IMMUNE_AGGRO_CLIENT)), luabind::value("immune_aggro_client", static_cast<int>(IMMUNE_AGGRO_CLIENT)),
luabind::value("immune_aggro_npc", static_cast<int>(IMMUNE_AGGRO_NPC)) luabind::value("immune_aggro_npc", static_cast<int>(IMMUNE_AGGRO_NPC)),
luabind::value("modify_avoid_damage", static_cast<int>(MODIFY_AVOID_DAMAGE))
]; ];
} }