PDA

View Full Version : Weapon properties, possible bug?



celestian
December 28th, 2019, 02:10
So while working on some documentation I ran across the 5e description of weapon properties.



The weapon's properties should follow those noted in the PHB so that Fantasy Grounds recognises what they mean, Thus the acceptable properties would be, light, finesse, thrown, heavy, two-handed, reach etc. Also record here whether the weapon is magical or is made from rare materials. Acceptable words are magic, silver, adamantine. Properties should be listed separated by commas e.g light, finesse, silver, magic. Two further properties are available 'crit range x' will determine whether this weapon criticals on a number less than 20 (crit range 19 for crit on 19-20); and 'reroll x' where a weapon rerolls damage dice (for example reroll 2 will reroll any 1's and 2's that come up on the damage dice and take the rerolled values).


So, that seems to imply adding "magic,finesse" to the property value of a weapon that the weapon would then act like it was magic on damage? It doesn't appear to do that.

I noticed the same thing in the AD&D ruleset and corrected it. This should work for 5E.

Location: char_weapon.lua


function onDamageAction(draginfo)
local nodeWeapon = getDatabaseNode();
local nodeChar = nodeWeapon.getChild("...")
local rActor = ActorManager.getActor("pc", nodeChar);

local aWeaponProps = StringManager.split(DB.getValue(nodeWeapon, "properties", ""):lower(), ",", true);

local rAction = {};
rAction.bWeapon = true;
rAction.label = DB.getValue(nodeWeapon, "name", "");
if type.getValue() == 0 then
rAction.range = "M";
else
rAction.range = "R";
end

local sBaseAbility = "strength";
if type.getValue() == 1 then
sBaseAbility = "dexterity";
end

-- Check for reroll tag
for _,vProperty in ipairs(aWeaponProps) do
local nPropReroll = tonumber(vProperty:match("reroll (%d+)")) or 0;
if nPropReroll > 0 then
rAction.nReroll = nPropReroll;
end
end

rAction.clauses = {};
local aDamageNodes = UtilityManager.getSortedTable(DB.getChildren(nodeW eapon, "damagelist"));
for _,v in ipairs(aDamageNodes) do
local sDmgAbility = DB.getValue(v, "stat", "");
if sDmgAbility == "base" then
sDmgAbility = sBaseAbility;
end
local nAbilityBonus = ActorManager2.getAbilityBonus(rActor, sDmgAbility);
local nMult = DB.getValue(v, "statmult", 1);
if nAbilityBonus > 0 and nMult ~= 1 then
nAbilityBonus = math.floor(nMult * nAbilityBonus);
end
local aDmgDice = DB.getValue(v, "dice", {});
local aDmgReroll = nil;
if rAction.nReroll then
aDmgReroll = {};
for kDie,vDie in ipairs(aDmgDice) do
aDmgReroll[kDie] = rAction.nReroll;
end
end
local nDmgMod = nAbilityBonus + DB.getValue(v, "bonus", 0);
local sDmgType = DB.getValue(v, "type", "");

-- this will check the properties on the weapon and apply addition damage types found
local aWeaponDamageTypes = StringManager.split(sDmgType,",",true);
for _,sProp in ipairs(aWeaponProps) do
if StringManager.contains(DataCommon.dmgtypes, sProp) and
not StringManager.contains(aWeaponDamageTypes, sProp) then
table.insert(aWeaponDamageTypes, sProp);
end
end
sDmgType = table.concat(aWeaponDamageTypes,", ");
--
table.insert(rAction.clauses, { dice = aDmgDice, stat = sDmgAbility, statmult = nMult, modifier = nDmgMod, dmgtype = sDmgType, reroll = aDmgReroll });
end

ActionDamage.performRoll(draginfo, rActor, rAction);
return true;
end



The bold bit is what I added.

Moon Wizard
December 28th, 2019, 02:34
It doesn't do it dynamically; it only takes those into account when first adding the weapon to the PC sheet and creating the linked weapon entry.

Regards,
JPG

celestian
December 28th, 2019, 02:40
It doesn't do it dynamically; it only takes those into account when first adding the weapon to the PC sheet and creating the linked weapon entry.

Regards,
JPG

Oh, so if you manually create a weapon it is not intended to work?

damned
December 28th, 2019, 02:44
Oh, so if you manually create a weapon it is not intended to work?

It works - but you would need to drag it off and then back on the charsheet.

celestian
December 28th, 2019, 02:59
It works - but you would need to drag it off and then back on the charsheet.

If you manually create an attack in 5e actions tab you can't drag/drop it back. There is no shortcut.

Moon Wizard
December 28th, 2019, 03:03
That’s right. It only works if you drag and drop from item records to PC sheet. If you create manually, then you have to set up any property modifications manually too.

JPG

Roach
December 28th, 2019, 07:14
Would it work if I created a new Item group, say "Homebrews", create a weapon in there (or drag one there and then modify it) and drag that to a character's inventory? Or create/modify a weapon in a Package? I'm not at my pc right now to check...

€dit: NM, I just tested (didn't realize I had FG installed on this PC as well, with a demo license) with a newly created weapon: dragged from Equipment sheet to a new Test group in Items, edited that, and dragged that back to the character. Worked like a charm.

mattekure
December 28th, 2019, 18:19
In the case of a manually created weapon, you would need to add the magic keyword to the damage type, not the properties. so piercing, magic for the damage type.

celestian
December 28th, 2019, 19:53
That’s right. It only works if you drag and drop from item records to PC sheet. If you create manually, then you have to set up any property modifications manually too.

JPG

If you'd like the feature to work for anything the code snippet included should work for 5e. It won't add it if it already exists so should be sane for manually created or drag/dropped.

Thanks for the details.

Zacchaeus
December 28th, 2019, 22:07
In the case of a manually created weapon, you would need to add the magic keyword to the damage type, not the properties. so piercing, magic for the damage type.

Just for completeness if you create a weapon as a template and add magic as a property; when you combine it in the forge with a mundane weapon it adds magic damage automatically