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

Post Reply
User avatar
dale_coop
Posts: 3090
Joined: Fri Feb 16, 2018 7:05 am
Location: France

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

Post by dale_coop » Thu Jan 10, 2019 11:01 pm

After hours of fixing scripts, testing, I figured how to brink back the Monster Locks (tiles that are removed when all the monsters are killed).
Here's how to do...

Here, for the Adventure Module --> http://nesmakers.com/viewtopic.php?p=10841#p10841


ADD MONSTER LOCK FOR THE PLATFORMER MODULE (Basic core)

Image


THE EASY WAY (NESMaker 4.1.3)
With a ZipScript patch:

1/ Download the ZipScript file from here: https://drive.google.com/open?id=1FtogE ... DPART-B_Ai

2/ On your scrolling game project, select the "Project > Run Project Script" menu:

Image

And select the "ScrollingPlatform_MonsterLocks.zip" you just downloaded. Validate and after confirming the warnings message, you should have the patch installed:

Image

3/ In your "Project Settings > User Constants", check the "TILE_MONSTER_LOCK" value and set the value corresponding to YOUR monster lock tile (in your tileset... I just count the 8x8 tiles in the tileset starting from 0. For example, mine in the GIF is the 46 ).

Now, the monster tiles should work.
If you have error to if the patch doesn't work, you could try the normal manual way.



THE NORMAL MANUAL WAY
Doing manually the modifications in some scripts:

1/ In your "Project Settings > Project Labels", renamed the unused Tile Type "14 - NULL" to "14 - Monster Lock".

Image


2/ In your "Project Settings > User Constants", add a constant named "COL_MONSTER_LOCK" with a value of "14" (because we choosed to use 14 for our Monster Lock)

Image

Still in your "Project Settings > User Constants", add also:
- a new constant named "TILE_MONSTER_LOCK" with a value "46" (the monster block tile in your tileset... mine is the 46. I just count the 8x8 tiles in the tileset starting from 0)
- a new constant named "TILE_MONSTER_LOCK_OFF" with a value of "0" (the tile used when the monsterLock is removed)
- a new constant named "TILE_OPENDOOR" with a value "0"

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

Code: Select all

	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
++

4/ Make a new script "CheckTriggeredColLoads_DC.asm" in the "GameEngineData\Routines\Basic\System" folder, with:

Code: Select all

	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.
++	

5/ 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: Select all

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

6/ Make a new script, named "KilledLastMonster_DC.asm" in your "GameEngineData\Routines\Basic\ModuleScripts\MainScripts\ScrollingPlatformer" folder, with that code:

Code: Select all

	;; 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	

7/ 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"

Image

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


8/ Also, assign the script "Routines\Basic\System\CheckTriggeredTileLoads_DC.asm" to the "Handle Triggered Tiles" element.

Image


9/ And, assign the "KilledLastMonster_DC.asm" to the "Kill Last Monster" element:

Image


10/ Duplicate the "HandleSpriteWeapon.asm" script located in your "GameEngineData\Routines\Basic\ModuleScripts\MainScripts\ScrollingPlatformer" folder, and name it "HandleSpriteWeapon_DC.asm".

Modify your new "HandleSpriteWeapon_DC.asm" script, around line 75, from that:

Code: Select all

		; LDA DrawHudBytes
		; ora #HUD_myScore
		; STA DrawHudBytes
	UpdateHud HUD_myScore
++
To that:

Code: Select all

		; LDA DrawHudBytes
		; ora #HUD_myScore
		; STA DrawHudBytes
	UpdateHud HUD_myScore
	
	;; check for monter locks begin:
	CountObjects #%00001000, #$00
	LDA monsterCounter
	CLC
	BEQ +
	JMP ++
	+
		.include SCR_KILLED_LAST_MONSTER
	;; check for monter locks end.
	
++
	INX 

11/ In your "Project Settings > Script Settings", assign the "HandleSpriteWeapon_DC.asm" script to the "Use Sprite Based Weapon" element:

Image


12/ Modify the "HandleHurtMonster.asm" script, that is located in the "GameEngineData\Routines\Basic\ModuleScripts\HurtWinLoseDeath" folder, around line 80, from that:

Code: Select all

		CountObjects #$00001000, #$00
		BEQ +
		JMP ++
	+
		.include SCR_KILLED_LAST_MONSTER
To that:

Code: Select all

		CountObjects #%00001000, #$00
		LDA monsterCounter
		CLC
		BEQ +
		JMP ++
	+
		.include SCR_KILLED_LAST_MONSTER

Voilà, now you can create your monster lock tiles, put it on your screen with monsters... and test
As usual the script might not be perfect, it might be some errors, might cause some issues... feel free to make modifications, fix it, ... or not using it ;)

Note: if you are using the "Jump On Kills", you have one step more, here: http://nesmakers.com/viewtopic.php?p=10807#p10807


And here, for the Adventure Module --->> http://nesmakers.com/viewtopic.php?p=10841#p10841


UPDATES
2019/01/19:
Updated the ZipScript patch versions for NESMaker 4.1.3 (that support user constants,... now)
2019/01/16:
Added some user constants, the checkTriggeredTileLoads, checkTriggeredTColLoads, LoadCollisionBytes scripts, made modifications in the KilledLastMonster_DC and removed the Handle_CheckForMonsters_DC that is no more needed (to fix the odd number screen issue).
Updated the ZipScript patch versions.
2019/01/13:
Fixed a problem with the sprite-based weapon, that was when you killed the 1st monster the locks was removed.
Modified the script assigned to "Kill Last Monster", to not trigger the screen, by default (like in previous NESMaker versions).
Added the ZipScript patch versions.
-----
Sorry about my poor english
All I need: A Damn Fine Cup of Coffee
My games: PRESS START GAME / UNDERGROUND ADVENTURE / UNDERGROUND ADVENTURE (Arcade version - Byte-Off-2019)
User avatar
jsherman
Posts: 292
Joined: Sun Apr 22, 2018 11:25 am
Location: Cleveland OH

Re: [4.1] Adding Monster Lock in the Platformer module

Post by jsherman » Thu Jan 10, 2019 11:51 pm

You are a machine!

I haven't tested this yet, but wanted to give you my gratitude.
"Turtle Rescue" updates can be found here: viewtopic.php?f=13&t=112
For more in-depth updates, please follow GossipTurtle on Twitter! https://twitter.com/TurtleRescueNES
User avatar
dale_coop
Posts: 3090
Joined: Fri Feb 16, 2018 7:05 am
Location: France

Re: [4.1] Adding Monster Lock in the Platformer module

Post by dale_coop » Fri Jan 11, 2019 12:05 am

If you are using the " Jump On Kills" (4.1) from http://nesmakers.com/viewtopic.php?f=3&t=1748

Modify your "HandleObjectCollisions_withJumpOnKills.asm" script, located in the "GameEngineData\Routines\Basic\ModuleScripts\MainScripts\ScrollingPlatformer" folder, around line 191, replace that :

Code: Select all

;;---- Jump On Kills code begin ----
	TYA
	STA tempy
	LDX tempx
	LDA Object_vulnerability,x
	AND #%00010000
	BNE jumpOnMonster
	LDX player1_object
	JMP dontJumpOnMonster
jumpOnMonster:
	LDX player1_object
	;TXA
	;STA tempx
	;JMP playerWasHurtDuringCollision
	;LDX player1_object
	LDA selfBottom
	CMP otherCenterY
	BCS dontJumpOnMonster
	;;; JUMP ON MONSTER
	LDX player1_object
	LDA #$00
	SEC
	SBC #$04
	STA Object_v_speed_hi,x
	LDX tempx
	DeactivateCurrentObject
	
	PlaySound #SND_SPLAT
	
	LDY tempy
	;; INCREASE SCORE
	AddValue #$08, myScore, #$01, #$00
	UpdateHud HUD_myScore	
	JMP playerWasHurtDuringCollision ;; just skips collision
dontJumpOnMonster:
;;---- Jump On Kills code end ----
With that:

Code: Select all

;;---- Jump On Kills code begin ----
	TYA
	STA tempy
	LDX tempx
	LDA Object_vulnerability,x
	AND #%00010000
	BNE jumpOnMonster
	LDX player1_object
	JMP dontJumpOnMonster
jumpOnMonster:
	LDX player1_object
	;TXA
	;STA tempx
	;JMP playerWasHurtDuringCollision
	;LDX player1_object
	LDA selfBottom
	CMP otherCenterY
	BCC isJumpingOnMonster
	JMP dontJumpOnMonster
isJumpingOnMonster:
	;;; JUMP ON MONSTER
	LDX player1_object
	LDA #$00
	SEC
	SBC #$04
	STA Object_v_speed_hi,x
	LDX tempx
	DeactivateCurrentObject
	PlaySound #SND_SPLAT
	
	LDY tempy
	;; INCREASE SCORE
	AddValue #$08, myScore, #$01, #$00
	UpdateHud HUD_myScore
	
	;; check for monter locks begin:
	CountObjects #%00001000, #$00
	LDA monsterCounter
	CLC
	BEQ +
	JMP playerWasHurtDuringCollision
	+
	.include SCR_KILLED_LAST_MONSTER
	;; check for monter locks end.

	JMP playerWasHurtDuringCollision ;; just skips collision
dontJumpOnMonster:
;;---- Jump On Kills code end ----
-----
Sorry about my poor english
All I need: A Damn Fine Cup of Coffee
My games: PRESS START GAME / UNDERGROUND ADVENTURE / UNDERGROUND ADVENTURE (Arcade version - Byte-Off-2019)
User avatar
dale_coop
Posts: 3090
Joined: Fri Feb 16, 2018 7:05 am
Location: France

Re: [4.1] Adding Monster Lock in the Platformer module

Post by dale_coop » Fri Jan 11, 2019 12:10 am

jsherman wrote:
Thu Jan 10, 2019 11:51 pm
You are a machine!

I haven't tested this yet, but wanted to give you my gratitude.
Ah ah thanks ;)
It's nothing perfect nor even very clean... It's just quick fix (fixing while I am using it).
I might be able code something cleaner, if I 'd spend more time on it. But Joe will surely make that work in a next version.
So in the mean time....
-----
Sorry about my poor english
All I need: A Damn Fine Cup of Coffee
My games: PRESS START GAME / UNDERGROUND ADVENTURE / UNDERGROUND ADVENTURE (Arcade version - Byte-Off-2019)
vanderblade
Posts: 65
Joined: Mon Jan 07, 2019 5:20 am

Re: [4.1] Adding Monster Lock in the Platformer module

Post by vanderblade » Fri Jan 11, 2019 1:13 am

Did you post how to "fix" monster lock in the adventure module?
Gilbertmaxter
Posts: 78
Joined: Tue Oct 16, 2018 3:04 am

Re: [4.1] Adding Monster Lock in the Platformer module

Post by Gilbertmaxter » Fri Jan 11, 2019 3:17 am

I seem to be getting unknown label errors for the Handle_CheckForMonsters_DC.asm at line 15

I am getting an unknown label error at the following lines.
22
68
78
89
102

Image


where did I go wrong ?
I was able to add it into the handle monster lock in the script settings.
is there a step I missed ?
User avatar
dale_coop
Posts: 3090
Joined: Fri Feb 16, 2018 7:05 am
Location: France

Re: [4.1] Adding Monster Lock in the Platformer module

Post by dale_coop » Fri Jan 11, 2019 11:34 am

Have you set your User Constants as written in the 5/ of my tutorial?
-----
Sorry about my poor english
All I need: A Damn Fine Cup of Coffee
My games: PRESS START GAME / UNDERGROUND ADVENTURE / UNDERGROUND ADVENTURE (Arcade version - Byte-Off-2019)
vanderblade
Posts: 65
Joined: Mon Jan 07, 2019 5:20 am

Re: [4.1] Adding Monster Lock in the Platformer module

Post by vanderblade » Fri Jan 11, 2019 2:03 pm

Does this work with the adventure module as well? If not, how do we fix monster lock for that?
User avatar
dale_coop
Posts: 3090
Joined: Fri Feb 16, 2018 7:05 am
Location: France

Re: [4.1] Adding Monster Lock in the Platformer module

Post by dale_coop » Fri Jan 11, 2019 3:10 pm

ADD MONSTER LOCK FOR THE ADVENTURE MODULE (Basic core)

Image

THE EASY WAY (NESMaker 4.1.3)
With a ZipScript patch:

1/ Download the ZipScript file from here: https://drive.google.com/open?id=1RQTxv ... jNjVTeiFuj

2/ On your scrolling game project, select the "Project > Run Project Script" menu:

Image

And select the "Adventure_MonsterLocks.zip" you just downloaded. Validate and after confirming the warnings message, you should have the patch installed:

Image


3/ In your "Project Settings > User Constants", check that check your "TILE_MONSTER_LOCK" value and set the value corresponding to YOUR monster lock tile (in your tileset... I just count the 8x8 tiles in the tileset starting from 0. For example, mine in the GIF is the 70).

Now, the monster tiles should work.
If you have error to if the patch doesn't work, you could try the normal manual way.



THE NORMAL MANUAL WAY
Doing manually the modifications in some scripts:

1/ In your "Project Settings > User Constants", check that you have a constant named "COL_MONSTER_LOCK" with a value of "5" (the monster lock tile type).
And add:
- a new constant named "TILE_MONSTER_LOCK" with a value "70" (the monster block tile in your tileset... mine is the 70. I just count the 8x8 tiles in the tileset starting from 0)
- a new constant named "TILE_MONSTER_LOCK_OFF" with a value of "0" (the tile used when the monsterLock is removed)
- a new constant named "TILE_OPENDOOR" with a value "0"


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

Code: Select all

	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: Select all

	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.
++	

4/ 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: Select all

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

5/ Make a new script, named "KilledLastMonster_DC.asm" in your "GameEngineData\Routines\Basic\ModuleScripts\MainScripts\AdventureGame" folder, with that code:

Code: Select all

	;; 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	

7/ 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"

Image

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


6/ Also, assign the script "Routines\Basic\System\CheckTriggeredTileLoads_DC.asm" to the "Handle Triggered Tiles" element.

Image


7/ And, assign the "KilledLastMonster_DC.asm" to the "Kill Last Monster" element:

Image


8/ Modify the "HandleSpriteWeapon_Alternate.asm" script (or make a new one if you don't have it), replacing with this code:

Code: Select all

	GetCurrentActionType player1_object
	CMP #$02 ;; attack state
	BEQ checkSpriteWeapon
	JMP skipSpriteWeaponCheck
checkSpriteWeapon:

	;;;;;;;;;;;;;;;;;;;;;;;;;
	;;here it did equal the melee attack pose.
	LDX player1_object
	LDA Object_movement,x
	AND #%00000111
	TAY ;; direction for offset table index
	LDA Object_x_hi,x
    ;;; offset x for creation
    CLC
    ADC weaponOffsetTableX,y
	STA selfRight
	SEC 
    SBC #$08 ;; width of weapon 
	STA selfLeft
	
	LDA Object_y_hi,x
    ;;; offset x for creation
    CLC
    ADC weaponOffsetTableY,y
	STA selfBottom
	SEC 
    SBC #$08 ;; width of weapon 
	STA selfTop
	;; run through objects.
	
	LDX #$00	
DoMonsterWeaponSpriteLoop:
	LDA Object_flags,x
	AND #%00001000
	BNE +
	JMP ++
+
	JSR GetOtherCollisionBox
	LDA selfRight
	CMP otherLeft
	BCS + ;; no player object collision
	JMP ++
+
	LDA otherRight
	CMP selfLeft
	BCS +
	JMP ++
+
	
	LDA otherBottom
	CMP selfTop
	BCS +
	JMP ++
+
	LDA selfBottom
	CMP otherTop
	BCS +
	JMP ++
+
;; ok, there is a collision with an monster object, from HERE :
;;; what should we do with the monster?
		LDA Object_vulnerability,x
		AND #%00000100 ;; is it weapon immune?
		BEQ notWeaponImmuneSpriteWeapon
		;PlaySound #SFX_MISS
		JMP skipHurtingMonsterAndSoundSpriteWeapon
    notWeaponImmuneSpriteWeapon:
		LDA Object_status,x
		AND #HURT_STATUS_MASK
		BEQ dontskipHurtingMonsterSpriteWeapon
		JMP skipHurtingMonsterSpriteWeapon
    dontskipHurtingMonsterSpriteWeapon:
		LDA Object_status,x
		ORA #%00000001
		STA Object_status,x
		LDA #HURT_TIMER
		STA Object_timer_0,x
		;;; assume idle is in step 0
		ChangeObjectState #$00,#$02
		;;;; unfortunately this recoil is backwards
		LDA Object_status,x
		AND #%00000100
		BNE skipRecoilBecauseOnEdgeSpriteWeapon
		LDA Object_vulnerability,x
		AND #%00001000 
		BNE skipRecoilBecauseOnEdgeSpriteWeapon ;; skip recoil because bit is flipped to ignore recoil

		LDA selfCenterX
		STA recoil_otherX
		LDA selfCenterY
		STA recoil_otherY
		LDA otherCenterX
		STA recoil_selfX
		LDA otherCenterY
		STA recoil_selfY
		JSR DetermineRecoilDirection
    skipRecoilBecauseOnEdgeSpriteWeapon:
		LDA Object_health,x
		SEC
		SBC #$01
		CMP #$01
		BCC isMonsterDeathSpriteWeapon:
		JMP notMonsterDeathSpriteWeapon
		isMonsterDeathSpriteWeapon:

		;LDA Object_x_hi,x
		;STA temp
		;LDA Object_y_hi,x
		;STA temp1
		DeactivateCurrentObject
		;CreateObject temp, temp1, #OBJ_MONSTER_DEATH, #$00, currentNametable	;; create a "pouf" death effect
		PlaySound #SND_SPLAT
		TXA
		STA tempx
		AddValue #$08, myScore, #$01, #$00

		UpdateHud HUD_myScore
		LDX tempx

		JSR HandleDrops
		JSR HandleToggleScrolling
			
		;; check for monter locks begin:
		CountObjects #%00001000, #$00
		LDA monsterCounter
		CLC
		BEQ +
		JMP ++
	+
		.include SCR_KILLED_LAST_MONSTER
		JMP skipHurtingMonsterSpriteWeapon
    notMonsterDeathSpriteWeapon:
		STA Object_health,x
    skipHurtingMonsterSpriteWeapon:
		;PlaySound #SFX_MONSTER_HURT
    skipHurtingMonsterAndSoundSpriteWeapon:
	
++
	INX 
	CPX #TOTAL_MAX_OBJECTS
	BEQ skipSpriteWeaponCheck ;; done with checking against objects 
	JMP DoMonsterWeaponSpriteLoop
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;	
skipSpriteWeaponCheck ;; there is no collision here horizontally.

	

11/ And in your "Project Settings > Script Settings", assign the "HandleSpriteWeapon_Alternate.asm" script to the "Handle Sprite Weapon" element.


12/ Modify the "HandleHurtMonster.asm" script, that is located in the "GameEngineData\Routines\Basic\ModuleScripts\HurtWinLoseDeath" folder, around line 80, from that:

Code: Select all

		CountObjects #$00001000, #$00
		BEQ +
		JMP ++
	+
		.include SCR_KILLED_LAST_MONSTER
To that:

Code: Select all

		CountObjects #%00001000, #$00
		LDA monsterCounter
		CLC
		BEQ +
		JMP ++
	+
		.include SCR_KILLED_LAST_MONSTER

It should work then... (if I haven't forgotten anything... sorry in advance)
-----
Sorry about my poor english
All I need: A Damn Fine Cup of Coffee
My games: PRESS START GAME / UNDERGROUND ADVENTURE / UNDERGROUND ADVENTURE (Arcade version - Byte-Off-2019)
vanderblade
Posts: 65
Joined: Mon Jan 07, 2019 5:20 am

Re: [4.1] Adding Monster Lock in the Platformer module

Post by vanderblade » Fri Jan 11, 2019 3:47 pm

Thanks. This made the monster lock work, but it's also triggering screens all over my game before I even arrive there. I'm looking into it, but you have any idea why this might be happening?

UPDATE: I just had to reassign all my screen numbers (I've been sloppy about this). It works great now! You're definitely getting a mention in the end game credits!

UPDATE #2: I playtested more, and if I have more than one monster on the screen, the lock disappears after I kill just one monster. What might be the issue?
Last edited by vanderblade on Fri Jan 11, 2019 4:15 pm, edited 2 times in total.
Post Reply