Custom DestroyMe scripts?

SuperNatetendo

New member
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.
 

MistSonata

Moderator
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

Active member
I want a different animation to display when monsters are hit by the projectile instead of the sword. Is that possible?
 

SuperNatetendo

New member
MistSonata said:
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....
 

MistSonata

Moderator
Bucket Mouse said:
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.
 

dale_coop

Moderator
Staff member
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:
;; 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
 

Bucket Mouse

Active member
dale_coop said:
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:
;; 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:
;; 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:
;; 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?
 

dale_coop

Moderator
Staff member
You could try:
Code:
;; 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
 

Bucket Mouse

Active member
dale_coop said:
You could try:
Code:
;; 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

Active member
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:
		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:
		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?
 

dale_coop

Moderator
Staff member
You should make a custom destroy me script:
Paste the code in the "Routines\System\AI_Reactions\Reaction_03.asm" (currently unused), then in you "Project Settings > Project Labels", rename "Reaction_03" to "Destoy Me (Player Weapon)" (edge reaction and solid reaction). Lastly, reassign this reaction to the Melee/projectile object.
 

Bucket Mouse

Active member
dale_coop said:
You should make a custom destroy me script:
Paste the code in the "Routines\System\AI_Reactions\Reaction_03.asm" (currently unused), then in you "Project Settings > Project Labels", rename "Reaction_03" to "Destoy Me (Player Weapon)" (edge reaction and solid reaction). Lastly, reassign this reaction to the Melee/projectile object.

OK, tried it...there was no difference or change for the monsters, but when the projectile hit an object it would just stay there.
 

dale_coop

Moderator
Staff member
Hmm...
In fact, thinking about the original question. You right, it's not the "DestroyMe" you want/need to customize... just the monster's death right?
So, as you said, you need just need to modify the "Adventure_HandleHurtMonster.asm".
 

dale_coop

Moderator
Staff member
And if you still want to play with the DESTROY ME script.
Soem correctins need to be made... add :
Code:
;; DESTROY ME
	TXA
	STA tempx
at the begining... and
Code:
continueDestroyingMe:
	LDX tempx 
	DeactivateCurrentObject
at then end.
Now the "DeactivateCurrentObject " parts should works again.
 

Bucket Mouse

Active member
dale_coop said:
And if you still want to play with the DESTROY ME script.
Soem correctins need to be made... add :
Code:
;; DESTROY ME
	TXA
	STA tempx
at the begining... and
Code:
continueDestroyingMe:
	LDX tempx 
	DeactivateCurrentObject
at then end.
Now the "DeactivateCurrentObject " parts should works again.

It still says "Branch out of range" when I put this in Adventure_HandleHurtMonster.asm
 

dale_coop

Moderator
Staff member
This code was supposed to be for your Reaction_03.asm (the custom "DESTROY ME" script).... but only IF you still have modifications in this script.
But I would suggest to remove all the modification in DESTROY ME scripts. Because when I read you, I know understand you don't want/need that.

You want/need to make your modifications in Adventure_HandleHurtMonster.asm script.
Go step by step... else you will never go anywhere.
First, I would suggest to make an effect (explose or whatever you want), when the monster dies:
Take a look at the the line
Code:
		JSR HandleDrops
This subroutine, is called each time a monster dies.
I think it would be smart, to write your code in that routine, make a copy custom script from this one.

If you can wait for 2 hours... I can do some tests, during my lunch time, and give you a script that should works.
 

dale_coop

Moderator
Staff member
Currently the subroutine "HandleDrops" create objects when a monster dies: the "health" object or the "currency" object AND create the "Effect 1" object.
In your case, you would like the effect to be different depending of the weapon used.

So make a modify (or better make a custom) "Adventure_HandleDrops.asm", and at the end...
replace :
Code:
donePickup:	
	;;; ALL cases create a "pow"
	CreateObject temp, temp1, #$09, #$00

by:
Code:
donePickup:	
	;;; ALL cases create a "pow"
	
	;;supposed here, the weapon/projectile object is in tempx
	;;supposed here, the monster object is in x
	TXA
	STA tempy
	LDX tempx
	
	LDA Object_type, x
	CMP #$01
	BEQ isSwordWeapon
	CMP #$02
	BEQ isSwordWeapon
	CMP #$03
	BEQ isProjectileWeapon
	JMP finishedMonsterDeathEffect
	
isSwordWeapon:
	;;get the position of the monster:
	LDA Object_x_hi,x
	STA temp
	LDA Object_y_hi,x
	STA temp1
	;;create the effect 9 object:
	CreateObject temp, temp1, #$09, #$00
	JMP finishedMonsterDeathEffect
	
isProjectileWeapon:
	;;get the position of the monster:
	LDA Object_x_hi,x
	STA temp
	LDA Object_y_hi,x
	STA temp1
	;;create the effect 11 object:
	CreateObject temp, temp1, #$0B, #$00
	JMP finishedMonsterDeathEffect
	
finishedMonsterDeathEffect:
    LDX tempy


PS: by the way, don't forget to remove all the modifications made in the DETROY ME (Reactions_02 or 03) scripts.
 

Bucket Mouse

Active member
Wow, you did it! It really works!

Can you post the completed script in the Code forum? I would post it, but you did all the work.
 

dale_coop

Moderator
Staff member
It’s you idea, Bucket Mouse, you can post it. I encourage you to do it. I just helped you to make it.
 
Top Bottom