Hurt Block

red moon

Member
Hello,
I am looking to set up a tile that damages rather than kills the player outright...
Could the handlehurtplayer script be altered to do this? I want the block's behavior to act similar to be hit by an enemy.
I renamed tile 11 to be hurtblock and was looking to replace the prize block tile script with one that simply damages the player.
 

Attachments

  • script.jpg
    script.jpg
    1 MB · Views: 683
  • script2.jpg
    script2.jpg
    511.9 KB · Views: 683

dale_coop

Moderator
Staff member
Here's a example of that kind of "Hurt" tiles:
http://nesmakers.com/viewtopic.php?f=40&t=2695
 

red moon

Member
I went ahead and added the changes outlined here and it works but does not add recoil when coming into contact with the object...

a simple addition, if you need one. detracts one life for player.

step 1:
-go to the handlePlayerHurt.asm your project is using. be aware that there may several copies named the same for different modules.

add this to the very top of the document
CODE: SELECT ALL

hurtPlayer:
save.

step 2:
make a new text document.
paste the following
CODE: SELECT ALL

cpx player1_object
bne +
lda Object_timer_0,x
bne +
jsr hurtPlayer
+
save as myHurtTile.asm or whatever you'd like it to be named in an appropriate place.

Link up the new .asm file in script settings to a tile ID you want it to be.

Hurt tile properties:
-only hurts player
-player will recoil
-only detracts one life per hit/recoil period (checking object_timer_0,x guarantees this every time).
 

dale_coop

Moderator
Staff member
Strange, the tutorial says that you should have recoil.

Maybe its because otherCenterY and otherCenterX are not set... because no object collision here.
You could try... maybe... something like that:
Code:
	CPX player1_object 
	BNE +
	LDA Object_timer_0,x
	BNE +

	LDA tileX
	AND #%11110000
	CLC
	ADC #$08
	STA otherCenterX
	
	LDA tileY
	AND #%11110000
	CLC
	ADC #$08
	STA otherCenterY
	
	JSR hurtPlayer
	+
 
Top Bottom