Hey there. A friend of mine has asked me if it would be possible to try to recreate a combat system from a certain tabletop RPG, and while I think I might be able to do it with some time, I might need a little bit of help.
Right now, what I’d like to know is, is there an easy way to handle dice? I either thought it’d involve a lot of ‘roll a random number from 1 to 6’ or having a value called ‘dice’, and specifying ‘D1’, ‘D2’, ‘D3’, ‘D4’, ‘D5’, and ‘D6’ as dice. The problem is that in both of those ways, I’m not really sure how to have Inform compare the roll of the player and the AI opponent.
Here’s my code so far, although it’s incorrect:
[code]“Jadeclaw Combat Simulator” by Robert Naytor
Include Simple Chat by Mark Tilford.
A person is either attackfirst or attacksecond. A person is usually attacksecond.
A dice is a kind of value. The dices are D1, D2, D3, D4, D5, D6, D7, and D8. A person has a dice. The dice of a person is usually D8.
The Combat Room is a room. The player is in The Combat Room.
The mook is a person. The mook is in The Combat Room.
When play begins:
run a conversation from roll-init;
Roll-init is a chat node.
Report giving link to roll-init: say “Roll initiative.” instead.
Report giving text for roll-init:
let D be a random dice;
if the D of the player is greater than the D of the mook:
say “You go first.”;
if the D of the mook is greater than the D of the player:
say “You go second.”’[/code]
When I say ‘D1’ and such in the code, it’s not meant to be an actual dice, it’s just to seperate it from a regular number.
Basically, how initiative in this game works is that two characters roll their Body die, which is a 1D6 for the player, and a 1d8 for the enemy, and their Mind die, which is 1d6 for both. Instead of adding them together, you just compare what you got on the dice. Whoever gets a higher number goes first. I just need to figure out how to code that.