About AI and nested functions (but not about a missing bracket, I swear)

Started by Pierrec, Sat 31/03/2012 12:31:30

Previous topic - Next topic

Pierrec

Hi there!
I've already made some point and clicks games with AGS and now I want to try something else.
I want to make a game with a combat screen based on a shifumi game. Well, it's not really a shifumi, it's another chinese game with reloading, blocking and blasting. (you reload, you get an energy point, you can use energy points to blast, if a player get blasted while he was reloading, he lose).
This is a random game, like shifumi, but with a bit of strategy, so, I have to code an AI, and that's precisely my challenge!

I have no problem coding the AI, but I can't think of any way to implement it in AGS. Let me explain...
I've got the AI code, which define the AI choice (reload, block, blast or megablast (like a blast but it cost 3 energy points and can't be blocked).
And I've got the combat resolution code, defining who lose life points, energy points etc...

This is how it should work in my head:
-The player make his choice clicking a button (for exemple : blast)
-The click-on-blast function opens.
-The AI code is "called" to know what is the AI choice (for exemple : reload)
-The combat is solved (in this exemple, the player lose an energy point and the AI lose a life point) 
-The click-on-blast function closes.
-Next turn

My problem is : I can't manage to "call" the AI snippet! I don't know where I should write this snippet to call it when the player press a button.
-If the AI code is in a custom function, I can't call it because nested function are not supported.
-I can't neither use a Struct because it doesn't seem to support if, else, etc.

This is not a scripting problem, it is a structure problem. I think my script is right, and if it is not, I'll be glad to fix it, but I can't even try it because the structure I imagined doesn't fit!

So : Is there another way in AGS to call a complex script snippet (with conditions, variables, etc) into a function ?  ???
And if not : could you think of a better structure ?  ???

I can show you the code if you're curious, but it's quite long.

Pierrec

Oh wait...I'm stupid.
I just had to move the IA snippets BEFORE the function in which I want to call it.
Sorry for that.
Now my IA is working well...very well...in fact I can't even manage to beat it  :P


SMF spam blocked by CleanTalk