Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
Shane Parker committed Jul 11, 2022
2 parents 225dd20 + e7375ee commit b711bdb
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 39 deletions.
1 change: 1 addition & 0 deletions extension.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ SOFTWARE.
<base>
<script name="ActionInitTF" file="scripts/manager_action_init_tf_5e.lua" ruleset="5E" />
<script name="CombatManagerTF" file="scripts/manager_combat_tf.lua" />
<script name="CombatRecordManagerTF" file="scripts/manager_combat_record_tf.lua" />
<script name="OptionsTF" file="scripts/data_options_tf.lua" />

<includefile source="campaign/record_npc_5e.xml" ruleset="5E" />
Expand Down
27 changes: 27 additions & 0 deletions scripts/manager_combat_record_tf.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
--
-- Please see the license file included with this distribution for
-- attribution and copyright information.
--

local handleCombatAddInitDnDOriginal;

function onInit()
handleCombatAddInitDnDOriginal = CombatRecordManager.handleCombatAddInitDnD;
CombatRecordManager.handleCombatAddInitDnD = handleCombatAddInitDnD;
end

function handleCombatAddInitDnD(tCustom)
local nDex = DB.getValue(tCustom.nodeRecord, "abilities.dexterity.score", 10);
local nDexMod = math.floor((nDex - 10) / 2);
local tempInit = DB.getValue(tCustom.nodeRecord, "inittemporary", 0);
DB.setValue(tCustom.nodeCT, "init", "number", nDexMod + tempInit);

local sOptINIT = OptionsManager.getOption("INIT");
if sOptINIT == "roll" then
local rActor = ActorManager.resolveActor(tCustom.nodeCT);
local bSecret = CombatManager.isCTHidden(tCustom.nodeCT);
ActionInit.performRoll(nil, rActor, bSecret);
else
handleCombatAddInitDnDOriginal(tCustom);
end
end
39 changes: 0 additions & 39 deletions scripts/manager_combat_tf.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ function onInit()
CombatManager.onTurnEndEvent = onTurnEndEvent;

if "5E" == Session.RulesetName then
addNPCOriginal = CombatManager.getCustomAddNPC();
CombatManager.setCustomAddNPC(addNPC);
rollEntryInitOriginal = CombatManager2.rollEntryInit;
CombatManager2.rollEntryInit = rollEntryInit;
end
Expand Down Expand Up @@ -193,43 +191,6 @@ function onTurnEndEvent(nodeCT)
onTurnEndEventOriginal(nodeCT);
end

local setDBValueOriginal;
function enableSetValueOverride()
if not setDBValueOriginal then
setDBValueOriginal = DB.setValue;
DB.setValue = setDBValue;
end
end

function disableSetValueOverride()
if setDBValueOriginal then
DB.setValue = setDBValueOriginal;
setDBValueOriginal = nil;
end
end

function addNPC(sClass, nodeNPC, sName)
enableSetValueOverride();
local nodeEntry = addNPCOriginal(sClass, nodeNPC, sName);
local sOptINIT = OptionsManager.getOption("INIT");
if sOptINIT == "roll" then
local rActor = ActorManager.resolveActor(nodeEntry);
local bSecret = CombatManager.isCTHidden(nodeEntry);
ActionInit.performRoll(nil, rActor, bSecret);
end
return nodeEntry;
end

function setDBValue(vFirst, vSecond, vThird, ...)
if vSecond == "init" then
local tempInit = DB.getValue(vFirst, "inittemporary", 0);
setDBValueOriginal(vFirst, vSecond, vThird, unpack(arg) + tempInit);
disableSetValueOverride();
else
setDBValueOriginal(vFirst, vSecond, vThird, unpack(arg));
end
end

function rollEntryInit(nodeEntry)
local sOptINIT = OptionsManager.getOption("INIT");
if sOptINIT == "roll" then
Expand Down

0 comments on commit b711bdb

Please sign in to comment.