From 4e6fbf5e9e7c09221040cc682a6e0fbb535cd76a Mon Sep 17 00:00:00 2001 From: Schmoozerd Date: Fri, 4 May 2012 17:46:29 +0200 Subject: [PATCH] [11984] Add new SCRIPT_COMMAND_SEND_TAXI_PATH to trigger a taxi path Idea for this patch by Klark20 (maybe he also was the author of this patch as well, I cannot check in this moment) Signed-off-by: Schmoozerd --- doc/script_commands.txt | 2 ++ src/game/ScriptMgr.cpp | 42 ++++++++++++++++++++++++++++++++++++++++ src/game/ScriptMgr.h | 7 +++++++ src/shared/revision_nr.h | 2 +- 4 files changed, 52 insertions(+), 1 deletion(-) diff --git a/doc/script_commands.txt b/doc/script_commands.txt index 95ede3e24..e3799b1f2 100644 --- a/doc/script_commands.txt +++ b/doc/script_commands.txt @@ -251,3 +251,5 @@ Where "A -> B" means that the command is executed from A with B as target. 29 SCRIPT_COMMAND_MODIFY_NPC_FLAGS resultingSource = Creature * datalong=NPCFlags * datalong2= 0x00=toggle, 0x01=add, 0x02=remove +30 SCRIPT_COMMAND_SEND_TAXI_PATH resultingTarget or Source must be Player + * datalong = taxi path id diff --git a/src/game/ScriptMgr.cpp b/src/game/ScriptMgr.cpp index 5a8dbfa0e..6f50860bd 100644 --- a/src/game/ScriptMgr.cpp +++ b/src/game/ScriptMgr.cpp @@ -536,6 +536,38 @@ void ScriptMgr::LoadScripts(ScriptMapMapName& scripts, const char* tablename) { break; } + case SCRIPT_COMMAND_SEND_TAXI_PATH: + { + if (!sTaxiPathStore.LookupEntry(tmp.sendTaxiPath.taxiPathId)) + { + sLog.outErrorDb("Table `%s` has datalong = %u in SCRIPT_COMMAND_SEND_TAXI_PATH for script id %u, but this taxi path does not exist.", tablename, tmp.sendTaxiPath.taxiPathId, tmp.id); + continue; + } + // Check if this taxi path can be triggered with a spell + if (!sLog.HasLogFilter(LOG_FILTER_DB_STRICTED_CHECK)) + { + uint32 taxiSpell = 0; + for (uint32 i = 1; i < sSpellStore.GetNumRows() && taxiSpell == 0; ++i) + { + if (SpellEntry const* spell = sSpellStore.LookupEntry(i)) + for (int j = 0; j < MAX_EFFECT_INDEX; ++j) + { + if (spell->Effect[j] == SPELL_EFFECT_SEND_TAXI && spell->EffectMiscValue[j] == tmp.sendTaxiPath.taxiPathId) + { + taxiSpell = i; + break; + } + } + } + + if (taxiSpell) + { + sLog.outErrorDb("Table `%s` has datalong = %u in SCRIPT_COMMAND_SEND_TAXI_PATH for script id %u, but this taxi path can be triggered by spell %u.", tablename, tmp.sendTaxiPath.taxiPathId, tmp.id, taxiSpell); + continue; + } + } + break; + } } if (scripts.second.find(tmp.id) == scripts.second.end()) @@ -1523,6 +1555,16 @@ void ScriptAction::HandleScriptStep() break; } + case SCRIPT_COMMAND_SEND_TAXI_PATH: + { + // only Player + Player* pPlayer = GetPlayerTargetOrSourceAndLog(pSource, pTarget); + if (!pPlayer) + break; + + pPlayer->ActivateTaxiPathTo(m_script->sendTaxiPath.taxiPathId); + break; + } default: sLog.outError(" DB-SCRIPTS: Process table `%s` id %u, command %u unknown command used.", m_table, m_script->id, m_script->command); break; diff --git a/src/game/ScriptMgr.h b/src/game/ScriptMgr.h index 754a30816..ce9ee47ca 100644 --- a/src/game/ScriptMgr.h +++ b/src/game/ScriptMgr.h @@ -88,6 +88,7 @@ enum ScriptCommand // resSource, resTar SCRIPT_COMMAND_MODIFY_NPC_FLAGS = 29, // resSource = Creature // datalong=NPCFlags // datalong2:0x00=toggle, 0x01=add, 0x02=remove + SCRIPT_COMMAND_SEND_TAXI_PATH = 30, // datalong = taxi path id (source or target must be player) }; #define MAX_TEXT_ID 4 // used for SCRIPT_COMMAND_TALK @@ -283,6 +284,12 @@ struct ScriptInfo uint32 change_flag; // datalong2 } npcFlag; + struct + { + uint32 taxiPathId; // datalong + uint32 empty; + } sendTaxiPath; + struct { uint32 data[2]; diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 55259b322..0df235bcb 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "11983" + #define REVISION_NR "11984" #endif // __REVISION_NR_H__