From 785926a584a392ff36323329f2fa30abb4dd0073 Mon Sep 17 00:00:00 2001 From: KayenEQ Date: Sat, 6 Nov 2021 21:06:14 -0400 Subject: [PATCH] [Quest API] Added NPC special ability to modify Riposte/Dodge/Parry/Block chance (#1683) * Update attack.cpp * u * Update attack.cpp * spellchecked --- zone/attack.cpp | 46 ++++++++++++++++---- zone/common.h | 5 ++- zone/lua_mob.cpp | 106 ++++++++++++++++++++++++----------------------- 3 files changed, 95 insertions(+), 62 deletions(-) diff --git a/zone/attack.cpp b/zone/attack.cpp index 28a6f995e..c869792a7 100644 --- a/zone/attack.cpp +++ b/zone/attack.cpp @@ -382,18 +382,32 @@ bool Mob::AvoidDamage(Mob *other, DamageHitInfo &hit) ultimately end up being more useful as fields in npc_types. */ - int counter_all = 0; + int counter_all = 0; int counter_riposte = 0; - int counter_block = 0; - int counter_parry = 0; - int counter_dodge = 0; + int counter_block = 0; + int counter_parry = 0; + int counter_dodge = 0; if (attacker->GetSpecialAbility(COUNTER_AVOID_DAMAGE)) { - counter_all = attacker->GetSpecialAbilityParam(COUNTER_AVOID_DAMAGE, 0); + counter_all = attacker->GetSpecialAbilityParam(COUNTER_AVOID_DAMAGE, 0); counter_riposte = attacker->GetSpecialAbilityParam(COUNTER_AVOID_DAMAGE, 1); - counter_block = attacker->GetSpecialAbilityParam(COUNTER_AVOID_DAMAGE, 2); - counter_parry = attacker->GetSpecialAbilityParam(COUNTER_AVOID_DAMAGE, 3); - counter_dodge = attacker->GetSpecialAbilityParam(COUNTER_AVOID_DAMAGE, 4); + counter_block = attacker->GetSpecialAbilityParam(COUNTER_AVOID_DAMAGE, 2); + counter_parry = attacker->GetSpecialAbilityParam(COUNTER_AVOID_DAMAGE, 3); + 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 @@ -420,6 +434,10 @@ bool Mob::AvoidDamage(Mob *other, DamageHitInfo &hit) float counter = (counter_riposte + counter_all) / 100.0f; chance -= chance * counter; } + if (modify_riposte || modify_all) { + float npc_modifier = (modify_riposte + modify_all) / 100.0f; + chance += chance * npc_modifier; + } // AA Slippery Attacks if (hit.hand == EQ::invslot::slotSecondary) { 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; 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)) { hit.damage_done = DMG_BLOCKED; return true; @@ -482,6 +504,10 @@ bool Mob::AvoidDamage(Mob *other, DamageHitInfo &hit) float counter = (counter_parry + counter_all) / 100.0f; 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)) { hit.damage_done = DMG_PARRIED; return true; @@ -505,6 +531,10 @@ bool Mob::AvoidDamage(Mob *other, DamageHitInfo &hit) float counter = (counter_dodge + counter_all) / 100.0f; 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)) { hit.damage_done = DMG_DODGED; return true; diff --git a/zone/common.h b/zone/common.h index 85f2d3cbc..c52dc74e1 100644 --- a/zone/common.h +++ b/zone/common.h @@ -201,14 +201,15 @@ enum { ALLOW_TO_TANK = 41, IGNORE_ROOT_AGGRO_RULES = 42, 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, IMMUNE_RANGED_ATTACKS = 46, IMMUNE_DAMAGE_CLIENT = 47, IMMUNE_DAMAGE_NPC = 48, IMMUNE_AGGRO_CLIENT = 49, 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 diff --git a/zone/lua_mob.cpp b/zone/lua_mob.cpp index 4b50c2b78..ad39f9af5 100644 --- a/zone/lua_mob.cpp +++ b/zone/lua_mob.cpp @@ -2841,58 +2841,60 @@ luabind::scope lua_register_mob() { luabind::scope lua_register_special_abilities() { return luabind::class_("SpecialAbility") - .enum_("constants") - [ - luabind::value("summon", static_cast(SPECATK_SUMMON)), - luabind::value("enrage", static_cast(SPECATK_ENRAGE)), - luabind::value("rampage", static_cast(SPECATK_RAMPAGE)), - luabind::value("area_rampage", static_cast(SPECATK_AREA_RAMPAGE)), - luabind::value("flurry", static_cast(SPECATK_FLURRY)), - luabind::value("triple_attack", static_cast(SPECATK_TRIPLE)), - luabind::value("quad_attack", static_cast(SPECATK_QUAD)), - luabind::value("innate_dual_wield", static_cast(SPECATK_INNATE_DW)), - luabind::value("bane_attack", static_cast(SPECATK_BANE)), - luabind::value("magical_attack", static_cast(SPECATK_MAGICAL)), - luabind::value("ranged_attack", static_cast(SPECATK_RANGED_ATK)), - luabind::value("unslowable", static_cast(UNSLOWABLE)), - luabind::value("unmezable", static_cast(UNMEZABLE)), - luabind::value("uncharmable", static_cast(UNCHARMABLE)), - luabind::value("unstunable", static_cast(UNSTUNABLE)), - luabind::value("unsnareable", static_cast(UNSNAREABLE)), - luabind::value("unfearable", static_cast(UNFEARABLE)), - luabind::value("undispellable", static_cast(UNDISPELLABLE)), - luabind::value("immune_melee", static_cast(IMMUNE_MELEE)), - luabind::value("immune_magic", static_cast(IMMUNE_MAGIC)), - luabind::value("immune_fleeing", static_cast(IMMUNE_FLEEING)), - luabind::value("immune_melee_except_bane", static_cast(IMMUNE_MELEE_EXCEPT_BANE)), - luabind::value("immune_melee_except_magical", static_cast(IMMUNE_MELEE_NONMAGICAL)), - luabind::value("immune_aggro", static_cast(IMMUNE_AGGRO)), - luabind::value("immune_aggro_on", static_cast(IMMUNE_AGGRO_ON)), - luabind::value("immune_casting_from_range", static_cast(IMMUNE_CASTING_FROM_RANGE)), - luabind::value("immune_feign_death", static_cast(IMMUNE_FEIGN_DEATH)), - luabind::value("immune_taunt", static_cast(IMMUNE_TAUNT)), - luabind::value("tunnelvision", static_cast(NPC_TUNNELVISION)), - luabind::value("dont_buff_friends", static_cast(NPC_NO_BUFFHEAL_FRIENDS)), - luabind::value("immune_pacify", static_cast(IMMUNE_PACIFY)), - luabind::value("leash", static_cast(LEASH)), - luabind::value("tether", static_cast(TETHER)), - luabind::value("destructible_object", static_cast(DESTRUCTIBLE_OBJECT)), - luabind::value("no_harm_from_client", static_cast(NO_HARM_FROM_CLIENT)), - luabind::value("always_flee", static_cast(ALWAYS_FLEE)), - luabind::value("flee_percent", static_cast(FLEE_PERCENT)), - luabind::value("allow_beneficial", static_cast(ALLOW_BENEFICIAL)), - luabind::value("disable_melee", static_cast(DISABLE_MELEE)), - luabind::value("npc_chase_distance", static_cast(NPC_CHASE_DISTANCE)), - luabind::value("allow_to_tank", static_cast(ALLOW_TO_TANK)), - luabind::value("ignore_root_aggro_rules", static_cast(IGNORE_ROOT_AGGRO_RULES)), - luabind::value("casting_resist_diff", static_cast(CASTING_RESIST_DIFF)), - luabind::value("counter_avoid_damage", static_cast(COUNTER_AVOID_DAMAGE)), - luabind::value("immune_ranged_attacks", static_cast(IMMUNE_RANGED_ATTACKS)), - luabind::value("immune_damage_client", static_cast(IMMUNE_DAMAGE_CLIENT)), - luabind::value("immune_damage_npc", static_cast(IMMUNE_DAMAGE_NPC)), - luabind::value("immune_aggro_client", static_cast(IMMUNE_AGGRO_CLIENT)), - luabind::value("immune_aggro_npc", static_cast(IMMUNE_AGGRO_NPC)) - ]; + + .enum_("constants") + [ + luabind::value("summon", static_cast(SPECATK_SUMMON)), + luabind::value("enrage", static_cast(SPECATK_ENRAGE)), + luabind::value("rampage", static_cast(SPECATK_RAMPAGE)), + luabind::value("area_rampage", static_cast(SPECATK_AREA_RAMPAGE)), + luabind::value("flurry", static_cast(SPECATK_FLURRY)), + luabind::value("triple_attack", static_cast(SPECATK_TRIPLE)), + luabind::value("quad_attack", static_cast(SPECATK_QUAD)), + luabind::value("innate_dual_wield", static_cast(SPECATK_INNATE_DW)), + luabind::value("bane_attack", static_cast(SPECATK_BANE)), + luabind::value("magical_attack", static_cast(SPECATK_MAGICAL)), + luabind::value("ranged_attack", static_cast(SPECATK_RANGED_ATK)), + luabind::value("unslowable", static_cast(UNSLOWABLE)), + luabind::value("unmezable", static_cast(UNMEZABLE)), + luabind::value("uncharmable", static_cast(UNCHARMABLE)), + luabind::value("unstunable", static_cast(UNSTUNABLE)), + luabind::value("unsnareable", static_cast(UNSNAREABLE)), + luabind::value("unfearable", static_cast(UNFEARABLE)), + luabind::value("undispellable", static_cast(UNDISPELLABLE)), + luabind::value("immune_melee", static_cast(IMMUNE_MELEE)), + luabind::value("immune_magic", static_cast(IMMUNE_MAGIC)), + luabind::value("immune_fleeing", static_cast(IMMUNE_FLEEING)), + luabind::value("immune_melee_except_bane", static_cast(IMMUNE_MELEE_EXCEPT_BANE)), + luabind::value("immune_melee_except_magical", static_cast(IMMUNE_MELEE_NONMAGICAL)), + luabind::value("immune_aggro", static_cast(IMMUNE_AGGRO)), + luabind::value("immune_aggro_on", static_cast(IMMUNE_AGGRO_ON)), + luabind::value("immune_casting_from_range", static_cast(IMMUNE_CASTING_FROM_RANGE)), + luabind::value("immune_feign_death", static_cast(IMMUNE_FEIGN_DEATH)), + luabind::value("immune_taunt", static_cast(IMMUNE_TAUNT)), + luabind::value("tunnelvision", static_cast(NPC_TUNNELVISION)), + luabind::value("dont_buff_friends", static_cast(NPC_NO_BUFFHEAL_FRIENDS)), + luabind::value("immune_pacify", static_cast(IMMUNE_PACIFY)), + luabind::value("leash", static_cast(LEASH)), + luabind::value("tether", static_cast(TETHER)), + luabind::value("destructible_object", static_cast(DESTRUCTIBLE_OBJECT)), + luabind::value("no_harm_from_client", static_cast(NO_HARM_FROM_CLIENT)), + luabind::value("always_flee", static_cast(ALWAYS_FLEE)), + luabind::value("flee_percent", static_cast(FLEE_PERCENT)), + luabind::value("allow_beneficial", static_cast(ALLOW_BENEFICIAL)), + luabind::value("disable_melee", static_cast(DISABLE_MELEE)), + luabind::value("npc_chase_distance", static_cast(NPC_CHASE_DISTANCE)), + luabind::value("allow_to_tank", static_cast(ALLOW_TO_TANK)), + luabind::value("ignore_root_aggro_rules", static_cast(IGNORE_ROOT_AGGRO_RULES)), + luabind::value("casting_resist_diff", static_cast(CASTING_RESIST_DIFF)), + luabind::value("counter_avoid_damage", static_cast(COUNTER_AVOID_DAMAGE)), + luabind::value("immune_ranged_attacks", static_cast(IMMUNE_RANGED_ATTACKS)), + luabind::value("immune_damage_client", static_cast(IMMUNE_DAMAGE_CLIENT)), + luabind::value("immune_damage_npc", static_cast(IMMUNE_DAMAGE_NPC)), + luabind::value("immune_aggro_client", static_cast(IMMUNE_AGGRO_CLIENT)), + luabind::value("immune_aggro_npc", static_cast(IMMUNE_AGGRO_NPC)), + luabind::value("modify_avoid_damage", static_cast(MODIFY_AVOID_DAMAGE)) + ]; } #endif