Lother
Member
I have a problem with the melee attack. I've binded the attack to a button and all, but when I press it when testing the attack doesn't activate.
My attack is 2 sprites large by 2 sprites high.
Here's the code :
In the options of the player object used for the attack, "Player Weapon" and "Monster" are the only boxes checked.
My attack is 2 sprites large by 2 sprites high.
Here's the code :
Code:
; load the playerX_object (current inputs):
JSR PlayerXobjectInputs
createWeaponMelee:
;; if on a cutscene:
LDA screenFlags
AND #%00000010
BEQ +
RTS
+
;TXA
;STA playerX_object
LDA gameHandler
AND #%00100000
BEQ notNPCstate_weapon
JMP doneCreatingWeaponMelee
notNPCstate_weapon:
LDA weaponsUnlocked
AND #%00000001
BNE canCreateWeaponMelee
JMP doneCreatingWeaponMelee
canCreateWeaponMelee:
;LDA limitWeapon
;BNE continueCreatingWeaponMelee
;RTS
continueCreatingWeaponMelee:
LDA Object_physics_byte,x
AND #%00000001 ;; is it on the ground?
BNE notCurrentyJumping
JMP doneCreatingWeaponMelee
notCurrentyJumping:
;;; IF YOU WANT TO USE AN SPECIFIC ANIMATION / ACTION STEP WHEN ATTACKING, comment out the following 3 lines:
;;; check if already attacking (assuming the attack action step is 03)
GetCurrentActionType playerX_object
CMP #$03
BNE notAlreadyCreatingWeaponMelee
JMP doneCreatingWeaponMelee
notAlreadyCreatingWeaponMelee:
;;; IF YOU WANT TO USE AN SPECIFIC ANIMATION / ACTION STEP WHEN ATTACKING, comment out the following 1 line:
;;; if not already attacking, change it's action step (assuming the attack action step is 03)
ChangeObjectState #$03, #$02
;;; if you want your player stops when he's attacking, comment out the following lines:
;LDA Object_movement,x
;AND #%00001111
;ORA #%00000010
;STA Object_movement,x
;LDA #$00
;STA Object_h_speed_hi,x
;STA Object_h_speed_lo,x
;STA Object_v_speed_hi,x
;STA Object_v_speed_lo,x
;; if was already attacking
wasAlreadyCreatingWeaponMelee:
LDA Object_movement,x
AND #%00000111
STA temp2
TAY
LDA Object_x_hi,x
SEC
SBC #$10 ;; <<-- HERE, width of weapon
STA temp
LDA temp
;;; offset x for creation
CLC
ADC weaponOffsetTableX,y
STA temp
LDA temp3
ADC #$00
STA temp3
LDA Object_y_hi,x
CLC
ADC weaponOffsetTableY,y
sec
sbc #$10 ;; <<-- HERE, height of weapon
STA temp1
CreateObject temp, temp1, #OBJECT_PLAYER_MELEE, #$00, currentNametable
;DEC limitWeapon
;;;; x is now the newly created object's x.
LDA Object_movement,x
ORA temp2
STA Object_movement,x
LDY temp2
LDA directionTable,y
ORA Object_movement,x
STA Object_movement,x
PlaySound #SND_SLASH
doneCreatingWeaponMelee:
RTS
In the options of the player object used for the attack, "Player Weapon" and "Monster" are the only boxes checked.