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

dale_coop

Moderator
Staff member
Check my tutorials on page 1... it's all updated, with the EASY way to install/update all this!
 

vanderblade

Active member
At first effort, I'm getting this compiler error.

Routines\Basic\ModuleScripts\MainScripts\AdventureGame\Handle_CheckForMonsters.asm(13): Label already defined.
Routines\Basic\ModuleScripts\MainScripts\AdventureGame\Handle_CheckForMonsters.asm(21): Label already defined.
Routines\Basic\ModuleScripts\MainScripts\AdventureGame\Handle_CheckForMonsters.asm(27): Label already defined.
Routines\Basic\ModuleScripts\MainScripts\AdventureGame\Handle_CheckForMonsters.asm(31): Label already defined.
demo.txt written.
 

dale_coop

Moderator
Staff member
Could you share your script?
And a screenshot of your "Project Settings > Script settings"?

Looks like this code already somewhere (or duplicate) in your project.
 

dale_coop

Moderator
Staff member
Ok no sorry... my mistake (might be too late for me now)... sorry, man ;)


Here your "Handle_CheckForTriggers":

Code:
;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;



		LDA screenType
		;; divide by 32
		LSR
		LSR
		LSR 
		;LSR
		;LSR
		;;; now we have the right *byte* out of the 32 needed for 256 screen bytes
		TAY
		LDA screenTriggers,y ;; now the rigth bit is loaded into the accum
		STA temp
		LDA screenType
		AND #%00000111 ;; look at last bits to know what bit to check, 0-7
		TAX
		LDA ValToBitTable_inverse,x
		AND temp
		BNE +
		JMP thisScreenIsNotTriggered_onScreenLoad
	+
		;; this screen IS triggered
DoDestroyAllTriggerTiles:	
	;;; HERE:
	;;; all of the tiles you would like to change when this screen is loaded.
	;;; do this routine for:
	;;; FIRST, GET RID OF LOCKS:
	LDA showingNametable
	STA temp
	ChangeAllTilesDirect #COL_LOCK, #$00, #TILE_OPENDOOR, temp
	;;; NOW, GET RID OF KEY TILES:
	LDA showingNametable
	STA temp
	ChangeAllTilesDirect #COL_KEY, #$00, #$00, temp ;; arg2 = floor, null, etc
	;ChangeAllTiles #COL_KEY, #$00, #$00, temp
	

thisScreenIsNotTriggered_onScreenLoad:


And here your "Handle_CheckForMonsters":

Code:
;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;
	;; monster bit is: #%00001000 
;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;To change collision type and graphic
	CountObjects #%00001000, #$00 ;; count monsters.
	LDA monsterCounter
	CLC
	BEQ doNoMoreMonsterCode
	JMP stillMonstersOnScreen_onScreenload
doNoMoreMonsterCode
	
	;;; all of the tiles you would like to change when this screen is loaded.
	;;; do this routine for:
	;;; FIRST, GET RID OF LOCKS:
	LDA update_screen
	BNE screenIsOffForMonsterCheck
	JMP doScreenOnMonsterCheck
screenIsOffForMonsterCheck:
	
	LDA showingNametable
	STA temp
	ChangeAllTilesDirect #COL_MONSTER_LOCK, #$00, #TILE_MONSTER_LOCK_OFF, temp
	JMP stillMonstersOnScreen_onScreenload
doScreenOnMonsterCheck:
	

	;;;;;===================
stillMonstersOnScreen_onScreenload:
;;;;  end what to do if no more objects
 

vanderblade

Active member
Okay. No more error, but...you guessed it, my lock blocks are still staying on the screen when I reenter a room.

I am using a tile that is assigned as a "4- Locked Door." This is the tile that is the issue.

Also, I want my screens to trigger and stay triggered. So where exactly do I re-add the TriggerScreen screentype line to make that happen?
 

Attachments

  • Screenshot (80).png
    Screenshot (80).png
    329.9 KB · Views: 1,521

dale_coop

Moderator
Staff member
Check script assigned to the "Killed Last Monster", it should looks like
Code:
	;; Remove all the monster locks:
	LDA showingNametable
	STA temp
	ChangeAllTiles #COL_MONSTER_LOCK, #$00, #TILE_MONSTER_LOCK_OFF, temp

If you REALLY want to trigger it should be:
Code:
	;; Trigger the current screen:
	TriggerScreen screenType
	
	;; Remove all the monster locks:
	LDA showingNametable
	STA temp
	ChangeAllTiles #COL_MONSTER_LOCK, #$00, #TILE_MONSTER_LOCK_OFF, temp

That means if you kill all the monsters your screen will be triggered.
When you (re) enter into a triggered screen, your normal monsters will not be there, so your monster tiles will be removed (of course) AND your doors will be removed too (even you didn't unlock them with the key. Keep that in mind).
 

vanderblade

Active member
With this code implemented, not only do the lock block tiles remain when re-entering a screen, but now so do the monster locks. :(
 

vanderblade

Active member
No, the monsters stay gone.

What's weird is that the monster lock tile graphic for one room stays gone but for other rooms in the dungeon, they come back. So confused...
 

vanderblade

Active member
My HUD is on every screen.

First is a shot before picking up the key and unlocking the key block.
Next is a shot of returning to the room to find the key block still displaying (but walkable).
Next is a shot of monster locks staying gone.
Finally, a shot, in the same dungeon, where the monster locks display still (but walkable).
 

Attachments

  • Screenshot (84).png
    Screenshot (84).png
    81 KB · Views: 2,810
  • Screenshot (83).png
    Screenshot (83).png
    82.6 KB · Views: 2,809
  • Screenshot (82).png
    Screenshot (82).png
    82 KB · Views: 2,808
  • Screenshot (81).png
    Screenshot (81).png
    82.4 KB · Views: 2,808

dale_coop

Moderator
Staff member
Interesting... looks like it's your key/door the problem, not the monster lock.
(all your screens have a different screen-type value?)
 

dale_coop

Moderator
Staff member
SOOOOOooooo frustrating
But... I think, I found what's happening, here.

For the key/door system you have to set some user constants, to have it working correctly.
I will do you some screenshots...
 

dale_coop

Moderator
Staff member
To make the door/key work correctly, you need to set the TILE_INDEX_LOCK (the door) in the "Project Settings > User Constants" (and it has nothing to do with the monster locks... You would have exactly the same issue with a freshly unzipped NESMaker 4.1)

The most difficult it to set this constant correctly ;)

In your tileset, (pixel editor, you have count the 8x8 tiles... (from 0 to 254... from left to right, and top to bottom)... to get the tile index.

2019-01-14-20-44-37-NES-MAKER-4-1-1-Version-0x158-Mon-Jeu-Aventure-MST.png


--> If you are using the tileset that comes with the tutorial, your door lock index might be "72". Then in the "Project Settings > User Constants", set the TILE_INDEX_LOCK to "72".

Your doors should work better.
 

vanderblade

Active member
Haha. That solved the lock block issue.

But since I used your new code for monster locks, now I have the problem of those not going away, too. Is this a user constant issue as well? With your old code, they worked perfectly.
 

vanderblade

Active member
As you can see in the screenshots, with the new code some of the monster lock graphic tiles come back when you re-enter the screen. This was not the case with your old fix.
 

dale_coop

Moderator
Staff member
Could we check again everything... :
- Your "COL_MONSTER_LOCK" value is "5" in the "Project Settings > User Constants" ?
- Your "TILE_MONSTER_LOCK_OFF" value is "0" in the "Project Settings > User Constants" ?
- What is the script assigned to the "Handle Monster Locks" element in the "Project Settings > Script Settings"?
- Could you share (again?) the content of that script?
- What is the script assigned to the "Handle Killed Last Monster" element in the "Project Settings > Script Settings"?
- Could you share (again?) the content of that script?
- You did not make any modification in the CheckTriggeredLoads.asm script?
- Could you share also the content of that script, just in case?

You might have something incorrect somewhere...
(I can't reproduce your problem on my adventure tutorial game)
 

vanderblade

Active member
1. COL_MONSTER_LOCK" value is set to "5" in the "Project Settings > User Constants".
2. TILE_MONSTER_LOCK_OFF" value is set to "0" in the "Project Settings > User Constants".
3. The Handle_CheckForMonsters_DC.asm script is assigned to to the "Handle Monster Locks" element in the "Project Settings > Script Settings".
4. The KilledLastMonster_DC.asm script is assigned to the "Handle Killed Last Monster" element in the "Project Settings > Script Settings".

Here is the Handle_CheckForMonsters_DC.asm.

Code:
;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;
	;; monster bit is: #%00001000 
;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;To change collision type and graphic
	CountObjects #%00001000, #$00 ;; count monsters.
	LDA monsterCounter
	CLC
	BEQ doNoMoreMonsterCode
	JMP stillMonstersOnScreen_onScreenload
doNoMoreMonsterCode
	
	;;; all of the tiles you would like to change when this screen is loaded.
	;;; do this routine for:
	;;; FIRST, GET RID OF LOCKS:
	LDA update_screen
	BNE screenIsOffForMonsterCheck
	JMP doScreenOnMonsterCheck
screenIsOffForMonsterCheck:
	
	LDA showingNametable
	STA temp
	ChangeAllTilesDirect #COL_MONSTER_LOCK, #$00, #TILE_MONSTER_LOCK_OFF, temp
	JMP stillMonstersOnScreen_onScreenload
doScreenOnMonsterCheck:
	

	;;;;;===================
stillMonstersOnScreen_onScreenload:
;;;;  end what to do if no more objects

Here is the KilledLastMonster_DC.asm.

Code:
;; Trigger the current screen:
	TriggerScreen screenType
	
	;; Remove all the monster locks:
	LDA showingNametable
	STA temp
	ChangeAllTiles #COL_MONSTER_LOCK, #$00, #TILE_MONSTER_LOCK_OFF, temp
 
Top Bottom