Follow Action Type 4.5

mkjake63

Member
Was playing around with some of the Ai_Scripts and was curious if anyone else has tested the Follow Action type in the current build? I was hoping to use it for a small game but as you can see in the video it's not really working. Was curious if there was something I could edit in the script itself to get it functioning


[media]https://youtu.be/J9Bvcwcxl_A[/media]

Look's like it's only aiming towards me but not actually following

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
 

Jonny

Well-known member
Curious about this too. How did you set the action up for the monster? As a loop?
 

mkjake63

Member
Yeah I set it up as a loop, when I set it up like the tutorials and had it stop randomly it kinda worked but obviously not what I was looking for
 

mouse spirit

Well-known member
Not sure but im guessing you want it to constantly follow you.And it looks like after you hit the enemy it starts to go to you.Does your script return a "monster to step 00" when hit? Whatever it does,looks like it is working for like a split second or quickly.So try looping step 00 and making that action state Timer 01.
Whatever the case, that "move towards" part of the code should probly run all the time.Ya know? Like it would need to say ,wheres the player , every second or so_Or maybe the whole code.So yes, quickly loop when it says follow the player.
 

Yan

Member
It might not be the best way to do it but I think it will work if you make two action steps that alternate between each other both using that same script.
 

mkjake63

Member
Hey that actually worked out pretty well! Instead of having the timer on zero I put it to 6 so the animation could still play and he follows me pretty consistently. My new issue now is how I'd get him to face different directions because he's only facing down
 

mouse spirit

Well-known member
Awesome. Yeah 0 on that specific timer means random amount i think. 1 is fast, 15 is slow.

When should they change facing? Compared to where you stand or compared to where they are heading?
And have you placed proper animations in the right spots when creating the monster? or are you saying that with this follow feature specifically that the monster does not change facing?
 

mkjake63

Member
I would prefer just to where they're heading and I got all the animations set up and everything. It works when I use move random but not with follow and I think that has to do with the scipt itself not telling it to change direction.

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

I tried copying the changefacingdirection line and the facing table into the follow code but no luck. I think there's more that I need to move over but I'm not really sure
 

mkjake63

Member
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
 

mouse spirit

Well-known member
Ok so i cant say exacyly. But yeah in that code there it looks to be feeding coodinates to the enemy. I know this is vague but we want to say " if movin left, look left. If movin right, look right, and so on. Probly obvious to ya, maybe it will further be explained . Was this from a video or a text tutorial.i would like to be linked to it. As maybe then i can help further.
 

mkjake63

Member
No tutorial sadly, just experimenting with the script that came with the 4.5 Update. Hoping it will pop up in a tutorial or you or someone on here figures it out. I still got a bit to go with learning asm so I'll just work with what I got until something pops up.
 

Bucket Mouse

Active member
mkjake63 said:
I tried copying the changefacingdirection line and the facing table into the follow code but no luck. I think there's more that I need to move over but I'm not really sure

Well, it's not enough to just do that...you need to fill those variables with the right info. This is what the variables in ChangeFacingDirection do...

MACRO ChangeFacingDirection arg0, arg1
;arg0 = object
;arg1 = what should be the new facing direction?

Argument 1 should be your monster. Argument 2 should be what direction the player sprite is currently facing.

As far as I can tell, the monster is loaded into tempx at this point. The player is loaded into tempA. So...

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
	ChangeFacingDirection tempx, tempA
	LDA Object_direction,x
	AND #%00000111
	ORA #%00001000
	STA Object_direction,x
	
	PLA
	TAX
	PLA
	TAY

This seems to work for me. Try it.
 

mkjake63

Member
Well it changes directions it just doesn't really face the right way and changes the way it faces after the follow timer is up. My guess is that it's just the way I have it set up for the monster to consistently follow the character.

[media]https://youtu.be/gPLWeGh6IIk[/media]

Currently the way I set it up is that Action step 0 is set to follow with a timer of 8 then it advances to action step 1 which stops the monster with a timer of 1. Originally it was also set to follow with a timer of 8 but it made it bug out even more. I did try it with having Action Step 0 loop and it kind worked but again he would just keep moving forward in the direction i spawned at
 

Bucket Mouse

Active member
I did it like this:

set to follow with a modified code (timer of 1)
Set to stop (timer of 1)
set to follow with a modified code (timer of 1)
Set to stop (timer of 1)

This way, it corrects itself every second. No, I have no idea why you have to do it twice, but if you don't do it twice it doesn't work. What can I say, this thing is broken.
 

mkjake63

Member
Tried it but still no luck sadly. Not sure what the issue is on my end. He just keeps changing directions randomly and when it does stay a direction it's usually not the one i want it to be as seen in the video
 
Top Bottom