Skip to content

Commit

Permalink
v1.2 - Work with FGU 4.1.14+
Browse files Browse the repository at this point in the history
  • Loading branch information
JustinFreitas committed Mar 16, 2022
1 parent f37c564 commit 0d2b590
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 8 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@

https://github.com/JustinFreitas/AspectOfTheBeastBear

Aspect Of The Beast: Bear v1.1, by Justin Freitas
Aspect Of The Beast: Bear v1.2, by Justin Freitas

ReadMe and Usage Notes

The purpose of this Fantasy Grounds 5e extension is to apply an additional 2x multiplier to encumbrance limits to barbarians of level 6 or higher that have the Aspect of the Beast: Bear listed in their features. The 'Bear' designation can be separated from the main feature with a dash or colon (i.e. - or :). Any amount of white space is also fine as it's matched via a flexible regular expression.
The purpose of this Fantasy Grounds 5e extension is to apply an additional 2x multiplier to encumbrance limits to barbarians of level 6 or higher that have the Aspect of the Beast: Bear listed in their features. The 'Bear' designation can be separated from the main feature with a dash or colon (i.e. - or :). Any amount of white space is also fine as it's matched via a flexible regular expression. Note, that if the client is FGU of 4.1.14 or greater, this functionality is built in and works off of 'Aspect of the Bear' by default, so the extension will be smart and not double up the bonus a second time if both are found.

Future Enhancements:
- Have the barbarian class and level filtering be an option instead of always enabled, defaulting to enabled.

Changelist:
- v1.0 - Initial version.
- v1.1 - Improvements to conform to FGU and upcoming standards. Improvements in code structure. Matching/regex improvements for flexibility and reliability. Function renaming for clarity.
- v1.2 - Fixed the extension to work with the FGU 4.1.14+ Aspect of the Bear functionality and not double the bonus a second time.
4 changes: 2 additions & 2 deletions extension.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<root version="3.3">
<announcement text="Aspect of the Beast: Bear v1.1.1, 2/20/22\r2021-22 Justin Freitas, FGC/FGU 5E" font="emotefont" icon="bear_icon" />
<announcement text="Aspect of the Beast: Bear v1.2, 3/15/22\r2021-22 Justin Freitas, FGC/FGU 5E" font="emotefont" icon="bear_icon" />
<properties>
<name>Feature: Aspect of the Beast - Bear</name>
<version>1.1.1</version>
<version>1.2</version>
<loadorder>998</loadorder>
<author>Justin Freitas</author>
<description>Double encumbrance limits if character is a barbarian of level six or higher and has Aspect of the Beast: Bear in their Features.</description>
Expand Down
20 changes: 16 additions & 4 deletions scripts/aspect_of_the_beast_bear.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
local getEncumbranceMult_orig
local bBearFromFGU

function onInit()
getEncumbranceMult_orig = CharManager.getEncumbranceMult
Expand All @@ -7,6 +8,12 @@ function onInit()
local featureNamePath = "charsheet.*.featurelist.*.name"
DB.addHandler(featureNamePath, "onAdd", onFeatureNameAddOrUpdate)
DB.addHandler(featureNamePath, "onUpdate", onFeatureNameAddOrUpdate)
bBearFromFGU = checkBearFromFGU()
end

function checkBearFromFGU()
local nMajor, nMinor, nPatch = Interface.getVersion()
return nMajor >= 4 and nMinor >= 1 and nPatch >= 14
end

-- This is entered on strength change or trait change (not feature)
Expand All @@ -15,22 +22,27 @@ end
function getEncumbranceMultOverride(nodeChar)
local mult = getEncumbranceMult_orig(nodeChar)
if isBarbarianOfLevelSixOrHigher(nodeChar) and
hasAspectOfTheBeastBear(nodeChar) then
hasAspectOfTheBeastBearIndependentOfFGU(nodeChar) then
mult = mult * 2
end

return mult
end

function hasAspectOfTheBeastBear(nodeChar)
function hasAspectOfTheBeastBearIndependentOfFGU(nodeChar)
local bBear, bBeastBear
for _, nodeFeature in pairs(DB.getChildren(nodeChar, "featurelist")) do
local name = DB.getValue(nodeFeature, "name", ""):lower()
if string.match(name, "^%W*aspect%W+of%W+the%W+beast%W*bear%W*$") then
return true
bBeastBear = true;
elseif string.match(name, "^%W*aspect%W+of%W+the%W+bear%W*$") then
bBear = true;
end
end

return false
return (bBear and not bBearFromFGU) or
(bBeastBear and not bBearFromFGU) or
(bBeastBear and not bBear and bBearFromFGU)
end

function isBarbarianOfLevelSixOrHigher(nodeChar)
Expand Down

0 comments on commit 0d2b590

Please sign in to comment.