Monster Jumping AI

Nintend0Nerd

New member
It's kind of surprising that there's no ai script for making an enemy jump in the platform module. I've taken a look at the player jump script and seeing if that could be modified to making an enemy jump, but with my limited knowledge with asm, I didn't get too far. Does anyone know how the code could be modified to make an enemy jump? A plan b would be just to make the enemy move up and down, but, for some reason, my boss will just stand still when it comes time for him to move up and down.
 

jorotroid

Member
I am working on this for my game right now. Still have a lot to figure out, but I can give you something partially workable. One of the problems with adding in a jump script for the AI is that the platformer physics doesn't check to see if the monster is on the ground or not. Adding this check in creates some unexpected behaviors. This means that if you tell the monster to jump too often, it will do several jumps in the air because it doesn't know not to. But what you can do is have the monster go back and forth between action states to give it enough time to land back on the ground before jumping again. Here is the AI Jump Code:
Code:
	LDA #$00
	SEC
	SBC #$05  ;;<--This is the jump speed
	STA Object_v_speed_hi,x

If you want regular intervals, you can do it with just the jumping state as long as the timer is long enough to allow the monster to get back on the ground. If you want random intervals, again make the timer on the jump state long enough for the monster to hit the ground, then have it switch to a different state that will have a timer of 0 to give you the random timing.

Also make sure you don't have Ignore Gravity checked. That disables vertical movement.

If that doesn't work, then I might have done an extra step that I've forgotten about.
 
Top Bottom