STAR TREK 2d20
  1. #1

    Troubles with fn rollStandardInit and groups

    Hi all,
    I have some troubles with function CombatManager.rollStandardInit and groups.

    In the 5E Combat Manager, function rollRandomInit is defined, which is assigned to the CoreRPG COmbatManager to be the function handling NPC init rolls. The 5E rollRandomInit is very short and basically just rolls a D20 and determines ADV and DIS, nothing else.

    In my ruleset, I need to have a more complex init roll. I have build this in manager_action_init. I assign the perfomRoll function of the Manager to be used by CoreRPG and it works just fine except if I roll init for groups.

    The issue seems to be the order of function calls. FGU runs through rollStandardInit, which triggers the performRoll function in manager_action_init. However, it runs through the loops defined for group init rolls without waiting for the roll result of the first NPC called via performRoll. Consequently, the first NPC has no init value and cannot inherit anything to other group NPCs. They all get a init of zero assigned.

    Init.png

    Any ideas on how to resolve this?

  2. #2
    Please post the code from your CombatManager2 functions that call these functions.

    Every ruleset has it's own implementation of how these are called in order for this to work with each system. The built-in functions in CombatManager have some specific assumptions, such as that you are using the INIT option for group vs. individual init for NPCs, and that the final initiative is a number field named "initresult", etc.)

    You can always implement your own functions completely independent of these, if your needs don't match up to the implementation (that was mostly designed to support D&D and clones).

    Regards,
    JPG

  3. #3
    Hi Moon Wizard,
    this is the code change to vanilla 5E. "performRoll" isn't returning a value, I grab the init roll result from the DB. However, the value is written to the DB in "handleApplyInit", which only runs after "rollStandardInit" has run.

    Code:
    function rollRandomInit(tInit)
    	ActionInit.performRoll(draginfo, tInit.nodeEntry, true);
    	
    	local nInitResult = DB.getValue(ActorManager.getCTNode(tInit.nodeEntry), "initresult")
    	Debug.chat("nodeEntry", tInit.nodeEntry)
    	Debug.chat("nInitResult", nInitResult)
    	
    	return nInitResult + (tInit.nMod or 0);
    end
    Test.png

  4. #4
    The rollRandomInit function is not meant to call an actual 3D dice roll; but to randomly calculate a number in script behind the scenes and return it. If you look at the example in 5E, you can see an example of this.

    It won't work the way you are doing it, because the3D dice rolls are asynchronous and will still be rolling when your script continues.

    Regards,
    JPG

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