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

Hey Dale, great work. I'm having 1 problem though, the door doesn't seem to act as a solid before I clear the room.

Maybe I missed a step, but my Collision Tile 14 is still set to Null, is that supposed to be updated/changed to something else?

EDIT: Sorted it out, just updated that script to be a Solid, everything else continues to work. (I usually make posts to help me trouble shoot)
 

digit2600

Member
The locks work well, only problem is.. Monster HP is now ignored and I can kill them all with one shot... I tried replacing the handle sprite weapon script with the alternate sprite weapon script but now the collision is ignored...
 

dale_coop

Moderator
Staff member
Ok, so yep, maybe you will have to modify again the handle sprite weapon script. I will give the modified one.
What kind of game ? Adventure ? Platformer?
 

dale_coop

Moderator
Staff member
If you're on a platformer game, here a Handle Sprite Weapon script that take the mosnter HP (edit the script assigned to your "Handle Sprite Weapon" in the Project Settings > Script Settings):
Code:
	GetCurrentActionType player1_object
	CMP #$03
	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.
 

Raftronaut

Member
Does this fix apply to the scrolling module as well?

The monster blocks in my shooter module Demo have all sorts of odd behavior.

Looked through the thread but am not certain I saw if this is addressed in regards to scrolling.

If not, can someone help point me in the right direction?
 

dale_coop

Moderator
Staff member
Never tried with the scrolling module (never had the time for that) but basically it should work.
Just be sure that your "TILE_xxxx" constants are correctly set.
 

Atarath

Member
This tutorial is wonderful. I have poured over every post here. I did the adventure manual install and my monster lock is working, but resets every time you reenter the screen. I take it that's because it's not actually triggering the screen but checking to see if the monsters were killed and just changing the tiles?
 

dale_coop

Moderator
Staff member
If there is no monster on your screen when yo u re-enter, but the monster lock are still here:
Just be sure that your "TILE_xxxx" constants are correctly set.
- the "TILE_MONSTER_LOCK": the monsterLock tile in your tileset.
- the "TILE_MONSTER_LOCK_OFF": the tile used when the monsterLock is removed.
(cf again my op)

If your monsters are here... it's normal, the screen is NOT trigger when you kill all monsters... you could make a TriggerScreen tile and put on your screen, just after the monster lock... (somewhere your player will walk through).
 

clay

New member
Hello. Will this work if I've changed locked doors to warpdoors? I notice the updated warpdoor asm (around line 128 of 'LoadCollisionBytes.asm') and this updated 'LoadCollisionBytes' are occupying the same space. The warpdoor change I found in this thread (change locked door to locked warp):

http://nesmakers.com/viewtopic.php?f=60&t=2591&p=16300&hilit=door#p16300
 

dale_coop

Moderator
Staff member
In that case, you will have to modify the "CheckTriggeredColLoads_DC.asm" script (assigned to the "Handle Triggered Collisions" element in the Project Settings > Script Settings), the line 5, replacing the:
Code:
	LDA #$00
	STA temp ;; set it to a walkable tile.
with:
Code:
	LDA #$06
	STA temp ;; set it to a warp tile.
 

mouse spirit

Well-known member
dale_coop,thank you. When i leave an come back to the screen the locks do work buuut they have the same tile as locked ones.I have rechecked my constants
Doing a platformer in 4.1.5..
 

dale_coop

Moderator
Staff member
You need to change the TILE_MONSTER_LOCK constant value... to match the tile index you use for your monster locks (in your tileset: display the 8x8 grid and count the tiles from 0).
If you can't find the right value, could you share a screenshot of your bg tileset with with the grid?
 

mouse spirit

Well-known member
I do see what you mean but i have tried.I will try again right now.One problem may be that im painting the tile "Monster Lock" over whatever tile i want on the current screen.But i did also make an asset and try it. I tried a few things but just couldn;t fix this. If i had to guess,id say its a screen load thing or something.I think nn the new 4.5 tutorials there was something similar with lock blocks.I will watch them again and see if that can help me here in any way also.

Untitled-7.png
Untitled-1.png
Untitled-2.png
Untitled-3.png


Now i leave and return to that screen and the lock tiles are back but NOT solid.

Untitled-4.png
Untitled-5.png
Untitled-6.png
 

dale_coop

Moderator
Staff member
Checking you bg tileset, the tile you use for your "Monster Lock" is the #14:`

Untitled-7.png



So, try to set the "TILE_MONSTER_LOCK" constant value to "14":

2020-06-25-09-52-17-Project-Settings.png


I think it should work better, now.
 

mouse spirit

Well-known member
Understood.I will try tonight and edit this post with a response.Thank you dale.

Edit: Works great.My issue is resolved for an asset.Does this mean that i cant paint a monster lock?Should i strictly use the same graphic spot(14)?
 

dale_coop

Moderator
Staff member
It would be easier to use always the same gfx (or the same spot in all your tilesets), yeah.
But if you want/need to use another one, it's doable, you will have to do some modification in the code (add a new TILE_MONSTER_LOCK_2 and a few lines of code in the CheckTriggeredTileLoads_DC.asm script)
 

Saulus_Lira

Member
WOOOOOOOOOLLLLLLLLL
I did it from easy steps and its done!!!!!
Thank you Dale_Coop.
On credits of my game, the programming has your name.
 
Top Bottom