Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/bindings/scripts/include/sc_creature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ void ScriptedAI::CastNextSpellIfAnyAndReady(uint32 diff)

bool casted = false;

if (m_creature->hasUnitState(UNIT_STAT_CASTING))
if (me->IsNonMeleeSpellCasted(false))
casted = true;

if (!spellList.empty() && !casted)
Expand Down Expand Up @@ -294,7 +294,7 @@ void ScriptedAI::CastNextSpellIfAnyAndReady(uint32 diff)

void ScriptedAI::DoCast(Unit* victim, uint32 spellId, bool triggered)
{
if (/*!victim || */m_creature->hasUnitState(UNIT_STAT_CASTING) && !triggered)
if (/*!victim || */me->IsNonMeleeSpellCasted(false) && !triggered)
return;

//m_creature->StopMoving();
Expand All @@ -303,7 +303,7 @@ void ScriptedAI::DoCast(Unit* victim, uint32 spellId, bool triggered)

void ScriptedAI::DoCastAOE(uint32 spellId, bool triggered)
{
if(!triggered && m_creature->hasUnitState(UNIT_STAT_CASTING))
if(!triggered && me->IsNonMeleeSpellCasted(false))
return;

m_creature->CastSpell((Unit*)NULL, spellId, triggered);
Expand Down Expand Up @@ -1029,8 +1029,8 @@ void ScriptedAI::DoModifyThreatPercent(Unit *pUnit, int32 pct)

void ScriptedAI::DoTeleportTo(float x, float y, float z, uint32 time)
{
m_creature->Relocate(x,y,z);
m_creature->SendMonsterMove(x, y, z, time);
m_creature->NearTeleportTo(x,y,z, me->GetOrientation());
//m_creature->SendMonsterMove(x, y, z, time);
}

void ScriptedAI::DoTeleportPlayer(Unit* pUnit, float x, float y, float z, float o)
Expand Down
76 changes: 1 addition & 75 deletions src/bindings/scripts/scripts/guard/guard_ai.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,80 +98,6 @@ void guardAI::UpdateAI(const uint32 diff)
if (!UpdateVictim())
return;

// Make sure our attack is ready and we arn't currently casting
if( m_creature->isAttackReady() && !m_creature->IsNonMeleeSpellCasted(false))
{
//If we are within range melee the target
if( m_creature->IsWithinMeleeRange(m_creature->getVictim()))
{
bool Healing = false;
SpellEntry const *info = NULL;

//Select a healing spell if less than 30% hp
if (m_creature->GetHealth()*100 / m_creature->GetMaxHealth() < 30)
info = SelectSpell(m_creature, -1, -1, SELECT_TARGET_ANY_FRIEND, 0, 0, 0, 0, SELECT_EFFECT_HEALING);

//No healing spell available, select a hostile spell
if (info) Healing = true;
else info = SelectSpell(m_creature->getVictim(), -1, -1, SELECT_TARGET_ANY_ENEMY, 0, 0, 0, 0, SELECT_EFFECT_DONTCARE);

//20% chance to replace our white hit with a spell
if (info && rand() % 5 == 0 && !GlobalCooldown)
{
//Cast the spell
if (Healing)DoCastSpell(m_creature, info);
else DoCastSpell(m_creature->getVictim(), info);

//Set our global cooldown
GlobalCooldown = GENERIC_CREATURE_COOLDOWN;
}
else m_creature->AttackerStateUpdate(m_creature->getVictim());

m_creature->resetAttackTimer();
}
}
else
{
//Only run this code if we arn't already casting
if (!m_creature->IsNonMeleeSpellCasted(false))
{
bool Healing = false;
SpellEntry const *info = NULL;

//Select a healing spell if less than 30% hp ONLY 33% of the time
if (m_creature->GetHealth()*100 / m_creature->GetMaxHealth() < 30 && rand() % 3 == 0)
info = SelectSpell(m_creature, -1, -1, SELECT_TARGET_ANY_FRIEND, 0, 0, 0, 0, SELECT_EFFECT_HEALING);

//No healing spell available, See if we can cast a ranged spell (Range must be greater than ATTACK_DISTANCE)
if (info) Healing = true;
else info = SelectSpell(m_creature->getVictim(), -1, -1, SELECT_TARGET_ANY_ENEMY, 0, 0, NOMINAL_MELEE_RANGE, 0, SELECT_EFFECT_DONTCARE);

//Found a spell, check if we arn't on cooldown
if (info && !GlobalCooldown)
{
//If we are currently moving stop us and set the movement generator
if ((*m_creature).GetMotionMaster()->GetCurrentMovementGeneratorType()!=IDLE_MOTION_TYPE)
{
(*m_creature).GetMotionMaster()->Clear(false);
(*m_creature).GetMotionMaster()->MoveIdle();
}

//Cast spell
if (Healing) DoCastSpell(m_creature,info);
else DoCastSpell(m_creature->getVictim(),info);

//Set our global cooldown
GlobalCooldown = GENERIC_CREATURE_COOLDOWN;

} //If no spells available and we arn't moving run to target
else if ((*m_creature).GetMotionMaster()->GetCurrentMovementGeneratorType()!=TARGETED_MOTION_TYPE)
{
//Cancel our current spell and then mutate new movement generator
m_creature->InterruptNonMeleeSpells(false);
(*m_creature).GetMotionMaster()->Clear(false);
(*m_creature).GetMotionMaster()->MoveChase(m_creature->getVictim());
}
}
}
DoMeleeAttackIfReady();
}

2 changes: 1 addition & 1 deletion src/bindings/scripts/scripts/item/item_scripts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ bool ItemUse_item_only_for_flight(Player *player, Item* _Item, SpellCastTargets
}

// allow use in flight only
if( player->isInFlight() && !disabled)
if( player->IsTaxiFlying() && !disabled)
return false;

// error
Expand Down
18 changes: 9 additions & 9 deletions src/bindings/scripts/scripts/npc/escort_ai.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ void npc_escortAI::MoveInLineOfSight(Unit* pWho)
if (HasEscortState(STATE_ESCORT_ESCORTING) && AssistPlayerInCombat(pWho))
return;

if (!m_creature->canFly() && m_creature->GetDistanceZ(pWho) > CREATURE_Z_ATTACK_RANGE)
if (!m_creature->CanFly() && m_creature->GetDistanceZ(pWho) > CREATURE_Z_ATTACK_RANGE)
return;

if (m_creature->IsHostileTo(pWho) && m_bIsActiveAttacker)
Expand Down Expand Up @@ -324,10 +324,10 @@ void npc_escortAI::MovementInform(uint32 uiMoveType, uint32 uiPointId)
{
debug_log("TSCR: EscortAI has returned to original position before combat");

if (m_bIsRunning && m_creature->HasUnitMovementFlag(SPLINEFLAG_WALKMODE_MODE))
m_creature->RemoveUnitMovementFlag(SPLINEFLAG_WALKMODE_MODE);
else if (!m_bIsRunning && !m_creature->HasUnitMovementFlag(SPLINEFLAG_WALKMODE_MODE))
m_creature->AddUnitMovementFlag(SPLINEFLAG_WALKMODE_MODE);
if (m_bIsRunning && m_creature->IsWalking())
m_creature->SetWalk(false);
else if (!m_bIsRunning && !m_creature->IsWalking())
m_creature->SetWalk(true);

RemoveEscortState(STATE_ESCORT_RETURNING);

Expand Down Expand Up @@ -419,14 +419,14 @@ void npc_escortAI::SetRun(bool bRun)
if (bRun)
{
if (!m_bIsRunning)
m_creature->RemoveUnitMovementFlag(SPLINEFLAG_WALKMODE_MODE);
m_creature->SetWalk(false);
else
debug_log("TSCR: EscortAI attempt to set run mode, but is already running.");
}
else
{
if (m_bIsRunning)
m_creature->AddUnitMovementFlag(SPLINEFLAG_WALKMODE_MODE);
m_creature->SetWalk(true);
else
debug_log("TSCR: EscortAI attempt to set walk mode, but is already walking.");
}
Expand Down Expand Up @@ -493,9 +493,9 @@ void npc_escortAI::Start(bool bIsActiveAttacker, bool bRun, uint64 uiPlayerGUID,

//Set initial speed
if (m_bIsRunning)
m_creature->RemoveUnitMovementFlag(SPLINEFLAG_WALKMODE_MODE);
m_creature->SetWalk(false);
else
m_creature->AddUnitMovementFlag(SPLINEFLAG_WALKMODE_MODE);
m_creature->SetWalk(true);

AddEscortState(STATE_ESCORT_ESCORTING);
}
Expand Down
6 changes: 3 additions & 3 deletions src/bindings/scripts/scripts/npc/follower_ai.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ void FollowerAI::MoveInLineOfSight(Unit* pWho)
if (HasFollowState(STATE_FOLLOW_INPROGRESS) && AssistPlayerInCombat(pWho))
return;

if (!me->canFly() && me->GetDistanceZ(pWho) > CREATURE_Z_ATTACK_RANGE)
if (!me->CanFly() && me->GetDistanceZ(pWho) > CREATURE_Z_ATTACK_RANGE)
return;

if (me->IsHostileTo(pWho))
Expand Down Expand Up @@ -166,7 +166,7 @@ void FollowerAI::EnterEvadeMode()
{
// sLog.outDebug("OSCR: FollowerAI left combat, returning to CombatStartPosition.");

if (me->GetMotionMaster()->GetCurrentMovementGeneratorType() == TARGETED_MOTION_TYPE)
if (me->GetMotionMaster()->GetCurrentMovementGeneratorType() == CHASE_MOTION_TYPE)
{
float fPosX, fPosY, fPosZ;
me->GetPosition(fPosX, fPosY, fPosZ);
Expand All @@ -175,7 +175,7 @@ void FollowerAI::EnterEvadeMode()
}
else
{
if (me->GetMotionMaster()->GetCurrentMovementGeneratorType() == TARGETED_MOTION_TYPE)
if (me->GetMotionMaster()->GetCurrentMovementGeneratorType() == CHASE_MOTION_TYPE)
me->GetMotionMaster()->MoveTargetedHome();
}

Expand Down
16 changes: 6 additions & 10 deletions src/bindings/scripts/scripts/npc/npcs_special.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,11 +165,8 @@ struct TRINITY_DLL_DECL npc_dancing_flamesAI : public ScriptedAI
float x, y, z;
m_creature->GetPosition(x,y,z);
m_creature->Relocate(x,y,z + 0.94f);
m_creature->AddUnitMovementFlag(MOVEFLAG_ONTRANSPORT | MOVEFLAG_LEVITATING);
m_creature->SetLevitate(true);
m_creature->HandleEmoteCommand(EMOTE_ONESHOT_DANCE);
WorldPacket data; //send update position to client
m_creature->BuildHeartBeatMsg(&data);
m_creature->SendMessageToSet(&data,true);
}

void UpdateAI(const uint32 diff)
Expand Down Expand Up @@ -200,9 +197,6 @@ bool ReceiveEmote_npc_dancing_flames( Player *player, Creature *flame, uint32 em
flame->SetInFront(player);
((npc_dancing_flamesAI*)flame->AI())->active = false;

WorldPacket data;
flame->BuildHeartBeatMsg(&data);
flame->SendMessageToSet(&data,true);
switch(emote)
{
case TEXTEMOTE_KISS: flame->HandleEmoteCommand(EMOTE_ONESHOT_SHY); break;
Expand Down Expand Up @@ -413,7 +407,7 @@ struct TRINITY_DLL_DECL npc_injured_patientAI : public ScriptedAI
DoSay(SAY_DOC1,LANG_UNIVERSAL,NULL);

uint32 mobId = m_creature->GetEntry();
m_creature->RemoveUnitMovementFlag(SPLINEFLAG_WALKMODE_MODE);
m_creature->SetWalk(false);
switch (mobId)
{
case 12923:
Expand Down Expand Up @@ -1978,7 +1972,9 @@ struct TRINITY_DLL_DECL npc_crashin_trashin_robotAI : public ScriptedAI
m_creature->SetDefaultMovementType(RANDOM_MOTION_TYPE);
m_creature->GetMotionMaster()->Initialize();
m_creature->GetMotionMaster()->Clear();
m_creature->GetMotionMaster()->MoveRandom(10.0);

// Need random ?
m_creature->GetMotionMaster()->MoveRandom();
moveTimer = urand(1000, 10000);
despawnTimer = 180000;
}
Expand Down Expand Up @@ -2198,7 +2194,7 @@ struct TRINITY_DLL_DECL npc_lurkyAI : public ScriptedAI

void UpdateAI(const uint32 diff)
{
if (inDance || m_creature->hasUnitState(UNIT_STAT_MOVE))
if (inDance || !me->IsStopped())
return;

if (danceTimer < diff)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ struct TRINITY_DLL_DECL boss_nexusprince_shaffarAI : public ScriptedAI
HasTaunted = true;
}

if (!m_creature->canFly() && m_creature->GetDistanceZ(who) > CREATURE_Z_ATTACK_RANGE)
if (!m_creature->CanFly() && m_creature->GetDistanceZ(who) > CREATURE_Z_ATTACK_RANGE)
return;

float attackRadius = m_creature->GetAttackDistance(who);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ struct TRINITY_DLL_DECL boss_talon_king_ikissAI : public ScriptedAI
DoScriptText(SAY_INTRO, m_creature);
}

if (!m_creature->canFly() && m_creature->GetDistanceZ(who) > CREATURE_Z_ATTACK_RANGE)
if (!m_creature->CanFly() && m_creature->GetDistanceZ(who) > CREATURE_Z_ATTACK_RANGE)
return;

float attackRadius = m_creature->GetAttackDistance(who);
Expand Down Expand Up @@ -194,8 +194,7 @@ struct TRINITY_DLL_DECL boss_talon_king_ikissAI : public ScriptedAI
//Spell doesn't work, but we use for visual effect at least
DoCast(target,SPELL_BLINK);

m_creature->Relocate(wLoc.coord_x,wLoc.coord_y,wLoc.coord_z);
m_creature->SendMonsterMove(wLoc.coord_x,wLoc.coord_y,wLoc.coord_z, 0);
m_creature->NearTeleportTo(wLoc.coord_x,wLoc.coord_y,wLoc.coord_z, 0.0f);

DoCast(target,SPELL_BLINK_TELEPORT);
Blink = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ struct TRINITY_DLL_DECL boss_murmurAI : public Scripted_NoMovementAI
// Resonance
if(Resonance_Timer < diff)
{
if(!m_creature->hasUnitState(UNIT_STAT_CASTING))
if(!m_creature->IsNonMeleeSpellCasted(false))
{
Unit *target = SelectUnit(SELECT_TARGET_NEAREST, 0, 100, true);

Expand Down
6 changes: 3 additions & 3 deletions src/bindings/scripts/scripts/zone/azshara/azshara.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -305,13 +305,13 @@ struct TRINITY_DLL_DECL mob_rizzle_sprysprocketAI : public ScriptedAI
if(map)
{
map->CreatureRelocation(m_creature, 3706.39, -3969.15, 35.9118, 0);
m_creature->AI_SendMoveToPacket(3706.39, -3969.15, 35.9118, 0, 0, 0);
//m_creature->AI_SendMoveToPacket(3706.39, -3969.15, 35.9118, 0, 0, 0);
}
//begin swimming and summon depth charges
Player* player = Unit::GetPlayer(PlayerGUID);
SendText(MSG_ESCAPE_NOTICE, player);
DoCast(m_creature, SPELL_PERIODIC_DEPTH_CHARGE);
m_creature->SetUnitMovementFlags(SPLINEFLAG_FLYINGING2 | MOVEFLAG_SWIMMING);
m_creature->SetLevitate(true);
m_creature->SetSpeed(MOVE_RUN, 0.85f, true);
m_creature->GetMotionMaster()->MovementExpired();
m_creature->GetMotionMaster()->MovePoint(CurrWP, WPs[CurrWP][0], WPs[CurrWP][1], WPs[CurrWP][2]);
Expand Down Expand Up @@ -440,7 +440,7 @@ struct TRINITY_DLL_DECL mob_depth_chargeAI : public ScriptedAI

void Reset()
{
m_creature->SetUnitMovementFlags(SPLINEFLAG_FLYINGING2 | MOVEFLAG_SWIMMING);
m_creature->SetLevitate(true);
m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
we_must_die = false;
must_die_timer = 1000;
Expand Down
12 changes: 6 additions & 6 deletions src/bindings/scripts/scripts/zone/black_temple/boss_illidan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ struct TRINITY_DLL_DECL boss_illidan_stormrageAI : public BossAI
SetWarglaivesEquipped(false);

me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
me->RemoveUnitMovementFlag(MOVEFLAG_LEVITATING);
me->SetLevitate(false);
me->HandleEmoteCommand(EMOTE_ONESHOT_LAND);
me->SetSelection(NULL);

Expand All @@ -262,7 +262,7 @@ struct TRINITY_DLL_DECL boss_illidan_stormrageAI : public BossAI
ClearCastQueue();
events.CancelEventsByGCD(m_phase);

me->RemoveUnitMovementFlag(SPLINEFLAG_WALKMODE_MODE);
me->SetWalk(false);

switch (m_phase = phase)
{
Expand Down Expand Up @@ -330,7 +330,7 @@ struct TRINITY_DLL_DECL boss_illidan_stormrageAI : public BossAI
me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);

me->HandleEmoteCommand(EMOTE_ONESHOT_LIFTOFF);
me->AddUnitMovementFlag(MOVEFLAG_LEVITATING);
me->SetLevitate(true);

me->GetMotionMaster()->MovePoint(0, CENTER_X +5.0f, CENTER_Y, CENTER_Z);

Expand Down Expand Up @@ -523,7 +523,7 @@ struct TRINITY_DLL_DECL boss_illidan_stormrageAI : public BossAI
}
case EVENT_ILLIDAN_LAND:
{
me->RemoveUnitMovementFlag(MOVEFLAG_LEVITATING);
me->SetLevitate(false);
me->HandleEmoteCommand(EMOTE_ONESHOT_LAND);

me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
Expand Down Expand Up @@ -1239,7 +1239,7 @@ struct TRINITY_DLL_DECL boss_illidan_akamaAI : public BossAI
}
else
{
me->RemoveUnitMovementFlag(SPLINEFLAG_WALKMODE);
me->SetWalk(false);
me->GetMotionMaster()->MovePoint(0, 728.379f, 314.462f, 352.996f);
}
break;
Expand Down Expand Up @@ -1698,7 +1698,7 @@ struct TRINITY_DLL_DECL boss_illidan_flameofazzinothAI : public ScriptedAI

if(check_timer < diff)
{
me->RemoveUnitMovementFlag(SPLINEFLAG_WALKMODE_MODE);
me->SetWalk(false);
me->UpdateSpeed(MOVE_RUN, 2.5f);
me->UpdateSpeed(MOVE_WALK, 4.5f); // test?
check_timer = 2000;
Expand Down
Loading