*Update some script functions.
--HG-- branch : trunk
This commit is contained in:
@@ -17,13 +17,26 @@ struct TSpellSummary {
|
|||||||
uint8 Effects; // set of enum SelectEffect
|
uint8 Effects; // set of enum SelectEffect
|
||||||
} *SpellSummary;
|
} *SpellSummary;
|
||||||
|
|
||||||
|
void SummonList::DoZoneInCombat(uint32 entry)
|
||||||
|
{
|
||||||
|
for(iterator i = begin(); i != end();)
|
||||||
|
{
|
||||||
|
Creature *summon = Unit::GetCreature(*m_creature, *i);
|
||||||
|
++i;
|
||||||
|
if(summon && summon->IsAIEnabled
|
||||||
|
&& (!entry || summon->GetEntry() == entry))
|
||||||
|
summon->AI()->DoZoneInCombat();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void SummonList::DoAction(uint32 entry, uint32 info)
|
void SummonList::DoAction(uint32 entry, uint32 info)
|
||||||
{
|
{
|
||||||
for(iterator i = begin(); i != end();)
|
for(iterator i = begin(); i != end();)
|
||||||
{
|
{
|
||||||
Creature *summon = Unit::GetCreature(*m_creature, *i);
|
Creature *summon = Unit::GetCreature(*m_creature, *i);
|
||||||
++i;
|
++i;
|
||||||
if(summon && summon->IsAIEnabled)
|
if(summon && summon->IsAIEnabled
|
||||||
|
&& (!entry || summon->GetEntry() == entry))
|
||||||
summon->AI()->DoAction(info);
|
summon->AI()->DoAction(info);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -213,6 +226,19 @@ Creature* ScriptedAI::DoSpawnCreature(uint32 id, float x, float y, float z, floa
|
|||||||
return m_creature->SummonCreature(id,m_creature->GetPositionX() + x,m_creature->GetPositionY() + y,m_creature->GetPositionZ() + z, angle, (TempSummonType)type, despawntime);
|
return m_creature->SummonCreature(id,m_creature->GetPositionX() + x,m_creature->GetPositionY() + y,m_creature->GetPositionZ() + z, angle, (TempSummonType)type, despawntime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Creature *ScriptedAI::DoSummon(uint32 entry, const float pos[4], uint32 despawntime, TempSummonType type)
|
||||||
|
{
|
||||||
|
return me->SummonCreature(entry, pos[0], pos[1], pos[2], pos[3], type, despawntime);
|
||||||
|
}
|
||||||
|
|
||||||
|
Creature *ScriptedAI::DoSummon(uint32 entry, WorldObject *obj, float radius, uint32 despawntime, TempSummonType type)
|
||||||
|
{
|
||||||
|
float x, y, z;
|
||||||
|
obj->GetGroundPointAroundUnit(x, y, z, radius * rand_norm(), rand_norm()*2*M_PI);
|
||||||
|
return me->SummonCreature(entry, x, y, z, me->GetOrientation(), type, despawntime);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Unit* ScriptedAI::SelectUnit(SelectAggroTarget target, uint32 position)
|
Unit* ScriptedAI::SelectUnit(SelectAggroTarget target, uint32 position)
|
||||||
{
|
{
|
||||||
//ThreatList m_threatlist;
|
//ThreatList m_threatlist;
|
||||||
@@ -493,6 +519,11 @@ void ScriptedAI::DoTeleportTo(float x, float y, float z, uint32 time)
|
|||||||
m_creature->SendMonsterMove(x, y, z, time);
|
m_creature->SendMonsterMove(x, y, z, time);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ScriptedAI::DoTeleportTo(const float pos[4])
|
||||||
|
{
|
||||||
|
me->NearTeleportTo(pos[0], pos[1], pos[2], pos[3]);
|
||||||
|
}
|
||||||
|
|
||||||
void ScriptedAI::DoTeleportPlayer(Unit* pUnit, float x, float y, float z, float o)
|
void ScriptedAI::DoTeleportPlayer(Unit* pUnit, float x, float y, float z, float o)
|
||||||
{
|
{
|
||||||
if(!pUnit || pUnit->GetTypeId() != TYPEID_PLAYER)
|
if(!pUnit || pUnit->GetTypeId() != TYPEID_PLAYER)
|
||||||
@@ -642,7 +673,8 @@ void BossAI::_EnterCombat()
|
|||||||
void BossAI::JustSummoned(Creature *summon)
|
void BossAI::JustSummoned(Creature *summon)
|
||||||
{
|
{
|
||||||
summons.Summon(summon);
|
summons.Summon(summon);
|
||||||
DoZoneInCombat(summon);
|
if(me->isInCombat())
|
||||||
|
DoZoneInCombat(summon);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BossAI::SummonedCreatureDespawn(Creature *summon)
|
void BossAI::SummonedCreatureDespawn(Creature *summon)
|
||||||
@@ -667,25 +699,36 @@ void LoadOverridenSQLData()
|
|||||||
goInfo->trap.radius = 50;
|
goInfo->trap.radius = 50;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define SPELL(x) const_cast<SpellEntry*>(GetSpellStore()->LookupEntry(x))
|
|
||||||
|
|
||||||
void LoadOverridenDBCData()
|
void LoadOverridenDBCData()
|
||||||
{
|
{
|
||||||
SpellEntry *spellInfo;
|
SpellEntry *spellInfo;
|
||||||
|
for(uint32 i = 0; i < GetSpellStore()->GetNumRows(); ++i)
|
||||||
// Black Temple : Illidan : Parasitic Shadowfiend Passive
|
|
||||||
if(spellInfo = SPELL(41913))
|
|
||||||
spellInfo->EffectApplyAuraName[0] = 4; // proc debuff, and summon infinite fiends
|
|
||||||
|
|
||||||
//temp, not needed in 310
|
|
||||||
if(spellInfo = SPELL(28531))
|
|
||||||
{
|
{
|
||||||
spellInfo->DurationIndex = 21;
|
spellInfo = (SpellEntry*)GetSpellStore()->LookupEntry(i);
|
||||||
spellInfo->Effect[0] = SPELL_EFFECT_APPLY_AREA_AURA_ENEMY;
|
if(!spellInfo)
|
||||||
}
|
continue;
|
||||||
if(spellInfo = SPELL(55799))
|
|
||||||
{
|
switch(i)
|
||||||
spellInfo->DurationIndex = 21;
|
{
|
||||||
spellInfo->Effect[0] = SPELL_EFFECT_APPLY_AREA_AURA_ENEMY;
|
// Black Temple : Illidan : Parasitic Shadowfiend Passive
|
||||||
|
case 41013:
|
||||||
|
spellInfo->EffectApplyAuraName[0] = 4; // proc debuff, and summon infinite fiends
|
||||||
|
break;
|
||||||
|
//temp, not needed in 310
|
||||||
|
case 28531:
|
||||||
|
case 55799:
|
||||||
|
spellInfo->DurationIndex = 21;
|
||||||
|
spellInfo->Effect[0] = SPELL_EFFECT_APPLY_AREA_AURA_ENEMY;
|
||||||
|
break;
|
||||||
|
// Naxxramas: Gothik : Inform Inf range
|
||||||
|
case 27892:
|
||||||
|
case 27928:
|
||||||
|
case 27935:
|
||||||
|
case 27915:
|
||||||
|
case 27931:
|
||||||
|
case 27937:
|
||||||
|
spellInfo->rangeIndex = 13;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ class SummonList : private std::list<uint64>
|
|||||||
void DespawnEntry(uint32 entry);
|
void DespawnEntry(uint32 entry);
|
||||||
void DespawnAll();
|
void DespawnAll();
|
||||||
void DoAction(uint32 entry, uint32 info);
|
void DoAction(uint32 entry, uint32 info);
|
||||||
|
void DoZoneInCombat(uint32 entry = 0);
|
||||||
private:
|
private:
|
||||||
Creature *m_creature;
|
Creature *m_creature;
|
||||||
};
|
};
|
||||||
@@ -152,6 +153,7 @@ struct TRINITY_DLL_DECL ScriptedAI : public CreatureAI
|
|||||||
void DoModifyThreatPercent(Unit *pUnit, int32 pct);
|
void DoModifyThreatPercent(Unit *pUnit, int32 pct);
|
||||||
|
|
||||||
void DoTeleportTo(float x, float y, float z, uint32 time = 0);
|
void DoTeleportTo(float x, float y, float z, uint32 time = 0);
|
||||||
|
void DoTeleportTo(const float pos[4]);
|
||||||
|
|
||||||
void DoAction(const int32 param) {}
|
void DoAction(const int32 param) {}
|
||||||
|
|
||||||
@@ -170,6 +172,8 @@ struct TRINITY_DLL_DECL ScriptedAI : public CreatureAI
|
|||||||
|
|
||||||
//Spawns a creature relative to m_creature
|
//Spawns a creature relative to m_creature
|
||||||
Creature* DoSpawnCreature(uint32 id, float x, float y, float z, float angle, uint32 type, uint32 despawntime);
|
Creature* DoSpawnCreature(uint32 id, float x, float y, float z, float angle, uint32 type, uint32 despawntime);
|
||||||
|
Creature *DoSummon(uint32 entry, const float pos[4], uint32 despawntime = 30000, TempSummonType type = TEMPSUMMON_CORPSE_TIMED_DESPAWN);
|
||||||
|
Creature *DoSummon(uint32 entry, WorldObject *obj, float radius = 5.0f, uint32 despawntime = 30000, TempSummonType type = TEMPSUMMON_CORPSE_TIMED_DESPAWN);
|
||||||
|
|
||||||
//Selects a unit from the creature's current aggro list
|
//Selects a unit from the creature's current aggro list
|
||||||
Unit* SelectUnit(SelectAggroTarget target, uint32 position);
|
Unit* SelectUnit(SelectAggroTarget target, uint32 position);
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ void SpellAI::UpdateAI(const uint32 diff)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
me->CastSpell(target, spellId, false);
|
if(target) me->CastSpell(target, spellId, false);
|
||||||
events.ScheduleEvent(spellId, AISpellInfo[spellId].cooldown + rand()%AISpellInfo[spellId].cooldown);
|
events.ScheduleEvent(spellId, AISpellInfo[spellId].cooldown + rand()%AISpellInfo[spellId].cooldown);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
+32
-23
@@ -39,6 +39,9 @@ void CreatureAI::DoZoneInCombat(Creature* creature)
|
|||||||
if (!creature)
|
if (!creature)
|
||||||
creature = me;
|
creature = me;
|
||||||
|
|
||||||
|
if(!creature->CanHaveThreatList())
|
||||||
|
return;
|
||||||
|
|
||||||
Map *map = creature->GetMap();
|
Map *map = creature->GetMap();
|
||||||
if (!map->IsDungeon()) //use IsDungeon instead of Instanceable, in case battlegrounds will be instantiated
|
if (!map->IsDungeon()) //use IsDungeon instead of Instanceable, in case battlegrounds will be instantiated
|
||||||
{
|
{
|
||||||
@@ -46,7 +49,7 @@ void CreatureAI::DoZoneInCombat(Creature* creature)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!creature->getVictim())
|
if(!creature->HasReactState(REACT_PASSIVE) && !creature->getVictim())
|
||||||
{
|
{
|
||||||
if(Unit *target = creature->SelectNearestTarget())
|
if(Unit *target = creature->SelectNearestTarget())
|
||||||
creature->AI()->AttackStart(target);
|
creature->AI()->AttackStart(target);
|
||||||
@@ -54,29 +57,30 @@ void CreatureAI::DoZoneInCombat(Creature* creature)
|
|||||||
{
|
{
|
||||||
if(Unit *summoner = ((TempSummon*)creature)->GetSummoner())
|
if(Unit *summoner = ((TempSummon*)creature)->GetSummoner())
|
||||||
{
|
{
|
||||||
if(summoner->getVictim()
|
Unit *target = summoner->getAttackerForHelper();
|
||||||
&& (creature->IsFriendlyTo(summoner) || creature->IsHostileTo(summoner->getVictim())))
|
if(!target && summoner->CanHaveThreatList() && !summoner->getThreatManager().isThreatListEmpty())
|
||||||
creature->AI()->AttackStart(summoner->getVictim());
|
target = summoner->getThreatManager().getHostilTarget();
|
||||||
|
if(target && (creature->IsFriendlyTo(summoner) || creature->IsHostileTo(target)))
|
||||||
|
creature->AI()->AttackStart(target);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!creature->CanHaveThreatList() || !creature->getVictim())
|
if(!creature->HasReactState(REACT_PASSIVE) && !creature->getVictim())
|
||||||
{
|
{
|
||||||
sLog.outError("DoZoneInCombat called for creature that either cannot have threat list or has empty threat list (creature entry = %d)", creature->GetTypeId() == TYPEID_UNIT ? ((Creature*)creature)->GetEntry() : 0);
|
sLog.outError("DoZoneInCombat called for creature that has empty threat list (creature entry = %u)", creature->GetEntry());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Map::PlayerList const &PlayerList = map->GetPlayers();
|
Map::PlayerList const &PlayerList = map->GetPlayers();
|
||||||
for(Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i)
|
for(Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i)
|
||||||
{
|
{
|
||||||
if (Player* i_pl = i->getSource())
|
if (i->getSource()->isAlive())
|
||||||
if (i_pl->isAlive())
|
{
|
||||||
{
|
creature->SetInCombatWith(i->getSource());
|
||||||
creature->SetInCombatWith(i_pl);
|
i->getSource()->SetInCombatWith(creature);
|
||||||
i_pl->SetInCombatWith(creature);
|
creature->AddThreat(i->getSource(), 0.0f);
|
||||||
creature->AddThreat(i_pl, 0.0f);
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -102,10 +106,10 @@ bool CreatureAI::UpdateVictim()
|
|||||||
return me->getVictim();
|
return me->getVictim();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CreatureAI::EnterEvadeMode()
|
bool CreatureAI::_EnterEvadeMode()
|
||||||
{
|
{
|
||||||
if(me->IsInEvadeMode())
|
if(me->IsInEvadeMode() || !me->isAlive())
|
||||||
return;
|
return false;
|
||||||
|
|
||||||
me->RemoveAllAuras();
|
me->RemoveAllAuras();
|
||||||
me->DeleteThreatList();
|
me->DeleteThreatList();
|
||||||
@@ -113,13 +117,18 @@ void CreatureAI::EnterEvadeMode()
|
|||||||
me->LoadCreaturesAddon();
|
me->LoadCreaturesAddon();
|
||||||
me->SetLootRecipient(NULL);
|
me->SetLootRecipient(NULL);
|
||||||
|
|
||||||
if(me->isAlive())
|
return true;
|
||||||
{
|
}
|
||||||
if(Unit *owner = me->GetCharmerOrOwner())
|
|
||||||
me->GetMotionMaster()->MoveFollow(owner, PET_FOLLOW_DIST, PET_FOLLOW_ANGLE, MOTION_SLOT_IDLE);
|
void CreatureAI::EnterEvadeMode()
|
||||||
else
|
{
|
||||||
me->GetMotionMaster()->MoveTargetedHome();
|
if(!_EnterEvadeMode())
|
||||||
}
|
return;
|
||||||
|
|
||||||
|
if(Unit *owner = me->GetCharmerOrOwner())
|
||||||
|
me->GetMotionMaster()->MoveFollow(owner, PET_FOLLOW_DIST, PET_FOLLOW_ANGLE, MOTION_SLOT_IDLE);
|
||||||
|
else
|
||||||
|
me->GetMotionMaster()->MoveTargetedHome();
|
||||||
|
|
||||||
Reset();
|
Reset();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -168,6 +168,9 @@ class TRINITY_DLL_SPEC CreatureAI : public UnitAI
|
|||||||
|
|
||||||
static AISpellInfoType *AISpellInfo;
|
static AISpellInfoType *AISpellInfo;
|
||||||
static void FillAISpellInfo();
|
static void FillAISpellInfo();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool _EnterEvadeMode();
|
||||||
};
|
};
|
||||||
|
|
||||||
enum Permitions
|
enum Permitions
|
||||||
|
|||||||
Reference in New Issue
Block a user