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 May 21, 2022
2 parents d677084 + 415b97c commit 3d7c458
Show file tree
Hide file tree
Showing 33 changed files with 802 additions and 134 deletions.
11 changes: 11 additions & 0 deletions campaign/4e/char_power.xml
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Please see the license.html file included with this distribution for
attribution and copyright information.
-->

<root>
<windowclass name="char_power" merge="join" ruleset="4E">
<script file="campaign/4e/scripts/char_power.lua" />
</windowclass>
</root>
44 changes: 44 additions & 0 deletions campaign/4e/scripts/char_power.lua
@@ -0,0 +1,44 @@
--
-- Please see the license.txt file included with this distribution for
-- attribution and copyright information.
--

local fActivatePowerOriginal;
function onInit()
fActivatePowerOriginal = super.activatePower;
super.activatePower = activatePower;

if super and super.onInit then
super.onInit()
end
end

function activatePower()
fActivatePowerOriginal();
local node = getDatabaseNode();

local charnode = node.getChild("...");
local rActor = ActorManager.resolveActor(charnode);

local sName = DB.getValue(node, "name", "");
local sRange = DB.getValue(node, "range", "");
local sRecharge = DB.getValue(node, "recharge", "");
local sAction = DB.getValue(node, "action", "");
local sKeywords = DB.getValue(node, "keywords", "");

local rPower = {
sName = sName,
sRange = sRange,
sRecharge = sRecharge,
sAction = sAction,
sKeywords = sKeywords
};
local rEventData = {
rSource = rActor,
rPower = rPower
};

TriggerManager.fireEvent(
CharPowerTMT_4E.rPowerUsedEvent.sName,
rEventData);
end
11 changes: 11 additions & 0 deletions campaign/5e/record_power.xml
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Please see the license.html file included with this distribution for
attribution and copyright information.
-->

<root>
<windowclass name="power_item" merge="join" ruleset="5E">
<script file="campaign/5e/scripts/record_power.lua" />
</windowclass>
</root>
52 changes: 52 additions & 0 deletions campaign/5e/scripts/record_power.lua
@@ -0,0 +1,52 @@
--
-- Please see the license.txt file included with this distribution for
-- attribution and copyright information.
--

local fUsePowerOriginal;

function onInit()
fUsePowerOriginal = super.usePower;
super.usePower = usePower;

if super and super.onInit then
super.onInit();
end
end

function usePower(bShowFull)
fUsePowerOriginal(bShowFull);

local node = getDatabaseNode();

local charnode = node.getChild("...");
local rActor = ActorManager.resolveActor(charnode);

local sName = DB.getValue(node, "name", "");
local nLevel = DB.getValue(node, "level", 0);
local sSchool = DB.getValue(node, "school", "");
local sCastingTime = DB.getValue(node, "castingtime", "");
local sComponents = DB.getValue(node, "components", "");
local sDuration = DB.getValue(node, "duration", "");
local sGroup = DB.getValue(node, "group", "");
local sRange = DB.getValue(node, "range", "");

local rPower = {
sName = sName,
nLevel = nLevel,
sSchool = sSchool,
sCastingTime = sCastingTime,
sComponents = sComponents,
sDuration = sDuration,
sGroup = sGroup,
sRange = sRange
};
local rEventData = {
rSource = rActor,
rPower = rPower
};

TriggerManager.fireEvent(
CharDamageTMT_5E.rPowerUsedEvent.sName,
rEventData);
end
17 changes: 15 additions & 2 deletions extension.xml
Expand Up @@ -38,15 +38,28 @@ Wood Board Vectors by Vecteezy

<base>
<script name="ActionsManagerTMT" file="scripts/manager_actions_tmt.lua" />
<script name="ActionDamageTMT_5E" file="scripts/manager_action_damage_5e_tmt.lua" ruleset="5E" />

<script name="CampaignDataManagerTMT" file="scripts/manager_campaigndata_tmt.lua" />
<script name="CharDamageTMT_5E" file="scripts/manager_char_5e_tmt.lua" ruleset="5E" />
<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" />
<script name="LibraryDataTMT" file="scripts/data_library_tmt.lua" />
<script name="TriggerData" file="scripts/data_trigger.lua" />
<script name="TriggerManager" file="scripts/manager_trigger.lua" />

<!-- 5E -->
<script name="CharDamageTMT_5E" file="scripts/manager_char_5e_tmt.lua" ruleset="5E" />
<script name="ActionDamageTMT_5E" file="scripts/manager_action_damage_5e_tmt.lua" ruleset="5E" />
<script name="ActionAttackTMT_5E" file="scripts/manager_action_attack_5e_tmt.lua" ruleset="5E" />
<includefile source="campaign/5e/record_power.xml" ruleset="5E" />

<!-- 4E -->
<script name="CharPowerTMT_4E" file="scripts/manager_char_4e_tmt.lua" ruleset="4E" />
<script name="ActionDamageTMT_4E" file="scripts/manager_action_damage_4e_tmt.lua" ruleset="4E" />
<script name="ActionAttackTMT_4E" file="scripts/manager_action_attack_4e_tmt.lua" ruleset="4E" />
<includefile source="campaign/4e/char_power.xml" ruleset="4E" />

<!-- TMT -->
<includefile source="triggers/triggers.xml" />
<includefile source="triggers/template_triggers.xml" />

Expand Down
4 changes: 4 additions & 0 deletions graphics/graphics_icons.xml
@@ -1,4 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Please see the license.html file included with this distribution for
attribution and copyright information.
-->

<root>
<icon name="TriggerMeTimbers" file="graphics/icons/TriggerMeTimbers.png" />
Expand Down
4 changes: 2 additions & 2 deletions scripts/data_library_tmt.lua
@@ -1,5 +1,5 @@
--
-- Please see the license.txt file included with this distribution for
--
-- Please see the license.txt file included with this distribution for
-- attribution and copyright information.
--

Expand Down
25 changes: 22 additions & 3 deletions scripts/data_trigger.lua
@@ -1,11 +1,30 @@
--
-- Please see the license.txt file included with this distribution for
--
-- Please see the license.txt file included with this distribution for
-- attribution and copyright information.
--

rIsSourceCondition = nil;
rIsTargetCondition = nil;

rCombatantParameter = {
sName = "sCombatant",
sDisplay = "combatant_parameter",
sDescription = "combatant_parameter_description",
sType = "combo",
aDefinedValues = {
{
sValue = "source_subject",
sDescription = "source_subject_description",
aRequiredParameters = {"rSource"}
},
{
sValue = "target_subject",
sDescription = "target_subject_description",
aRequiredParameters = {"rTarget"}
},
}
};

rComparisonParameter = {
sName = "sComparison",
sDisplay = "comparison_parameter",
Expand Down Expand Up @@ -35,7 +54,7 @@ function initializeConditions()
fCondition = isTarget,
aRequiredParameters = {"rTarget"}
};

-- TODO flesh out before re-enabling
-- TriggerManager.defineCondition(rIsSourceCondition);
-- TriggerManager.defineCondition(rIsTargetCondition);
Expand Down
81 changes: 81 additions & 0 deletions scripts/manager_action_attack_4e_tmt.lua
@@ -0,0 +1,81 @@
--
-- Please see the license.txt file included with this distribution for
-- attribution and copyright information.
--

rAfterAttackRollEvent = {
sName = "after_attack_event",
aParameters = {
"rSource",
"rTarget",
"nAttack",
"sDesc",
"sResults"
}
}
rAttackResultCondition = nil;

local fApplyAttackOriginal;

function onInit()
fApplyAttackOriginal = ActionAttack.applyAttack;
ActionAttack.applyAttack = applyAttack;

initializeConditions();
TriggerManager.defineEvent(rAfterAttackRollEvent);
end

function initializeConditions()
rAttackResultCondition = {
sName = "attack_result_condition",
fCondition = attackMatchesResultCondition,
aRequriedParameters = {
"rSource",
"rTarget",
"nAttack",
"sResults"
},
aConfigurableParameters = {
{
sName = "sAttackResult",
sDisplay = "attack_result_property_parameter",
sType = "combo",
aDefinedValues = {
"attack_result_property_hit",
"attack_result_property_miss",
"attack_result_property_critical",
"attack_result_property_fumble"
}
}
}
}

TriggerManager.defineCondition(rAttackResultCondition);
end

function attackMatchesResultCondition(rTriggerData, rEventData)
if rTriggerData.sAttackResult == "attack_result_property_hit" then
return string.match(rEventData.sResults, "%[HIT%]") ~= nil or string.match(rEventData.sResults, "%[AUTOMATIC HIT%]") ~= nil;
elseif rTriggerData.sAttackResult == "attack_result_property_critical" then
return string.match(rEventData.sResults, "%[CRITICAL HIT%]") ~= nil;
elseif rTriggerData.sAttackResult == "attack_result_property_miss" then
return string.match(rEventData.sResults, "%[MISS%]") ~= nil
elseif rTriggerData.sAttackResult == "attack_result_property_fumble" then
return string.match(rEventData.sResults, "%[AUTOMATIC MISS%]") ~= nil or string.match(rEventData.sResults, "%[FUMBLE%]") ~= nil
end

return false;
end

function applyAttack(rSource, rTarget, sDesc, nTotal, sResults, bSecret)
fApplyAttackOriginal(rSource, rTarget, sDesc, nTotal, sResults, bSecret);

local rEventData = {
rSource = rSource,
rTarget = rTarget,
nAttack = nTotal,
sDesc = sDesc,
sResults = sResults
}
TriggerManager.fireEvent(rAfterAttackRollEvent.sName, rEventData);
end
81 changes: 81 additions & 0 deletions scripts/manager_action_attack_5e_tmt.lua
@@ -0,0 +1,81 @@
--
-- Please see the license.txt file included with this distribution for
-- attribution and copyright information.
--

rAfterAttackRollEvent = {
sName = "after_attack_event",
aParameters = {
"rSource",
"rTarget",
"nAttack",
"sDesc",
"sResults"
}
}
rAttackResultCondition = nil;

local fApplyAttackOriginal;

function onInit()
fApplyAttackOriginal = ActionAttack.applyAttack;
ActionAttack.applyAttack = applyAttack;

initializeConditions();
TriggerManager.defineEvent(rAfterAttackRollEvent);
end

function initializeConditions()
rAttackResultCondition = {
sName = "attack_result_condition",
fCondition = attackMatchesResultCondition,
aRequriedParameters = {
"rSource",
"rTarget",
"nAttack",
"sResults"
},
aConfigurableParameters = {
{
sName = "sAttackResult",
sDisplay = "attack_result_property_parameter",
sType = "combo",
aDefinedValues = {
"attack_result_property_hit",
"attack_result_property_miss",
"attack_result_property_critical",
"attack_result_property_fumble"
}
}
}
}

TriggerManager.defineCondition(rAttackResultCondition);
end

function attackMatchesResultCondition(rTriggerData, rEventData)
if rTriggerData.sAttackResult == "attack_result_property_hit" then
return string.match(rEventData.sResults, "%[HIT%]") ~= nil or string.match(rEventData.sResults, "%[AUTOMATIC HIT%]") ~= nil;
elseif rTriggerData.sAttackResult == "attack_result_property_critical" then
return string.match(rEventData.sResults, "%[CRITICAL HIT%]") ~= nil;
elseif rTriggerData.sAttackResult == "attack_result_property_miss" then
return string.match(rEventData.sResults, "%[MISS%]") ~= nil
elseif rTriggerData.sAttackResult == "attack_result_property_fumble" then
return string.match(rEventData.sResults, "%[AUTOMATIC MISS%]") ~= nil or string.match(rEventData.sResults, "%[FUMBLE%]") ~= nil
end

return false;
end

function applyAttack(rSource, rTarget, bSecret, sAttackType, sDesc, nTotal, sResults)
fApplyAttackOriginal(rSource, rTarget, bSecret, sAttackType, sDesc, nTotal, sResults);

local rEventData = {
rSource = rSource,
rTarget = rTarget,
nAttack = nTotal,
sDesc = sDesc,
sResults = sResults
}
TriggerManager.fireEvent(rAfterAttackRollEvent.sName, rEventData);
end

0 comments on commit 3d7c458

Please sign in to comment.