mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-27 20:32:21 +01:00
[svn] Update trinityscript to SD2 rev 700. Source: scriptdev2. Patch provided by SLG.
--HG-- branch : trunk
This commit is contained in:
@@ -11,8 +11,8 @@
|
||||
|
||||
// Spell summary for ScriptedAI::SelectSpell
|
||||
struct TSpellSummary {
|
||||
uint8 Targets; // set of enum SelectTarget
|
||||
uint8 Effects; // set of enum SelectEffect
|
||||
uint8 Targets; // set of enum SelectTarget
|
||||
uint8 Effects; // set of enum SelectEffect
|
||||
} *SpellSummary;
|
||||
|
||||
bool ScriptedAI::IsVisible(Unit* who) const
|
||||
@@ -25,53 +25,74 @@ bool ScriptedAI::IsVisible(Unit* who) const
|
||||
|
||||
void ScriptedAI::MoveInLineOfSight(Unit *who)
|
||||
{
|
||||
if( !m_creature->getVictim() && who->isTargetableForAttack() && ( m_creature->IsHostileTo( who )) && who->isInAccessablePlaceFor(m_creature) )
|
||||
if (!m_creature->getVictim() && who->isTargetableForAttack() && ( m_creature->IsHostileTo( who )) && who->isInAccessablePlaceFor(m_creature))
|
||||
{
|
||||
if (!m_creature->canFly() && m_creature->GetDistanceZ(who) > CREATURE_Z_ATTACK_RANGE)
|
||||
return;
|
||||
|
||||
float attackRadius = m_creature->GetAttackDistance(who);
|
||||
if( m_creature->IsWithinDistInMap(who, attackRadius) && m_creature->IsWithinLOSInMap(who) )
|
||||
if (m_creature->IsWithinDistInMap(who, attackRadius) && m_creature->IsWithinLOSInMap(who))
|
||||
{
|
||||
DoStartAttackAndMovement(who);
|
||||
who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH);
|
||||
|
||||
if (!InCombat)
|
||||
{
|
||||
InCombat = true;
|
||||
Aggro(who);
|
||||
}
|
||||
AttackStart(who);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ScriptedAI::AttackStart(Unit* who, bool melee)
|
||||
{
|
||||
if (!who)
|
||||
return;
|
||||
|
||||
if (m_creature->Attack(who, melee))
|
||||
{
|
||||
m_creature->AddThreat(who, 0.0f);
|
||||
m_creature->SetInCombatWith(who);
|
||||
who->SetInCombatWith(m_creature);
|
||||
|
||||
if (!InCombat)
|
||||
{
|
||||
InCombat = true;
|
||||
Aggro(who);
|
||||
}
|
||||
|
||||
if(melee)
|
||||
DoStartMovement(who);
|
||||
else
|
||||
DoStartNoMovement(who);
|
||||
}
|
||||
}
|
||||
|
||||
void ScriptedAI::AttackStart(Unit* who)
|
||||
{
|
||||
if (!who)
|
||||
return;
|
||||
|
||||
if (who->isTargetableForAttack())
|
||||
if (m_creature->Attack(who, true))
|
||||
{
|
||||
//Begin attack
|
||||
DoStartAttackAndMovement(who);
|
||||
m_creature->AddThreat(who, 0.0f);
|
||||
m_creature->SetInCombatWith(who);
|
||||
who->SetInCombatWith(m_creature);
|
||||
|
||||
if (!InCombat)
|
||||
{
|
||||
InCombat = true;
|
||||
Aggro(who);
|
||||
}
|
||||
|
||||
DoStartMovement(who);
|
||||
}
|
||||
}
|
||||
|
||||
void ScriptedAI::UpdateAI(const uint32 diff)
|
||||
{
|
||||
//Check if we have a current target
|
||||
if( m_creature->isAlive() && m_creature->SelectHostilTarget() && m_creature->getVictim())
|
||||
if (m_creature->isAlive() && m_creature->SelectHostilTarget() && m_creature->getVictim())
|
||||
{
|
||||
if( m_creature->isAttackReady() )
|
||||
if (m_creature->isAttackReady() )
|
||||
{
|
||||
//If we are within range melee the target
|
||||
if( m_creature->IsWithinDistInMap(m_creature->getVictim(), ATTACK_DISTANCE))
|
||||
if (m_creature->IsWithinDistInMap(m_creature->getVictim(), ATTACK_DISTANCE))
|
||||
{
|
||||
m_creature->AttackerStateUpdate(m_creature->getVictim());
|
||||
m_creature->resetAttackTimer();
|
||||
@@ -88,7 +109,7 @@ void ScriptedAI::EnterEvadeMode()
|
||||
m_creature->CombatStop();
|
||||
m_creature->LoadCreaturesAddon();
|
||||
|
||||
if( m_creature->isAlive() )
|
||||
if (m_creature->isAlive())
|
||||
m_creature->GetMotionMaster()->MoveTargetedHome();
|
||||
|
||||
m_creature->SetLootRecipient(NULL);
|
||||
@@ -103,37 +124,31 @@ void ScriptedAI::JustRespawned()
|
||||
Reset();
|
||||
}
|
||||
|
||||
void ScriptedAI::DoStartAttackAndMovement(Unit* victim, float distance, float angle)
|
||||
void ScriptedAI::DoStartMovement(Unit* victim, float distance, float angle)
|
||||
{
|
||||
if (!victim)
|
||||
return;
|
||||
|
||||
if ( m_creature->Attack(victim, true) )
|
||||
{
|
||||
m_creature->GetMotionMaster()->MoveChase(victim, distance, angle);
|
||||
m_creature->AddThreat(victim, 0.0f);
|
||||
}
|
||||
m_creature->GetMotionMaster()->MoveChase(victim, distance, angle);
|
||||
}
|
||||
|
||||
void ScriptedAI::DoStartAttackNoMovement(Unit* victim)
|
||||
void ScriptedAI::DoStartNoMovement(Unit* victim)
|
||||
{
|
||||
if (!victim)
|
||||
return;
|
||||
|
||||
if ( m_creature->Attack(victim, true) )
|
||||
{
|
||||
m_creature->AddThreat(victim, 0.0f);
|
||||
}
|
||||
m_creature->GetMotionMaster()->MoveIdle();
|
||||
m_creature->StopMoving();
|
||||
}
|
||||
|
||||
|
||||
void ScriptedAI::DoMeleeAttackIfReady()
|
||||
{
|
||||
//Make sure our attack is ready and we aren't currently casting before checking distance
|
||||
if( m_creature->isAttackReady() && !m_creature->IsNonMeleeSpellCasted(false))
|
||||
if (m_creature->isAttackReady() && !m_creature->IsNonMeleeSpellCasted(false))
|
||||
{
|
||||
//If we are within range melee the target
|
||||
if( m_creature->IsWithinCombatDist(m_creature->getVictim(), ATTACK_DISTANCE))
|
||||
if (m_creature->IsWithinDistInMap(m_creature->getVictim(), ATTACK_DISTANCE))
|
||||
{
|
||||
m_creature->AttackerStateUpdate(m_creature->getVictim());
|
||||
m_creature->resetAttackTimer();
|
||||
@@ -143,7 +158,7 @@ void ScriptedAI::DoMeleeAttackIfReady()
|
||||
|
||||
void ScriptedAI::DoStopAttack()
|
||||
{
|
||||
if( m_creature->getVictim() != NULL )
|
||||
if (m_creature->getVictim() != NULL)
|
||||
{
|
||||
m_creature->AttackStop();
|
||||
}
|
||||
@@ -169,19 +184,19 @@ void ScriptedAI::DoCastSpell(Unit* who,SpellEntry const *spellInfo, bool trigger
|
||||
|
||||
void ScriptedAI::DoSay(const char* text, uint32 language, Unit* target)
|
||||
{
|
||||
if (target)m_creature->Say(text, language, target->GetGUID());
|
||||
if (target) m_creature->Say(text, language, target->GetGUID());
|
||||
else m_creature->Say(text, language, 0);
|
||||
}
|
||||
|
||||
void ScriptedAI::DoYell(const char* text, uint32 language, Unit* target)
|
||||
{
|
||||
if (target)m_creature->Yell(text, language, target->GetGUID());
|
||||
if (target) m_creature->Yell(text, language, target->GetGUID());
|
||||
else m_creature->Yell(text, language, 0);
|
||||
}
|
||||
|
||||
void ScriptedAI::DoTextEmote(const char* text, Unit* target, bool IsBossEmote)
|
||||
{
|
||||
if (target)m_creature->TextEmote(text, target->GetGUID(), IsBossEmote);
|
||||
if (target) m_creature->TextEmote(text, target->GetGUID(), IsBossEmote);
|
||||
else m_creature->TextEmote(text, 0, IsBossEmote);
|
||||
}
|
||||
|
||||
@@ -204,7 +219,10 @@ void ScriptedAI::DoPlaySoundToSet(Unit* unit, uint32 sound)
|
||||
return;
|
||||
}
|
||||
|
||||
unit->SendPlaySound(sound, false);
|
||||
WorldPacket data(4);
|
||||
data.SetOpcode(SMSG_PLAY_SOUND);
|
||||
data << uint32(sound);
|
||||
unit->SendMessageToSet(&data,false);
|
||||
}
|
||||
|
||||
Creature* ScriptedAI::DoSpawnCreature(uint32 id, float x, float y, float z, float angle, uint32 type, uint32 despawntime)
|
||||
@@ -461,6 +479,7 @@ void ScriptedAI::DoZoneInCombat(Unit* pUnit)
|
||||
/*if (!pUnit->CanHaveThreatList() || pUnit->getThreatManager().isThreatListEmpty())
|
||||
{
|
||||
error_log("SD2: DoZoneInCombat called for creature that either cannot have threat list or has empty threat list (pUnit entry = %d)", pUnit->GetTypeId() == TYPEID_UNIT ? ((Creature*)pUnit)->GetEntry() : 0);
|
||||
|
||||
return;
|
||||
}*/
|
||||
|
||||
@@ -579,14 +598,8 @@ void Scripted_NoMovementAI::MoveInLineOfSight(Unit *who)
|
||||
float attackRadius = m_creature->GetAttackDistance(who);
|
||||
if( m_creature->IsWithinDistInMap(who, attackRadius) && m_creature->IsWithinLOSInMap(who) )
|
||||
{
|
||||
DoStartAttackNoMovement(who);
|
||||
who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH);
|
||||
|
||||
if (!InCombat)
|
||||
{
|
||||
InCombat = true;
|
||||
Aggro(who);
|
||||
}
|
||||
AttackStart(who);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -596,15 +609,18 @@ void Scripted_NoMovementAI::AttackStart(Unit* who)
|
||||
if (!who)
|
||||
return;
|
||||
|
||||
if (who->isTargetableForAttack())
|
||||
if (m_creature->Attack(who, true))
|
||||
{
|
||||
//Begin attack
|
||||
DoStartAttackNoMovement(who);
|
||||
m_creature->AddThreat(who, 0.0f);
|
||||
m_creature->SetInCombatWith(who);
|
||||
who->SetInCombatWith(m_creature);
|
||||
|
||||
if (!InCombat)
|
||||
{
|
||||
InCombat = true;
|
||||
Aggro(who);
|
||||
}
|
||||
|
||||
DoStartNoMovement(who);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ struct TRINITY_DLL_DECL ScriptedAI : public CreatureAI
|
||||
|
||||
//Called at each attack of m_creature by any victim
|
||||
void AttackStart(Unit *);
|
||||
void AttackStart(Unit *, bool melee);
|
||||
|
||||
//Called at stoping attack by any attacker
|
||||
void EnterEvadeMode();
|
||||
@@ -89,11 +90,11 @@ struct TRINITY_DLL_DECL ScriptedAI : public CreatureAI
|
||||
//AI Helper Functions
|
||||
//*************
|
||||
|
||||
//Start attack of victim and go to him
|
||||
void DoStartAttackAndMovement(Unit* victim, float distance = 0, float angle = 0);
|
||||
//Start movement toward victim
|
||||
void DoStartMovement(Unit* victim, float distance = 0, float angle = 0);
|
||||
|
||||
//Start attack on victim but do not move
|
||||
void DoStartAttackNoMovement(Unit* victim);
|
||||
//Start no movement on victim
|
||||
void DoStartNoMovement(Unit* victim);
|
||||
|
||||
//Do melee swing of current victim if in rnage and ready and not casting
|
||||
void DoMeleeAttackIfReady();
|
||||
|
||||
Reference in New Issue
Block a user