Please Help Me Advance My AI's Code

[U]**[COLOR=Red][SIZE=7][SIZE=5]This Is For A Bleach Game I’m Making

[/SIZE][/SIZE][/COLOR][/U][COLOR=Red][SIZE=7][SIZE=5][SIZE=4]That will be like[/SIZE][/SIZE][/SIZE][/COLOR][COLOR=Red][SIZE=7][SIZE=5][SIZE=4][COLOR=Blue]Streetfighter[/COLOR][/SIZE][/SIZE][/SIZE][/COLOR][COLOR=Red][SIZE=7][SIZE=5][SIZE=4]meets[/SIZE][/SIZE][/SIZE][/COLOR][COLOR=Red][SIZE=7][SIZE=5][SIZE=4][COLOR=Blue]Sinjid Shadow of the[/COLOR][/SIZE][/SIZE][/SIZE][/COLOR]*[COLOR=Red][SIZE=7][SIZE=5][SIZE=4][COLOR=Blue]Warrior[/COLOR][/SIZE][/SIZE][/SIZE][/COLOR][U][COLOR=Red][SIZE=7][SIZE=5][SIZE=4]or[/SIZE][/SIZE][/SIZE][/COLOR][/U][COLOR=Red][SIZE=7][SIZE=5][SIZE=4][COLOR=Blue]Sonny[/COLOR][/SIZE][/SIZE][/SIZE][/COLOR][SIZE=3][COLOR=Red] that zombie[/COLOR][/SIZE]*[COLOR=Red][SIZE=7][SIZE=5][SIZE=4] [SIZE=3]game[/SIZE]

[COLOR=Black]
please look the games up on google if u dont know them yet.[/COLOR][/SIZE][/SIZE][/SIZE][/COLOR][U][COLOR=Red][SIZE=7][SIZE=5]
[/SIZE][/SIZE][/COLOR]**[/U]

so far my ai does this

http://spamtheweb.com/ul/upload/100508/1 2994_ikkakuwitharray1.php

i want to make it do one of these, preferably the second one but the first is easier to help me do

the second one is a much better ai though

im using coding on just one frame and it attaches the hero movie clip and the enemy movieclip

and the enemy respawns if its killed

but i cant get my enemy to do anything besides come to me and when its 70 away from me it stops… within reach of my weapon but its still doing the flying animation

until its hit
when its hit itll go to a random animation and im fixing the code now so that if he goes to “block” animation he wont
lose hp

[SIZE=7]1[/SIZE].

"i want to make him attack me when he is close enough to me and if he hits me
how to make it go to a second attack but only have a small chance of going to that

but if ikkaku block= true and the monsters attack hits me he would go to the animation movie clip named attackblocked

also this isnt as important for now but id like him to have a timer so it only attacks every so often"

[SIZE=7]2[/SIZE].

"i want to have him be like a streetfighter ai
but i dont like that whole ai random thing i have
i want my monster to be a fighting monster that can block me sometimes, hit me, fall when hit by full combo and get away from me at certain hp levels and come back with an attack

until its dead "

[COLOR=Blue]COULD YALL VIEW MY LINK AND THEN SEE WHAT COULD BE DONETO THAT AI TO BETTER IT[/COLOR]

http://spamtheweb.com/ul/upload/100508/1 2994_ikkakuwitharray1.php

anyone please even tiny advice will do

[URL=“http://spamtheweb.com/ul/upload/100508/1%202994_ikkakuwitharray1.php”]
[COLOR=Black] [/COLOR]

"i want to make him attack me when he is close enough to me and if he hits me
how to make it go to a second attack but only have a small chance of going to that

but if ikkaku block= true and the monsters attack hits me he would go to the animation movie clip named attackblocked

also this isnt as important for now but id like him to have a timer so it only attacks every so often"

Sounds to me like you have the right idea on how to think of these things, you just have to execute them.

First of all, if you want him to attackhe is close to you then you need to constantly check the distance between him and your character, if that distance is below the predetermined length then let him attack. Like this:

if (distance < 70){
enemy.attack();}

If you dont know how find the distance between 2 points then do a quick google search.

As far as the small chance to attack twice then you would use the Math.random() method. Like this:

if (Math.random() < .3){
attack again}

Math.random() returns a value between 0 and 1, so in that example there is a 30% chance that the enemy will attack again.

okay let me go try to add this

i wanna make it also when hp is 75 have a 50% chance of running away 100 and facing me then shooting a bullet.
and at 50 i want it to have a 75% chance of doing that

and then coming back to the reached distance of attacking range

i hey that dont work properly lol

he just attacks nonstop

and i cant find a proper distance formula either

well for distance you can just use the X value if this isn’t a platformer game. So like if(Math.abs(object1.x - object2.x) < range). If it is a platformer use the pythagorean theorem. if((object1.x - object2.x) * (object1.x - object2.x) + (object1.y - object2.y) * (object1.y - object2.y) < range * range)