[4.1] Adding Monster Locks for your game (Basic core)

dale_coop

Moderator
Staff member
Looks nice! Same scripts here, and all work perfectly.
How is your CheckTriggeredLoads.asm script?
 

vanderblade

Active member
Code:
	LDA temp
	CMP #TILE_INDEX_LOCK
	BNE ++
	LDA #TILE_OPENDOOR ;; what tile do you want under lock?
	STA temp
	JMP notPath
++
 

dale_coop

Moderator
Staff member
Everything's correct. but you have some screens with monster blocks that work. What is the difference between the screens that work and the one that doesn't? Might be difference that causes that.... for example if you make another screen similar, will it have the same problem?
 

dale_coop

Moderator
Staff member
I could make a fix, that would work specifically for your case, but I would prefer to find the real cause of your issue.

Because, else a temporary fix, for this game would be, to add a new User Constant named "TILE_INDEX_LOCK" with a value "70".
And make a new CheckTriggeredLoads_DC.asm script:
Code:
	LDA temp
	CMP #TILE_MONSTER_LOCK
	BNE ++
	LDA #TILE_MONSTER_LOCK_OFF ;; what tile do you want under monster lock?
	STA temp
	JMP notPath
++
	LDA temp
	CMP #TILE_INDEX_LOCK
	BNE ++
	LDA #TILE_OPENDOOR ;; what tile do you want under lock?
	STA temp
	JMP notPath
++
And assign this script to the "Handle Triggered Tiles" element in the "Script Settings".
 

vanderblade

Active member
Hmmm...

I just made two new rooms and both work properly. So...I'm going to have to look into what might be the issue. What kind of parameters could I have possibly changed, though?

Update: It makes no bloody sense. I deleted the screen with the issue and the new screen on the same spot has the same issue. Yet if I make a room on a different screen, there is no issue at all.

Update 2: I also get this error if I try your fix: Routines\Basic\System\CheckTriggeredLoads.asm(2): Unknown label.

Update 3: I just copied and pasted each dungeon screen to shift it all to the right to avoid the "broken" screens. Everything works now. So...it's definitely a specific screen number issue. Specifically, it was screens X: 1 Y: 12 and X: 1 Y: 13 on the underworld map. Sooooo bizarre.

Update 4: Okay. For some dumb reason, now the screens that weren't working before I shifted everything to the right one screen are working, but the ones that were working previously are not. So X: 3 Y: 13; X: 3 Y: 14; X: 3 Y: 15 don't work, just like the broken screens above. It seems entirely random. Why would screen position matter AT ALL? Can you recreate this phenomenon?

I'm sorry about all this, by the way. Once again, this functionality was baked into the original release of the adventure module, and here we are spending days just trying to recreate it in 4.1. :(
 

dale_coop

Moderator
Staff member
Wow... looks interesting ! ;)
I will do more tests, with screens at different positions. Or if you could send me your project, I could test with your situations. Thank you vanderblade for all that tests.
 

dale_coop

Moderator
Staff member
There definitely a difference between EVEN numbered screens and ODD numbered screens (in the HandScreenLoads.asm), but couldn't figure exactly what's going on (looks like related to the scrolling engine).

Joe confirmed on FB :
It's because now, there are ALWAYS two screens worth of data loaded.
It's checking what's loaded to collisionTable and in the first
nametable, and never what's in collisionTable2 or the second
nametable. :)

So I guess I have to search more deep and fix that! (tomorrow... too late now, here in France)
 
now this is weird adding the melee into the weapon so I can use a melee as well as the projectile whenever I kill just one enemy, the door opens.
it works fine when I just use the melee but with a projection the lock will end with just one monster shot.
 

vanderblade

Active member
Gilbert, follow Dale's tutorial linked on page one for the adventure game. That should fix your problem. Now we're working on solving an issue with odd and even screen numbers.
 

dale_coop

Moderator
Staff member
Gilbertmaxter said:
now this is weird adding the melee into the weapon so I can use a melee as well as the projectile whenever I kill just one enemy, the door opens.
it works fine when I just use the melee but with a projection the lock will end with just one monster shot.


Check again.. my OP, first page : http://nesmakers.com/viewtopic.php?f=3&t=1750
download the zipScripts and install it. Or fix manually the script (the 8/ about the Handle Monster Hurt script)
 

dale_coop

Moderator
Staff member
I think I fixed the Monster Lock Tiles to make it work for all the screens (not only the odd number screens :p)


1/ You don't have them already, add a new "TILE_OPENDOOR" user constants with a value "0".
And a new "TILE_MONSTER_LOCK" user constants (in the "Project Settings > User Constants" with the value of YOUR monster tile (for this exemple, the numeric value is "70"):

2019-01-16-11-30-08-Project-Settings.png


To find the value, just look at your tile infos :

2019-01-16-11-22-53-NES-MAKER-4-1-1-Version-0x158-Adventure-Test-MST.png

Here, it's a tileID #$46 (in hexa), it means 70 in numeric.

You can also check directly in your tileset, counting from 0 to 255 (from top to bottom, left to right) :

2019-01-16-11-24-52-NES-MAKER-4-1-1-Version-0x158-Adventure-Test-MST.png



2/ Make a new script "CheckTriggeredTileLoads_DC.asm" in the "GameEngineData\Routines\Basic\System" folder, with this code:

Code:
	LDA temp
	CMP #TILE_INDEX_LOCK
	BNE ++
	LDA #TILE_OPENDOOR ;; what tile do you want under lock?
	STA temp
	JMP notPath
++
	LDA temp
	CMP #TILE_MONSTER_LOCK
	BNE ++
	LDA #TILE_MONSTER_LOCK_OFF ;; what tile do you want under Monster Lock?
	STA temp
	JMP notPath
++


3/ Make a new script "CheckTriggeredColLoads_DC.asm" in the "GameEngineData\Routines\Basic\System" folder, with:
Code:
	LDA temp
	CMP #COL_INDEX_LOCK
	BNE ++
	;;; if it was a locked tile, make sure it is 
	LDA #$00
	STA temp ;; set it to a walkable tile.
++
	LDA temp
	CMP #COL_MONSTER_LOCK
	BNE ++
	;;; if it was a monster locked tile, make sure it is 
	LDA #$00
	STA temp ;; set it to a walkable tile.
++


3/ Modify the content of the "LoadCollisionBytes.asm" script in the "GameEngineData\Routines\Basic\System", with this code (make a copy before, to keep the original one):

Code:
LoadCollisionBytes:

	JSR LoadEvenCollisionPoint
	INX
	DEC updateCol_columnCounter
notEndOfColumn:
	JSR LoadOddCollisionPoint
	INX
	DEC updateCol_columnCounter
	LDA updateCol_columnCounter
	BNE notEndOfColumn2
	;; is end of column.
	
	LDA updateCol_columns
	STA updateCol_columnCounter
	TXA
	SEC
	SBC updateCol_columns
	CLC
	ADC #$10
	TAX
	
	
	LDA updateCol_columns
	LSR
	STA temp2
	TYA
	SEC
	SBC temp2
	CLC
	ADC #$08;; one more will get added below as part of flowing into notEndofColumn2
	TAY
	
	INC updateCol_rowCounter
	LDA updateCol_rowCounter
	CMP updateCol_rows
	BEQ doneWithColBytes
	
notEndOfColumn2:
	INY
	;CPY #$78
	;BEQ doneWithColBytes
	JMP LoadCollisionBytes
doneWithColBytes
	RTS
	
	
	
	
	
	
doEndOfColumn:

	INC updateCol_rowCounter
	LDA updateCol_columns
	STA updateCol_columnCounter
	RTS
	
	
	
	

	
	
LoadEvenCollisionPoint:

;; get the first point:
	LDA (collisionPointer),y
	LSR
	LSR
	LSR
	LSR
	STA temp
;;;;;;;;;;;; CHECK FOR TRIGGERED.
;;;;;;;;;;;; Do all triggered updates here.
	GetTrigger
	BEQ noTriggerStateEvenCollisionPoint
	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	;;;; ALL POSSIBLE "CHANGE COLLISIONS", make the caveat here:
	.include SCR_TRIGGERED_COL_LOADS
noTriggerStateEvenCollisionPoint:

	;;; this is the first point.
	LDA updateCol_table
	BNE loadFirstPoint_ToSecondNametable
	LDA temp
	STA collisionTable,x ;; the collision table in RAM
	LDA newScreen
	AND #%00000001
	BNE loaded_FirstPoint ;; skip checking for prize counter.
	LDA temp
	CMP #COL_INDEX_PRIZE
	BNE +
	INC screenPrizeCounter
+
	JMP loaded_FirstPoint
loadFirstPoint_ToSecondNametable:
	LDA temp
	STA collisionTable2,x
	LDA newScreen
	AND #%00000001
	BEQ loaded_FirstPoint ;; skip checking for prize counter.
		LDA temp
	CMP #COL_INDEX_PRIZE
	BNE +
	INC screenPrizeCounter
+
loaded_FirstPoint:


	RTS
	
LoadOddCollisionPoint:

	LDA (collisionPointer),y
	AND #%00001111
	sta temp
	
	GetTrigger
	BEQ noTriggerStateOddCollisionPoint
	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	;;;; ALL POSSIBLE "CHANGE COLLISIONS", make the caveat here:
	.include SCR_TRIGGERED_COL_LOADS
noTriggerStateOddCollisionPoint:	

	LDA updateCol_table
	BNE update_CollisionTable2_2
	LDA temp
	STA collisionTable,x
	LDA newScreen
	AND #%00000001
	BNE loaded_SecondPoint ;; skip checking for prize counter.
		LDA temp
	CMP #COL_INDEX_PRIZE
	BNE +
	INC screenPrizeCounter
+
	
	JMP loaded_SecondPoint
update_CollisionTable2_2:
	LDA temp
	STA collisionTable2,x
	LDA newScreen
	AND #%00000001
	BEQ loaded_SecondPoint ;; skip checking for prize counter.
		LDA temp
	CMP #COL_INDEX_PRIZE
	BNE +
	INC screenPrizeCounter
+
	
loaded_SecondPoint:

	RTS


4/ In the "Project Settings > Script Settings", add a new script element (button "Add") , named it "Handle Triggered Collisions" with the code "SCR_TRIGGERED_COL_LOADS"

2019-01-16-11-11-44-Script-Define.png


And assign it the script "Routines\Basic\System\CheckTriggeredColLoads_DC.asm".


5/ And, assign the script "In the "Routines\Basic\System\CheckTriggeredTileLoads_DC.asm" to the "Handle Triggered Tiles" element.

2019-01-16-11-14-50-Project-Settings.png



6/ Modify the "KilledLastMonster_DC.asm" script in the "GameEngineData\Routines\Basic\ModuleScripts\MainScripts\AdventureGame" folder (or in "GameEngineData\Routines\Basic\ModuleScripts\MainScripts\ScrollingPlatform" if Scrolling Plaformer, ...), replacing with this code:
Code:
	;; Remove all the monster locks:
	ChangeAllTiles #COL_MONSTER_LOCK, #$00, #TILE_MONSTER_LOCK_OFF, #$00
	ChangeAllTiles #COL_MONSTER_LOCK, #$00, #TILE_MONSTER_LOCK_OFF, #$01

Check this script is assigned to the "Kill Last Monster" element:

2019-01-13-13-26-36-Project-Settings.png




Note: I will update my tutorial and the ZipScripts during the afternoon.
 
Wow its a mouthful. Let us know when the toturial and zip files are updated as this is kinda lost to me will look at it again some time to try to understand it better.
 
and its good :) I wanted to see if I can use tile 0 for my lock door and leave it same as my open door and it works fine.


Update: change it to something cooler lol so it looks better than being blocked by thin air.
 

Tishero

New member
I did the quick and easy install method and now I am getting these errors..

Routines\Basic\System\CheckTriggeredColLoads_DC.asm(16): Unknown label.
Routines\Basic\System\CheckTriggeredColLoads_DC.asm(16): Unknown label.
Routines\Basic\System\CheckTriggeredTileLoads_DC.asm(16): Unknown label.
 

dale_coop

Moderator
Staff member
What is your version of NESMaker?
You need to have NESMaker 4.1.3 ou more to use the "easy way" without any error ;)
If you have the 4.1.1, you can just "Help > Check for updates". If you're still in NESMaker 4.1.0, first, you have to update to the 4.1.1 following this: http://joshuafallon.com/nesmaker/?fbclid=IwAR1ZQaSV0CURv4vQv02i6BcKAM2u8zTpvwXfeye5uCeubdqc7lNThc2drnc

When you are using NESMaker 4.1.3 or 4.1.4, you can try again installing my ZipScript.
 

dale_coop

Moderator
Staff member
Redherring32 said:
Adding "COL_KEY", and "TILE_KEY" to user variables with a value of 0 did the trick.

Exactly, if you don't have one of the latest versions of NESMaker (4.1.3 or more), you will have to ad the user constants yourself in the "Project Settings > User Constants".
 
I'm not having luck with this.

I went over the tutorial 3 times to make sure I didn't miss anything, but I am getting this error when I try to compile:
'Routines\Metroidvania\\System\AssignBanks.asm(111): Value out of range.'

Clarification: Using Scrolling platformer module.

Edit:
I tried using both the zipscript and manually modifying my scripts. Same error.
 
Top Bottom