STAR TREK 2d20
  1. #1
    Varsuuk's Avatar
    Join Date
    Dec 2015
    Location
    New York
    Posts
    2,075

    Spells, saves and damage .... oh my

    Anyhow, Wizard of Oz references aside...

    I created a spell action which is really better called a spell damage action. I created a saving throw roller. Now, it hit me that I really never looked at how this works and the right way to automate. My original thought was to just create the saving throw - have the person click and if failed they click the spell for the damage (or effect).

    I figured I'd add a mod button for like 1/2 etc to press if that applied.

    Then, thought why not include more functionality in first try. Well, probably because my head got mixed up looking at 5E for ideas on how casting works (was going to look at 2E tomorrow in case it is clear since I am more familiar with 1E/2E terms but suspect even if how it worked changed the names/types are probably reused from 5E)


    Like, in broad strokes, how does it work?
    Press a "cast" action that triggers a saving throw on target(s).
    Resolve the roll(s)

    First question is how the results of the roll are persisted for the next step to reference.

    Next, the caster presses an effect/dmg button and that roll executes, checks someplace for results of the save (if allowed) and apples the damage.

    (if anyone can suggest a good place to put printstack in 5E/2E to better follow things, let me know)
    Perhaps there is a tutorial write up here or on YouTube for this sort of basic pattern?

    Appreciate your time, night all
    --Dan


    EDIT: I need to get sleep, it's 1:30am but I skimmed manager_power and saw one method calls performMultiAction with an array of rolls. So maybe the acts are all "joined" in some way after all? Didn't try to read it, just after a game and late night helping son write a paper... brain fried
    Last edited by Varsuuk; May 27th, 2021 at 06:27.

  2. #2
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    33,361
    5E handles this in two steps:-
    1) tracking of the save result for damage application purposes
    2) Removal of successful saves.

    Step 1 - the result of the save is recorded on the GM side at the end of the ActionSave.applySave OOB function (which only runs on the GM side) using the ActionDamage.setDamageState code. This tracks damage state in a LUA table aDamageState in the ActionDamage global script package. Gotcha - this is only available to the GM (as it is stored on the GM side) so this can only be accessed by code running on the GM side - usually as part of the final step of an action (apply<action>) which runs on the GM side via OOB messaging. In this case the data is set in ActionSave.applySave and is read/removed in ActionDamage.applyDamage.

    So - step 1 records the result of all targeted saves through ActionDamage.setDamageState which stores the result of the save in a LUA table referenced by the source, name of the ability/save and the target.

    Step 2 - when damage is rolled, code running on the GM side in ActionDamage.applyDamage gets the damage state (using getDamageState) to calculate the damage to apply to the targets. And, it also removes targets that succeeded the save (via the bRemoveTarget flag). This then allows any subsequent effects to be applied to the remaining targets (the ones that failed the save).

    To reiterate the gotchas (and mention another one):
    1) The result state is tracked on the GM side only - any code that sets/reads the state must run on the GM side.
    2) The results are stored in a LUA table (aDamageState) in the scope of the ActionDamage global script package - this is a local LUA table, so can cannot be accessed directly outside of that script package - the various helper functions must be used.
    3) The results are stored in memory, not the database, so they aren't maintained through a GM session restart. This shouldn't impact game play - as long as damage is rolled after making the targeted save. But it's something to keep in mind.
    4) It should be obvious, but I'll state it anyway - this only works for tracking save results for automatic saving throws with targets that is made through the cast/save button (either click with targets or drag/drop to a single target).
    Private Messages: My inbox is forever filling up with PMs. Please don't send me PMs unless they are actually private/personal messages. General FG questions should be asked in the forums - don't be afraid, the FG community don't bite and you're giving everyone the chance to respond and learn!

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
  •  
Starfinder Playlist

Log in

Log in