//Sergeant Mark IV's Tanks and Helicopter.
//If you use this in your mod, give me credits.

//Vehicle models used for rips by Illidan(Evil)X
//Helicopter sound effects by the youtube channel Audio Productions
//tank fire sounds by Andy Pang
//M1 abrams engine sounds by kempet
//car crash sound effect by SoundIdeasCanada

//To implement these vehicles into your mod, copy all lumps. The fire and smoke effects used for explosions
//are inside the TESTMAP.wad file and are not obligatory.

Actor MechFireMode : Inventory
{
inventory.maxamount 3
}

Actor CanLeaveVehicle : Inventory
{
inventory.maxamount 1
}

Actor HelicopterIsFlying : Inventory
{
inventory.maxamount 1
}

Actor StoredHealthInsideVehicle : Inventory
{
inventory.maxamount 9999
}

Actor StoredArmorInsideVehicle : Inventory
{
inventory.maxamount 9999
}

Actor Accelerate : Inventory
{
inventory.maxamount 1
}

Actor Backpedal : Inventory
{
inventory.maxamount 1
}

Actor TurnLeft : Inventory
{
inventory.maxamount 1
}

Actor TurnRight : Inventory
{
inventory.maxamount 1
}

Actor TurnMouseLeft : Inventory
{
inventory.maxamount 1
}

Actor TurnMouseRight : Inventory
{
inventory.maxamount 1
}

Actor PressedUse : Inventory
{
inventory.maxamount 1
}

Actor PressedJump : Inventory
{
inventory.maxamount 1
}

Actor PressedLeft : Inventory
{
inventory.maxamount 1
}


Actor TankZoom : Inventory
{
inventory.maxamount 1
}


Actor MaxLeft : Inventory
{
inventory.maxamount 1
}

Actor MaxRight : Inventory
{
inventory.maxamount 1
}


Actor IsAVehicle : Inventory
{
inventory.maxamount 1
}


Actor VehicleFallingCount : Inventory
{
inventory.maxamount 100
}

ACTOR VehicleSpeed : Ammo
{
	Game Doom
	SpawnID 11
	Inventory.PickupMessage "$GOTCLIP"
	Inventory.Amount 0
	Inventory.MaxAmount 999
	Ammo.BackpackAmount 0
	Ammo.BackpackMaxAmount 999
	Inventory.Icon "CLIPA0"
	States
	{
	Spawn:
		CLIP A -1
		Stop
	}
}

Actor TankDirection : Inventory
{
inventory.maxamount 60
}



ACTOR TankBaseDirection : Ammo
{
	Game Doom
	SpawnID 11
	Inventory.PickupMessage "$GOTCLIP"
	Inventory.Amount 0
	Inventory.MaxAmount 360
	Ammo.BackpackAmount 0
	Ammo.BackpackMaxAmount 360
	Inventory.Icon "CLIPA0"
	States
	{
	Spawn:
		CLIP A -1
		Stop
	}
}

actor ChaseCam3
{
  height 1
  radius 1
  +NOGRAVITY
  +THRUACTORS
  states
  {
  Spawn:
    NULL A -1
    stop
  }
}
	


Actor DestroyedArmouredVehicle
{
+NOGRAVITY
+NOCLIP
+THRUACTORS
Height 96
Radius 64
Scale 2.0
States
{
Spawn:
8762 B 1 A_CustomMissile ("HollywoodFire2", 76, 0, random (0, 360), 2, random (40, 90))
8762 B 3
Loop
}
}


Actor DestroyedAircraft
{
+NOGRAVITY
+NOCLIP
+THRUACTORS
Height 96
Radius 64
Scale 2.0
States
{
Spawn:
8762 C 1 A_CustomMissile ("HollywoodFire2", 76, 0, random (0, 360), 2, random (40, 90))
8762 C 3
Loop
}
}


Actor CancelTeleportFog
{
+THRUACTORS
+MISSILE
+NOPAIN
Height 0
Radius 0
Speed 0
damagetype "CancelTeleportFog"
States
{
Spawn:
TNT1 A 1
Death:
TNT1 A 0 A_Explode(4, 128, 0)
Stop
}
}


ACTOR TransferPlayerOutOfVehicle
{

	Radius 16
	Height 40
	+MISSILE
	+NOGRAVITY
	MaxTargetRange 120
	Speed 0
    States
    {
    Spawn:
	    TNT1 A 0
		TNT1 A 0 A_GiveToTarget("CanLeaveVehicle", 1)
		TNT1 A 0 Thing_ChangeTID(0, 264)
		TNT1 A 0 A_NoBlocking
		TNT1 A 6
		TNT1 A 0 A_SpawnItem("CancelTeleportFog")
		TNT1 A 2
		TNT1 A 0 Thing_ChangeTID(0, 0)
		Stop
		
	Death:
		TNT1 A 0
		Stop
	}
}












Actor FiredTankMainGun : Inventory
{
inventory.maxamount 1
}


ACTOR TankShell
{
	Radius 6
	Height 6
	Speed 90
	Damage (random (400, 500))
	Projectile
	+RANDOMIZE
	+DEHEXPLOSION
	+ROCKETTRAIL
	+MISSILE
	-NOGRAVITY
	damagetype "TankShell"
	Gravity 0.3
	SeeSound "weapons/rocklf"
	DeathSound "weapons/rocklx"
	Obituary "$OB_MPROCKET"
	States
	{
	Spawn:
		MISL A 1 Bright
		Loop
	Death:
		MISL B 0 Bright A_Explode
		
		TNT1 A 0 A_PlaySound("EXPLOSIO", 3)
		TNT1 A 0 A_SpawnItem("TankShotExplosion")
		TNT1 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 0 A_CustomMissile ("ExplosionParticle", 0, 0, random (0, 360), 2, random (30, 160))
		TNT1 A 0 A_SpawnItem("TankShotExplosionImpact")
		TNT1 A 6
		TNT1 A 0 A_PlaySound("FAREXPL", 1)
		TNT1 AAAAAAAA 0 A_CustomMissile ("ExplosionSmoke", 0, 0, random (0, 360), 2, random (0, 360))
		TNT1 AAAAA 0 A_CustomMissile ("ExplosionSmokeFast", 0, 0, random (0, 360), 2, random (0, 360))
		TNT1 A 12
		Stop
	}
}


ACTOR TankFireEffect
{
	Radius 1
	Height 1
	Speed 70
	Damage 1
	Projectile
	+RANDOMIZE
	+MISSILE
	States
	{
	Spawn:
		TNT1 A 2
		Goto Death
	Death:
		TNT1 A 0
		TNT1 A 0 Radius_Quake(6, 12, 0, 4, 0)
		TNT1 AAAAA 0 A_SpawnItem("RedFlare")
		TNT1 AAAAA 0 A_CustomMissile ("ExplosionSmokeFast", 0, 0, random (0, 360), 2, random (0, 360))
		TNT1 A 1 BRIGHT
		TNT1 AAAAA 0 A_SpawnItem("RedFlare")
		TNT1 A 0 A_Stop
		TNT1 A 0 A_Recoil(-5)
		TKFL A 5 BRIGHT
		Stop
	}
}


ACTOR TankShotExplosionImpact
{
	damagetype "ExplosiveImpact"
	+MISSILE
	+NOCLIP
	States
	{
	Spawn:
		TNT1 A 1
		TNT1 A 0 A_Explode(50, 400)
		Stop
	}
}




actor TankTreadsDamage
{
+NOTARGET
Radius 1
Height 1
DamageType Stomp
+NOGRAVITY
+NOTELEPORT
+NODAMAGETHRUST
+THRUGHOST
+NORADIUSDMG
+FORCERADIUSDMG
PROJECTILE
	+DEHEXPLOSION
	+ACTIVATEMCROSS
	+EXPLODEONWATER
States
{
Spawn:
TNT1 A 0
TNT1 A 0 A_Explode(200,50,0)
TNT1 A 0 A_SpawnItemEx("TreadsDamage2", 0, 50)
TNT1 A 0 A_SpawnItemEx("TreadsDamage2", 0, -50)
TNT1 A 0 A_SpawnItemEx("TreadsDamage3", 0, 50, 70)
TNT1 A 0 A_SpawnItemEx("TreadsDamage3", 0, -50, 70)
TNT1 A 0 A_SpawnItemEx("TreadsDamage3", 0, 0, 70)
TNT1 A 1 A_Noblocking
PLAY A 0
Stop
 }
}


actor TreadsDamage2: TankTreadsDamage
{
States
{
Spawn:
TNT1 A 0
TNT1 A 0 A_Explode(200,50,0)
PLAY A 0
TNT1 A 1 A_Noblocking
Stop
 }
}


actor TreadsDamage3: TankTreadsDamage
{
DamageType Kick
States
{
Spawn:
TNT1 A 0
TNT1 A 0 A_Explode(10,30,0)
PLAY A 0
TNT1 A 1 A_Noblocking
Stop
 }
}


ACTOR TankAmmo : Ammo
{
	Game Doom
	SpawnID 11
	Inventory.PickupMessage "Picked up a Magazine."
	Inventory.Amount 10
	Inventory.MaxAmount 100
	Ammo.BackpackAmount 0
	Ammo.BackpackMaxAmount 100
	Inventory.Icon "NULL"
	States
	{
	Spawn:
		CLIP A -1
		Stop
	}
}


ACTOR MechAmmo : Ammo
{
	Game Doom
	SpawnID 11
	Inventory.PickupMessage "Picked up a Magazine."
	Inventory.Amount 10
	Inventory.MaxAmount 100
	Ammo.BackpackAmount 0
	Ammo.BackpackMaxAmount 100
	Inventory.Icon "NULL"
	States
	{
	Spawn:
		CLIP A -1
		Stop
	}
}




ACTOR HeavyMachinegunAmmo : Ammo
{
	Game Doom
	Inventory.PickupMessage "Picked up a Magazine."
	Inventory.Amount 100
	Inventory.MaxAmount 2000
	Ammo.BackpackAmount 0
	Ammo.BackpackMaxAmount 2000
	Inventory.Icon "NULL"
	States
	{
	Spawn:
		CLIP A -1
		Stop
	}
}



ACTOR MechRocketAmmo : Ammo
{
	Game Doom
	Inventory.PickupMessage "Picked up a Magazine."
	Inventory.Amount 5
	Inventory.MaxAmount 60
	Ammo.BackpackAmount 0
	Ammo.BackpackMaxAmount 60
	Inventory.Icon "NULL"
	States
	{
	Spawn:
		CLIP A -1
		Stop
	}
}


ACTOR MechLaserAmmo : Ammo
{
	Game Doom
	Inventory.PickupMessage "Picked up a Magazine."
	Inventory.Amount 30
	Inventory.MaxAmount 200
	Ammo.BackpackAmount 0
	Ammo.BackpackMaxAmount 200
	Inventory.Icon "NULL"
	States
	{
	Spawn:
		CLIP A -1
		Stop
	}
}



ACTOR MechMOrtarAmmo : Ammo
{
	Game Doom
	Inventory.PickupMessage "Picked up a Magazine."
	Inventory.Amount 1
	Inventory.MaxAmount 20
	Ammo.BackpackAmount 0
	Ammo.BackpackMaxAmount 20
	Inventory.Icon "NULL"
	States
	{
	Spawn:
		CLIP A -1
		Stop
	}
}



ACTOR HelicopterRocketAmmo : Ammo
{
	Game Doom
	Inventory.PickupMessage "Picked up a Magazine."
	Inventory.Amount 1
	Inventory.MaxAmount 40
	Ammo.BackpackAmount 0
	Ammo.BackpackMaxAmount 40
	Inventory.Icon "NULL"
	States
	{
	Spawn:
		CLIP A -1
		Stop
	}
}


Actor TankBlood: Blood
{
+NOCLIP
-ALLOWPARTICLES
+NOBLOODDECALS
-BLOODSPLATTER
States
	{
	Spawn:
	See:
	Death:
	    TNT1 A 1
		TNT1 A 0 A_SpawnItem("BulletPuff")
		TNT1 A 0 A_PlaySound("RICMET")
		TNT1 A 60
		Stop}}
		
		
		
		

actor TankWeakSpotBase
{
	+NOTARGET
damagefactor "Taunt", 0.0
damagefactor "Blood", 0.0
damagefactor "BlueBlood", 0.0
damagefactor "Head", 0.0
damagefactor "MinorHead", 0.0
damagefactor "KillMe", 0.0
damagefactor "Control", 0.0
damagefactor "Trample", 0.0
damagefactor "GibRemoving", 0.0
//damagefactor "Melee", 0.3
damagefactor "Alert", 0.0
damagefactor "SSG", 1.0
damagefactor "ExplosiveImpact", 0.0
damagefactor "Bullet", 1.5
damagefactor "GibRemoving", 0.0
damagefactor "Kick", 0.0
damagefactor "Stomp", 0.0
damagefactor "TeleportRemover", 0.0
damagefactor "TankShell", 5.5
damagefactor "Plasma", 1.2
damagefactor "Plasma2", 1.2
damagefactor "Railgun", 1.2 damagefactor "Explosives", 1.2
damagefactor "Repair", 0.0 damagefactor "CheckRepair", 0.0
//MONSTER
-COUNTKILL
Health 300
GibHealth 10000
Radius 32
Height 52
DamageType TankWeakSpot
BloodType "TankBlood"
PainChance 255
+NOGRAVITY
+SHOOTABLE
+NOTELEPORT
+FORCERADIUSDMG
-SOLID
+NODAMAGETHRUST
+NORADIUSDMG
+SERVERSIDEONLY
-COUNTKILL
damagefactor "Trample", 0
damagefactor "TankWeakSpot", 0
Species "VehicleSpecial"
States
{
Spawn:
TNT1 A 5
XXXX A 0 A_NoBlocking
Stop

Pain.Explosive:
TNT1 A 3
Goto Pain

Pain.ExplosiveImpact:
TNT1 A 3
Goto Pain

Pain:
TNT1 A 0
//TNT1 A 0 ThrustThingZ(0,-40,0,1)
TNT1 A 0 A_NoBlocking
TNT1 A 0 A_JumpIfHealthLower(-100, "SuperDeath")
TNT1 A 0 A_JumpIfHealthLower(25, "Pain550")
TNT1 A 0 A_JumpIfHealthLower(50, "Pain500")
TNT1 A 0 A_JumpIfHealthLower(75, "Pain450")
TNT1 A 0 A_JumpIfHealthLower(100, "Pain400")
TNT1 A 0 A_JumpIfHealthLower(125, "Pain350")
TNT1 A 0 A_JumpIfHealthLower(150, "Pain300")
TNT1 A 0 A_JumpIfHealthLower(175, "Pain250")
TNT1 A 0 A_JumpIfHealthLower(200, "Pain200")
TNT1 A 0 A_JumpIfHealthLower(225, "Pain150")
TNT1 A 0 A_JumpIfHealthLower(250, "Pain100")
TNT1 A 0 A_JumpIfHealthLower(275, "Pain50")
TNT1 A 0 A_JumpIfHealthLower(288, "Pain35")
TNT1 A 0 A_JumpIfHealthLower(292, "Pain25")
XDT3 A 0 A_Explode(20,20,0)//hs
PLAY A 0
Stop


Pain25:
TNT1 A 0
XDT3 A 0 A_Explode(10,80,0)//hs
TNT1 A 0 A_NoBlocking
Stop


Pain35:
TNT1 A 0
XDT3 A 0 A_Explode(15,80,0)//hs
TNT1 A 0 A_NoBlocking
Stop

Pain50:
TNT1 A 0
XDT3 A 0 A_Explode(30,80,0)//hs
TNT1 A 0 A_NoBlocking
Stop

Pain100:
TNT1 A 0
XDT3 A 0 A_Explode(80,80,0)//hs
TNT1 A 0 A_NoBlocking
Stop

Pain150:
TNT1 A 0
XDT3 A 0 A_Explode(100,80,0)//hs
TNT1 A 0 A_NoBlocking
Stop

Pain200:
TNT1 A 0
XDT3 A 0 A_Explode(150,80,0)//hs
TNT1 A 0 A_NoBlocking
Stop

Pain250:
TNT1 A 0
XDT3 A 0 A_Explode(200,80,0)//hs
TNT1 A 0 A_NoBlocking
Stop

Pain300:
TNT1 A 0
XDT3 A 0 A_Explode(300,80,0)//hs
TNT1 A 0 A_NoBlocking
Stop

Pain350:
TNT1 A 0
XDT3 A 0 A_Explode(350,80,0)//hs
TNT1 A 0 A_NoBlocking
Stop

Pain400:
TNT1 A 0
XDT3 A 0 A_Explode(400,80,0)//hs
TNT1 A 0 A_NoBlocking
Stop

Pain450:
TNT1 A 0
XDT3 A 0 A_Explode(600,80,0)//hs
TNT1 A 0 A_NoBlocking
Stop

Pain500:
TNT1 A 0
XDT3 A 0 A_Explode(1200,80,0)//hs
TNT1 A 0 A_NoBlocking
Stop

Pain550:
TNT1 A 0
XDT3 A 0 A_Explode(1550,80,0)//hs
TNT1 A 0 A_NoBlocking
Stop

Pain600:
TNT1 A 0
XDT3 A 0 A_Explode(1600,80,0)//hs
TNT1 A 0 A_NoBlocking
Stop

SuperDeath:
Death:
TNT1 A 0
XDT3 A 0 A_Explode(1800,80,0)//hs
TNT1 A 0 A_NoBlocking
Stop
 }
}	