
//Dusk damage chart (type: Dmg)
//SP: Unknown
//MP: Unknown


//The totem. Galena approves. Multiplayer only.


//The ammotype. Exclusive for this weapon.
ACTOR Dusk_TotemAmmo : Ammo 
{
	Game Doom
	SpawnID 11
	Inventory.PickupMessage "$PICKUP_BULLETS_12"
	Inventory.Amount 10
	Inventory.MaxAmount 100
	Ammo.BackpackAmount 0
	Ammo.BackpackMaxAmount 100
	Inventory.Icon "CLIPA0"
+IGNORESKILL
	Height 48
	Radius 20
	Scale 0.3
	States
	{
	Spawn:
		BUL1 ABCDEFGHIJKLMNOP 4 bright
		Loop
	}
}

//The weapon. Self explanatory.
ACTOR Dusk_Totem : DuskWeapon 
{
Weapon.Kickback 0
	+WEAPON.NOALERT
+weapon.AMMO_OPTIONAL
+WEAPON.NOAUTOAIM
+weapon.CHEATNOTWEAPON
	Weapon.SelectionOrder 89
Weapon.Slotnumber 9

	Weapon.AmmoGive 0
	Weapon.AmmoUse 4
	Weapon.AmmoType "Dusk_TotemAmmo"
	Weapon.UpSound "crossbow/raise"

	Inventory.PickupMessage "$TOTM_PICK"
	Tag "Totem"
	States
	{
	Ready:
W21E J 0 A_JumpIfInventory("Doosk_ExplosiveBarrelWeapon",1,"Select_Barrel")
TNT1 A 0 A_JumpIfInventory("Doosk_HereticBarrelWeapon",1,"Select_HereticBarrel")
TNT1 A 0 A_JumpIfInventory("Doosk_SoapWeapon",1,"Select_Soap")
	Ready_Totem:
		W21E J 1 bright A_WeaponReady(WRF_ALLOWRELOAD)
		Goto Ready
	Deselect:
    TNT1 A 0 A_TakeInventory("SetWeaponMemory",50)
    TNT1 A 0 A_GiveInventory("SetWeaponMemory",14)
	DeselectLoop:
		TST1 AAA 0 A_Lower
		TST1 A 1 bright A_Lower
		Loop
	Select:
		TNT1 A 0 A_SetCrosshair(17)
    TNT1 A 0 A_TakeInventory("SetWeaponActual",50)
    TNT1 A 0 A_GiveInventory("SetWeaponActual",14)
		TNT1 A 3 bright A_WeaponReady//(WRF_NOFIRE)
		W21A BCDEFGH 1 bright A_WeaponReady//(WRF_NOFIRE)
		Goto Ready


	Reload://Weapon melee
	TNT1 A 0 A_PlaySound("sickles/fire")
		W01G A 0 A_CustomPunch(2 * random(1, 10), TRUE, 0, "MeleePuff")

		W21B ABCDE 1 bright A_WeaponReady (WRF_NOBOB)//(WRF_ALLOWRELOAD)
		W21B FGHIJK 1 bright A_WeaponReady (WRF_ALLOWRELOAD|WRF_NOBOB)
		W21B LMNOPQRSTUVWXYZ 1 bright A_WeaponReady (WRF_ALLOWRELOAD)
		W21C AB 1 bright A_WeaponReady (WRF_ALLOWRELOAD)
		Goto Ready


BotFire:
TNT1 A 0 A_JumpIfInventory("Dusk_TotemAmmo",4,	"FireContinue")
    TNT1 A 0 A_SelectWeapon("Dusk_SuperShotgun")
Goto Ready_Totem


	Fire:
//W21E J 5 bright A_WeaponReady(WRF_NOFIRE)//A_JumpIfNoAmmo("Ready_Totem")
//TNT1 A 0 A_Refire("Fire_Continue")
//Goto Fire_Alt

//Fire_Continue:

	TNT1 A 0 A_JumpIfInventory("IsBot",1,"BotFire")

FireContinue:
W21E J 0 A_JumpIfNoAmmo("Ready_Totem")


		TNT1 A 0 A_GunFlash		TNT1 A 0 A_GiveInventory("Player_WeaponShot",1)


TNT1 A 0 A_JumpIfInventory("Fastfire_TotemAmount",31,	"Fire_Stacked2")
TNT1 A 0 A_JumpIfInventory("Fastfire_TotemAmount",1,	"Fire_Stacked1")

		W21D ABCDEF 1 bright A_WeaponReady (WRF_NOFIRE|WRF_NOSWITCH)
TNT1 A 0 A_Refire
		W21D GHIJKLMNOPQRSTUVWXYZ 1 bright A_WeaponReady (WRF_ALLOWRELOAD)
Fire_EndCommon:
		W21E ABCDEFGHIJ 1 bright A_WeaponReady (WRF_ALLOWRELOAD)
		Goto Ready

	Fire_Stacked1:
		W21D ABC 1 bright A_WeaponReady (WRF_NOFIRE|WRF_NOSWITCH)
TNT1 A 0 A_Refire
		W21D DEFGHIJKLMNOPQRSTUVWXYZ 1 bright A_WeaponReady (WRF_ALLOWRELOAD)
		Goto Fire_EndCommon


	Fire_Stacked2:
		W21D AB 1 bright A_WeaponReady (WRF_NOFIRE|WRF_NOSWITCH)
TNT1 A 0 A_Refire
		W21D CDEFGHIJKLMNOPQRSTUVWXYZ 1 bright A_WeaponReady (WRF_ALLOWRELOAD)
		Goto Fire_EndCommon







/*
	Fire_Alt:
	Altfire:
TNT1 A 0 A_JumpIfInventory("Dusk_TotemAmmo",15,	2)
TNT1 A 0 A_JumpIfInventory("Dusk_TotemAmmo",1,	"Ready_Totem")


		TNT1 A 0 A_GunFlash("AltFlash")		TNT1 A 0 A_GiveInventory("Player_WeaponShot",1)


TNT1 A 0 A_JumpIfInventory("Fastfire_TotemAmount",31,	"AltFire_Stacked2")
TNT1 A 0 A_JumpIfInventory("Fastfire_TotemAmount",1,	"AltFire_Stacked1")

		W21F ABCDEFGHIJKL 1 bright A_WeaponReady (WRF_NOFIRE|WRF_NOSWITCH)
TNT1 A 0 A_Refire("Altfire")
		W21F MNOPQRSTUVWXYZ 1 bright A_WeaponReady (WRF_ALLOWRELOAD)
Altfire_EndCommon:
		W21G ABCDEFGHIJKLMN 1 bright A_WeaponReady (WRF_ALLOWRELOAD)
		Goto Ready

	Altfire_Stacked1:
		W21F ABCDEF 1 bright A_WeaponReady (WRF_NOFIRE|WRF_NOSWITCH)
TNT1 A 0 A_Refire("Altfire")
		W21F GHIJKLMNOPQRSTUVWXYZ 1 bright A_WeaponReady (WRF_ALLOWRELOAD)
		Goto Altfire_EndCommon


	Altfire_Stacked2:
		W21F ABC 1 bright A_WeaponReady (WRF_NOFIRE|WRF_NOSWITCH)
TNT1 A 0 A_Refire("Altfire")
		W21F DEFGHIJKLMNOPQRSTUVWXYZ 1 bright A_WeaponReady (WRF_ALLOWRELOAD)
		Goto Altfire_EndCommon
*/		






	Flash:
	TNT1 A 0 A_AlertMonsters
W21E J 0 A_JumpIfNoAmmo("Ready_Totem")
	TNT1 A 0 A_PlaySound("totem/fire", CHAN_WEAPON)
		TNT1 A 0 A_FireCustomMissile("Dusk_Totem_4Bounces",0,1,random(-2,2),0,0,random(-2,2))
	FlashContinue:
	TNT1 A 0 ACS_NamedExecuteAlways("Weapon_Recoil", 0, 4, 0, 0)
		TNT1 A 3 A_Light2
		TNT1 A 4 A_Light1
		Goto LightDone
/*
	AltFlash:
	TNT1 A 0 A_AlertMonsters
W21E J 0 A_JumpIfNoAmmo("Ready_Totem")
	TNT1 A 0 A_PlaySound("sword/fire", CHAN_WEAPON)
		TNT1 A 0 A_FireCustomMissile("Dusk_Grenade",0,1,0,0,0,10)
	AltFlashContinue:
	TNT1 A 0 ACS_NamedExecuteAlways("Weapon_Recoil", 0, 1, 0, 0)
		TNT1 A 3 A_Light2
		TNT1 A 4 A_Light1
		Goto LightDone
*/




	Spawn:
		W08Z A -1
		Stop
	}
}



//Visual fx
actor Totempuff : DooskPuff
{
  SeeSound "Sil/Encio"//"Weapon/Hit" 
  AttackSound "Sickles/Wall"

	RenderStyle Stencil
	StencilColor LightBlue
}


ACTOR Totem_bulletFX
{
	+NOBLOCKMAP
+NOINTERACTION
	Gravity 0.125
	RenderStyle Stencil
	StencilColor LightBlue

	Scale 0.35
	States
	{
	Spawn:
		PART A 1 BRIGHT A_FadeOut(0.06)//0.04
		Loop
	}
}

ACTOR Dusk_Totem_4Bounces
{
    Radius 4
    Height 9
    Health 50 //(50+50+20direct = 120)
    Damage (random(15,30))//(randompick(10,15,20,25,30))
    Speed 40
    Mass 0
    BounceFactor 1
	WallBounceFactor 1
BounceCount 4

//    Gravity 0.25
    BounceType "Hexen"
//+MBFBOUNCER
    -ROCKETTRAIL
    PROJECTILE
    +CANBOUNCEWATER
    +NOGRAVITY
    +FORCERADIUSDMG
//+BOUNCEAUTOOFF
//+BOUNCEAUTOOFFFLOORONLY
+USEBOUNCESTATE

  ReactionTime 70 //(3 seconds) 
    +NOBLOCKMAP
    +MISSILE
    +BRIGHT
	+SEEKERMISSILE //Not actually used for anything other than checking radius.
SeeSound "Sil/Encio"
    BounceSound "totem/bounce"
//    DeathSound "weapons/rocklx"
    Obituary "$TOTM_OB"

	RenderStyle Stencil
	StencilColor LightBlue
Scale 1.0
    States
    {
    Spawn:
    Idle:
        MORT A 0 A_SpawnItemEx("Totem_BulletFX", random2[BoltSpark]()*0.015625, random2[BoltSpark]()*0.015625, 0, 0,0,0,0,SXF_ABSOLUTEPOSITION, 50)
   PART A 1 Bright A_CountDown
	Loop


bounce.ceiling:
bounce.wall:
bounce.floor:
		BLLT A 0 BRIGHT A_SpawnItem("TotemPuff")
Goto Idle




	Death: //crashed somewhere and checks for splash
        MISL B 0 //A_Explode
        Stop
		
		XDeath:	//splash damage beep
			TNT1 A 0 A_GiveToTarget("DamageDealtSoundItemHack",1)
		BLLT A 0 BRIGHT A_SpawnItem("Dusk_BloodParticle")
tnt1 a 0 A_PlaySound("Totem/bounce")
        MISL B 0 //A_Explode
        Stop
		

    }
}
 
