NewageMugen

A Mugen community that specializes in stage, screenpack creation, and graphics.

You are not connected. Please login or register

AI Programming Tutorial by Flowagirl

Go down  Message [Page 1 of 1]

1 AI Programming Tutorial by Flowagirl on Sun Feb 23, 2014 4:07 pm

Demitri

avatar


Spoiler:
Copy-pasted because im a lazy fucker.
========================
AI Programming Tutorial
========================
Author: FlowaGirl
flowergirl@cutey.com
http://blargh.i-xcell.com

---------------------------------------------------------------------------
Programming a character's custom AI is something extra; It's not needed in any
character, but most people seem to want to do it anyway, whether it is to kick
another character's arse, increase the gameplay of the character, or just for
watch mode.
---------------------------------------------------------------------------

When programming an AI, it is recommended that you have completed most of
the character. It will makes things easier, so you won't have to go back and change
anything in the script if you decide to add in more stuff.

Think about the moves for your character; How you want it to use a projectile,
when to guard, and when to attempt to throw the opponent? It's up to you. A well
planned AI is important, as poorly made AI's can end up extremely glitchy.

This example shows how your character will attempt to throw the opponent, only
when it is close to the opponent, and when the opponent is on the floor. I choose
to do the AI programming under StateDef -3, but this can be done under StateDef -2, or
even StateDef -1 of the CMD file.

[State -3: ChangeState]
type = ChangeState
trigger1 = (Var(0) > 0)
trigger1 = (Random <= 499)
trigger1 = (StateType != A) && (Ctrl)
trigger1 = (P2BodyDist X <= 40) && (P2StateType = S)
value = ****

The 1st trigger, "(Var(0) > 0)" means that the move can only be read by the AI.
Remember, the AI Activation sets the value of Var(0) to 1.

2nd trigger, "(Random <= 499)" means that the AI will make an attempt to throw the
opponent, but only half the time. This should be used, so your character
is not too predictable.

3rd trigger, is simply used, so that the character can only make the throw attempt
when he is on the ground, (StateType != A) and is able to do so. (Ctrl)

Finally, the 4th trigger, "(P2BodyDist X <= 40) && (P2StateType = S)" means that
the character will throw the opponent, only when the opponent is close, (P2BodyDist X <= 40)
and when the opponent is on the ground as well. (P2StateType = S)

Given this idea as how it is done, you can come up with your own character AI's.


________________________________________________________________________________________________________________________________________________________________________

2 Re: AI Programming Tutorial by Flowagirl on Sun Feb 23, 2014 5:25 pm

Demitri

avatar


===============================
AI Activation: Pallette method
===============================
Author: FlowaGirl
flowergirl@cutey.com
http://blargh.i-xcell.com

---------------------------------------------------------------------------
Until Elecbyte decides to add in a trigger that detects
whether the character is controlled by a player or by the
CPU, this code will be used as a workaround.

After implementing this little piece, you are free to program
your character's AI, providing that you know how it's done. ;)
---------------------------------------------------------------------------

There's not much needed to put to achieve the effect. All you
have to remember is that you, the player must -never- use pallettes
7-12; They are reserved for the AI.

Add this piece under StateDef -2.

[State -2: VarSet]
type = VarSet
trigger1 = (Var(0) != 0) && (PalNo = [7,12])
var(0) = 1

These next few states are used to turn the AI on and off at the
appropriate times. We wouldn't want the character to battle during
his winpose. ;)

[State -2: VarSet]
type = VarSet
trigger1 = (Var(0) = 1)
var(0) = 2

[State -2: VarSet]
type = VarSet
trigger1 = (Var(0) != 0) && (RoundState != 2)
var(0) = 0

[State -2: ChangeState]
type = ChangeState
trigger1 = (RoundState = 3) && (StateType != A) && (Ctrl)
value = 0

The advantage to this method is that you can choose different levels
of AI for watch mode. When selecting the character, you hold the start
button, and simply choose a pallette. However, you must create a
different level of AI for every one of the pallettes, 7 to 12.

[State -2: VarSet]
type = VarSet
trigger1 = (Var(0) != 0) && (PalNo = [7,12])
var(0) = (PalNo - 6)

When programming your AI's they can be organized in this way:

Var(0) = 1: Level 1, Pal 7
Var(0) = 2: Level 2, Pal 8
Var(0) = 3: Level 3, Pal 9

etc...


________________________________________________________________________________________________________________________________________________________________________

Back to top  Message [Page 1 of 1]

Permissions in this forum:
You cannot reply to topics in this forum