fix for chest_traps not existing in DB

This commit is contained in:
Image 2020-04-14 16:23:37 -04:00
parent af90a2adaa
commit 16814d1787
2 changed files with 25 additions and 19 deletions

View file

@ -47,10 +47,10 @@ bool ChestTrapList::GetNextTrap(int32 zoneid, int32 chest_difficulty, ChestTrap:
ChestTrapList* zoneTrapList = GetChestListByZone(zoneid);
ChestTrapList* zoneDifficultyTrapList = zoneTrapList->GetChestListByDifficulty(chest_difficulty);
zoneTrapList->GetNextChestTrap(cti);
bool ret = zoneTrapList->GetNextChestTrap(cti);
MChestListsInUse.releasewritelock(__FUNCTION__, __LINE__);
return true;
return ret;
}
void ChestTrapList::Clear() {
@ -71,6 +71,9 @@ bool ChestTrapList::GetNextChestTrap(ChestTrap::ChestTrapInfo* cti) {
else
MChestTrapList.releasereadlock(__FUNCTION__, __LINE__);
if (cycleItr == chesttrap_list.end())
return false;
MChestTrapList.writelock(__FUNCTION__, __LINE__);
ChestTrap* trap = cycleItr->second;

View file

@ -4066,32 +4066,35 @@ void Client::OpenChest(Entity* entity, bool attemptDisarm)
{
ChestTrap::ChestTrapInfo nextTrap;
chest_trap_list.GetNextTrap(GetCurrentZone()->GetZoneID(), chest_difficulty, &nextTrap);
bool ret = chest_trap_list.GetNextTrap(GetCurrentZone()->GetZoneID(), chest_difficulty, &nextTrap);
Skill* disarmSkill = GetPlayer()->GetSkillByName("Disarm Trap", false);
firstChestOpen = true;
entity->SetTrapTriggered(true);
if (disarmSkill && attemptDisarm)
if (ret)
{
if (disarmSkill->CheckDisarmSkill(entity->GetLevel(), chest_difficulty) < 1)
if (disarmSkill && attemptDisarm)
{
CastGroupOrSelf(entity, nextTrap.spell_id, nextTrap.spell_tier,
if (disarmSkill->CheckDisarmSkill(entity->GetLevel(), chest_difficulty) < 1)
{
CastGroupOrSelf(entity, nextTrap.spell_id, nextTrap.spell_tier,
rule_manager.GetGlobalRule(R_Loot, ChestTriggerRadiusGroup)->GetFloat());
Message(CHANNEL_COLOR_WHITE, "You trigger the trap on %s!", modelName.c_str());
}
else
{
Message(CHANNEL_COLOR_WHITE, "You disarm the trap on %s", modelName.c_str());
}
// despite fail/succeed we should always try to increase skill if disarm is available
GetPlayer()->GetSkillByName("Disarm Trap", true);
}
else // no disarm skill, always fail
{
CastGroupOrSelf(entity, nextTrap.spell_id, nextTrap.spell_tier,
rule_manager.GetGlobalRule(R_Loot, ChestTriggerRadiusGroup)->GetFloat());
Message(CHANNEL_COLOR_WHITE, "You trigger the trap on %s!", modelName.c_str());
}
else
{
Message(CHANNEL_COLOR_WHITE, "You disarm the trap on %s", modelName.c_str());
}
// despite fail/succeed we should always try to increase skill if disarm is available
GetPlayer()->GetSkillByName("Disarm Trap", true);
}
else // no disarm skill, always fail
{
CastGroupOrSelf(entity, nextTrap.spell_id, nextTrap.spell_tier,
rule_manager.GetGlobalRule(R_Loot, ChestTriggerRadiusGroup)->GetFloat());
Message(CHANNEL_COLOR_WHITE, "You trigger the trap on %s!", modelName.c_str());
}
}
else if(!entity->HasTrapTriggered())