aboutsummaryrefslogtreecommitdiff
path: root/src/bindings/scripts/include
diff options
context:
space:
mode:
Diffstat (limited to 'src/bindings/scripts/include')
-rw-r--r--src/bindings/scripts/include/sc_creature.cpp336
-rw-r--r--src/bindings/scripts/include/sc_creature.h48
2 files changed, 171 insertions, 213 deletions
diff --git a/src/bindings/scripts/include/sc_creature.cpp b/src/bindings/scripts/include/sc_creature.cpp
index 4438f42564f..fe81a68112f 100644
--- a/src/bindings/scripts/include/sc_creature.cpp
+++ b/src/bindings/scripts/include/sc_creature.cpp
@@ -12,7 +12,8 @@
#include "TemporarySummon.h"
// Spell summary for ScriptedAI::SelectSpell
-struct TSpellSummary {
+struct TSpellSummary
+{
uint8 Targets; // set of enum SelectTarget
uint8 Effects; // set of enum SelectEffect
} *SpellSummary;
@@ -84,43 +85,41 @@ ScriptedAI::ScriptedAI(Creature* creature) : CreatureAI(creature), m_creature(cr
HeroicMode = m_creature->GetMap()->IsHeroic();
}
-void ScriptedAI::AttackStartNoMove(Unit* who)
+void ScriptedAI::AttackStartNoMove(Unit* pWho)
{
- if (!who)
+ if (!pWho)
return;
- if(m_creature->Attack(who, false))
- DoStartNoMovement(who);
+ if(m_creature->Attack(pWho, false))
+ DoStartNoMovement(pWho);
}
-void ScriptedAI::UpdateAI(const uint32 diff)
+void ScriptedAI::UpdateAI(const uint32 uiDiff)
{
//Check if we have a current target
- if (UpdateVictim())
+ if (!UpdateVictim())
+ return;
+
+ if (m_creature->isAttackReady())
{
- if (m_creature->isAttackReady())
+ //If we are within range melee the target
+ if (m_creature->IsWithinMeleeRange(m_creature->getVictim()))
{
- //If we are within range melee the target
- if (m_creature->IsWithinMeleeRange(m_creature->getVictim()))
- {
- m_creature->AttackerStateUpdate(m_creature->getVictim());
- m_creature->resetAttackTimer();
- }
+ m_creature->AttackerStateUpdate(m_creature->getVictim());
+ m_creature->resetAttackTimer();
}
}
}
-void ScriptedAI::DoStartMovement(Unit* victim, float distance, float angle)
+void ScriptedAI::DoStartMovement(Unit* pVictim, float fDistance, float fAngle)
{
- if (!victim)
- return;
-
- m_creature->GetMotionMaster()->MoveChase(victim, distance, angle);
+ if (pVictim)
+ m_creature->GetMotionMaster()->MoveChase(pVictim, fDistance, fAngle);
}
-void ScriptedAI::DoStartNoMovement(Unit* victim)
+void ScriptedAI::DoStartNoMovement(Unit* pVictim)
{
- if (!victim)
+ if (!pVictim)
return;
m_creature->GetMotionMaster()->MoveIdle();
@@ -128,50 +127,17 @@ void ScriptedAI::DoStartNoMovement(Unit* victim)
void ScriptedAI::DoStopAttack()
{
- if (m_creature->getVictim() != NULL)
- {
+ if (m_creature->getVictim())
m_creature->AttackStop();
- }
}
-void ScriptedAI::DoCastSpell(Unit* who,SpellEntry const *spellInfo, bool triggered)
+void ScriptedAI::DoCastSpell(Unit* pTarget, SpellEntry const* pSpellInfo, bool bTriggered)
{
- if (!who || m_creature->IsNonMeleeSpellCasted(false))
+ if (!pTarget || m_creature->IsNonMeleeSpellCasted(false))
return;
m_creature->StopMoving();
- m_creature->CastSpell(who, spellInfo, triggered);
-}
-
-void ScriptedAI::DoSay(const char* text, uint32 language, Unit* target, bool SayEmote)
-{
- if (target)
- {
- m_creature->MonsterSay(text, language, target->GetGUID());
- if(SayEmote)
- m_creature->HandleEmoteCommand(EMOTE_ONESHOT_TALK);
- }
- else m_creature->MonsterSay(text, language, 0);
-}
-
-void ScriptedAI::DoYell(const char* text, uint32 language, Unit* target)
-{
- if (target) m_creature->MonsterYell(text, language, target->GetGUID());
- else m_creature->MonsterYell(text, language, 0);
-}
-
-void ScriptedAI::DoTextEmote(const char* text, Unit* target, bool IsBossEmote)
-{
- if (target) m_creature->MonsterTextEmote(text, target->GetGUID(), IsBossEmote);
- else m_creature->MonsterTextEmote(text, 0, IsBossEmote);
-}
-
-void ScriptedAI::DoWhisper(const char* text, Unit* reciever, bool IsBossWhisper)
-{
- if (!reciever || reciever->GetTypeId() != TYPEID_PLAYER)
- return;
-
- m_creature->MonsterWhisper(text, reciever->GetGUID(), IsBossWhisper);
+ m_creature->CastSpell(pTarget, pSpellInfo, bTriggered);
}
void ScriptedAI::DoPlaySoundToSet(WorldObject* pSource, uint32 uiSoundId)
@@ -188,59 +154,59 @@ void ScriptedAI::DoPlaySoundToSet(WorldObject* pSource, uint32 uiSoundId)
pSource->PlayDirectSound(uiSoundId);
}
-Creature* ScriptedAI::DoSpawnCreature(uint32 id, float x, float y, float z, float angle, uint32 type, uint32 despawntime)
+Creature* ScriptedAI::DoSpawnCreature(uint32 uiId, float fX, float fY, float fZ, float fAngle, uint32 uiType, uint32 uiDespawntime)
{
- 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(uiId, m_creature->GetPositionX()+fX, m_creature->GetPositionY()+fY, m_creature->GetPositionZ()+fZ, fAngle, (TempSummonType)uiType, uiDespawntime);
}
-Creature *ScriptedAI::DoSummon(uint32 entry, const float pos[4], uint32 despawntime, TempSummonType type)
+Creature *ScriptedAI::DoSummon(uint32 uiEntry, const float fPos[4], uint32 uiDespawntime, TempSummonType uiType)
{
- return me->SummonCreature(entry, pos[0], pos[1], pos[2], pos[3], type, despawntime);
+ return me->SummonCreature(uiEntry, fPos[0], fPos[1], fPos[2], fPos[3], uiType, uiDespawntime);
}
-Creature *ScriptedAI::DoSummon(uint32 entry, WorldObject *obj, float radius, uint32 despawntime, TempSummonType type)
+Creature *ScriptedAI::DoSummon(uint32 uiEntry, WorldObject* pGo, float fRadius, uint32 uiDespawntime, TempSummonType uiType)
{
- 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);
+ float fX, fY, fZ;
+ pGo->GetGroundPointAroundUnit(fX, fY, fZ, fRadius * rand_norm(), rand_norm()*2*M_PI);
+ return me->SummonCreature(uiEntry, fX, fY, fZ, me->GetOrientation(), uiType, uiDespawntime);
}
-Unit* ScriptedAI::SelectUnit(SelectAggroTarget target, uint32 position)
+Unit* ScriptedAI::SelectUnit(SelectAggroTarget target, uint32 uiPosition)
{
//ThreatList m_threatlist;
- std::list<HostilReference*>& m_threatlist = m_creature->getThreatManager().getThreatList();
- std::list<HostilReference*>::iterator i = m_threatlist.begin();
- std::list<HostilReference*>::reverse_iterator r = m_threatlist.rbegin();
+ std::list<HostilReference*>& threatlist = m_creature->getThreatManager().getThreatList();
+ std::list<HostilReference*>::iterator itr = threatlist.begin();
+ std::list<HostilReference*>::reverse_iterator ritr = threatlist.rbegin();
- if (position >= m_threatlist.size() || !m_threatlist.size())
+ if (uiPosition >= threatlist.size() || !threatlist.size())
return NULL;
switch (target)
{
case SELECT_TARGET_RANDOM:
- advance ( i , position + (rand() % (m_threatlist.size() - position ) ));
- return Unit::GetUnit((*m_creature),(*i)->getUnitGuid());
+ advance (itr , uiPosition + (rand() % (threatlist.size() - uiPosition ) ));
+ return Unit::GetUnit((*m_creature),(*itr)->getUnitGuid());
break;
case SELECT_TARGET_TOPAGGRO:
- advance ( i , position);
- return Unit::GetUnit((*m_creature),(*i)->getUnitGuid());
+ advance (itr , uiPosition);
+ return Unit::GetUnit((*m_creature),(*itr)->getUnitGuid());
break;
case SELECT_TARGET_BOTTOMAGGRO:
- advance ( r , position);
- return Unit::GetUnit((*m_creature),(*r)->getUnitGuid());
+ advance (ritr , uiPosition);
+ return Unit::GetUnit((*m_creature),(*ritr)->getUnitGuid());
break;
}
return NULL;
}
-SpellEntry const* ScriptedAI::SelectSpell(Unit* Target, int32 School, int32 Mechanic, SelectTargetType Targets, uint32 PowerCostMin, uint32 PowerCostMax, float RangeMin, float RangeMax, SelectEffect Effects)
+SpellEntry const* ScriptedAI::SelectSpell(Unit* pTarget, int32 uiSchool, int32 uiMechanic, SelectTargetType selectTargets, uint32 uiPowerCostMin, uint32 uiPowerCostMax, float fRangeMin, float fRangeMax, SelectEffect selectEffects)
{
//No target so we can't cast
- if (!Target)
+ if (!pTarget)
return false;
//Silenced so we can't cast
@@ -248,105 +214,102 @@ SpellEntry const* ScriptedAI::SelectSpell(Unit* Target, int32 School, int32 Mech
return false;
//Using the extended script system we first create a list of viable spells
- SpellEntry const* Spell[CREATURE_MAX_SPELLS];
- for (uint8 i=0;i<CREATURE_MAX_SPELLS;i++)
- Spell[i] = 0;
+ SpellEntry const* apSpell[CREATURE_MAX_SPELLS];
+ memset(apSpell, 0, sizeof(SpellEntry)*CREATURE_MAX_SPELLS);
- uint32 SpellCount = 0;
+ uint32 uiSpellCount = 0;
- SpellEntry const* TempSpell;
- SpellRangeEntry const* TempRange;
+ SpellEntry const* pTempSpell;
+ SpellRangeEntry const* pTempRange;
//Check if each spell is viable(set it to null if not)
for (uint32 i = 0; i < CREATURE_MAX_SPELLS; i++)
{
- TempSpell = GetSpellStore()->LookupEntry(m_creature->m_spells[i]);
+ pTempSpell = GetSpellStore()->LookupEntry(m_creature->m_spells[i]);
//This spell doesn't exist
- if (!TempSpell)
+ if (!pTempSpell)
continue;
// Targets and Effects checked first as most used restrictions
//Check the spell targets if specified
- if ( Targets && !(SpellSummary[m_creature->m_spells[i]].Targets & (1 << (Targets-1))) )
+ if (selectTargets && !(SpellSummary[m_creature->m_spells[i]].Targets & (1 << (selectTargets-1))))
continue;
//Check the type of spell if we are looking for a specific spell type
- if ( Effects && !(SpellSummary[m_creature->m_spells[i]].Effects & (1 << (Effects-1))) )
+ if (selectEffects && !(SpellSummary[m_creature->m_spells[i]].Effects & (1 << (selectEffects-1))))
continue;
//Check for school if specified
- if (School >= 0 && TempSpell->SchoolMask & School)
+ if (uiSchool >= 0 && pTempSpell->SchoolMask & uiSchool)
continue;
//Check for spell mechanic if specified
- if (Mechanic >= 0 && TempSpell->Mechanic != Mechanic)
+ if (uiMechanic >= 0 && pTempSpell->Mechanic != uiMechanic)
continue;
//Make sure that the spell uses the requested amount of power
- if (PowerCostMin && TempSpell->manaCost < PowerCostMin)
+ if (uiPowerCostMin && pTempSpell->manaCost < uiPowerCostMin)
continue;
- if (PowerCostMax && TempSpell->manaCost > PowerCostMax)
+ if (uiPowerCostMax && pTempSpell->manaCost > uiPowerCostMax)
continue;
//Continue if we don't have the mana to actually cast this spell
- if (TempSpell->manaCost > m_creature->GetPower((Powers)TempSpell->powerType))
+ if (pTempSpell->manaCost > m_creature->GetPower((Powers)pTempSpell->powerType))
continue;
//Get the Range
- TempRange = GetSpellRangeStore()->LookupEntry(TempSpell->rangeIndex);
+ pTempRange = GetSpellRangeStore()->LookupEntry(pTempSpell->rangeIndex);
//Spell has invalid range store so we can't use it
- if (!TempRange)
+ if (!pTempRange)
continue;
//Check if the spell meets our range requirements
- if (RangeMin && m_creature->GetSpellMinRangeForTarget(Target, TempRange) < RangeMin)
+ if (fRangeMin && m_creature->GetSpellMinRangeForTarget(pTarget, pTempRange) < fRangeMin)
continue;
- if (RangeMax && m_creature->GetSpellMaxRangeForTarget(Target, TempRange) > RangeMax)
+ if (fRangeMax && m_creature->GetSpellMaxRangeForTarget(pTarget, pTempRange) > fRangeMax)
continue;
//Check if our target is in range
- if (m_creature->IsWithinDistInMap(Target, m_creature->GetSpellMinRangeForTarget(Target, TempRange)) || !m_creature->IsWithinDistInMap(Target, m_creature->GetSpellMaxRangeForTarget(Target, TempRange)))
+ if (m_creature->IsWithinDistInMap(pTarget, m_creature->GetSpellMinRangeForTarget(pTarget, pTempRange)) || !m_creature->IsWithinDistInMap(pTarget, m_creature->GetSpellMaxRangeForTarget(pTarget, pTempRange)))
continue;
//All good so lets add it to the spell list
- Spell[SpellCount] = TempSpell;
- SpellCount++;
+ apSpell[uiSpellCount] = pTempSpell;
+ ++uiSpellCount;
}
//We got our usable spells so now lets randomly pick one
- if (!SpellCount)
+ if (!uiSpellCount)
return NULL;
- return Spell[rand()%SpellCount];
+ return apSpell[rand()%uiSpellCount];
}
-bool ScriptedAI::CanCast(Unit* Target, SpellEntry const *Spell, bool Triggered)
+bool ScriptedAI::CanCast(Unit* pTarget, SpellEntry const* pSpell, bool bTriggered)
{
//No target so we can't cast
- if (!Target || !Spell)
+ if (!pTarget || !pSpell)
return false;
//Silenced so we can't cast
- if (!Triggered && me->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SILENCED))
+ if (!bTriggered && me->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SILENCED))
return false;
//Check for power
- if (!Triggered && me->GetPower((Powers)Spell->powerType) < Spell->manaCost)
+ if (!bTriggered && me->GetPower((Powers)pSpell->powerType) < pSpell->manaCost)
return false;
- SpellRangeEntry const *TempRange = NULL;
-
- TempRange = GetSpellRangeStore()->LookupEntry(Spell->rangeIndex);
+ SpellRangeEntry const* pTempRange = GetSpellRangeStore()->LookupEntry(pSpell->rangeIndex);
//Spell has invalid range store so we can't use it
- if (!TempRange)
+ if (!pTempRange)
return false;
//Unit is out of range of this spell
- if (me->IsInRange(Target,me->GetSpellMinRangeForTarget(Target, TempRange),me->GetSpellMaxRangeForTarget(Target, TempRange)))
+ if (me->IsInRange(pTarget, m_creature->GetSpellMinRangeForTarget(pTarget, pTempRange), m_creature->GetSpellMaxRangeForTarget(pTarget, pTempRange)))
return false;
return true;
@@ -356,82 +319,82 @@ void FillSpellSummary()
{
SpellSummary = new TSpellSummary[GetSpellStore()->GetNumRows()];
- SpellEntry const* TempSpell;
+ SpellEntry const* pTempSpell;
for(uint32 i = 0; i < GetSpellStore()->GetNumRows(); ++i)
{
SpellSummary[i].Effects = 0;
SpellSummary[i].Targets = 0;
- TempSpell = GetSpellStore()->LookupEntry(i);
+ pTempSpell = GetSpellStore()->LookupEntry(i);
//This spell doesn't exist
- if (!TempSpell)
+ if (!pTempSpell)
continue;
for(uint32 j = 0; j < 3; ++j)
{
//Spell targets self
- if ( TempSpell->EffectImplicitTargetA[j] == TARGET_UNIT_CASTER )
+ if (pTempSpell->EffectImplicitTargetA[j] == TARGET_UNIT_CASTER )
SpellSummary[i].Targets |= 1 << (SELECT_TARGET_SELF-1);
//Spell targets a single enemy
- if ( TempSpell->EffectImplicitTargetA[j] == TARGET_UNIT_TARGET_ENEMY ||
- TempSpell->EffectImplicitTargetA[j] == TARGET_DST_TARGET_ENEMY )
+ if (pTempSpell->EffectImplicitTargetA[j] == TARGET_UNIT_TARGET_ENEMY ||
+ pTempSpell->EffectImplicitTargetA[j] == TARGET_DST_TARGET_ENEMY )
SpellSummary[i].Targets |= 1 << (SELECT_TARGET_SINGLE_ENEMY-1);
//Spell targets AoE at enemy
- if ( TempSpell->EffectImplicitTargetA[j] == TARGET_UNIT_AREA_ENEMY_SRC ||
- TempSpell->EffectImplicitTargetA[j] == TARGET_UNIT_AREA_ENEMY_DST ||
- TempSpell->EffectImplicitTargetA[j] == TARGET_SRC_CASTER ||
- TempSpell->EffectImplicitTargetA[j] == TARGET_DEST_DYNOBJ_ENEMY )
+ if (pTempSpell->EffectImplicitTargetA[j] == TARGET_UNIT_AREA_ENEMY_SRC ||
+ pTempSpell->EffectImplicitTargetA[j] == TARGET_UNIT_AREA_ENEMY_DST ||
+ pTempSpell->EffectImplicitTargetA[j] == TARGET_SRC_CASTER ||
+ pTempSpell->EffectImplicitTargetA[j] == TARGET_DEST_DYNOBJ_ENEMY )
SpellSummary[i].Targets |= 1 << (SELECT_TARGET_AOE_ENEMY-1);
//Spell targets an enemy
- if ( TempSpell->EffectImplicitTargetA[j] == TARGET_UNIT_TARGET_ENEMY ||
- TempSpell->EffectImplicitTargetA[j] == TARGET_DST_TARGET_ENEMY ||
- TempSpell->EffectImplicitTargetA[j] == TARGET_UNIT_AREA_ENEMY_SRC ||
- TempSpell->EffectImplicitTargetA[j] == TARGET_UNIT_AREA_ENEMY_DST ||
- TempSpell->EffectImplicitTargetA[j] == TARGET_SRC_CASTER ||
- TempSpell->EffectImplicitTargetA[j] == TARGET_DEST_DYNOBJ_ENEMY )
+ if (pTempSpell->EffectImplicitTargetA[j] == TARGET_UNIT_TARGET_ENEMY ||
+ pTempSpell->EffectImplicitTargetA[j] == TARGET_DST_TARGET_ENEMY ||
+ pTempSpell->EffectImplicitTargetA[j] == TARGET_UNIT_AREA_ENEMY_SRC ||
+ pTempSpell->EffectImplicitTargetA[j] == TARGET_UNIT_AREA_ENEMY_DST ||
+ pTempSpell->EffectImplicitTargetA[j] == TARGET_SRC_CASTER ||
+ pTempSpell->EffectImplicitTargetA[j] == TARGET_DEST_DYNOBJ_ENEMY )
SpellSummary[i].Targets |= 1 << (SELECT_TARGET_ANY_ENEMY-1);
//Spell targets a single friend(or self)
- if ( TempSpell->EffectImplicitTargetA[j] == TARGET_UNIT_CASTER ||
- TempSpell->EffectImplicitTargetA[j] == TARGET_UNIT_TARGET_ALLY ||
- TempSpell->EffectImplicitTargetA[j] == TARGET_UNIT_TARGET_PARTY )
+ if (pTempSpell->EffectImplicitTargetA[j] == TARGET_UNIT_CASTER ||
+ pTempSpell->EffectImplicitTargetA[j] == TARGET_UNIT_TARGET_ALLY ||
+ pTempSpell->EffectImplicitTargetA[j] == TARGET_UNIT_TARGET_PARTY )
SpellSummary[i].Targets |= 1 << (SELECT_TARGET_SINGLE_FRIEND-1);
//Spell targets aoe friends
- if ( TempSpell->EffectImplicitTargetA[j] == TARGET_UNIT_PARTY_CASTER ||
- TempSpell->EffectImplicitTargetA[j] == TARGET_UNIT_PARTY_TARGET ||
- TempSpell->EffectImplicitTargetA[j] == TARGET_SRC_CASTER)
+ if (pTempSpell->EffectImplicitTargetA[j] == TARGET_UNIT_PARTY_CASTER ||
+ pTempSpell->EffectImplicitTargetA[j] == TARGET_UNIT_PARTY_TARGET ||
+ pTempSpell->EffectImplicitTargetA[j] == TARGET_SRC_CASTER)
SpellSummary[i].Targets |= 1 << (SELECT_TARGET_AOE_FRIEND-1);
//Spell targets any friend(or self)
- if ( TempSpell->EffectImplicitTargetA[j] == TARGET_UNIT_CASTER ||
- TempSpell->EffectImplicitTargetA[j] == TARGET_UNIT_TARGET_ALLY ||
- TempSpell->EffectImplicitTargetA[j] == TARGET_UNIT_TARGET_PARTY ||
- TempSpell->EffectImplicitTargetA[j] == TARGET_UNIT_PARTY_CASTER ||
- TempSpell->EffectImplicitTargetA[j] == TARGET_UNIT_PARTY_TARGET ||
- TempSpell->EffectImplicitTargetA[j] == TARGET_SRC_CASTER)
+ if (pTempSpell->EffectImplicitTargetA[j] == TARGET_UNIT_CASTER ||
+ pTempSpell->EffectImplicitTargetA[j] == TARGET_UNIT_TARGET_ALLY ||
+ pTempSpell->EffectImplicitTargetA[j] == TARGET_UNIT_TARGET_PARTY ||
+ pTempSpell->EffectImplicitTargetA[j] == TARGET_UNIT_PARTY_CASTER ||
+ pTempSpell->EffectImplicitTargetA[j] == TARGET_UNIT_PARTY_TARGET ||
+ pTempSpell->EffectImplicitTargetA[j] == TARGET_SRC_CASTER)
SpellSummary[i].Targets |= 1 << (SELECT_TARGET_ANY_FRIEND-1);
//Make sure that this spell includes a damage effect
- if ( TempSpell->Effect[j] == SPELL_EFFECT_SCHOOL_DAMAGE ||
- TempSpell->Effect[j] == SPELL_EFFECT_INSTAKILL ||
- TempSpell->Effect[j] == SPELL_EFFECT_ENVIRONMENTAL_DAMAGE ||
- TempSpell->Effect[j] == SPELL_EFFECT_HEALTH_LEECH )
+ if (pTempSpell->Effect[j] == SPELL_EFFECT_SCHOOL_DAMAGE ||
+ pTempSpell->Effect[j] == SPELL_EFFECT_INSTAKILL ||
+ pTempSpell->Effect[j] == SPELL_EFFECT_ENVIRONMENTAL_DAMAGE ||
+ pTempSpell->Effect[j] == SPELL_EFFECT_HEALTH_LEECH )
SpellSummary[i].Effects |= 1 << (SELECT_EFFECT_DAMAGE-1);
//Make sure that this spell includes a healing effect (or an apply aura with a periodic heal)
- if ( TempSpell->Effect[j] == SPELL_EFFECT_HEAL ||
- TempSpell->Effect[j] == SPELL_EFFECT_HEAL_MAX_HEALTH ||
- TempSpell->Effect[j] == SPELL_EFFECT_HEAL_MECHANICAL ||
- (TempSpell->Effect[j] == SPELL_EFFECT_APPLY_AURA && TempSpell->EffectApplyAuraName[j]== 8 ))
+ if (pTempSpell->Effect[j] == SPELL_EFFECT_HEAL ||
+ pTempSpell->Effect[j] == SPELL_EFFECT_HEAL_MAX_HEALTH ||
+ pTempSpell->Effect[j] == SPELL_EFFECT_HEAL_MECHANICAL ||
+ (pTempSpell->Effect[j] == SPELL_EFFECT_APPLY_AURA && pTempSpell->EffectApplyAuraName[j]== 8 ))
SpellSummary[i].Effects |= 1 << (SELECT_EFFECT_HEALING-1);
//Make sure that this spell applies an aura
- if ( TempSpell->Effect[j] == SPELL_EFFECT_APPLY_AURA )
+ if (pTempSpell->Effect[j] == SPELL_EFFECT_APPLY_AURA )
SpellSummary[i].Effects |= 1 << (SELECT_EFFECT_AURA-1);
}
}
@@ -442,17 +405,15 @@ void ScriptedAI::DoResetThreat()
if (!m_creature->CanHaveThreatList() || m_creature->getThreatManager().isThreatListEmpty())
{
error_log("TSCR: DoResetThreat called for creature that either cannot have threat list or has empty threat list (m_creature entry = %d)", m_creature->GetEntry());
-
return;
}
- std::list<HostilReference*>& m_threatlist = m_creature->getThreatManager().getThreatList();
- std::list<HostilReference*>::iterator itr;
+ std::list<HostilReference*>& threatlist = m_creature->getThreatManager().getThreatList();
- for(itr = m_threatlist.begin(); itr != m_threatlist.end(); ++itr)
+ for(std::list<HostilReference*>::iterator itr = threatlist.begin(); itr != threatlist.end(); ++itr)
{
- Unit* pUnit = NULL;
- pUnit = Unit::GetUnit((*m_creature), (*itr)->getUnitGuid());
+ Unit* pUnit = Unit::GetUnit((*m_creature), (*itr)->getUnitGuid());
+
if(pUnit && DoGetThreat(pUnit))
DoModifyThreatPercent(pUnit, -100);
}
@@ -464,36 +425,36 @@ float ScriptedAI::DoGetThreat(Unit* pUnit)
return m_creature->getThreatManager().getThreat(pUnit);
}
-void ScriptedAI::DoModifyThreatPercent(Unit *pUnit, int32 pct)
+void ScriptedAI::DoModifyThreatPercent(Unit* pUnit, int32 pct)
{
if(!pUnit) return;
m_creature->getThreatManager().modifyThreatPercent(pUnit, pct);
}
-void ScriptedAI::DoTeleportTo(float x, float y, float z, uint32 time)
+void ScriptedAI::DoTeleportTo(float fX, float fY, float fZ, uint32 uiTime)
{
- m_creature->Relocate(x,y,z);
- m_creature->SendMonsterMove(x, y, z, time);
+ m_creature->Relocate(fX, fY, fZ);
+ m_creature->SendMonsterMove(fX, fY, fZ, uiTime);
}
-void ScriptedAI::DoTeleportTo(const float pos[4])
+void ScriptedAI::DoTeleportTo(const float fPos[4])
{
- me->NearTeleportTo(pos[0], pos[1], pos[2], pos[3]);
+ me->NearTeleportTo(fPos[0], fPos[1], fPos[2], fPos[3]);
}
-void ScriptedAI::DoTeleportPlayer(Unit* pUnit, float x, float y, float z, float o)
+void ScriptedAI::DoTeleportPlayer(Unit* pUnit, float fX, float fY, float fZ, float fO)
{
if(!pUnit || pUnit->GetTypeId() != TYPEID_PLAYER)
{
if(pUnit)
- error_log("TSCR: Creature %u (Entry: %u) Tried to teleport non-player unit (Type: %u GUID: %u) to x: %f y:%f z: %f o: %f. Aborted.", m_creature->GetGUID(), m_creature->GetEntry(), pUnit->GetTypeId(), pUnit->GetGUID(), x, y, z, o);
+ error_log("TSCR: Creature %u (Entry: %u) Tried to teleport non-player unit (Type: %u GUID: %u) to x: %f y:%f z: %f o: %f. Aborted.", m_creature->GetGUID(), m_creature->GetEntry(), pUnit->GetTypeId(), pUnit->GetGUID(), fX, fY, fZ, fO);
return;
}
- CAST_PLR(pUnit)->TeleportTo(pUnit->GetMapId(), x, y, z, o, TELE_TO_NOT_LEAVE_COMBAT);
+ CAST_PLR(pUnit)->TeleportTo(pUnit->GetMapId(), fX, fY, fZ, fO, TELE_TO_NOT_LEAVE_COMBAT);
}
-void ScriptedAI::DoTeleportAll(float x, float y, float z, float o)
+void ScriptedAI::DoTeleportAll(float fX, float fY, float fZ, float fO)
{
Map *map = m_creature->GetMap();
if (!map->IsDungeon())
@@ -503,33 +464,34 @@ void ScriptedAI::DoTeleportAll(float x, float y, float z, float o)
for(Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i)
if (Player* i_pl = i->getSource())
if (i_pl->isAlive())
- i_pl->TeleportTo(m_creature->GetMapId(), x, y, z, o, TELE_TO_NOT_LEAVE_COMBAT);
+ i_pl->TeleportTo(m_creature->GetMapId(), fX, fY, fZ, fO, TELE_TO_NOT_LEAVE_COMBAT);
}
-Unit* ScriptedAI::DoSelectLowestHpFriendly(float range, uint32 MinHPDiff)
+Unit* ScriptedAI::DoSelectLowestHpFriendly(float fRange, uint32 uiMinHPDiff)
{
Unit* pUnit = NULL;
- Trinity::MostHPMissingInRange u_check(m_creature, range, MinHPDiff);
+ Trinity::MostHPMissingInRange u_check(m_creature, fRange, uiMinHPDiff);
Trinity::UnitLastSearcher<Trinity::MostHPMissingInRange> searcher(m_creature, pUnit, u_check);
- m_creature->VisitNearbyObject(range, searcher);
+ m_creature->VisitNearbyObject(fRange, searcher);
+
return pUnit;
}
-std::list<Creature*> ScriptedAI::DoFindFriendlyCC(float range)
+std::list<Creature*> ScriptedAI::DoFindFriendlyCC(float fRange)
{
std::list<Creature*> pList;
- Trinity::FriendlyCCedInRange u_check(m_creature, range);
+ Trinity::FriendlyCCedInRange u_check(m_creature, fRange);
Trinity::CreatureListSearcher<Trinity::FriendlyCCedInRange> searcher(m_creature, pList, u_check);
- m_creature->VisitNearbyObject(range, searcher);
+ m_creature->VisitNearbyObject(fRange, searcher);
return pList;
}
-std::list<Creature*> ScriptedAI::DoFindFriendlyMissingBuff(float range, uint32 spellid)
+std::list<Creature*> ScriptedAI::DoFindFriendlyMissingBuff(float fRange, uint32 uiSpellid)
{
std::list<Creature*> pList;
- Trinity::FriendlyMissingBuffInRange u_check(m_creature, range, spellid);
+ Trinity::FriendlyMissingBuffInRange u_check(m_creature, fRange, uiSpellid);
Trinity::CreatureListSearcher<Trinity::FriendlyMissingBuffInRange> searcher(m_creature, pList, u_check);
- m_creature->VisitNearbyObject(range, searcher);
+ m_creature->VisitNearbyObject(fRange, searcher);
return pList;
}
@@ -577,6 +539,14 @@ void ScriptedAI::SetCombatMovement(bool bCombatMove)
m_bCombatMovement = bCombatMove;
}
+enum
+{
+ NPC_BROODLORD = 12017,
+ NPC_VOID_REAVER = 19516,
+ NPC_JAN_ALAI = 23578,
+ NPC_SARTHARION = 28860
+};
+
// Hacklike storage used for misc creatures that are expected to evade of outside of a certain area.
// It is assumed the information is found elswehere and can be handled by mangos. So far no luck finding such information/way to extract it.
bool ScriptedAI::EnterEvadeIfOutOfCombatArea(const uint32 uiDiff)
@@ -598,19 +568,19 @@ bool ScriptedAI::EnterEvadeIfOutOfCombatArea(const uint32 uiDiff)
switch(m_creature->GetEntry())
{
- case 12017: // broodlord (not move down stairs)
+ case NPC_BROODLORD: // broodlord (not move down stairs)
if (fZ > 448.60f)
return false;
break;
- case 19516: // void reaver (calculate from center of room)
+ case NPC_VOID_REAVER: // void reaver (calculate from center of room)
if (m_creature->GetDistance2d(432.59f, 371.93f) < 105.0f)
return false;
break;
- case 23578: // jan'alai (calculate by Z)
+ case NPC_JAN_ALAI: // jan'alai (calculate by Z)
if (fZ > 12.0f)
return false;
break;
- case 28860: // sartharion (calculate box)
+ case NPC_SARTHARION: // sartharion (calculate box)
if (fX > 3218.86f && fX < 3275.69f && fY < 572.40f && fY > 484.68f)
return false;
break;
@@ -623,14 +593,14 @@ bool ScriptedAI::EnterEvadeIfOutOfCombatArea(const uint32 uiDiff)
return true;
}
-void Scripted_NoMovementAI::AttackStart(Unit* who)
+void Scripted_NoMovementAI::AttackStart(Unit* pWho)
{
- if (!who)
+ if (!pWho)
return;
- if (m_creature->Attack(who, true))
+ if (m_creature->Attack(pWho, true))
{
- DoStartNoMovement(who);
+ DoStartNoMovement(pWho);
}
}
diff --git a/src/bindings/scripts/include/sc_creature.h b/src/bindings/scripts/include/sc_creature.h
index cfce5c25bfa..b0a885643fc 100644
--- a/src/bindings/scripts/include/sc_creature.h
+++ b/src/bindings/scripts/include/sc_creature.h
@@ -63,7 +63,7 @@ struct TRINITY_DLL_DECL ScriptedAI : public CreatureAI
void AttackStartNoMove(Unit *target);
// Called at any Damage from any attacker (before damage apply)
- void DamageTaken(Unit *done_by, uint32 &damage) {}
+ void DamageTaken(Unit* pDone_by, uint32& uiDamage) {}
//Called at World update tick
void UpdateAI(const uint32);
@@ -78,7 +78,7 @@ struct TRINITY_DLL_DECL ScriptedAI : public CreatureAI
void JustSummoned(Creature* ) {}
// Called when a summoned creature is despawned
- void SummonedCreatureDespawn(Creature* /*unit*/) {}
+ void SummonedCreatureDespawn(Creature*) {}
// Called when hit by a spell
void SpellHit(Unit* caster, const SpellEntry *spell) {}
@@ -119,28 +119,16 @@ struct TRINITY_DLL_DECL ScriptedAI : public CreatureAI
//*************
//Start movement toward victim
- void DoStartMovement(Unit* victim, float distance = 0, float angle = 0);
+ void DoStartMovement(Unit* pVictim, float fDistance = 0, float fAngle = 0);
//Start no movement on victim
- void DoStartNoMovement(Unit* victim);
+ void DoStartNoMovement(Unit* pVictim);
//Stop attack of current victim
void DoStopAttack();
//Cast spell by spell info
- void DoCastSpell(Unit* who,SpellEntry const *spellInfo, bool triggered = false);
-
- //Creature say
- void DoSay(const char* text, uint32 language, Unit* target, bool SayEmote = false);
-
- //Creature Yell
- void DoYell(const char* text, uint32 language, Unit* target);
-
- //Creature Text emote, optional bool for boss emote text
- void DoTextEmote(const char* text, Unit* target, bool IsBossEmote = false);
-
- //Creature whisper, optional bool for boss whisper
- void DoWhisper(const char* text, Unit* reciever, bool IsBossWhisper = false);
+ void DoCastSpell(Unit* pTarget, SpellEntry const* pSpellInfo, bool bTriggered = false);
//Plays a sound to all nearby players
void DoPlaySoundToSet(WorldObject* pSource, uint32 sound);
@@ -148,37 +136,37 @@ struct TRINITY_DLL_DECL ScriptedAI : public CreatureAI
//Drops all threat to 0%. Does not remove players from the threat list
void DoResetThreat();
- float DoGetThreat(Unit *u);
- void DoModifyThreatPercent(Unit *pUnit, int32 pct);
+ float DoGetThreat(Unit* u);
+ void DoModifyThreatPercent(Unit* pUnit, int32 pct);
- void DoTeleportTo(float x, float y, float z, uint32 time = 0);
+ void DoTeleportTo(float fX, float fY, float fZ, uint32 uiTime = 0);
void DoTeleportTo(const float pos[4]);
void DoAction(const int32 param) {}
//Teleports a player without dropping threat (only teleports to same map)
- void DoTeleportPlayer(Unit* pUnit, float x, float y, float z, float o);
- void DoTeleportAll(float x, float y, float z, float o);
+ void DoTeleportPlayer(Unit* pUnit, float fX, float fY, float fZ, float fO);
+ void DoTeleportAll(float fX, float fY, float fZ, float fO);
//Returns friendly unit with the most amount of hp missing from max hp
- Unit* DoSelectLowestHpFriendly(float range, uint32 MinHPDiff = 1);
+ Unit* DoSelectLowestHpFriendly(float fRange, uint32 uiMinHPDiff = 1);
//Returns a list of friendly CC'd units within range
- std::list<Creature*> DoFindFriendlyCC(float range);
+ std::list<Creature*> DoFindFriendlyCC(float fRange);
//Returns a list of all friendly units missing a specific buff within range
- std::list<Creature*> DoFindFriendlyMissingBuff(float range, uint32 spellid);
+ std::list<Creature*> DoFindFriendlyMissingBuff(float fRange, uint32 uiSpellId);
//Return a player with at least minimumRange from m_creature
Player* GetPlayerAtMinimumRange(float fMinimumRange);
//Spawns a creature relative to m_creature
- 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);
+ Creature* DoSpawnCreature(uint32 uiId, float fX, float fY, float fZ, float fAngle, uint32 uiType, uint32 uiDespawntime);
+ Creature *DoSummon(uint32 uiEntry, const float fPos[4], uint32 uiDespawntime = 30000, TempSummonType uiType = TEMPSUMMON_CORPSE_TIMED_DESPAWN);
+ Creature *DoSummon(uint32 uiEntry, WorldObject *obj, float fRadius = 5.0f, uint32 uiDespawntime = 30000, TempSummonType uiType = TEMPSUMMON_CORPSE_TIMED_DESPAWN);
//Selects a unit from the creature's current aggro list
- Unit* SelectUnit(SelectAggroTarget target, uint32 position);
+ Unit* SelectUnit(SelectAggroTarget target, uint32 uiPosition);
bool HealthBelowPct(uint32 pct) const { return me->GetHealth() * 100 < m_creature->GetMaxHealth() * pct; }
@@ -186,7 +174,7 @@ struct TRINITY_DLL_DECL ScriptedAI : public CreatureAI
SpellEntry const* SelectSpell(Unit* Target, int32 School, int32 Mechanic, SelectTargetType Targets, uint32 PowerCostMin, uint32 PowerCostMax, float RangeMin, float RangeMax, SelectEffect Effect);
//Checks if you can cast the specified spell
- bool CanCast(Unit* Target, SpellEntry const *Spell, bool Triggered = false);
+ bool CanCast(Unit* pTarget, SpellEntry const* pSpell, bool bTriggered = false);
void SetEquipmentSlots(bool bLoadDefault, int32 uiMainHand = EQUIP_NO_CHANGE, int32 uiOffHand = EQUIP_NO_CHANGE, int32 uiRanged = EQUIP_NO_CHANGE);