vanderblade
Active member
dale_coop said:I will try again with a fresh NESMaker folder and check everything
Thanks.
If you have a paypal or a patreon, I'll gladly give you some money.
dale_coop said:I will try again with a fresh NESMaker folder and check everything
JSR screenIsOffForMonsterCheck
;;Trigger the current screen
TriggerScreen screenType
;;update all tiles
LDA showingNametable
STA temp
ChangeAllTilesDirect #COL_MONSTER_LOCK, #$00, #TILE_MONSTER_LOCK_OFF, temp
vanderblade said: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?
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
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.
vanderblade said:Hey Dale. Your updated code works with the player weapon. But my projectile still triggers the monster lock if I use it to kill the first monster.
vanderblade said:And I also noticed killing enemies with the weapon now causes two death explosion animations.
;; CreateObject temp, temp1, #OBJ_MONSTER_DEATH, #$00, currentNametable
vanderblade said:Hey Dale. Your updated code works with the player weapon. But my projectile still triggers the monster lock if I use it to kill the first monster.
;;; what should we do with the monster?
;;; monster is loaded in x
LDA Object_vulnerability,x
AND #%00000100 ;; is it weapon immune?
BEQ notWeaponImmune
;PlaySound #SFX_MISS
JMP skipHurtingMonsterAndSound
notWeaponImmune:
LDA Object_status,x
AND #HURT_STATUS_MASK
BEQ dontskipHurtingMonster
JMP skipHurtingMonster
dontskipHurtingMonster:
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 skipRecoilBecauseOnEdge
LDA Object_vulnerability,x
AND #%00001000
BNE skipRecoilBecauseOnEdge ;; 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
skipRecoilBecauseOnEdge:
LDA Object_health,x
SEC
SBC #$01
CMP #$01
BCC +
JMP notMonsterDeath
+
DeactivateCurrentObject
PlaySound #SND_SPLAT
;;;;;;;;;;;;;;;;;; ok, so now we also add points to score
;LDY Object_type,x
;LDA ObjectWorth,y
;STA temp
; AddValue #$03, GLOBAL_Player1_Score, temp
;arg0 = how many places this value has.
;arg1 = home variable
;arg2 = amount to add ... places?
;; and this should trip the update hud flag?
;;;;
TXA
STA tempx
AddValue #$08, myScore, #$01, #$00
;STA hudElementTilesToLoad
; LDA #$00
; STA hudElementTilesMax
; LDA DrawHudBytes
; ora #HUD_myScore
; STA DrawHudBytes
UpdateHud HUD_myScore
LDX tempx
JSR HandleDrops
JSR HandleToggleScrolling
CountObjects #$00001000, #$00
LDA monsterCounter
CLC
BEQ +
JMP ++
+
.include SCR_KILLED_LAST_MONSTER
++
JMP skipHurtingMonster
notMonsterDeath
STA Object_health,x
skipHurtingMonster:
;PlaySound #SFX_MONSTER_HURT
skipHurtingMonsterAndSound:
LDX tempx
;; what should we do with the projectile?
DeactivateCurrentObject
;;; what should we do with the monster?
;;; monster is loaded in x
LDA Object_vulnerability,x
AND #%00000100 ;; is it weapon immune?
BEQ notWeaponImmune
;PlaySound #SFX_MISS
JMP skipHurtingMonsterAndSound
notWeaponImmune:
LDA Object_status,x
AND #HURT_STATUS_MASK
BEQ dontskipHurtingMonster
JMP skipHurtingMonster
dontskipHurtingMonster:
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 skipRecoilBecauseOnEdge
LDA Object_vulnerability,x
AND #%00001000
BNE skipRecoilBecauseOnEdge ;; 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
skipRecoilBecauseOnEdge:
LDA Object_health,x
SEC
SBC #$01
CMP #$01
BCC +
JMP notMonsterDeath
+
DeactivateCurrentObject
PlaySound #SND_SPLAT
;;;;;;;;;;;;;;;;;; ok, so now we also add points to score
;LDY Object_type,x
;LDA ObjectWorth,y
;STA temp
; AddValue #$03, GLOBAL_Player1_Score, temp
;arg0 = how many places this value has.
;arg1 = home variable
;arg2 = amount to add ... places?
;; and this should trip the update hud flag?
;;;;
TXA
STA tempy ;;dale_coop
AddValue #$08, myScore, #$01, #$00
;STA hudElementTilesToLoad
; LDA #$00
; STA hudElementTilesMax
; LDA DrawHudBytes
; ora #HUD_myScore
; STA DrawHudBytes
UpdateHud HUD_myScore
LDX tempy ;;dale_coop
JSR HandleDrops
JSR HandleToggleScrolling
CountObjects #%00001000, #$00
LDX tempx ;;dale_coop
LDA monsterCounter
CLC ;;dale_coop
BEQ +
JMP ++
+
.include SCR_KILLED_LAST_MONSTER
++
JMP skipHurtingMonster
notMonsterDeath
STA Object_health,x
skipHurtingMonster:
;PlaySound #SFX_MONSTER_HURT
skipHurtingMonsterAndSound:
LDX tempx
;; what should we do with the projectile?
DeactivateCurrentObject
;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;
;; monster bit is: #%00001000
;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;To change collision type and graphic
CountObjects #%00001000, #$00 ;; count monsters.
LDA monsterCounter
CLC
BEQ doNoMoreMonsterCode
JMP stillMonstersOnScreen_onScreenload
doNoMoreMonsterCode
;;; all of the tiles you would like to change when this screen is loaded.
;;; do this routine for:
;;; FIRST, GET RID OF LOCKS:
LDA update_screen
BNE screenIsOffForMonsterCheck
JMP doScreenOnMonsterCheck
screenIsOffForMonsterCheck:
LDA showingNametable
STA temp
ChangeAllTilesDirect #COL_MONSTER_LOCK, #$00, #TILE_OPENDOOR, temp
JMP stillMonstersOnScreen_onScreenload
doScreenOnMonsterCheck:
;;;;;===================
stillMonstersOnScreen_onScreenload:
;;;; end what to do if no more objects
;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;
LDA screenType
;; divide by 32
LSR
LSR
LSR
;LSR
;LSR
;;; now we have the right *byte* out of the 32 needed for 256 screen bytes
TAY
LDA screenTriggers,y ;; now the rigth bit is loaded into the accum
STA temp
LDA screenType
AND #%00000111 ;; look at last bits to know what bit to check, 0-7
TAX
LDA ValToBitTable_inverse,x
AND temp
BNE +
JMP thisScreenIsNotTriggered_onScreenLoad
+
;; this screen IS triggered
DoDestroyAllTriggerTiles:
;;; HERE:
;;; all of the tiles you would like to change when this screen is loaded.
;;; do this routine for:
;;; FIRST, GET RID OF LOCKS:
LDA showingNametable
STA temp
ChangeAllTilesDirect #COL_LOCK, #$00, #TILE_OPENDOOR, temp
;;; NOW, GET RID OF KEY TILES:
LDA showingNametable
STA temp
ChangeAllTilesDirect #COL_KEY, #$00, #$00, temp ;; arg2 = floor, null, etc
;ChangeAllTiles #COL_KEY, #$00, #$00, temp
thisScreenIsNotTriggered_onScreenLoad:
;;; FIRST, GET RID OF LOCKS:
LDA showingNametable
STA temp
ChangeAllTilesDirect #COL_LOCK, #$00, #TILE_OPENDOOR, temp
;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;
;; monster bit is: #%00001000
;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;To change collision type and graphic
CountObjects #%00001000, #$00 ;; count monsters.
LDA monsterCounter
CLC
BEQ doNoMoreMonsterCode
JMP stillMonstersOnScreen_onScreenload
doNoMoreMonsterCode
;;; all of the tiles you would like to change when this screen is loaded.
;;; do this routine for:
;;; FIRST, GET RID OF LOCKS:
LDA update_screen
BNE screenIsOffForMonsterCheck
JMP doScreenOnMonsterCheck
screenIsOffForMonsterCheck:
LDA showingNametable
STA temp
ChangeAllTilesDirect #COL_MONSTER_LOCK, #$00, #TILE_MONSTER_LOCK_OFF, temp
JMP stillMonstersOnScreen_onScreenload
doScreenOnMonsterCheck:
;;;;;===================
stillMonstersOnScreen_onScreenload:
;;;; end what to do if no more objects
;; Remove all the monster locks:
LDA showingNametable
STA temp
ChangeAllTiles #COL_MONSTER_LOCK, #$00, #TILE_MONSTER_LOCK_OFF, temp