TolerantX
Active member
This code I know worked before I added more to it. I keep getting branch out of range errors for my +commands
I'm trying to make it so if the player is in action state 2, the attack state already when they attack, then it does a different player animation (*got that working) but then the weapon is suppose to be the other state of the weapon, and it's still only showing the first state of the weapon not the one called for.... This was what it was before I added more code in the beginning. now I have branch out of range errors...
Please help me fix these so I can add punch combos to my game.
Thank you for your help and consideration.
I'm trying to make it so if the player is in action state 2, the attack state already when they attack, then it does a different player animation (*got that working) but then the weapon is suppose to be the other state of the weapon, and it's still only showing the first state of the weapon not the one called for.... This was what it was before I added more code in the beginning. now I have branch out of range errors...
Please help me fix these so I can add punch combos to my game.
Code:
;;; originally from mod_adventure as ChangeToAttack ;;;
;;;;;;;;;;;;;; Check ActionStep here and if player is in action step 2 then make step 3 combo_1 ;;;;;;;;;;;;;;;;;;;
TXA
STA temp ;; assumes the object that we want is in x.
GetActionStep temp
CMP #$02 ;; is player action step 02 or what state you have set for regular punch? ;;
BNE +doCreatePunch ;;; if the player is not in action step 2 do the normal punch animation ;;;
ChangeActionStep temp, #$03 ;;; assumes that "combo" is in action 2 ;;;
;arg0 = what object?
;arg1 = what behavior?
StopMoving temp, #$FF, #$00
;;;;;;;;;;;;;;;;;;;;;;;;; End of Check and change player ActionStep is here ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;; Here we are setting up object to be created. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
hi,x
CLC
ADC #WEAPON_POSITION_LEFT_X
STA tempA
LDA Object_y_hi,x
CLC
ADC #WEAPON_POSITION_LEFT_Y
STA tempB
CreateObject tempA, tempB, #WEAPON_OBJECT, #WEAPON_LEFT_STATE, currentNametable
JMP +doneWithCreatingWeapon
;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+doCreatePunch:
TXA
STA temp ;; assumes the object that we want is in x.
ChangeActionStep temp, #$02 ;; assumes that "attack" is in action 2
;arg0 = what object?
;arg1 = what behavior?
StopMoving temp, #$FF, #$00
;;; some constants for where to create the punch.
;;; Constants do not take up any memory.
WEAPON_POSITION_RIGHT_X = #$10
WEAPON_POSITION_RIGHT_Y = #$10
;WEAPON_POSITION_UP_X = #$00
;WEAPON_POSITION_UP_Y = #$F0
;WEAPON_POSITION_DOWN_X = #$00
;WEAPON_POSITION_DOWN_Y = #$10
WEAPON_POSITION_LEFT_X = #$F8
WEAPON_POSITION_LEFT_Y = #$10
WEAPON_OBJECT = #$03 ;;; This is the object number you are using from game objects ;;;
WEAPON_RIGHT_STATE = #$00 ;;; WEAPON_OBJECT action step number ;;;
WEAPON_LEFT_STATE = #$01 ;;; WEAPON_OBJECT action step number ;;;
;WEAPON_UP_STATE = #$00 ;;; WEAPON_OBJECT action step number ;;;
;WEAPON_DOWN_STATE = #$00 ;;; WEAPON_OBJECT action step number ;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;makePunchObjects:
;; Now, we have to create the object.
;; We will need to determine the direction
;; of the player.
LDX player1_object
TXA
STA temp
GetObjectDirection temp ;; temp still observed from above.
;;; this object's direction is now loaded into the
;;; accumulator for comparison after the macro.
;; 0 = down
;; 1 = downright
;; 2 = right
;; 3 = upright
;; 4 = up
;; 5 = upleft
;; 6 = left
;; 7 = downleft
;BNE +notDown ;; jump if not equal to zero.
;;; CREATE DOWN WEAPON
;;; create an object for the weapon.
;;; create it at the down positions.
;;; create it with the down state
;LDX player1_object
;LDA Object_x_hi,x
;CLC
;ADC #WEAPON_POSITION_DOWN_X
;STA tempA
;LDA Object_y_hi,x
;CLC
;ADC #WEAPON_POSITION_DOWN_Y
;STA tempB
;CreateObject tempA, tempB, #WEAPON_OBJECT, #WEAPON_DOWN_STATE, currentNametable
;JMP +doneWithCreatingWeapon
;+notDown
CMP #$02 ;; direction ;;
BNE +notRight
;;; CREATE RIGHT WEAPON
LDX player1_object
LDA Object_x_hi,x
CLC
ADC #WEAPON_POSITION_RIGHT_X
STA tempA
LDA Object_y_hi,x
CLC
ADC #WEAPON_POSITION_RIGHT_Y
STA tempB
CreateObject tempA, tempB, #WEAPON_OBJECT, #WEAPON_RIGHT_STATE, currentNametable
JMP +doneWithCreatingWeapon
+notRight
;CMP #$04 ;; direction ;;
;BNE +notUp
;;; CREATE UP WEAPON
;LDX player1_object
;LDA Object_x_hi,x
;CLC
;ADC #WEAPON_POSITION_UP_X
;STA tempA
;LDA Object_y_hi,x
;CLC
;ADC #WEAPON_POSITION_UP_Y
;STA tempB
;CreateObject tempA, tempB, #WEAPON_OBJECT, #WEAPON_UP_STATE, currentNametable
;JMP +doneWithCreatingWeapon
;+notUp
CMP #$06 ;; direction ;;
BNE +notLeft
;;; CREATE LEFT WEAPON
LDX player1_object
LDA Object_x_hi,x
CLC
ADC #WEAPON_POSITION_LEFT_X
STA tempA
LDA Object_y_hi,x
CLC
ADC #WEAPON_POSITION_LEFT_Y
STA tempB
CreateObject tempA, tempB, #WEAPON_OBJECT, #WEAPON_LEFT_STATE, currentNametable
JMP +doneWithCreatingWeapon
+notLeft
+doneWithCreatingWeapon
RTS
Thank you for your help and consideration.