PDA

View Full Version : 5E (& originally 2E) ruleset question - is this a bug? - Unsure where to post



Varsuuk
January 17th, 2020, 06:08
While I was looking at rulesets (especially 2E) for my NPC/CT code - I came across getPercentWounded2 and was trying to understand when it would be "pc", "ct" etc and other stuff. I was trying to see if I could put in code in the future for my ruleset to treat PC, Monster, NPC (ie: special "monster") differently when it came to death options in my ruleset.

I was confused as to how "rActor" variable in 2E's manager_actor2.lua code could have a value (is it global?) and I put in a debug and it was nil.
So before I wrote in Discord to Cel, I looked to see how it was in 5E in case it was cut and paste error missing something from 5E. And I saw the same issue in 5E.

So, since 5E is big - I assumed I am reading this wrong? Or is it that no one uses "Stable" so it never is noticed?
Didn't know where to ask since it isn't a ruleset USE question but a code question. When saw Celestian posted on discord he was traveling for "a few weeks" about a week or so back - figured not wait on DM reply.
Apologies if I just read wrong.




function getPercentWounded2(sNodeType, node)
local nHP, nWounds, nDeathSaveFail;
if sNodeType == "pc" then
nHP = math.max(DB.getValue(node, "hp.total", 0), 0);
nWounds = math.max(DB.getValue(node, "hp.wounds", 0), 0);
nDeathSaveFail = DB.getValue(node, "hp.deathsavefail", 0);
elseif sNodeType == "ct" then
nHP = math.max(DB.getValue(node, "hptotal", 0), 0);
nWounds = math.max(DB.getValue(node, "wounds", 0), 0);
nDeathSaveFail = DB.getValue(node, "deathsavefail", 0);
end

local nPercentWounded = 0;
if nHP > 0 then
nPercentWounded = nWounds / nHP;
end

local sStatus;
if nPercentWounded >= 1 then
if nDeathSaveFail >= 3 then
sStatus = "Dead";
else
if EffectManager5E.hasEffect(rActor, "Stable") then
sStatus = "Unconscious";
else
sStatus = "Dying";
end
if nDeathSaveFail > 0 then
sStatus = sStatus .. " (" .. nDeathSaveFail .. ")";
end
end
elseif OptionsManager.isOption("WNDC", "detailed") then
if nPercentWounded >= .75 then
sStatus = "Critical";
elseif nPercentWounded >= .5 then
sStatus = "Heavy";
elseif nPercentWounded >= .25 then
sStatus = "Moderate";
elseif nPercentWounded > 0 then
sStatus = "Light";
else
sStatus = "Healthy";
end
else
if nPercentWounded >= .5 then
sStatus = "Heavy";
elseif nPercentWounded > 0 then
sStatus = "Wounded";
else
sStatus = "Healthy";
end
end

return nPercentWounded, sStatus;
end

Zacchaeus
January 17th, 2020, 10:15
I'm not a coder but that snippet seems to be concerned with what the colour bar and description is for NPCs and PC which is shown on the CT and on the token depending on what option the DM has set to show the health of the PC/NPC.

So if the option for wounds is set to simple and the NPC has between 75 and 100% health then it is shown as Wounded, but if the option is set to detailed then it is shown as Light.

Varsuuk
January 17th, 2020, 13:08
Gotcha, that’s why I was reading through it to translate that for what I needed. The things I noticed however is that the variable rActor is created/assigned in the method calling the one I posted. But the one I posted refers to that variable anyway. Which I believe is “not defined” (or whatever it is in Lua, since I am more familiar with languages like C++, Java.)

I wondered if it was possible that it was referring to some global rActor instead somewhere. But when I tested with 2E (by adding a debut print to it) it was printed as “nil” which is what I expected if I understood the code (which is often in question when I read these ;) it’s not my comfort zone, I don’t even use scripting languages other than bash like python/perl in my work.)

So if it is always null it means that if we reach this block:



if EffectManager5E.hasEffect(rActor, "Stable") then
sStatus = "Unconscious";
else
sStatus = "Dying";
end


sStatus will ALWAYS be “Dying” and never “Unconscious”

celestian
February 7th, 2020, 03:19
Gotcha, that’s why I was reading through it to translate that for what I needed. The things I noticed however is that the variable rActor is created/assigned in the method calling the one I posted. But the one I posted refers to that variable anyway. Which I believe is “not defined” (or whatever it is in Lua, since I am more familiar with languages like C++, Java.)

I wondered if it was possible that it was referring to some global rActor instead somewhere. But when I tested with 2E (by adding a debut print to it) it was printed as “nil” which is what I expected if I understood the code (which is often in question when I read these ;) it’s not my comfort zone, I don’t even use scripting languages other than bash like python/perl in my work.)

So if it is always null it means that if we reach this block:



if EffectManager5E.hasEffect(rActor, "Stable") then
sStatus = "Unconscious";
else
sStatus = "Dying";
end


sStatus will ALWAYS be “Dying” and never “Unconscious”

You are correct about rActor being used but never defined.

The function should be adjusted:



function getPercentWounded2(sNodeType, node)
local rActor = ActorManager.getActorFromCT(node);
local nHP, nWounds, nDeathSaveFail;



I've corrected this in the AD&D ruleset.

Varsuuk
February 7th, 2020, 07:34
That’s great. I expect I will see mostly trivial things but I tend to do borrowing line by line so I can review/understand it.

Two questions, in this case what is “stable” effect (in bed with phone not near 5E)? How does a character get it? Because how I understood it, it it was there the char goes to unconscious if the effect wasn’t, the char goes to dying (and it was prev never there because in 5E code rActor was undefined/nil)

Zacchaeus
February 7th, 2020, 09:41
If a character drops to zero hit points and becomes unconscious they need to make death saving throws. If another character spends an action administering first aid and succeeds on a skill check the dying character becomes stable (but still unconscious) and doesn't need to make any other death saving throws. There are also other circumstances when a character might be stable for example if they fail a system shock check they might drop to zero hit points but are stable.

Varsuuk
February 7th, 2020, 14:15
Awesome explanation. Makes sense. This is something we would do in AD&D to stop negative bleeding.

I pretty much think in our 5E games that they usually got healed. I also remember folks “going to” 1hp, although my memory being what it is - I might remember that wrong. It maybe going to 1hp was a workaround for applying “stable” effect which has to be put on while at 0 and probably does not stay long so maybe even if it worked, people would do 1hp for ease?

Unless heals or rest automatically removed stable which is possible, haven’t looked at it. Whatever, now I get what that was meant to do much better than before.

Zacchaeus
February 7th, 2020, 15:55
Yes, any form of healing will also remove the unconscious state and set the hp to positive - which means that the character misses the stable condition altogether. Rest on it's own I don't think automatically removes the stable condition; but healing using HD would do it during a rest.

Griogre
February 8th, 2020, 03:17
If you are stable and unconscious after 1d4 hours you will gain 1 hp (PH 197).

Zacchaeus
February 8th, 2020, 10:19
If you are stable and unconscious after 1d4 hours you will gain 1 hp (PH 197).

Indeed, but I'm not sure that FG knows that :)

Moon Wizard
February 9th, 2020, 20:03
Thanks for original report. I'll add to the v3.3.10 changes I'm accumulating in the Test channel.

Regards,
JPG