diff --git a/src/game/Maps/Map.h b/src/game/Maps/Map.h index 950ef2a96..da9a0756e 100644 --- a/src/game/Maps/Map.h +++ b/src/game/Maps/Map.h @@ -665,6 +665,8 @@ class MANGOS_DLL_SPEC Map : public GridRefManager, public MaNGOS::Obj bool ScriptCommand_SetHomePosition(ScriptAction& step, Object* source, Object* target); bool ScriptCommand_TurnTo(ScriptAction& step, Object* source, Object* target); bool ScriptCommand_MeetingStone(ScriptAction& step, Object* source, Object* target); + bool ScriptCommand_SetData(ScriptAction& step, Object* source, Object* target); + bool ScriptCommand_SetData64(ScriptAction& step, Object* source, Object* target); // Add any new script command functions to the array. const ScriptCommandFunction m_ScriptCommands[SCRIPT_COMMAND_MAX] = @@ -705,7 +707,9 @@ class MANGOS_DLL_SPEC Map : public GridRefManager, public MaNGOS::Obj &Map::ScriptCommand_Evade, // 33 &Map::ScriptCommand_SetHomePosition, // 34 &Map::ScriptCommand_TurnTo, // 35 - &Map::ScriptCommand_MeetingStone // 36 + &Map::ScriptCommand_MeetingStone, // 36 + &Map::ScriptCommand_SetData, // 37 + &Map::ScriptCommand_SetData64, // 38 }; public: diff --git a/src/game/Maps/MapManager.cpp b/src/game/Maps/MapManager.cpp index d3e7748e9..9d925dd49 100644 --- a/src/game/Maps/MapManager.cpp +++ b/src/game/Maps/MapManager.cpp @@ -836,25 +836,25 @@ uint32 MapManager::GetContinentInstanceId(uint32 mapId, float x, float y, bool* }; const static float feralasThousandNeedlesSouthLimit[] = { - -6495.4995, -4711.981, - -6674.9995, -4515.0019, - -6769.5717, -4122.4272, - -6838.2651, -3874.2792, - -6851.1314, -3659.1179, - -6624.6845, -3063.3843, - -6416.9067, -2570.1301, - -5959.8466, -2287.2634, - -5947.9135, -1866.5028, - -5947.9135, -820.4881, - -5876.7114, -3.5138, - -5876.7114, 917.6407, - -6099.3603, 1153.2884, - -6021.8989, 1638.1809, - -6091.6176, 2335.8892, - -6744.9946, 2393.4855, - -6973.8608, 3077.0281, - -7068.7241, 4376.2304, - -7142.1211, 4808.4331 + -6495.4995f, -4711.981f, + -6674.9995f, -4515.0019f, + -6769.5717f, -4122.4272f, + -6838.2651f, -3874.2792f, + -6851.1314f, -3659.1179f, + -6624.6845f, -3063.3843f, + -6416.9067f, -2570.1301f, + -5959.8466f, -2287.2634f, + -5947.9135f, -1866.5028f, + -5947.9135f, -820.4881f, + -5876.7114f, -3.5138f, + -5876.7114f, 917.6407f, + -6099.3603f, 1153.2884f, + -6021.8989f, 1638.1809f, + -6091.6176f, 2335.8892f, + -6744.9946f, 2393.4855f, + -6973.8608f, 3077.0281f, + -7068.7241f, 4376.2304f, + -7142.1211f, 4808.4331f }; if (IsNorthTo(x, y, northMiddleLimit, sizeof(northMiddleLimit) / (2 * sizeof(float)))) diff --git a/src/game/Maps/ScriptCommands.cpp b/src/game/Maps/ScriptCommands.cpp index 9fc0ec550..dcd1eb20a 100644 --- a/src/game/Maps/ScriptCommands.cpp +++ b/src/game/Maps/ScriptCommands.cpp @@ -19,6 +19,7 @@ #include "Map.h" #include "ScriptMgr.h" #include "GridSearchers.h" +#include "InstanceData.h" // Script commands should return false by default. // If they return true the rest of the script is aborted. @@ -1272,5 +1273,84 @@ bool Map::ScriptCommand_MeetingStone(ScriptAction& step, Object* source, Object* if (!sLFGMgr.IsPlayerInQueue(pPlayer->GetObjectGuid())) sLFGMgr.AddToQueue(pPlayer, step.script->meetingstone.areaId); + return false; +} + +// SCRIPT_COMMAND_SET_INST_DATA (37) +bool Map::ScriptCommand_SetData(ScriptAction& step, Object* source, Object* target) +{ + InstanceData* pInst = GetInstanceData(); + + if (!pInst) + { + sLog.outError("SCRIPT_COMMAND_SET_INST_DATA (script id %u) call for map without an instance script, skipping.", step.script->id); + return ShouldAbortScript(step); + } + + uint32 uiData = step.script->setData.data; + switch (step.script->setData.type) + { + case SO_INSTDATA_RAW: + { + break; + } + case SO_INSTDATA_INCREMENT: + { + uiData+= pInst->GetData(step.script->setData.field); + break; + } + case SO_INSTDATA_DECREMENT: + { + uint32 uiOldData = pInst->GetData(step.script->setData.field); + uiData = (uiData < uiOldData) ? (uiOldData - uiData) : 0; + break; + } + default: + { + sLog.outError("SCRIPT_COMMAND_SET_INST_DATA (script id %u) call for an invalid type (datalong3=%u), skipping.", step.script->id, step.script->setData.type); + return ShouldAbortScript(step); + } + } + + pInst->SetData(step.script->setData.field, uiData); + return false; +} + +// SCRIPT_COMMAND_SET_INST_DATA64 (38) +bool Map::ScriptCommand_SetData64(ScriptAction& step, Object* source, Object* target) +{ + InstanceData* pInst = GetInstanceData(); + + if (!pInst) + { + sLog.outError("SCRIPT_COMMAND_SET_INST_DATA64 (script id %u) call for map without an instance script, skipping.", step.script->id); + return ShouldAbortScript(step); + } + + switch (step.script->setData64.type) + { + case SO_INSTDATA64_RAW: + { + pInst->SetData64(step.script->setData64.field, step.script->setData64.data); + break; + } + case SO_INSTDATA64_SOURCE_GUID: + { + if (source) + pInst->SetData64(step.script->setData64.field, source->GetGUID()); + else + { + sLog.outError("SCRIPT_COMMAND_SET_INST_DATA64 (script id %u) call for a NULL source, skipping.", step.script->id); + return ShouldAbortScript(step); + } + break; + } + default: + { + sLog.outError("SCRIPT_COMMAND_SET_INST_DATA64 (script id %u) call for an invalid type (datalong3=%u), skipping.", step.script->id, step.script->setData64.type); + return ShouldAbortScript(step); + } + } + return false; } \ No newline at end of file diff --git a/src/game/ScriptMgr.cpp b/src/game/ScriptMgr.cpp index 11febf93a..8f58b2c04 100644 --- a/src/game/ScriptMgr.cpp +++ b/src/game/ScriptMgr.cpp @@ -632,6 +632,24 @@ void ScriptMgr::LoadScripts(ScriptMapMap& scripts, const char* tablename) } break; } + case SCRIPT_COMMAND_SET_INST_DATA: + { + if (tmp.setData.type >= SO_INSTDATA_MAX) + { + sLog.outErrorDb("Table `%s` has invalid option datalong3 = %u in SCRIPT_COMMAND_SET_INST_DATA for script id %u.", tablename, tmp.setData.type, tmp.id); + continue; + } + break; + } + case SCRIPT_COMMAND_SET_INST_DATA64: + { + if (tmp.setData64.type >= SO_INSTDATA64_MAX) + { + sLog.outErrorDb("Table `%s` has invalid option datalong3 = %u in SCRIPT_COMMAND_SET_INST_DATA64 for script id %u.", tablename, tmp.setData64.type, tmp.id); + continue; + } + break; + } } if (scripts.find(tmp.id) == scripts.end()) diff --git a/src/game/ScriptMgr.h b/src/game/ScriptMgr.h index e0c6124d6..a4898e1fd 100644 --- a/src/game/ScriptMgr.h +++ b/src/game/ScriptMgr.h @@ -176,7 +176,15 @@ enum eScriptCommand // datalong = eTurnToFacingOptions SCRIPT_COMMAND_MEETINGSTONE = 36, // source = Player // datalong = area_id - + SCRIPT_COMMAND_SET_INST_DATA = 37, // source = Map + // datalong = field + // datalong2 = data + // datalong3 = eSetInstDataOptions + SCRIPT_COMMAND_SET_INST_DATA64 = 38, // source = Map + // target = Object (when saving guid) + // datalong = field + // datalong2 = data + // datalong3 = eSetInstData64Options SCRIPT_COMMAND_MAX }; @@ -269,6 +277,25 @@ enum eTurnToFacingOptions SO_TURNTO_PROVIDED_ORIENTATION = 1 }; +// Possible datalong3 values for SCRIPT_COMMAND_SET_INST_DATA +enum eSetInstDataOptions +{ + SO_INSTDATA_RAW = 0, + SO_INSTDATA_INCREMENT = 1, + SO_INSTDATA_DECREMENT = 2, + + SO_INSTDATA_MAX +}; + +// Possible datalong3 values for SCRIPT_COMMAND_SET_INST_DATA64 +enum eSetInstData64Options +{ + SO_INSTDATA64_RAW = 0, + SO_INSTDATA64_SOURCE_GUID = 1, + + SO_INSTDATA64_MAX +}; + // Values used in buddy_type column enum eBuddyType { @@ -517,6 +544,20 @@ struct ScriptInfo uint32 areaId; // datalong } meetingstone; + struct // SCRIPT_COMMAND_SET_INST_DATA (37) + { + uint32 field; + uint32 data; + uint32 type; + } setData; + + struct // SCRIPT_COMMAND_SET_INST_DATA64 (38) + { + uint32 field; + uint32 data; + uint32 type; + } setData64; + struct { uint32 data[9]; diff --git a/src/scripts/custom/custom_creatures.cpp b/src/scripts/custom/custom_creatures.cpp index 211fce9ec..c05fdcfca 100644 --- a/src/scripts/custom/custom_creatures.cpp +++ b/src/scripts/custom/custom_creatures.cpp @@ -1015,7 +1015,7 @@ struct npc_summon_debugAI : ScriptedAI npc_summon_debugAI(Creature *pCreature) : ScriptedAI(pCreature) { m_summonCount = 0; - for (int i = 0; i < m_maxSummonCount; ++i) + for (uint32 i = 0; i < m_maxSummonCount; ++i) m_summons[i] = nullptr; Reset(); @@ -1024,7 +1024,7 @@ struct npc_summon_debugAI : ScriptedAI void Reset() override { m_summonCount = 0; - for (int i = 0; i < m_maxSummonCount; ++i) + for (uint32 i = 0; i < m_maxSummonCount; ++i) { if (m_summons[i]) ((TemporarySummon*)m_summons[i])->UnSummon(); diff --git a/src/scripts/kalimdor/silithus/ruins_of_ahnqiraj/boss_rajaxx.cpp b/src/scripts/kalimdor/silithus/ruins_of_ahnqiraj/boss_rajaxx.cpp index 203762af8..337fecc66 100644 --- a/src/scripts/kalimdor/silithus/ruins_of_ahnqiraj/boss_rajaxx.cpp +++ b/src/scripts/kalimdor/silithus/ruins_of_ahnqiraj/boss_rajaxx.cpp @@ -405,7 +405,7 @@ struct boss_rajaxxAQWarAI : public boss_rajaxxAI DoScriptText(SAY_AQ_WAR_START, m_creature); } - void UpdateAI(uint32 uiDiff) + void UpdateAI(const uint32 uiDiff) override { return; }