├── README.md └── Solocraft.cpp /README.md: -------------------------------------------------------------------------------- 1 | Description 2 | =========== 3 | 4 | These are my extensions to the [TrinityCore][4] WoW Server Emulator for WoW 5 | version 3.3.5a that are targetted toward soloing (or with a very small party) 6 | the group content in WoW like dungeons and raids at the level the content was 7 | meant for instead of having to come back and solo when you are 20 levels higher 8 | than the content. 9 | 10 | The goal is to automatically apply stat buffs, HP regeneration, procs like 11 | dispelling target regeneration buffs, and other things to the player based on 12 | the instance the player has entered and the size of the party they are in to 13 | make up the non-deal party makeup. 14 | 15 | [4]: 16 | 17 | Installation 18 | ------------ 19 | 20 | While following the [TrinityCore installation guide][1] after you have used git 21 | to grab the TrinityCore source but before you [run cmake][2] you need to add 22 | this git submodule: 23 | 24 | `git submodule add https://github.com/DavidMacalaster/Solocraft.git 25 | src/server/scripts/Custom/Solocraft` 26 | 27 | then add Solocraft to [src/server/scripts/Custom/custom_script_loader.cpp][3]: 28 | 29 | [3]: 30 | 31 | ```c++ 32 | // This is where scripts' loading functions should be declared: 33 | void AddSC_solocraft(); 34 | 35 | // The name of this function should match: void Add${NameOfDirectory}Scripts() 36 | void AddCustomScripts() 37 | { 38 | AddSC_solocraft(); 39 | } 40 | ``` 41 | 42 | [1]: 43 | 44 | [2]: 45 | -------------------------------------------------------------------------------- /Solocraft.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "Config.h" 4 | #include "ScriptMgr.h" 5 | #include "Unit.h" 6 | #include "Player.h" 7 | #include "Pet.h" 8 | #include "Map.h" 9 | #include "Group.h" 10 | #include "InstanceScript.h" 11 | 12 | /* 13 | * TODO: 14 | * 1. Dispel target regeneration 15 | * 2. Provide unlimited http://www.wowhead.com/item=17333/aqual-quintessence 16 | */ 17 | 18 | namespace { 19 | 20 | class solocraft_player_instance_handler : public PlayerScript { 21 | public: 22 | solocraft_player_instance_handler() : PlayerScript("solocraft_player_instance_handler") { 23 | TC_LOG_INFO("scripts.solocraft.player.instance", "[Solocraft] solocraft_player_instance_handler Loaded"); 24 | } 25 | 26 | void OnLogin(Player *player, bool firstLogin) override { 27 | ChatHandler(player->GetSession()).SendSysMessage("Welcome to World of Solocraft"); 28 | } 29 | 30 | void OnMapChanged(Player *player) override { 31 | Map *map = player->GetMap(); 32 | int difficulty = CalculateDifficulty(map, player); 33 | int numInGroup = GetNumInGroup(player); 34 | ApplyBuffs(player, map, difficulty, numInGroup); 35 | } 36 | private: 37 | std::map _unitDifficulty; 38 | 39 | int CalculateDifficulty(Map *map, Player *player) { 40 | int difficulty = 1; 41 | if (map) { 42 | if (map->Is25ManRaid()) { 43 | difficulty = 25; 44 | } else if (map->IsHeroic()) { 45 | difficulty = 10; 46 | } else if (map->IsRaid()) { 47 | difficulty = 40; 48 | } else if (map->IsDungeon()) { 49 | difficulty = 5; 50 | } 51 | } 52 | return difficulty; 53 | } 54 | 55 | int GetNumInGroup(Player *player) { 56 | int numInGroup = 1; 57 | Group *group = player->GetGroup(); 58 | if (group) { 59 | Group::MemberSlotList const& groupMembers = group->GetMemberSlots(); 60 | numInGroup = groupMembers.size(); 61 | } 62 | return numInGroup; 63 | } 64 | 65 | void ApplyBuffs(Player *player, Map *map, int difficulty, int numInGroup) { 66 | ClearBuffs(player, map); 67 | if (difficulty > 1) { 68 | //InstanceMap *instanceMap = map->ToInstanceMap(); 69 | //InstanceScript *instanceScript = instanceMap->GetInstanceScript(); 70 | 71 | ChatHandler(player->GetSession()).PSendSysMessage("Entered %s (difficulty = %d, numInGroup = %d)", 72 | map->GetMapName(), difficulty, numInGroup); 73 | 74 | _unitDifficulty[player->GetGUID()] = difficulty; 75 | for (int32 i = STAT_STRENGTH; i < MAX_STATS; ++i) { 76 | player->HandleStatModifier(UnitMods(UNIT_MOD_STAT_START + i), TOTAL_PCT, float(difficulty * 100), true); 77 | } 78 | player->SetFullHealth(); 79 | if (player->getPowerType() == POWER_MANA) { 80 | player->SetPower(POWER_MANA, player->GetMaxPower(POWER_MANA)); 81 | } 82 | } 83 | } 84 | 85 | void ClearBuffs(Player *player, Map *map) { 86 | std::map::iterator unitDifficultyIterator = _unitDifficulty.find(player->GetGUID()); 87 | if (unitDifficultyIterator != _unitDifficulty.end()) { 88 | int difficulty = unitDifficultyIterator->second; 89 | _unitDifficulty.erase(unitDifficultyIterator); 90 | 91 | ChatHandler(player->GetSession()).PSendSysMessage("Left to %s (removing difficulty = %d)", 92 | map->GetMapName(), difficulty); 93 | 94 | for (int32 i = STAT_STRENGTH; i < MAX_STATS; ++i) { 95 | player->HandleStatModifier(UnitMods(UNIT_MOD_STAT_START + i), TOTAL_PCT, float(difficulty * 100), false); 96 | } 97 | } 98 | } 99 | }; 100 | 101 | } 102 | 103 | void AddSC_solocraft() { 104 | new solocraft_player_instance_handler(); 105 | } 106 | --------------------------------------------------------------------------------