playMaker

Author Topic: Any ideas on how to best organize spells with playmaker?  (Read 892 times)

Snowbird

  • Playmaker Newbie
  • *
  • Posts: 25
Any ideas on how to best organize spells with playmaker?
« on: February 04, 2020, 07:37:49 PM »
I know the question title is vague, but a specific response to this problem is perfectly helpful for me:

Let's say there are 30 spells that a character can have, but a player can only have 6 spells "equipped" at once.

Right now it is very simple and I have an FSM that deals with the key presses and then goes on to cast that specific spell that follows from the key press (i.e. press 1 = flare, 2 = firebolt, 3 = fireball, etc.)

Lets say I have, in my project folder, 30 prefabs for different spells, and each time the key button is pressed, it creates (or pools, whatever) an instance of that prefab. How do I get a key press in an FSM correspond to whatever particular spell that is selected at the time (i.e. it can be changed at will).

I'd prefer something like 30 FSM's that can each individually handle the spells, with one FSM that deals with the 6 key presses and sends for whichever FSM is needed. I suppose I could do everything on one FSM if I had too (the problem being some spells need a lot more information when they are cast than others). So lets say I do have 30 individual FSM's. What is the proper way to have a send-event that can change in order to bring me to the correct one? I could figure it out with a giant if/then sort of thing but that's a mess.

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Any ideas on how to best organize spells with playmaker?
« Reply #1 on: February 04, 2020, 09:53:57 PM »
Hi.

You should have this spit up in several fsms/prefabs.

1st have a fsm to handle button/key/mouse presses.

in the fsm you could set a gameobject for each spell slot or use a array.
In there you need to place your 'Spell Handler' (with 'Spell Handler' FSM) prefabs   (selected by the player)

When a button is pressed, use 'Send Event By Name' and send to the according
Spell Handler.

Then 'Spell Handler' Will handle The actual spell attack. (Check Mana, then Shoot a fire ball (prefab) for example)

For Selecting menu you could have all the Spell Handlers preset in a parent and just disable/enable them (so even without setting as prefab this can work)
or spawn/despawn the  selected/deselected once's)