(4.5.6) MoveToPlayer Monster Movement Speed

Craigery

Member
The Monster Object AI script MoveTowardsPlayer uses a different speed than the one assigned under Object Details. I want to speed up the movement, because currently its too slow for my game.

As I understand it, having a Monster move toward the player involves 3 Scripts:
MoveTowardsPlayer.asm is the AI script
MoveTowardsPoint.asm is the macro from line 22 of the previous ASM
doMoveTowardsPoint.asm is the macro from line 22 of the previous ASM (coincidence??)

In doMoveTowardsPoint.asm you get tempA and tempB
TAY
LDA AngleToHVelLo,y
sec
sbc #$80
STA tempA
LDA AngleToVVelLo,y
CLC
ADC #$80
STA tempB

which are used in MoveTowardsPoint.asm as:
LDA tempA
STA Object_h_speed_lo,x
LDA #$00
STA Object_h_speed_hi,x
LDA tempB
STA Object_v_speed_lo,x

So its storing the H and V angle as the objects speed? If I increase either Object H or V speed variable it moves faster, but towards a different point. What is another way around this? I suppose I could offset the position it looks for to move to, but I wonder if someone else has a fix for this, so I can change the speed without changing the trajectory?
 
Last edited:

dale_coop

Moderator
Staff member
If you followed the shooter tutorial, you will see that the monster shoots projectile at player, and the projectile speed can be set. And it works.
In fact, in that module, it uses another settings for that "shoot at player" thing.

The Monster Object action is set to "Shoot At Player". Here the corresponding ShootAtPlayer.asm script (also check my comment in the script):
Code:
   LDA Object_x_hi,x
   ;; plus x offset
   STA tempA
   LDA Object_y_hi,x
   ;; plus y offset
   STA tempB
   LDA #$02 ;; <-- dale_coop: HERE !!! your projectile object to create
   STA tempC
   LDA #$00 ;; action step for that object
   STA tempD
   LDA Object_screen,x
   STA tempz
 
   CreateObjectOnScreen tempA, tempB, tempC, tempD, tempz

And the Projectile object itself has an Action Step 0 set to "Move Toward Player":


This way, the speed and acceleration of the projectile object is not ignored.
 

9Panzer

Active member
Did this work for you @Craigery ? I've been pulling my hair out for weeks and nothing I do seems to get it right. I did have a hailstorm of bullets once... but that wasn't what I was after lol.
 

Craigery

Member
Did this work for you @Craigery ? I've been pulling my hair out for weeks and nothing I do seems to get it right. I did have a hailstorm of bullets once... but that wasn't what I was after lol.
Not specifically, no. Somewhere, some seemingly unrelated code was messing it up unintentionally. I ended up restarting it as a new project in a fresh download of NESMaker and reimplementing doing all my custom ASM one piece at a time and it worked that time around. So no clue what I had done wrong. Sorry that's not helpful.
 
Top Bottom