Core/GameObjects: Implemented AllowMultiInteract for GAMEOBJECT_TYPE_GOOBER

Port From (https://github.com/TrinityCore/TrinityCore/commit/f52f2cc67ad91fa9017f6739e0efdf9677c5d629)
This commit is contained in:
hondacrx
2022-10-22 22:32:25 -04:00
parent 66ad9f4ce0
commit d457828f3b
4 changed files with 49 additions and 18 deletions
+30 -17
View File
@@ -957,6 +957,14 @@ namespace Game.Entities
}
}
void DespawnForPlayer(Player seer, TimeSpan respawnTime)
{
PerPlayerState perPlayerState = GetOrCreatePerPlayerStates()[seer.GetGUID()];
perPlayerState.ValidUntil = GameTime.GetSystemTime() + respawnTime;
perPlayerState.Despawned = true;
seer.UpdateVisibilityOf(this);
}
public void Delete()
{
SetLootState(LootState.NotReady);
@@ -1891,11 +1899,10 @@ namespace Game.Entities
case GameObjectTypes.Goober: //10
{
GameObjectTemplate info = GetGoInfo();
Player player = user.ToPlayer();
if (user.IsTypeId(TypeId.Player))
if (player != null)
{
Player player = user.ToPlayer();
if (info.Goober.pageID != 0) // show page...
{
PageTextPkt data = new();
@@ -1941,16 +1948,26 @@ namespace Game.Entities
if (trapEntry != 0)
TriggeringLinkedGameObject(trapEntry, user);
SetFlag(GameObjectFlags.InUse);
SetLootState(LootState.Activated, user);
// this appear to be ok, however others exist in addition to this that should have custom (ex: 190510, 188692, 187389)
if (info.Goober.customAnim != 0)
SendCustomAnim(GetGoAnimProgress());
if (info.Goober.AllowMultiInteract != 0 && player != null)
{
if (info.IsDespawnAtAction())
DespawnForPlayer(player, TimeSpan.FromSeconds(m_respawnDelayTime));
else
SetGoStateFor(GameObjectState.Active, player);
}
else
SetGoState(GameObjectState.Active);
{
SetFlag(GameObjectFlags.InUse);
SetLootState(LootState.Activated, user);
m_cooldownTime = GameTime.GetGameTimeMS() + info.GetAutoCloseTime();
// this appear to be ok, however others exist in addition to this that should have custom (ex: 190510, 188692, 187389)
if (info.Goober.customAnim != 0)
SendCustomAnim(GetGoAnimProgress());
else
SetGoState(GameObjectState.Active);
m_cooldownTime = GameTime.GetGameTimeMS() + info.GetAutoCloseTime();
}
// cast this spell later if provided
spellId = info.Goober.spell;
@@ -2906,14 +2923,10 @@ namespace Game.Entities
GameObjectTemplate goInfo = GetGoInfo();
if (goInfo.Chest.consumable == 0 && goInfo.Chest.chestPersonalLoot != 0)
{
PerPlayerState perPlayerState = GetOrCreatePerPlayerStates()[looter.GetGUID()];
perPlayerState.ValidUntil = GameTime.GetSystemTime() + (goInfo.Chest.chestRestockTime != 0
DespawnForPlayer(looter, goInfo.Chest.chestRestockTime != 0
? TimeSpan.FromSeconds(goInfo.Chest.chestRestockTime)
: TimeSpan.FromSeconds(m_respawnDelayTime)); // not hiding this object permanently to prevent infinite growth of m_perPlayerState
// while also maintaining some sort of cheater protection (not getting rid of entries on logout)
perPlayerState.Despawned = true;
looter.UpdateVisibilityOf(this);
// while also maintaining some sort of cheater protection (not getting rid of entries on logout)
}
break;
}
@@ -131,12 +131,21 @@ namespace Game.Entities
dynFlags |= GameObjectDynamicLowFlags.Activate;
break;
case GameObjectTypes.Chest:
case GameObjectTypes.Goober:
if (gameObject.ActivateToQuest(receiver))
dynFlags |= GameObjectDynamicLowFlags.Activate | GameObjectDynamicLowFlags.Sparkle | GameObjectDynamicLowFlags.Highlight;
else if (receiver.IsGameMaster())
dynFlags |= GameObjectDynamicLowFlags.Activate;
break;
case GameObjectTypes.Goober:
if (gameObject.ActivateToQuest(receiver))
{
dynFlags |= GameObjectDynamicLowFlags.Highlight;
if (gameObject.GetGoStateFor(receiver.GetGUID()) != GameObjectState.Active)
dynFlags |= GameObjectDynamicLowFlags.Activate;
}
else if (receiver.IsGameMaster())
dynFlags |= GameObjectDynamicLowFlags.Activate;
break;
case GameObjectTypes.Generic:
if (gameObject.ActivateToQuest(receiver))
dynFlags |= GameObjectDynamicLowFlags.Sparkle | GameObjectDynamicLowFlags.Highlight;
@@ -2978,6 +2978,7 @@ namespace Game.Entities
case GameObjectTypes.Chest:
case GameObjectTypes.Goober:
case GameObjectTypes.Generic:
case GameObjectTypes.GatheringNode:
if (Global.ObjectMgr.IsGameObjectForQuests(obj.GetEntry()))
objMask.MarkChanged(obj.m_objectData.DynamicFlags);
break;
+8
View File
@@ -4709,6 +4709,14 @@ namespace Game
continue;
}
case GameObjectTypes.GatheringNode:
{
// scan GO chest with loot including quest items
// find quest loot for GO
if (LootStorage.Gameobject.HaveQuestLootFor(pair.Value.GatheringNode.chestLoot))
break;
continue;
}
default:
continue;
}