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

dale_coop

Moderator
Staff member
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)

MonsterLockPlatf20237fc3d58f99d.gif



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

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

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

2019-01-13-15-58-19-NES-MAKER-4-1-1-Version-0x158-Mon-Jeu-Plateforme-MST.png


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

2019-01-13-15-13-26-Script-Execute.png


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

2019-01-10-23-37-36-Param-tres-du-projet.png



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)

2019-01-10-23-36-04-Param-tres-du-projet.png


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

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


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.

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



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

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



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:
		; LDA DrawHudBytes
		; ora #HUD_myScore
		; STA DrawHudBytes
	UpdateHud HUD_myScore
++

To that:

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

2019-01-11-00-34-43-Param-tres-du-projet.png



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

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

To that:

Code:
		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.
 

dale_coop

Moderator
Staff member
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:
;;---- 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:
;;---- 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 ----
 

dale_coop

Moderator
Staff member
jsherman said:
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....
 
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

49769545_10216382942424056_6716324940993265664_n.jpg



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 ?
 

dale_coop

Moderator
Staff member
ADD MONSTER LOCK FOR THE ADVENTURE MODULE (Basic core)

MonsterLockAdv.gif


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

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

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

2019-01-13-15-58-19-NES-MAKER-4-1-1-Version-0x158-Mon-Jeu-Plateforme-MST.png


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

2019-01-13-15-13-26-Script-Execute.png



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


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

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


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.

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



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

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



8/ Modify the "HandleSpriteWeapon_Alternate.asm" script (or make a new one if you don't have it), replacing with this code:
Code:
	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:
		CountObjects #$00001000, #$00
		BEQ +
		JMP ++
	+
		.include SCR_KILLED_LAST_MONSTER

To that:

Code:
		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)
 

vanderblade

Active member
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?
 
vanderblade said:
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?

Make sure they don't share the same screen type as the one that the lock is in. You can check by clicking "show type" in your overworld map screen.
 

dale_coop

Moderator
Staff member
Yes when a screen is "triggered", all the screens that have the same "screen type" value are triggered too (it's useful in some levels design, blocking/unblocking certain area, ...).

2019-01-11-20-27-17-Screen-Details.png


So if you want only THIS screen to be triggered, you have to give it a unique "screen type" number (different the other screens)
 

vanderblade

Active member
Yeah, I was sloppy with my Screen Type assignments, so that's sorted.

However, I have an issue where if I kill only one monster on a screen, it triggers the monster lock. Thoughts?
 

dale_coop

Moderator
Staff member
Strange that looks ok for me.
In the "User Constants" tab, you need to add a new "COL_MONSTER_LOCK" (value 14) and a "TILE_MONSTER_LOCK_OFF" (value "0"), check again.
All is in my OP. You might have missed something.
 
dale_coop said:
Strange that looks ok for me.
In the "User Constants" tab, you need to add a new "COL_MONSTER_LOCK" (value 14) and a "TILE_MONSTER_LOCK_OFF" (value "0"), check again.
All is in my OP. You might have missed something.


Yeah i think i posted that right after you commented.

not sure what is happening.
 

dale_coop

Moderator
Staff member
Please, check again the user constant names, you might have miswrote them...
(sorry but a lot of people asking for help, I am quite off...late...)
...


Ah ok, I think I see your problem, the second user constant needs to be named ""TILE_MONSTER_LOCK_OFF" and not TILE_MONSTER_LOCK. It might be your issue.
 
Why yes it is lol that was the error sorry what you wrote om the forum and the picture was different.


Now when I get to the boss or monster room I seem to be able to walk pass the barricade I made. is there something I might be doing wrong code wise ?
 
Top Bottom