Page 1 of 2 12 Last
  1. #1

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

    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.


    Code:
    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

  2. #2
    Zacchaeus's Avatar
    Join Date
    Dec 2014
    Location
    Scotland
    Posts
    11,879
    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.
    If there is something that you would like to see in Fantasy Grounds that isn't currently part of the software or if there is something you think would improve a ruleset then add your idea to the wish list http://fg2app.idea.informer.com/

  3. #3
    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:
    Code:
    			if EffectManager5E.hasEffect(rActor, "Stable") then
    				sStatus = "Unconscious";
    			else
    				sStatus = "Dying";
    			end
    sStatus will ALWAYS be “Dying” and never “Unconscious”

  4. #4
    celestian's Avatar
    Join Date
    Jan 2017
    Location
    DFW, Texas
    Posts
    2,181
    Quote Originally Posted by Varsuuk View Post
    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:
    Code:
    			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:

    Code:
    function getPercentWounded2(sNodeType, node)
      local rActor = ActorManager.getActorFromCT(node);
      local nHP, nWounds, nDeathSaveFail;
    I've corrected this in the AD&D ruleset.
    ---
    Coding the Official AD&D Ruleset
    My Twitch Channel for AD&D and FG related streams (See schedule for live days)
    My YouTube for FG related Tutorials and AD&D Actual Plays
    Custom Maps (I2, S4, T1-4, Barrowmaze,Lost City of Barakus)

  5. #5
    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)

  6. #6
    Zacchaeus's Avatar
    Join Date
    Dec 2014
    Location
    Scotland
    Posts
    11,879
    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.
    If there is something that you would like to see in Fantasy Grounds that isn't currently part of the software or if there is something you think would improve a ruleset then add your idea to the wish list http://fg2app.idea.informer.com/

  7. #7
    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.

  8. #8
    Zacchaeus's Avatar
    Join Date
    Dec 2014
    Location
    Scotland
    Posts
    11,879
    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.
    If there is something that you would like to see in Fantasy Grounds that isn't currently part of the software or if there is something you think would improve a ruleset then add your idea to the wish list http://fg2app.idea.informer.com/

  9. #9

    Join Date
    Mar 2006
    Location
    California
    Posts
    6,467
    If you are stable and unconscious after 1d4 hours you will gain 1 hp (PH 197).

  10. #10
    Zacchaeus's Avatar
    Join Date
    Dec 2014
    Location
    Scotland
    Posts
    11,879
    Quote Originally Posted by Griogre View Post
    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
    If there is something that you would like to see in Fantasy Grounds that isn't currently part of the software or if there is something you think would improve a ruleset then add your idea to the wish list http://fg2app.idea.informer.com/

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Log in

Log in