mirror of
https://github.com/mangosfour/server.git
synced 2025-12-14 16: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 GO is ReqCreatureOrGoN for quest
|
||||||
if (pTarget->HasQuestForGO(GetEntry()))
|
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))
|
GetPhaseMask(), GetPositionX(), GetPositionY(), GetPositionZ(), GetOrientation(), 0.0f, 0.0f, 0.0f, 0.0f, GO_ANIMPROGRESS_DEFAULT, GO_STATE_READY))
|
||||||
{
|
{
|
||||||
delete linkedGO;
|
delete linkedGO;
|
||||||
linkedGO = NULL;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -828,10 +827,15 @@ void GameObject::SummonLinkedTrapIfAny()
|
||||||
GetMap()->Add(linkedGO);
|
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);
|
GameObjectInfo const* trapInfo = sGOStorage.LookupEntry<GameObjectInfo>(trapEntry);
|
||||||
if(!trapInfo || trapInfo->type!=GAMEOBJECT_TYPE_TRAP)
|
if (!trapInfo || trapInfo->type != GAMEOBJECT_TYPE_TRAP)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
SpellEntry const* trapSpell = sSpellStore.LookupEntry(trapInfo->trap.spellId);
|
SpellEntry const* trapSpell = sSpellStore.LookupEntry(trapInfo->trap.spellId);
|
||||||
|
|
@ -920,7 +924,7 @@ void GameObject::Use(Unit* user)
|
||||||
|
|
||||||
switch(GetGoType())
|
switch(GetGoType())
|
||||||
{
|
{
|
||||||
case GAMEOBJECT_TYPE_DOOR: //0
|
case GAMEOBJECT_TYPE_DOOR: // 0
|
||||||
{
|
{
|
||||||
//doors never really despawn, only reset to default state/flags
|
//doors never really despawn, only reset to default state/flags
|
||||||
UseDoorOrButton();
|
UseDoorOrButton();
|
||||||
|
|
@ -929,7 +933,7 @@ void GameObject::Use(Unit* user)
|
||||||
GetMap()->ScriptsStart(sGameObjectScripts, GetDBTableGUIDLow(), spellCaster, this);
|
GetMap()->ScriptsStart(sGameObjectScripts, GetDBTableGUIDLow(), spellCaster, this);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
case GAMEOBJECT_TYPE_BUTTON: //1
|
case GAMEOBJECT_TYPE_BUTTON: // 1
|
||||||
{
|
{
|
||||||
//buttons never really despawn, only reset to default state/flags
|
//buttons never really despawn, only reset to default state/flags
|
||||||
UseDoorOrButton();
|
UseDoorOrButton();
|
||||||
|
|
@ -937,13 +941,10 @@ void GameObject::Use(Unit* user)
|
||||||
// activate script
|
// activate script
|
||||||
GetMap()->ScriptsStart(sGameObjectScripts, GetDBTableGUIDLow(), spellCaster, this);
|
GetMap()->ScriptsStart(sGameObjectScripts, GetDBTableGUIDLow(), spellCaster, this);
|
||||||
|
|
||||||
// triggering linked GO
|
TriggerLinkedGameObject(user);
|
||||||
if (uint32 trapEntry = GetGOInfo()->button.linkedTrapId)
|
|
||||||
TriggeringLinkedGameObject(trapEntry, user);
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
case GAMEOBJECT_TYPE_QUESTGIVER: //2
|
case GAMEOBJECT_TYPE_QUESTGIVER: // 2
|
||||||
{
|
{
|
||||||
if (user->GetTypeId() != TYPEID_PLAYER)
|
if (user->GetTypeId() != TYPEID_PLAYER)
|
||||||
return;
|
return;
|
||||||
|
|
@ -958,7 +959,7 @@ void GameObject::Use(Unit* user)
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
case GAMEOBJECT_TYPE_CHEST:
|
case GAMEOBJECT_TYPE_CHEST: // 3
|
||||||
{
|
{
|
||||||
if (user->GetTypeId() != TYPEID_PLAYER)
|
if (user->GetTypeId() != TYPEID_PLAYER)
|
||||||
return;
|
return;
|
||||||
|
|
@ -972,10 +973,7 @@ void GameObject::Use(Unit* user)
|
||||||
GetMap()->ScriptsStart(sEventScripts, GetGOInfo()->chest.eventId, user, this);
|
GetMap()->ScriptsStart(sEventScripts, GetGOInfo()->chest.eventId, user, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
// triggering linked GO
|
TriggerLinkedGameObject(user);
|
||||||
if (uint32 trapEntry = GetGOInfo()->chest.linkedTrapId)
|
|
||||||
TriggeringLinkedGameObject(trapEntry, user);
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
case GAMEOBJECT_TYPE_GENERIC: // 5
|
case GAMEOBJECT_TYPE_GENERIC: // 5
|
||||||
|
|
@ -987,7 +985,7 @@ void GameObject::Use(Unit* user)
|
||||||
case GAMEOBJECT_TYPE_TRAP: // 6
|
case GAMEOBJECT_TYPE_TRAP: // 6
|
||||||
{
|
{
|
||||||
// Currently we do not expect trap code below to be Use()
|
// 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
|
// FIXME: when GO casting will be implemented trap must cast spell to target
|
||||||
if (uint32 spellId = GetGOInfo()->trap.spellId)
|
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);
|
player->SetStandState(UNIT_STAND_STATE_SIT_LOW_CHAIR+info->chair.height);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
case GAMEOBJECT_TYPE_SPELL_FOCUS:
|
case GAMEOBJECT_TYPE_SPELL_FOCUS: // 8
|
||||||
{
|
{
|
||||||
// triggering linked GO
|
TriggerLinkedGameObject(user);
|
||||||
if (uint32 trapEntry = GetGOInfo()->spellFocus.linkedTrapId)
|
|
||||||
TriggeringLinkedGameObject(trapEntry, user);
|
|
||||||
|
|
||||||
// some may be activated in addition? Conditions for this? (ex: entry 181616)
|
// some may be activated in addition? Conditions for this? (ex: entry 181616)
|
||||||
break;
|
break;
|
||||||
|
|
@ -1110,8 +1106,7 @@ void GameObject::Use(Unit* user)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (uint32 trapEntry = info->goober.linkedTrapId)
|
TriggerLinkedGameObject(user);
|
||||||
TriggeringLinkedGameObject(trapEntry, user);
|
|
||||||
|
|
||||||
SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_IN_USE);
|
SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_IN_USE);
|
||||||
SetLootState(GO_ACTIVATED);
|
SetLootState(GO_ACTIVATED);
|
||||||
|
|
@ -1497,7 +1492,7 @@ void GameObject::Use(Unit* user)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Spell *spell = new Spell(spellCaster, spellInfo, triggered,GetGUID());
|
Spell *spell = new Spell(spellCaster, spellInfo, triggered, GetObjectGuid());
|
||||||
|
|
||||||
// spell target is user of GO
|
// spell target is user of GO
|
||||||
SpellCastTargets targets;
|
SpellCastTargets targets;
|
||||||
|
|
|
||||||
|
|
@ -695,7 +695,7 @@ class MANGOS_DLL_SPEC GameObject : public WorldObject
|
||||||
bool IsFriendlyTo(Unit const* unit) const;
|
bool IsFriendlyTo(Unit const* unit) const;
|
||||||
|
|
||||||
void SummonLinkedTrapIfAny();
|
void SummonLinkedTrapIfAny();
|
||||||
void TriggeringLinkedGameObject( uint32 trapEntry, Unit* target);
|
void TriggerLinkedGameObject(Unit* target);
|
||||||
|
|
||||||
bool isVisibleForInState(Player const* u, WorldObject const* viewPoint, bool inVisibleList) const;
|
bool isVisibleForInState(Player const* u, WorldObject const* viewPoint, bool inVisibleList) const;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#ifndef __REVISION_NR_H__
|
#ifndef __REVISION_NR_H__
|
||||||
#define __REVISION_NR_H__
|
#define __REVISION_NR_H__
|
||||||
#define REVISION_NR "10901"
|
#define REVISION_NR "10902"
|
||||||
#endif // __REVISION_NR_H__
|
#endif // __REVISION_NR_H__
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue