Assigning Modifiers to *Rand

I’ve seen on the wiki that it is possible to use *rand to set a range of numbers to do X, Y or Z.

What I have not seen (forgive me if I have missed it) is the ability to set a modifier to *rand based on a variable.

For example,

Your character is a soldier with a focus on combat but has a weakness of seeing traps. Ergo because of your skill in combat, your characters gains +X to any *rand that specifies a combat related skill (swinging a sword, punching things, etc). Conversely, your character has a -Y to any *rand that involves seeing a trap.

Is this possible with C-Script and I’m just missing something? The best I could come up with was this:

*rand 1 20 +var

sure! you can do it two different ways:

Say you’re rolling a d20 and you have +5 mod to your result, defined as the variable rollmod:

*rand rollresult (1+rollmod) (20+rollmod)

Could also do

*rand rollresult 1 20
*set rollresult + rollmod
3 Likes

Okay. So with a named variable (for example “combat”) would it look like this then?

*rand 1 20 + Combat

Edit: I swear to Drunk I’m not God.

*rand 1 20 (1+Combat) (20+Combat)

1 Like

yeah, close, you can just cut the initial 1 and 20:

*rand rollresult (1+Combat) (20+Combat)

Okay. And rollresult would be telling it to roll within the range of (1+Combat) and (20+Combat) right?

rollresult is telling it to take the result of a random number between 1+combat and 20+combat and assign it to the variable rollresult, right

Is there a way to also set it up so that when the roll is 20 (without the modifier but we want it to include the modifier in case it does not) it does something unique? If you’re familiar with D&D it’d be rolling a natural 20 versus 19 + PB + ABSM

Ooh, good question – you could fake it by checking after the fact:

*rand rollresult (1+Combat) (20+Combat)
*if (rollresult - combat = 20)
    Natural 20!
*if (rollresult - combat = 1)
    Critical Fail!

Oh awesome. This helps quite a bit. Thank you so much.

Checking multiple variables would be done this way I assume?

*rand rollresult (1+Combat+OtherThing) (20+Combat+OtherThing)
*if (rollresult - Combat - OtherThing = 20)
     Natural 20! 
*if (rollresult - Combat - OtherThing = 1)
    Natural 1!

I’m not sure if CS will let you add multiple variables at the same time, you might have to do it in a couple steps, but yeah, that’s the right logic

1 Like

Thankies.

1 Like

There is another way to do this.

Let’s say that you ordinarily roll a 1d6 and only a 6 passes the hurdle:

*temp diceroll 0
*rand diceroll 1 6

*if diceroll > 5
  *goto pass_hurdle
*else
  *goto fail_hurdle

But now you want to give a person with combat experience a “boost” on the diceroll. To do that, you need to change the threshold.

Here’s how to do that with a variable:

*temp diceroll 0
*temp threshold 5
*if combat_experience > 0
  *set threshhold 3

*rand diceroll 1 6

*if dieroll > {threshhold}
  *goto pass_hurdle
*else
  *goto fail_hurdle

This will give an inexperienced player a 1 in 6 chance of passing the roll while a combat-experienced player will have a 50/50 chance of passing the roll.

Obviously, you can calculate the threshold to whatever works best for you, and you can add different thresholds for different stat checks.

4 Likes

Thanks. I’m a little surprised this information isn’t available on the wiki but the community is pretty quick to respond.

Unfortunately the wiki isn’t open to general access/editing, due to risk of abuse.

And the people with access don’t always have the time to keep it updated. If anyone feels like they can contribute, don’t hesitate to reach out to myself or @Szaal (only admins I can think of right now that are active).

I meant no offense when I said that. It’s just surprising to me because I figured more people would be using those commands and such than there are.

1 Like

No offense taken :slight_smile:

1 Like