1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Scripts

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

  1. Krilion_GD

    Krilion_GD Community Manager
    Staff Member

    Joined:
    Aug 1, 2011
    Messages:
    2,176
    Likes Received:
    136
    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 Community Manager
    Staff Member

    Joined:
    Aug 1, 2011
    Messages:
    2,176
    Likes Received:
    136
    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:
    311
    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 Community Manager
    Staff Member

    Joined:
    Aug 1, 2011
    Messages:
    2,176
    Likes Received:
    136
    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 Community Manager
    Staff Member

    Joined:
    Aug 1, 2011
    Messages:
    2,176
    Likes Received:
    136
    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 Community Manager
    Staff Member

    Joined:
    Aug 1, 2011
    Messages:
    2,176
    Likes Received:
    136
    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.
     

Share This Page