Setting a difficulty level modifier

So I have these three difficulty levels.

One of which is

$difficultyEasy

How would I make this a modifier on dice rolls BEFORE they take place later in the game? (not on the same passage for example, that way I don’t have to include the code each time there’s a dice-roll event.

Code I have tried:

<<if $difficultyEasy>> <<set $roll to -=10>>Bonus Dice Roll of -10!<</if>>

So it affects this later on in the game etc.

<span id='dice-button'><<button 'Melee!'>>
	<<set $roll to random(0, 60)>>	
	<<if $roll gte $pcStats.mel>>
	<<replace '#dice-outcome'>>
			You rolled $roll!
			
			You got hit!
<</replace>>
	<<set $CurHP -= 10>><</if>>
	<<if $CurHP lt 1>>
	<<goto [[Death1]]>>	
		<<else>>
		<<if $roll lte $pcStats.mel>>
			<<set $GenemyHP -= 18>>
				<<replace '#dice-outcome'>>
				You rolled $roll.
				
				You hit it!

The Thing loses 18 HP!
				
Enemy HP Remaining - <<print "$GenemyHP">><br><br>Player HP Remaining - <<print "$CurHP">>
		<</replace>>
 	<<if $GenemyHP lte 0>>
		<<replace '#dice-outcome'>>
			You rolled a $roll.<br>
			You killed it.

[[Resume|Combat Outcome]]
		<</replace>>
		<<replace '#dice-button'>><</replace>> /% remove button %/
		<</if>>
	<</if>>
<</if>>	
<</button>>
</span>```

The issue is that the -= 10 is not a permanent thing. As soon as you say set $roll to random(0, 60), $roll is assigned a new value and that - 10 is gone.

(As a side note, I believe set $roll to -=10 is broken code. It should be set $roll to $roll - 10 or set $roll -= 10.)

My suggestion would be to have a $rollModifier variable that you set in the beginning (value adjusted based on difficulty setting) and then add it to your roll when you’re rolling.

<<if $difficultyEasy>> <<set $rollModifier to -10>>Bonus Dice Roll of -10!<</if>> 
<span id='dice-button'><<button 'Melee!'>>
	<<set $roll to random(0, 60) + $rollModifier>>
	/% rest of code is unchanged %/

Just to be clear, we’re adding a negative number, so it’s reducing the roll total like you want.

2 Likes

Cheers for that, I think it’s sorted it out. :slight_smile: