• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
ComposerCookie

Event System like RPG Maker?

13 posts in this topic

I had been making an event system, things are fine, my code work fine, but now i stuck on a conceptual idea

how would i implement the conditional branch dynamically?

I cant seem to find a good way to code it that make use efficiently of space, and having multiple if at once

 

So far, the best thing that i could come up with was to have an int* ConditionBranch[somenumber] , which when checked, if it return a value that isnt zero, it will point to a Condition (assuming a class Condition that was declared as Condition myCondition[somenumber]). But, if i do it like that, then there would only be 1 if, (because it only check for 1 thing at a time).

 

I cant figure out a way to code it so that it allow an else statement, else if statement

 

any help would be appreciated.

0

Share this post


Link to post
Share on other sites

Do you have RMXP or RMVX?

 

You can look at the interpreter class to see how Enterbrain did it. It's not very efficient, but the general structure is there.

0

Share this post


Link to post
Share on other sites

Do you have RMXP or RMVX?

 

You can look at the interpreter class to see how Enterbrain did it. It's not very efficient, but the general structure is there.

 

Arent RMXP and RMVX have the same type of event system (i mean its basic structure is there)

 

And that is actually a really good idea. I never thought about take a look at their scripting engine about the part where they do the event system

 

But if anyone have any advice to give on this i would love to hear it

0

Share this post


Link to post
Share on other sites

Nearly every game has a similar event system, not just RPGs.

Effectively it is something along these lines:

class EventManager {
RegisterListener (event, delegate)
UnregisterListener (event, delegate)
ProcessEvent( event, parameters)
}

Various objects register to listen for specific events. When the event happens, the details are sent to the event manager, which in turn forwards it on to all listeners who are interested.

There are variations, of course. You can add additional variations that limit event handling to a radius of the object, or limit it to a specific actor or target, or limit it to some other specific parameter. These serve as optimizations and don't really impact the core functionality.

The exact details of what you do within your callback delegate is up to you. That includes choosing one of several random sub-events, as your post asks.

 

can you please explain a bit more detail?

0

Share this post


Link to post
Share on other sites

can you please explain a bit more detail?

So, you have an "event", which is just an id to distinguish between events. It can be an enum, #DEFINE'd ints, hashed strings, whatever.

You also have a "delegate", which is the code that should be executed when the event happens. Delegates in C++ (which is what I assume you're using) are a pretty big topic, so I'll link you to the stackoverflow question What is a C++ delegate?

Lets say you have a class that keeps track of the player's score, and whenever an enemy is killed, the score should increase by the enemy's point value.

Pseudocode would look like this:
class ScoreTracker
{
    class EnemyKilledDelegate : Delegate
    {
       int totalPoints;

       virtual void operator()(void* data)
       {
           totalPoints = (int*)data;
       }
    }

    ScoreTracker()
    {
        //...
        EventManager* mgr;
        EnemyKilledDelegate* del;
        mgr.RegisterListener("EnemyKilled", del);
        //...
    }
}
The event manager would then keep some sort of dictionary to call the delegates when the event occurs:
class EventManager
{
    map<string, vector<Delegate*>*> eventMap;  // map strings to (pointers to (vector of pointers to delegates))
    RegisterListener(string event, Delegate* delegate)
    {
        // get the vector of delegates for the event (or create a new one)
        vector<Delegate>* eventListeners = eventMap.getOrCreate(event);
        eventListeners.add(delegate);    // add the delegate
    }

    ProcessEvent(string event, void* data)
    {
        // get the vector of delegates for the event (or create a new one)
        vector<Delegate>* eventListeners = eventMap.getOrCreate(event);

        foreach(Delegate* del in eventListeners)   // loop through and call each delegate
        {
            (*del)(data);
        }
    }
}
And finally, to fire an event:
class Enemy
{
    int pointValue;

    Die()
    {
        //...
        EventManager* mgr;
        mgr.ProcessEvent("EnemyKilled", &pointValue);
        //...
    }
}
Edited by turch
2

Share this post


Link to post
Share on other sites


Do you have RMXP or RMVX?
 
You can look at the interpreter class to see how Enterbrain did it. It's not very efficient, but the general structure is there.

 
Arent RMXP and RMVX have the same type of event system (i mean its basic structure is there)
 
And that is actually a really good idea. I never thought about take a look at their scripting engine about the part where they do the event system
 
But if anyone have any advice to give on this i would love to hear it


 
The whole of the event updating system is implemented between the Event class and the Interpreter class. When an event updates it just hands each line of its commands (in a symbolic format) into the Interpreter instance one at a time until it reaches the end of the list.
 
You others, while your points are certainly valid, in RPG Maker 'Event' is the term used for 'Entity'. He's asking about how to structure a configurable Entity AI system.
 
http://www.youtube.com/watch?v=qX-jWJvuAJs
 
It's a pretty crazy implementation. The IDE basically packages the listed commands into an array of objects. The objects have a command ID number and whatever arguments are provided. This gets marshalled into the game package to be loaded by the Ruby interpreter at runtime. It's basically a script engine on top of a script engine on top of DX9.
 
The Interpreter class is an enormous monster of a thing that IIRC is more or less stateless. It's just a huge collection of methods named 'CommandXXX(arg, arg)' where XXX is the matching command ID number from the IDE.

Just to make sure that everything is as confusing as possible, the engine uses entities to drive things like cut-scenes as well. You can create a non-collidable 'Event' with no sprite and set it to trigger whatever behavior you want using the same system as an 'Event' like a treasure chest or NPC.

Honestly, I'm not sure what OP is up to overall. If he's trying to make an RMXP clone then that's how they went about it. If he's just trying to make an RPG then it may be worth using a less convoluted system. The RMXP method is flexible for content creation, but it's slow as hell and extremely clumsy to modify.

Anyway, he's talking about customizable entity AI management, not 'events' in the normal sense of the word.
1

Share this post


Link to post
Share on other sites

 

Do you have RMXP or RMVX?
 
You can look at the interpreter class to see how Enterbrain did it. It's not very efficient, but the general structure is there.

 
Arent RMXP and RMVX have the same type of event system (i mean its basic structure is there)
 
And that is actually a really good idea. I never thought about take a look at their scripting engine about the part where they do the event system
 
But if anyone have any advice to give on this i would love to hear it

 

 
The whole of the event updating system is implemented between the Event class and the Interpreter class. When an event updates it just hands each line of its commands (in a symbolic format) into the Interpreter instance one at a time until it reaches the end of the list.
 
You others, while your points are certainly valid, in RPG Maker 'Event' is the term used for 'Entity'. He's asking about how to structure a configurable Entity AI system.
 
http://www.youtube.com/watch?v=qX-jWJvuAJs
 
It's a pretty crazy implementation. The IDE basically packages the listed commands into an array of objects. The objects have a command ID number and whatever arguments are provided. This gets marshalled into the game package to be loaded by the Ruby interpreter at runtime. It's basically a script engine on top of a script engine on top of DX9.
 
The Interpreter class is an enormous monster of a thing that IIRC is more or less stateless. It's just a huge collection of methods named 'CommandXXX(arg, arg)' where XXX is the matching command ID number from the IDE.

Just to make sure that everything is as confusing as possible, the engine uses entities to drive things like cut-scenes as well. You can create a non-collidable 'Event' with no sprite and set it to trigger whatever behavior you want using the same system as an 'Event' like a treasure chest or NPC.

Honestly, I'm not sure what OP is up to overall. If he's trying to make an RMXP clone then that's how they went about it. If he's just trying to make an RPG then it may be worth using a less convoluted system. The RMXP method is flexible for content creation, but it's slow as hell and extremely clumsy to modify.

Anyway, he's talking about customizable entity AI management, not 'events' in the normal sense of the word.

 

^This guy

 

he know what im talking about :D

 

But sadly that is what im trying to achieve - an RPG Maker event system clone

 

Now to the concept, how do i do the event system condition branch... That is the only part that i have problem on at the moment. 

 

But yeah i realized, in the end it all up to scripting. I believe i have to sort of code a "script" reader, where u can just have the { and } to state whenever there is a condition.

 

 

But again, if you have any advice/help i would definately appreciate it

0

Share this post


Link to post
Share on other sites
Did you look at the Interpreter and Event classes yet? It's been quite a while, but IIRC the Interpreter used Ruby procs to transfer control.

Are you really sure you want to do it the way Enterbrain did? It's pretty Ruby dependent.

I'm still not clear on whether you're making a game or an RPGMaker clone.
0

Share this post


Link to post
Share on other sites

Did you look at the Interpreter and Event classes yet? It's been quite a while, but IIRC the Interpreter used Ruby procs to transfer control.

Are you really sure you want to do it the way Enterbrain did? It's pretty Ruby dependent.

I'm still not clear on whether you're making a game or an RPGMaker clone.

 

Yes, I had look at the interpreter and the event class already

 

but i was thinking about taking some compiler book (aka the dragon book) and start reading

then at one point i will implement a scripting engine that apparently will do the condition branch work for me

aka the event system will be a scripting engine. where u have file 1.eventfile (is a text file filled with script)

 

so yeah i dont think it will be a RPG Maker event system clone, but i will try my best to do as good as their event system

0

Share this post


Link to post
Share on other sites
If you're just looking to script behavior why not just embed a scripting language?

Ruby is a bit of a pain in the ass to embed, but others, such as Lua, can be pretty straightforward.

I think I still have a Ruby embed at home in my archives though, so if you're interested I can upload it for you.
0

Share this post


Link to post
Share on other sites

If you're just looking to script behavior why not just embed a scripting language?

Ruby is a bit of a pain in the ass to embed, but others, such as Lua, can be pretty straightforward.

I think I still have a Ruby embed at home in my archives though, so if you're interested I can upload it for you.

This, literally.

 

If you want conditional branches and event behavior like RMXP you're either gonna end up copying most of their convuluted code to basically recreate a scripting system. You would probably fare way better just embedding an actual scripting language and using that. Faster, more powerful, more to the point.

0

Share this post


Link to post
Share on other sites

To be honest I have no knowledge of embedding scripting engine or doing script.

 

So im just doing whatever i can do for now

0

Share this post


Link to post
Share on other sites

If you can write C++ then you should have no trouble picking up a scripting language. Scripting languages are designed with the goal of making it quick and easy to write and change high level code. Lua is a good place to start.

0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0