[9317] Call linkedtrap summon in more cases.

* GAMEOBJECT_TYPE_BUTTON can have linked traps
* Spell::EffectSummonObject also can summon objects with linked traps

Thanks to patman128 for research second case.

Signed-off-by: VladimirMangos <vladimir@getmangos.com>
This commit is contained in:
VladimirMangos 2010-02-07 00:48:23 +03:00
parent 02c23b247e
commit 87a35b0489
5 changed files with 52 additions and 43 deletions

View file

@ -770,6 +770,33 @@ bool GameObject::ActivateToQuest( Player *pTarget)const
return false; return false;
} }
void GameObject::SummonLinkedTrapIfAny()
{
uint32 linkedEntry = GetGOInfo()->GetLinkedGameObjectEntry();
if (!linkedEntry)
return;
GameObject* linkedGO = new GameObject;
if (!linkedGO->Create(sObjectMgr.GenerateLowGuid(HIGHGUID_GAMEOBJECT), linkedEntry, GetMap(),
GetPhaseMask(), GetPositionX(), GetPositionY(), GetPositionZ(), GetOrientation(), 0.0f, 0.0f, 0.0f, 0.0f, 100, GO_STATE_READY))
{
delete linkedGO;
linkedGO = NULL;
return;
}
linkedGO->SetRespawnTime(GetRespawnDelay());
linkedGO->SetSpellId(GetSpellId());
if (GetOwnerGUID())
{
linkedGO->SetOwnerGUID(GetOwnerGUID());
linkedGO->SetUInt32Value(GAMEOBJECT_LEVEL, GetUInt32Value(GAMEOBJECT_LEVEL));
}
GetMap()->Add(linkedGO);
}
void GameObject::TriggeringLinkedGameObject( uint32 trapEntry, Unit* target) void GameObject::TriggeringLinkedGameObject( uint32 trapEntry, Unit* target)
{ {
GameObjectInfo const* trapInfo = sGOStorage.LookupEntry<GameObjectInfo>(trapEntry); GameObjectInfo const* trapInfo = sGOStorage.LookupEntry<GameObjectInfo>(trapEntry);
@ -869,15 +896,28 @@ void GameObject::Use(Unit* user)
switch(GetGoType()) switch(GetGoType())
{ {
case GAMEOBJECT_TYPE_DOOR: //0 case GAMEOBJECT_TYPE_DOOR: //0
case GAMEOBJECT_TYPE_BUTTON: //1
{ {
//doors/buttons never really despawn, only reset to default state/flags //doors never really despawn, only reset to default state/flags
UseDoorOrButton(); UseDoorOrButton();
// activate script // activate script
GetMap()->ScriptsStart(sGameObjectScripts, GetDBTableGUIDLow(), spellCaster, this); GetMap()->ScriptsStart(sGameObjectScripts, GetDBTableGUIDLow(), spellCaster, this);
return; return;
} }
case GAMEOBJECT_TYPE_BUTTON: //1
{
//buttons never really despawn, only reset to default state/flags
UseDoorOrButton();
// activate script
GetMap()->ScriptsStart(sGameObjectScripts, GetDBTableGUIDLow(), spellCaster, this);
// triggering linked GO
if (uint32 trapEntry = GetGOInfo()->button.linkedTrapId)
TriggeringLinkedGameObject(trapEntry, user);
return;
}
case GAMEOBJECT_TYPE_QUESTGIVER: //2 case GAMEOBJECT_TYPE_QUESTGIVER: //2
{ {
if (user->GetTypeId() != TYPEID_PLAYER) if (user->GetTypeId() != TYPEID_PLAYER)

View file

@ -65,7 +65,7 @@ struct GameObjectInfo
uint32 startOpen; //0 uint32 startOpen; //0
uint32 lockId; //1 -> Lock.dbc uint32 lockId; //1 -> Lock.dbc
uint32 autoCloseTime; //2 secs till autoclose = autoCloseTime / IN_MILISECONDS (previous was 0x10000) uint32 autoCloseTime; //2 secs till autoclose = autoCloseTime / IN_MILISECONDS (previous was 0x10000)
uint32 linkedTrap; //3 uint32 linkedTrapId; //3
uint32 noDamageImmune; //4 isBattlegroundObject uint32 noDamageImmune; //4 isBattlegroundObject
uint32 large; //5 uint32 large; //5
uint32 openTextID; //6 can be used to replace castBarCaption? uint32 openTextID; //6 can be used to replace castBarCaption?
@ -457,6 +457,7 @@ struct GameObjectInfo
{ {
switch(type) switch(type)
{ {
case GAMEOBJECT_TYPE_BUTTON: return button.linkedTrapId;
case GAMEOBJECT_TYPE_CHEST: return chest.linkedTrapId; case GAMEOBJECT_TYPE_CHEST: return chest.linkedTrapId;
case GAMEOBJECT_TYPE_SPELL_FOCUS: return spellFocus.linkedTrapId; case GAMEOBJECT_TYPE_SPELL_FOCUS: return spellFocus.linkedTrapId;
case GAMEOBJECT_TYPE_GOOBER: return goober.linkedTrapId; case GAMEOBJECT_TYPE_GOOBER: return goober.linkedTrapId;
@ -677,6 +678,7 @@ class MANGOS_DLL_SPEC GameObject : public WorldObject
void ResetDoorOrButton(); void ResetDoorOrButton();
void SummonLinkedTrapIfAny();
void TriggeringLinkedGameObject( uint32 trapEntry, Unit* target); void TriggeringLinkedGameObject( uint32 trapEntry, Unit* target);
bool isVisibleForInState(Player const* u, WorldObject const* viewPoint, bool inVisibleList) const; bool isVisibleForInState(Player const* u, WorldObject const* viewPoint, bool inVisibleList) const;

View file

@ -5959,6 +5959,8 @@ void ObjectMgr::LoadGameobjectInfo()
{ {
if (goInfo->button.lockId) if (goInfo->button.lockId)
CheckGOLockId(goInfo,goInfo->button.lockId,1); CheckGOLockId(goInfo,goInfo->button.lockId,1);
if (goInfo->button.linkedTrapId) // linked trap
CheckGOLinkedTrapId(goInfo,goInfo->button.linkedTrapId,3);
CheckGONoDamageImmuneId(goInfo,goInfo->button.noDamageImmune,4); CheckGONoDamageImmuneId(goInfo,goInfo->button.noDamageImmune,4);
break; break;
} }

View file

@ -4922,25 +4922,7 @@ void Spell::EffectSummonObjectWild(uint32 i)
} }
} }
if(uint32 linkedEntry = pGameObj->GetGOInfo()->GetLinkedGameObjectEntry()) pGameObj->SummonLinkedTrapIfAny();
{
GameObject* linkedGO = new GameObject;
if(linkedGO->Create(sObjectMgr.GenerateLowGuid(HIGHGUID_GAMEOBJECT), linkedEntry, map,
m_caster->GetPhaseMask(), x, y, z, target->GetOrientation(), 0.0f, 0.0f, 0.0f, 0.0f, 100, GO_STATE_READY))
{
linkedGO->SetRespawnTime(duration > 0 ? duration/IN_MILISECONDS : 0);
linkedGO->SetSpellId(m_spellInfo->Id);
// Wild object not have owner and check clickable by players
map->Add(linkedGO);
}
else
{
delete linkedGO;
linkedGO = NULL;
return;
}
}
} }
void Spell::EffectScriptEffect(uint32 effIndex) void Spell::EffectScriptEffect(uint32 effIndex)
@ -6141,6 +6123,8 @@ void Spell::EffectSummonObject(uint32 i)
map->Add(pGameObj); map->Add(pGameObj);
m_caster->m_ObjectSlot[slot] = pGameObj->GetGUID(); m_caster->m_ObjectSlot[slot] = pGameObj->GetGUID();
pGameObj->SummonLinkedTrapIfAny();
} }
void Spell::EffectResurrect(uint32 /*effIndex*/) void Spell::EffectResurrect(uint32 /*effIndex*/)
@ -6763,26 +6747,7 @@ void Spell::EffectTransmitted(uint32 effIndex)
cMap->Add(pGameObj); cMap->Add(pGameObj);
if(uint32 linkedEntry = pGameObj->GetGOInfo()->GetLinkedGameObjectEntry()) pGameObj->SummonLinkedTrapIfAny();
{
GameObject* linkedGO = new GameObject;
if(linkedGO->Create(sObjectMgr.GenerateLowGuid(HIGHGUID_GAMEOBJECT), linkedEntry, cMap,
m_caster->GetPhaseMask(), fx, fy, fz, m_caster->GetOrientation(), 0.0f, 0.0f, 0.0f, 0.0f, 100, GO_STATE_READY))
{
linkedGO->SetRespawnTime(duration > 0 ? duration/IN_MILISECONDS : 0);
linkedGO->SetUInt32Value(GAMEOBJECT_LEVEL, m_caster->getLevel());
linkedGO->SetSpellId(m_spellInfo->Id);
linkedGO->SetOwnerGUID(m_caster->GetGUID());
linkedGO->GetMap()->Add(linkedGO);
}
else
{
delete linkedGO;
linkedGO = NULL;
return;
}
}
} }
void Spell::EffectProspecting(uint32 /*i*/) void Spell::EffectProspecting(uint32 /*i*/)

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__ #ifndef __REVISION_NR_H__
#define __REVISION_NR_H__ #define __REVISION_NR_H__
#define REVISION_NR "9316" #define REVISION_NR "9317"
#endif // __REVISION_NR_H__ #endif // __REVISION_NR_H__