|
| 1 | +#include "ScriptMgr.h" |
| 2 | +#include "Player.h" |
| 3 | +#include "Group.h" |
| 4 | +#include "ObjectAccessor.h" |
| 5 | + |
| 6 | +enum MiscCrossFactionPVE |
| 7 | +{ |
| 8 | + ZONE_ICECROWN_CITADEL = 4812, |
| 9 | + ICC_MAP_ID = 631, |
| 10 | + ZONE_TRIAL_OF_THE_CHAMPION = 4723, |
| 11 | + TOCHAMPION_MAP_ID = 650, |
| 12 | + ZONE_TRIAL_OF_THE_CRUSADER = 4722, |
| 13 | + TOCRUSADER_MAP_ID = 649, |
| 14 | + ZONE_PIT_OF_SARON = 4813, |
| 15 | + POS_MAP_ID = 658, |
| 16 | + ZONE_HALLS_OF_REFLECTION = 4820, |
| 17 | + HOR_MAP_ID = 668, |
| 18 | + ZONE_FORGE_OF_SOULS = 4809, |
| 19 | + FOS_MAP_ID = 632, |
| 20 | + ZONE_HALLS_OF_STONE = 4264, |
| 21 | + HOS_MAP_ID = 599, |
| 22 | + ZONE_THE_NEXUS = 4265, |
| 23 | + TN_MAP_ID = 576, |
| 24 | + ZONE_WARSONG_GULCH = 3277, |
| 25 | + WSG_MAP_ID = 489, |
| 26 | + ZONE_ARATHI_BASIN = 3358, |
| 27 | + AB_MAP_ID = 529 |
| 28 | +}; |
| 29 | + |
| 30 | +void TemporaryFactionChange(Player* player) |
| 31 | +{ |
| 32 | + if (Group* group = player->GetGroup()) |
| 33 | + { |
| 34 | + if (Player* leader = ObjectAccessor::FindPlayer(group->GetLeaderGUID())) |
| 35 | + { |
| 36 | + player->SetFaction(leader->GetFaction()); |
| 37 | + } |
| 38 | + } |
| 39 | +} |
| 40 | + |
| 41 | +class CfPlayerScript : public PlayerScript |
| 42 | +{ |
| 43 | +public: |
| 44 | + CfPlayerScript() : PlayerScript("CfPlayerScript") {} |
| 45 | + |
| 46 | + // Called when a player enters the world (logs in or teleports) |
| 47 | + void OnLogin(Player* player, bool firstLogin) override |
| 48 | + { |
| 49 | + switch (player->GetMapId()) |
| 50 | + { |
| 51 | + case ICC_MAP_ID: |
| 52 | + case TOCHAMPION_MAP_ID: |
| 53 | + case TOCRUSADER_MAP_ID: |
| 54 | + case POS_MAP_ID: |
| 55 | + case HOR_MAP_ID: |
| 56 | + case FOS_MAP_ID: |
| 57 | + case HOS_MAP_ID: |
| 58 | + case TN_MAP_ID: |
| 59 | + case WSG_MAP_ID: |
| 60 | + case AB_MAP_ID: |
| 61 | + TemporaryFactionChange(player); |
| 62 | + break; |
| 63 | + } |
| 64 | + } |
| 65 | + |
| 66 | + // Called when a player changes zones |
| 67 | + void OnUpdateZone(Player* player, uint32 newZone, uint32 /*newArea*/) override |
| 68 | + { |
| 69 | + switch (newZone) |
| 70 | + { |
| 71 | + case ZONE_ICECROWN_CITADEL: |
| 72 | + case ZONE_TRIAL_OF_THE_CHAMPION: |
| 73 | + case ZONE_TRIAL_OF_THE_CRUSADER: |
| 74 | + case ZONE_PIT_OF_SARON: |
| 75 | + case ZONE_HALLS_OF_REFLECTION: |
| 76 | + case ZONE_FORGE_OF_SOULS: |
| 77 | + case ZONE_HALLS_OF_STONE: |
| 78 | + case ZONE_THE_NEXUS: |
| 79 | + case ZONE_WARSONG_GULCH: |
| 80 | + case ZONE_ARATHI_BASIN: |
| 81 | + TemporaryFactionChange(player); |
| 82 | + break; |
| 83 | + } |
| 84 | + } |
| 85 | +}; |
| 86 | + |
| 87 | +void AddSC_cfpve() |
| 88 | +{ |
| 89 | + new CfPlayerScript(); |
| 90 | +} |
0 commit comments