Advertisement

How to handle/design RPG event ???

Started by May 07, 2000 07:16 PM
19 comments, last by Veron2 24 years, 7 months ago
Hello Everyone I''m newbie here, and I have a problem about event in RPG (i.e. when man talk to man2 and there is something happen, or when man walk to some position there is something happen but once ,or after fighting there is something happen , and all event happen once) if I desing it to state machine I will have a huge thousand states I try to search previos topic here but not found. Please advice me how to design event in RPG ..... how to keep all information about event ?? (words of people,item in ..., ...) Thank you very much .. Veron 2 Veron@rome.com
I don''t know in what stage of the project you are, but I''m guessing design stage...

Maybe it''s a good idea to sum all things up you want to use.
In one of my previous games I implemented doors, enemies, objects(equipment) and other events with the folowing structure:

typedef enum
{
ELEMENT_TYPE_DOOR_LEFT,
ELEMENT_TYPE_DOOR_TOP,
ELEMENT_TYPE_DOOR_RIGHT,
ELEMENT_TYPE_DOOR_BOTTOM,
ELEMENT_TYPE_DOOR_ENEMY,
ELEMENT_TYPE_DOOR_EQUIPMENT,
ELEMENT_TYPE_DOOR_EVENT,
...etc...
}
ELEMENT_TYPE;

typedef struct
{
int iRoom;
int iCondition;
ELEMENT_TYPE eType;
int iX;
int iY;
...etc...
}
ELEMENT;

The condition is used if element is valid. For example:
- the player must have a key to open door.
- the player with a level below 10 gets enemy A.
- the player with a level above 10 gets enemy B.


Then I made a large list of "events".
When the player moved, I checked it''s position with those in the list.

Hope this is what you meant,
Bas.
Advertisement
Generally your game plot will advance as a result of key ''events''. Is that the kind of thing you are thinking of? You can represent this generally with a load of flags (encapsulated in a ''progress'' or ''events'' class, if you like.)

Perhaps something like this:
bool completed_intro_area;
bool killed_green_dragon;
bool talked_to_bard_and_got_main_quest;
bool found_spell_book;

etc etc. 4 flags allows you to represent 16 states, essentially. If there are certain parts which progress in order, you can use an enum:
enum DragonQuest { NOT_STARTED, STARTED, FOUND_DRAGON, KILLED_DRAGON, RETURNED };

These flags and enums can easily be checked by other events to see whether it is time to fire them or not. When you want to check something that should only happen once, check the flag to see if it''s happened yet. If not, make it happen, and flip the flag so it won''t happen next time.

Individual conversations and mini-scripts you probably want some sort of scripting language for, which is called by your event and loops a line every second or so. That is a little more complex
Thank you for your help !! baskuenen !!
and thank you to mr. Kylotan !
Hey you all I have a question .

- Kylotan sorry to this stupid question ,but
if I design a big RPG event then and use
your suggestion then I have many 1000 BOOL
variableS !!! ( although I use enum Dragonquest
it still have a big state)

- baskuenen , I don''t understand your condition
please show your example condition please ....
( when player level 11 what flag tell that meet enemy A or B ?)


Advertisement
quote: Original post by Anonymous Poster

Hey you all I have a question .

- Kylotan sorry to this stupid question ,but
if I design a big RPG event then and use
your suggestion then I have many 1000 BOOL
variableS !!! ( although I use enum Dragonquest
it still have a big state)


Well, if you''re worried about size, then 1000 bools isn''t much compared to your graphics If you''re thinking about complexity... well I doubt you''d need 1000 separate flags. I measure a game''s immensity by comparing it to my all-time favourite, Ultima VII, and I doubt they had more than 100 flags. Lots of stuff doesn''t need a flag, for example when you need a certain item (just check the inventory) or you need to kill a certain creature (just check if the creature is still alive). A common puzzle is the key-door type, and you need no flags for that either. You only need a flag when completion of an event is difficult to find out by some other means.

Either way, when you write your story, you might want to separate out the individual events and number them or something. That way, you can reference events in a predictable way, eg "Event 35: Encounter with Green Dragon. Will not occur if player did not meet Wizard (Event 12)." You will probably want to go back to Event 12 and write in "precondition for Event 35", to help keep track.

How to do this effectively is an interesting question. Perhaps making a flowchart of your game detailing major plot elements would help. Number these 1...n, then separate each sub part out, make a flowchart for that part, number them 1.1 to 1.n, etc etc.

Any other ideas?

Um...
Other question ...
in RPG games whick information we should keep in file ???
Hi All!

What about making your events part of the map? And then use a OOP approach to model it. For example you could have a tile class like this:

class Tile {
Terrain terrain; // reference to terrain type
Monster monster; // reference to monster occupying tile
Event event; // reference to event
}

When a character steps in to a tile where event is not a null reference, you do:

if (Tile.event.preConditions() == true) {
tile.event.activate();
}

And the activate method sets off a trap, shows a piece of dialog or a cut-scene or something. And possibly update a quest log, add or remove items from the characters inventory and so on.

The Event class would then be subclassed to give many different event types (ie. TrapEvent, EndOfLevelEvent and so on) which all shared the common method of the base Event class. Or maybe you would just have a single event class capable of doing all kind of events through some scripting.

Well, what do you think?

Regatds

nicba

[Sorry for all the editing of the message, just trying to make my code look better using some HTML tags. It didn't work]

Edited by - nicba on May 10, 2000 8:07:10 PM

Edited by - nicba on May 10, 2000 8:09:36 PM
hello again .
nicba when you use
if (Tile.event.preConditions() == true) {
tile.event.activate();
}
Is the eventpreConditions() function
build in concept like Kylotan?
(check BOOL,flag)

This topic is closed to new replies.

Advertisement