Fix traps (#126)

* Fix .ticket surveyclose

* Fix trap activation with 0 charges
This commit is contained in:
Elmsroth 2020-12-30 19:32:57 +01:00 committed by GitHub
parent e242f1b7cc
commit 99a6b16acf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -409,8 +409,12 @@ void GameObject::Update(uint32 update_diff, uint32 p_time)
if (isSpawned())
{
// traps can have time and can not have
GameObjectInfo const* goInfo = GetGOInfo();
uint32 max_charges = goInfo->GetCharges();
if (goInfo->type == GAMEOBJECT_TYPE_TRAP) // traps
{
if (m_cooldownTime >= time(NULL))
@ -418,12 +422,6 @@ void GameObject::Update(uint32 update_diff, uint32 p_time)
return;
}
// cannot use more than trap charges
if (m_useTimes >= goInfo->GetCharges())
{
return;
}
// FIXME: this is activation radius (in different casting radius that must be selected from spell data)
// TODO: move activated state code (cast itself) to GO_ACTIVATED, in this place only check activating and set state
float radius = float(goInfo->trap.radius);
@ -475,15 +473,16 @@ void GameObject::Update(uint32 update_diff, uint32 p_time)
}
}
if (uint32 max_charges = goInfo->GetCharges())
{
if (m_useTimes >= max_charges)
// Only despawn object if there are charges to "consume"
// it means (all GO with charges = 0 in DB should never be despawned)
// Check : https://www.getmangos.eu/wiki/referenceinfo/dbinfo/mangosdb/mangoszeroworlddb/gameobject_template-r1047
// for more information about charges field in db depending on object type
if (max_charges > 0 && m_useTimes >= max_charges)
{
m_useTimes = 0;
SetLootState(GO_JUST_DEACTIVATED); // can be despawned or destroyed
}
}
}
break;
}
case GO_ACTIVATED: