[4.5] Trigger Screen with Enemy Death

offparkway

Active member
Looking to trigger a screen when a specific enemy dies. Is it possible to maybe check to see if monster 08 (for example) is destroyed, and if it is destroyed, trigger the screen? To maybe remove a lock block or open a door.

Or perhaps unlocking a lock block if all enemies on screen are defeated? Not sure how to write the code for something like that.
 

mouse spirit

Well-known member
Yes. It is sometimes a feature for nesmaker and called Monster Locks. Should be like vids 5 and 6 in the new summer camp vid series for 4.5. Should be able to find the vids on the nesmaker site or here in annoincements i think. For doing a single specific monster, like we will call him a "gatekeeper", in the code when it destroys a monster who is out of health, you would end up asking if its monster 8 and if so, go do monster lock code.
Oor make it trigger screentype in that room, also have the room somewhere else you want "unlocked" to have the same screentype.

Example. Im in screentype 03. I kill gatekeeper whos death triggers screentype. Nothin in here but 5 rooms over was the other room that is screentype 03 also. Which was triggered when we killed "gatekeeper" in the first room, and so has unlocked a door or monsterlock. In the 2nd room in question.

Screentypes and monsterlocks work seperately. But i think to make the monster lock stay "unlocked" you do have to subsequently trigger that screen as that is how monsterlocks work.

Code:
Code example:
;;heres where monster death happens in my code 

LDA object_y_hi,x
STA temp1

;;so before deactivating the monster,right here compare to the specific monster
;;if its him,now execute monsterlocks or triggerscreentype
;;if not the specific monster,simply continue,actually continue either way

DeactivateCurrentObject

PlaySound #SND_SPLAT

CreateObject temp, temp1n #OBJ_MONSTER_DEATH, #$00 , currentNametable

This is only an example of code and using monsterlocks is actually more involved so watchin the vids is best.

But just think about code in a way like you would litterally say what you want. When monster dies i want to know if it was the gatekeeper. If it is, i want this to open up and unlock, open and unlock means do this, do this is change tile to walkable and change graphic, i want thi to save,so trigger screentype.

If you are looking for a more specific answer im sure someone else will chime in to help also. But i hope this helps understand what you may want to think about atleast. An undersatnding of like a flowchart or a program analysis mentallity helps. Or like binaryor somethin. Just yes and no's, and branches and returns. Within the answers to questions are more questions,and so on.

Monster killed,
Is this monster 08,yes
do i unlock door,yes.
update score,yes
Is score a hud variable,no
update hud,no
does the enemy drop an item,no
play a sound,yes
Loop
another monster killed,
is this monster 08,no,
do i unlock do,no
Yes,no,branch,loop and check again.
 

offparkway

Active member
This is a great start, thank you! I watched all the new videos, and I don't recall monster locks ever being mentioned. I've seen folks talk about it here, but it seemed to be a feature from 4.1.

I'll go back and look at the videos you suggested just in case. I can follow the code and recognize what it's doing for the most part, but writing it myself is a whole different thing. Like, no one every explained what a branch or a return is lol. But I can sort of guess. That code would be included injected into Handle Monster Hurt?

counting from 0, the monster I'd want to to trigger would be 06. So if I'm following you, I think i'd want:

monster destroyed
is monster 06?
if no, skip to end of monster hurt
if yes, remove lock block (or open door)... which i'm assuming needs to be done by triggering the screen. Ideally I want to do it on the same screen
 

mouse spirit

Well-known member
I think youve got a handle on it. Specifically with calling an object that way,(like #$00) object 0 is actual the first of your player objects. There are 16 of those. So monster 1 is actually object 17 which we can represent with #$10...Because stuff is in 8s all the time here,and the way to count these can use 0-9 and A-F. Your first monster object is actually #$10. Sooo monster 6 is object #$16 i believe.I will link a better explanation.

http://nesmakers.com/viewtopic.php?t=2474#p15308
 

mouse spirit

Well-known member
And yes some code should go there for this. But like monster locks will be set up somewhere else, but you could call or reference it this code, to then go trigger monster locks. Its how alot of code works. Its not all typed right here, sometimes its what is called a macro and other stuff.

Now i see. I was thinkin episode 4 and 5 lock blocks. Similar except they are not based on the amount of monster, they work with keys. Sorry bout that . If he hasnt done a vid on monsterlocks,theres probly gonna be one. Or look into if its possible to adapt 4.1.5 monsterlocks when you have a better grasp.
 

offparkway

Active member
Oh, ok I didn't realize monsters were just basically continuations of the game objects. So I understand that my monster would be object #$16 (not 06).

Creating a monster lock is where I'm gonna get tripped up, I'm sure. The videos taught us how to do a lock tile, which I've used in a few places. But I don't remember a reference to a monster lock.
 

mouse spirit

Well-known member
You are correct.my bad. This may help. http://nesmakers.com/viewtopic.php?f=40&p=26251
Go ahead and ask there. Say hey. How can i do this in 4.5?
 

dale_coop

Moderator
Staff member
A lot of functionalities from the 4.1.5 are not (yet) in the new version. Keep it mind that the current 4.5 is a beta, it came with an almost empty module, to be used for the Summer Camp tutorials... to learn, modify, customize the module and do great things. It was a simple one to help us to understand.

We need a more complete one with more functionalities... Joe said he will release the definitive version of NESmaker 4.5 for the Byte Off (it means by August 1st)

In the meantime, we figure out how to implement some of the old functionalities, but in a few days... not everything
 
Top Bottom