// Freeze Thrower

ACTOR FreezeThrower : IDMWeapon
{
  Weapon.SelectionOrder 50
  Weapon.AmmoUse 1
  Weapon.AmmoGive 100
  Weapon.AmmoType "IDMCell"
  //Weapon.PreferredSkin "FreezeMarine"
  Inventory.PickupMessage "Freeze Thrower! (Slot 6)"
  Tag "Freeze Thrower"
  +WEAPON.BFG
  +WEAPON.NOLMS
  States
  {
  Ready:
    FRSG A 1 A_WeaponReady
    Loop
  Deselect:
    FRSG A 1 A_Lower
    Loop
  Select:
	TNT1 A 0 A_PlaySound("weapons/wswitch",CHAN_WEAPON)
  Sloop:
    FRSG A 1 A_Raise
    Loop
  Fire:
	TNT1 A 0 A_Playsound("weapons/freezecnnf",CHAN_WEAPON)
	FRSG A 18 A_GunFlash
	Goto Hold
  Hold:
    TNT1 A 0 A_GunFlash("Flash2")
	TNT1 A 0 A_JumpIfInventory("PowerIDMWeaponLevel2",1,"Level2")
	TNT1 A 0 A_JumpIfInventory("PowerQuadDamage",1,"Quad")
	FRSG A 2 Bright A_FireCustomMissile("FreezeBall",frandom(-4,4),1,0,0,0)
    TNT1 A 0 A_GunFlash("Flash3")
	FRSG A 2 Bright A_FireCustomMissile("FreezeBall",frandom(-4,4),1,0,0,0)
  FireEnd:
	TNT1 A 0 A_Refire("Hold")
    FRSG B 30 A_GunFlash("Flash4")
    Goto Ready
  Quad:
    TNT1 A 0 A_Playsound("misc/qdmg2",CHAN_5,1)
	FRSG A 2 Bright A_FireCustomMissile("FreezeBall",frandom(-4,4),1,0,0,0)
    TNT1 A 0 A_GunFlash("Flash3")
	TNT1 A 0 A_Playsound("misc/qdmg2",CHAN_5,1)
	FRSG A 2 Bright A_FireCustomMissile("FreezeBall",frandom(-4,4),1,0,0,0)
	Goto FireEnd
  Level2:
	TNT1 A 0 A_JumpIfInventory("PowerQuadDamage",1,"QuadLevel2")
    TNT1 A 0 A_GunFlash("Flash2")
	FRSG A 1 Bright A_FireCustomMissile("FreezeBall2",frandom(-10,10))
    TNT1 A 0 A_GunFlash("Flash3")
	FRSG A 1 Bright
	Goto FireEnd
  QuadLevel2:
    TNT1 A 0 A_Playsound("misc/qdmg2",CHAN_5,1)
	Goto Level2+1
  Flash:
	FRSG A 12 Bright
	FRSF AB 3 Bright
	Goto LightDone
  Flash2:
    FRSF A 4 Bright A_Light1
    Goto LightDone
  Flash3:
	FRSF B 4 Bright A_Light1
    Goto LightDone
  Flash4:
	FRSG B 5 Bright A_Light1
	Goto LightDone
  Spawn:
    FRAS A -1 Bright
    Stop
  }
}

// Freezethrower Snowball

ACTOR FreezeBall : FastProjectile
{
  Radius 13
  Height 8
  Speed 50
  Damage (25*random(1,4))
  DamageType Ice
  Projectile
  ProjectileKickBack 25
  RenderStyle Add
  Alpha 0.75
  SeeSound "weapons/freezeshot"
  DeathSound "weapons/freezehit"
  Obituary "%o got frozen solid by %k's Freezethrower."
  Decal FreezeBlastMelt
  +RANDOMIZE
  +SKYEXPLODE
  -NOTELEPORT
  States
  {
  Spawn:
    FBLS A 1 bright A_SpawnItemEx("FreezeBallTrail")
    loop
  Death:
	TNT1 A 0
	TNT1 AAAAAAAAAA 0 A_SpawnItemEx("FreezeBallShard",0,0,0,frandom(5,20),0,frandom(0,10),frandom(0,360),SXF_TRANSFERPOINTERS)
    FBLS BCDE 3 bright
    stop
  }
}

ACTOR ExtremeFreezeBall : FreezeBall
{
	+EXTREMEDEATH
	States
	{
	XDeath:
	  TNT1 A 0 A_Playsound("misc/crit",CHAN_AUTO)
	  Goto Death
	}
}

ACTOR FreezeBall2 : FreezeBall
{
  States
  {
  Death:
	TNT1 A 0
	TNT1 AAAAA 0 A_CustomMissile("FreezeSpikeBall",0,0,frandom(120,240),CMF_AIMDIRECTION|CMF_TRACKOWNER,frandom(-5,5))
	TNT1 AAAAAAAAAA 0 A_SpawnItemEx("FreezeBallShard",0,0,0,frandom(5,20),0,frandom(0,10),frandom(0,360),SXF_TRANSFERPOINTERS)
    FBLS BCDE 3 bright
    stop
  }
}

ACTOR FreezeBallShard
{
  Radius 6
  Height 4
  Speed 25
  Damage (20*random(1,4))
  DamageType Ice
  Projectile
  ProjectileKickback 10
  Gravity 0.5
  RenderStyle Add
  Alpha 0.75
  Obituary "%o got frozen solid by %k's Freezethrower."
  Decal BulletChip
  +RANDOMIZE
  +SKYEXPLODE
  -NOGRAVITY
  -NOTELEPORT
  States
  {
  Spawn:
    FRT2 NOP 3 Bright
    Loop
  Death:
	TNT1 A 0 A_ChangeFlag(NOGRAVITY,1)
    FRT2 Q 7 Bright A_Playsound("weapons/freezehit",CHAN_VOICE,0.5,0)
    FRT2 R 7 Bright
	Stop
  }
}

ACTOR FreezeSpikeBall : FreezeBall
{
  Radius 10
  Height 6
  Speed 30
  Damage (20*random(1,4))
  States
  {
  Spawn:
	FRT2 ABC 2 Bright A_SpawnItem("FreezeSpikeBallTrail")
	Loop
  Death:
	TNT1 AAAAAAAAAA 0 A_SpawnItemEx("FreezeBallShard",0,0,0,frandom(5,20),0,frandom(0,10),frandom(0,360),SXF_TRANSFERPOINTERS)
	FRT2 DEFGH 2 Bright
	Stop
  }
}

ACTOR FreezeBallTrail
{
  Radius 13
  Height 8
  RenderStyle Add
  Alpha 0.75
  +NOCLIP
  +NOBLOCKMAP
  +NOGRAVITY
  +RANDOMIZE
  +CLIENTSIDEONLY
  States
  {
  Spawn:
	TNT1 A 3
  SpawnLoop:
    FRTR ABC 6 bright A_FadeOut(0.2)
    Loop
  }
}

ACTOR FreezeSpikeBallTrail : FreezeBallTrail
{
  Alpha 0.5
  States
  {
  Spawn:
    TNT1 A 2
    FRT2 IJKLM 3 Bright
	Stop
  }
}