Few Remaining Misc. Bugs!

Retrobuster

New member
Hey all,

I'm almost done with my game but am getting some persistent bugs I haven't been able to figure out how to fix so I'm hoping you guys can help. They're sort of all over the place so apologies for that but figured this'd be better than posting multiple threads ;)

1) My hurt sound effect isn't playing when I collide with a monster. I have tiles in my game that hurt me when I collide with those and those play the hurt sound effect perfectly so I'm pretty sure it's not the sound effect file itself.

2) When my player dies, the tens digit of my score in the HUD gets replaced with an opaque square no matter what my score is before I die.

3) Occasionally, seemingly at random, when warping to a new screen of any kind - level or cutscene - the player hurt sound effect will play immediately and there'll be no music playing. Sound effects still work and beating that level and starting a new level brings the music back. I can't seem to recreate this glitch on command so that's why it feels like it happens at random - not always the same screen and doesn't always happen.

Any help would be greatly appreciated!
 

dale_coop

Moderator
Staff member
1) check your Handle Player Hurt script... and the "PlaySound" missing line.

2) could share a screenshot?

3) weird...
 

Retrobuster

New member
Screenshot attached. Here's my player hurt script. The PlaySound line is there but maybe something else is off or missing. Don't think I made any modifications to this script though.

Code:
;;; assumes myHealth variable
;;; if a different variable should handle health
;;; change thename of myHealth.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; uses timers set in GameData\Constants:
;;OBJECT TIMERS
;HURT_TIMER = #$08
;INVINCIBILITY_TIMER = #$08
;RECOIL_SPEED_HI = #$06
;RECOIL_SPEED_LO = #$00

;;;; To change invincibility time, knock back speed, or hurt duration
;;;; updating the abovevalues in constants.

	LDA Object_health,x
	SEC
	SBC #$01 ;; subtract other's strength
	CMP #$01
	BCS notPlayerDeath
	
	PlaySound #SND_HURT_PLAYER
	JSR HandlePlayerDeath
	JMP doneWithPlayerHurt

notPlayerDeath:
	STA Object_health,x
	STA myHealth
	STA hudElementTilesToLoad
		LDA #$00
		STA hudElementTilesMax
		; LDA DrawHudBytes
		; ora #HUD_myHealth
		; STA DrawHudBytes
	UpdateHud HUD_myHealth
    ;; TURN ON handling the hud
	
	SubtractValue #$08, myScore, #$02, #$00
	;;; we also need to set up the routine to update the HUD
	;; for this to work right, health must be a "blank-then-draw" type element.
	;STA hudElementTilesToLoad
	;	LDA #$00
	;	STA hudElementTilesMax
		; LDA DrawHudBytes
		; ora #HUD_myScore
		; STA DrawHudBytes
	UpdateHud HUD_myScore
	
	LDA Object_status,x
	ORA #%00000001
	STA Object_status,x	

	LDA #HURT_TIMER
	STA Object_timer_0,x
	ChangeObjectState #$00,#$02 ;; uses idle for hurt state.
	
	LDA selfCenterX
	STA recoil_selfX
	LDA selfCenterY
	STA recoil_selfY
	LDA otherCenterX
	STA recoil_otherX
	LDA otherCenterY
	STA recoil_otherY
	
	JSR DetermineRecoilDirection


	;;;;; SCROLLER CAN NOT MAKE USE OF UPDATING HUD THIS WAY.


	
doneWithPlayerHurt:
 

Retrobuster

New member
Hmmmm...getting a weird error when trying to attach a screenshot - board attachment quota has been reached. It's an 87kb file :(
 

dale_coop

Moderator
Staff member
For your Playsound... currently, in this script, the line is just when no more health, so for the death, not for hurt.
Try adding the line ("PlaySound #SND_HURT_PLAYER") after the "JSR DetermineRecoilDirection" line.
 

dale_coop

Moderator
Staff member
For posting images, try using a online image sharing service (like postimg.cc or imgbb.com or ...)
 

dale_coop

Moderator
Staff member
Ok...
the square means a tile greater than your tile for the "9"... the logic is
myScore variable is divided in 4 different variables myScore (of the unit place), myScore+1 (for the tenth place), myScore+2 (for the hundreds place) and myScore+3 (for the thousands place)... etc.
So here your myScore+1 var is more than 9. So it loades the corresponding tile in your hud tileset.

A fix...
1/ Check your AddValue myscore in your script.. and check that it follows that post http://nesmakers.com/viewtopic.php?f=35&t=2061
2/ There is an strange behavior in the code with the HUD "element 3" variable... so I would suggest to move the myScore to another element.
To do that, in "Hud & boxes", in the "user variables" tab, select the 3rd element (currently named "myScore" and rename it to "UserVar_2". Then select an unused one (for example, "UserVar_6") and rename it as "myScore".
In the "HUD elements" tab, select the Element 3, set the max value to "0", the type to none. Then set your Element 7 (your new myScore).
 

Retrobuster

New member
The score works fine in every way except when I die, no matter what score I've got, that block shows up so not sure why it's trying to load a value higher than 9 only upon death but I'll give those suggestions a shot. Thanks Dale! Hope your trip was fun!
 

dale_coop

Moderator
Staff member
My trip was great... (2 weeks away from work is always great ;))

Yep, try the fix (about "element 3"), you should have good results.
 

Retrobuster

New member
OK that fixed the score issue in the HUD!

Also, the hurt sound effect is playing properly when a monster collides, however, now the death sound doesn't play when a monster kills me. It played correctly before this change so where the original PlaySound command was, I replaced that with the death sound effect but that doesn't work. And the death sound does play correctly when a hurt tile kills me so it must be another issue with the hurt script.
 

Retrobuster

New member
It’s the same as the one I posted earlier in this thread, just with PlaySound line at the bottom where you suggested and the original PlaySound line commented out. (I also tried leaving the original in uncommented and that didn’t work. Also tried changing the original to PlaySound SFX_SPLAT which didn’t work either)
 

dale_coop

Moderator
Staff member
As I wrote, just add a line for your hurt playsound.. something like that should work:

Code:
;;; assumes myHealth variable
;;; if a different variable should handle health
;;; change thename of myHealth.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; uses timers set in GameData\Constants:
;;OBJECT TIMERS
;HURT_TIMER = #$08
;INVINCIBILITY_TIMER = #$08
;RECOIL_SPEED_HI = #$06
;RECOIL_SPEED_LO = #$00

;;;; To change invincibility time, knock back speed, or hurt duration
;;;; updating the abovevalues in constants.

	LDA Object_health,x
	SEC
	SBC #$01 ;; subtract other's strength
	CMP #$01
	BCS notPlayerDeath
	
	PlaySound #SND_HURT_PLAYER
	JSR HandlePlayerDeath
	JMP doneWithPlayerHurt

notPlayerDeath:
	STA Object_health,x
	STA myHealth
	STA hudElementTilesToLoad
		LDA #$00
		STA hudElementTilesMax
		; LDA DrawHudBytes
		; ora #HUD_myHealth
		; STA DrawHudBytes
	UpdateHud HUD_myHealth
    ;; TURN ON handling the hud
	
	SubtractValue #$08, myScore, #$02, #$00
	;;; we also need to set up the routine to update the HUD
	;; for this to work right, health must be a "blank-then-draw" type element.
	;STA hudElementTilesToLoad
	;	LDA #$00
	;	STA hudElementTilesMax
		; LDA DrawHudBytes
		; ora #HUD_myScore
		; STA DrawHudBytes
	UpdateHud HUD_myScore
	
	LDA Object_status,x
	ORA #%00000001
	STA Object_status,x	

	LDA #HURT_TIMER
	STA Object_timer_0,x
	ChangeObjectState #$00,#$02 ;; uses idle for hurt state.
	
	LDA selfCenterX
	STA recoil_selfX
	LDA selfCenterY
	STA recoil_selfY
	LDA otherCenterX
	STA recoil_otherX
	LDA otherCenterY
	STA recoil_otherY
	
	JSR DetermineRecoilDirection

	PlaySound #SND_HURT_PLAYER

	;;;;; SCROLLER CAN NOT MAKE USE OF UPDATING HUD THIS WAY.


	
doneWithPlayerHurt:
 

Retrobuster

New member
Yeah that's what I've got. My death sound and hurt sound are two different sound effects. Problem is, the death sound effect isn't playing when a monster kills me, but it does play when a hurt tile kills me. I tried chaning the first "PlaySound #SND_HURT_PLAYER" to "PlaySound SFX_SPLAT" which is my death sound but that didn't work. I also tried just commenting out the first "PlaySound" line which didn't work either.


Code:
;;; assumes myHealth variable
;;; if a different variable should handle health
;;; change thename of myHealth.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; uses timers set in GameData\Constants:
;;OBJECT TIMERS
;HURT_TIMER = #$08
;INVINCIBILITY_TIMER = #$08
;RECOIL_SPEED_HI = #$06
;RECOIL_SPEED_LO = #$00

;;;; To change invincibility time, knock back speed, or hurt duration
;;;; updating the abovevalues in constants.

	LDA Object_health,x
	SEC
	SBC #$01 ;; subtract other's strength
	CMP #$01
	BCS notPlayerDeath
	
	PlaySound #SND_HURT_PLAYER
	JSR HandlePlayerDeath
	JMP doneWithPlayerHurt

notPlayerDeath:
	STA Object_health,x
	STA myHealth
	STA hudElementTilesToLoad
		LDA #$00
		STA hudElementTilesMax
		; LDA DrawHudBytes
		; ora #HUD_myHealth
		; STA DrawHudBytes
	UpdateHud HUD_myHealth
    ;; TURN ON handling the hud
	
	SubtractValue #$08, myScore, #$02, #$00
	;;; we also need to set up the routine to update the HUD
	;; for this to work right, health must be a "blank-then-draw" type element.
	;STA hudElementTilesToLoad
	;	LDA #$00
	;	STA hudElementTilesMax
		; LDA DrawHudBytes
		; ora #HUD_myScore
		; STA DrawHudBytes
	UpdateHud HUD_myScore
	
	LDA Object_status,x
	ORA #%00000001
	STA Object_status,x	

	LDA #HURT_TIMER
	STA Object_timer_0,x
	ChangeObjectState #$00,#$02 ;; uses idle for hurt state.
	
	LDA selfCenterX
	STA recoil_selfX
	LDA selfCenterY
	STA recoil_selfY
	LDA otherCenterX
	STA recoil_otherX
	LDA otherCenterY
	STA recoil_otherY
	
	JSR DetermineRecoilDirection
PlaySound #SND_HURT_PLAYER

	;;;;; SCROLLER CAN NOT MAKE USE OF UPDATING HUD THIS WAY.


	
doneWithPlayerHurt:
 

dale_coop

Moderator
Staff member
Check the script assigned to your "Handle Player Death" element in the Project Settings > Script settings...
There is a "StopSound" line in that script... try commenting out that line, to see if you have better results.
Also you could move the "PlaySound #SND_HURT_PLAYER" from the HandlePlayerHurt script (the first one) to that death script.
 

Retrobuster

New member
Here's my death script. Tried commenting out the stop sound but that just keeps the background music playing.

Code:
    TXA
    STA tempx
    TYA 
    STA tempy

    ;;;;;;;;;;;;;;;;;;;
    LDX player1_object
    LDA Object_x_hi,x
    STA temp
    LDA Object_y_hi,x
    STA temp1

    DeactivateCurrentObject
    
    CreateObject temp, temp1, #OBJ_PLAYER_DEATH, #$00, currentNametable
    ;;;;;;;;;;;;;;;;;;;
    StopSound
	
    PlaySound #SND_SPLAT
    LDA #$FF
    STA player1_object
    
    LDX tempx
    LDY tempy
 

dale_coop

Moderator
Staff member
What happens... if you use PlaySound #SND_HURT_PLAYER instead of PlaySound #SND_SPLAT ? Can you hear the sound?
Maybe your SND_SPLAT sound doesn't work? (sound is not correct or not set?)
 

Retrobuster

New member
I know SND_SPLAT works, because it works properly when I die by a hurt tile. I also just noticed this: If I die by monster collision on the first level, the sound doesn't play BUT if I beat the first level and die by monster collision on any other level, the death sound plays properly. This is leading me to believe that there's something off with a warp script or something, because a couple of the random issues I'm having seem to occur after a warp happens. Going to look into that.
 
Top Bottom