Trigger Same Active Screen

offparkway

Active member
Went through the advanced tutorial for the MetroVania module, and I now have a door that opens when triggered.

Do we have to go to another screen to get the triggered object to activate? or is there a way to refresh the current screen and have the door open immediately on the same screen as the trigger?
 

AllDarnDavey

Active member
Look into the boss tiles in the horizontal shooter. They switch to blank tiles after you shoot the boss (made up of background tiles) a certain number of times. Probably could mix the bit that makes the tile & collision change with a trigger check instead.
 

offparkway

Active member
I'll take a look at the shooter videos, but they aren't solid objects are they?

Yeah that's what I'm starting to think... you might have to leave the screen to trigger a screen type. I do have some code that will change tiles to to a different graphic (and make them walkable) when all monsters are killed... that's the effect I'm going for. haven't figured out how to adapt it for this case.

basically I want a door to open once I've collected 8 items. I do have a different sound that plays once 8 items are collected, so that part of the code is good. It's replacing the solid tile with an open door that I'm working on. Monster block I guess.

So maybe if I can change this code, and instead of having it check for the last monster death, I want it to check to see if myHealth is equal (or greater than) 8. Not sure what needs to change.

Code:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
			;;;;; Here we will look at all of the tiles one by one, and if there is a monster block tile, we will convert it
			CountObjects #%00001000
			BEQ +noMoreMonsters
				JMP +doSkipHurtingThisObject
			+noMoreMonsters
				
				MONSTER_BLOCK_TILE = #$07 ; the number collision type of your monster block.
				LDX #$00
				doCheckForMonsterBlockAfterMonsterDeath:
					LDA currentNametable
						AND #%00000001
						BEQ +isEvenCt
							LDA #$24
							STA temp1 ;; high byte of thing
							;;; is odd col table.
							LDA collisionTable2,x
							CMP #MONSTER_BLOCK_TILE
							BEQ +isMonsterBlockTile
								JMP +notMonsterBlockTile
							+isMonsterBlockTile
								;; is monster block table.
								LDA #$00
								STA collisionTable2,x
								
								JSR getTileToChange_forMonBlock

								JMP +doneWithTileUpdate
						+isEvenCt
							LDA #$20
							STA temp1 ;; high byte of thing.
							;;; is odd col table.
							LDA collisionTable,x
							CMP #MONSTER_BLOCK_TILE
							BEQ +isMonsterBlockTile
								JMP +notMonsterBlockTile
							+isMonsterBlockTile
								;; is monster block table.
								LDA #$00
								STA collisionTable,x
								JSR getTileToChange_forMonBlock
		
								JMP +doneWithTileUpdate
								
								
								
							getTileToChange_forMonBlock:
								TXA
								STA temp
								LSR
								LSR
								LSR
								LSR
								LSR
								LSR
								clc
								ADC temp1
								STA temp2 ;;;temp16+1
								TXA
								AND #%11110000
								ASL
								ASL
								STA tempz
								TXA
								AND #%00001111
								ASL
								ORA tempz
								STA temp3 ;temp16
								
								
								;;; SET THE TILE NUMBER TO CHANGE TO.	
								LDA #$00 ;; the tile to change.
										;;; this is in tiles, so if you wanted the second "metatile",
										;;; use 2, not 1.  If you wanted the tile in the next row, 
										;;; use #$20, not #$10.  Etc.
								STA tempA
								CLC
								ADC #$01
								STA tempB
								CLC
								ADC #$0F
								STA tempC
								CLC
								ADC #$01
								STA tempD
								
								
								LDY #$00
									LDA temp2
									STA scrollUpdateRam,y
									INY
									LDA temp3
									STA scrollUpdateRam,y
									INY
									LDA tempA
									STA scrollUpdateRam,y
									INY
									
									LDA temp2
									STA scrollUpdateRam,y
									INY
									LDA temp3
									CLC
									ADC #$01
									STA scrollUpdateRam,y
									INY
									LDA tempB
									STA scrollUpdateRam,y
									INY
									
										LDA temp3
										CLC
										ADC #$20
										STA temp3
										LDA temp2
										ADC #$00
										STA temp2
									
									LDA temp2
									STA scrollUpdateRam,y
									INY
									LDA temp3
									STA scrollUpdateRam,y
									INY
									LDA tempC
									STA scrollUpdateRam,y
									INY
									
									LDA temp2
									STA scrollUpdateRam,y
									INY
									LDA temp3
									CLC
									ADC #$01
									STA scrollUpdateRam,y
									INY
									LDA tempD
									STA scrollUpdateRam,y
									INY
								
								TYA
								STA maxScrollOffsetCounter
								
								
										
								
							;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
							;;; Turn on update screen on next frame.
									LDA updateScreenData
									ORA #%0000100
									STA updateScreenData
							;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
								TriggerScreen screenType
								RTS
						+doneWithTileUpdate
	
						
						JSR doWaitFrame
					+notMonsterBlockTile
					INX 
					CPX #240
					BEQ +doSkipHurtingThisObject ;; done
						JMP doCheckForMonsterBlockAfterMonsterDeath ;; last monster block.
 

offparkway

Active member
Ok this sort of works. I modded the script above and added it to my pickup script, so when I've collected enough items to make myHealth = 8, the door goes away (monster block set to 0E). But it only goes away if the 8th item I collected is on the same screen as the door, and I also need to start from that same screen (because it's a scrolling game?). I guess the question now is: what do I change so that it doesn't matter what screen I collect items on, or what screen the door is on?

Code:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
			;;;;; Here we will look at all of the tiles one by one, and if there is a monster block tile, we will convert it
			LDA myHealth
			CMP #$08
			BEQ +noMoreMonsters
				JMP +doSkipHurtingThisObject
			+noMoreMonsters
				
				MONSTER_BLOCK_TILE = #$0E ; the number collision type of your monster block.
				LDX #$00
				doCheckForMonsterBlockAfterMonsterDeath:
					LDA currentNametable
						AND #%00000001
						BEQ +isEvenCt
							LDA #$24
							STA temp1 ;; high byte of thing
							;;; is odd col table.
							LDA collisionTable2,x
							CMP #MONSTER_BLOCK_TILE
							BEQ +isMonsterBlockTile
								JMP +notMonsterBlockTile
							+isMonsterBlockTile
								;; is monster block table.
								LDA #$00
								STA collisionTable2,x
								
								JSR getTileToChange_forMonBlock

								JMP +doneWithTileUpdate
						+isEvenCt
							LDA #$20
							STA temp1 ;; high byte of thing.
							;;; is odd col table.
							LDA collisionTable,x
							CMP #MONSTER_BLOCK_TILE
							BEQ +isMonsterBlockTile
								JMP +notMonsterBlockTile
							+isMonsterBlockTile
								;; is monster block table.
								LDA #$00
								STA collisionTable,x
								JSR getTileToChange_forMonBlock
		
								JMP +doneWithTileUpdate
								
								
								
							getTileToChange_forMonBlock:
								TXA
								STA temp
								LSR
								LSR
								LSR
								LSR
								LSR
								LSR
								clc
								ADC temp1
								STA temp2 ;;;temp16+1
								TXA
								AND #%11110000
								ASL
								ASL
								STA tempz
								TXA
								AND #%00001111
								ASL
								ORA tempz
								STA temp3 ;temp16
								
								
								;;; SET THE TILE NUMBER TO CHANGE TO.	
								LDA #$00 ;; the tile to change.
										;;; this is in tiles, so if you wanted the second "metatile",
										;;; use 2, not 1.  If you wanted the tile in the next row, 
										;;; use #$20, not #$10.  Etc.
								STA tempA
								CLC
								ADC #$01
								STA tempB
								CLC
								ADC #$0F
								STA tempC
								CLC
								ADC #$01
								STA tempD
								
								
								LDY #$00
									LDA temp2
									STA scrollUpdateRam,y
									INY
									LDA temp3
									STA scrollUpdateRam,y
									INY
									LDA tempA
									STA scrollUpdateRam,y
									INY
									
									LDA temp2
									STA scrollUpdateRam,y
									INY
									LDA temp3
									CLC
									ADC #$01
									STA scrollUpdateRam,y
									INY
									LDA tempB
									STA scrollUpdateRam,y
									INY
									
										LDA temp3
										CLC
										ADC #$20
										STA temp3
										LDA temp2
										ADC #$00
										STA temp2
									
									LDA temp2
									STA scrollUpdateRam,y
									INY
									LDA temp3
									STA scrollUpdateRam,y
									INY
									LDA tempC
									STA scrollUpdateRam,y
									INY
									
									LDA temp2
									STA scrollUpdateRam,y
									INY
									LDA temp3
									CLC
									ADC #$01
									STA scrollUpdateRam,y
									INY
									LDA tempD
									STA scrollUpdateRam,y
									INY
								
								TYA
								STA maxScrollOffsetCounter
								
								
										
								
							;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
							;;; Turn on update screen on next frame.
									LDA updateScreenData
									ORA #%0000100
									STA updateScreenData
							;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
								TriggerScreen screenType
								RTS
						+doneWithTileUpdate
	
						
						JSR doWaitFrame
					+notMonsterBlockTile
					INX 
					CPX #240
					BEQ +notThisPickup ;; done
						JMP doCheckForMonsterBlockAfterMonsterDeath ;; last monster block.
;;;;;;;;;
+doSkipHurtingThisObject
 

mouse spirit

Well-known member
Well if you make both screens the same screentype, i believe that should work if using screentypes.
If not, then yes you should use screentype trigger for that situation.
On type 43 screen, i collect 8 coins and trigger
Now on other type 43 screen, my door is gone because
Its triggered.
 

offparkway

Active member
It's a scrolling game though... so all the screens are the same screentype, but to trigger I'd have to leave and go to another screen right? I'm trying to have the door open without leaving the screen (like in Zelda when you beat the boss and the door immediately opens). Except there is no monster to defeat, I just want the door to open once I've collected 8 items. But on the same screen as the items.

The monster block seems to do it, but only if I start on the last screen with the door. If I start on the first screen and scroll to the last screen, the door won't unlock.

Right now, my workaround is just to keep the door open, but I made a warp tile that only activates if I have 8 items (so the door does nothing until I get 8 items). That works fine, it just doesn't look as nice.
 

mouse spirit

Well-known member
Gotchya. Yeah im sorry but i guess i havnt delved into
a scrolling game really.

So maybe make a monster that dies when you have
those 8 coins. Like have the monster(door) script say
"Hey does the player have 8 coins?If so then just kill me!"

And truly the 8 collection objects should just be a variable like (currentlevelneeds) . So a monster(door)
could just reference the variable and so you could use that same monster(door) script every level or whatever.

It can say.....


Do you have currentlevelneeds?
If so kill me.



Edit: Let me try to be less vague.
Code:
LDA coins
CMP currentlevelneeds
BEQ ++
RTS
++
Deactivatecurrentobject;;;;i dont know the 4.5 propercode

Something like this.
 

offparkway

Active member
I see, thanks! I'll give that a shot... I'll have to figure out how to make a monster solid though. In the GUI, we can make it an NPC or a Monster, neither of which are solid (and a monster harms the player by default).
 

mouse spirit

Well-known member
Yeah thats an issue. Please make an easy solid monster and share it in the tutorial section as everyone wants one.
I dont know if its easy or tough.

I have done something like a solid monster. Heres a link.
http://nesmakers.com/viewtopic.php?f=35&t=5522&p=27201&hilit=Blocks#p27201
 
Top Bottom