Initiative during combat, with Inform


I’m making a RPG and i wonder how to do concerning the initiative, in a fight. If you have 10 people (let’s say the player + 4 companions, and 5 opponents), how do you do something like :

repeat with P running through fighting person SORTED BY AGILITY (for example) begin ; [ P attack or parry or whatever ] ; end repeat.


A friend of mine told me it wasn’t possible at all, but I hope he’s wrong…

See chapter 20 (Lists), particularly the section on sorting lists.

Tables might be better for this. Try making a Table of Combatants with an “attacker” column and an “initiative” column and lots of blank rows. Then put the attackers into the table with their initiatives, and “repeat through the Table of Combatants in initiative column order”.

thank you zarf and draconis … I SHOULD read entirely the manual one of these days …

that said … Draconis, if and only if you have just a little more time for me, could you paste here some example code ? I never used tables and if I understand the principle of what you wrote, I wouldn’t be able to code it by myself, from scratch…


Table of Combatants
attacker        initiative
a person        a number
(with 10 empty rows)

Add a person by selecting a blank row and changing the entries. Then:

Repeat through the Table of Combatants in initiative column order:

thank you, I’ll try that :slight_smile:

You could also consider using the Inform ATTACK system which includes this by default.

oh, thanks :slight_smile: