Advertisement

Question about scripting

Started by June 04, 2000 07:52 AM
1 comment, last by Roderik 24 years, 6 months ago
Well, everybody seems to talk about how great scripting languages are, and since I'm planning to make a fairly complex RPG with a good story, non-linearity, "world interactivity" and everything else that's in right now , I figured that I needed to implement some form of scripting language. Now my problem is not that I don't know how to parse the scripts, convert it to to code etc.; my problem is, how exactly do I use it? I mean, should I give every object in the game universe a script which tells it how to behave? How can I make things like "twice a day a bar brawl starts in the bar in town xXX" in a scripting language? Should I execute the scripts every frame or what (I'm planning to use interpreted scripting, where the scripts are in external files which can easily be edited so recompilation won't be necessary)? I mean, it's not much of a problem to give f.e. a trap-tile a script like IF (STEPPED_ON(BY_ANY_PARTY_MEMBER)) BEGIN CAUSE_DAMAGE(A_LOT); PRINT_MESSAGE("YOU ACTIVATED A TRAP"); END or something, so the problem isn't how to execute the script (parsing etc.) but WHEN to execute it. Should I execute the script every time the party moves? I dont't think this a good way to do it, since it would be pretty slow... Edited by - Roderik on 6/4/00 7:54:35 AM
--------------------------Ghosts crowd the young child's fragile eggshell mind...
You could set up a basic event handler, and you can divide your world into sections. The event handler would take care of everything and you just ask it to notify you when something happens. Then you can optimize the event handler to know when to check things. For example in the morning (6:00 am) send a message to the rooster object to crow. The event handler can be optimized to check for certain things only if it is a certain part of the day (break day down to 24 segments and only check the segment where the hour coincides), you dont care about checking for the rooster event a 9:00pm. The same thinking can be applied to checking for proximity. The event handle can be told only check for certain events when the man comes into the right section of the level. You should look at how worlds are divided to know when to draw certain geometry (octrees).

http://3d.n3.net/
Advertisement
It''s easiest for event based scripts to be activated by triggers. Then you attach the scripts to the trigger to be processed.

For example, if you have a tile-based map, each tile will have a OnStepped handler. If you want a trap to go off when the party steps on the trap, attach a script to the OnStepped handler. Every time the party moves, check the OnStepped handler for the tile they stepped on. If the handler is non-NULL, then execute the script.

If you want a bar brawl started twice a day, you can create an hour trigger for your town structure. Whenever the party is in the town, every time an hour passes, execute the OnHour handler for the town structure. Then have the OnHour handler check the time to see if to start (or stop) a brawl in the bar.

This topic is closed to new replies.

Advertisement