Fix traps (#126)
* Fix .ticket surveyclose * Fix trap activation with 0 charges
This commit is contained in:
parent
e242f1b7cc
commit
99a6b16acf
@ -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,13 +473,14 @@ void GameObject::Update(uint32 update_diff, uint32 p_time)
|
||||
}
|
||||
}
|
||||
|
||||
if (uint32 max_charges = goInfo->GetCharges())
|
||||
// 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)
|
||||
{
|
||||
if (m_useTimes >= max_charges)
|
||||
{
|
||||
m_useTimes = 0;
|
||||
SetLootState(GO_JUST_DEACTIVATED); // can be despawned or destroyed
|
||||
}
|
||||
m_useTimes = 0;
|
||||
SetLootState(GO_JUST_DEACTIVATED); // can be despawned or destroyed
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
Loading…
x
Reference in New Issue
Block a user