LDA gameHandler
AND #%00100000
BEQ notNPCstate_attack
JMP doneAttacking
notNPCstate_attack:
LDA weaponsUnlocked
AND #%00000001
BNE canAttack
JMP doneAttacking
canAttack:
LDX player1_object
GetCurrentActionType player1_object
CMP #$02
BNE notAlreadyAttacking
JMP doneAttacking
notAlreadyAttacking:
;;; don't attack if already attacking.
;;; do we have to check for hurt here?
;;;;; Here, we WOULD create melee
ChangeObjectState #$02, #$02
LDA Object_movement,x
AND #%00001111
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
LDA Object_x_hi,x
STA temp
LDA Object_y_hi,x
STA temp1
LDA Object_movement,x
AND #%00000111
STA temp2
TAY
LDA Object_x_hi,x
SEC
SBC #$08 ;; <<--- HERE, you have to set width of melee weapon in HEX (1 tile = 8px, 8 in decimal = #$08 in hex. Use the binary <-> hex converter plugin)
STA temp
LDA Object_scroll,x
SBC #$00
STA temp3
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 #$08 ;; <<--- HERE, you have to set height of melee weapon in HEX (1 tile = 8px, 8 in decimal = #$08 in hex. Use the binary <-> hex converter plugin)
STA temp1
CreateObject temp, temp1, #OBJECT_PLAYER_MELEE, #$00, temp3
meleeCreated:
;;;; x is now the newly created object's x.
LDA Object_movement,x
ORA temp2
STA Object_movement,x
;PlaySound #SND_SLASH
doneAttacking:
RTS