DSJesterXII wrote:I'm thinking of making a text game. Using Inform 7. I don't know how to do random encounters, though. Any advice?
Well, part of it will depend on your overall game design.
For random events:
My first recommendation is to do it similar to FS, but with some changes/tweaks.
- Create a class of things (we use 'situations').
- Assign an adjective property to all of those to indicate whether they're available or not (we use 'resolved').
- If you have (or plan on having) several areas with different event sets, assign a property to indicate that. While we use 'sarea' as a text property, I'd recommend making it numeric or an adjective. Numeric would be fast and easy, though adjectives would give you the option to allow some events to work in multiple areas with little hassle.
- Assign another property to indicate what happens dealing with each situation, which can then be occupied by a say statement. While we use 'instead of' to do this, a direct say subroutine would probably work out better.
- Set up a mechanic to prompt random events to occur. This can be done similar to what we have with the explore/hunt command and trying to move into hunting areas ('dangerous doors'). If you're doing the multiple area method, then you'll want to cross-check the area property you assigned to the random events versus a similar property on the room/door/area the player is occupying or using. Tell Inform to pick a random matching one to your request and process it.
- Once a random event is completed, be sure it's assigned as such.
Review our code for 'hunting' and 'exploring' as well as 'instead of going through a dangerous door', but keep in mind the suggested changes I've outlined when planning your own method.
- For random monster encounters, I'd suggest building them as a special class of person instead of our existing method of using a table.
- Assign them the necessary values you need for combat, any adjectives, properties or other fun stuff to make comparisons.
- If you're going to have multiple areas, as above assign them a property to indicate their location (either by number or by adjective).
- When you want to call upon a random encounter, instruct inform to pick an appropriate random monster (based on level/area/whatever). Once it's picked, declare that to be a special person ('current foe' as a suggestion) and then enter your combat system.
- In your combat system, used values such as the 'level of current foe', 'hp of current foe', 'damage of current foe', etc... so you can read the stats from the current enemy.
- Have text values leading to say statements (if needed) to cover special win/loss scenes. If no such message is needed (basic dungeon crawl), run your generalized win/lose subroutine/message, award rewards if applicable and so on.