Skip to content

Commit

Permalink
Update Solocraft.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
acidmanifesto committed Aug 18, 2023
1 parent 0144f8e commit d57b83b
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions src/server/scripts/Custom/Solocraft.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ class SolocraftAnnounce : public PlayerScript
void OnLogout(Player* player) override
{
//Remove database entry as the player has logged out
CharacterDatabase.PExecute("DELETE FROM custom_solocraft_character_stats WHERE GUID = %u", player->GetGUID());
CharacterDatabase.PExecute("DELETE FROM custom_solocraft_character_stats WHERE GUID = {}", player->GetGUID());
}
};
class solocraft_player_instance_handler : public PlayerScript {
Expand Down Expand Up @@ -445,7 +445,7 @@ class solocraft_player_instance_handler : public PlayerScript {
difficulty = (-abs(difficulty)) + ((((float)classBalance / 100) * difficulty) / numInGroup);
difficulty = roundf(difficulty * 100) / 100; //Float variables suck

//sLog->outError("%u: would have this difficulty: %f", player->GetGUID(), tempDiff);
//sLog->outError("{}: would have this difficulty: {}", player->GetGUID(), tempDiff);
}
else
{
Expand All @@ -456,7 +456,7 @@ class solocraft_player_instance_handler : public PlayerScript {
}

//Check Database for a current dungeon entry
QueryResult result = CharacterDatabase.PQuery("SELECT `GUID`, `Difficulty`, `GroupSize`, `SpellPower`, `Stats` FROM `custom_solocraft_character_stats` WHERE GUID = %u", player->GetGUID());
QueryResult result = CharacterDatabase.PQuery("SELECT `GUID`, `Difficulty`, `GroupSize`, `SpellPower`, `Stats` FROM `custom_solocraft_character_stats` WHERE GUID = {}", player->GetGUID());

//Modify Player Stats
for (int32 i = STAT_STRENGTH; i < MAX_STATS; ++i) //STATS defined/enum in SharedDefines.h
Expand Down Expand Up @@ -488,29 +488,29 @@ class solocraft_player_instance_handler : public PlayerScript {
{
SpellPowerBonus = static_cast<int>((player->GetLevel() * SoloCraftSpellMult) * difficulty);//Yes, I pulled this calc out of my butt.
player->ApplySpellPowerBonus(SpellPowerBonus, true);
//sLog->outError("%u: spellpower Bonus applied: %i", player->GetGUID(), SpellPowerBonus);
//sLog->outError("{}: spellpower Bonus applied: {}", player->GetGUID(), SpellPowerBonus);
}
}
//Announcements
if (difficulty > 0)
{
// Announce to player - Buff
ss << "|cffFF0000[SoloCraft] |cffFF8000" << player->GetName() << " entered %s - Difficulty Offset: %0.2f. Spellpower Bonus: %i. Class Balance Weight: %i";
ss << "|cffFF0000[SoloCraft] |cffFF8000" << player->GetName() << " entered {} - Difficulty Offset: %0.2f. Spellpower Bonus: {}. Class Balance Weight: {}";
ChatHandler(player->GetSession()).PSendSysMessage(ss.str().c_str(), map->GetMapName(), difficulty, SpellPowerBonus, classBalance);
}
else
{
// Announce to player - Debuff
ss << "|cffFF0000[SoloCraft] |cffFF8000" << player->GetName() << " entered %s - |cffFF0000BE ADVISED - You have been debuffed by offset: %0.2f with a Class Balance Weight: %i. |cffFF8000 A group member already inside has the dungeon's full buff offset. No Spellpower buff will be applied to spell casters. ALL group members must exit the dungeon and re-enter to receive a balanced offset.";
ss << "|cffFF0000[SoloCraft] |cffFF8000" << player->GetName() << " entered {} - |cffFF0000BE ADVISED - You have been debuffed by offset: %0.2f with a Class Balance Weight: {}. |cffFF8000 A group member already inside has the dungeon's full buff offset. No Spellpower buff will be applied to spell casters. ALL group members must exit the dungeon and re-enter to receive a balanced offset.";
ChatHandler(player->GetSession()).PSendSysMessage(ss.str().c_str(), map->GetMapName(), difficulty, classBalance);
}
// Save Player Dungeon Offsets to Database
CharacterDatabase.PExecute("REPLACE INTO custom_solocraft_character_stats (GUID, Difficulty, GroupSize, SpellPower, Stats) VALUES (%u, %f, %u, %i, %f)", player->GetGUID(), difficulty, numInGroup, SpellPowerBonus, SoloCraftStatsMult);
CharacterDatabase.PExecute("REPLACE INTO custom_solocraft_character_stats (GUID, Difficulty, GroupSize, SpellPower, Stats) VALUES ({}, {}, {}, {}, {})", player->GetGUID(), difficulty, numInGroup, SpellPowerBonus, SoloCraftStatsMult);
}
else
{
// Announce to player - Over Max Level Threshold
ss << "|cffFF0000[SoloCraft] |cffFF8000" << player->GetName() << " entered %s - |cffFF0000You have not been buffed. |cffFF8000 Your level is higher than the max level (%i) threshold for this dungeon.";
ss << "|cffFF0000[SoloCraft] |cffFF8000" << player->GetName() << " entered {} - |cffFF0000You have not been buffed. |cffFF8000 Your level is higher than the max level ({}) threshold for this dungeon.";
ChatHandler(player->GetSession()).PSendSysMessage(ss.str().c_str(), map->GetMapName(), dunLevel + SolocraftLevelDiff);
ClearBuffs(player, map); //Check to revert player back to normal
}
Expand All @@ -535,14 +535,14 @@ class solocraft_player_instance_handler : public PlayerScript {
if (itr->guid != player->GetGUID())
{
//Database query to find difficulty for each group member that is currently in an instance
QueryResult result = CharacterDatabase.PQuery("SELECT `GUID`, `Difficulty`, `GroupSize` FROM `custom_solocraft_character_stats` WHERE GUID = %u", itr->guid);
QueryResult result = CharacterDatabase.PQuery("SELECT `GUID`, `Difficulty`, `GroupSize` FROM `custom_solocraft_character_stats` WHERE GUID = {}", itr->guid);
if (result)
{
//Test for debuffs already give to other members - They cannot be used to determine the total offset because negative numbers will skew the total difficulty offset
if ((*result)[1].GetFloat() > 0)
{
GroupDifficulty = GroupDifficulty + (*result)[1].GetFloat();
//sLog->outError("%u : Group member GUID in instance: %u", player->GetGUID(), itr->guid);
//sLog->outError("{} : Group member GUID in instance: {}", player->GetGUID(), itr->guid);
}
}
}
Expand All @@ -554,16 +554,16 @@ class solocraft_player_instance_handler : public PlayerScript {
void ClearBuffs(Player* player, Map* map)
{
//Database query to get offset from the last instance player exited
QueryResult result = CharacterDatabase.PQuery("SELECT `GUID`, `Difficulty`, `GroupSize`, `SpellPower`, `Stats` FROM `custom_solocraft_character_stats` WHERE GUID = %u", player->GetGUID());
QueryResult result = CharacterDatabase.PQuery("SELECT `GUID`, `Difficulty`, `GroupSize`, `SpellPower`, `Stats` FROM `custom_solocraft_character_stats` WHERE GUID = {}", player->GetGUID());
if (result)
{
float difficulty = (*result)[1].GetFloat();
int SpellPowerBonus = (*result)[3].GetUInt32();
float StatsMultPct = (*result)[4].GetFloat();
//sLog->outError("Map difficulty: %f", difficulty);
//sLog->outError("Map difficulty: {}", difficulty);
// Inform the player
std::ostringstream ss;
ss << "|cffFF0000[SoloCraft] |cffFF8000" << player->GetName() << " exited to %s - Reverting Difficulty Offset: %0.2f. Spellpower Bonus Removed: %i";
ss << "|cffFF0000[SoloCraft] |cffFF8000" << player->GetName() << " exited to {} - Reverting Difficulty Offset: %0.2f. Spellpower Bonus Removed: {}";
ChatHandler(player->GetSession()).PSendSysMessage(ss.str().c_str(), map->GetMapName(), difficulty, SpellPowerBonus);
// Clear the buffs
for (int32 i = STAT_STRENGTH; i < MAX_STATS; ++i)
Expand All @@ -576,7 +576,7 @@ class solocraft_player_instance_handler : public PlayerScript {
player->ApplySpellPowerBonus(SpellPowerBonus, false);
}
//Remove database entry as the player is no longer in an instance
CharacterDatabase.PExecute("DELETE FROM custom_solocraft_character_stats WHERE GUID = %u", player->GetGUID());
CharacterDatabase.PExecute("DELETE FROM custom_solocraft_character_stats WHERE GUID = {}", player->GetGUID());
}
}
};
Expand Down

0 comments on commit d57b83b

Please sign in to comment.