Making the monsters move in specific directions (4.5)

Bucket Mouse

Active member
I just spend a maddening night trying to hash out the code to make monster characters move in a specific direction. It's completely different in 4.5 and the code as it is offers no clues, since all the movement scripts are for random numbers, and the script that moves YOU doesn't work for monsters.

The closest I could get was to modify the tempB variable in MoveRandom_8Dr.asm. That's the script that looks like this:

Code:
;;;; Choose out of 4 directions, UDLR.
	TXA	
	STA tempA
	JSR doGetRandomNumber
	AND #%00000111
	TAY
	LDA DirectionTable,y
	STA tempB
	LDA FacingTable,y
	STA tempC
	StartMoving tempA, tempB, #$00
	ChangeFacingDirection tempA, tempC

On StartMoving, I replaced the tempB variable with a number in binary. This took an entire night of trying random ones and zeroes just to see which ones would finally work. Yup, I'm that crazy when I really want something.
And these are my results:

#%11000000 -- right
#%10000000 -- left
#%01100000 -- up
#%01110000 -- down

And here's what I REALLY don't understand. You'd think I would have enough now, but the script doesn't work without EVERYTHING that's in it including the part that gets a random number, which we're not using.

And I have NO idea how to change the direction of the monster, which is what will be needed to truly complete this. Like I said earlier, the word variables used to control the player sprite (#LEFT, #FACE_LEFT) do not work with monsters. And the math here leaves the true answer completely obtuse, unless I want to spend another three hours randomly entering binaries. And I have had my fill of that.

Anybody have any insight here?
 

dale_coop

Moderator
Staff member
I think it works almost like the previous core...

Move Up:
Code:
	TXA	
	STA tempA

	StartMoving tempA, #UP, #$00
	ChangeFacingDirection tempA, #FACE_UP


Move Right:
Code:
	TXA	
	STA tempA

	StartMoving tempA, #RIGHT, #$00
	ChangeFacingDirection tempA, #FACE_RIGHT


More Up Left:
Code:
	TXA	
	STA tempA

	StartMoving tempA, #UPLEFT, #$00
	ChangeFacingDirection tempA, #FACE_UPLEFT


ETC...
 

Bucket Mouse

Active member
......You know, I almost got that. And I'm not just claiming it to save face...I tried something very similar to that script and it didn't work, leading me down the wrong path all evening. Maybe I had the names wrong or something, because it worked this time.

Thanks again!
 
Top Bottom