LDA #TILE_SOLID
STA tile_solidity
LDA Object_health,x
SEC
SBC #$01
CMP #$01
BCS notPlayerDeath2
PlaySound #SND_HURT_PLAYER
JSR HandlePlayerDeath
JMP doneWithPlayerHurt2
notPlayerDeath2:
STA Object_health,x
STA myHealth
STA hudElementTilesToLoad
LDA #$00
STA hudElementTilesMax
UpdateHud HUD_myHealth
LDA Object_status,x
ORA #%00000001
STA Object_status,x
LDA #HURT_TIMER
STA Object_timer_0,x
ChangeObjectState #$05,#$02 ; uses state #$05 for hurt state.
; set this to your player's hurt state.
LDA selfCenterX
STA recoil_selfX
LDA selfCenterY
STA recoil_selfY
LDA otherCenterX
STA recoil_otherX
LDA otherCenterY
STA recoil_otherY
JSR DetermineRecoilDirection
doneWithPlayerHurt2:
Mugi said:here you go:
save this as an .asm file, and assign it to a tile type from script settings.
this tile will hurt the player upon collision, and othervise acts as a solid object.
the script assumes that your player's hurt state is 05, adjust if necessary.
Code:LDA #TILE_SOLID STA tile_solidity LDA Object_health,x SEC SBC #$01 CMP #$01 BCS notPlayerDeath2 PlaySound #SND_HURT_PLAYER JSR HandlePlayerDeath JMP doneWithPlayerHurt2 notPlayerDeath2: STA Object_health,x STA myHealth STA hudElementTilesToLoad LDA #$00 STA hudElementTilesMax UpdateHud HUD_myHealth LDA Object_status,x ORA #%00000001 STA Object_status,x LDA #HURT_TIMER STA Object_timer_0,x ChangeObjectState #$05,#$02 ; uses state #$05 for hurt state. ; set this to your player's hurt state. LDA selfCenterX STA recoil_selfX LDA selfCenterY STA recoil_selfY LDA otherCenterX STA recoil_otherX LDA otherCenterY STA recoil_otherY JSR DetermineRecoilDirection doneWithPlayerHurt2:
might be slightly buggy but my whole game is slightly buggy at the moment so can't test it too well. it's essentially just a modification of the handleplayerhurt.
dale_coop said:You're using NESMaker 4.1, right?
Mugi said:propably the UpdateHud HUD_myHealth macros dont exist on 4.0.11, since that's what your error message complains about.
LDA Object_status,x
AND #HURT_STATUS_MASK ;; if the monster is hurt, it can't hurt us
BEQ +
JMP doneWithPlayerHurt2
+
LDA #TILE_SOLID
STA tile_solidity
LDA Object_status,x
AND #HURT_STATUS_MASK ;; if the monster is hurt, it can't hurt us
BEQ +
JMP doneWithPlayerHurt2
+
Retrobuster said:That definitely helped. Now I'm wondering how I can go about removing that tile entirely once I collide with it- like how the collectable tile disappears after you collide with it and is replaced with just a basic walkable tile AND how to subtract from the score in the opposite manner of the collectable tile. Don't tell me just yet! Trying to figure this out for myself, but just still wanted to reply to say you've helped me get this far. Thanks!
LDA #TILE_SOLID
STA tile_solidity
LDA ObjectFlags,x ;; Is it a monster?
AND #%00001000
BNE notAmonster
RTS
notAmonster:
LDA #TILE_SOLID
STA tile_solidity
LDA ObjectFlags,x ;; Is it a monster?
AND #%00001000
BNE notAmonster
RTS
notAmonster:
LDA Object_health,x
SEC
SBC #$01
CMP #$01
BCS notPlayerDeath2
PlaySound #SND_HURT_PLAYER
JSR HandlePlayerDeath
JMP doneWithPlayerHurt2
notPlayerDeath2:
STA Object_health,x
STA myHealth
STA hudElementTilesToLoad
LDA #$00
STA hudElementTilesMax
UpdateHud HUD_myHealth
LDA Object_status,x
ORA #%00000001
STA Object_status,x
LDA #HURT_TIMER
STA Object_timer_0,x
ChangeObjectState #$04,#$02 ; uses state #$04 for hurt state.
; set this to your player's hurt state.
LDA selfCenterX
STA recoil_selfX
LDA selfCenterY
STA recoil_selfY
LDA otherCenterX
STA recoil_otherX
LDA otherCenterY
STA recoil_otherY
JSR DetermineRecoilDirection
doneWithPlayerHurt2: