# Creating an action system

This topic is 3222 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi. I am trying to create a simple yet flexible action system for my platform game (currently being developed in XNA) but it seems I need to think outside the box. So what do I mean with Action System The Action System, AS for short, is a system that is capable of tracking the current actions the player is performing and preventing unavailable and illegal action and action combinations to be performed. Illegal Action Combinations, IAC, is a series of actions that is "physically" impossible to perform, like Crouching while Jumping or Jumping while Falling while Unavailable Action, UA, are actions that need a specific talent or item to perfom, like the Spiderball in Metroid or some sticky boots to be able to walk upside down. I got a few actions up and running with the classic switch-case/if methods, but those are really a mess with restricions like mine and I need a way to get a better overview and control over the system. I had some kind of Actor-system underway, but fell on its "bloatity". Can someone shed some light over here or give me some tips and hints?

##### Share on other sites
Did you look into states/FSMs ?

##### Share on other sites
No not really, but FSMs in that scale can be a bit tedious; I am expecting atleast 10-20 actions and around the same in interactions so a FSM with atleast 40 states gets pretty nasty, but I will take a better look at FSMs anyway so thanks for the tip.

##### Share on other sites
Quote:
 Original post by WixnerNo not really, but FSMs in that scale can be a bit tedious; I am expecting atleast 10-20 actions and around the same in interactions so a FSM with atleast 40 states gets pretty nasty, but I will take a better look at FSMs anyway so thanks for the tip.

No, you just need to code it better. Look up representing FSM using tables.

http://en.wikipedia.org/wiki/Finite_state_machine

You'd basically have a column/row of 40. You populate these with 0s and 1s. 1 representing that it's possible to go from state A to state B, while 0 representing a no.

Then you'd just need to:
if (state[current_state][next_state] == 1) {   current_state = next_state;   perform_action(next_state);}

[Edited by - alnite on April 23, 2009 1:18:37 AM]

##### Share on other sites
I found this article very useful a couple of years ago when I was coding a platform game for the GBA. Hope you find it useful!

Cheers,

--Nacho