[RESOLVED] [4.5.9] MoveTowardsPlayer_AdventureBase

Kanbei85

Member
The AI behavior script : MoveTowardsPlayer_AdventureBase has some major problems.

1) It contains no code to change the monster's facing direction, so it causes the monster to appear to float instead of actually walking under its own power

2) It seems to override or interfere with the recoil mechanic somehow, so it seems to be negating the monster's Health entirely and the monster always dies in one hit.

3) For some reason, it also doesn't play nicely with the StopMoving script, so once the monster starts moving toward the player, it never stops regardless of action step commands.

I cannot fix this, I don't know assembly! This is pretty important, since monsters should be able to actually be aggressive to the player.

Here's the 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

PLA
TAX
PLA
TAY
 
Last edited:

Bucket Mouse

Active member
I fixed it months ago; here you go:

I don't remember the original having recoil or Action Step issues, though. You sure that's not the result of something else you did?
 

Kanbei85

Member
I fixed it months ago; here you go:

I don't remember the original having recoil or Action Step issues, though. You sure that's not the result of something else you did?

I just implemented your fix. Now the monster does change facing direction, so that's an improvement. The other problems remain, however. As far as I know, I'm not doing anything to cause them. If I switch from your script to a "Move Random_Maze Base" script, for example, suddenly everything works as it should. But somehow this "move toward player" script, even your fixed version, causes the monster to ignore recoil and stop action commands.
 

Kanbei85

Member
Bucketmouse, I think the problem is that the move towards player script you have now is utilizing a subroutine MoveTowardsPoint, which is continuous and thus doesn't allow for a break in the code to receive new or updated commands, such as stop moving, or recoil.

My theory is that somehow the oStartMovingInADirection subroutine needs to be either used, or at least copied in some way. The calculations from MoveTowardsPoint need to be translated into a "direction" for use in the StartMovingInADirection sub.

My assembly coding knowledge isn't really great enough to figure this out right now, but in the meantime I might just use the movetowardsplayer action sparingly and in short bursts. That way the monster can make a little progress towards the player without staying in a non-recoil state for very long.

EDIT: Nope, I can't even do that compromise, because the MoveTowardsPlayer script destroys ALL action step changes from that point. So I really can't do anything with this script as-is. Once the monster sets in motion toward the player, nothing will stop it.
 
Last edited:

Bucket Mouse

Active member
This is the issue: it's not a problem for me. I've used this to make monsters move toward the player, and they have their recoil intact. I still don't know why it doesn't work for you.
 

Kanbei85

Member
Alright, tell me this: are you able, once you've put the monster in motion towards the player, to then get that monster to stop using an action step timer?

It may be helpful to know that I am also not able to get the "stop at proximity" script to work either. So somehow these moving towards player scripts are not allowing a stop command to go through after initiating?
 

Bucket Mouse

Active member
Alright, tell me this: are you able, once you've put the monster in motion towards the player, to then get that monster to stop using an action step timer?

It may be helpful to know that I am also not able to get the "stop at proximity" script to work either. So somehow these moving towards player scripts are not allowing a stop command to go through after initiating?
Yup, just tried it. The monsters stopped.
 

Kanbei85

Member
View attachment 5791

(shrug)

Maybe we're using two different StopMoving scripts? Mine looks like this:

Code:
;;; stop moving.
LDA Object_direction,x
AND #%11110111
STA Object_direction,x

LDA Object_direction,x
AND #%00001111
STA Object_direction,x


Guess what? You were right. ALL my StopMoving scripts were missing lines of code that you have there. But I have never made any changes to my StopMoving scripts to remove anything, so how do you have those extra lines of code?

This was my whole stopmoving script:
;;; stop moving.
LDA Object_direction,x
AND #%00001111
STA Object_direction,x

Adding the extra code did fix the problem.
 

Bucket Mouse

Active member
I think they're from an experiment, since StopMoving originally didn't work for me either. Loading Object_direction twice is redundant, but I'm not going to argue with what works.
 
Top Bottom