Skip to content

Commit 0bfe55b

Browse files
author
Conan
committed
Release the files
1 parent a2b234c commit 0bfe55b

File tree

8 files changed

+848
-0
lines changed

8 files changed

+848
-0
lines changed

CMakeLists.txt

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
AC_ADD_SCRIPT("${CMAKE_CURRENT_LIST_DIR}/src/Solocraft.cpp")
3+
4+
AC_ADD_SCRIPT_LOADER("Solocraft" "${CMAKE_CURRENT_LIST_DIR}/src/loader.h")
5+
6+
CU_ADD_HOOK(AFTER_WORLDSERVER_CMAKE "${CMAKE_CURRENT_LIST_DIR}/src/cmake/after_ws_install.cmake")

LICENSE

+674
Large diffs are not rendered by default.

README.md

+7
Original file line numberDiff line numberDiff line change
@@ -1 +1,8 @@
11
# mod-solocraft
2+
3+
## Solocraft module for AzerothCore.
4+
5+
Solocraft creates a balance based on party size in the dungeons.
6+
7+
# Original script:
8+
https://github.com/DavidMacalaster/Solocraft

conf/Solocraft.conf.dist

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[worldserver]
2+
#
3+
###################################################################################################
4+
5+
###################################################################################################
6+
#
7+
# Solocraft.Enable
8+
# Description: Solocraft is a script to increase players and bots stats in raids,
9+
# based on group size. It feels a little Hacky, but raids is unfair hard with playerbots.
10+
# Default: 0
11+
12+
Solocraft.Enable = 0

include.sh

Whitespace-only changes.

src/Solocraft.cpp

+133
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
#include <map>
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+
sLog->outString("scripts.solocraft.player.instance", "[Solocraft] solocraft_player_instance_handler Loaded");
24+
}
25+
26+
void OnLogin(Player *player) override {
27+
if (sConfigMgr->GetBoolDefault("Solocraft.Enable", true))
28+
{
29+
ChatHandler(player->GetSession()).SendSysMessage("This server is running a Solocraft Module.");
30+
}
31+
}
32+
33+
void OnMapChanged(Player *player) override {
34+
if (sConfigMgr->GetBoolDefault("Solocraft.Enable", true)) {
35+
Map *map = player->GetMap();
36+
int difficulty = CalculateDifficulty(map, player);
37+
int numInGroup = GetNumInGroup(player);
38+
ApplyBuffs(player, map, difficulty, numInGroup);
39+
}
40+
}
41+
private:
42+
std::map<uint32, int> _unitDifficulty;
43+
44+
int CalculateDifficulty(Map *map, Player *player) {
45+
int difficulty = 1;
46+
if (map) {
47+
if (map->Is25ManRaid()) {
48+
difficulty = 25;
49+
} else if (map->IsHeroic()) {
50+
difficulty = 10;
51+
} else if (map->IsRaid()) {
52+
difficulty = 40;
53+
} else if (map->IsDungeon()) {
54+
difficulty = 5;
55+
}
56+
}
57+
return difficulty;
58+
}
59+
60+
int GetNumInGroup(Player *player) {
61+
int numInGroup = 1;
62+
Group *group = player->GetGroup();
63+
if (group) {
64+
Group::MemberSlotList const& groupMembers = group->GetMemberSlots();
65+
numInGroup = groupMembers.size();
66+
}
67+
return numInGroup;
68+
}
69+
70+
void ApplyBuffs(Player *player, Map *map, int difficulty, int numInGroup) {
71+
ClearBuffs(player, map);
72+
if (difficulty > 1) {
73+
//InstanceMap *instanceMap = map->ToInstanceMap();
74+
//InstanceScript *instanceScript = instanceMap->GetInstanceScript();
75+
76+
ChatHandler(player->GetSession()).PSendSysMessage("Entered %s (difficulty = %d, numInGroup = %d)",
77+
map->GetMapName(), difficulty, numInGroup);
78+
79+
_unitDifficulty[player->GetGUID()] = difficulty;
80+
for (int32 i = STAT_STRENGTH; i < MAX_STATS; ++i) {
81+
player->HandleStatModifier(UnitMods(UNIT_MOD_STAT_START + i), TOTAL_PCT, float(difficulty * 100), true);
82+
}
83+
player->SetFullHealth();
84+
if (player->getPowerType() == POWER_MANA) {
85+
player->SetPower(POWER_MANA, player->GetMaxPower(POWER_MANA));
86+
}
87+
}
88+
}
89+
90+
void ClearBuffs(Player *player, Map *map) {
91+
std::map<uint32, int>::iterator unitDifficultyIterator = _unitDifficulty.find(player->GetGUID());
92+
if (unitDifficultyIterator != _unitDifficulty.end()) {
93+
int difficulty = unitDifficultyIterator->second;
94+
_unitDifficulty.erase(unitDifficultyIterator);
95+
96+
ChatHandler(player->GetSession()).PSendSysMessage("Left to %s (removing difficulty = %d)",
97+
map->GetMapName(), difficulty);
98+
99+
for (int32 i = STAT_STRENGTH; i < MAX_STATS; ++i) {
100+
player->HandleStatModifier(UnitMods(UNIT_MOD_STAT_START + i), TOTAL_PCT, float(difficulty * 100), false);
101+
}
102+
}
103+
}
104+
};
105+
106+
}
107+
108+
class SolocraftWorld : public WorldScript
109+
{
110+
public:
111+
SolocraftWorld() : WorldScript("SolocraftWorld") { }
112+
113+
void OnBeforeConfigLoad(bool reload) override
114+
{
115+
if (!reload) {
116+
std::string conf_path = _CONF_DIR;
117+
std::string cfg_file = conf_path + "/Solocraft.conf";
118+
#ifdef WIN32
119+
cfg_file = "Solocraft.conf";
120+
#endif
121+
std::string cfg_def_file = cfg_file +".dist";
122+
sConfigMgr->LoadMore(cfg_def_file.c_str());
123+
124+
sConfigMgr->LoadMore(cfg_file.c_str());
125+
}
126+
}
127+
};
128+
129+
130+
void AddSolocraftScripts() {
131+
new SolocraftWorld();
132+
new solocraft_player_instance_handler();
133+
}

src/cmake/after_ws_install.cmake

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
if( WIN32 )
2+
if ( MSVC )
3+
add_custom_command(TARGET worldserver
4+
POST_BUILD
5+
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_SOURCE_DIR}/modules/mod-solocraft/conf/Solocraft.conf.dist" ${CMAKE_BINARY_DIR}/bin/$(ConfigurationName)/
6+
)
7+
elseif ( MINGW )
8+
add_custom_command(TARGET worldserver
9+
POST_BUILD
10+
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_SOURCE_DIR}/modules/mod-solocraft/conf/Solocraft.conf.dist" ${CMAKE_BINARY_DIR}/bin/
11+
)
12+
endif()
13+
endif()
14+
15+
install(FILES "${CMAKE_SOURCE_DIR}/modules/mod-solocraft/conf/Solocraft.conf.dist" DESTINATION ${CONF_DIR})

src/loader.h

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
void AddSolocraftScripts();

0 commit comments

Comments
 (0)