;;; Create a Projectile.
;;; Assumes that the projectile you want to create is in GameObject Slot 01.
;;; Assumes variable called myAmmo exists.
;;; assumes myAmmo is in hud element 8.
LDA myAmmo
BNE +canShootMega
LDA #$01 ;; assumes normal projectile is in 1
STA tempz ;; we will use tempz to hold which type of projectile.
;;; if I had no special ammo, i'll just use normal projectile
JMP +shootThing
+canShootMega:
;;; but if i DID have ammo, I'll shoot mega shot!
LDA #$02 ;; assumes mega projectile is in 2.
STA tempz
;; there is ammo here.
DEC myAmmo
; UpdateHudElement #$03 ;; change this to which element shows myAmmo.
+shootThing
TXA
PHA
TYA
PHA
LDX player1_object
LDA Object_direction,x
AND #%00000111
CMP #FACE_LEFT
BEQ +playerFacingLeft
;; else player is facing right:
+playerFacingRight:
;; determining the projectile horizontal origin when the player's facing right:
LDA Object_x_hi,x
CLC
ADC #$0A ;; HERE to adjust the horiz offset (you can try different values 01,02,...08,09,0A,0B,...,0F,10,11,12...)
STA tempA
LDA Object_screen,x
ADC #$00
STA tempD
JMP +continue
+playerFacingLeft:
;; determining the projectile horizontal origin when the player's facing right:
LDA Object_x_hi,x
CLC
ADC #$00 ;; HERE to adjust the horiz offset
STA tempA
LDA Object_screen,x
ADC #$00
STA tempD
+continue:
LDA Object_y_hi,x
CLC
ADC #$04
STA tempB
LDA Object_direction,x
AND #%00000111
STA tempC
CreateObjectOnScreen tempA, tempB, tempz, #$00, tempD
;;; x, y, object, starting action.
;;; and now with that object, copy the player's
;;; direction and start it moving that way.
LDA tempC
STA Object_direction,x
TAY
LDA DirectionTableOrdered,y
STA temp1
TXA
STA temp
StartMoving temp, temp1
PLA
TAY
PLA
TAX
+canNotShoot:
RTS
I got it working better with this code! Thanks!Here a modified script that will take the facing direction in consideration:
Code:;;; Create a Projectile. ;;; Assumes that the projectile you want to create is in GameObject Slot 01. ;;; Assumes variable called myAmmo exists. ;;; assumes myAmmo is in hud element 8. LDA myAmmo BNE +canShootMega LDA #$01 ;; assumes normal projectile is in 1 STA tempz ;; we will use tempz to hold which type of projectile. ;;; if I had no special ammo, i'll just use normal projectile JMP +shootThing +canShootMega: ;;; but if i DID have ammo, I'll shoot mega shot! LDA #$02 ;; assumes mega projectile is in 2. STA tempz ;; there is ammo here. DEC myAmmo ; UpdateHudElement #$03 ;; change this to which element shows myAmmo. +shootThing TXA PHA TYA PHA LDX player1_object LDA Object_direction,x AND #%00000111 CMP #FACE_LEFT BEQ +playerFacingLeft ;; else player is facing right: +playerFacingRight: ;; determining the projectile horizontal origin when the player's facing right: LDA Object_x_hi,x CLC ADC #$0A ;; HERE to adjust the horiz offset (you can try different values 01,02,...08,09,0A,0B,...,0F,10,11,12...) STA tempA LDA Object_screen,x ADC #$00 STA tempD JMP +continue +playerFacingLeft: ;; determining the projectile horizontal origin when the player's facing right: LDA Object_x_hi,x CLC ADC #$00 ;; HERE to adjust the horiz offset STA tempA LDA Object_screen,x ADC #$00 STA tempD +continue: LDA Object_y_hi,x CLC ADC #$04 STA tempB LDA Object_direction,x AND #%00000111 STA tempC CreateObjectOnScreen tempA, tempB, tempz, #$00, tempD ;;; x, y, object, starting action. ;;; and now with that object, copy the player's ;;; direction and start it moving that way. LDA tempC STA Object_direction,x TAY LDA DirectionTableOrdered,y STA temp1 TXA STA temp StartMoving temp, temp1 PLA TAY PLA TAX +canNotShoot: RTS
Is there a way to stop the player from moving while attacking and animating the attack? I've tried the stop moving input scripts and they don't seem to work and none of the action steps seem to be related to the attack. I'll try putting some of the stop input code into the attack script.You can adjust the offset value if you need the projectile closer or further check (my “HERE” comments in the code)