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 Jun 12, 2022
2 parents 3d7c458 + 89551e9 commit 0f1125d
Show file tree
Hide file tree
Showing 8 changed files with 255 additions and 103 deletions.
1 change: 1 addition & 0 deletions extension.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ Wood Board Vectors by Vecteezy
<script name="ActionsManagerTMT" file="scripts/manager_actions_tmt.lua" />

<script name="CampaignDataManagerTMT" file="scripts/manager_campaigndata_tmt.lua" />
<script name="CombatManagerTMT" file="scripts/manager_combat_tmt.lua" />
<script name="DesktopManagerTMT" file="scripts/manager_desktop_tmt.lua" />
<script name="EffectManagerTMT" file="scripts/manager_effect_tmt.lua" />
<script name="ChatManagerTMT" file="scripts/manager_chat_tmt.lua" />
Expand Down
22 changes: 7 additions & 15 deletions scripts/manager_action_damage_5e_tmt.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ local stringFormatOriginal;

local rActiveSource = nil;
local rActiveTarget = nil;
local rDamageOutput = nil;
local rActiveDamageOutput = nil;
local bPrepareForBeforeDamageEvent = false;

rBeforeDamageTakenEvent = {
Expand All @@ -22,13 +22,6 @@ rBeforeDamageTakenEvent = {
aParameters = {"rSource", "rTarget", "nDamage", "nWounds", "nHitpoints", "nTemporaryHitpoints"}
};

-- TODO damage value comparison
-- rolls in general? if so roll type needed
-- geenral roll here confounded by resitances
-- TODO support for configurable parameters that depend on event params
-- damage exceeds wounds is primary use case here
-- which would need secondary configurable for type of comparison

rTargetHasCurrentHitPointsCondition = nil;
rCombatantHasTemporaryHitPointsCondition = nil;
rDamageValueCondition = nil;
Expand Down Expand Up @@ -186,6 +179,7 @@ end
function mathMax(adjustedWounds, zero)
math.max = mathMaxOriginal;

-- TODO account for tempHP damage by checking against the getDamageAdjust output
local nWounds = getWounds(rActiveTarget);
local nDamage = nWounds - adjustedWounds;
local nTotal = getTotalHitPoints(rActiveTarget);
Expand Down Expand Up @@ -219,8 +213,8 @@ function getDamageAdjust(rSource, rTarget, nDamage, rDamageOutput)
end

function decodeDamageText(nDamage, sDamageDesc)
rDamageOutput = decodeDamageTextOriginal(nDamage, sDamageDesc);
return rDamageOutput;
rActiveDamageOutput = decodeDamageTextOriginal(nDamage, sDamageDesc);
return rActiveDamageOutput;
end

function applyDamage(rSource, rTarget, bSecret, sDamage, nTotal)
Expand All @@ -235,7 +229,7 @@ function messageDamage(rSource, rTarget, bSecret, sDamageType, sDamageDesc, sTot

rActiveSource = nil;
rActiveTarget = nil;
rDamageOutput = nil;
rActiveDamageOutput = nil;
end

function targetHasCurrentHitpoints(rTriggerData, rEventData)
Expand Down Expand Up @@ -328,14 +322,12 @@ function getWounds(rActor, sType, nodeActor)
end

function ensureRemainingHitpoints(rTriggerData, rEventData)
-- TODO what to do about damage sharing?
-- might just work regardless
local nCurrent = rEventData.nHitpoints - rEventData.nWounds;
local nInitialDamage = rEventData.nDamage;
rEventData.nDamage = math.max(rEventData.nDamage, rTriggerData.nMinimum - nCurrent);

if nInitialDamage ~= rEventData.nDamage then
table.insert(rDamageOutput.tNotifications, rTriggerData.sMessage);
table.insert(rActiveDamageOutput.tNotifications, rTriggerData.sMessage);
end
end

Expand Down Expand Up @@ -369,7 +361,7 @@ function modifyDamage(rTriggerData, rEventData)
end

if nInitialDamage ~= rEventData.nDamage then
table.insert(rDamageOutput.tNotifications, rTriggerData.sMessage);
table.insert(rActiveDamageOutput.tNotifications, rTriggerData.sMessage);
end
end

Expand Down
6 changes: 0 additions & 6 deletions scripts/manager_actions_tmt.lua
Original file line number Diff line number Diff line change
Expand Up @@ -152,12 +152,6 @@ function rollIsType(rTriggerData, rEventData)
end

function rollIsValue(rTriggerData, rEventData)
-- TODO Halfling luck can reroll either one of the dice, but not both
-- may want to with adv dropping a 1, since the high roll could still be low
-- Could consider bool for calculating before/after dropping the die, but then any replacement action gets more complicated
-- Could make this handle each roll individually... only that complicates the "but not both" above
-- All/Lowest/Highest option on action could resolve that
-- How to handle post-drop things then, such as reliable talent etc?
if rTriggerData.bIncludeAdvantage and ActionsManager2 and ActionsManager2.decodeAdvantage then
ActionsManager2.decodeAdvantage(rEventData.rRoll);
end
Expand Down
132 changes: 67 additions & 65 deletions scripts/manager_char_5e_tmt.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ rCreatureHasTraitCondition = nil;
rPowerContainsDataCondition = nil;

rPowerUsedEvent = {
sName = "power_used_event",
aParameters = {
"rSource",
"rPower"
};
sName = "power_used_event",
aParameters = {
"rSource",
"rPower"
};
};

function onInit()
Expand Down Expand Up @@ -49,62 +49,64 @@ function initializeConditions()
TriggerManager.defineCondition(rCreatureHasTraitCondition);

rPowerContainsDataCondition = {
sName = "power_used_contains_data",
fCondition = powerContainsDataCondition,
aRequiredParameters = {
"rSource",
"rPower"
},
aConfigurableParameters = {
{
sName = "sPowerProperty",
sDisplay = "power_used_property_parameter",
sType = "combo",
aDefinedValues = {
"power_used_property_name",
"power_used_property_level",
"power_used_property_school",
"power_used_property_castingtime",
sName = "power_used_contains_data",
fCondition = powerContainsDataCondition,
aRequiredParameters = {
"rSource",
"rPower"
},
aConfigurableParameters = {
{
sName = "sPowerProperty",
sDisplay = "power_used_property_parameter",
sType = "combo",
aDefinedValues = {
"power_used_property_name",
"power_used_property_level",
"power_used_property_school",
"power_used_property_castingtime",
"power_used_property_components",
"power_used_property_duration",
"power_used_property_group",
"power_used_property_range",
}
},
{
sName = "sPowerContains",
sDisplay = "power_used_contains_parameter",
sType = "string"
}
}
}
"power_used_property_range",
}
},
{
sName = "sPowerContains",
sDisplay = "power_used_contains_parameter",
sType = "string"
}
}
}

TriggerManager.defineCondition(rPowerContainsDataCondition);
TriggerManager.defineCondition(rPowerContainsDataCondition);
end

function creatureHasTraitCondition(rTriggerData, rEventData)
if rTriggerData.sCreature == "source_subject" then
return hasTrait(rEventData.rSource, rTriggerData.sTraitName);
elseif rTriggerData.sCreature == "target_subject" then
return hasTrait(rEventData.rTarget, rTriggerData.sTraitName);
Debug.chat("creatureHasTraitCondition", rTriggerData, rEventData)
if rTriggerData.sCombatant == "source_subject" then
return hasTrait(rEventData.rSource, rTriggerData.sType, rTriggerData.sTraitName);
elseif rTriggerData.sCombatant == "target_subject" then
return hasTrait(rEventData.rTarget, rTriggerData.sType, rTriggerData.sTraitName);
end

return false;
end

function hasTrait(rActor, sTrait)
local sType, nodeActor = ActorManager.getTypeAndNode(rActor);
function hasTrait(rActor, sTraitType, sTrait)
local sNodeType, nodeActor = ActorManager.getTypeAndNode(rActor);
Debug.chat("hasTrait", rActor, sTraitType, sTrait, sNodeType, nodeActor)
if not nodeActor then
return false;
end

if sType == "pc" then
if sType == "trait_feat" then
return sType == CharManager.hasFeat(nodeActor, sTrait);
elseif sType == "trait_feature" then
return sType == CharManager.hasFeature(nodeActor, sTrait);
elseif sType == "trait_trait" then
return sType == CharManager.hasTrait(nodeActor, sTrait);
if sNodeType == "pc" then
if sTraitType == "trait_type_feat" then
return CharManager.hasFeat(nodeActor, sTrait);
elseif sTraitType == "trait_type_feature" then
return CharManager.hasFeature(nodeActor, sTrait);
elseif sTraitType == "trait_type_trait" then
return CharManager.hasTrait(nodeActor, sTrait);
else
return CharManager.hasFeat(nodeActor, sTrait) or
CharManager.hasFeature(nodeActor, sTrait) or
Expand All @@ -122,32 +124,32 @@ function hasTrait(rActor, sTrait)
end

function powerContainsDataCondition(rTriggerData, rEventData)
-- If contain property is empty, return true
if (rTriggerData.sPowerContains or "") == "" then
return true;
end
-- If contain property is empty, return true
if (rTriggerData.sPowerContains or "") == "" then
return true;
end

local sData = "";
if rTriggerData.sPowerProperty == "power_used_property_name" then
sData = rEventData.rPower.sName;
elseif rTriggerData.sPowerProperty == "power_used_property_level" then
sData = tostring(rEventData.rPower.nLevel);
elseif rTriggerData.sPowerProperty == "power_used_property_school" then
sData = rEventData.rPower.sSchool;
elseif rTriggerData.sPowerProperty == "power_used_property_castingtime" then
sData = rEventData.rPower.sCastingTime;
local sData = "";
if rTriggerData.sPowerProperty == "power_used_property_name" then
sData = rEventData.rPower.sName;
elseif rTriggerData.sPowerProperty == "power_used_property_level" then
sData = tostring(rEventData.rPower.nLevel);
elseif rTriggerData.sPowerProperty == "power_used_property_school" then
sData = rEventData.rPower.sSchool;
elseif rTriggerData.sPowerProperty == "power_used_property_castingtime" then
sData = rEventData.rPower.sCastingTime;
elseif rTriggerData.sPowerProperty == "power_used_property_components" then
sData = rEventData.rPower.sComponents;
elseif rTriggerData.sPowerProperty == "power_used_property_duration" then
sData = rEventData.rPower.sDuration;
elseif rTriggerData.sPowerProperty == "power_used_property_group" then
sData = rEventData.rPower.sGroup;
elseif rTriggerData.sPowerProperty == "power_used_property_range" then
sData = rEventData.rPower.sRange;
end
if string.find(sData:lower(), rTriggerData.sPowerContains:lower()) then
return true;
end
elseif rTriggerData.sPowerProperty == "power_used_property_range" then
sData = rEventData.rPower.sRange;
end
if string.find(sData:lower(), rTriggerData.sPowerContains:lower()) then
return true;
end

return false;
return false;
end
52 changes: 52 additions & 0 deletions scripts/manager_combat_tmt.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
--
-- Please see the license.txt file included with this distribution for
-- attribution and copyright information.
--

rRoundStartEvent = {
sName = "round_start_event",
aParameters = {
"nRound",
};
};

rTurnStartEvent = {
sName = "turn_start_event",
aParameters = {
"rSource",
};
};

rTurnEndEvent = {
sName = "turn_end_event",
aParameters = {
"rSource",
};
};

function onInit()
CombatManager.setCustomRoundStart(onRoundStart);
CombatManager.setCustomTurnStart(onTurnStart);
CombatManager.setCustomTurnEnd(onTurnEnd);

TriggerManager.defineEvent(rRoundStartEvent);
TriggerManager.defineEvent(rTurnStartEvent);
TriggerManager.defineEvent(rTurnEndEvent);
end

function onRoundStart(nCurRound)
local rEventData = {nRound=nCurRound};
TriggerManager.fireEvent(rRoundStartEvent.sName, rEventData);
end

function onTurnStart(nodeCT)
local rActor = ActorManager.resolveActor(nodeCT);
local rEventData = {rSource=rActor};
TriggerManager.fireEvent(rTurnStartEvent.sName, rEventData);
end

function onTurnEnd(nodeCT)
local rActor = ActorManager.resolveActor(nodeCT);
local rEventData = {rSource=rActor};
TriggerManager.fireEvent(rTurnEndEvent.sName, rEventData);
end
Loading

0 comments on commit 0f1125d

Please sign in to comment.