Gregg Richardson
Member
Don't you hate it when you press the attack button sooner, and it starts a new attack animation before the rest of the attack animation can finish? Having multiple weapons on the screen slows down the game speed. I am using the turbo attacking button. The first picture is from the Adventure BBI demo, and the second is from my adventure project. Thanks to dale_coop and baardbi for helping me figure out how to fix this problem. This code works so wonderfully that it won't cut short the attack animation by pressing the attack button sooner, and there are no multiple weapons on the screen.
1. First, go to BASE_4_5\Game\MOD_AdventureBase\Inputs\attack_with_Action.asm from the Input Scripts.
Put this code on line 34, right below "StopMoving temp, #$FF"
Make sure Attack: is above "STX temp"
The frame counts for The Player attacking and weapon swinging do not matter. Adventure BBI demo uses one frame of the player attacking and 3 frames of weapon swinging. I use three each on my adventure project. Both work great. You can see the Adventure BBI demo now using one fulling weapon swinging, instead of three swords at the same time, on the Sprite Viewer on the left side of the screen, on the third picture. My adventure project is now using one claw attack at a time instead of 8 claws on the screen on the Sprite Viewer on the fourth picture.
Now, remember.
Animated Speed must be at the same speed for both player and weapon.
Set both of them EndAction: "Loop"
Set End Animation: For Player-"GoToFirst", For Weapon-"DestroyMe".
No "Timer" on either of them.
Be sure you put lines of code in the right place.
1. First, go to BASE_4_5\Game\MOD_AdventureBase\Inputs\attack_with_Action.asm from the Input Scripts.
Put this code on line 34, right below "StopMoving temp, #$FF"
Code:
;;; Anti-machine gun attacking code.
GetActionStep temp
CMP #2
BNE Attack: ;; Clear to attack after the attacking animation ends.
JMP notAmmoWeapon: ;; Not clear to start attack while the attacking animation is running.
Attack:
Make sure Attack: is above "STX temp"
The frame counts for The Player attacking and weapon swinging do not matter. Adventure BBI demo uses one frame of the player attacking and 3 frames of weapon swinging. I use three each on my adventure project. Both work great. You can see the Adventure BBI demo now using one fulling weapon swinging, instead of three swords at the same time, on the Sprite Viewer on the left side of the screen, on the third picture. My adventure project is now using one claw attack at a time instead of 8 claws on the screen on the Sprite Viewer on the fourth picture.
Now, remember.
Animated Speed must be at the same speed for both player and weapon.
Set both of them EndAction: "Loop"
Set End Animation: For Player-"GoToFirst", For Weapon-"DestroyMe".
No "Timer" on either of them.
Be sure you put lines of code in the right place.
Code:
;;;; Attack
;;;;;; Set these values to correspond to the game objects
;;;;;; OBJ_AMMO_WEAPON uses ammo and can only be used
;;;;;; if myAmmo has a value of 1 or more.
;;;;;; Set these values to adjust the offsets for the player weapon
WEAPON_OFFSET_LEFT_X = 8
WEAPON_OFFSET_LEFT_Y = 8
WEAPON_OFFSET_RIGHT_X = 16
WEAPON_OFFSET_RIGHT_Y = 8
WEAPON_OFFSET_UP_X = 0
WEAPON_OFFSET_UP_Y = 8
WEAPON_OFFSET_DOWN_X = 0
WEAPON_OFFSET_DOWN_Y = 16
;;; If weaponChoice is 0 we can't attack
LDA weaponChoice
BNE +canAttack
RTS
+canAttack:
LDA #0
STA Object_v_speed_hi,x
STA Object_v_speed_lo,x
STA Object_h_speed_hi,x
STA Object_h_speed_lo,x
STX temp
StopMoving temp, #$FF
;;; Anti-machine gun attacking code.
GetActionStep temp
CMP #2
BNE Attack: ;; Clear to attack after the attacking animation ends.
JMP notAmmoWeapon: ;; Not clear to start attack while the attacking animation is running.
Attack:
STX temp
ChangeActionStep temp, #2 ;;; Attack
LDA Object_direction,x
STA tempC
LDA Object_direction,x
AND #%00001111
CMP #FACE_LEFT
BEQ weaponLeftOffset
CMP #FACE_RIGHT
BEQ weaponRightOffset
CMP #FACE_UP
BEQ weaponUpOffset
CMP #FACE_DOWN
BEQ weaponDownOffset
RTS
weaponLeftOffset:
LDA Object_x_hi,x
SEC
SBC #WEAPON_OFFSET_LEFT_X
STA tempA
LDA Object_y_hi,x
CLC
ADC #WEAPON_OFFSET_LEFT_Y
STA tempB
JMP createPlayerObject
weaponRightOffset:
LDA Object_x_hi,x
CLC
ADC #WEAPON_OFFSET_RIGHT_X
STA tempA
LDA Object_y_hi,x
CLC
ADC #WEAPON_OFFSET_RIGHT_Y
STA tempB
JMP createPlayerObject
weaponUpOffset:
LDA Object_x_hi,x
CLC
ADC #WEAPON_OFFSET_UP_X
STA tempA
LDA Object_y_hi,x
SEC
SBC #WEAPON_OFFSET_UP_Y
STA tempB
JMP createPlayerObject
weaponDownOffset:
LDA Object_x_hi,x
CLC
ADC #WEAPON_OFFSET_DOWN_X
STA tempA
LDA Object_y_hi,x
CLC
ADC #WEAPON_OFFSET_DOWN_Y
STA tempB
createPlayerObject:
TXA
PHA
CreateObject tempA, tempB, weaponChoice, #0
LDA tempC
STA Object_direction,x
PLA
TAX
LDA weaponChoice
CMP #OBJ_AMMO_WEAPON
BNE notAmmoWeapon
DEC myAmmo
UpdateHudElement #5
LDA myAmmo
BNE notAmmoWeapon
;;;;; If we don't have more ammo we go back to the normal weapon.
LDA #OBJ_MELEE_WEAPON
STA weaponChoice
notAmmoWeapon:
RTS
Attachments
Last edited: