playMaker

Author Topic: Test for multiple events  (Read 4004 times)

lion-gv

  • Playmaker Newbie
  • *
  • Posts: 5
Test for multiple events
« on: June 14, 2012, 07:02:14 AM »
I would like to be able to list more than one event per transition slot and only transition when all of the listed events are present. For instance transitioning when an animation is broadcasting "Allow Attack 2" event AND there is an "Attack Button" input event.
- if "Allow Attack 2" & "Attack Button" then transition to Attack 2

I also want to define events that can not be present. For instance, not allowing attack 2 if the player is invincible.
- if "Allow Attack 2" & "Attack Button" &! "Invincible" then transition to Attack 2

Can you extend transition slots to accommodate this?

Is there an existing pattern I can use to accomplish the same thing, like with Booleans or something?

Thanks!

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Test for multiple events
« Reply #1 on: June 14, 2012, 08:48:15 AM »
Hi,

 I don't think the api expose any ability to extend and modify the current transition behavior.

 A transition has one event only, you can wire two transitions to go to the same state, that's fine.

In your case, I think you need to create more states, one that will transit under the "ALLOW ATTACK 2" to a state listening then to the attack button and would fire the "ATTACK BUTTON" event when pressed.

 This is a very common practice, nothing wrong in cutting down the task into several state to really define the process and flow.

Checking for invincibility would simply require a third state inserted anywhere in your flow.

another variant would be to store all these states in boolean variables, and use the action found under the logic category like "bool all true" and list all them bool ( you would actually define invicible as the opposite, for example "vulnerable" so that the "all" true check passes)

However I would recommend the first solution, because visually it is clear and you can very easily insert more and more checks and let your system grow in complexity easily. Make use of generic events such as "YES" "NO" "TRUE" "FALSE" or similar and name your state. you will find that you can describe complex flow with a limited number of events ( instead of having specific events for each statements)

I have attached a dummy fsm showing the kind of possible flow. the global transition "ATTACK" would be fired by a fsm listening the the attack button, or you could just plug that to the button itself and listen the "MOUSE UP" or else.


bye,

 Jean

kiriri

  • Hero Member
  • *****
  • Posts: 506
Re: Test for multiple events
« Reply #2 on: June 14, 2012, 11:16:06 AM »
Now, I really don't have any practical experience in this field of programming at all, but wouldn't an integration of boo into the playmake api make such things possible (Methaprogramming)? Like adding a button to the action which triggers an extend script function? Then again, that would require instanced scripts (so the action only changes itself, and not all the rest of the actions in the other states which rely on the same code).
But wouldn't it be doable?

Then again, I really don't know much about methaprogramming :D
Best,
Sven