Enemy who says something when defeated

salgue79

New member
Hello!! I would like to know, if it were possible that an enemy, Level Boss, could say something when defeated. As if it were an NPC. It would be for a phrase for each Level Boss.
Would it be possible?
 

dale_coop

Moderator
Staff member
salgue79 said:
Hello!! I would like to know, if it were possible that an enemy, Level Boss, could say something when defeated. As if it were an NPC. It would be for a phrase for each Level Boss.
Would it be possible?

Here a simple way to do that:


1) Open the "Project Settings" dialog and go to the "User Variables" tab. Check if you have a variable named "npc_autotext":

2020-06-17-23-46-16-Project-Settings.png


If you do NOT have it, create a "npc_autotext" with initial value "0".


2) Modify the "HandleDrops.asm" script that is assigned to the "Handle Drops" in your "Project Settings > Script Settings" (select the line and click ok the Edit button):

2020-06-17-23-48-09-Project-Settings.png


At the beginning of the "HandleDrops.asm" script, add this piece of code:

Code:
	;; which text to use:
	LDA Object_ID,x	;; the one assigned to the monster placement
	STA textVar
	LDA #$01
	STA npc_autotext
	;; display the text:
	LDA gameHandler
	ORA #%00100000
	STA gameHandler
	LDA #%10000000
	STA textboxHandler



3) Modify your b_activate_text_box.asm in your "Scripts > Input Scripts" list:

2020-06-17-23-52-43-NES-MAKER-4-1-5-Version-0x159-Plat-MST.png

(it is the script that show/close the NPC text box when you press B)

And replace with that script:

Code:
    LDA textboxHandler  ;; check if the text is completely displayed
    AND #%11000000 
    BEQ +
    RTS
    +

	LDA textboxHandler
	AND #%00010000 ;; if the b button is pressed
					;; but the box + text have been activated
					;; and also the 'do box' bit is OFF
					;; that means this is ready to "go away".
					
	BEQ checkToTurnTheTextboxOn ;; hasn't started yet

	;; begin turning the textbox off.
	LDA gameHandler
	ORA #%00100000
	STA gameHandler
	;;; are we turning this on or off?
	;;; check for more
	;;; check for 'choice'.

	LDA #$00
	STA updateNT_offset
	STA updateNT_H_offset
	STA updateNT_V_offset

	STA npc_autotext	;;<-- dale_coop: for autotext tiles

	LDA #%10001000
	STA textboxHandler
	RTS
   
checkToTurnTheTextboxOn:  
	LDA npc_autotext	;;<-- dale_coop: for autotext tiles
	BEQ +
	JMP ++
	+
	LDA npc_collision
	BEQ noNPCcollision
	++
	LDA textboxHandler
	AND #%10000000
	BNE noNPCcollision
	LDA gameHandler
	ORA #%00100000
	STA gameHandler
	;;; are we turning this on or off?
	;;; check for more
	;;; check for 'choice'.

turnTheTextboxOn:
  
	LDA #%10000000
	STA textboxHandler
    
noNPCcollision:
	RTS



4) Assign your Text to your Text Group... then, assign that Text Group to your screen, in the "Infos" dialog:

2020-06-17-23-55-55-NES-MAKER-4-1-5-Version-0x159-Plat-MST.png



VoilĂ , now you should have a text that shows up when you kill a monster.


PS: don't forget to save your project.
 

salgue79

New member
I have put all this, but it does not work. By eliminating the enemy, the same thing continues to happen. Automatically go to the next level.
Perhaps this is why, by eliminating the enemy, we are transferred to the next level. Maybe you have to put something in the Jump Kills script, right?
 

dale_coop

Moderator
Staff member
If you automatically warp.... it is because for your project, it's coded to do that.

In your project, it's the ALL MONSTERS KILLED that warps you when all the monster are killed.
So, you might need to do it differently:
--> do not warp when all the monster are killed (comment out the code in the corresponding script, in your "Project Settings > Script Settings")
--> instead, do a warp when the text is closed (http://nesmakers.com/viewtopic.php?f=40&t=2009)


Remember: all projects are different! your project uses now a lot of specific code and scripts... the rules that apply for others will not apply for your game... and the opposite.
 
Top Bottom