diff --git a/src/game/Entities/GameObject.cpp b/src/game/Entities/GameObject.cpp index 89394b60e8a..4bfcb1cf9b8 100644 --- a/src/game/Entities/GameObject.cpp +++ b/src/game/Entities/GameObject.cpp @@ -71,6 +71,7 @@ GameObject::GameObject() : WorldObject(), m_isInUse = false; m_reStockTimer = 0; + m_rearmTimer = 0; m_despawnTimer = 0; } @@ -423,6 +424,20 @@ void GameObject::Update(uint32 update_diff, uint32 p_time) loot->Update(); } break; + case GAMEOBJECT_TYPE_TRAP: + if (m_rearmTimer == 0) + { + m_rearmTimer = time(nullptr) + GetRespawnDelay(); + SetGoState(GO_STATE_ACTIVE_ALTERNATIVE); + } + + if (m_rearmTimer < time(nullptr)) + { + SetGoState(GO_STATE_READY); + m_lootState = GO_READY; + m_rearmTimer = 0; + }; + break; case GAMEOBJECT_TYPE_GOOBER: if (m_cooldownTime < time(nullptr)) { diff --git a/src/game/Entities/GameObject.h b/src/game/Entities/GameObject.h index b5cc7c5feac..5c96c1b0587 100644 --- a/src/game/Entities/GameObject.h +++ b/src/game/Entities/GameObject.h @@ -836,6 +836,9 @@ class GameObject : public WorldObject ObjectGuid m_lootRecipientGuid; // player who will have rights for looting if m_lootGroupRecipient==0 or group disbanded uint32 m_lootGroupRecipientId; // group who will have rights for looting if set and exist + // Used for trap type + time_t m_rearmTimer; // timer to rearm the trap once disarmed + // Used for chest type bool m_isInUse; // only one player at time are allowed to open chest time_t m_reStockTimer; // timer to refill the chest diff --git a/src/game/Globals/SharedDefines.h b/src/game/Globals/SharedDefines.h index e9673a976ff..e6680d55973 100644 --- a/src/game/Globals/SharedDefines.h +++ b/src/game/Globals/SharedDefines.h @@ -2059,6 +2059,7 @@ enum LockKeyType enum LockType { + LOCKTYPE_NONE = 0, LOCKTYPE_PICKLOCK = 1, LOCKTYPE_HERBALISM = 2, LOCKTYPE_MINING = 3, diff --git a/src/game/Spells/SpellEffects.cpp b/src/game/Spells/SpellEffects.cpp index d4b94e4862a..ca4e78c30dc 100644 --- a/src/game/Spells/SpellEffects.cpp +++ b/src/game/Spells/SpellEffects.cpp @@ -1167,7 +1167,7 @@ void Spell::EffectDummy(SpellEffectIndex eff_idx) creatureTarget->ForcedDespawn(); } } - + return; } case 23074: // Arcanite Dragonling @@ -1246,7 +1246,7 @@ void Spell::EffectDummy(SpellEffectIndex eff_idx) return; } - case 24019: // Gurubashi Axe Thrower; Axe Flurry. + case 24019: // Gurubashi Axe Thrower; Axe Flurry. { if (unitTarget && m_caster->IsWithinLOSInMap(unitTarget)) m_caster->CastSpell(unitTarget, 24020, TRIGGERED_OLD_TRIGGERED); @@ -1521,7 +1521,7 @@ void Spell::EffectDummy(SpellEffectIndex eff_idx) case 39088: // second target the other m_scriptValue = 1; unitTarget->CastSpell(unitTarget, 39091, TRIGGERED_OLD_TRIGGERED); - break; + break; case 39091: m_scriptValue = 1; unitTarget->CastSpell(unitTarget, 39088, TRIGGERED_OLD_TRIGGERED); @@ -1557,7 +1557,7 @@ void Spell::EffectDummy(SpellEffectIndex eff_idx) case 0: spellId = 39241; break; // Summon Mature Bone Sifter case 1: spellId = 39240; break; // Summon Sand Gnome } - + m_caster->CastSpell(m_caster, spellId, TRIGGERED_OLD_TRIGGERED); return; } @@ -5264,9 +5264,9 @@ void Spell::SendLoot(ObjectGuid guid, LootType loottype, LockType lockType) break; case GAMEOBJECT_TYPE_TRAP: - if (lockType == LOCKTYPE_DISARM_TRAP) + if (lockType == LOCKTYPE_DISARM_TRAP || lockType == LOCKTYPE_NONE) { - gameObjTarget->SetLootState(GO_JUST_DEACTIVATED); + gameObjTarget->SetLootState(GO_ACTIVATED); return; } sLog.outError("Spell::SendLoot unhandled locktype %u for GameObject trap (entry %u) for spell %u.", lockType, gameObjTarget->GetEntry(), m_spellInfo->Id); @@ -10633,7 +10633,7 @@ void Spell::EffectStuck(SpellEffectIndex /*eff_idx*/) } else { - // If the player is alive, but their hearthstone is either not in their inventory (e.g. in the bank) or + // If the player is alive, but their hearthstone is either not in their inventory (e.g. in the bank) or // their hearthstone is on cooldown, then the game will try to "nudge" the player in a seemingly random direction. // @todo This check could possibly more accurately find a safe position to port to, has the potential for porting underground. float x, y, z;