Log in

View Full Version : Two Way Sync - CT to PC Char Sheet



damned
March 8th, 2016, 12:57
Im trying to find the right code to sync data to and from the Combat Tracker and the Character Sheet for an update to MoreCore.

Currently I have 6 fields on the PC Sheet nominally named:

Health
Defence
Wounds
C4
C5
Order

These names are all editable for use in your own games. Any changes made to these values on the PC sheet will update the corresponding columns (if set to be active by the GM) on the Combat Tracker. Id like Wounds and Order to be adjustable on the Combat Tracker as well. Eg GM or player might roll initiative or damage and drag it on to a target on the CT and it should update the Char Sheet.

I can see that the 3.5E and 5E rulesets do this for Wounds but there is a lot of other code in those rulesets from Health Bar colours etc to the actual damage. I havent worked out as yet what I need to keep. If anyone has done this, knows the functions to use, can point me to a simpler implementation etc - Id appreciate it!

Trenloe
March 8th, 2016, 14:29
The code will all be in the relevant manager_action_XXXX.lua scripts - where XXXXX is the action type. Attack, damage, save, etc.. The end result of the action is applied to the base PC record or NPC record in the Combat Tracker - each of these are known as the "actor" (for the format of the rActor record and for helper functions, see CoreRPG scripts\manager_actor.lua).

Now, back to the manager_action_XXXX.lua scripts. The key thing with these scripts is that any changes to actor fields are updated by the GM using OOB (Out Of Bounds) messaging. So the code gets kicked off on the client side (if it was a player doing the action) but the actual change to any database fields is done by the GM. If you have a look at the top of the 3.5E or 5E ruleset script you will see a OOB message registered in the first line of the onInit function: OOBManager.registerOOBMsgHandler(OOB_MSGTYPE_APPLY DMG, handleApplyDamage); The handleApplyDamage script can get pretty complex, but the key thing to take away is that the code is ran by the GM, even if the players do the damage action. The database changes are made against nodeTarget - search for that in the applyDamage function to see how the actual HP is updated.