🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Implementation ideas

Started by
1 comment, last by Deyja 17 years, 11 months ago
Hello all, I'm writing a game using AS, and I need some ideas. It is a fantasy game (turn based). I'm defining everything inside an xml file, and there is a node with code for the different options. For example: <Room> <Script> void onEnter(Player &inout p) { if (random(1,3)>1) // chance of 2/3 { Monster m=createMonster(random(1,maxMonsters())); m.attack(p); } } </Script> </Room> <Object Name="Sword"> <Script> void onPickup(Player &inout p) { p.strength++; } void onDrop(Player &inout p) { p.strength--; } </Script> </Object> I guess you get the general idea. Now the tricky part: Sometimes, players can react to other players events (player A can cast a spell, that whenever player B wins a battle, player A will gain all experience instead. Another example: If a player has water, he won't die in the desert. So whenever a player is going to lose one life, it should check if he has water AND he is in the desert. If so, it should not lose a life. I can hardcode everything, but I want to be able to extend it (that's why I'm using AS :)) I need some kind of dynamic event registration. So an object/player/room can register/unregister an event for another object (temporal or permanent). So in the first example, the spell has an event (OnCastSpell) which should register another player's event (OnBattleEnd), and the second example, the water object should register the player's event (OnLoseLife). I hope I was clear. Any ideas are welcome. Gilad
Advertisement
I'm left confused by your explanation of exactly what you want, but it sounds vagualy like a system of my own.

I have it set up so that game entities each have a specific script associated with them. The globals in this script are that objects properties. (Each entity needs a unigue module so they also have unigue globals. An unfortunate problem.) The entities are defined in XML. The XML must define three things about every global it is setting: The name, Type, and Value. The loader uses the name and type to get the global from angelscript, and sets the value. Now, each function represents a single event. The engine calls functions like 'on_tick' and 'on_creation'. The function signatures for every event type are pre-defined.

Now, how this relates to doing that other stuff... I never needed any of that. But all this stuff is already mostly implemented in my SIL library ( http://www.omnisu.com/files/sil.zip ). It doesn't work with the latest version of angelscript, though. And I'm not sure how complete the version I released is. If you're interested, I'll update it. :)
I was bored, so I went ahead and fixed it anyway. Biggest problem was the removal of asIOutputStream, which I was actually using in other places. I still prefer the stream abstraction over the callbacks, so I'm still using it; I just had to replace it with the stream class from my preprocessor.

Also seems I was calling GetModuleID for some reason. Didn't actually use the value for anything; everything that used to take module IDs takes strings instead now. But, eh, it was there, making it not compile...

Offer's still good if you want to use it.

This topic is closed to new replies.

Advertisement