mirror of
https://github.com/mangosfour/server.git
synced 2025-12-15 19:37:02 +00:00
[11848] Change use of ScriptLibrary OnGOUse return value in GO::Use
Now mainly used to allow or prevent DB scripts use Also some related code cleaned and reordered Signed-off-by: Schmoozerd <schmoozerd@scriptdev2.com>
This commit is contained in:
parent
c814e10481
commit
3ae1f25b9b
2 changed files with 58 additions and 46 deletions
|
|
@ -934,9 +934,6 @@ void GameObject::Use(Unit* user)
|
||||||
uint32 spellId = 0;
|
uint32 spellId = 0;
|
||||||
bool triggered = false;
|
bool triggered = false;
|
||||||
|
|
||||||
if (user->GetTypeId() == TYPEID_PLAYER && sScriptMgr.OnGameObjectUse((Player*)user, this))
|
|
||||||
return;
|
|
||||||
|
|
||||||
// test only for exist cooldown data (cooldown timer used for door/buttons reset that not have use cooldown)
|
// test only for exist cooldown data (cooldown timer used for door/buttons reset that not have use cooldown)
|
||||||
if (uint32 cooldown = GetGOInfo()->GetCooldown())
|
if (uint32 cooldown = GetGOInfo()->GetCooldown())
|
||||||
{
|
{
|
||||||
|
|
@ -946,6 +943,8 @@ void GameObject::Use(Unit* user)
|
||||||
m_cooldownTime = sWorld.GetGameTime() + cooldown;
|
m_cooldownTime = sWorld.GetGameTime() + cooldown;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool scriptReturnValue = user->GetTypeId() == TYPEID_PLAYER && sScriptMgr.OnGameObjectUse((Player*)user, this);
|
||||||
|
|
||||||
switch (GetGoType())
|
switch (GetGoType())
|
||||||
{
|
{
|
||||||
case GAMEOBJECT_TYPE_DOOR: // 0
|
case GAMEOBJECT_TYPE_DOOR: // 0
|
||||||
|
|
@ -954,6 +953,7 @@ void GameObject::Use(Unit* user)
|
||||||
UseDoorOrButton();
|
UseDoorOrButton();
|
||||||
|
|
||||||
// activate script
|
// activate script
|
||||||
|
if (!scriptReturnValue)
|
||||||
GetMap()->ScriptsStart(sGameObjectScripts, GetGUIDLow(), spellCaster, this);
|
GetMap()->ScriptsStart(sGameObjectScripts, GetGUIDLow(), spellCaster, this);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -962,10 +962,12 @@ void GameObject::Use(Unit* user)
|
||||||
//buttons never really despawn, only reset to default state/flags
|
//buttons never really despawn, only reset to default state/flags
|
||||||
UseDoorOrButton();
|
UseDoorOrButton();
|
||||||
|
|
||||||
|
TriggerLinkedGameObject(user);
|
||||||
|
|
||||||
// activate script
|
// activate script
|
||||||
|
if (!scriptReturnValue)
|
||||||
GetMap()->ScriptsStart(sGameObjectScripts, GetGUIDLow(), spellCaster, this);
|
GetMap()->ScriptsStart(sGameObjectScripts, GetGUIDLow(), spellCaster, this);
|
||||||
|
|
||||||
TriggerLinkedGameObject(user);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
case GAMEOBJECT_TYPE_QUESTGIVER: // 2
|
case GAMEOBJECT_TYPE_QUESTGIVER: // 2
|
||||||
|
|
@ -988,6 +990,8 @@ void GameObject::Use(Unit* user)
|
||||||
if (user->GetTypeId() != TYPEID_PLAYER)
|
if (user->GetTypeId() != TYPEID_PLAYER)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
TriggerLinkedGameObject(user);
|
||||||
|
|
||||||
// TODO: possible must be moved to loot release (in different from linked triggering)
|
// TODO: possible must be moved to loot release (in different from linked triggering)
|
||||||
if (GetGOInfo()->chest.eventId)
|
if (GetGOInfo()->chest.eventId)
|
||||||
{
|
{
|
||||||
|
|
@ -997,11 +1001,13 @@ void GameObject::Use(Unit* user)
|
||||||
GetMap()->ScriptsStart(sEventScripts, GetGOInfo()->chest.eventId, user, this);
|
GetMap()->ScriptsStart(sEventScripts, GetGOInfo()->chest.eventId, user, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
TriggerLinkedGameObject(user);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
case GAMEOBJECT_TYPE_GENERIC: // 5
|
case GAMEOBJECT_TYPE_GENERIC: // 5
|
||||||
{
|
{
|
||||||
|
if (scriptReturnValue)
|
||||||
|
return;
|
||||||
|
|
||||||
// No known way to exclude some - only different approach is to select despawnable GOs by Entry
|
// No known way to exclude some - only different approach is to select despawnable GOs by Entry
|
||||||
SetLootState(GO_JUST_DEACTIVATED);
|
SetLootState(GO_JUST_DEACTIVATED);
|
||||||
return;
|
return;
|
||||||
|
|
@ -1011,8 +1017,11 @@ void GameObject::Use(Unit* user)
|
||||||
// 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 TriggerLinkedGameObject.
|
// directly (except from spell effect). Code here will be called by TriggerLinkedGameObject.
|
||||||
|
|
||||||
|
if (scriptReturnValue)
|
||||||
|
return;
|
||||||
|
|
||||||
// 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 (spellId = GetGOInfo()->trap.spellId)
|
||||||
user->CastSpell(user, spellId, true, NULL, NULL, GetObjectGuid());
|
user->CastSpell(user, spellId, true, NULL, NULL, GetObjectGuid());
|
||||||
|
|
||||||
// TODO: all traps can be activated, also those without spell.
|
// TODO: all traps can be activated, also those without spell.
|
||||||
|
|
@ -1089,12 +1098,25 @@ void GameObject::Use(Unit* user)
|
||||||
TriggerLinkedGameObject(user);
|
TriggerLinkedGameObject(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;
|
return;
|
||||||
}
|
}
|
||||||
case GAMEOBJECT_TYPE_GOOBER: // 10
|
case GAMEOBJECT_TYPE_GOOBER: // 10
|
||||||
{
|
{
|
||||||
GameObjectInfo const* info = GetGOInfo();
|
GameObjectInfo const* info = GetGOInfo();
|
||||||
|
|
||||||
|
TriggerLinkedGameObject(user);
|
||||||
|
|
||||||
|
SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_IN_USE);
|
||||||
|
SetLootState(GO_ACTIVATED);
|
||||||
|
|
||||||
|
// this appear to be ok, however others exist in addition to this that should have custom (ex: 190510, 188692, 187389)
|
||||||
|
if (info->goober.customAnim)
|
||||||
|
SendGameObjectCustomAnim(GetObjectGuid());
|
||||||
|
else
|
||||||
|
SetGoState(GO_STATE_ACTIVE);
|
||||||
|
|
||||||
|
m_cooldownTime = time(NULL) + info->GetAutoCloseTime();
|
||||||
|
|
||||||
if (user->GetTypeId() == TYPEID_PLAYER)
|
if (user->GetTypeId() == TYPEID_PLAYER)
|
||||||
{
|
{
|
||||||
Player* player = (Player*)user;
|
Player* player = (Player*)user;
|
||||||
|
|
@ -1134,18 +1156,8 @@ void GameObject::Use(Unit* user)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TriggerLinkedGameObject(user);
|
if (scriptReturnValue)
|
||||||
|
return;
|
||||||
SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_IN_USE);
|
|
||||||
SetLootState(GO_ACTIVATED);
|
|
||||||
|
|
||||||
// this appear to be ok, however others exist in addition to this that should have custom (ex: 190510, 188692, 187389)
|
|
||||||
if (info->goober.customAnim)
|
|
||||||
SendGameObjectCustomAnim(GetObjectGuid());
|
|
||||||
else
|
|
||||||
SetGoState(GO_STATE_ACTIVE);
|
|
||||||
|
|
||||||
m_cooldownTime = time(NULL) + info->GetAutoCloseTime();
|
|
||||||
|
|
||||||
// cast this spell later if provided
|
// cast this spell later if provided
|
||||||
spellId = info->goober.spellId;
|
spellId = info->goober.spellId;
|
||||||
|
|
@ -1597,7 +1609,7 @@ void GameObject::Use(Unit* user)
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
sLog.outError("GameObject::Use unhandled GameObject type %u (entry %u).", GetGoType(), GetEntry());
|
sLog.outError("GameObject::Use unhandled GameObject type %u (entry %u).", GetGoType(), GetEntry());
|
||||||
break;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!spellId)
|
if (!spellId)
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#ifndef __REVISION_NR_H__
|
#ifndef __REVISION_NR_H__
|
||||||
#define __REVISION_NR_H__
|
#define __REVISION_NR_H__
|
||||||
#define REVISION_NR "11847"
|
#define REVISION_NR "11848"
|
||||||
#endif // __REVISION_NR_H__
|
#endif // __REVISION_NR_H__
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue