Jump to content
Rick

How do you handle tasks

Recommended Posts

If i understand correct - you all talking about that i calling "messages system".

 

Each active object on creation adds to "listeners list"

They are all have one same method OnMessage(msg), string name and string class

 

I have global function send(name,class,msg,delay)

Message adds to "messages list"

 

In main loop i run messages list

decrace each of it delay value

and if delay became to be zero

compare name\class of message adres and "listener"

if all cool, just call listener method OnMessage with current message object

all done, message sent to all fits objects, removes it from messages list

 

So i can sending messages with delay, and no need to warry abut - when entity will be broken by peaces, when fire sprites to be respawn, sound, etc...

 

It's like Leadwerks messages system, but little updated to handle delay and possible to send many messages per iteration to one object.

 

I have one try to gather Last Chapter with such "messages system", where i'm not acessing to objects directly, all stuff only by messages, and it works good and fast for Last Chapter gameplay.

 

And in the end i'm get separate classes of all objects in world as usual, but they totaly movable from one project to another - without any warry for methods compatibility. If another project don't generate messages - this class will stay silent, if project trying to call unknown method of such messaging-class - just nothing happens, no any crashes.

 

As for me it's best issue with my developements, and when i will return to making gamplay will be use this system.

 

I hope you understand me wink.png

Share this post


Link to post

there is a pattern from functional programming called partial application which is kind of interesting for message handlers

Share this post


Link to post

If i understand correct - you all talking about that i calling "messages system".

 

Each active object on creation adds to "listeners list"

They are all have one same method OnMessage(msg), string name and string class

 

I have global function send(name,class,msg,delay)

Message adds to "messages list"

 

In main loop i run messages list

decrace each of it delay value

and if delay became to be zero

compare name\class of message adres and "listener"

if all cool, just call listener method OnMessage with current message object

all done, message sent to all fits objects, removes it from messages list

 

So i can sending messages with delay, and no need to warry abut - when entity will be broken by peaces, when fire sprites to be respawn, sound, etc...

 

It's like Leadwerks messages system, but little updated to handle delay and possible to send many messages per iteration to one object.

 

I have one try to gather Last Chapter with such "messages system", where i'm not acessing to objects directly, all stuff only by messages, and it works good and fast for Last Chapter gameplay.

 

And in the end i'm get separate classes of all objects in world as usual, but they totaly movable from one project to another - without any warry for methods compatibility. If another project don't generate messages - this class will stay silent, if project trying to call unknown method of such messaging-class - just nothing happens, no any crashes.

 

As for me it's best issue with my developements, and when i will return to making gamplay will be use this system.

 

I hope you understand me wink.png

Aily, that is exactly how I have handled communication between C++ game objects in the past, and would recommend that.

 

However, I would not recommend that for Lua because Lua has additional flexibility that allows more direct options. We can actually check to see if an entity has a specific script attached, and we can also check to see if a script attached to an entity contains a function. This would not be possible in most languages, unless you used reflection, and even then it would not be as versatile. We can also call Lua functions with any number of parameters, regardless of how many parameters the function is declared with.

 

So for Lua instead of sending a "message" to another entity, I would just call the function directly. You can add a check if you aren't sure it will be present. Basically you're just getting rid of the message receive function and going directly to the function it would have called anyways, so the messages are just an extra unnecessary layer.

Share this post


Link to post

However, I would not recommend that for Lua because Lua has additional flexibility.

 

Yes, Lua is fantastic with if someObject.SomeFuntion~=nil then ... language maked realy for people.

Share this post


Link to post

hi i read so much in the forum and i comming to my questions nearly ,the thing is how i connect attack animations with hurt animations is there someone who gives me an example more abbout this with c ++ or lua or i must finished the animation in blender and connected with controller and import than to leadwerks

 

http://www.leadwerks.com/werkspace/topic/11877-online-battle-players-vs-players-connect-attack-with-hurt-animations/

Share this post


Link to post

I tend to gravitate to finite state machines quite naturally and I'm working on my RPG framework as we speak (full time job permitting....)

 

The way I'm handling it is for each state to go through three stages intro, main, exit, in theory any or all of the stages can be null.

 

For example rather than just teleport the player intra-map or inter-map the intro stage will do the nice anim stuff, the main actually moves the player and the exit an outgoing anim.

 

At present I'm focussing on the player states and getting them all to hang together but the same applies to other stuff as well. Trigger a spawner and intro does the "I'm going to spawn something" anim, the main creates the spawned but I've left the exit null. This is because the spawned entity intro is null, the main just gets its necessary info from its spawner but it has an exit anim which leads into normal movement/behaviour. I get my full desired effect from a combination of the spawner and the spawned.

 

One useful thing is that a stage may or may not introduce a delay before hitting the next stage, very useful for synching up anims.

Share this post


Link to post

thanks for reply randomkeyhits

 

i read the content its a nice idea for me in my status actually complicated to understand the 100% ,i see now they are many ways to get it work with collusion animations betwen charakters/players

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...