STAR TREK 2d20
Page 1 of 2 12 Last
  1. #1

    Restricting Acing to only wildcards

    Is there are way to make non wildcards (Extras) not have their dice ace (explode)?

    https://www.fantasygrounds.com/forum...ous-extensions

    In this thread, the extension limits acing to 1 reroll but it's for everyone. Is there any way to check first to see if the roll came from an extra and, if so, limit rerolls to 0?

  2. #2
    Doswelk's Avatar
    Join Date
    Jul 2005
    Location
    Surrey, UK
    Posts
    2,679
    There is no way in FG to do that, SWADE as written all trait and damage rolls can Ace, you may be able to write an extension to do so, but I suspect it would be complicated as you are trying to go against the whole design of the system...
    My players just defeated an army, had a dogfight with aliens, machine-gunned the zombies, stormed the tower, became Legendary and died heroically

    Yours are still on combat round 6

    Get Savage
    Ultimate License Holder.
    First GM to post a game for the original FG Con!

  3. #3
    Thank you for the response (even if it's not good news). I just wondering if it's possible to get the value of the "wildcard" variable in the ruleset that determines if a PC/NPC is a wildcard or extra right before the roll with a local test = wildcard.getvalue() kind of line of code and then if test = 0 (the value set to extras), use the acing restriction extension above except with it's value change to 0 to not allow acing.
    I've actually tinnkered with the extension to not allowing acing. I'm just stuck on figuring out how to read the wildcard variable right before the roll. pretty sure "wildcard" is the name of the variable but the local test = line code doesn't work.

  4. #4
    Let me explain better...

    In the SW ruleset, in the record_npc.xml file this part of the file creates the varialbe that determines if an NPC is a wildcard that gets a wildcard die or an extra that doesn't.

    -<windowclass name="npc_header">
    <margins control="0,0,0,7"/>
    <script file="campaign/scripts/npc_header.lua"/>
    -<sheetdata>
    -<link_record_header_id>
    <class>npc</class>
    </link_record_header_id>
    <anchor_record_header_right name="rightanchor"/>
    <record_activateid/>
    <record_token name="token"/>
    <record_isidentified name="isidentified"/>
    <icon_record_locked/>
    <button_record_locked/>
    -<string_record_name_npc name="name">
    <empty textres="library_recordtype_empty_npc"/>
    </string_record_name_npc>
    -<string_record_name_npc name="nonid_name">
    <empty textres="library_recordtype_empty_nonid_npc"/>
    <invisible/>
    </string_record_name_npc>

    <record_wildcardtool name="wildcardtool"/>

    <hs name="wilddie"/>


    -<hn name="wildcard">

    <default>0</default>

    </hn>


    </sheetdata>
    </windowclass>


    So, I believe that "Wildcard" is the name of the variable to determine if the NPC is a wildcard or extra and the default is 0 or extra.

    In the Acing Restriction extension... it's beautifully simple... here is the important code:

    <base>
    <script name="SWAceLimitOne">
    function onInit()
    TraitManager.customizeRoll = customizeRoll
    end
    function customizeRoll(rRoll)
    rRoll.custom.maxacing = 0

    end
    </script>
    </base>


    Can the code me changed to read the varialbe (wildcard) to check if the roll is being made by an extra and then if so, trigger the restriction? Something like this...

    <base>
    <script name="SWAceLimitOne">
    function onInit()
    TraitManager.customizeRoll = customizeRoll
    end
    function customizeRoll(rRoll)
    local test = wildcard.getValue()
    if test == 0 then
    rRoll.custom.maxacing = 0
    end

    end
    </script>
    </base>


    When I try this, I get the error:

    attempt to index global 'wildcard' (a nil value)

    This makes me think that I am attempting to recall the value of wildcard incorrectly in the added code of the extenstion... that's where I am stuck.
    Last edited by chillybilly; November 11th, 2020 at 14:02.

  5. #5
    Just an update. I've got it to where players can ace but the host cannot with this tweaked extension code

    function onInit()
    TraitManager.customizeRoll = customizeRoll
    end
    function customizeRoll(rRoll)
    if User.isHost() then rRoll.custom.maxacing = 0
    end
    end

    My preference would be to allow Wildcard NPCs (bosses) to ace but this is a step forward.

  6. #6
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    33,402
    wildcard is a nil value because the script scope is not related to the window where wildcard is a control. TraitManager is a global script package, which doesn't have direct access to the GUI.

    customizeRoll receives rRoll - which includes the actor making the roll - stored in rRoll.actor

    Assuming that wildcard is a database field for NPCs and PCs (I haven't checked, I'm just going by the XML pasted above), then you should be able to extract the value from the database.

    Try something like this (I haven't tested):
    Code:
    function customizeRoll(rRoll)
    	local nodeCT = ActorManager.getCTNode(rRoll.actor);
    	if nodeCT then
    		local nWildcard = DB.getValue(nodeCT, "wildcard", 0);
    		if nWildcard == 0 then
    			rRoll.custom.maxacing = 0;
    		end
    	end
    end
    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
    Thank you, Trenloe!

    The code doesn't work but that's almost assuredly because "wildcard" is not the database field. I thought it was but I'll look over the coding to see where I went wrong and then insert that correct name.

  8. #8
    I tried to use an NPC variable I was almost certain I knew the name of (reach) and still couldn't get it to work.

    Here is the coding for record.npc.xml
    <windowclass name="npc_combat">
    <margins control="0,0,0,2" />
    <script file="campaign/scripts/npc_combat.lua"/>
    <sheetdata>
    <anchor_column name="columnanchor" />

    <label_column name="defeatedmarker_label">
    <static textres="defeatedmarker_label" />
    </label_column>
    <defeatedmarker_combobox_npc name="defeatedmarker" />
    <label_column name="spacereach_label">
    <static textres="size_spacereach" />
    </label_column>
    <size_space name="space" />
    <size_reach name="reach" />

    "reach" is the variable name, right? So I set the Trenloe written code to look for that...

    function customizeRoll(rRoll)
    local nodeCT = ActorManager.getCTNode(rRoll.actor);
    if nodeCT then
    local nWildcard = DB.getValue(nodeCT, "reach", 0);
    if nWildcard == 2 then
    rRoll.custom.maxacing = 0;
    end
    end
    end

    Then loaded up the program and manually changed the NPC to have reach 2. Still, the dice would ace.

  9. #9
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    33,402
    Don't look at the GUI specification. Look in the actual FG database - because this is where you're going to have to go for things like this.

    Without FG running open the campaign db.xml file. The code I provided above will hopefully provide the base database node for the actor within the combat tracker. The Savage Worlds ruleset has a slightly different structure to other rulesets, so there may need to be additional database navigation to get to the data needed.

    Put some debug in customizeRoll code to output to the console what the nodeCT object is actually pointing to. Use Debug.console("nodeCT = ", nodeCT); and check where that points to within the campaign db.xml 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!

  10. #10
    I know you are spoon-feeding me this and I'm too dumb to swallow....

    here is a picture with the db open and then FG running. I changed an NPC reach to 7 and found that in the database and I also found (I think) th wildcard variable which correctly is zero since the NPC is an extra.

    acing woes.jpg

    Shouldn't this work (if reach is 7)

    function customizeRoll(rRoll)
    local nodeCT = ActorManager.getCTNode(rRoll.actor);
    if nodeCT then
    local nWildcard = DB.getValue(nodeCT, "reach", 0);
    if nWildcard == 7 then
    rRoll.custom.maxacing = 0;
    end
    end
    end

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