Well, I recommend setting up all the variables you're going to use in a great big block in your first passage, like so:
<<silently>>
<<set $maxhealth = 0>>
<<set $maxmana = 0>>
[etc]
<<endsilently>>
THEN, say you've got a passage with links that you choose what character you are:
[["I'm a fighter!"|fighter][$maxhealth = 100, $maxmana = 0]]
[["I'm a mage!"|mage][$maxhealth = 50, $maxmana = 50]]
Basically, you can stuff variable changes into links, by putting them in square brackets after the main part of the link (the link text and link passage title).
You can also do things like:
[["Health Down!"|nextpage][$health = $health - 1]]
[["Health Up!"|nextpage][$health = $health + 1]]
For dice, you need to use the random function. random(x,y) will give you a number between x and y, inclusive.
So:
[["Health Down!"|nextpage][$health = $health - random(1,5)]]
will subtract anywhere from 1 to 5 from your health.
Of course, at this point, nothing will change if you go below 0, or above $maxhealth. But this should give you something to play with while I'm thinking about the best way to handle those two contingencies. XD