ok, yes, I am aware this is a mess, but bare with me because it actually works as intended as a weapon now. There is only one problem remaining:
When the weapon is in the Hold state, the weapon sprite jumps up and down the vertical axis wildly if the player is moving and holding down the trigger simultaneously.
Code: Select all
ACTOR DooMSPAS : DoomWeapon
{
Weapon.BobStyle Alpha
Weapon.BobRangeX .05
Weapon.BobRangeY .85
Weapon.BobSpeed 1.775
Inventory.PickupMessage "You got the Charger!"
Weapon.AmmoType "Shell"
Weapon.AmmoGive 8
Weapon.AmmoUse 1
Weapon.SlotNumber 3
Weapon.SelectionOrder 397
+INVENTORY.ALWAYSPICKUP
+WEAPON.NOAUTOFIRE
Inventory.PickupSound "weapons/get"
AttackSound "SSG_SHOO" // Fallback sound
Scale 1.25
States
{
Ready:
SPAS AAAAAAAAAAAA 0 A_WeaponReady
SPAS A 1 A_WeaponReady // Bobbing happens here
Loop
Select:
SPAS A 1 A_Raise
Loop
Deselect:
SPAS A 1 A_Lower
Loop
// State entered when fire button is first pressed
Fire:
SPAS A 0 A_TakeInventory("ChargeCounter", 10)// Reset charge counter
SPAS A 1 A_WeaponReady//A_TakeInventory("ChargeCounter", 10) // Use a tick here too
Goto Hold
// State loops while the fire button is held down
Hold:
SPAS A 2 A_GiveInventory("ChargeCounter", 1)
// Check if max charge reached ONLY to play the sound cue (instant check is fine)
TNT1 A 0 A_JumpIfInventory("ChargeCounter", 6, "FireCharged")
// Fall through to the main hold loop
SPAS A 1
SPAS A 0 A_WeaponReady//Small Delay before first A_WeaponReady
HoldLoop:
SPAS A 1 A_WeaponReady(WRF_NOFIRE | WRF_NOSWITCH) // Keep bobbing but prevent switching/firing
TNT1 A 0 A_JumpIfInventory("ChargeCounter", 6, "FireCharged")
TNT1 A 0 A_Refire
// State entered when the fire button is released (instant decision is fine)
ReleaseFire:
// Check if the counter reached the maximum charge
SPSF A 1
TNT1 A 0 A_JumpIfInventory("ChargeCounter", 6, "FireCharged")
// If not fully charged, jump to the normal firing sequence
Goto FireNormal
// Normal firing sequence (not fully charged)
FireNormal:
// Combine sound and flash on the first visible frame of the firing animation
SPSF A 1 Bright A_GunFlash
SHTG A 0 Bright A_RailAttack (15, 0, 0, none, "Gold" , RGF_NOPIERCING|RGF_EXPLICITANGLE|RGF_FULLBRIGHT|RGF_SILENT, 0, "ARPuff", random (-6,5),random (-4,3), 0, 8, 12, 3, none, 4)
SHTG A 0 Bright A_RailAttack (10, 0, 0, none, "Gold" , RGF_NOPIERCING|RGF_EXPLICITANGLE|RGF_FULLBRIGHT|RGF_SILENT, 0, "ARPuff", random (-6,5),random (-4,3), 0, 8, 12, 3, none, 4)
SHTG A 0 Bright A_RailAttack (5, 0, 0, none, "Gold" , RGF_NOPIERCING|RGF_EXPLICITANGLE|RGF_FULLBRIGHT|RGF_SILENT, 0, "ArPuff", random (-6,5),random (-4,3), 0, 8, 12, 3, none, 4)
SPSF A 1 Bright
TNT1 A 0 A_TakeInventory("ChargeCounter", 6)
TNT1 A 0 A_PlaySound ("SSG_SHOO", CHAN_WEAPON)
// --- Standard Shot Pellet Pattern (these can likely remain 0-tick) ---
SHTG A 0 Bright A_RailAttack (15, 0, 0, none, "Gold" , RGF_NOPIERCING|RGF_EXPLICITANGLE|RGF_FULLBRIGHT|RGF_SILENT, 0, "ArPuff", random (-6,5),random (-4,3), 0, 8, 12, 3, none, 4)
SHTG A 0 Bright A_RailAttack (5, 0, 0, none, "Gold" , RGF_NOPIERCING|RGF_EXPLICITANGLE|RGF_FULLBRIGHT|RGF_SILENT, 0, "ArPuff", random (-6,5),random (-4,3), 0, 8, 12, 3, none, 4)
SHTG A 0 Bright A_RailAttack (10, 0, 0, none, "Gold" , RGF_NOPIERCING|RGF_EXPLICITANGLE|RGF_FULLBRIGHT|RGF_SILENT, 0, "ArPuff", random (-6,5),random (-4,3), 0, 8, 12, 3, none, 4)
SHTG A 0 Bright A_RailAttack (5, 0, 0, none, "Gold" , RGF_NOPIERCING|RGF_EXPLICITANGLE|RGF_FULLBRIGHT|RGF_SILENT, 0, "ArPuff", random (-6,5),random (-4,3), 0, 8, 12, 3, none, 4)
// --- Continue Animation ---
SPSF B 2 Bright // Second frame of flash/firing
SPAS C 4 // Start recovery/pump animation
SPAS C 3
SPAS C 4
SPAS B 3
SPAS B 3
SPAS B 3 A_WeaponReady
Goto PostFireCleanup
// Charged firing sequence (fully charged)
FireCharged:
// Combine sound and *custom* flash on the first visible frame
TNT1 A 0 A_TakeInventory("ChargeCounter", 6)
SPSF E 3 Bright A_GunFlash("FlashCharged")
TNT1 A 0 A_PlaySound("LIFEWARN", CHAN_BODY)
TNT1 A 0 A_PlaySound ("SSG_SHOO", CHAN_WEAPON)
// --- Charged Shot Pellet Pattern (Restored) ---
SHTG A 0 Bright A_RailAttack (15, 0, 0, none, "Gold" , RGF_NOPIERCING|RGF_EXPLICITANGLE|RGF_FULLBRIGHT|RGF_SILENT, 0, "ARPuff", random (-6,5),random (-4,3), 0, 8, 12, 3, none, 4)
SHTG A 0 Bright A_RailAttack (10, 0, 0, none, "Gold" , RGF_NOPIERCING|RGF_EXPLICITANGLE|RGF_FULLBRIGHT|RGF_SILENT, 0, "ARPuff", random (-6,5),random (-4,3), 0, 8, 12, 3, none, 4)
SHTG A 0 Bright A_RailAttack (5, 0, 0, none, "Gold" , RGF_NOPIERCING|RGF_EXPLICITANGLE|RGF_FULLBRIGHT|RGF_SILENT, 0, "ArPuff", random (-6,5),random (-4,3), 0, 8, 12, 3, none, 4)
SHTG A 0 Bright A_RailAttack (15, 0, 0, none, "Gold" , RGF_NOPIERCING|RGF_EXPLICITANGLE|RGF_FULLBRIGHT|RGF_SILENT, 0, "ArPuff", random (-6,5),random (-4,3), 0, 8, 12, 3, none, 4)
SHTG A 0 Bright A_RailAttack (5, 0, 0, none, "Gold" , RGF_NOPIERCING|RGF_EXPLICITANGLE|RGF_FULLBRIGHT|RGF_SILENT, 0, "ArPuff", random (-6,5),random (-4,3), 0, 8, 12, 3, none, 4)
SHTG A 0 Bright A_RailAttack (10, 0, 0, none, "Gold" , RGF_NOPIERCING|RGF_EXPLICITANGLE|RGF_FULLBRIGHT|RGF_SILENT, 0, "ArPuff", random (-6,5),random (-4,3), 0, 8, 12, 3, none, 4)
SHTG A 0 Bright A_RailAttack (5, 0, 0, none, "Gold" , RGF_NOPIERCING|RGF_EXPLICITANGLE|RGF_FULLBRIGHT|RGF_SILENT, 0, "ArPuff", random (-6,5),random (-4,3), 0, 8, 12, 3, none, 4)
SHTG A 0 Bright A_RailAttack (15, 0, 0, none, "Gold" , RGF_NOPIERCING|RGF_EXPLICITANGLE|RGF_FULLBRIGHT|RGF_SILENT, 0, "ARPuff", random (-6,5),random (-4,3), 0, 8, 12, 3, none, 4)
SHTG A 0 Bright A_RailAttack (10, 0, 0, none, "Gold" , RGF_NOPIERCING|RGF_EXPLICITANGLE|RGF_FULLBRIGHT|RGF_SILENT, 0, "ARPuff", random (-6,5),random (-4,3), 0, 8, 12, 3, none, 4)
SHTG A 0 Bright A_RailAttack (5, 0, 0, none, "Gold" , RGF_NOPIERCING|RGF_EXPLICITANGLE|RGF_FULLBRIGHT|RGF_SILENT, 0, "ArPuff", random (-6,5),random (-4,3), 0, 8, 12, 3, none, 4)
SHTG A 0 Bright A_RailAttack (15, 0, 0, none, "Gold" , RGF_NOPIERCING|RGF_EXPLICITANGLE|RGF_FULLBRIGHT|RGF_SILENT, 0, "ArPuff", random (-6,5),random (-4,3), 0, 8, 12, 3, none, 4)
SHTG A 0 Bright A_RailAttack (5, 0, 0, none, "Gold" , RGF_NOPIERCING|RGF_EXPLICITANGLE|RGF_FULLBRIGHT|RGF_SILENT, 0, "ArPuff", random (-6,5),random (-4,3), 0, 8, 12, 3, none, 4)
SHTG A 0 Bright A_RailAttack (10, 0, 0, none, "Gold" , RGF_NOPIERCING|RGF_EXPLICITANGLE|RGF_FULLBRIGHT|RGF_SILENT, 0, "ArPuff", random (-6,5),random (-4,3), 0, 8, 12, 3, none, 4)
SHTG A 0 Bright A_RailAttack (5, 0, 0, none, "Gold" , RGF_NOPIERCING|RGF_EXPLICITANGLE|RGF_FULLBRIGHT|RGF_SILENT, 0, "ArPuff", random (-6,5),random (-4,3), 0, 8, 12, 3, none, 4)
SHTG A 0 Bright A_RailAttack (15, 0, 0, none, "Gold" , RGF_NOPIERCING|RGF_EXPLICITANGLE|RGF_FULLBRIGHT|RGF_SILENT, 0, "ARPuff", random (-6,5),random (-4,3), 0, 8, 12, 3, none, 4)
SHTG A 0 Bright A_RailAttack (10, 0, 0, none, "Gold" , RGF_NOPIERCING|RGF_EXPLICITANGLE|RGF_FULLBRIGHT|RGF_SILENT, 0, "ARPuff", random (-6,5),random (-4,3), 0, 8, 12, 3, none, 4)
SHTG A 0 Bright A_RailAttack (5, 0, 0, none, "Gold" , RGF_NOPIERCING|RGF_EXPLICITANGLE|RGF_FULLBRIGHT|RGF_SILENT, 0, "ArPuff", random (-6,5),random (-4,3), 0, 8, 12, 3, none, 4)
SHTG A 0 Bright A_RailAttack (15, 0, 0, none, "Gold" , RGF_NOPIERCING|RGF_EXPLICITANGLE|RGF_FULLBRIGHT|RGF_SILENT, 0, "ArPuff", random (-6,5),random (-4,3), 0, 8, 12, 3, none, 4)
SHTG A 0 Bright A_RailAttack (5, 0, 0, none, "Gold" , RGF_NOPIERCING|RGF_EXPLICITANGLE|RGF_FULLBRIGHT|RGF_SILENT, 0, "ArPuff", random (-6,5),random (-4,3), 0, 8, 12, 3, none, 4)
SHTG A 0 Bright A_RailAttack (10, 0, 0, none, "Gold" , RGF_NOPIERCING|RGF_EXPLICITANGLE|RGF_FULLBRIGHT|RGF_SILENT, 0, "ArPuff", random (-6,5),random (-4,3), 0, 8, 12, 3, none, 4)
SHTG A 0 Bright A_RailAttack (5, 0, 0, none, "Gold" , RGF_NOPIERCING|RGF_EXPLICITANGLE|RGF_FULLBRIGHT|RGF_SILENT, 0, "ArPuff", random (-6,5),random (-4,3), 0, 8, 12, 3, none, 4)
// --- Continue Animation ---
SPSF F 3 Bright // Second frame of charged flash/firing
SPAS C 4 // Start recovery/pump animation
SPAS C 3
SPAS C 4
SPAS B 3
SPAS B 3
SPAS B 3 A_WeaponReady
Goto PostFireCleanup
// Common state after firing either normal or charged shot
PostFireCleanup:
// Resetting the counter here instantly should be fine
SPAS B 1 A_TakeInventory("ChargeCounter", 6)
Goto Ready // Return to ready state
Flash:
TNT1 A 4 // Default flash duration if state is used
Goto LightDone
// Custom muzzle flash state (Not strictly needed now, but good for A_GunFlash fallback)
FlashCharged:
TNT1 A 6 // Custom flash duration if state is used
Goto LightDone
Spawn:
SHOT A -1 Bright // Assuming SHOT A is your pickup sprite
Stop
}
}
// Inventory item to track the charge level (no changes needed here)
ACTOR ChargeCounter : Inventory
{
Inventory.MaxAmount 6
Inventory.Amount 0
+INVENTORY.UNDROPPABLE
+INVENTORY.NOSCREENFLASH
}