mirror of
https://github.com/mangosfour/server.git
synced 2025-12-14 07:37:01 +00:00
[10902] Simplify code for triggering linked trap
This commit is contained in:
parent
2f4e7a9377
commit
d9579dd44a
3 changed files with 21 additions and 26 deletions
|
|
@ -720,7 +720,7 @@ void GameObject::Respawn()
|
|||
}
|
||||
}
|
||||
|
||||
bool GameObject::ActivateToQuest(Player *pTarget)const
|
||||
bool GameObject::ActivateToQuest(Player *pTarget) const
|
||||
{
|
||||
// if GO is ReqCreatureOrGoN for quest
|
||||
if (pTarget->HasQuestForGO(GetEntry()))
|
||||
|
|
@ -812,7 +812,6 @@ void GameObject::SummonLinkedTrapIfAny()
|
|||
GetPhaseMask(), GetPositionX(), GetPositionY(), GetPositionZ(), GetOrientation(), 0.0f, 0.0f, 0.0f, 0.0f, GO_ANIMPROGRESS_DEFAULT, GO_STATE_READY))
|
||||
{
|
||||
delete linkedGO;
|
||||
linkedGO = NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -828,10 +827,15 @@ void GameObject::SummonLinkedTrapIfAny()
|
|||
GetMap()->Add(linkedGO);
|
||||
}
|
||||
|
||||
void GameObject::TriggeringLinkedGameObject( uint32 trapEntry, Unit* target)
|
||||
void GameObject::TriggerLinkedGameObject(Unit* target)
|
||||
{
|
||||
uint32 trapEntry = GetGOInfo()->GetLinkedGameObjectEntry();
|
||||
|
||||
if (!trapEntry)
|
||||
return;
|
||||
|
||||
GameObjectInfo const* trapInfo = sGOStorage.LookupEntry<GameObjectInfo>(trapEntry);
|
||||
if(!trapInfo || trapInfo->type!=GAMEOBJECT_TYPE_TRAP)
|
||||
if (!trapInfo || trapInfo->type != GAMEOBJECT_TYPE_TRAP)
|
||||
return;
|
||||
|
||||
SpellEntry const* trapSpell = sSpellStore.LookupEntry(trapInfo->trap.spellId);
|
||||
|
|
@ -920,7 +924,7 @@ void GameObject::Use(Unit* user)
|
|||
|
||||
switch(GetGoType())
|
||||
{
|
||||
case GAMEOBJECT_TYPE_DOOR: //0
|
||||
case GAMEOBJECT_TYPE_DOOR: // 0
|
||||
{
|
||||
//doors never really despawn, only reset to default state/flags
|
||||
UseDoorOrButton();
|
||||
|
|
@ -929,7 +933,7 @@ void GameObject::Use(Unit* user)
|
|||
GetMap()->ScriptsStart(sGameObjectScripts, GetDBTableGUIDLow(), spellCaster, this);
|
||||
return;
|
||||
}
|
||||
case GAMEOBJECT_TYPE_BUTTON: //1
|
||||
case GAMEOBJECT_TYPE_BUTTON: // 1
|
||||
{
|
||||
//buttons never really despawn, only reset to default state/flags
|
||||
UseDoorOrButton();
|
||||
|
|
@ -937,13 +941,10 @@ void GameObject::Use(Unit* user)
|
|||
// activate script
|
||||
GetMap()->ScriptsStart(sGameObjectScripts, GetDBTableGUIDLow(), spellCaster, this);
|
||||
|
||||
// triggering linked GO
|
||||
if (uint32 trapEntry = GetGOInfo()->button.linkedTrapId)
|
||||
TriggeringLinkedGameObject(trapEntry, user);
|
||||
|
||||
TriggerLinkedGameObject(user);
|
||||
return;
|
||||
}
|
||||
case GAMEOBJECT_TYPE_QUESTGIVER: //2
|
||||
case GAMEOBJECT_TYPE_QUESTGIVER: // 2
|
||||
{
|
||||
if (user->GetTypeId() != TYPEID_PLAYER)
|
||||
return;
|
||||
|
|
@ -958,7 +959,7 @@ void GameObject::Use(Unit* user)
|
|||
|
||||
return;
|
||||
}
|
||||
case GAMEOBJECT_TYPE_CHEST:
|
||||
case GAMEOBJECT_TYPE_CHEST: // 3
|
||||
{
|
||||
if (user->GetTypeId() != TYPEID_PLAYER)
|
||||
return;
|
||||
|
|
@ -972,10 +973,7 @@ void GameObject::Use(Unit* user)
|
|||
GetMap()->ScriptsStart(sEventScripts, GetGOInfo()->chest.eventId, user, this);
|
||||
}
|
||||
|
||||
// triggering linked GO
|
||||
if (uint32 trapEntry = GetGOInfo()->chest.linkedTrapId)
|
||||
TriggeringLinkedGameObject(trapEntry, user);
|
||||
|
||||
TriggerLinkedGameObject(user);
|
||||
return;
|
||||
}
|
||||
case GAMEOBJECT_TYPE_GENERIC: // 5
|
||||
|
|
@ -987,7 +985,7 @@ void GameObject::Use(Unit* user)
|
|||
case GAMEOBJECT_TYPE_TRAP: // 6
|
||||
{
|
||||
// Currently we do not expect trap code below to be Use()
|
||||
// directly (except from spell effect). Code here will be called by TriggeringLinkedGameObject.
|
||||
// directly (except from spell effect). Code here will be called by TriggerLinkedGameObject.
|
||||
|
||||
// FIXME: when GO casting will be implemented trap must cast spell to target
|
||||
if (uint32 spellId = GetGOInfo()->trap.spellId)
|
||||
|
|
@ -1058,11 +1056,9 @@ void GameObject::Use(Unit* user)
|
|||
player->SetStandState(UNIT_STAND_STATE_SIT_LOW_CHAIR+info->chair.height);
|
||||
return;
|
||||
}
|
||||
case GAMEOBJECT_TYPE_SPELL_FOCUS:
|
||||
case GAMEOBJECT_TYPE_SPELL_FOCUS: // 8
|
||||
{
|
||||
// triggering linked GO
|
||||
if (uint32 trapEntry = GetGOInfo()->spellFocus.linkedTrapId)
|
||||
TriggeringLinkedGameObject(trapEntry, user);
|
||||
TriggerLinkedGameObject(user);
|
||||
|
||||
// some may be activated in addition? Conditions for this? (ex: entry 181616)
|
||||
break;
|
||||
|
|
@ -1110,8 +1106,7 @@ void GameObject::Use(Unit* user)
|
|||
|
||||
}
|
||||
|
||||
if (uint32 trapEntry = info->goober.linkedTrapId)
|
||||
TriggeringLinkedGameObject(trapEntry, user);
|
||||
TriggerLinkedGameObject(user);
|
||||
|
||||
SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_IN_USE);
|
||||
SetLootState(GO_ACTIVATED);
|
||||
|
|
@ -1497,7 +1492,7 @@ void GameObject::Use(Unit* user)
|
|||
return;
|
||||
}
|
||||
|
||||
Spell *spell = new Spell(spellCaster, spellInfo, triggered,GetGUID());
|
||||
Spell *spell = new Spell(spellCaster, spellInfo, triggered, GetObjectGuid());
|
||||
|
||||
// spell target is user of GO
|
||||
SpellCastTargets targets;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue