diff --git a/TemplePlus/dungeon_master.cpp b/TemplePlus/dungeon_master.cpp index b36e854ec..7dbbab5d1 100644 --- a/TemplePlus/dungeon_master.cpp +++ b/TemplePlus/dungeon_master.cpp @@ -116,6 +116,13 @@ void DungeonMaster::Render() { ImGui::TreePop(); } + // Roll Fudger + if (ImGui::TreeNodeEx("Fudge Rolls", ImGuiTreeNodeFlags_CollapsingHeader)) { + + RenderFudgeRolls(); + ImGui::TreePop(); + } + // Monster Tree if (ImGui::TreeNodeEx("Monsters", ImGuiTreeNodeFlags_CollapsingHeader)) { @@ -1255,6 +1262,17 @@ void DungeonMaster::RenderVsParty(){ +} + +void DungeonMaster::RenderFudgeRolls(){ + + ImGui::Text("Force dice roll results:"); + ImGui::RadioButton("Normal", &mForceRollType, 0); ImGui::SameLine(); + ImGui::RadioButton("Min", &mForceRollType, 1); ImGui::SameLine(); + ImGui::RadioButton("Avg", &mForceRollType, 2); ImGui::SameLine(); + ImGui::RadioButton("Max", &mForceRollType, 3); + + } void DungeonMaster::SetObjEditor(objHndl handle){ @@ -1369,6 +1387,10 @@ void DungeonMaster::SetIsHandlingMsg(bool b){ isHandlingMsg = b; } +int DungeonMaster::GetDiceRollForcing(){ + return mForceRollType; +} + bool DungeonMaster::IsMoused(){ return isMoused; } diff --git a/TemplePlus/dungeon_master.h b/TemplePlus/dungeon_master.h index 267de95af..d523d7fa1 100644 --- a/TemplePlus/dungeon_master.h +++ b/TemplePlus/dungeon_master.h @@ -27,11 +27,14 @@ class DungeonMaster bool IsHandlingMsg(); void SetIsHandlingMsg(bool b);; + int GetDiceRollForcing(); + void Render(); void RenderDmButton(); void RenderMaps(); void RenderEditedObj(); void RenderVsParty(); + void RenderFudgeRolls(); bool HandleMsg(const TigMsg & msg); bool HandleSpawning(const TigMsg & msg); @@ -88,6 +91,7 @@ class DungeonMaster // bool mIsActive = true; bool mJustOpened = false; + int mForceRollType; // 0 - normal, 1 - rolls 1s, 2 - roll 10s, 3 - rolls 20s void RenderMonster(Record& record); void RenderMonsterFilter(); diff --git a/TemplePlus/temple_functions.cpp b/TemplePlus/temple_functions.cpp index 5661e7520..80b13b46c 100644 --- a/TemplePlus/temple_functions.cpp +++ b/TemplePlus/temple_functions.cpp @@ -10,6 +10,7 @@ #include "config/config.h" #include "util/fixes.h" #include "rng.h" +#include TempleFuncs templeFuncs; @@ -25,9 +26,28 @@ class TempleFuncReplacements : public TempleFix int32_t TempleFuncs::diceRoll(uint32_t dieNum, uint32_t dieType, int32_t dieBonus) { + auto dmFudge = dmSys.GetDiceRollForcing(); int32_t result = dieBonus; - for (uint32_t i = 0; i < dieNum; i++) - { + + switch (dmFudge){ + case 0: + for (uint32_t i = 0; i < dieNum; i++) { + result += rngSys.GetInt(1, dieType); + } + return result; + case 1: + result += 1 * dieNum; + return result; + case 2: + result += (int)ceil( ( (1.0 + dieType) * dieNum) / 2); // average, rounded up for even dice + return result; + case 3: + result += dieNum * dieType; + return result; + default: + break; + } + for (uint32_t i = 0; i < dieNum; i++){ result += rngSys.GetInt(1, dieType); } return result;