Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Improve handle of SPELL_EFFECT_OPEN_LOCK for GAMEOBJECT_TYPE_TRAP
Improve the way traps are handled when targetted by SPELL_EFFECT_OPEN_LOCK (like disarm trap spell). Instead of being desactivated and despawning, they change state and use an alternate visual for the duration of the open lock (which is equal to the GO respawn time). They are then rearmed (back to GO_STATE_READY)

This should fix:
- the disarming of Suppression Device traps in BWL that were despawning instead of being disarmed
- quests 4734 and 4735 in UBRS where egg traps were still triggering instead of temporary changing state as expected
  • Loading branch information
cala committed Nov 1, 2017
1 parent bdbb19b commit 3368bca
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 7 deletions.
15 changes: 15 additions & 0 deletions src/game/Entities/GameObject.cpp
Expand Up @@ -71,6 +71,7 @@ GameObject::GameObject() : WorldObject(),

m_isInUse = false;
m_reStockTimer = 0;
m_rearmTimer = 0;
m_despawnTimer = 0;
}

Expand Down Expand Up @@ -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))
{
Expand Down
3 changes: 3 additions & 0 deletions src/game/Entities/GameObject.h
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/game/Globals/SharedDefines.h
Expand Up @@ -2059,6 +2059,7 @@ enum LockKeyType

enum LockType
{
LOCKTYPE_NONE = 0,
LOCKTYPE_PICKLOCK = 1,
LOCKTYPE_HERBALISM = 2,
LOCKTYPE_MINING = 3,
Expand Down
14 changes: 7 additions & 7 deletions src/game/Spells/SpellEffects.cpp
Expand Up @@ -1167,7 +1167,7 @@ void Spell::EffectDummy(SpellEffectIndex eff_idx)
creatureTarget->ForcedDespawn();
}
}

return;
}
case 23074: // Arcanite Dragonling
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 3368bca

Please sign in to comment.