Core/CreatureAI: Implement an OnSpellClick hook instead of the ugly way that uses DoAction with EVENT_SPELLCLICK.

Core/SmartAI: Implement SMART_EVENT_ON_SPELLCLICK. Parameter is the clicker.

If someone could update the wiki accordingly for SAI I would appreciate that. Thanks to @Shauren for some help!
This commit is contained in:
Discover-
2012-06-19 00:07:20 +02:00
parent 29f1ab2438
commit e190a202ca
11 changed files with 26 additions and 27 deletions

View File

@@ -1013,11 +1013,8 @@ class npc_dream_portal : public CreatureScript
{
}
void DoAction(int32 const action)
void OnSpellClick(Unit* /*clicker*/)
{
if (action != EVENT_SPELLCLICK)
return;
_used = true;
me->DespawnOrUnsummon();
}

View File

@@ -720,20 +720,18 @@ class boss_flame_leviathan_overload_device : public CreatureScript
{
}
void DoAction(const int32 param)
void OnSpellClick(Unit* /*clicker*/)
{
if (param == EVENT_SPELLCLICK)
if (me->GetVehicle())
{
if (me->GetVehicle())
me->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_SPELLCLICK);
me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
if (Unit* player = me->GetVehicle()->GetPassenger(SEAT_PLAYER))
{
me->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_SPELLCLICK);
me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
if (Unit* player = me->GetVehicle()->GetPassenger(SEAT_PLAYER))
{
me->GetVehicleBase()->CastSpell(player, SPELL_SMOKE_TRAIL, true);
player->GetMotionMaster()->MoveKnockbackFrom(me->GetVehicleBase()->GetPositionX(), me->GetVehicleBase()->GetPositionY(), 30, 30);
player->ExitVehicle();
}
me->GetVehicleBase()->CastSpell(player, SPELL_SMOKE_TRAIL, true);
player->GetMotionMaster()->MoveKnockbackFrom(me->GetVehicleBase()->GetPositionX(), me->GetVehicleBase()->GetPositionY(), 30, 30);
player->ExitVehicle();
}
}
}