STAR TREK 2d20
  1. #1

    Maximum NPC hitpoints

    Currently in FG there's either the option to use average HP (default) or randomize NPC hp when they're dropped into the tracker.

    How hard would it be to add an option for maximum hp?


    I'm running a 6 player game and they're steamrolling and dry cleaning everything I throw at them, this seems like a a good way to extend fights slightly.

  2. #2
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    33,408
    Quote Originally Posted by GeneralChaos
    How hard would it be to add an option for maximum hp?
    Not too hard - would need to do a few steps:

    1) need to change the RHPS code in manager_options.lua to add a Max option :

    Code:
    registerOption("RHPS", false, "House Rules (GM)", "CT: Randomize NPC hit points", "option_entry_radio", 
    { labels = "On|Max|Off", values = "on|max|off", optionwidth = 70, default = "off" });
    2) code for this in ct.lua -> addNpc function:

    Code:
    	-- HP
    	if  sOptRHPS == "on" then
    		local nRandomHP = StringManager.evalDiceString(NodeManager.get(source, "hd", ""), true);
    		win.hp.setValue(nRandomHP);
            elseif sOptRHPS == "max" Then
            -- *** Work out the maximum HP here ***
    
    	else
    		win.hp.setValue(NodeManager.get(source, "hp", 0));
    	end
    Sorry, don't know off hand the best way to get the max result from a dice string. Perhaps copy StringManager.evalDiceString (in manager_string.lua) and create a new function evalDiceStrinMax and change the math.random call to math.max???

  3. #3
    Spot on, Brilliant!

  4. #4
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    33,408
    Quote Originally Posted by GeneralChaos
    Spot on, Brilliant!
    No worries, glad it worked for you...

  5. #5
    Did this work for you? It's something I wouldn't mind having an option of. Especially on big bad fights.

  6. #6
    can someone say Extension!

    Chris
    "Over thinking, over analyzing separates the body from the mind."...MJK... Tool frontman




  7. #7
    It sure worked.

    I don't know how to make an extension, but I've uploaded the modified files here

  8. #8
    I was going to do the extension for this, But i am missing something.

    If someone with more code levels could look at it.

    ERROR:Script Error: [string "ct/scripts/ct.lua"]:22: attempt to call global 'getNextWindow' (a nil value)


    Madman
    Last edited by madman; February 18th, 2012 at 15:46.
    "Over thinking, over analyzing separates the body from the mind."...MJK... Tool frontman




  9. #9
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    33,408
    Quote Originally Posted by madman
    I was going to do the extension for this, But i am missing something.

    If someone with more code levels could look at it.

    ERROR:Script Error: [string "ct/scripts/ct.lua"]:22: attempt to call global 'getNextWindow' (a nil value)


    Madman
    Joshuha mentions the issue in post #16 in this thread when MurghBpurn was having a similar problem.

    Basically, having the "<script name="ct" file="ct/scripts/ct.lua"/>" in extension.xml loads that script (and so executes it's onInit function) too early - before the Combat Tracker has been constructed and so getNextWindow fails (as there's no window to get).

    So, in this case, we need to add into the extension the xml file that constructs the CT and references ct.lua - which is ct\ct_host.xml. Then we need to reference that file in extension.xml so that it will use any scripts in the extension first (in our case the modified ct.lua). And, we need to remove the ct.lua script reference from extension.xml. Hope my explanation makes sense?

    Attached is the extension with the change made, so you can see what I mean in practice. And, it works fine with just this change.

    Thanks Madman for putting this together...

    Attachment 2187

  10. #10
    Changed the text in the extension. Forgot to say Trenloe was the one who came up with the code. Thanks by the way.

    Chris
    "Over thinking, over analyzing separates the body from the mind."...MJK... Tool frontman




Thread Information

Users Browsing this Thread

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

Bookmarks

Posting Permissions

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

Log in

Log in