Custom DestroyMe scripts?

Have a thought on how NESmaker can be improved? We are a small team with limited means, but we'd love to hear your ideas!
User avatar
SuperNatetendo
Posts: 35
Joined: Wed Aug 08, 2018 4:51 pm

Custom DestroyMe scripts?

Post by SuperNatetendo » Sat Sep 08, 2018 11:47 pm

So right now I really want to have custom death animations per player/monster/object/etc. But there's just a kinda generic one. Was wondering if there could be a "DestroyMe" reaction list that one could customize? I think that could go a long way in things like cool boss deaths or things of the like.
User avatar
MistSonata
Posts: 267
Joined: Fri Feb 16, 2018 7:10 am

Re: Custom DestroyMe scripts?

Post by MistSonata » Sun Sep 09, 2018 1:14 am

It depends on what module you're using, but if you go to Project Settings>Script Settings, then select "Handle Monster Hurt" or "Handle Player Death" and press the edit button, it should open the scripts that handle their deaths.

For the "Handle Monster Hurt" script, scroll down until you see the code "BCS notMonsterDeath", right after that line is where you'll want to put your custom code.
Bucket Mouse
Posts: 193
Joined: Wed Mar 07, 2018 2:25 am

Re: Custom DestroyMe scripts?

Post by Bucket Mouse » Sun Sep 09, 2018 3:10 am

I want a different animation to display when monsters are hit by the projectile instead of the sword. Is that possible?
User avatar
SuperNatetendo
Posts: 35
Joined: Wed Aug 08, 2018 4:51 pm

Re: Custom DestroyMe scripts?

Post by SuperNatetendo » Sun Sep 09, 2018 1:35 pm

MistSonata wrote:
Sun Sep 09, 2018 1:14 am
It depends on what module you're using, but if you go to Project Settings>Script Settings, then select "Handle Monster Hurt" or "Handle Player Death" and press the edit button, it should open the scripts that handle their deaths.

For the "Handle Monster Hurt" script, scroll down until you see the code "BCS notMonsterDeath", right after that line is where you'll want to put your custom code.
Ah! Good to know. I think I might be able to create multiple deaths per enemy if I make the Handle Monster Death change to an action state....
User avatar
MistSonata
Posts: 267
Joined: Fri Feb 16, 2018 7:10 am

Re: Custom DestroyMe scripts?

Post by MistSonata » Sun Sep 09, 2018 11:47 pm

Bucket Mouse wrote:
Sun Sep 09, 2018 3:10 am
I want a different animation to display when monsters are hit by the projectile instead of the sword. Is that possible?
I'm sure it's possible, but the way the code is, it doesn't distinguish between a projectile or a melee weapon in the collision code, for that you might need to separate the "player weapon" bit into two bits, "player projectile" and "player melee". Or it might be possible to, somewhere in the object collision script, insert a check for the object_type and load that in a variable somewhere and use it to determine which animation to call in the monster hurt script.
User avatar
dale_coop
Posts: 1593
Joined: Fri Feb 16, 2018 7:05 am
Location: France

Re: Custom DestroyMe scripts?

Post by dale_coop » Mon Sep 10, 2018 9:18 am

I am not home, so I can't test... but it might be possible, testing the type of the object (I suppose the weapon is loaded in "x", here):

Code: Select all

;; DESTROY ME
	LDA Object_type,x
	CMP #$01
	BEQ isSwordWeapon
	CMP #$02
	BEQ isSwordWeapon
	CMP #$03
	BEQ isProjectileWeapon
	JMP continueDestroyingMe
	
	
isSwordWeapon:
	;; create object animation (sword)
	;; here
	;;
	JMP continueDestroyingMe
  
isProjectileWeapon:
	;; create object animation (projectile)
	;; here
	;;
	JMP continueDestroyingMe

continueDestroyingMe:
	DeactivateCurrentObject
-----
Sorry about my poor english
All I need: A Damn Fine Cup of Coffee
My games: PRESS START GAME / UNDERGROUND ADVENTURE
Bucket Mouse
Posts: 193
Joined: Wed Mar 07, 2018 2:25 am

Re: Custom DestroyMe scripts?

Post by Bucket Mouse » Thu Sep 13, 2018 8:55 am

dale_coop wrote:
Mon Sep 10, 2018 9:18 am
I am not home, so I can't test... but it might be possible, testing the type of the object (I suppose the weapon is loaded in "x", here):

Code: Select all

;; DESTROY ME
	LDA Object_type,x
	CMP #$01
	BEQ isSwordWeapon
	CMP #$02
	BEQ isSwordWeapon
	CMP #$03
	BEQ isProjectileWeapon
	JMP continueDestroyingMe
	
	
isSwordWeapon:
	;; create object animation (sword)
	;; here
	;;
	JMP continueDestroyingMe
  
isProjectileWeapon:
	;; create object animation (projectile)
	;; here
	;;
	JMP continueDestroyingMe

continueDestroyingMe:
	DeactivateCurrentObject

The regular monster death animation is ninth in "Game Objects" (counting from zero) and the Projectile death animation is eleventh. So I tried this first:

Code: Select all

;; DESTROY ME
	LDA Object_type,x
	CMP #$01
	BEQ isSwordWeapon
	CMP #$02
	BEQ isSwordWeapon
	CMP #$03
	BEQ isProjectileWeapon
	JMP continueDestroyingMe
	
	
isSwordWeapon:

	CreateObject #$09, #$00
	JMP continueDestroyingMe
  
isProjectileWeapon:

	CreateObject #$0B, #$00
	JMP continueDestroyingMe

continueDestroyingMe:
	DeactivateCurrentObject 
"Unknown label," it said on the lines where CreateObject was mentioned. Even though it should clearly know what CreateObject is.

I looked up another instance where CreateObject was used -- the player death animation. It loaded the coordinates of the sprite and used them as part of the CreateObject line. So....

Code: Select all

;; DESTROY ME
	LDA Object_type,x
	CMP #$01
	BEQ isSwordWeapon
	CMP #$02
	BEQ isSwordWeapon
	CMP #$03
	BEQ isProjectileWeapon
	JMP continueDestroyingMe
	
	
isSwordWeapon:
	LDX Object_type,x
	LDA Object_x_hi,x
	STA temp
	LDA Object_y_hi,x
	STA temp1
	CreateObject temp, temp1, #$09, #$00
	JMP continueDestroyingMe
  
isProjectileWeapon:
	LDX Object_type,x
	LDA Object_x_hi,x
	STA temp
	LDA Object_y_hi,x
	STA temp1
	CreateObject temp, temp1, #$0B, #$00
	JMP continueDestroyingMe

continueDestroyingMe:
	DeactivateCurrentObject 
"Illegal Instruction," it now says. DARN!

What am I missing?
User avatar
dale_coop
Posts: 1593
Joined: Fri Feb 16, 2018 7:05 am
Location: France

Re: Custom DestroyMe scripts?

Post by dale_coop » Thu Sep 13, 2018 9:07 am

You could try:

Code: Select all

;; DESTROY ME
	LDA Object_type,x
	CMP #$01
	BEQ isSwordWeapon
	CMP #$02
	BEQ isSwordWeapon
	CMP #$03
	BEQ isProjectileWeapon
	JMP continueDestroyingMe
	
	
isSwordWeapon:
	LDA Object_x_hi,x
	STA temp
	LDA Object_y_hi,x
	STA temp1
	CreateObject temp, temp1, #$09, #$00
	JMP continueDestroyingMe
  
isProjectileWeapon:
	LDA Object_x_hi,x
	STA temp
	LDA Object_y_hi,x
	STA temp1
	CreateObject temp, temp1, #$0B, #$00
	JMP continueDestroyingMe

continueDestroyingMe:
	DeactivateCurrentObject 
	
-----
Sorry about my poor english
All I need: A Damn Fine Cup of Coffee
My games: PRESS START GAME / UNDERGROUND ADVENTURE
Bucket Mouse
Posts: 193
Joined: Wed Mar 07, 2018 2:25 am

Re: Custom DestroyMe scripts?

Post by Bucket Mouse » Fri Sep 14, 2018 1:59 am

dale_coop wrote:
Thu Sep 13, 2018 9:07 am
You could try:

Code: Select all

;; DESTROY ME
	LDA Object_type,x
	CMP #$01
	BEQ isSwordWeapon
	CMP #$02
	BEQ isSwordWeapon
	CMP #$03
	BEQ isProjectileWeapon
	JMP continueDestroyingMe
	
	
isSwordWeapon:
	LDA Object_x_hi,x
	STA temp
	LDA Object_y_hi,x
	STA temp1
	CreateObject temp, temp1, #$09, #$00
	JMP continueDestroyingMe
  
isProjectileWeapon:
	LDA Object_x_hi,x
	STA temp
	LDA Object_y_hi,x
	STA temp1
	CreateObject temp, temp1, #$0B, #$00
	JMP continueDestroyingMe

continueDestroyingMe:
	DeactivateCurrentObject 
	
Oof, it's causing all sorts of problems. That code makes the projectile stop when it reaches the edge of the screen instead of disappear, and it causes graphics glitches on some screens. What NESMaker sets up as far as weapons data goes, this undoes. Turns out DestroyMe is utilized by more things than just monsters. If it's not a monster it doesn't know what to do.
Bucket Mouse
Posts: 193
Joined: Wed Mar 07, 2018 2:25 am

Re: Custom DestroyMe scripts?

Post by Bucket Mouse » Fri Sep 14, 2018 6:28 am

So I tried putting your code into Adventure_HandleHurtMonster. The point where the monster vanishes has to be the "DeactivateCurrentObject" right after "BCS notMonsterDeath."

it gave me an error, but not where I figured: it flagged the BCS line as "out of range."

BCS is a new command to me so I looked it up; it means "branch if a carry occurs." If that has to be replaced with something else, I wouldn't know what.

Code: Select all

		LDA Object_health,x
		SEC
		SBC #$01
		CMP #$01
		BCS notMonsterDeath
		DeactivateCurrentObject
It checks the health of the monster, subtracts one point, then compares it to 1. If it's 1 or greater, it skips the death command. I don't see why this wouldn't still work even with your code there.

I tried this:

Code: Select all

		LDA Object_health,x
		SEC
		SBC #$01
		CMP #$00
		BEQ notMonsterDeath
		DeactivateCurrentObject
Same result -- "out of range." I don't get it. It hasn't even gotten to your code yet; what makes it give up?
Post Reply