Monsters Still Resetting to Action 0 When Hit...?

User avatar
crazygrouptrio
Posts: 63
Joined: Fri Jan 11, 2019 2:22 pm
Location: United States
Contact:

Monsters Still Resetting to Action 0 When Hit...?

Post by crazygrouptrio » Sun Oct 06, 2019 12:51 am

So I've been fighting with this issue for awhile. I'm trying to get monsters (mostly bosses) to not reset to action state 0 when they get hit. I'm trying to get this to work in both a platformer and an adventure game, but we'll focus on the 2 player adventure core for now... This is more of general problem I feel so I'm just going to ask for any guidance before I break something valuable in frustration :lol: (also yes I've commented out the ChangeObjectState #$00 line in all related instances, such as HandleUpdateObjects and MonsterHurt)

First I tried to use this: [url]http://nesmakers.com/viewtopic.php?f=40&t=3387[/url]
After messing with the code for awhile to get it to actually not crash, for some reason it ignored all bounding boxes for everything. I don't know why, but all monsters/players bounding box was only the bottom right pixel of their sprite, which obviously messed up pretty much everything. I never intentionally messed with that part of the script, and removing the above scripts put everything back to normal. So... :?

Second I messed with this: [url]http://nesmakers.com/viewtopic.php?f=40&t=2298&sid=1ee16fd48aed4f1f603054eaacd97711[/url]
This is what I'm working with now, which still doesn't seem to work. When monsters get hit they fly off in the opposite direction until their Action 0 is forced to kick in again. This happens even if I disable recoil completely. I was able to make a boss switch to a specific action state when hit but when I put the same code in the "normal monsters" area it never activates. Plus they still fly off in the opposite direction when they're hit so... there's that.

This is how that script looks as of now:

Code: Select all

HandleObjectTimers:
;; Updated version by Chronicler Of Legends 3_3_19
;;; handle object timers, tool
	LDA Object_timer_0,x
	BEQ ++
	DEC Object_timer_0,x
	LDA Object_timer_0,x
	BNE ++ ;; timer is still going.
	;;;;; object timer 0 has cycled and is finished.
	;;;;; right now, we'll use this to flip hurt/invincible to just invincible, to normal.
	JMP continueTimer
	++
	JMP ObjectTimer0Finished
	
	continueTimer:
	
	LDA Object_status,x
	AND #%00000001 ;; is it hurt and invincible?
	BEQ notHurtAndInvincible
	;; hurt and invincible
	LDA Object_status,x
	AND #%11111110
	ORA #%00000010
	STA Object_status,x
    
    ;; Is this a player, boss, or other object?
    LDA Object_type,x
    CMP player1_object
    BNE +
	LDA Object_type,x
	CMP player2_object
	BNE +
    ;; Changed this to custom invincibility timer.
    LDA #PLR_INVINC_TIM ;; my custom invincibility timer constant
	STA Object_timer_0,x
    JMP handleObjectTimer_afterSetInvincibility   
    
+:  ;; Not player object
    ;; Is it a boss?
    LDA Object_flags,x
	AND #%01000000 ;; is it a Boss  ;; CUSTOM ID SET IN USER CONSTANTS, you can change this to however you want to flag an enemy as a 'boss'
    BNE +
    LDA #INVINCIBILITY_TIMER ;; Same as a normal enemy
	STA Object_timer_0,x
    JMP handleObjectTimer_afterSetInvincibility
    
 ;
 +: ;; Add other things that you want to have custom invulnerablity timers here.
 ; LDA Object_type,x ; this can be any type of comparison that flags the object
 ; CMP #SOME_ID_HERE
 ; BNE +
 ; LDA #CUSTOM_TIMER
 ; STA Object_timer_0,x
 ; JMP handleObjectTimer_afterSetInvincibility


+:
    ;; Normal object

	LDA #INVINCIBILITY_TIMER
	STA Object_timer_0,x
	
    
handleObjectTimer_afterSetInvincibility:
    ;; Is it a boss?
   LDA Object_flags,x
	AND #%01000000 ;; is it a Boss
    BNE +
    JMP ObjectTimer0Finished ;; Skip resetting the movement
+:
	LDA Object_movement,x
	AND #%00001111
	STA Object_movement,x
	LDA #$00
	STA Object_h_speed_hi,x
	STA Object_h_speed_lo,x
	STA Object_v_speed_hi,x
	STA Object_v_speed_lo,x
	
	
	
	
	JMP ObjectTimer0Finished
notHurtAndInvincible:
	LDA Object_status,x
	AND #%00000010
	BEQ ObjectTimer0Finished ;; no longer invincible...not sure what this timer would be doing at this point.
	;;; it IS still invincible, need to change it back to normal.
	LDA Object_status,x
	AND #%11111100
	STA Object_status,x
	;;; activate state 0
	;ChangeObjectState #$00,#$02
    
    ;; Is it a boss?
    LDA Object_flags,x
	AND #%01000000 ;; is it a Boss
    BNE +
    JMP ObjectTimer0Finished ;; Don't reset the action for bosses.
+:
	JSR DoNewAction
	
ObjectTimer0Finished:
	RTS

I had to change the above script some so the game would not crash and to add the 2nd player, but any other code involving this issue was not really changed from the default script provided or that comes with Dale's 2 Player core. Any help would be vastly appreciated!
User avatar
chronicleroflegends
Posts: 190
Joined: Thu Sep 06, 2018 3:51 am

Re: Monsters Still Resetting to Action 0 When Hit...?

Post by chronicleroflegends » Sun Oct 06, 2019 2:36 am

Not sure if this will help the overall problem but this part here:

Code: Select all

;; Is this a player, boss, or other object?
    LDA Object_type,x
    CMP player1_object
    BNE +
	LDA Object_type,x
	CMP player2_object
	BNE +
    ;; Changed this to custom invincibility timer.
    LDA #PLR_INVINC_TIM ;; my custom invincibility timer constant
	STA Object_timer_0,x
    JMP handleObjectTimer_afterSetInvincibility   
    
+:  ;; Not player object
The way you have it set up it checks if it is the player 1 object. If it is not it jumps to the not player object section.
If it IS the player 1 object then it compares the object to the player 2 object. This will always be false, because it has already established that it is the player 1 object.
So no matter what you are going into the ;;Not player object code. The custom invincibility timer is never being set and it isn't making that jump.

Try this instead:

Code: Select all

;; Is this a player, boss, or other object?
    LDA Object_type,x ;; Check if it is player 1
    CMP player1_object
    BEQ ++
    LDA Object_type,x ;; Check if it is player 2
    CMP player2_object
    BEQ ++
    JMP + ;; neither was true so jump to not player code
    ++:
    ;; Changed this to custom invincibility timer.
    LDA #PLR_INVINC_TIM ;; my custom invincibility timer constant
	STA Object_timer_0,x
    JMP handleObjectTimer_afterSetInvincibility   
    
+:  ;; Not player object
~Do you believe in legends? ~
My Games: Nix: The Paradox Relic
User avatar
crazygrouptrio
Posts: 63
Joined: Fri Jan 11, 2019 2:22 pm
Location: United States
Contact:

Re: Monsters Still Resetting to Action 0 When Hit...?

Post by crazygrouptrio » Sun Oct 06, 2019 1:25 pm

Thank you that was definitely a necessary change. Unfortunately the problem remains the same :|
User avatar
dale_coop
Posts: 4236
Joined: Fri Feb 16, 2018 7:05 am
Location: France

Re: Monsters Still Resetting to Action 0 When Hit...?

Post by dale_coop » Sun Oct 06, 2019 7:11 pm

Strange... I think that just commenting out the line :

Code: Select all

; ChangeObjectState #$00,#$02
Would have been enough.
(Also you'll need to do the same in the Handle Monster Hurt script).
-----
Sorry about my poor english
All I need: A Damn Fine Cup of Coffee
My games: PRESS START GAME / UNDERGROUND ADVENTURE / UNDERGROUND ADVENTURE (Arcade version - Byte-Off-2019)
User avatar
crazygrouptrio
Posts: 63
Joined: Fri Jan 11, 2019 2:22 pm
Location: United States
Contact:

Re: Monsters Still Resetting to Action 0 When Hit...?

Post by crazygrouptrio » Sun Oct 06, 2019 11:54 pm

dale_coop wrote:
Sun Oct 06, 2019 7:11 pm
Strange... I think that just commenting out the line :

Code: Select all

; ChangeObjectState #$00,#$02
Would have been enough.
(Also you'll need to do the same in the Handle Monster Hurt script).
Yep I've commented out that line in this script, handle monster hurt and player hurt. Here's a gif of exactly what's happening.
Image
This happens when no other action is cued by the monster or player. The monster just has action 0 on loop where he moves up and down only. I can specifically make the monster/player switch to a specific action state when hit, but even if its set to "stop movement" the monster will move away for a few seconds before the action kicks in.
User avatar
dale_coop
Posts: 4236
Joined: Fri Feb 16, 2018 7:05 am
Location: France

Re: Monsters Still Resetting to Action 0 When Hit...?

Post by dale_coop » Mon Oct 07, 2019 8:08 am

Sorry, about the weirdness... It could be somewhere in my code.
Looks like the x register is corrupted womwhere duing that collision... and weird things are happening, here.
It could be anywhere in the engine... if made any small modification (a small mistake in a branch, on a load,...)...

Could you send me your nesmaker folder (or at least your project .MST file and "GraphicAssets" + "GameEngineData" folders)?
I'll check where is the error...
-----
Sorry about my poor english
All I need: A Damn Fine Cup of Coffee
My games: PRESS START GAME / UNDERGROUND ADVENTURE / UNDERGROUND ADVENTURE (Arcade version - Byte-Off-2019)
User avatar
crazygrouptrio
Posts: 63
Joined: Fri Jan 11, 2019 2:22 pm
Location: United States
Contact:

Re: Monsters Still Resetting to Action 0 When Hit...?

Post by crazygrouptrio » Mon Oct 07, 2019 3:32 pm

No problem I sent my nesmaker folder to you.
Also to be clear this happens when hit from any direction. If the player or monster is hit from the bottom they will move that way going up, etc. I've also experienced this exact problem in the Simple Platformer Module so it probably isn't specifically your code.
User avatar
dale_coop
Posts: 4236
Joined: Fri Feb 16, 2018 7:05 am
Location: France

Re: Monsters Still Resetting to Action 0 When Hit...?

Post by dale_coop » Mon Oct 07, 2019 3:39 pm

Thanks, I'll check that tonight and tell you what's going on ;)
-----
Sorry about my poor english
All I need: A Damn Fine Cup of Coffee
My games: PRESS START GAME / UNDERGROUND ADVENTURE / UNDERGROUND ADVENTURE (Arcade version - Byte-Off-2019)
User avatar
dale_coop
Posts: 4236
Joined: Fri Feb 16, 2018 7:05 am
Location: France

Re: Monsters Still Resetting to Action 0 When Hit...?

Post by dale_coop » Mon Oct 07, 2019 6:13 pm

I checked your project... and it's your HandleUpdateObjects.asm that is messing completely the engine.
The code you wrote is not correct and, I think, way too complex for the purpose.

Could you explained, what you want to achieve exactly?

Just to not reset the Action Step 0 when it's a "boss" monster? That it? And for all other objects, you want the normal behavior?
-----
Sorry about my poor english
All I need: A Damn Fine Cup of Coffee
My games: PRESS START GAME / UNDERGROUND ADVENTURE / UNDERGROUND ADVENTURE (Arcade version - Byte-Off-2019)
User avatar
crazygrouptrio
Posts: 63
Joined: Fri Jan 11, 2019 2:22 pm
Location: United States
Contact:

Re: Monsters Still Resetting to Action 0 When Hit...?

Post by crazygrouptrio » Mon Oct 07, 2019 7:30 pm

Yes more or less. I want all monsters to not change action when hit and I want bosses to change to a specific action when hit.
I know that script does more than I needed but it was the closest I could find here to what I needed :?
... Though now that I think about it I probably could have left most of it alone and just removed "changeobjectstate" for regular monsters and added a check for bosses to do something different huh? :oops:
Post Reply