From c2b4831838df4df8412d3eeff48307394e975452 Mon Sep 17 00:00:00 2001 From: John Doe Date: Sat, 14 Sep 2024 20:56:01 +0100 Subject: [PATCH 1/5] added cfpve.cpp --- src/server/scripts/Custom/custom_script_loader.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/server/scripts/Custom/custom_script_loader.cpp b/src/server/scripts/Custom/custom_script_loader.cpp index 9e5e9ba2bfd..718f9586f04 100644 --- a/src/server/scripts/Custom/custom_script_loader.cpp +++ b/src/server/scripts/Custom/custom_script_loader.cpp @@ -17,8 +17,11 @@ // This is where scripts' loading functions should be declared: + void AddSC_cfpve(); + // The name of this function should match: // void Add${NameOfDirectory}Scripts() void AddCustomScripts() { + AddSC_cfpve(); } From 235c7d74b5962ac78b49b31df67532a74c723f52 Mon Sep 17 00:00:00 2001 From: urwifemykids <62853915+urwifemykids@users.noreply.github.com> Date: Sat, 14 Sep 2024 21:16:17 +0100 Subject: [PATCH 2/5] Add files via upload --- src/server/scripts/Custom/cfpve.cpp | 90 +++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 src/server/scripts/Custom/cfpve.cpp diff --git a/src/server/scripts/Custom/cfpve.cpp b/src/server/scripts/Custom/cfpve.cpp new file mode 100644 index 00000000000..7db8439e6a3 --- /dev/null +++ b/src/server/scripts/Custom/cfpve.cpp @@ -0,0 +1,90 @@ +#include "ScriptMgr.h" +#include "Player.h" +#include "Group.h" +#include "ObjectAccessor.h" + +enum MiscCrossFactionPVE +{ + ZONE_ICECROWN_CITADEL = 4812, + ICC_MAP_ID = 631, + ZONE_TRIAL_OF_THE_CHAMPION = 4723, + TOCHAMPION_MAP_ID = 650, + ZONE_TRIAL_OF_THE_CRUSADER = 4722, + TOCRUSADER_MAP_ID = 649, + ZONE_PIT_OF_SARON = 4813, + POS_MAP_ID = 658, + ZONE_HALLS_OF_REFLECTION = 4820, + HOR_MAP_ID = 668, + ZONE_FORGE_OF_SOULS = 4809, + FOS_MAP_ID = 632, + ZONE_HALLS_OF_STONE = 4264, + HOS_MAP_ID = 599, + ZONE_THE_NEXUS = 4265, + TN_MAP_ID = 576, + ZONE_WARSONG_GULCH = 3277, + WSG_MAP_ID = 489, + ZONE_ARATHI_BASIN = 3358, + AB_MAP_ID = 529 +}; + +void TemporaryFactionChange(Player* player) +{ + if (Group* group = player->GetGroup()) + { + if (Player* leader = ObjectAccessor::FindPlayer(group->GetLeaderGUID())) + { + player->SetFaction(leader->GetFaction()); + } + } +} + +class CfPlayerScript : public PlayerScript +{ +public: + CfPlayerScript() : PlayerScript("CfPlayerScript") {} + + // Called when a player enters the world (logs in or teleports) + void OnLogin(Player* player, bool firstLogin) override + { + switch (player->GetMapId()) + { + case ICC_MAP_ID: + case TOCHAMPION_MAP_ID: + case TOCRUSADER_MAP_ID: + case POS_MAP_ID: + case HOR_MAP_ID: + case FOS_MAP_ID: + case HOS_MAP_ID: + case TN_MAP_ID: + case WSG_MAP_ID: + case AB_MAP_ID: + TemporaryFactionChange(player); + break; + } + } + + // Called when a player changes zones + void OnUpdateZone(Player* player, uint32 newZone, uint32 /*newArea*/) override + { + switch (newZone) + { + case ZONE_ICECROWN_CITADEL: + case ZONE_TRIAL_OF_THE_CHAMPION: + case ZONE_TRIAL_OF_THE_CRUSADER: + case ZONE_PIT_OF_SARON: + case ZONE_HALLS_OF_REFLECTION: + case ZONE_FORGE_OF_SOULS: + case ZONE_HALLS_OF_STONE: + case ZONE_THE_NEXUS: + case ZONE_WARSONG_GULCH: + case ZONE_ARATHI_BASIN: + TemporaryFactionChange(player); + break; + } + } +}; + +void AddSC_cfpve() +{ + new CfPlayerScript(); +} From e49135c81955dfddf43d30392e52ae19e8dd57be Mon Sep 17 00:00:00 2001 From: urwifemykids <62853915+urwifemykids@users.noreply.github.com> Date: Sat, 14 Sep 2024 21:23:36 +0100 Subject: [PATCH 3/5] Add files via upload --- src/server/scripts/Custom/cfpve.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/server/scripts/Custom/cfpve.cpp b/src/server/scripts/Custom/cfpve.cpp index 7db8439e6a3..e67759fdd52 100644 --- a/src/server/scripts/Custom/cfpve.cpp +++ b/src/server/scripts/Custom/cfpve.cpp @@ -1,3 +1,21 @@ +/* + * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ + + #include "ScriptMgr.h" #include "Player.h" #include "Group.h" From c5c475597039b2f8658d5d36d3be72ff79f42268 Mon Sep 17 00:00:00 2001 From: urwifemykids <62853915+urwifemykids@users.noreply.github.com> Date: Sat, 14 Sep 2024 21:56:13 +0100 Subject: [PATCH 4/5] Update cfpve.cpp added faction reset --- src/server/scripts/Custom/cfpve.cpp | 78 ++++++++++++++--------------- 1 file changed, 39 insertions(+), 39 deletions(-) diff --git a/src/server/scripts/Custom/cfpve.cpp b/src/server/scripts/Custom/cfpve.cpp index e67759fdd52..6b9ef1a723e 100644 --- a/src/server/scripts/Custom/cfpve.cpp +++ b/src/server/scripts/Custom/cfpve.cpp @@ -45,17 +45,6 @@ enum MiscCrossFactionPVE AB_MAP_ID = 529 }; -void TemporaryFactionChange(Player* player) -{ - if (Group* group = player->GetGroup()) - { - if (Player* leader = ObjectAccessor::FindPlayer(group->GetLeaderGUID())) - { - player->SetFaction(leader->GetFaction()); - } - } -} - class CfPlayerScript : public PlayerScript { public: @@ -64,40 +53,51 @@ class CfPlayerScript : public PlayerScript // Called when a player enters the world (logs in or teleports) void OnLogin(Player* player, bool firstLogin) override { - switch (player->GetMapId()) - { - case ICC_MAP_ID: - case TOCHAMPION_MAP_ID: - case TOCRUSADER_MAP_ID: - case POS_MAP_ID: - case HOR_MAP_ID: - case FOS_MAP_ID: - case HOS_MAP_ID: - case TN_MAP_ID: - case WSG_MAP_ID: - case AB_MAP_ID: - TemporaryFactionChange(player); - break; - } + HandleFactionChange(player, player->GetMapId()); } // Called when a player changes zones void OnUpdateZone(Player* player, uint32 newZone, uint32 /*newArea*/) override { - switch (newZone) + HandleFactionChange(player, newZone); + } + +private: + // Store the original faction in a map + std::unordered_map originalFactionMap; + + void HandleFactionChange(Player* player, uint32 zoneOrMapId) + { + static const std::set zoneSet = { + ICC_MAP_ID, TOCHAMPION_MAP_ID, TOCRUSADER_MAP_ID, POS_MAP_ID, + HOR_MAP_ID, FOS_MAP_ID, HOS_MAP_ID, TN_MAP_ID, WSG_MAP_ID, AB_MAP_ID + }; + + if (zoneSet.count(zoneOrMapId)) + { + // Change faction to match the group leader + if (Group* group = player->GetGroup()) + { + if (Player* leader = ObjectAccessor::FindPlayer(group->GetLeaderGUID())) + { + if (originalFactionMap.find(player->GetGUID()) == originalFactionMap.end()) + { + // Store the original faction + originalFactionMap[player->GetGUID()] = player->GetFaction(); + } + player->SetFaction(leader->GetFaction()); + } + } + } + else { - case ZONE_ICECROWN_CITADEL: - case ZONE_TRIAL_OF_THE_CHAMPION: - case ZONE_TRIAL_OF_THE_CRUSADER: - case ZONE_PIT_OF_SARON: - case ZONE_HALLS_OF_REFLECTION: - case ZONE_FORGE_OF_SOULS: - case ZONE_HALLS_OF_STONE: - case ZONE_THE_NEXUS: - case ZONE_WARSONG_GULCH: - case ZONE_ARATHI_BASIN: - TemporaryFactionChange(player); - break; + // Restore player's original faction + auto it = originalFactionMap.find(player->GetGUID()); + if (it != originalFactionMap.end()) + { + player->SetFaction(it->second); + originalFactionMap.erase(it); // Clean up the map after restoring + } } } }; From 4d2ca87eeebdfdb69491a4dc0b153ced08962a08 Mon Sep 17 00:00:00 2001 From: urwifemykids <62853915+urwifemykids@users.noreply.github.com> Date: Mon, 16 Sep 2024 12:03:07 +0100 Subject: [PATCH 5/5] Add files via upload --- cfpve.cpp | 108 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 cfpve.cpp diff --git a/cfpve.cpp b/cfpve.cpp new file mode 100644 index 00000000000..d87a1b273e1 --- /dev/null +++ b/cfpve.cpp @@ -0,0 +1,108 @@ +/* + * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ + + +#include "ScriptMgr.h" +#include "Player.h" +#include "Group.h" +#include "ObjectAccessor.h" + +enum MiscCrossFactionPVE +{ + ZONE_ICECROWN_CITADEL = 4812, + ICC_MAP_ID = 631, + ZONE_TRIAL_OF_THE_CHAMPION = 4723, + TOCHAMPION_MAP_ID = 650, + ZONE_TRIAL_OF_THE_CRUSADER = 4722, + TOCRUSADER_MAP_ID = 649, + ZONE_PIT_OF_SARON = 4813, + POS_MAP_ID = 658, + ZONE_HALLS_OF_REFLECTION = 4820, + HOR_MAP_ID = 668, + ZONE_FORGE_OF_SOULS = 4809, + FOS_MAP_ID = 632, + ZONE_HALLS_OF_STONE = 4264, + HOS_MAP_ID = 599, + ZONE_THE_NEXUS = 4265, + TN_MAP_ID = 576, + ZONE_WARSONG_GULCH = 3277, + WSG_MAP_ID = 489, + ZONE_ARATHI_BASIN = 3358, + AB_MAP_ID = 529 +}; + +class CfPlayerScript : public PlayerScript +{ +public: + CfPlayerScript() : PlayerScript("CfPlayerScript") {} + + // Called when a player enters the world (logs in or teleports) + void OnLogin(Player* player, bool /* firstLogin */) override + { + HandleFactionChange(player, player->GetMapId()); + } + + // Called when a player changes zones + void OnUpdateZone(Player* player, uint32 newZone, uint32 /*newArea*/) override + { + HandleFactionChange(player, newZone); + } + +private: + // Store the original faction in a map + std::unordered_map originalFactionMap; + + void HandleFactionChange(Player* player, uint32 zoneOrMapId) + { + static const std::set zoneSet = { + ICC_MAP_ID, TOCHAMPION_MAP_ID, TOCRUSADER_MAP_ID, POS_MAP_ID, + HOR_MAP_ID, FOS_MAP_ID, HOS_MAP_ID, TN_MAP_ID, WSG_MAP_ID, AB_MAP_ID + }; + + if (zoneSet.count(zoneOrMapId)) + { + // Change faction to match the group leader + if (Group* group = player->GetGroup()) + { + if (Player* leader = ObjectAccessor::FindPlayer(group->GetLeaderGUID())) + { + if (originalFactionMap.find(player->GetGUID()) == originalFactionMap.end()) + { + // Store the original faction + originalFactionMap[player->GetGUID()] = player->GetFaction(); + } + player->SetFaction(leader->GetFaction()); + } + } + } + else + { + // Restore player's original faction + auto it = originalFactionMap.find(player->GetGUID()); + if (it != originalFactionMap.end()) + { + player->SetFaction(it->second); + originalFactionMap.erase(it); // Clean up the map after restoring + } + } + } +}; + +void AddSC_cfpve() +{ + new CfPlayerScript(); +}