From 5ffb6bdee7840ec0f6506b90afa14ddb6825c857 Mon Sep 17 00:00:00 2001 From: "Michael Cook (mackal)" Date: Mon, 29 Sep 2014 16:32:48 -0400 Subject: [PATCH] Reworked blind running around This should be more in line with how we do current fearpath stuff and with live. --- zone/bonuses.cpp | 12 +++++++-- zone/common.h | 1 + zone/fearpath.cpp | 55 ++++++++++++++---------------------------- zone/mob.cpp | 1 - zone/mob.h | 2 +- zone/mob_ai.cpp | 8 +++--- zone/spell_effects.cpp | 7 +++--- 7 files changed, 39 insertions(+), 47 deletions(-) diff --git a/zone/bonuses.cpp b/zone/bonuses.cpp index d3d4f03f4..89af2a244 100644 --- a/zone/bonuses.cpp +++ b/zone/bonuses.cpp @@ -2472,7 +2472,7 @@ void Mob::ApplySpellsBonuses(uint16 spell_id, uint8 casterlevel, StatBonuses* ne } break; } - + case SE_ManaAbsorbPercentDamage: { if (newbon->ManaAbsorbPercentDamage[0] < effect_value){ @@ -2493,7 +2493,7 @@ void Mob::ApplySpellsBonuses(uint16 spell_id, uint8 casterlevel, StatBonuses* ne case SE_ShieldBlock: newbon->ShieldBlock += effect_value; break; - + case SE_ShieldEquipHateMod: newbon->ShieldEquipHateMod += effect_value; break; @@ -2507,6 +2507,10 @@ void Mob::ApplySpellsBonuses(uint16 spell_id, uint8 casterlevel, StatBonuses* ne newbon->BlockBehind += effect_value; break; + case SE_Blind: + newbon->IsBlind = true; + break; + case SE_Fear: newbon->IsFeared = true; break; @@ -4086,6 +4090,10 @@ void Mob::NegateSpellsBonuses(uint16 spell_id) itembonuses.BlockBehind = effect_value; break; + case SE_Blind: + spellbonuses.IsBlind = false; + break; + case SE_Fear: spellbonuses.IsFeared = false; break; diff --git a/zone/common.h b/zone/common.h index 0dbb68e0b..fb56b3f01 100644 --- a/zone/common.h +++ b/zone/common.h @@ -294,6 +294,7 @@ struct StatBonuses { int16 ResistFearChance; //i bool Fearless; //i bool IsFeared; //i + bool IsBlind; //i int16 StunResist; //i int16 MeleeSkillCheck; //i uint8 MeleeSkillCheckSkill; diff --git a/zone/fearpath.cpp b/zone/fearpath.cpp index 592fa2090..47fc53a96 100644 --- a/zone/fearpath.cpp +++ b/zone/fearpath.cpp @@ -31,12 +31,10 @@ #define snprintf _snprintf #endif - extern Zone* zone; #define FEAR_PATHING_DEBUG - //this is called whenever we are damaged to process possible fleeing void Mob::CheckFlee() { //if were allready fleeing, dont need to check more... @@ -55,7 +53,7 @@ void Mob::CheckFlee() { float ratio = GetHPRatio(); float fleeratio = GetSpecialAbility(FLEE_PERCENT); fleeratio = fleeratio > 0 ? fleeratio : RuleI(Combat, FleeHPRatio); - + if(ratio >= fleeratio) return; @@ -101,12 +99,13 @@ void Mob::CheckFlee() { } } - -void Mob::ProcessFlee() { +void Mob::ProcessFlee() +{ //Stop fleeing if effect is applied after they start to run. //When ImmuneToFlee effect fades it will turn fear back on and check if it can still flee. - if(flee_mode && (GetSpecialAbility(IMMUNE_FLEEING) || spellbonuses.ImmuneToFlee) && !spellbonuses.IsFeared){ + if (flee_mode && (GetSpecialAbility(IMMUNE_FLEEING) || spellbonuses.ImmuneToFlee) && + !spellbonuses.IsFeared && !spellbonuses.IsBlind) { curfp = false; return; } @@ -114,46 +113,42 @@ void Mob::ProcessFlee() { //see if we are still dying, if so, do nothing float fleeratio = GetSpecialAbility(FLEE_PERCENT); fleeratio = fleeratio > 0 ? fleeratio : RuleI(Combat, FleeHPRatio); - if(GetHPRatio() < fleeratio) + if (GetHPRatio() < fleeratio) return; //we are not dying anymore... see what we do next flee_mode = false; - //see if we are legitimately feared now - if(!spellbonuses.IsFeared) { - //not feared... were done... + //see if we are legitimately feared or blind now + if (!spellbonuses.IsFeared && !spellbonuses.IsBlind) { + //not feared or blind... were done... curfp = false; return; } } -float Mob::GetFearSpeed() { - if(flee_mode || is_blind) { +float Mob::GetFearSpeed() +{ + if (flee_mode) { //we know ratio < FLEE_HP_RATIO float speed = GetBaseRunspeed(); float ratio = GetHPRatio(); float multiplier = RuleR(Combat, FleeMultiplier); - if(GetSnaredAmount() > 40) + if (GetSnaredAmount() > 40) multiplier = multiplier / 6.0f; speed = speed * ratio * multiplier / 100; - // A blinded mob should be pretty slow when running amuck. - if (is_blind) - { - speed = speed/3.0; - } - //NPC will eventually stop. Snares speeds this up. - if(speed < 0.09) + if (speed < 0.09) speed = 0.0001f; - - return(speed); + + return speed; } - return(GetRunspeed()); + // fear and blind use their normal run speed + return GetRunspeed(); } void Mob::CalculateNewFearpoint() @@ -215,17 +210,3 @@ void Mob::CalculateNewFearpoint() } } - - - - - - - - - - - - - - diff --git a/zone/mob.cpp b/zone/mob.cpp index 7eb967428..2441ca0bc 100644 --- a/zone/mob.cpp +++ b/zone/mob.cpp @@ -114,7 +114,6 @@ Mob::Mob(const char* in_name, fear_walkto_y = -999999; fear_walkto_z = -999999; curfp = false; - is_blind = false; AI_Init(); SetMoving(false); diff --git a/zone/mob.h b/zone/mob.h index 66c2a8711..352a610eb 100644 --- a/zone/mob.h +++ b/zone/mob.h @@ -768,6 +768,7 @@ public: inline void StartFleeing() { flee_mode = true; CalculateNewFearpoint(); } void ProcessFlee(); void CheckFlee(); + inline bool IsBlind() { return spellbonuses.IsBlind; } inline bool CheckAggro(Mob* other) {return hate_list.IsOnHateList(other);} float CalculateHeadingToTarget(float in_x, float in_y); @@ -1190,7 +1191,6 @@ protected: float fear_walkto_y; float fear_walkto_z; bool curfp; - bool is_blind; // Pathing // diff --git a/zone/mob_ai.cpp b/zone/mob_ai.cpp index d1dc18d5d..5f8ea2c11 100644 --- a/zone/mob_ai.cpp +++ b/zone/mob_ai.cpp @@ -1039,8 +1039,8 @@ void Mob::AI_Process() { // Begin: Additions for Wiz Fear Code // if(RuleB(Combat, EnableFearPathing)){ - if(curfp || (is_blind && !CombatRange(hate_list.GetClosest(this)))) { - if(IsRooted()) { + if(curfp) { + if(IsRooted() || (IsBlind() && CombatRange(hate_list.GetClosest(this)))) { //make sure everybody knows were not moving, for appearance sake if(IsMoving()) { @@ -1087,7 +1087,9 @@ void Mob::AI_Process() { if (engaged) { - if (IsRooted() || is_blind) + // we are prevented from getting here if we are blind and don't have a target in range + // from above, so no extra blind checks needed + if (IsRooted() || IsBlind()) SetTarget(hate_list.GetClosest(this)); else { diff --git a/zone/spell_effects.cpp b/zone/spell_effects.cpp index 42a1edb65..f5509ece2 100644 --- a/zone/spell_effects.cpp +++ b/zone/spell_effects.cpp @@ -1270,8 +1270,8 @@ bool Mob::SpellEffect(Mob* caster, uint16 spell_id, float partial) // this should catch the cures if (BeneficialSpell(spell_id) && spells[spell_id].buffduration == 0) BuffFadeByEffect(SE_Blind); - else - is_blind = true; + else if (!IsClient()) + CalculateNewFearpoint(); break; } @@ -3997,7 +3997,8 @@ void Mob::BuffFadeBySlot(int slot, bool iRecalcBonuses) } case SE_Blind: - is_blind = false; + if (curfp && !FindType(SE_Fear)) + curfp = false; break; case SE_Fear: