*Fix snake trap.

--HG--
branch : trunk
This commit is contained in:
QAston
2009-07-09 17:02:29 +02:00
parent 0687722812
commit 5206cd8a4e
2 changed files with 13 additions and 22 deletions
@@ -1467,17 +1467,14 @@ struct TRINITY_DLL_DECL npc_snake_trap_serpentsAI : public ScriptedAI
npc_snake_trap_serpentsAI(Creature *c) : ScriptedAI(c) {} npc_snake_trap_serpentsAI(Creature *c) : ScriptedAI(c) {}
uint32 SpellTimer; uint32 SpellTimer;
Unit *Owner;
bool IsViper; bool IsViper;
bool Spawn;
void EnterCombat(Unit *who) {} void EnterCombat(Unit *who) {}
void Reset() void Reset()
{ {
Owner = m_creature->GetOwner(); Spawn = true;
if (!m_creature->isPet() || !Owner)
return;
CreatureInfo const *Info = m_creature->GetCreatureInfo(); CreatureInfo const *Info = m_creature->GetCreatureInfo();
@@ -1499,10 +1496,7 @@ struct TRINITY_DLL_DECL npc_snake_trap_serpentsAI : public ScriptedAI
//Redefined for random target selection: //Redefined for random target selection:
void MoveInLineOfSight(Unit *who) void MoveInLineOfSight(Unit *who)
{ {
if (!m_creature->isPet() || !Owner) if( !m_creature->getVictim() && who->isTargetableForAttack() && ( m_creature->IsHostileTo( who )) && who->isInAccessiblePlaceFor(m_creature))
return;
if( !m_creature->getVictim() && who->isTargetableForAttack() && ( m_creature->IsHostileTo( who )) && who->isInAccessiblePlaceFor(m_creature) && Owner->IsHostileTo(who))//don't attack not-pvp-flaged
{ {
if (m_creature->GetDistanceZ(who) > CREATURE_Z_ATTACK_RANGE) if (m_creature->GetDistanceZ(who) > CREATURE_Z_ATTACK_RANGE)
return; return;
@@ -1522,25 +1516,20 @@ struct TRINITY_DLL_DECL npc_snake_trap_serpentsAI : public ScriptedAI
void UpdateAI(const uint32 diff) void UpdateAI(const uint32 diff)
{ {
if (!m_creature->isPet() || !Owner) if(Spawn)
return;
//Follow if not in combat
if (!m_creature->hasUnitState(UNIT_STAT_FOLLOW)&& !m_creature->isInCombat())
{ {
m_creature->GetMotionMaster()->Clear(); Spawn = false;
m_creature->GetMotionMaster()->MoveFollow(Owner,PET_FOLLOW_DIST,PET_FOLLOW_ANGLE); // Start attacking attacker of owner on first ai update after spawn - move in line of sight may choose better target
if (!m_creature->getVictim() && m_creature->isSummon())
if (Unit * Owner = ((TempSummon*)m_creature)->GetSummoner())
if(Owner->getAttackerForHelper())
AttackStart(Owner->getAttackerForHelper());
} }
//No victim -> get new from owner (need this because MoveInLineOfSight won't work while following -> corebug)
if (!m_creature->getVictim()) if (!m_creature->getVictim())
{ {
if (m_creature->isInCombat()) if (m_creature->isInCombat())
DoStopAttack(); DoStopAttack();
if(Owner->getAttackerForHelper())
AttackStart(Owner->getAttackerForHelper());
return; return;
} }
+3 -1
View File
@@ -3468,7 +3468,9 @@ void Spell::EffectSummonType(uint32 i)
TempSummonType summonType = (duration == 0) ? TEMPSUMMON_DEAD_DESPAWN : TEMPSUMMON_TIMED_DESPAWN; TempSummonType summonType = (duration == 0) ? TEMPSUMMON_DEAD_DESPAWN : TEMPSUMMON_TIMED_DESPAWN;
m_originalCaster->SummonCreature(entry,px,py,pz,m_caster->GetOrientation(),summonType,duration); TempSummon * summon = m_originalCaster->SummonCreature(entry,px,py,pz,m_caster->GetOrientation(),summonType,duration);
if (properties->Category == SUMMON_CATEGORY_ALLY)
summon->setFaction(m_caster->getFaction());
} }
break; break;
} }