Pickups Collision Glitch

tbizzle

Well-known member
Once in a while my pickups will get dropped by my monsters only to have no collision to them? I am stumped as to why this is happening. I'll post my Hurt Monster script below. Any help GREATLY appreciated!!!!


Code:
LDA coolDown
BEQ +actuallyHurt1
JMP endIt
    +actuallyHurt1:
       
LDY Object_type,x
LDA MonsterBits,y
AND #%00000001 ;;;;This bit is the top "check box/bit" for monster bits
BEQ poot5
JSR doWaitFrame
RTS
    poot5:
   
TXA
PHA
STA temp
    GetActionStep temp
CMP #$07 ;; we will use action step 7 for hurt.
BNE +dontSkipHurtingThisObject  
    +dontSkipHurtingThisObject:    
LDA Object_vulnerability,x
AND #%00000001    ;; "no object collision" ?
BEQ +next      
JMP +doSkipHurtingThisObject
    +next:
     
PlaySound #sfx_enemyHurt  
LDX otherObject
LDA Object_defense,x
STA tempDE ;;tempDE is monster defense
LDX selfObject ;;now Player Weapon Object is in X register
LDA Object_strength,x ;;Weapon Strength is in Accumulator
SEC ;;Start Subtract
SBC tempDE ;; Monster Defense subtracted from Accumulator (Weapon Strength)
BMI +End ;;if the result is negative, then no damage happens, so end.
BEQ +End
STA tempWD ;;tempWD is player weapon damage after going through defense

LDX otherObject ;;Loading Monster Health
LDA Object_health,x
SEC ;;Subtracting Weapon Damage from Health
SBC tempWD
BEQ +dontSkipHurtingThisObject ;;if health is 0, kill
BMI +dontSkipHurtingThisObject ;;if health is negative, kill
STA Object_health,x ;;Save monster health

;+End:
JMP +doSkipHurtingThisObject
+End:      
               
    TXA
    PHA
    LDX selfObject
    LDA Object_direction,x
    AND #%11110000
    STA temp1
    PLA
    TAX
           
    LDA Object_direction,x
    AND #%00001111
    ORA temp1
    STA Object_direction,x
                                   
    DEC Object_health,x
    LDA Object_health,x
    BEQ +dontSkipHurtingThisObject
    JMP +doSkipHurtingThisObject
    +dontSkipHurtingThisObject:
            ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;          
            ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;DALE"S HURT MONSTER SCRIPT
LDA Object_x_hi,x
        CLC
        ADC other_center_x
        STA tempA
        LDA Object_y_hi,x
        CLC
        ADC other_center_y
        STA tempB
        TXA
        PHA
            LDX selfObject
            LDA Object_x_hi,x
            CLC
            ADC self_center_x
            STA tempC
            LDA Object_y_hi,x
            CLC
            ADC self_center_y
            STA tempD
        PLA
        TAX
   
        ;;; RECOIL
        ;;; find the center.
        LDA tempA
        SEC
        SBC tempC
        bpl +gotAbs ;; if positive, this is abs value
            EOR #$FF
            CLC
            ADC #$01
        +gotAbs:
            STA temp
           
        LDA tempB
        SEC
        SBC tempD
        bpl +gotAbs
            EOR #$FF
            CLC
            ADC #$01
        +gotAbs:
            ;;; now abs of y is in A
            CMP temp
            BCC +recoilHor
                ;; recoil vert
                LDA tempB
                CMP tempD
                BCS +recoilDown
                    LDA Object_direction,x
                    AND #%00001111
                    ORA #%00100000
                    STA Object_direction,x
                    JMP +continue
            +recoilDown:
                    LDA Object_direction,x
                    AND #%00001111
                    ORA #%00110000
                    STA Object_direction,x
                    JMP +continue
            +recoilHor:
                LDA tempA
                CMP tempC
                BCS +recoilRight
                    LDA Object_direction,x
                    AND #%00001111
                    ORA #%10000000
                    STA Object_direction,x
                    JMP +continue

            +recoilRight:
                    LDA Object_direction,x
                    AND #%00001111
                    ORA #%11000000
                    STA Object_direction,x
                     
            +continue:
           
   
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;      
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;END OF DALE"S SCRIPT  
                       
        LDA #$27 ;(change the number as you see fit)
        STA coolDown
                       
        DestroyObject
     
        ;CreateObject tempA, tempB, #$0F, #$00
                               
            ;; maintain x and y positions for dropable location
            LDA Object_x_hi,x
            STA tempA
            LDA Object_y_hi,x
            STA tempB
           
            CreateObject tempA, tempB, #$0F, #$00  
            ;JSR doWaitFrame
           
            DROPABLE_00 = #$FF ; game object #02          
            DROPABLE_01 = #$FF    ;; game object #03          
            DROPABLE_02 = #$0B   ;; game object #04          
            DROPABLE_03 = #$FF    ;; game object #05          
            DROPABLE_04 = #$FF  ;; game object #09          
            DROPABLE_05 = #$FF  ;; game object #10          
            DROPABLE_06 = #$05  ;; game object #11          
            DROPABLE_07 = #$FF  ;; game object #12          
            DROPABLE_08 = #$FF  ;; game object #13          
            DROPABLE_09 = #$FF  ;; game object #14          
            DROPABLE_10 = #$FF  ;; not used (FF)          
            DROPABLE_11 = #$FF ; not used (FF)          
            DROPABLE_12 = #$FF  ;; not used (FF)          
            DROPABLE_13 = #$0B ;; not used (FF)          
            DROPABLE_14 = #$FF  ;; not used (FF)          
            DROPABLE_15 = #$FF  ;; not used (FF)          
            DROPABLE_16 = #$FF  ;; not used (FF)          
            DROPABLE_17 = #$FF  ;; not used (FF)          
            DROPABLE_18 = #$0B  ;; not used (FF)          
            DROPABLE_19 = #$FF  ;; not used (FF)          
            DROPABLE_20 = #$FF  ;; not used (FF)          
            DROPABLE_21 = #$05  ;; not used (FF)          
            DROPABLE_22 = #$FF  ;; not used (FF)          
            DROPABLE_23 = #$FF  ;; not used (FF)          
            DROPABLE_24 = #$0D  ;; not used (FF)          
            DROPABLE_25 = #$FF  ;; not used (FF)          
            DROPABLE_26 = #$FF  ;; not used (FF)          
            DROPABLE_27 = #$0C  ;; not used (FF)          
            DROPABLE_28 = #$0E  ;; not used (FF)          
            DROPABLE_29 = #$FF  ;; not used (FF)          
            DROPABLE_30 = #$FF  ;; not used (FF)          
            DROPABLE_31 = #$09  ;; not used (FF)
                             
            ;JSR doWaitFrame
            JSR doGetRandomNumber
            ;AND #%00001111  ;; random # 0-15
            AND #%00011111 ;; random number between 0 and 31.                      
            TAY ;; load it into y.          
            LDA DropTable,y
            CMP #$FF
            BNE +dontSkipHurtingThisObject
            JMP +doSkipHurtingThisObject
            +dontSkipHurtingThisObject                      
            ;;;;;;;;;;;;;;;;;;;;;;;MONSTER BITS EXAMPLE;;;;;;;;;;;;;;;;;;;;;;;;;;
            ;LDY Object_type,x
            ;LDA MonsterBits,y
            ;AND #%10000000 ;;;;This bit is the top "check box/bit" for monster bits
            ;BEQ poot5
            ;different monster death animtion?, ignore certain player weapons?
            ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
Last edited:

tbizzle

Well-known member
Continuation Of Hurt Monster Script:

Code:
STA tempC              
                ;JSR doWaitFrame              
                CreateObject tempA, tempB, tempC, #$00, currentNametable              
                   
                ;; create the value that is in the droppable table
            +doSkipHurtingThisObject
            ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
            ;;;;; Here we will look at all of the tiles one by one, and if there is a monster block tile, we will convert it
            CountObjects #%00001000
            BEQ +noMoreMonsters
                JMP +doSkipHurtingThisObject
            +noMoreMonsters
               
                MONSTER_BLOCK_TILE = #$07 ; the number collision type of your monster block.
                LDX #$00
                doCheckForMonsterBlockAfterMonsterDeath:
                    LDA currentNametable
                        AND #%00000001
                        BEQ +isEvenCt
                            LDA #$24
                            STA temp1 ;; high byte of thing
                            ;;; is odd col table.
                            LDA collisionTable2,x
                            CMP #MONSTER_BLOCK_TILE
                            BEQ +isMonsterBlockTile
                                JMP +notMonsterBlockTile
                            +isMonsterBlockTile
                                ;; is monster block table.
                                LDA #$00
                                STA collisionTable2,x
                               
                                JSR getTileToChange_forMonBlock

                                JMP +doneWithTileUpdate
                        +isEvenCt
                            LDA #$20
                            STA temp1 ;; high byte of thing.
                            ;;; is odd col table.
                            LDA collisionTable,x
                            CMP #MONSTER_BLOCK_TILE
                            BEQ +isMonsterBlockTile
                                JMP +notMonsterBlockTile
                            +isMonsterBlockTile
                                ;; is monster block table.
                                LDA #$00
                                STA collisionTable,x
                                JSR getTileToChange_forMonBlock
       
                                JMP +doneWithTileUpdate
                               
                               
                               
                            getTileToChange_forMonBlock:
                                TXA
                                STA temp
                                LSR
                                LSR
                                LSR
                                LSR
                                LSR
                                LSR
                                clc
                                ADC temp1
                                STA temp2 ;;;temp16+1
                                TXA
                                AND #%11110000
                                ASL
                                ASL
                                STA tempz
                                TXA
                                AND #%00001111
                                ASL
                                ORA tempz
                                STA temp3 ;temp16
                               
                               
                                ;;; SET THE TILE NUMBER TO CHANGE TO.  
                                LDA #$22 ;; the tile to change.
                                        ;;; this is in tiles, so if you wanted the second "metatile",
                                        ;;; use 2, not 1.  If you wanted the tile in the next row,
                                        ;;; use #$20, not #$10.  Etc.
                                STA tempA
                                CLC
                                ADC #$01
                                STA tempB
                                CLC
                                ADC #$0F
                                STA tempC
                                CLC
                                ADC #$01
                                STA tempD
                               
                               
                                LDY #$00
                                    LDA temp2
                                    STA scrollUpdateRam,y
                                    INY
                                    LDA temp3
                                    STA scrollUpdateRam,y
                                    INY
                                    LDA tempA
                                    STA scrollUpdateRam,y
                                    INY
                                   
                                    LDA temp2
                                    STA scrollUpdateRam,y
                                    INY
                                    LDA temp3
                                    CLC
                                    ADC #$01
                                    STA scrollUpdateRam,y
                                    INY
                                    LDA tempB
                                    STA scrollUpdateRam,y
                                    INY
                                   
                                        LDA temp3
                                        CLC
                                        ADC #$20
                                        STA temp3
                                        LDA temp2
                                        ADC #$00
                                        STA temp2
                                   
                                    LDA temp2
                                    STA scrollUpdateRam,y
                                    INY
                                    LDA temp3
                                    STA scrollUpdateRam,y
                                    INY
                                    LDA tempC
                                    STA scrollUpdateRam,y
                                    INY
                                   
                                    LDA temp2
                                    STA scrollUpdateRam,y
                                    INY
                                    LDA temp3
                                    CLC
                                    ADC #$01
                                    STA scrollUpdateRam,y
                                    INY
                                    LDA tempD
                                    STA scrollUpdateRam,y
                                    INY
                               
                                TYA
                                STA maxScrollOffsetCounter
                               
                               
                                       
                               
                            ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
                            ;;; Turn on update screen on next frame.
                                    LDA updateScreenData
                                    ORA #%0000100
                                    STA updateScreenData
                            ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
                                TriggerScreen screenType
                                RTS
                        +doneWithTileUpdate
   
                       
                        JSR doWaitFrame
                    +notMonsterBlockTile
                    INX
                    CPX #240
                    BEQ +doSkipHurtingThisObject ;; done
                        JMP doCheckForMonsterBlockAfterMonsterDeath ;; last monster block.
           
    +doSkipHurtingThisObject
       
        PLA
        TAX
        endIt:
 
Last edited:

dale_coop

Moderator
Staff member
In the first part of your script, find the lines:
Code:
            ;; maintain x and y positions for dropable location
            LDA Object_x_hi,x
            STA tempA
            LDA Object_y_hi,x
            STA tempB
And change like that (I added 2 lines):
Code:
            ;; maintain x and y positions for dropable location
            LDA Object_x_hi,x
            STA tempA
            LDA Object_screen,x  ;; dale_coop: added
            STA tempD             ;; dale_coop: added
            LDA Object_y_hi,x
            STA tempB

Then, in the second part of the script, modify the line:
Code:
CreateObject tempA, tempB, tempC, #$00, currentNametable
Into:
Code:
CreateObject tempA, tempB, tempC, #$00, tempD

I think that should fix the collision issue with the pickups.
 

tbizzle

Well-known member
@dale_coop Same results unfortunately :( I'm going to try and put a weapon cooldown on all my weapons, maybe its all the projectiles and melee weapons being created on the screen at the same time that is causing it to get corrupted.
 
Top Bottom