1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. While the majority of active discourse on D20PRO has moved to our Discord Channels, this forum is still active and checked-in on regularly by our staff. However, for the very latest information, conversation and/or immediate support, please join us on Discord here: http://discord.gg/Ph38ckM
    Dismiss Notice

Scripts

Discussion in 'User Created Content' started by Krilion_GD, Dec 18, 2018.

  1. Krilion_GD

    Krilion_GD Production/Community Manager
    Staff Member

    Joined:
    Aug 1, 2011
    Messages:
    2,395
    Likes Received:
    140
    quick script just slammed out for doing a combined d20 + Dex mod + Prof/Bab line attack, so as not to have to write out dice(1d20 + func(getDexMod() + getCasterProfBonus())) everytime...

    Code:
    function getDexAttackRoll() {
        var Num = caster.rollDice("1d20");
        return Num.total() + getDexMod() + getCasterProfBonus();
    }
     

    Attached Files:

    #1 Krilion_GD, Dec 18, 2018
    Last edited: Dec 19, 2018
  2. Krilion_GD

    Krilion_GD Production/Community Manager
    Staff Member

    Joined:
    Aug 1, 2011
    Messages:
    2,395
    Likes Received:
    140
    This is untested

    num = number of units.

    Code:
    function enlargeTarget(num)
    {
        if (null !== targets)
        {
            if(Number.isInteger(num))
            {
                if(num > 50) { num = 50; }
                var xnum = target.getSize() + num;
                if(xnum > 50) { num = 50; }
                target.setSize( target.getSize() + num );
                target.setFace( target.getWidth() + num, target.getHeight() + num );
                target.setReach( target.getReach() + num );
            }
        }
    
        return 0;
    }
    
    Code:
    function reduceTarget(num)
    {
        if (null !== targets)
        {
            if(Number.isInteger(num))
            {
                if(num > 50) { num = 50; }
                var xnum = target.getSize() - num;
                if(xnum < 0) { num = 0; }
                target.setSize( target.getSize() - num );
                target.setFace( target.getWidth() - num, target.getHeight() - num );
                target.setReach( target.getReach() - num );
            }
        }
    
        return 0;
    }
    
    
     
    #2 Krilion_GD, Dec 19, 2018
    Last edited: Dec 19, 2018
  3. Tay-Dor

    Tay-Dor Active Member

    Joined:
    May 15, 2016
    Messages:
    313
    Likes Received:
    47
    Here's an example of the getDexAttackRoll() in a spell flow.
    disrupt undead.png
     
  4. Caraldur

    Caraldur Member

    Joined:
    Aug 18, 2011
    Messages:
    62
    Likes Received:
    0
    I tried using the getAttackRoll() function with a scorching ray spell but everytime it rolled the attack result was 0 and no damage was applied.

    Here are screenshots of the Scorching Ray flow, game log and the getDexAttackRoll.
    ScorchingRayFlow.png.png getDexAttackRoll.png GameLog.png

    Any idea what I'm doing wrong? I also tried the getDexAttackRoll without func() and it didn't work.

    Thanks,
    Car
     
  5. Krilion_GD

    Krilion_GD Production/Community Manager
    Staff Member

    Joined:
    Aug 1, 2011
    Messages:
    2,395
    Likes Received:
    140
    upload_2019-6-23_21-45-58.png

    You don't need a func() wrapper there. func() is used to do math or call functions from inside another function.
     
  6. Krilion_GD

    Krilion_GD Production/Community Manager
    Staff Member

    Joined:
    Aug 1, 2011
    Messages:
    2,395
    Likes Received:
    140
    var rollResult = caster.rollDice(roll);
    var result = rollResult.total();
     
  7. Caraldur

    Caraldur Member

    Joined:
    Aug 18, 2011
    Messages:
    62
    Likes Received:
    0
    I've made some modifications and its kind of working now but its not quite right. Here's what is happening, I cast the spell and then click the expand button to select each target, the script rolls and displays rolls in the game log, but the second roll isn't being used for the second target and when I apply the effect it only displays the first roll.

    I've attached some screenshots to help illustrate what I'm doing. Not sure how to fix the problem.

    ScorchingRaySpellFlow.png Targeting and GameLog Results.png getDexAttackRoll_Script.png
     
  8. Krilion_GD

    Krilion_GD Production/Community Manager
    Staff Member

    Joined:
    Aug 1, 2011
    Messages:
    2,395
    Likes Received:
    140
    Y'all are covering this on Discord I believe.
     
  9. Caraldur

    Caraldur Member

    Joined:
    Aug 18, 2011
    Messages:
    62
    Likes Received:
    0
    Yeah, all good. I'm to post the fix here, so its easy for someone else to find if they need it.
     
  10. MattBridger35777

    MattBridger35777 New Member

    Joined:
    Jun 15, 2020
    Messages:
    14
    Likes Received:
    0
    Question : How would you do this with something like Ray of Sickening? I ask because the Sickened condition applies penalties to Attack, Damage, All Skills and All Saves.
    Would you have to create Effect nodes for every single individual Skill and Save to achieve this?
     
  11. Krilion_GD

    Krilion_GD Production/Community Manager
    Staff Member

    Joined:
    Aug 1, 2011
    Messages:
    2,395
    Likes Received:
    140
    You could do this... I would not.. Denoting the Status on the target with a Status marker is enough to have the GM adjust the numbers on the fly for the character in question.
     
  12. MattBridger35777

    MattBridger35777 New Member

    Joined:
    Jun 15, 2020
    Messages:
    14
    Likes Received:
    0
    What was the fix may I ask?
     
  13. MattBridger35777

    MattBridger35777 New Member

    Joined:
    Jun 15, 2020
    Messages:
    14
    Likes Received:
    0
    Heya,
    I tried copying the Scorching Ray Flow seen above (without "Function(DexAttackRoll())", just "DexAttackRoll()" ) for my own Scorching Ray spell. What I'm finding is that even though the Caster is a Level 6 Arcanist, the second 4d6 is firing anyway, even though the Apply At Level is defined as "7,11" just like above. Anybody have any ideas why?
     
  14. Krilion_GD

    Krilion_GD Production/Community Manager
    Staff Member

    Joined:
    Aug 1, 2011
    Messages:
    2,395
    Likes Received:
    140
    These things are incredibly hard to answer or offer suggestions without seeing your work. Please export and/or screenshot what you are referring to/
     

Share This Page