How do I manage state?

Get help using Construct 2

Post » Fri May 10, 2013 2:03 pm

Hi guys,

I want to make some kind of small RPG, in this RPG the battle happens automatically. So the player would run/walk and meet enemy, and they'd automatically fight.

My game has several state, one of them is "inBattle" state. In that state there are a few phases, like: defineAttacker, calculateHit, calculateCritical, calculateDamage, and dealDamage. The problem I'm having is in the dealDamage phase.

what I want to achive is character (player) and monster take turn attacking depending on who is attacking this turn (decided in defineAttacker). But it seems while the monster is in the process of attacking, the attacker changes to character. So the character attack before the monster even deal its attack.

I think the problem is in the attacker variable, because the value change fastly when it is monster's turn. I know that is the problem but I don't know why that problem happens, because the attacker is decided in the defineAttacker phase.

So I want to know, is there a good way to manage states (or phases), or there is a way specific for construct to manage it

here's the file in dropbox: https://www.dropbox.com/s/t6i9qf725vcvglz/EXP%20project.capx

thanks
B
40
S
12
G
2
Posts: 167
Reputation: 5,061

Post » Mon May 13, 2013 2:42 am

ouch, no reply yet?
B
40
S
12
G
2
Posts: 167
Reputation: 5,061

Post » Mon May 13, 2013 7:31 am

I usually group said phases into functions. And call them accordingly, in a 'queue'. Let me check your capx first though. And happy to know a fellow countryman here in C2 forums :D
B
21
S
5
G
5
Posts: 58
Reputation: 5,232

Post » Mon May 13, 2013 10:26 am

Rough modification to functions: http://sdrv.ms/1258Rzu
B
21
S
5
G
5
Posts: 58
Reputation: 5,232

Post » Mon May 13, 2013 10:40 am

owh, I need a newer version of construct to open the file. Turns out mine isn't up to date enough.
I'll check it out later, but thanks
B
40
S
12
G
2
Posts: 167
Reputation: 5,061

Post » Tue May 14, 2013 3:06 am

wait, there's a "function" in there? how come I never notice? must be a new feature
anyway, thanks :D
B
40
S
12
G
2
Posts: 167
Reputation: 5,061

Post » Tue May 14, 2013 6:35 am

Yeah, Function plugin was introduced somewhere in February. Forgot the version number. Scirra pushes new releases pretty often so it might be a good idea to sign up for their newsletter
B
21
S
5
G
5
Posts: 58
Reputation: 5,232


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 23 guests