/*
CREDITS:
Pitchfork sprites - Monolith (Blood)
Smoke and particles - Folks from AEoD
Sphere and white glow - Zrrion the Insect

Sounds:
Rotating forks, fork impact - Ubisoft (Will Rock)
Idle - Raven (Wolfenstein 3)
Creepy laughs - Looking Glass (Thief)
Forks launching, part of pickup, use - Blizzard (Diablo II)
*/

ACTOR ForkGod : PlayerPawn
{
  Health 666
  ReactionTime 0
  PainChance 255
  Mass 9999999
  Radius 16
  Height 56
  Speed 1
  +NOSKIN
  +INVULNERABLE
  +NOGRAVITY
  +FLOAT
  PainSound ""
  DeathSound ""
  Player.Viewheight 45
  Player.SpawnClass ""
  Player.SoundClass ""
  Player.DisplayName "God of Pitchforks"
  Player.MorphWeapon "ForkMaster"
  -PICKUP
  States
  {
  Spawn:
    TNT1 A -1
    Stop
  See:
    TNT1 A 1
    Loop
  Melee:
  Missile:
    TNT1 A 1
    Goto Spawn
  Pain:
    TNT1 A 1
    Goto Spawn
  Death:
    TNT1 A 1 A_Scream
    TNT1 A -1
    Stop
  }
}

ACTOR ForkMaster : Weapon
{
  Weapon.Kickback 200
  /*Weapon.BobStyle InverseSmooth
  Weapon.BobSpeed 1.0
  Weapon.BobRangeY 0.6
  Weapon.BobRangeX 1.2*/
  +WEAPON.CHEATNOTWEAPON
  States
  {
  Ready:
  FRKG A 0 A_TakeInventory("ForkCharge",1)
  FRKG A 0 A_PlaySound("Fork/Idle",5,1.0,1)
  FRKG ABC 2 Bright A_WeaponReady
  TNT1 A 0 A_JumpIfInventory("RO_GotoReload", 1, "Reload")
  Loop
  Fire:
  FRKG A 0 A_TakeInventory("ForkCharge",6)
  FRKF A 1 Bright Offset(0,35)
  FRKF A 1 Bright Offset(0,34)
  FRKF A 1 Bright Offset(0,33)
  FRKF A 1 Bright Offset(0,31)
  FRKF A 1 Bright Offset(0,29)
  FRKF A 1 Bright Offset(0,26)
  FRKF A 1 Bright Offset(0,23)
  FRKF A 1 Bright Offset(0,20)
  FRKF B 1 Bright Offset(0,32)
  FRKF B 1 Bright Offset(0,29)
  FRKF B 1 Bright Offset(0,26) A_ZoomFactor(0.995)
  FRKF B 1 Bright Offset(0,24) A_ZoomFactor(0.99)
  FRKF C 1 Bright Offset(0,32) A_ZoomFactor(0.97)
  FRKF A 0 A_PlaySound("Weapons/ExcalibatWoosh",1)
  FRKF A 0 A_SetBlend("White",0.3,20)
  FRKF A 0 A_Quake(2,15,0,16,"none")
  FKRF A 0 A_FireCustomMissile("PowerFork")
  FRKF C 1 Bright Offset(0,31) A_ZoomFactor(0.7)
  FRKF C 1 Bright Offset(0,30) A_ZoomFactor(0.75)
  FRKF C 1 Bright Offset(0,29) A_ZoomFactor(0.8)

  FRKF C 1 Bright Offset(0,30) A_ZoomFactor(0.85)
  FRKF C 1 Bright Offset(0,31) A_ZoomFactor(0.9)
  FRKF C 1 Bright Offset(0,32) A_ZoomFactor(0.91)
  FRKF B 1 Bright Offset(0,24) A_ZoomFactor(0.92)
  FRKF B 1 Bright Offset(0,26) A_ZoomFactor(0.93)
  FRKF B 1 Bright Offset(0,29) A_ZoomFactor(0.94)
  FRKF B 1 Bright Offset(0,32) A_ZoomFactor(0.95)
  FRKF A 1 Bright Offset(0,20) A_ZoomFactor(0.96)
  FRKF A 1 Bright Offset(0,23) A_ZoomFactor(0.97)
  FRKF A 1 Bright Offset(0,26) A_ZoomFactor(0.98)
  FRKF A 1 Bright Offset(0,29) A_ZoomFactor(0.99)
  FRKF A 1 Bright Offset(0,31) A_ZoomFactor(1)
  FRKF A 1 Bright Offset(0,33)
  FRKF A 1 Bright Offset(0,34)
  FRKF A 1 Bright Offset(0,35)
  Goto Ready
  AltFire:
  FRKG A 0 A_JumpIfInventory("ForkCharge",1,"Ready")
  FRKG A 0 //A_Stop
  FRKG A 0 A_GiveInventory("ForkCharge",60)
  FRKG A 0 A_PlaySound("Fork/Alt",6)
  FRKF A 1 Bright Offset(0,35)
  FRKF A 1 Bright Offset(0,34)
  FRKF A 1 Bright Offset(0,33)
  FRKF A 1 Bright Offset(0,31)
  FRKF A 1 Bright Offset(0,29)
  FRKF A 1 Bright Offset(0,26)
  FRKF A 1 Bright Offset(0,23)
  FRKF A 1 Bright Offset(0,20)
  FRKF B 1 Bright Offset(0,32)
  FRKF B 1 Bright Offset(0,29)
  FRKF B 1 Bright Offset(0,26) A_ZoomFactor(0.995)
  FRKF B 1 Bright Offset(0,24) A_ZoomFactor(0.99)
  FRKF C 1 Bright Offset(0,32) A_ZoomFactor(0.97)
  FRKF A 0 A_PlaySound("Weapons/ExcalibatWoosh",1)
  FRKF A 0 A_SetBlend("White",0.5,50)
  FRKF A 0 A_Quake(2,15,0,16,"none")
  FRKG A 0 A_SpawnItemEx("Forkageddon",0,0,0,0,0,0,0,SXF_TRANSFERPOINTERS)
  FRKF C 1 Bright Offset(0,31) A_ZoomFactor(0.7)
  FRKF C 1 Bright Offset(0,30) A_ZoomFactor(0.75)
  FRKF C 1 Bright Offset(0,29) A_ZoomFactor(0.8)

  FRKF C 1 Bright Offset(0,30) A_ZoomFactor(0.85)
  FRKF C 1 Bright Offset(0,31) A_ZoomFactor(0.9)
  FRKF C 1 Bright Offset(0,32) A_ZoomFactor(0.91)
  FRKF B 1 Bright Offset(0,24) A_ZoomFactor(0.92)
  FRKF B 1 Bright Offset(0,26) A_ZoomFactor(0.93)
  FRKF B 1 Bright Offset(0,29) A_ZoomFactor(0.94)
  FRKF B 1 Bright Offset(0,32) A_ZoomFactor(0.95)
  FRKF A 1 Bright Offset(0,20) A_ZoomFactor(0.96)
  FRKF A 1 Bright Offset(0,23) A_ZoomFactor(0.97)
  FRKF A 1 Bright Offset(0,26) A_ZoomFactor(0.98)
  FRKF A 1 Bright Offset(0,29) A_ZoomFactor(0.99)
  FRKF A 1 Bright Offset(0,31) A_ZoomFactor(1)
  FRKF A 1 Bright Offset(0,33)
  FRKF A 1 Bright Offset(0,34)
  FRKF A 1 Bright Offset(0,35)
  Goto Ready
  Looplo:
  FRKF A 0 A_Quake(1,3,0,16,"none")
  FRKG ABC 1 Bright
  Loop
  TheEnd:
  FRKG A 0
  Goto Ready
  Select:
  FRKG AAAAAAAAA 0 A_Raise
  FRKG A 1 Bright A_Raise
  Loop
  Deselect:
  FRKG A 0 A_StopSound(5)
  FRKG A 0 A_ZoomFactor(1)
  FRKG AAAAAAAAA 0 A_Lower
  FRKG A 1 Bright A_Lower
  Loop
  Reload:
  FRKG A 0 A_ChangeFlag("Invulnerable",0)
  FRKG A 0 ACS_ExecuteAlways(700, 0, 0, 0, 0)
  Goto Ready
  }
}

ACTOR ForkCharge : Inventory { Inventory.MaxAmount 999 }

ACTOR Powerfork : FastProjectile
{
	Radius 12
	Height 18
	Speed 100
	Damage 100
	Projectile
	+SEEKERMISSILE
	+FOILINVUL
	+DONTSPLASH
	+SKYEXPLODE
	+RIPPER
	MissileType "PowerforkTrail"
	Obituary "%o was tracked down by %k's wratful pitchfork of damnation."
	States
	{
	Spawn:
	XIPP A 0
	XIPP A 1 A_SeekerMissile(5,20,SMF_LOOK|SMF_PRECISE,256,10)
	Loop
	Death:
	XIPP A 105 A_PlaySound("Fork/Hit")
	XIPP A 1 A_FadeOut(0.1)
	Wait
	}
}

ACTOR PowerforkTrail
{
	+NOINTERACTION
	+CLIENTSIDEONLY
	+NOGRAVITY
	States
	{
	Spawn:
	TNT1 AA 0 A_SpawnItemEx("ForkSmoke",random(30,-30),random(30,-30),random(30,-30),frandom(0.1,0.2),frandom(0.1,0.2),frandom(-0.2,0.2),random(0,359))
	TNT1 A 0 A_SpawnItemEx("ForkParticle",random(20,-20),random(20,-20),random(20,-20),0,0,frandom(0.1,1.0),0,0,192)
	Goto Ready
	}
}

ACTOR ForkSmoke
{
	+NOINTERACTION
	+CLIENTSIDEONLY
	+NOGRAVITY
	Renderstyle Add
	Alpha 0.6
	Scale 0.8
	States
	{
	Spawn:
	FRKS ABCDEFGHIJKLMNOPQR 1
	Stop
	}
}

ACTOR ForkParticle
{
	+NOINTERACTION
	+CLIENTSIDEONLY
	+NOGRAVITY
	Renderstyle Add
	Alpha 1.0
	Scale 0.6
	States
	{
	Spawn:
	FRKP AA 0 A_FadeOut(0.05)
	FRKP A 1 //A_SetScale(ScaleX-0.025,ScaleX)
	Loop
	}
}

ACTOR Forkageddon
{
	+NOINTERACTION
	+NOGRAVITY
	ReactionTime 53
	States
	{
	Spawn:
	TNT1 A 0
	TNT1 A 0 A_SpawnItemEx("PowerforkHelicopter",random(300,-300),random(300,-300),random(-20,70),0,0,random(0.2,0.8),0,SXF_TRANSFERPOINTERS)
	TNT1 A 3 A_Countdown
	Loop
	Death:
	TNT1 A 0
	Stop
	}
}

ACTOR ForkTurn
{
	+NOINTERACTION
	+CLIENTSIDEONLY
	+NOGRAVITY
	States
	{
	Spawn:
	TNT1 A 0
	TNT1 AAAAAAAAAAAAAAA 0 A_SpawnItemEx("ForkSmoke",random(30,-30),random(30,-30),random(30,-30),frandom(0.1,0.2),frandom(0.1,0.2),frandom(-0.2,0.2),random(0,359))
	TNT1 AAAAAAAA 0 A_SpawnItemEx("ForkParticle",random(30,-30),random(30,-30),random(30,-30),0,0,frandom(0.1,1.0),0,0,192)
	TNT1 A 1
	Stop
	}
}

ACTOR PowerforkHelicopter
{
	ReactionTime 14
	+FOILINVUL
	+DONTSPLASH
	+SKYEXPLODE
	+NOINTERACTION
	States
	{
	Spawn:
	XIPP A 0
	XIPP A 0 A_SetAngle(Angle+random(0,359))
	Looplo:
	XIPP A 0 A_Countdown
	XIPP A 0 A_PlaySound("Fork/Rotate",5,1.0,1)
	XIPP A 5 A_SetAngle(Angle+45)
	Loop
	Death:
	TNT1 A 0 A_PlaySound("Fork/Fly",5,1.0,0)
	TNT1 A 0 A_SpawnItemEx("ForkTurn")
	TNT1 A 1 A_SpawnItemEx("Powerforker",0,0,0,0,0,0,0,SXF_TRANSFERPOINTERS)
	Stop
	}
}

ACTOR Powerforker
{
   Radius 1
   Height 1
   +ISMONSTER
   +FRIENDLY
   +LOOKALLAROUND
   +NOBLOCKMONST
   +NOGRAVITY
   +NOINTERACTION
   +DONTBLAST
   Obituary "%o was tracked down by %k's wratful pitchforks of damnation."
   States
   {
   Spawn:
      TNT1 A 0
      TNT1 A 1 A_LookEx(0,0,16384,16384,0,"See")
      Stop
   See:
   Missile:
      TNT1 A 0 A_FaceTarget
      TNT1 A 1 A_CustomMissile("Powerfork2",0,0,0,CMF_TRACKOWNER)
      Stop
   XDeath:
      TNT1 A 1
      stop
   Death:
      TNT1 A 1
      stop
   }
}

ACTOR Powerfork2 : Powerfork
{
	-SEEKERMISSILE
	MissileType "PowerforkTrail2"
	Damage 500
}

ACTOR PowerforkTrail2
{
	+NOINTERACTION
	+NOGRAVITY
	+CLIENTSIDEONLY
	States
	{
	Spawn:
	TNT1 AA 0 A_SpawnItemEx("ForkSmoke",random(30,-30),random(30,-30),random(30,-30),frandom(0.1,0.2),frandom(0.1,0.2),frandom(-0.2,0.2),random(0,359),SXF_TRANSFERPOINTERS,192)
	TNT1 A 0 A_SpawnItemEx("ForkParticle",random(20,-20),random(20,-20),random(20,-20),0,0,frandom(0.1,1.0),0,SXF_TRANSFERPOINTERS,214)
	Goto Ready
	}
}

actor Forksphere : CustomInventory
{
  Inventory.PickupMessage "Forksphere! (Turns you into almighty evil deity of pitchforks. Cool, ain't it?)\nWant to get off from it? Press the reload button!"
  Inventory.Amount 1
  Inventory.MaxAmount 1
  Inventory.InterHubAmount 1
  Inventory.PickupSound "Fork/Pickup"
  Inventory.UseSound ""
  Inventory.Icon ARTIFORK
  Renderstyle Add
  +INVENTORY.FANCYPICKUPSOUND
  +INVBAR
  +FLOATBOB
  +FLOAT
  states
  {
  Use:
   TNT1 A 0 A_PlaySound("Fork/Use")
   TNT1 A 0 ACS_ExecuteAlways(701, 0, 0, 0, 0)
   stop
  Spawn:
    GFRK ABCDCB 3 Bright
    loop
  }
}

ACTOR Forkanator : PowerupGiver
{
 Inventory.PickupMessage "Yeah well, you just turned into almighty evil deity of pitchforks. Have fun."  
 Inventory.PickupSound "Fork/Pickup"
 Powerup.Type ForkGodman
 Powerup.Duration 0x7FFFFFFF
 +INVENTORY.FANCYPICKUPSOUND
 +INVBAR
 +FLOATBOB
 +FLOAT
 +INVENTORY.AUTOACTIVATE
 +INVENTORY.ALWAYSPICKUP
 States
 {
  Spawn:
    GFRK ABCDCB 3 Bright
    Loop
 }
}

ACTOR PowerForkGodman : PowerMorph
{
 PowerMorph.PlayerClass "ForkGod"
 PowerMorph.MorphStyle (MRF_FULLHEALTH|MRF_WHENINVULNERABLE|MRF_LOSEACTUALWEAPON|MRF_UNDOBYDEATH|MRF_UNDOBYDEATHSAVES)
 PowerMorph.MorphFlash "ForkTurn"
 PowerMorph.UnMorphFlash "ForkTurn"
}

ACTOR LegitKiller
{
	+NOINTERACTION
	States
	{
	Spawn:
	TNT1 AA 0 A_Explode(1,128,1,0,128)
	Stop
	}
}
