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: