Starfinder Playlist
  1. #1

    Existing function parse through Damage types, ie 2d6 heat

    Afternoon Folks,

    Been banging on with WOIN recently, trying to sign off all the loose ends, niggles and caveats.

    One on my list is this.

    Within the NPC section, we you add 'attack actions' you have a damage box, in that you can put in 3d6 slashing, 2d6 ion, 2d6 cold etc.

    Here's a screeny of the CT with a few NPC's added.

    Attachment 19750

    What I'm after is pulling the 'Damage Type' from the damage string, ie 'slashing', 'ion', 'cold' from my earlier examples.

    I know I can iterate through the field and work this out myself, but wondering if there's an official function that does this.

    Cheers
    Colin
    Ruleset and much more content built for FGU.
    Come join me on Twitter at: https://twitter.com/MadBeardMan to see what I'm up to!

  2. #2
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    33,582
    See the various functions in the UTILITY FUNCTIONS section of the 5E scripts\manager_action_damage.lua file.
    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!

  3. #3
    I have, there's not one that does this, so I'm writing one myself.

    Cheers
    Ruleset and much more content built for FGU.
    Come join me on Twitter at: https://twitter.com/MadBeardMan to see what I'm up to!

  4. #4
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    33,582
    Then I'm confused what you're trying to do (and when). Can you provide more information on when (i.e. which event) you're trying to extract the damage type, and what format the data is in at that point?
    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!

  5. #5
    The 'damage' string is '2d6 heat'.

    All I want is the 'heat' word from that string. This is so I can populate the 'dmgtype' property with this.

    So what I've done is add a new method to the ActionDamage class to do this, it's very crude as it steps through all the words and returns the last word.
    Ruleset and much more content built for FGU.
    Come join me on Twitter at: https://twitter.com/MadBeardMan to see what I'm up to!

  6. #6
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    33,582
    So, the "when" I mentioned is when damage is being rolled - as part of the damage action?
    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!

  7. #7
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    33,582
    Have a look at the 5E scripts\manager_combat2.lua file. The function parseAttackLine parses the data in the CT attack line. The section of code beginning elseif sAbility:sub(1,4) == "DMG:" and #sAbility > 4 then sets up the damage clause, which includes aClause.dmgtype

    Hope that's what you're looking for.
    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!

  8. #8
    That function does far more than what I need as it looks for Abilities to add bonuses etc etc.

    WOiN is built right on top of CoreRPG but in places I've borrowed from 5E. I've got all the basics of combat working now I'm onto the 'awkward' bits....

    Cheers for the replies chap.
    Ruleset and much more content built for FGU.
    Come join me on Twitter at: https://twitter.com/MadBeardMan to see what I'm up to!

  9. #9
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    33,582
    Quote Originally Posted by MadBeardMan View Post
    That function does far more than what I need as it looks for Abilities to add bonuses etc etc.
    You can ignore the stuff you don't want. There's a section that adds a clause LUA table (aClause) that has three entries: .dice (the damage dice to roll), .modifier (the modifier to apply to the damage roll) and .dmgtype (the damage types to apply to the roll - which is what you're looking for).

    Code:
    local aDmgType = {};
    while aPowerWords[i+1] and not StringManager.isDiceString(aPowerWords[i+1]) and not StringManager.isWord(aPowerWords[i+1], {"and", "plus"}) do
    	table.insert(aDmgType, aPowerWords[i+1]);
    	i = i + 1;
    end
    aClause.dmgtype = table.concat(aDmgType, ",");
    This strips out the dice string plus any "and" or "plus" entries in the attack string and gives the remaining damage types in the aDmgType table. The table entries are then concatenated together. In your two screenshots in post #1: 2d6+5 desiccation and 2d6 heat this would result in aClause.dmgtype being "desiccation" and "heat", respectively. You'd just need to set aPowerWords using the damage string, e.g. local aPowerWords = StringManager.parseWords(sDamage); and step through the power words - this is all in the section of code I've previously referenced.
    Last edited by Trenloe; July 9th, 2017 at 18:04.
    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!

  10. #10
    Cheers for letting me know, I'm a coder who prefers nice and clean functions/methods, sometimes best to call a method that does 1 thing, but as that does more than 1 I might look into using it to parse the full string rather than like this:

    Code:
        local sDamage = damage.getValue();
        local aDice, nMod = StringManager.convertStringToDice(sDamage);
        local sDmgType = ActionDamage.getDamageType(sDamage);
    Ruleset and much more content built for FGU.
    Come join me on Twitter at: https://twitter.com/MadBeardMan to see what I'm up to!

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
  •  
5E Character Create Playlist

Log in

Log in