actor C7Bullets : Ammo
{
	inventory.pickupsound "misc/ammo_pkup"
	inventory.amount 100
	inventory.maxamount 200
}

actor C7Energy : Ammo
{
	inventory.pickupsound "misc/ammo_pkup"
	inventory.amount 100
	inventory.maxamount 999
}

// Alien weapons drain both the displayed charge and this slowly shrinking
// capacity. Charge regenerates by two while an alien weapon is selected.
actor C7EnergyCapacity : Ammo
{
	inventory.amount 100
	inventory.maxamount 100
}

actor C7Mines : Ammo
{
	inventory.pickupsound "misc/ammo_pkup"
	inventory.amount 25
	inventory.maxamount 25
}

actor C7VisorCharge : Ammo
{
	inventory.pickupsound "misc/ammo_pkup"
	inventory.amount 100
	inventory.maxamount 100
}

// One-based mode: normal, night vision, infrared. Keeping this as inventory
// makes the selected visor mode survive save/load without engine globals.
actor C7VisorMode : Inventory
{
	inventory.amount 1
	inventory.maxamount 3
}

actor C7Player : PlayerPawn
{
	health 100
	radius 22
	player.movebob 0
	player.viewheight 32
	player.displayname "Corridor 7 Marine"
	player.startitem "C7M16"
	player.startitem "C7Bayonet"
	player.startitem "C7Bullets", 100
	player.startitem "C7VisorCharge", 100
	player.startitem "C7VisorMode", 1
	player.startitem "C7EnergyCapacity", 100
	painsound "c7/player/pain"
	deathsound "c7/player/death"
	player.weaponslot 1, "C7Bayonet"
	player.weaponslot 2, "C7Shotgun"
	player.weaponslot 3, "C7M16"
	player.weaponslot 4, "C7M343"
	player.weaponslot 5, "C7DualBlaster"
	player.weaponslot 6, "C7PlasmaRifle"
	player.weaponslot 7, "C7AssaultCannon"
	player.weaponslot 8, "C7Disintegrator"
	player.damagescreencolor "FF 00 00"
	// C744 and C745, which these states used to name, are two frames of the
	// exit vortex. Nobody ever saw it: a player is the one actor you are never
	// looking at, so the placeholder survived until multiplayer made every
	// player something the others have to draw.
	//
	// The archive has a complete human soldier at C459-C509 that no actor
	// referenced -- five walk frames in eight rotations, a pain frame, a
	// seven-frame death and a three-frame firing pose -- and a second one in
	// gray immediately after it, which is what a game with more than one
	// player on screen needs. co7map.txt names the first of them MARN.
	states
	{
		Spawn:
			MARN A -1
			stop
		See:
			// Three, not six. Durations here are in 35Hz tics and the engine
			// runs at 70, so this is six tics a frame and a thirty-tic stride.
			// At six it was a sixty-tic stride, and a player covers ground far
			// faster than the aliens these numbers were copied from: the legs
			// could not keep up with the movement and the marine appeared to
			// slide along the floor rather than walk. Measured from
			// --capture-players, which prints the sprite frame each tic.
			MARN ABCDE 3
			loop
		Missile:
			MARN NOP 6 bright
			goto See
		Melee:
			MARN NO 6 bright
			goto See
		Pain:
			MARN F 5
			goto See
		Death:
			MARN G 0 A_Scream
			MARN G 5 A_Fall
			MARN HIJKL 5
			MARN M -1
			stop
	}
}

// The other half of 9.5: "players may select the Marine or alien classes with
// different health, speed, and damage characteristics".
//
// Which alien is not recorded anywhere, so it is an argument rather than a
// citation. Eitak is the game's primary alien-world guard -- the alien
// counterpart to a human soldier -- it is upright and carries a weapon, and it
// is one of only seven actors in the whole archive drawn in eight rotations.
// A player is seen from every angle by definition, so whatever the original
// used had to be one of those seven; of them, Eitak is the armed humanoid
// guard rather than a sentry, a floating probe or a boss.
//
// The numbers are a reconstruction and are meant to read as one. What is
// documented is the split of the arsenal: the guide's weapon table gives 1-4
// to the human (and says the M-24 "starts with Marine") and 5-8 to the alien,
// drawing on two separate ammunition pools. So the classes differ in damage by
// carrying different halves of a documented armoury rather than by a
// multiplier. Health follows the bestiary, where every alien warrior outlasts
// the Marine's hundred; the speed difference is the invented part, and pays
// for the extra health.
actor C7AlienPlayer : C7Player
{
	health 150
	player.maxhealth 150
	player.displayname "Eitak Warrior"
	player.forwardmove 0.8, 0.8
	player.sidemove 0.8, 0.8
	player.startitem "C7DualBlaster"
	player.startitem "C7Bayonet"
	player.startitem "C7Energy", 200
	player.startitem "C7VisorCharge", 100
	player.startitem "C7VisorMode", 1
	player.startitem "C7EnergyCapacity", 100
	painsound "c7/monster/attack/class18"
	deathsound "c7/monster/death/class18"
	states
	{
		Spawn:
			EITK A -1
			stop
		See:
			// As the marine above: halved so the stride matches how fast a
			// player actually moves.
			EITK ABCD 3
			loop
		Missile:
			C634 A 3
			C635 A 6
			C636 A 5 bright
			C637 A 6
			goto See
		Melee:
			C636 A 6 bright
			goto See
		Pain:
			C630 A 5
			goto See
		Death:
			C630 A 0 A_Scream
			C630 A 5 A_Fall
			C631 A 4
			C632 A 4
			C633 A -1
			stop
	}
}

// Frame durations below are DECORATE tics, which ECWolf authors in Doom's 35Hz
// and doubles at parse time to reach its 70Hz TICRATE. The released game's
// attack table is in 70Hz tics, so a value copied from it verbatim runs at half
// speed -- which is what these tables used to do.
//
// Measured from a 70fps capture of the DOS game holding fire (see
// tools/dosbox/capture_corridor7_timing.sh): every weapon frame dwells exactly
// 6 tics, flat across 82 consecutive cycles with no variance. That is DECORATE
// 3, and it matches Wolf3D's own attackinfo table, which also uses 6 tics and
// which ECWolf's wolfweapons.txt likewise writes as 3.
actor C7Weapon : Weapon
{
	weapon.yadjust 32
	+WEAPON.DONTBOB
	states
	{
		Select:
			TNT1 A 0 A_Raise
			loop
		Deselect:
			TNT1 A 0 A_Lower
			loop
	}
}

actor C7Bayonet : C7Weapon
{
	// The shipped game calls this the self-powered security Taser.
	attacksound "c7/weapon/bayonet"
	weapon.ammouse1 0
	states
	{
		Ready:
			C753 A 1 A_WeaponReady
			loop
		Fire:
		Hold:
			C746 A 3
			C747 A 3
			C748 A 3 bright A_CustomPunch(random(0, 255), true, CPF_ALWAYSPLAYSOUND)
			C749 A 3
			TNT1 A 0 A_ReFire
			goto Ready
		Spawn:
			C453 A -1
			stop
	}
}

actor C7M16 : C7Weapon
{
	attacksound "c7/weapon/m16"
	weapon.ammotype1 "C7Bullets"
	weapon.ammouse1 1
	weapon.ammogive1 100
	states
	{
		Ready:
			C761 A 1 A_WeaponReady
			loop
		Fire:
			C754 A 3
			C755 A 3
		Hold:
			C756 A 3 bright A_C7GunAttack(2)
			// A_ReFire changes the psprite immediately when its state is entered.
			// Branch after C757 so both native firing frames remain visible.
			C757 A 3
			TNT1 A 0 A_ReFire
			goto Ready
		Spawn:
			C454 A -1
			stop
	}
}

actor C7M343 : C7Weapon
{
	attacksound "c7/weapon/m343"
	weapon.ammotype1 "C7Bullets"
	weapon.ammouse1 1
	weapon.ammogive1 100
	states
	{
		Ready:
			C769 A 1 A_WeaponReady
			loop
		Fire:
		Hold:
			// Restart held bursts at the muzzle flash, then advance through the
			// complete rotating-barrel sequence.
			C762 A 3
			C763 A 3
			C764 A 3 bright A_C7GunAttack(3)
			C765 A 3
			TNT1 A 0 A_ReFire
			goto Ready
		Spawn:
			C007 A -1
			stop
	}
}

actor C7DualBlaster : C7Weapon
{
	attacksound "c7/weapon/dualblaster"
	weapon.ammotype1 "C7Energy"
	weapon.ammouse1 1
	weapon.ammogive1 100
	states
	{
		Ready:
			C777 A 1 A_WeaponReady
			loop
		Fire:
			C770 A 3
			C771 A 3
		Hold:
			C772 A 3 bright A_C7GunAttack(4)
			C773 A 3 bright
			TNT1 A 0 A_ReFire
			goto Ready
		Spawn:
			C029 A -1
			stop
	}
}

actor C7Disintegrator : C7Weapon
{
	attacksound "c7/weapon/disintegrator"
	weapon.ammotype1 "C7Energy"
	weapon.ammouse1 1
	weapon.ammogive1 100
	states
	{
		Ready:
			C809 A 1 A_WeaponReady
			loop
		Fire:
			C802 A 3
			C803 A 3
		Hold:
			// The released attack table holds the peak discharge for 20 tics,
			// which is DECORATE 10 -- durations here are in Doom's 35Hz and are
			// doubled at parse time to reach ECWolf's 70Hz TICRATE.
			C804 A 10 bright A_C7GunAttack(7)
			C805 A 3
			TNT1 A 0 A_ReFire
			goto Ready
		Spawn:
			C452 A -1
			stop
	}
}

actor C7Shotgun : C7Weapon
{
	attacksound "c7/weapon/shotgun"
	weapon.ammotype1 "C7Bullets"
	weapon.ammouse1 5
	weapon.ammogive1 100
	states
	{
		Ready:
			C793 A 1 A_WeaponReady
			loop
		Fire:
		Hold:
			C786 A 3
			C787 A 3
			C788 A 3 bright A_C7GunAttack(1)
			C789 A 3
			C810 A 6
			C811 A 6
			C812 A 6
			C813 A 6
			TNT1 A 0 A_ReFire
			goto Ready
		Spawn:
			C450 A -1
			stop
	}
}

actor C7PlasmaRifle : C7Weapon
{
	attacksound "c7/weapon/plasma"
	weapon.ammotype1 "C7Energy"
	weapon.ammouse1 1
	weapon.ammogive1 100
	states
	{
		Ready:
			C785 A 1 A_WeaponReady
			loop
		Fire:
			C778 A 3
			C779 A 3
		Hold:
			C780 A 10 bright A_FireCustomMissile("C7PlasmaBolt")
			C781 A 3
			TNT1 A 0 A_ReFire
			goto Ready
		Spawn:
			C031 A -1
			stop
	}
}

actor C7AssaultCannon : C7Weapon
{
	attacksound "c7/weapon/assault"
	weapon.ammotype1 "C7Energy"
	weapon.ammouse1 1
	weapon.ammogive1 100
	states
	{
		Ready:
			C801 A 1 A_WeaponReady
			loop
		Fire:
			C794 A 3
			C795 A 3
		Hold:
			C796 A 3 bright A_C7GunAttack(6)
			C797 A 3
			TNT1 A 0 A_ReFire
			goto Ready
		Spawn:
			C451 A -1
			stop
	}
}

// C7MedicPack, C7AmmoClip, C7VisorBattery and C7ScoreBonus are leftovers, kept
// because they cost nothing and because deleting them would lose what they
// record about the game's history.
// None is placed by any map word, and none can be: Corridor 7 chose wall
// dispensers over floor pickups for health, ammo and visor charge, and these
// are the pickup forms that did not survive that decision. Their sprites were
// guessed when they were written and are wrong -- C7VisorBattery's C071 is the
// fourth frame of the proximity mine's explosion -- which is harmless only
// because nothing ever spawns them. The live versions are the C7_Dispenser
// cases in lnspec.cpp.
//
// C7ScoreBonus is a different leftover: it inherits ECWolf's ScoreItem, the
// Wolfenstein 3D treasure mechanic, which Corridor 7 does not have.
//
// The two that looked like leftovers and are not: C7Bayonet is the Taser, the
// self-powered infinite-ammo fallback in weapon slot 1, and C7M16 is slot 3.
// Both are handed to the player at spawn rather than placed, which is why no
// map word mentions them.
actor C7MedicPack : Health
{
	inventory.pickupsound "misc/medkit_pkup"
	inventory.amount 25
	states { Spawn: C007 A -1 stop }
}

// GFXTILES.CO7 chunk 962 is the player's blue plasma bolt (C706). C707-C709
// are its three impact frames. C738-C744 belong to the exit vortex and must
// not be used by this weapon.
actor C7PlasmaBolt
{
	radius 4
	speed 30
	damage 0
	deathsound "c7/teleport"
	PROJECTILE
	states
	{
		Spawn:
			C706 A 2 bright
			loop
		Death:
			C707 A 4 bright A_Explode(random(25, 280), 64, 1, true)
			C708 A 4 bright
			C709 A 4 bright
			stop
	}
}

actor C7Adrenaline : Health
{
	inventory.pickupsound "misc/medkit_pkup"
	// The released game adds 300 health, up to its 400-point boosted cap.
	inventory.amount 300
	inventory.maxamount 400
	states { Spawn: C058 A -1 stop }
}

actor C7BodyArmor : Inventory
{
	inventory.pickupsound "misc/health_pkup"
	// Suits add 200 and stack; the HUD displays a full bar at 200.
	inventory.amount 200
	inventory.maxamount 65535
	states { Spawn: C060 A -1 stop }
}

actor C7AmmoClip : C7Bullets
{
	inventory.amount 50
	states { Spawn: C057 A -1 stop }
}

actor C7AmmoPack : C7Bullets
{
	inventory.amount 100
	states { Spawn: C057 A -1 stop }
}

actor C7ChargePack : CustomInventory
{
	inventory.pickupsound "misc/ammo_pkup"
	+INVENTORY.ALWAYSPICKUP
	states
	{
		Spawn:
			C059 A -1
			stop
		Pickup:
			TNT1 A 0 A_GiveInventory("C7Energy", 100)
			TNT1 A 0 A_GiveInventory("C7EnergyCapacity", 100)
			stop
	}
}

actor C7MinePack : C7Mines
{
	inventory.amount 25
	states { Spawn: C063 A -1 stop }
}

actor C7ProximityMine
{
	health 1
	radius 8
	+SHOOTABLE
	states
	{
		Spawn:
			// The native mine-drop/arming path does not call SD_PlaySound.
			// CORR7CD.EXE's static table identifies type 0x13 as shape 67,
			// the released silver floor mine. C063 is its pickup crate.
			C067 A 36
		Armed:
			C067 A 1 A_C7MineThink
			loop
		Death:
			C068 A 3 bright A_Explode(random(102, 500), 128, 1, true)
			C069 A 3 bright
			C070 A 3 bright
			C071 A 3 bright
			C072 A 3 bright
			C073 A 3 bright
			C074 A 3 bright
			stop
	}
}

actor C7VisorBattery : C7VisorCharge
{
	inventory.amount 100
	states { Spawn: C071 A -1 stop }
}

actor C7ScoreBonus : ScoreItem
{
	inventory.amount 500
	states { Spawn: C006 A -1 stop }
}

actor C7Invulnerability : Inventory
{
	inventory.amount 2100
	inventory.maxamount 2100
	states { Spawn: C061 A -1 stop }
}

actor C7FloorPlan : MapRevealer
{
	// The floor map does not survive a floor change -- like the blue/red access
	// cards you have to find the new one on every level. MapRevealer inherits
	// Inventory's interhubamount of 1, which would carry it over; Key sets 0 for
	// the same reason.
	inventory.interhubamount 0
	states { Spawn: C030 A -1 stop }
}
