MonsterLock variant?

So, for my game I need a "MonsterLock" variant, except I want it to open when "myMoney" is 5 or greater.
The best I can think of is that it requires the use of "BCS", as for the rest I have no clue. :lol:

Thanks in advance for any help!
 

dale_coop

Moderator
Staff member
Yeah right, you would need to use the "BSC" opcode to check tht amount of money.
Another thing is the myMoney you would need to check if >100 or >10 before check greater or equal to 5.

(Someone should correct me on that, because not 100%sure and can"t test right now... but) the script would look like, that:
Code:
	LDA #TILE_SOLID
	STA tile_solidity
	;; if you want it solid, declare it at the end	

	;; is collision position loaded into y?
	CPX player1_object
	BNE +
	
	;; check if money greater or equal to 100
	LDA myMoney+2
	BNE canUnlockDoor
	;; else
	;; check if money greater or equal to 10
	LDA myMoney+1
	BNE canUnlockDoor
	;; else
	;; check if money greater or equal to 5
	LDA myMoney
	CMP #$05
	BCS canUnlockDoor
	;; else, we skip everything
	JMP +

canUnlockDoor:
	;; uncomment the foloowing lines if you want substract 5 from myMoney:
	;;SubtractValue #$03, myMoney, #$05
	;;LDA #$01 ;; amount of score places?
	;;STA hudElementTilesToLoad
	;;LDA DrawHudBytes
	;;ORA #HUD_myMoney
	;;STA DrawHudBytes
	
	ChangeTileAtCollision #$02, underSecret
	
	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	;;; IF YOU WANT THE LOCK TO STAY GONE, Trigger the screen.
	;;; if not, comment this out.
	TriggerScreen screenType
	PlaySound #SFX_LOCKED_DOOR
	
+
 
dale_coop said:
Yeah right, you would need to use the "BSC" opcode to check tht amount of money.
Another thing is the myMoney you would need to check if >100 or >10 before check greater or equal to 5.

(Someone should correct me on that, because not 100%sure and can"t test right now... but) the script would look like, that:

It works, sorta... it acts like a "Warp to Screen" tile when "myMoney" is greater than or equal to 5.
 

dale_coop

Moderator
Staff member
The script just modify the doorLock tile collision behavior.

Need to go further... and might not be so simple.
 
dale_coop said:
The script just modify the doorLock tile collision behavior.

Need to go further... and might not be so simple.

Which script, and what would I change in it? (I'm not good with asm yet.)
 

dale_coop

Moderator
Staff member
Redherring32 said:
dale_coop said:
The script just modify the doorLock tile collision behavior.

Need to go further... and might not be so simple.

Which script, and what would I change in it? (I'm not good with asm yet.)

...I am not sure.

Normally, the keys open the locked doors. The key pickup triggers the screen and all the screens with the same screen-type (so, if the screen where the locked door is same type, the door is automatically opened, because triggered).
But for money... it would be impossible to use the same system, I think. Because you don't know where is the 5th coin, I mean on which screen it will be.

Would need to modify the HandleScreenLoads.asm script (like the updateNametable_checkForTriggers subroutine, and the FindLockedDoorTilesTarget_onScreenLoad) but it would required a lot of modifications for the behavior you want... don't know how to deal with those doors in that context, sorry.
 
Thanks for the effort anyway Dale!
Much appreciated as always.
Edit: for the record, the "myMoney" variable has been hijacked for a different purpose than money.
 

dale_coop

Moderator
Staff member
Redherring32 said:
Edit: for the record, the "myMoney" variable has been hijacked for a different purpose than money.

Ok, like items? or gems? or keys maybe? cats? ;)
And what represents the door in your game? The end of the level? Access to the boss room?

Because if the door is an acces to end or boss room, or something equivalent, you could trigger the screens (where your items/cats are) when you collect 5 of them, maybe?

If you want to try that, modify or make a new "Powerup_IncreaseMoney.asm" script (that will trigger the screen when you gotat least 5 money/cats), something like this:
Code:
	;; incresease the money by 1
	AddValue #$03, myMoney, #$01, #$00

	;; check if money greater or equal to 100
	LDA myMoney+2
	BNE canUnlockDoor
	;; else
	;; check if money greater or equal to 10
	LDA myMoney+1
	BNE canUnlockDoor
	;; else
	;; check if money greater or equal to 5
	LDA myMoney
	CMP #$05
	BCS canUnlockDoor
	;; else, we skip everything
	JMP +

canUnlockDoor:
	;; uncomment the foloowing lines if you want substract 5 from myMoney:
	;;SubtractValue #$03, myMoney, #$05

	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	;;; IF YOU WANT THE LOCK TO STAY GONE, Trigger the screen.
	;;; if not, comment this out.
	TriggerScreen screenType
	PlaySound #SFX_LOCKED_DOOR
	
+
	;;;;;;;;;;;;; UPDATE HUD

	LDA #$01 ;; amount of score places?
	STA hudElementTilesToLoad
	LDA DrawHudBytes
	ORA #HUD_myKeys
	STA DrawHudBytes

And be sure this script is assigned to the Power Up 3 (...if i remember it well) in your "Project scripts > Script settings" .


note: when you modify scripts, dont't forget to make a copy/backup of the original ones.
 
Thanks a bunch, I'll try it tonight!
"myMoney" was used for the "cat counter" and I want a boss door to open when the player finds 5 cats.

Edit: I also want 2 more of these doors, one that opens at 10 cats, and one that opens at 15.
Is there a way to do that?
 
How do I implement this code?
I tried replacing a blank powerup script with it, but I get this error:

ezIDZko.png


Again thanks for all the help Dale!
 

dale_coop

Moderator
Staff member
You can make any new file (copy paste, ... then assign the new script in Project Settings > Script settings).

Oh I see, the error is because I used "continueUnlockDoor" twice, here a fix (just rename the label):
Code:
	;; incresease the money by 1
	AddValue #$03, myMoney, #$01, #$00

	;; check if money greater or equal to 100
	LDA myMoney+2
	BNE canPickupUnlockDoor
	;; else
	;; check if money greater or equal to 10
	LDA myMoney+1
	BNE canPickupUnlockDoor
	;; else
	;; check if money greater or equal to 5
	LDA myMoney
	CMP #$05
	BCS canPickupUnlockDoor
	;; else, we skip everything
	JMP +

canPickupUnlockDoor:
	;; uncomment the foloowing lines if you want substract 5 from myMoney:
	;;SubtractValue #$03, myMoney, #$05

	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	;;; IF YOU WANT THE LOCK TO STAY GONE, Trigger the screen.
	;;; if not, comment this out.
	TriggerScreen screenType
	PlaySound #SFX_LOCKED_DOOR
	
+
	;;;;;;;;;;;;; UPDATE HUD

	LDA #$01 ;; amount of score places?
	STA hudElementTilesToLoad
	LDA DrawHudBytes
	ORA #HUD_myMoney
	STA DrawHudBytes
 

dale_coop

Moderator
Staff member
When a screen is triggered (calling the TriggerScreen macro with a script, for example), every screen that have the same "screen type" number will be triggered too.
You can set "screen type" number in the "Screen Info" dialog.

I would recommand you to watch again the adventure tutorial video that explains that concept (doors, keys, screen trigger, ...).
 

dale_coop

Moderator
Staff member
And a small modification on the pickup script, if the 5th cat is on the same screen that your door, you could add "JSR updateNametable_checkForTriggers" to call the remove all triggers-related tiles (the door in your case).

PS: and I fixed a small mistake I wrote in the previous script (for the HUD update).

Here the full script:
Code:
	;; incresease the money by 1
	AddValue #$03, myMoney, #$01, #$00

	;; check if money greater or equal to 100
	LDA myMoney+2
	BNE canPickupUnlockDoor
	;; else
	;; check if money greater or equal to 10
	LDA myMoney+1
	BNE canPickupUnlockDoor
	;; else
	;; check if money greater or equal to 5
	LDA myMoney
	CMP #$05
	BCS canPickupUnlockDoor
	;; else, we skip everything
	JMP +

canPickupUnlockDoor:
	;; uncomment the foloowing lines if you want substract 5 from myMoney:
	;;SubtractValue #$03, myMoney, #$05

	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	;;; IF YOU WANT THE LOCK TO STAY GONE, Trigger the screen.
	;;; if not, comment this out.
	TriggerScreen screenType
	PlaySound #SFX_LOCKED_DOOR
	
	;; remove all door tiles now :
	JSR updateNametable_checkForTriggers
	
+
	;;;;;;;;;;;;; UPDATE HUD

	LDA #$01 ;; amount of score places?
	STA hudElementTilesToLoad
	LDA DrawHudBytes
	ORA #HUD_myMoney
	STA DrawHudBytes
 

dale_coop

Moderator
Staff member
Yes, it trigger the current screen (when the player takes the cat), then every other screens that are the same "screen-type" will be triggered too.
 
dale_coop said:
Yes, it trigger the current screen (when the player takes the cat), then every other screens that are the same "screen-type" will be triggered too.

I used the script, but it still changes to a warp.
Edit: I'll PM you my rom so you can see what I mean.
 
Top Bottom