actor TorrentBubbleWep_NormalBar : NormalBar{args 4,75}
actor TorrentBubbleWep : BaseMM8BDMWep 
{
Weapon.AmmoUse 1
Weapon.AmmoGive 50
Weapon.SlotNumber 7
Inventory.Pickupmessage "$PU_TORRENTBUBBLE"
Obituary "$OB_TORRENTBUBBLE"
Tag "$TAG_TORRENTBUBBLE"
weapon.ammotype "TorrentBubbleAmmo"
inventory.pickupsound "weapon/weaponup"
inventory.icon "TOBLICON"
+WEAPON.AMMO_OPTIONAL
Scale 2.0
States
{
SpawnLoop:
TOBL Z 1
loop
Ready:
TOBL A 0 ACS_NamedExecuteWithResult("core_weaponcolor",COLOR_TORRENTBUBBLE)
TOBL A 1 A_WeaponReady
Goto Ready+1
ReadyC: Goto Ready+1
Deselect:
TOBL A 0 
goto DeselectSwap
Select:
TOBL A 0 
goto SelectSwap

Fire:
TOBL A 0 A_JumpIfNoAmmo("NoAmmo")
TOBL A 0 A_PlaySoundEx("Weapon/TorrentBubbleFire","Weapon")
TOBL A 0 A_FireCustomMissile("TorrentBubble",random(-4,4),1,8)
TOBL B 2
TOBL C 2
TOBL A 0 A_Refire
TOBL A 0 A_GiveInventory("TorrentBubbleFlag",1)
TOBL A 2
goto Ready+1
AltFire:
TOBL A 0 A_JumpIfInventory("Vile_ClassAltfire", 1, "ClassAltfire")
TOBL A 0 A_JumpIf(CallACS("Vile_class_altfire"), "ClassAltfire")
TOBL A 1 A_JumpIfInventory("MM8BDMPlayer", 1, 1)
wait
TOBL A 0 A_JumpIfNoAmmo("NoAmmo")
TOBL A 0 A_PlaySoundEx("Weapon/TorrentBubbleFire","Weapon")
TOBL A 0 A_FireCustomMissile("TorrentBubbleLightning",0,1,8,0)
TOBL B 3
TOBL CA 3
goto Ready+1
ClassAltfire:
TOBL A 0 
goto Super::Altfire
NoAmmo:
TOBL A 0 A_GiveInventory("TorrentBubbleFlag",1)
TOBL A 1 ACS_NamedExecuteAlways("core_noammo",0)
Goto Ready+1
}
}

actor TorrentBubbleFlag : PowerUp {Powerup.duration 6}

actor TorrentBubble : ProjSpawnFuncActor
{
+HEXENBOUNCE
+DONTRIP
+SHOOTABLE
+NOGRAVITY
+BRIGHT
health 10
var int user_A;
var int user_NoOwnerDamage;
+MISSILE
+NOTARGETSWITCH
+SEEKERMISSILE
Radius 14
Height 14
Obituary "$OB_TORRENTBUBBLE"
damagetype "TorrentBubble"
scale 2.5
damage (CallACS("vile_cbm_damage",4))
speed 17
reactiontime 14
species "TorrentBubble"
+THRUSPECIES
States
{
Spawn:
TOBL I 0
TOBL I 2 A_RearrangePointers(AAPTR_DEFAULT, AAPTR_TARGET, AAPTR_TARGET, PTROP_NOSAFEGUARDS)
TOBL I 0 A_ChangeVelocity(random(-2,2),random(-2,2),random(-2,6))
TOBL JJKK 1 A_JumpIfInTargetInventory("TorrentBubbleFlag",1,"Flying")
Flying:
TOBL O 0 A_SeekerMissile(12, 90, SMF_PRECISE, 0)
TOBL OO 1 A_JumpIfInTargetInventory("TorrentBubbleFlag",1,"PopTheBubble")
TOBL KK 1 A_JumpIfInTargetInventory("TorrentBubbleFlag",1,"PopTheBubble")
TNT1 A 0 A_Countdown
Loop
PopTheBubble:
TOBL K 1
Death:
FireOff:
TNT1 A 0 ACS_NamedExecuteWithResult("vilecbm_CopyPointerAnglePitch",2,0)//Change pitch to player pitch
TNT1 A 0 A_SetUserVar("user_A",CallACS("vilecbm_FetchPointerAngle",2)*360.0/256.0*100000.0)//Record player angle
TOBL O 1
TOBL O 0 A_PlaySoundEx("Weapon/TorrentBubblePop","Weapon")
TNT1 I 0 A_SpawnItemEx("TorrentBubbleLightning",0,0,0,cos(-pitch)*60,0,sin(-pitch)*60,user_A/100000.0,4)
TOBL OXY 3 A_Stop
TNT1 A 8
stop
XDeath:
TNT1 A 0 
stop
}
}

actor TorrentBubbleLightning : BasicProjectile
{
species "TorrentBubble"
+THRUSPECIES
PROJECTILE
Radius 16
Height 16
Obituary "$OB_TORRENTBUBBLE"
damagetype "TorrentBubble"
scale 2.5
damage (CallACS("vile_cbm_damage",4))
speed 60
States
{
Spawn:
TOBL L 39
goto Death+2
Death:
TNT1 O 0 A_PlaySoundEx("Weapon/TorrentBubbleLand","Weapon")
TOBL OXY 3
stop
}
}

actor TorrentBubbleAmmo : Ammo
{
inventory.amount 1
inventory.maxamount 50
+INVENTORY.IGNORESKILL
}
