;Better Charge Beam vulnerability.
;Enemy is vulnerable to Charge if and only if it's vulnerable to the non-charged beam.
;Other projectile types work as normal.
;Made by Smiley

lorom

!currentProjectile = $18A6
!projectileType = $0C18,x
!enemyIndex = $0E54
!enemyId = $0F78,x

org $A0F7E0                                     ;JSL to this from the enemy's bank, then set the shot AI to the JSL
CustomShotAI:

  LDA !currentProjectile : ASL A : TAX          ;Projectile index to X
  LDA !projectileType : STA $12                 ;Find the projectile type to $12
  LDX !enemyIndex : LDA !enemyId : TAX          ;Enemy ID (type, eg. a Waver) to X
  LDA $A0003C,x : STA $14                       ;Vulnerability pointer to $14
  
  LDA $12
  BIT #$0F00 : BNE NormalShotAi                 ;If projectile is *not* a beam, or
  AND #$000F : CLC : ADC $14 : TAX              ;\
  LDA $B40000,x : AND #$00FF : BNE NormalShotAi ;/If non-charged beam vulnerability is non-zero, then branch

End:
  JSL $A0A8BC                                   ;Else, creates a dud shot
  RTL

NormalShotAi:
  JSL $A0A63D                                   ;Normal shot AI
  RTL