Melee in platform module

digitalbooty

New member
http://nesmakers.com/viewtopic.php?f=23&t=926&p=5846&hilit=melee#p5846

I've used the below code as my input for "B" button. I've created a melee object and animation, but when I press "B," nothing happens. Any suggestions on what I could be missing? Thanks


Code:
 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
 
 LDA Object_movement,x          ;
 CMP #$00                       ;If player is moving, skip changing the animation
 BNE +                          ;
 LDX player1_object             ;
 ChangeObjectState #$04, #$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
 
    LDA temp2
    TAY
    LDA temp
    SEC
    SBC #$08 ;; width of weapon
    CLC
    ADC weaponOffsetTableX,y
    STA temp
    LDA temp1
    SEC
    SBC #$10
    CLC
    ADC weaponOffsetTableY,y
    STA temp1
 
 CreateObject temp, temp1, #$01, #$00
 
meleeCreated:
    ;;;; x is now the newly created object's x.
    LDA Object_movement,x
    ORA temp2
    STA Object_movement,x
doneAttacking:
    RTS


;;000 down
;010 right
;100 up
;110 left
 

dale_coop

Moderator
Staff member
Have you check the weapon 1 in the project info?

(In Project > Info menu dialog, there are a lot of checkboxes. You have to check the first weapon: your player will have its weapon unlocked from the start.... else you babe to make a NPC give it to your player ;))
 

digitalbooty

New member
That's what it was! Pretty silly of me to miss. Now I just need to figure out how to get the melee animate toward the left when I turn around and hopefully change my player animation to match it. Thanks for the help!
 
Top Bottom