/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 * Burning corpses
 *
 * Players spawn these corpses when they are killed with fire or chemical
 * weapons. Can damage and kill enemies if they get too close, awarding
 * frags.
 */

actor BurningCorpse {
	MONSTER
	+FLOORCLIP
	+NORADIUSDMG
	-COUNTKILL
	-SHOOTABLE
	-ISMONSTER
	
	obituary "$OB_CORPSEBURN" // "%o got too close to %k burning corpse."
	radius 20
	height 56
	speed 12
	damagetype "Fire" // FireSpecial
	painsound "player/burn"
	states {
	Spawn:
		BDT1 A 0 BRIGHT
	See:
		BDT1 A 0 BRIGHT A_NoBlocking
		BDT1 A 0 BRIGHT A_Pain
		BDT1 A 0 BRIGHT A_Wander
		BDT1 A 0 A_Explode(8,128)
		BDT1 A 0 A_SpawnItemEx("BurnDeathShot", random(-16,16), random(-16,16), random(24,64), 0, 0, 0.1*random(2,5), 0, 128, 32)
		BDT1 A 0 A_SpawnItemEx("BurnDeathShotFloor", random(-16,16), random(-16,16), random(0,4), 0, 0, 0.1*random(2,5), 0, 128, 32)
		BDT1 A 2 BRIGHT A_Wander
		BDT1 A 0 A_Explode(8,128)
		BDT1 A 0 A_SpawnItemEx("BurnDeathShot", random(-16,16), random(-16,16), random(24,64), 0, 0, 0.1*random(2,5), 0, 128, 32)
		BDT1 A 0 A_SpawnItemEx("BurnDeathShotFloor", random(-16,16), random(-16,16), random(0,4), 0, 0, 0.1*random(2,5), 0, 128, 32)
		BDT1 A 2 BRIGHT A_Wander
		BDT1 B 0 A_Explode(8,128)
		BDT1 B 0 A_SpawnItemEx("BurnDeathShot", random(-16,16), random(-16,16), random(24,64), 0, 0, 0.1*random(2,5), 0, 128, 32)
		BDT1 B 0 A_SpawnItemEx("BurnDeathShotFloor", random(-16,16), random(-16,16), random(0,4), 0, 0, 0.1*random(2,5), 0, 128, 32)
		BDT1 B 2 BRIGHT A_Wander
		BDT1 B 0 A_Explode(8,128)
		BDT1 B 0 A_SpawnItemEx("BurnDeathShot", random(-16,16), random(-16,16), random(24,64), 0, 0, 0.1*random(2,5), 0, 128, 32)
		BDT1 B 0 A_SpawnItemEx("BurnDeathShotFloor", random(-16,16), random(-16,16), random(0,4), 0, 0, 0.1*random(2,5), 0, 128, 32)
		BDT1 B 2 BRIGHT A_Wander
		BDT1 C 0 A_Explode(8,128)
		BDT1 C 0 A_SpawnItemEx("BurnDeathShot", random(-16,16), random(-16,16), random(24,64), 0, 0, 0.1*random(2,5), 0, 128, 32)
		BDT1 C 0 A_SpawnItemEx("BurnDeathShotFloor", random(-16,16), random(-16,16), random(0,4), 0, 0, 0.1*random(2,5), 0, 128, 32)
		BDT1 C 2 BRIGHT A_Wander
		BDT1 C 0 A_Explode(8,128)
		BDT1 C 0 A_SpawnItemEx("BurnDeathShot", random(-16,16), random(-16,16), random(24,64), 0, 0, 0.1*random(2,5), 0, 128, 32)
		BDT1 C 0 A_SpawnItemEx("BurnDeathShotFloor", random(-16,16), random(-16,16), random(0,4), 0, 0, 0.1*random(2,5), 0, 128, 32)
		BDT1 C 2 BRIGHT A_Wander
		BDT1 D 0 A_Explode(8,128)
		BDT1 D 0 A_SpawnItemEx("BurnDeathShot", random(-16,16), random(-16,16), random(24,64), 0, 0, 0.1*random(2,5), 0, 128, 32)
		BDT1 D 0 A_SpawnItemEx("BurnDeathShotFloor", random(-16,16), random(-16,16), random(0,8), 0, 0, 0.1*random(2,5), 0, 128, 32)
		BDT1 D 2 BRIGHT A_Wander
		BDT1 D 0 A_Explode(8,128)
		BDT1 D 0 A_SpawnItemEx("BurnDeathShot", random(-16,16), random(-16,16), random(24,64), 0, 0, 0.1*random(2,5), 0, 128, 32)
		BDT1 D 0 A_SpawnItemEx("BurnDeathShotFloor", random(-16,16), random(-16,16), random(0,4), 0, 0, 0.1*random(2,5), 0, 128, 32)
		BDT1 D 2 BRIGHT A_Wander
		
		BDT1 A 0 A_GiveInventory ("BurnCount", 1)
		BDT1 A 0 A_JumpIfInventory ("BurnCount", random(9,12), "Death")
		goto See+3
	Death:
		BURN AABBCCDDEEFFGGHHIIJJKKLLMMNNOOPP 2 BRIGHT A_SpawnItemEx("BurnDeathShot", random(-16,16), random(-16,16), random(16,64), 0, 0, 0.1*random(2,5), 0, 128, 32)
		BURN Q 0 BRIGHT A_PlaySound("misc/thud") //[Bloax] This is the correct time.
		BURN QQ 2 BRIGHT A_SpawnItemEx("BurnDeathShot", random(-16,16), random(-16,16), random(16,64), 0, 0, 0.1*random(2,5), 0, 128, 32)
		BURN R 0 A_SpawnItemEx ("FlameDecay", random(-16,16), random(-16,16), 4)
		BURN RRR 0 A_SpawnItemEx ("Credits1", random(-4,4), random(-4,4), random(32,48), random(-4,4), random(-4,4), random(4,8), 0, 0, 128)
		BURN R 0 A_SpawnItemEx ("PowerupCrate", random(-4,4), random(-4,4), random(32,48), random(2,4), random(-2,2), random(2,4), 0, 0, 230)
		BURN RSTU 3 A_NoBlocking
		BURN V 128
		BURN V 0 A_StopSound (5)
		BURN V 4 A_FadeOut(0.05)
		wait
	}
}

// This variant is spawned when the player burns in spawn room
actor BurningCorpseReduced : BurningCorpse {
	speed 0
	states {
	Spawn:
		BURN A 0 BRIGHT
		BURN AABBCCDDEEFFGGHHIIJJKKLLMMNNOOPP 2 BRIGHT A_SpawnItemEx("BurnDeathShot", random(-16,16), random(-16,16), random(16,64), 0, 0, 0.1*random(2,5), 0, 128, 32)
		BURN Q 0 BRIGHT A_PlaySound("misc/thud")
		BURN QQ 2 BRIGHT A_SpawnItemEx("BurnDeathShot", random(-16,16), random(-16,16), random(16,64), 0, 0, 0.1*random(2,5), 0, 128, 32)
		BURN RSTU 3 A_NoBlocking
		BURN V 128
		BURN V 0 A_StopSound (5)
		BURN V 4 A_FadeOut(0.05)
		wait
	}
}

actor BurnCount : Inventory {inventory.maxamount 12}

actor FlameFX {
	PROJECTILE
	+CLIENTSIDEONLY
	+FORCEXYBILLBOARD
	-RANDOMIZE
	radius 13
	height 8
	speed 5
	damage 0
	renderstyle Add
	alpha 0.75
	states {
	Spawn:
		TNT1 A 0
		FLMB A 1 bright // A_SpawnItemEx("BurnDeathSmokePuff", 0, 0, random(20,28), 0, 0, random(1,2), 0, 128, 0)
		FLMB A 1 bright ThrustThingZ(0,1,0,1)
		FLMB BCDEFGH 2 bright
		FLMB ABCDEFGHABCDEFGH 2 bright A_FadeOut(0.1)
		stop
	Death:
		FLMB A 1 bright
		FLMB A 1 ThrustThingZ(0,1,0,1)
		FLMB BCDEFGH 2 bright
		FLMB ABCDEFGHABCDEFGH 2 bright A_FadeOut(0.1)
		stop
	}
}

actor FlameFXFloor : FlameFX {
	Scale 0.625
	states {
	Spawn:
		TNT1 A 0
		FLMB A 2 bright // A_SpawnItemEx("BurnDeathSmokePuff", 0, 0, random(20,28), 0, 0, random(1,2), 0, 128, 0)
		FLMB A 2 bright
		FLMB BCDEFGH 4 bright
		FLMB ABCDEFGHABCDEFGH 4 bright A_FadeOut(0.1)
		stop
	Death:
		FLMB A 2 bright
		FLMB A 2
		FLMB BCDEFGH 4 bright
		FLMB ABCDEFGHABCDEFGH 4 bright A_FadeOut(0.1)
		Stop
	}
}

// Green variant for chemical death
actor ChemicalCorpse : BurningCorpse {
	obituary "$OB_CHEMICALCORPSE" // "%o got too close to %k's radioactive corpse."
	damagetype "Chemical" // ChemicalSpecial
	states {
	Spawn:
		CDT1 A 0 BRIGHT
	See:
		CDT1 C 0 BRIGHT A_NoBlocking
		CDT1 C 0 BRIGHT A_Pain
		CDT1 C 0 BRIGHT A_PlaySound ("chem/chem", 5, 1.0, 1)
		CDT1 D 0 BRIGHT A_Wander
		CDT1 A 0 A_Explode(8,128)
		CDT1 AAAA 0 A_SpawnItemEx("ChemicalFlame", random(-16,16), random(-16,16), random(16,64), 0, 0, 0.5*random(2,5),  0, 128, 32)
		CDT1 A 2 BRIGHT A_Wander
		CDT1 A 0 A_Explode(8,128)
		CDT1 AAAA 0 A_SpawnItemEx("ChemicalFlame", random(-16,16), random(-16,16), random(16,64), 0, 0, 0.5*random(2,5),    0, 128, 32)
		CDT1 A 2 BRIGHT A_Wander
		CDT1 B 0 A_Explode(8,128)
		CDT1 BBBB 0 A_SpawnItemEx("ChemicalFlame", random(-16,16), random(-16,16), random(16,64), 0, 0, 0.5*random(2,5),    0, 128, 32)
		CDT1 B 2 BRIGHT A_Wander
		CDT1 B 0 A_Explode(8,128)
		CDT1 BBBB 0 A_SpawnItemEx("ChemicalFlame", random(-16,16), random(-16,16), random(16,64), 0, 0, 0.5*random(2,5),    0, 128, 32)
		CDT1 B 2 BRIGHT A_Wander
		CDT1 C 0 A_Explode(8,128)
		CDT1 CCCC 0 A_SpawnItemEx("ChemicalFlame", random(-16,16), random(-16,16), random(16,64), 0, 0, 0.5*random(2,5),    0, 128, 32)
		CDT1 C 2 BRIGHT A_Wander
		CDT1 C 0 A_Explode(8,128)
		CDT1 CCCC 0 A_SpawnItemEx("ChemicalFlame", random(-16,16), random(-16,16), random(16,64), 0, 0, 0.5*random(2,5),    0, 128, 32)
		CDT1 C 2 BRIGHT A_Wander
		CDT1 D 0 A_Explode(8,128)
		CDT1 DDDD 0 A_SpawnItemEx("ChemicalFlame", random(-16,16), random(-16,16), random(16,64), 0, 0, 0.5*random(2,5),    0, 128, 32)
		CDT1 D 2 BRIGHT A_Wander
		CDT1 D 0 A_Explode(8,128)
		CDT1 DDDD 0 A_SpawnItemEx("ChemicalFlame", random(-16,16), random(-16,16), random(16,64), 0, 0, 0.5*random(2,5),    0, 128, 32)
		CDT1 D 2 BRIGHT A_Wander
		CDT1 A 0 A_GiveInventory("BurnCount",1)
		CDT1 A 0 A_JumpIfInventory("BurnCount",random(9,12),"Death")
		goto See+3
	Death:
		CURN AAAABBBBCCCCDDDDEEEEFFFFGGGGHHHHIIIIJJJJKKKKLLLLMMMMNNNNOOOOPPPP 1 BRIGHT A_SpawnItemEx("ChemicalFlame", random(-16,16), random(-16,16), random(16,64), 0, 0, 0.5*random(2,5),    0, 128, 32)
		CURN Q 0 BRIGHT A_PlaySound("misc/thud")
		CURN QQQQ 1 BRIGHT A_SpawnItemEx("ChemicalFlame", random(-16,16), random(-16,16), random(16,64), 0, 0, 0.5*random(2,5),    0, 128, 32)
		CURN AA 0 A_SpawnItemEx("AnthraxDecaySpecial", random(-16,16), random(-16,16), 4)
		CURN AAA 0 A_SpawnItemEx ("Credits1", random(-4,4), random(-4,4), random(32,48), random(-4,4), random(-4,4), random(4,8), 0, 0, 128)
		CURN A 0 A_SpawnItemEx ("PowerupCrate", random(-4,4), random(-4,4), random(32,48), random(2,4), random(-2,2), random(2,4), 0, 0, 230)
		CURN RSTU 3 A_NoBlocking
		CURN V 0 A_StopSound (5)
		CURN V 128
		CURN V 2 A_FadeOut (0.1)
		wait
	}
}

actor ChemicalCorpseReduced : ChemicalCorpse {
	states {
	Spawn:
		CURN A 0 BRIGHT
		CURN AAAABBBBCCCCDDDDEEEEFFFFGGGGHHHHIIIIJJJJKKKKLLLLMMMMNNNNOOOOPPPP 1 BRIGHT A_SpawnItemEx("ChemicalFlame", random(-16,16), random(-16,16), random(16,64), 0, 0, 0.5*random(2,5),    0, 128, 32)
		CURN Q 0 BRIGHT A_PlaySound("misc/thud")
		CURN QQQQ 1 BRIGHT A_SpawnItemEx("ChemicalFlame", random(-16,16), random(-16,16), random(16,64), 0, 0, 0.5*random(2,5),    0, 128, 32)
		CURN RSTU 3 A_NoBlocking
		CURN V 128 A_PlaySound("misc/thud")
		CURN V 0 A_StopSound (5)
		CURN V 4 A_FadeOut(0.05)
		wait
	}
}

actor ChemicalFlame {
	PROJECTILE
	-RANDOMIZE
	+CLIENTSIDEONLY
	+FORCEXYBILLBOARD
	radius 13
	height 8
	speed 5
	damage 0
	renderstyle Add
	alpha 0.75
	scale 0.25
	states {
	Spawn:
		TNT1 A 0
		TIBX ABCDEFGHIJKL 2 bright
		TIBX MMNNOOPPQQ 1 bright A_FadeOut(0.1)
		stop
	Death:
		TIBX GHIJKLMNOPQ 3 bright
		stop
	}
}

actor ChemicalFlameSmall : ChemicalFlame {
	radius 13
	height 8
	speed 22
	damage 0
	renderstyle Add
	alpha 0.75
	PROJECTILE
	-RANDOMIZE
	Scale 0.4
	states {
	Spawn:
		TNT1 A 0
		TIBX ABCDEFGHIJKL 2 bright
		TIBX MMNNOOPPQQ 1 bright A_FadeOut(0.1)
		stop
	Death:
		TIBX GHIJKLMNOPQ 3 bright
		stop
	}
}

// variants for not so male players
actor BurningCorpseFemale : BurningCorpse {painsound "female/burn"}
actor ChemicalCorpseFemale : ChemicalCorpse {painsound "female/burn"}

// compatibility.. so many actors spawn these
actor BurnDeathShot : FlameFX {}
actor BurnDeathShotFloor : FlameFXFloor {}
actor ChemicalDeathShot : ChemicalFlame {}
actor ChemicalShotSmall : ChemicalFlameSmall {}


actor FadingCorpse {
	states {
	Spawn:
		PLAY N 2 A_FadeOut(0.1)
		wait
	}
}

actor DisintegratedCorpse {
	+NOINTERACTION
	+NOBLOCKMAP
	+CLIENTSIDEONLY
	states {
	Spawn:
        DISR ABCDEFGHIJ 3 bright
        Stop
	}
}

actor FakeIcePlayer {
	Translation "Ice"
	Radius 16
	Height 56
	Health 1
	+SHOOTABLE
	+SOLID
	States {
	Spawn:
		TNT1 A 0
		Goto Ice
	Ice:
		PLAY G 0 A_GenericFreezeDeath
		PLAY G 2 A_FreezeDeathChunks
		Wait
	Death:
		PLAY G 1 A_IceGuyDie
		Stop
	}
}
