From 8787c00ca3eda49410cf9ecf2df53c2061628afd Mon Sep 17 00:00:00 2001 From: megamage Date: Thu, 5 Mar 2009 18:48:56 -0600 Subject: *Disable charmed/possessed creature AI. *Use general react states to replace charminfo react states. --HG-- branch : trunk --- src/game/Unit.cpp | 66 ++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 46 insertions(+), 20 deletions(-) (limited to 'src/game/Unit.cpp') diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index bb0229aeef5..0fb9426870a 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -149,7 +149,7 @@ bool IsPassiveStackableSpell( uint32 spellId ) Unit::Unit() : WorldObject(), i_motionMaster(this), m_ThreatManager(this), m_HostilRefManager(this) -, m_IsInNotifyList(false), m_Notified(false), m_AI_enabled(false) +, m_IsInNotifyList(false), m_Notified(false), IsAIEnabled(false) { m_objectType |= TYPEMASK_UNIT; m_objectTypeId = TYPEID_UNIT; @@ -627,7 +627,7 @@ uint32 Unit::DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDa } //Script Event damage taken - if( pVictim->GetTypeId()== TYPEID_UNIT && ((Creature *)pVictim)->AI() ) + if( pVictim->GetTypeId()== TYPEID_UNIT && ((Creature *)pVictim)->IsAIEnabled ) { ((Creature *)pVictim)->AI()->DamageTaken(this, damage); @@ -778,7 +778,7 @@ uint32 Unit::DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDa if(!getVictim()) /*{ // if have target and damage pVictim just call AI reaction - if(pVictim != getVictim() && pVictim->GetTypeId()==TYPEID_UNIT && ((Creature*)pVictim)->AI()) + if(pVictim != getVictim() && pVictim->GetTypeId()==TYPEID_UNIT && ((Creature*)pVictim)->IsAIEnabled) ((Creature*)pVictim)->AI()->AttackedBy(this); } else*/ @@ -8283,7 +8283,7 @@ bool Unit::Attack(Unit *victim, bool meleeAttack) m_attacking = victim; m_attacking->_addAttacker(this); - //if(m_attacking->GetTypeId()==TYPEID_UNIT && ((Creature*)m_attacking)->AI()) + //if(m_attacking->GetTypeId()==TYPEID_UNIT && ((Creature*)m_attacking)->IsAIEnabled) // ((Creature*)m_attacking)->AI()->AttackedBy(this); if(GetTypeId()==TYPEID_UNIT) @@ -9831,7 +9831,7 @@ void Unit::CombatStart(Unit* target) target->SetStandState(PLAYER_STATE_NONE); if(!target->isInCombat() && target->GetTypeId() != TYPEID_PLAYER - && !((Creature*)target)->HasReactState(REACT_PASSIVE) && ((Creature*)target)->AI()) + && !((Creature*)target)->HasReactState(REACT_PASSIVE) && ((Creature*)target)->IsAIEnabled) ((Creature*)target)->AI()->AttackStart(this); SetInCombatWith(target); @@ -10454,7 +10454,7 @@ void Unit::TauntApply(Unit* taunter) return; SetInFront(taunter); - if (((Creature*)this)->AI()) + if (((Creature*)this)->IsAIEnabled) ((Creature*)this)->AI()->AttackStart(taunter); m_ThreatManager.tauntApply(taunter); @@ -10478,7 +10478,7 @@ void Unit::TauntFadeOut(Unit *taunter) if(m_ThreatManager.isThreatListEmpty()) { - if(((Creature*)this)->AI()) + if(((Creature*)this)->IsAIEnabled) ((Creature*)this)->AI()->EnterEvadeMode(); return; } @@ -10489,7 +10489,7 @@ void Unit::TauntFadeOut(Unit *taunter) if (target && target != taunter) { SetInFront(target); - if (((Creature*)this)->AI()) + if (((Creature*)this)->IsAIEnabled) ((Creature*)this)->AI()->AttackStart(target); } } @@ -11225,21 +11225,43 @@ void Unit::CleanupsBeforeDelete() RemoveFromWorld(); } -CharmInfo* Unit::InitCharmInfo(Unit *charm) +CharmInfo* Unit::InitCharmInfo() { if(!m_charmInfo) - m_charmInfo = new CharmInfo(charm); + m_charmInfo = new CharmInfo(this); return m_charmInfo; } +void Unit::DeleteCharmInfo() +{ + if(!m_charmInfo) + return; + + delete m_charmInfo; + m_charmInfo = NULL; +} + CharmInfo::CharmInfo(Unit* unit) -: m_unit(unit), m_CommandState(COMMAND_FOLLOW), m_reactState(REACT_PASSIVE), m_petnumber(0), m_barInit(false) +: m_unit(unit), m_CommandState(COMMAND_FOLLOW), m_petnumber(0), m_barInit(false) { for(int i =0; i<4; ++i) { m_charmspells[i].spellId = 0; m_charmspells[i].active = ACT_DISABLED; } + if(m_unit->GetTypeId() == TYPEID_UNIT) + { + m_oldReactState = ((Creature*)m_unit)->GetReactState(); + ((Creature*)m_unit)->SetReactState(REACT_PASSIVE); + } +} + +CharmInfo::~CharmInfo() +{ + if(m_unit->GetTypeId() == TYPEID_UNIT) + { + ((Creature*)m_unit)->SetReactState(m_oldReactState); + } } void CharmInfo::InitPetActionBar() @@ -12084,7 +12106,7 @@ void Unit::SetFeared(bool apply, uint64 casterGUID, uint32 spellID) // attack caster if can Unit* caster = ObjectAccessor::GetObjectInWorld(casterGUID, (Unit*)NULL); - if(caster && caster != getVictim() && ((Creature*)this)->AI()) + if(caster && caster != getVictim() && ((Creature*)this)->IsAIEnabled) ((Creature*)this)->AI()->AttackStart(caster); } } @@ -12768,7 +12790,7 @@ void Unit::Kill(Unit *pVictim, bool durabilityLoss) ((Player*)pVictim)->GetSession()->SendPacket(&data); } // Call KilledUnit for creatures - if (GetTypeId() == TYPEID_UNIT && ((Creature*)this)->AI()) + if (GetTypeId() == TYPEID_UNIT && ((Creature*)this)->IsAIEnabled) ((Creature*)this)->AI()->KilledUnit(pVictim); // last damage from non duel opponent or opponent controlled creature @@ -12791,11 +12813,11 @@ void Unit::Kill(Unit *pVictim, bool durabilityLoss) } // Call KilledUnit for creatures, this needs to be called after the lootable flag is set - if (GetTypeId() == TYPEID_UNIT && ((Creature*)this)->AI()) + if (GetTypeId() == TYPEID_UNIT && ((Creature*)this)->IsAIEnabled) ((Creature*)this)->AI()->KilledUnit(pVictim); // Call creature just died function - if (cVictim->AI()) + if (cVictim->IsAIEnabled) cVictim->AI()->JustDied(this); // Dungeon specific stuff, only applies to players killing creatures @@ -13059,7 +13081,7 @@ void Unit::SetCharmedOrPossessedBy(Unit* charmer, bool possess) if(GetTypeId() == TYPEID_UNIT) { - ((Creature*)this)->InitPossessedAI(); + ((Creature*)this)->AI()->OnCharmed(true); StopMoving(); GetMotionMaster()->Clear(false); GetMotionMaster()->MoveIdle(); @@ -13074,8 +13096,7 @@ void Unit::SetCharmedOrPossessedBy(Unit* charmer, bool possess) // Pets already have a properly initialized CharmInfo, don't overwrite it. if(GetTypeId() == TYPEID_PLAYER || GetTypeId() == TYPEID_UNIT && !((Creature*)this)->isPet()) { - CharmInfo *charmInfo = InitCharmInfo(this); - charmInfo->SetReactState(REACT_DEFENSIVE); + CharmInfo *charmInfo = InitCharmInfo(); if(possess) charmInfo->InitPossessCreateSpells(); else @@ -13145,8 +13166,8 @@ void Unit::RemoveCharmedOrPossessedBy(Unit *charmer) if(!((Creature*)this)->isPet()) RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP_ATTACKABLE); - ((Creature*)this)->DisablePossessedAI(); - if(isAlive() && ((Creature*)this)->AI()) + ((Creature*)this)->AI()->OnCharmed(false); + if(isAlive() && ((Creature*)this)->IsAIEnabled) { if(charmer && !IsFriendlyTo(charmer)) { @@ -13192,6 +13213,11 @@ void Unit::RemoveCharmedOrPossessedBy(Unit *charmer) } } + if(GetTypeId() == TYPEID_PLAYER || GetTypeId() == TYPEID_UNIT && !((Creature*)this)->isPet()) + { + DeleteCharmInfo(); + } + if(possess || charmer->GetTypeId() == TYPEID_PLAYER) { // Remove pet spell action bar -- cgit v1.2.3 From 0b9d3f95de06da9e23bdd075a286679395dab49c Mon Sep 17 00:00:00 2001 From: QAston Date: Fri, 6 Mar 2009 19:58:02 +0100 Subject: *Apply Savage fury also to mangle's bleeding effects. --HG-- branch : trunk --- sql/updates/1159_world.sql | 10 ++++++++++ src/game/Unit.cpp | 5 +++++ 2 files changed, 15 insertions(+) create mode 100644 sql/updates/1159_world.sql (limited to 'src/game/Unit.cpp') diff --git a/sql/updates/1159_world.sql b/sql/updates/1159_world.sql new file mode 100644 index 00000000000..b237e0422c4 --- /dev/null +++ b/sql/updates/1159_world.sql @@ -0,0 +1,10 @@ +DELETE from `spell_affect` where entry=16999; +DELETE from `spell_affect` where entry=16998; +INSERT INTO `spell_affect` VALUES (16998, 0, 0x40000001000); +INSERT INTO `spell_affect` VALUES (16998, 1, 0x40000001000); +INSERT INTO `spell_affect` VALUES (16998, 2, 0x40000001000); +INSERT INTO `spell_affect` VALUES (16999, 0, 0x40000001000); +INSERT INTO `spell_affect` VALUES (16999, 1, 0x40000001000); +INSERT INTO `spell_affect` VALUES (16999, 2, 0x40000001000); + + diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index 0fb9426870a..a3fc2400208 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -8703,6 +8703,7 @@ uint32 Unit::SpellDamageBonus(Unit *pVictim, SpellEntry const *spellProto, uint3 } } + bool hasmangle=false; // .. taken pct: dummy auras AuraList const& mDummyAuras = pVictim->GetAurasByType(SPELL_AURA_DUMMY); for(AuraList::const_iterator i = mDummyAuras.begin(); i != mDummyAuras.end(); ++i) @@ -8725,6 +8726,10 @@ uint32 Unit::SpellDamageBonus(Unit *pVictim, SpellEntry const *spellProto, uint3 //Mangle case 2312: case 44955: + // don't apply mod twice + if (hasmangle) + break; + hasmangle=true; for(int j=0;j<3;j++) { if(GetEffectMechanic(spellProto, j)==MECHANIC_BLEED) -- cgit v1.2.3