// Powerup Crate and related actors

// A single spot for the powerup crate. Unfortunately SpecialSpot cannot be used
// here since A_SpawnSingleItem can only be used once.
actor PowerupCrateSpot 21410 {
	//$Category Pickups
	+NOINTERACTION
	+SERVERSIDEONLY
	Tag "Powerup Crate Spot"
	States {
	Spawn:
		TNT1 A 0 A_GiveInventory ("IsCrateSpot", 1)
		TNT1 A 0 ACS_ExecuteAlways (810, 0) // Get a TID for the spot.
		TNT1 A -1
		stop
	}
}

actor IsCrateSpot : Inventory {}

actor PowerupCrate : CustomInventory 21411 {
	//$Category Pickups
	+ALWAYSPICKUP
	Tag "Powerup Crate"
	Gravity 0.125
	inventory.pickupmessage "Powerup Crate"
	inventory.pickupsound "powerup/basic"
	inventory.respawntics 2100 // 1 minute
	states {
	Spawn:
		UCRT A 6 BRIGHT
		UCRT A 6
		loop
	Pickup:
		TNT1 A 0 ACS_ExecuteAlways (309, 0, -1)
		stop
	}
}

// Map marker for Powerup Crate.
actor CrateMapMarker : MapMarker {
	//$Category Markers
	Tag "Powerup Crate Map-Marker"
	+CLIENTSIDEONLY
	scale 0.4
	states {
	Spawn:
		AMRK A -1
		stop
	}
}

actor PowerSpeedUpgrade : PowerSpeed {
	Speed 1.3
}

actor SpeedUpgrade : PermanentPowerup {
	Powerup.Type "SpeedUpgrade"
	Powerup.Duration 10500
}

actor PowerFatigue : PowerSpeed {speed 0.55}
actor SpeedDowngrade : PermanentPowerup {
	powerup.type "Fatigue"
	powerup.duration -60
}

actor IronCurtain : PowerupGiver {
	+AUTOACTIVATE
	+ALWAYSPICKUP
	Inventory.MaxAmount 0
	Powerup.Duration 1050
	Powerup.Type "IronCurtain"
	Powerup.Color GreenMap
}

actor IronCurtainHealth : Health
{
	inventory.amount 1000
	inventory.maxamount 1000
}

// Separate class to determine if invulnerable
// because of Iron Curtain or of other sources
// e.g. spawn invul
actor PowerIronCurtain : PowerInvulnerable {}

actor PowerThermalCloak : PowerDamage {
	DamageFactor Normal, 1.0
}

actor ThermalCloak : PermanentPowerup {
	Powerup.Type ThermalCloak
	Powerup.Duration -90
}

actor NukeKamikaze {
	+NOINTERACTION
	+FORCERADIUSDMG
	obituary "$OB_KAMIKAZE" // "%k make %o go boom!"
	damagetype "Explosion"
	states {
	Spawn:
		TNT1 A 0
		TNT1 A 0 A_SpawnItemEx ("Nuke", 0,0,0,0,0,0,0,160)
		TNT1 A 5 A_Explode(7000, 1024, 1)
		stop
	}
}

actor BlueStrikeKamikaze : NukeKamikaze {
	damagetype "Explosion"
	states {
	Spawn:
		TNT1 A 0
		TNT1 A 0 A_SpawnItemEx ("BlueStrike", 0,0,0,0,0,0,0,160)
		TNT1 A 5 A_Explode (7000, 1024, 1)
		stop
	}
}

actor BombExplosion : KamikazeExplosion {
	+EXTREMEDEATH
	obituary "%o was blasted away by %k's bomb crate."
	damagetype "Monster"
	states {
	Spawn:
		TNT1 A 0
		TNT1 A 0 A_SpawnItemEx ("KamikazeExplosionFX")
		TNT1 A 0 A_Explode (5000, 128)
		TNT1 A 0 A_Explode (1500, 256)
		stop
	}
}
actor IsBombCrate : Inventory {}

// ==== NEW BOMB CRATE STUFF
actor BombCrateFXBlue1 {
	PROJECTILE
	+NOINTERACTION
	+CLIENTSIDEONLY
	+FORCEXYBILLBOARD
	+NOCLIP
	radius 0
	height 0
	renderstyle add
	alpha 0
	reactiontime 42
	scale 3
	states {
	Spawn:
		ION1 A 0
		goto Idle
	Idle:
		"----" A 0 bright A_FadeIn (0.015)
		"----" AAAA 1 bright ACS_ExecuteAlways (966, 0)
		"----" A 0 bright A_Countdown
		loop
	Clear:
		TNT1 A 0
		TNT1 A 5 A_StopSound (1)
		stop
	Death:
		ION1 A 0
		stop
	}
}

actor BombCrateFXBlue2 : BombCrateFXBlue1 {
	scale 2.7
	states {
	Spawn:
		ION1 B 0
		goto Idle
	}
}

actor BombCrateFXBlue3 : BombCrateFXBlue1 {
	scale 2.5
	states {
	Spawn:
		ION1 C 0
		goto Idle
	}
}

actor BombCrateFXBlue4 : BombCrateFXBlue1 {
	scale 2.5
	states {
	Spawn:
		ION1 D 0
		goto Idle
	}
}

actor BombCrateFXRed1 : BombCrateFXBlue1 {
	scale 1
	states {
	Spawn:
		FLAR A 0
		goto Idle
	}
}

actor BombCrateFXRed2 : BombCrateFXBlue1 {
	scale 0.9
	states {
	Spawn:
		FLA2 A 0
		goto Idle
	}
}

actor BombCrateFXRed3 : BombCrateFXBlue1 {
	scale 0.8
	states {
	Spawn:
		FLA3 A 0
		goto Idle
	}
}

actor BombCrateFXRed4 : BombCrateFXBlue1 {
	scale 0.8
	states {
	Spawn:
		FLA4 A 0
		goto Idle
	}
}

actor BombCrateFXGiverBlue : CustomInventory {
	+AUTOACTIVATE
	+ALWAYSPICKUP
	states {
	Pickup:
		TNT1 A 0
		TNT1 A 0 A_SpawnItemEx ("BombCrateFXBlue1", 0,0,0,0,0,0,0, 32)
		TNT1 A 0 A_SpawnItemEx ("BombCrateFXBlue2", 0,0,0,0,0,0,0, 32)
		TNT1 A 0 A_SpawnItemEx ("BombCrateFXBlue3", 0,0,0,0,0,0,0, 32)
		TNT1 A 0 A_SpawnItemEx ("BombCrateFXBlue4", 0,0,0,0,0,0,0, 32)
		stop
	}
}

actor BombCrateFXGiverRed : CustomInventory {
	+AUTOACTIVATE
	+ALWAYSPICKUP
	states {
	Pickup:
		TNT1 A 0 A_SpawnItemEx ("BombCrateFXRed1", 0,0,0,0,0,0,0, 32)
		TNT1 A 0 A_SpawnItemEx ("BombCrateFXRed2", 0,0,0,0,0,0,0, 32)
		TNT1 A 0 A_SpawnItemEx ("BombCrateFXRed3", 0,0,0,0,0,0,0, 32)
		TNT1 A 0 A_SpawnItemEx ("BombCrateFXRed4", 0,0,0,0,0,0,0, 32)
		stop
	}
}

actor PowerRadar : Powerup {}

actor Radar : PowerupGiver 15400 {
	//$Category Powerups
	+INVENTORY.AUTOACTIVATE
	+INVENTORY.ALWAYSPICKUP
	Inventory.PickupMessage "Radar"
	Powerup.Type Radar
	Powerup.Duration 10500 // Five minutes
	Inventory.MaxAmount 1
	States {
	Spawn:
		MMAP ABCD 4 Bright
		loop
	}
}

actor ImpSpawner {
	MONSTER
	+SERVERSIDEONLY
	+THRUACTORS
	+DROPOFF
	Radius 2
	Height 2
	Speed 8
	States {
	Spawn:
		PUFF AAAAA 1 A_Wander
		PUFF A 0 ACS_ExecuteAlways (808, 0)
		PUFF A 0 A_JumpIfInventory ("ImpSpawnerCount", 7, "GoAway")
		loop
	GoAway:
		TNT1 A 0
		stop
	}
}

actor ImpSpawnerCount : Inventory {
	Inventory.MaxAmount 0x7FFFFFFF
}

actor ImpSpawnerTarget : Inventory {
	Inventory.MaxAmount 0x7FFFFFFF
}

// [JD] used to keep track of Soulsphere powerups from the crate.
Actor CRATE_SoulsphereDummyItem : Inventory
{
	Inventory.MaxAmount 1
}

Actor hasTeamBoost : Inventory
{
	Inventory.Amount 1
	Inventory.MaxAmount 1
}
