key issue

dale_coop

Moderator
Staff member
BentPawGames, you need to tell me, how can I easily test / reproduce that issue...
How do you test it?


EDIT: Ok, I understand how to test.. I was not really awaken this morning :p
 

dale_coop

Moderator
Staff member
I see the issue here... if I display the keys hud (number 1 digit):

Key1f2eb35a7d30b175.gif

The key variable is not correctly decreased when you open a door.
 

dale_coop

Moderator
Staff member
Change your LockdDoor.asm tile script, for that one:
Code:
	CPX player1_object
	BEQ +
	JMP ++
+
	LDA myKeys
	BNE + ;; if you have no more keys.
	JMP ++
+	
	LDA tileCollisionFlag
	BEQ +
	JMP ++
+
	;;; if you DO have more keys
	LDA #$01
	STA tileCollisionFlag
	ChangeTileAtCollision #$00, #TILE_OPENDOOR
	
	LDA myKeys
	SEC
	SBC #$01
	STA myKeys


	STA hudElementTilesToLoad
	UpdateHud HUD_myKeys

	PlaySound #SND_UNLOCK

	TriggerScreen screenType
	
	JMP +++ ;; it is no longer solid.
	
++
	LDA #TILE_SOLID
	STA tile_solidity
+++
	
	;; if you want it solid, declare it at the end


Now your keys/doos should work better.
 
Hmm so this fix seems to solve the problem when you start the game from the start point in what I sent you. But, when I start the game at the actual start screen, the same problem emerges, where:

door 1 is locked, get a key and it unlocks.
door 2 is locked, get a key and it unlocks.
door 3 is locked, don't need to get another key for it to unlock.
 

dale_coop

Moderator
Staff member
I tested, and didn't have any issue about keys/doors.... the door 3 is locked for me. (I played from the beginning...)
You could try displaying the myKeys variable on your hud (number "1" digit)
2019-11-22-12-35-19-NES-MAKER-4-1-5-Version-0x159-windermere-July-4th-fixing-key-issue-MST.png

And check the moment/action it goes to "1", during game play (when getting a key... then back to 0 when you use it).
 
Hmm so a weird thing happened.

I displayed the number of keys as you suggested. All was working fine.

I approached the 3rd locked door without a key (display said zero keys) and I still had the same problem.

I restarted the game and did it again. Then, it was locked, like it should be. But then I approached it from the side and it opened. So I went back and fiddled around with the first locked door. It's doesn't "open" (the tile doesn't disappear) but I can glitch through it without a key.

I wonder if there is something weird about having a warp tile right on top of a locked tile? Or maybe something with the collision where, given the size of my character, there is some collision with the corner of the warp tile? I dunno. I'm gonna do some digging though, and worst case scenario just redesign the rooms a bit to see if I can keep it from happening :)
 

dale_coop

Moderator
Staff member
Oh you right, it's a collision issue...
when you try on the right side of the locked door, the top left bounding box of the player might touch the warp tile, so he warps!
It will not be easy to fix in the engine...

A workaround could be to make the bottom of the door a "0 null walkable", the top of the door a "4 - Lock door" and tile above the door the "6 - warp"?
 
Top Bottom