mirror of
https://github.com/mangosfour/server.git
synced 2025-12-17 16:37:00 +00:00
[c12607] Implement SCRIPT_COMMAND_TERMINATE_COND
This commit is contained in:
parent
ad7d7dad1a
commit
af1c665095
6 changed files with 70 additions and 3 deletions
|
|
@ -645,6 +645,20 @@ void ScriptMgr::LoadScripts(ScriptMapMapName& scripts, const char* tablename)
|
|||
break;
|
||||
case SCRIPT_COMMAND_XP_USER: // 33
|
||||
break;
|
||||
case SCRIPT_COMMAND_TERMINATE_COND: // 34
|
||||
{
|
||||
if (!sConditionStorage.LookupEntry<PlayerCondition>(tmp.terminateCond.conditionId))
|
||||
{
|
||||
sLog.outErrorDb("Table `%s` has datalong = %u in SCRIPT_COMMAND_TERMINATE_COND for script id %u, but this condition_id does not exist.", tablename, tmp.terminateCond.conditionId, tmp.id);
|
||||
continue;
|
||||
}
|
||||
if (tmp.terminateCond.failQuest && !sObjectMgr.GetQuestTemplate(tmp.terminateCond.failQuest))
|
||||
{
|
||||
sLog.outErrorDb("Table `%s` has datalong2 = %u in SCRIPT_COMMAND_TERMINATE_COND for script id %u, but this questId does not exist.", tablename, tmp.terminateCond.failQuest, tmp.id);
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
sLog.outErrorDb("Table `%s` unknown command %u, skipping.", tablename, tmp.command);
|
||||
|
|
@ -1704,6 +1718,45 @@ bool ScriptAction::HandleScriptStep()
|
|||
pPlayer->RemoveFlag(PLAYER_FLAGS, PLAYER_FLAGS_XP_USER_DISABLED);
|
||||
break;
|
||||
}
|
||||
case SCRIPT_COMMAND_TERMINATE_COND:
|
||||
{
|
||||
Player* player = NULL;
|
||||
WorldObject* second = pSource;
|
||||
// First case: target is player
|
||||
if (pTarget && pTarget->GetTypeId() == TYPEID_PLAYER)
|
||||
player = static_cast<Player*>(pTarget);
|
||||
// Second case: source is player
|
||||
else if (pSource && pSource->GetTypeId() == TYPEID_PLAYER)
|
||||
{
|
||||
player = static_cast<Player*>(pSource);
|
||||
second = pTarget;
|
||||
}
|
||||
|
||||
bool terminateResult;
|
||||
if (m_script->data_flags & SCRIPT_FLAG_COMMAND_ADDITIONAL)
|
||||
terminateResult = !sObjectMgr.IsPlayerMeetToCondition(m_script->terminateCond.conditionId, player, m_map, second, CONDTION_FROM_DBSCRIPTS);
|
||||
else
|
||||
terminateResult = sObjectMgr.IsPlayerMeetToCondition(m_script->terminateCond.conditionId, player, m_map, second, CONDTION_FROM_DBSCRIPTS);
|
||||
|
||||
if (terminateResult && m_script->terminateCond.failQuest && player)
|
||||
{
|
||||
if (Group* group = player->GetGroup())
|
||||
{
|
||||
for (GroupReference* groupRef = group->GetFirstMember(); groupRef != NULL; groupRef = groupRef->next())
|
||||
{
|
||||
Player* member = groupRef->getSource();
|
||||
if (member->GetQuestStatus(m_script->terminateCond.failQuest) == QUEST_STATUS_INCOMPLETE)
|
||||
member->FailQuest(m_script->terminateCond.failQuest);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (player->GetQuestStatus(m_script->terminateCond.failQuest) == QUEST_STATUS_INCOMPLETE)
|
||||
player->FailQuest(m_script->terminateCond.failQuest);
|
||||
}
|
||||
}
|
||||
return terminateResult;
|
||||
}
|
||||
default:
|
||||
sLog.outError(" DB-SCRIPTS: Process table `%s` id %u, command %u unknown command used.", m_table, m_script->id, m_script->command);
|
||||
break;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue