Omnimaga
Calculator Community => TI Calculators => Axe => Topic started by: aeTIos on April 19, 2011, 03:43:52 pm
-
Can anyone explain how to create an Action-RPG AI?
Including enemy moving, attacking, etc.
Also, checking your own attacks would be nice to be explained too.
Thanks a lot in advance!
--aeTIos
-
*bump* Is there no one who knows anything about this subject?
-
Well, you've left the question awfully general. What kind of AI do you need? What's the game like? How complex do behaviors have to be?
Generally speaking, moving towards a player is accomplished by a simple "if playerx > enemyx then enemyx + 1 -> enemyx", with matching conditions for the opposite direction and for the Y vars. Naturally, before actually updating the position, you'd have to check whether it's possible for the enemy to go there, but without info on your code I can't really go into that.
Attacks can be triggered via the distance formula, SQRT( (playerx - enemyx) ^2 + (playery - enemyy) ^ 2 ): compare that to a fixed number and have an attack routine fire at that point.
Sorry if this was waaaay more basic than you were looking for. Good luck!
-
If it's just for enemies moving around, what I did in Zelda Dark link quest is something like this:
While 1
<other code goes here>
0->F
If F=0:Then
1->F:Move enemy in your direction
Else
0->F:Move enemy in a random direction
End
End
That ensures the enemy won't move towards you too fast, but will still somewhat tries to touch you.
For bosses, if for example hitting the boss causes him to act differently, I just change a variable when hitting him and the code launched every loop depends of the variable value.
-
If it's just for enemies moving around, what I did in Zelda Dark link quest is something like this:
While 1
<other code goes here>
0->F
If F=0:Then
1->F:Move enemy in your direction
Else
0->F:Move enemy in a random direction
End
End
That ensures the enemy won't move towards you too fast, but will still somewhat tries to touch you.
For bosses, if for example hitting the boss causes him to act differently, I just change a variable when hitting him and the code launched every loop depends of the variable value.
Though if you're using coordinates multiplied by 16 / 32 / 64 or whatever, this obviously isn't necessary.