playMaker

Author Topic: Efficient Way to Handle Data In and Out of FSM?  (Read 1223 times)

rechronicle

  • Full Member
  • ***
  • Posts: 119
  • Mystvaldia
    • Indie RPG Creator
Efficient Way to Handle Data In and Out of FSM?
« on: January 21, 2019, 09:52:47 AM »
Hello,

I was wondering about how things work in Turn-Based RPG inventory and battle system. (Shown in the attachment.) Taking out STR attribute, apply it to damage calculator, and send back damage to HP bar, something like that.

What is the best way to handle this kind of data flow? Bringing out specific data from one FSM to another FSM and do conditional things, then bring the changes back to original FSM.

Or is it not work the way I thought it is?
I'm not sure enough, need enlightenment.

Hope anyone can help.
Thank you!

ch1ky3n

  • Full Member
  • ***
  • Posts: 208
Re: Efficient Way to Handle Data In and Out of FSM?
« Reply #1 on: January 21, 2019, 05:34:52 PM »
You could do all the calculation of taking out str attribute, apply it to damage calculator and send it to reduce HP bar on the OPPONENT side. So all you need to do is making the OPPONENT detect the collision/trigger that activate those actions.

it is just a suggestion, it might not fit your game type



Thore

  • Sr. Member
  • ****
  • Posts: 480
Re: Efficient Way to Handle Data In and Out of FSM?
« Reply #2 on: January 21, 2019, 05:55:15 PM »
With Set Event Data, Get Event Info, check the many posts and the example posted in this forum.

ch1ky3n

  • Full Member
  • ***
  • Posts: 208
Re: Efficient Way to Handle Data In and Out of FSM?
« Reply #3 on: January 21, 2019, 07:43:57 PM »
Woops, i guess i missed the important point of the question and gave you a trick instead.

So to pass the data between FSM, you could use,

“Set FSM” command to manipulate variable on other FSM.
“Send event” to each FSM to control the state flows on each FSM

An example,
Player has a supper dupper magic that instakill everyone on the map, you could use
“send event” broadcast all “EVENT DOOM”.

Add global state EVENT DOOM on each of the enemy FSM and put action “destroy all” inside it



djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Efficient Way to Handle Data In and Out of FSM?
« Reply #4 on: January 22, 2019, 02:52:06 AM »
Hi,
Here is a video about Global and local events :


jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Efficient Way to Handle Data In and Out of FSM?
« Reply #5 on: January 22, 2019, 03:03:29 AM »
Hi,

 typically, I use a dedicated FSM to host data, and I call it "Meta Data", all fsm are aware of this meta data fsm, and read write to it, these other fsm only store data to work with it and once they processed it, they must write back the data, for other fsm to carry on or use it later. This is done via SetFsmXXX and GetFsmXXX actions.

And then for complex sequence of event, you simply have your fsm sending events either globably or locally, depending on the context ( is it a player instance or something general to the game).

Bye,

 Jean