diff options
-rw-r--r-- | src/server/game/AI/SmartScripts/SmartAI.cpp | 3 | ||||
-rw-r--r-- | src/server/game/AI/SmartScripts/SmartAI.h | 3 | ||||
-rw-r--r-- | src/server/game/AI/SmartScripts/SmartScript.cpp | 10 | ||||
-rw-r--r-- | src/server/game/AI/SmartScripts/SmartScript.h | 1 |
4 files changed, 13 insertions, 4 deletions
diff --git a/src/server/game/AI/SmartScripts/SmartAI.cpp b/src/server/game/AI/SmartScripts/SmartAI.cpp index d4b2a9746be..07a8e3fdca7 100644 --- a/src/server/game/AI/SmartScripts/SmartAI.cpp +++ b/src/server/game/AI/SmartScripts/SmartAI.cpp @@ -68,6 +68,7 @@ SmartAI::SmartAI(Creature* c) : CreatureAI(c) mFollowCredit = 0; mFollowArrivedEntry = 0; mFollowCreditType = 0; + mInvinceabilityHpLevel = 0; } void SmartAI::UpdateDespawn(const uint32 diff) @@ -637,6 +638,8 @@ void SmartAI::SpellHitTarget(Unit* target, const SpellInfo* spellInfo) void SmartAI::DamageTaken(Unit* doneBy, uint32& damage) { GetScript()->ProcessEventsFor(SMART_EVENT_DAMAGED, doneBy, damage); + if ((me->GetHealth() - damage) <= mInvinceabilityHpLevel) + damage -= mInvinceabilityHpLevel; } void SmartAI::HealReceived(Unit* doneBy, uint32& addhealth) diff --git a/src/server/game/AI/SmartScripts/SmartAI.h b/src/server/game/AI/SmartScripts/SmartAI.h index 0576612a155..a40254fe384 100644 --- a/src/server/game/AI/SmartScripts/SmartAI.h +++ b/src/server/game/AI/SmartScripts/SmartAI.h @@ -175,6 +175,8 @@ class SmartAI : public CreatureAI void SetSwim(bool swim = true); + void SetInvinceabilityHpLevel(uint32 level) { mInvinceabilityHpLevel = level; } + void sGossipHello(Player* player); void sGossipSelect(Player* player, uint32 sender, uint32 action); void sGossipSelectCode(Player* player, uint32 sender, uint32 action, const char* code); @@ -222,6 +224,7 @@ class SmartAI : public CreatureAI bool mCanAutoAttack; bool mCanCombatMove; bool mForcedPaused; + uint32 mInvinceabilityHpLevel; bool AssistPlayerInCombat(Unit* who); diff --git a/src/server/game/AI/SmartScripts/SmartScript.cpp b/src/server/game/AI/SmartScripts/SmartScript.cpp index 3c0bdfcade7..2b32946da17 100644 --- a/src/server/game/AI/SmartScripts/SmartScript.cpp +++ b/src/server/game/AI/SmartScripts/SmartScript.cpp @@ -39,7 +39,6 @@ SmartScript::SmartScript() go = NULL; me = NULL; mEventPhase = 0; - mInvinceabilityHpLevel = 0; mPathId = 0; mTargetStorage = new ObjectListMap(); mStoredEvents.clear(); @@ -992,10 +991,15 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u if (!me) break; + SmartAI* ai = CAST_AI(SmartAI, me->AI()); + + if (!ai) + break; + if (e.action.invincHP.percent) - mInvinceabilityHpLevel = me->CountPctFromMaxHealth(e.action.invincHP.percent); + ai->SetInvinceabilityHpLevel(me->CountPctFromMaxHealth(e.action.invincHP.percent)); else - mInvinceabilityHpLevel = e.action.invincHP.minHP; + ai->SetInvinceabilityHpLevel(e.action.invincHP.minHP); break; } case SMART_ACTION_SET_DATA: diff --git a/src/server/game/AI/SmartScripts/SmartScript.h b/src/server/game/AI/SmartScripts/SmartScript.h index f55d91ed52f..fec38a690ed 100644 --- a/src/server/game/AI/SmartScripts/SmartScript.h +++ b/src/server/game/AI/SmartScripts/SmartScript.h @@ -236,7 +236,6 @@ class SmartScript SmartScriptType mScriptType; uint32 mEventPhase; - uint32 mInvinceabilityHpLevel; UNORDERED_MAP<int32, int32> mStoredDecimals; uint32 mPathId; SmartAIEventList mStoredEvents; |