Bucket Mouse
Active member
There exists, in the Adventure Module, a "Move Towards Player" AI that causes monster sprites to move toward your own sprite when you enter a room. However, this script contains no information for the monster to change its facing direction, so unless you designed your monster to make sense from all angles, it'll often be looking in the other direction while chasing you.
Until now, no one knew what to do about that. I asked Joe for hints on how to solve this, and he gave me a few...but the actual solution turned out to be sort of different from what he proposed. Anyway, this works, and if you replace the current Move Towards Player AI script with this one, the monsters will always stare you down as they chase you, as they should.
Until now, no one knew what to do about that. I asked Joe for hints on how to solve this, and he gave me a few...but the actual solution turned out to be sort of different from what he proposed. Anyway, this works, and if you replace the current Move Towards Player AI script with this one, the monsters will always stare you down as they chase you, as they should.
Code:
;;; aim towards player.
TYA
PHA
TXA
PHA
STA tempx
LDA Object_x_hi,x
STA tempA
LDA Object_y_hi,x
STA tempB
LDX player1_object
LDA Object_x_hi,x
STA tempC
LDA Object_y_hi,x
STA tempD
LDX tempx
MoveTowardsPoint tempA, tempC, tempB, tempD
LDA Object_direction,x
AND #%00000111
ORA #%00001000
STA Object_direction,x
LDA tempA ; horizontal
CMP tempB ; vertical
BCS verticalCompare
horizontalCompare:
LDA tempA
BPL movingRight
movingLeft:
LDA #6
STA tempy
JMP +
movingRight:
LDA #2
STA tempy
JMP +
verticalCompare:
LDA tempB
BMI movingUp
movingDown:
LDA #4
STA tempy
JMP +
movingUp:
LDA #0
STA tempy
JMP +
+
TXA
STA tempA
TAX
ChangeFacingDirection tempA, tempy
PLA
TAX
PLA
TAY