#library "CVARS"
#include "zcommon.acs"



	

script "BDInitialize" enter
{
    // Fade In
	sethudsize(160, 90, TRUE);
	setfont("BLASCR");
	
	if	(GameType () == GAME_SINGLE_PLAYER) 
		{
		HudMessageBold(s:"a"; HUDMSG_FADEOUT, 1, CR_BLACK, 0.1, 0.1, 0.1, 1.0);
		}

	sethudsize(640, 400, TRUE);
	setfont("SmallFONT");
	HudMessageBold(s:"Alpha 0.1 Dec 08 2019"; HUDMSG_PLAIN, 8, CR_WHITE, 500.0, 10.01, 9999.1, 1.0);
		
		
	

	if	(GameType () == GAME_NET_COOPERATIVE) 
		{
		ConsoleCommand("compat_clientssendfullbuttoninfo 1");
		}
		
		
	

	//Spawn surviving marines
	
	//Rifle Marines
	if (checkinventory("NumberOfAllies") == 1){	Spawn("Marine_Rifle", GetActorX(0)-32, GetActorY(0), GetActorZ(0), 0, 0);}
	if (checkinventory("NumberOfAllies") > 1){	Spawn("Marine_Rifle", GetActorX(0)-32, GetActorY(0), GetActorZ(0), 0, 0);}
	if (checkinventory("NumberOfAllies") > 2){	Spawn("Marine_Rifle", GetActorX(0)-32, GetActorY(0), GetActorZ(0), 0, 0);}
	if (checkinventory("NumberOfAllies") > 3){	Spawn("Marine_Rifle", GetActorX(0)-32, GetActorY(0), GetActorZ(0), 0, 0);}
	if (checkinventory("NumberOfAllies") > 4){	Spawn("Marine_Rifle", GetActorX(0)-32, GetActorY(0), GetActorZ(0), 0, 0);}
	if (checkinventory("NumberOfAllies") > 5){	Spawn("Marine_Rifle", GetActorX(0)-32, GetActorY(0), GetActorZ(0), 0, 0);}
	if (checkinventory("NumberOfAllies") > 6){	Spawn("Marine_Rifle", GetActorX(0)-32, GetActorY(0), GetActorZ(0), 0, 0);}
	if (checkinventory("NumberOfAllies") > 7){	Spawn("Marine_Rifle", GetActorX(0)-32, GetActorY(0), GetActorZ(0), 0, 0);}
	
	//Shotgun Marines
	if (checkinventory("NumberOfAlliesShotgun") == 1){	Spawn("Marine_Shotgun", GetActorX(0)-32, GetActorY(0), GetActorZ(0), 0, 0);}
	if (checkinventory("NumberOfAlliesShotgun") > 1){	Spawn("Marine_Shotgun", GetActorX(0)-32, GetActorY(0), GetActorZ(0), 0, 0);}
	if (checkinventory("NumberOfAlliesShotgun") > 2){	Spawn("Marine_Shotgun", GetActorX(0)-32, GetActorY(0), GetActorZ(0), 0, 0);}
	if (checkinventory("NumberOfAlliesShotgun") > 3){	Spawn("Marine_Shotgun", GetActorX(0)-32, GetActorY(0), GetActorZ(0), 0, 0);}
	if (checkinventory("NumberOfAlliesShotgun") > 4){	Spawn("Marine_Shotgun", GetActorX(0)-32, GetActorY(0), GetActorZ(0), 0, 0);}
	if (checkinventory("NumberOfAlliesShotgun") > 5){	Spawn("Marine_Shotgun", GetActorX(0)-32, GetActorY(0), GetActorZ(0), 0, 0);}
	if (checkinventory("NumberOfAlliesShotgun") > 6){	Spawn("Marine_Shotgun", GetActorX(0)-32, GetActorY(0), GetActorZ(0), 0, 0);}
	if (checkinventory("NumberOfAlliesShotgun") > 7){	Spawn("Marine_Shotgun", GetActorX(0)-32, GetActorY(0), GetActorZ(0), 0, 0);}
	
	//Minigun Marines
	if (checkinventory("NumberOfAlliesMinigun") == 1){	Spawn("Marine_Minigun", GetActorX(0)-32, GetActorY(0), GetActorZ(0), 0, 0);}
	if (checkinventory("NumberOfAlliesMinigun") > 1){	Spawn("Marine_Minigun", GetActorX(0)-32, GetActorY(0), GetActorZ(0), 0, 0);}
	if (checkinventory("NumberOfAlliesMinigun") > 2){	Spawn("Marine_Minigun", GetActorX(0)-32, GetActorY(0), GetActorZ(0), 0, 0);}
	if (checkinventory("NumberOfAlliesMinigun") > 3){	Spawn("Marine_Minigun", GetActorX(0)-32, GetActorY(0), GetActorZ(0), 0, 0);}
	if (checkinventory("NumberOfAlliesMinigun") > 4){	Spawn("Marine_Minigun", GetActorX(0)-32, GetActorY(0), GetActorZ(0), 0, 0);}
	if (checkinventory("NumberOfAlliesMinigun") > 5){	Spawn("Marine_Minigun", GetActorX(0)-32, GetActorY(0), GetActorZ(0), 0, 0);}
	if (checkinventory("NumberOfAlliesMinigun") > 6){	Spawn("Marine_Minigun", GetActorX(0)-32, GetActorY(0), GetActorZ(0), 0, 0);}
	if (checkinventory("NumberOfAlliesMinigun") > 7){	Spawn("Marine_Minigun", GetActorX(0)-32, GetActorY(0), GetActorZ(0), 0, 0);}
	
	
	//Rocket Marines
	if (checkinventory("NumberOfAlliesRocket") == 1){	Spawn("Marine_Rocket", GetActorX(0)-32, GetActorY(0), GetActorZ(0), 0, 0);}
	if (checkinventory("NumberOfAlliesRocket") > 1){	Spawn("Marine_Rocket", GetActorX(0)-32, GetActorY(0), GetActorZ(0), 0, 0);}
	if (checkinventory("NumberOfAlliesRocket") > 2){	Spawn("Marine_Rocket", GetActorX(0)-32, GetActorY(0), GetActorZ(0), 0, 0);}
	if (checkinventory("NumberOfAlliesRocket") > 3){	Spawn("Marine_Rocket", GetActorX(0)-32, GetActorY(0), GetActorZ(0), 0, 0);}
	if (checkinventory("NumberOfAlliesRocket") > 4){	Spawn("Marine_Rocket", GetActorX(0)-32, GetActorY(0), GetActorZ(0), 0, 0);}
	if (checkinventory("NumberOfAlliesRocket") > 5){	Spawn("Marine_Rocket", GetActorX(0)-32, GetActorY(0), GetActorZ(0), 0, 0);}
	if (checkinventory("NumberOfAlliesRocket") > 6){	Spawn("Marine_Rocket", GetActorX(0)-32, GetActorY(0), GetActorZ(0), 0, 0);}
	if (checkinventory("NumberOfAlliesRocket") > 7){	Spawn("Marine_Rocket", GetActorX(0)-32, GetActorY(0), GetActorZ(0), 0, 0);}
	
	
	//Plasmagun Marines
	if (checkinventory("NumberOfAlliesPlasmagun") == 1){	Spawn("Marine_Plasmagun", GetActorX(0)-32, GetActorY(0), GetActorZ(0), 0, 0);}
	if (checkinventory("NumberOfAlliesPlasmagun") > 1){	Spawn("Marine_Plasmagun", GetActorX(0)-32, GetActorY(0), GetActorZ(0), 0, 0);}
	if (checkinventory("NumberOfAlliesPlasmagun") > 2){	Spawn("Marine_Plasmagun", GetActorX(0)-32, GetActorY(0), GetActorZ(0), 0, 0);}
	if (checkinventory("NumberOfAlliesPlasmagun") > 3){	Spawn("Marine_Plasmagun", GetActorX(0)-32, GetActorY(0), GetActorZ(0), 0, 0);}
	if (checkinventory("NumberOfAlliesPlasmagun") > 4){	Spawn("Marine_Plasmagun", GetActorX(0)-32, GetActorY(0), GetActorZ(0), 0, 0);}
	if (checkinventory("NumberOfAlliesPlasmagun") > 5){	Spawn("Marine_Plasmagun", GetActorX(0)-32, GetActorY(0), GetActorZ(0), 0, 0);}
	if (checkinventory("NumberOfAlliesPlasmagun") > 6){	Spawn("Marine_Plasmagun", GetActorX(0)-32, GetActorY(0), GetActorZ(0), 0, 0);}
	if (checkinventory("NumberOfAlliesPlasmagun") > 7){	Spawn("Marine_Plasmagun", GetActorX(0)-32, GetActorY(0), GetActorZ(0), 0, 0);}
	
	
	TakeInventory("TankGun", 1);
	TakeInventory("ArtilleryTankGun", 1);
	TakeInventory("HelicopterGun", 1);
	TakeInventory("MechGun", 1);
	TakeInventory("HeavyMachinegunHUD", 1);
	SetPlayerProperty(0, 0, PROP_BUDDHA);

}


Script "BDCHeckJanitor" (VOID)
{
if	(GetCvar("bd_lowgraphicsmode") == 1) { GiveInventory("LowGraphicsMode", 1); }
if	(GetCvar("zdoombrutaljanitor") == 1) { GiveInventory("LowGraphicsMode", 1); }
if	(GameType () == GAME_NET_DEATHMATCH) { GiveInventory("LowGraphicsMode", 1); }
}

Script "BDCHeckJanitor2" (VOID)
{
if	(GetCvar("bd_infinitecasings") == 0) { GiveInventory("LowGraphicsMode", 1); }
}

Script "BDCHeckJanitor3" (VOID)//Making limbs not bounce with explosives
{
if	(GetCvar("bd_lowgraphicsmode") == 1) { SetActorState(0, "NoColision", 1); }
if	(GetCvar("zdoombrutaljanitor") == 1) { SetActorState(0, "NoColision", 1); }
}



Script "BDCHeckJanitor4" (VOID)
{



	if	(GetCvar("isrunningzandronum") == 1)
	{
	if	(GetCvar("bd_bloodamount") < 2) { SetActorState(0,"Vanish"); }
	}

	if	(GetCvar("isrunningzandronum") == 0)
	{
	if	(GetCvar("zdoombrutalblood") < 2) { SetActorState(0,"Vanish"); }
	}

}

Script "BDCHeckClassicMonsters" (VOID)
{
if	(GetCvar("bd_classicmonsters") == 1) { SetActorState(0,"ReplaceVanilla"); }
}

Script "BDCheckDecorations" (VOID)
{
if	(GetCvar("bd_disabledecorations") == 1) { SetActorState(0,"Vanilla"); }
}

Script "BDDisableMapEnhancements" (VOID)
{
if	(GetCvar("bd_disablemapenhancements") == 1) { SetActorState(0,"Vanilla"); }
}


Script "BDDisableNewGuns" (VOID)
{
if	(GetCvar("bd_disablenewguns") == 1) { SetActorState(0,"Vanilla"); }
}



Script "CheckIfDM" (VOID)
{
	if	(GameType () == GAME_NET_DEATHMATCH) 	GiveInventory("DMGame", 1);
	Delay(1);
	if	(GameType () == GAME_NET_DEATHMATCH) 	SetActorState(0,"DM"); 
}

Script "BDCheckStuff" (VOID)
{
if	(GetCvar("bd_nobulletpenetration") == 0) { TakeInventory("nopenetration", 1);}
if	(GetCvar("bd_nobulletpenetration") == 1) { GiveInventory("nopenetration", 1);}
if	(GetCvar("bd_shotgunstrap") == 1) { GiveInventory("useshotgunstrap", 1);}
if	(GetCvar("zdoombd_shotgunstrap") == 1) { GiveInventory("useshotgunstrap", 1);}
if	(GetCvar("bd_disablenewenemies") == 1) { GiveInventory("nonewenemies", 1);}
}



Script "BDCheckWaterRipples" (VOID)
{
if	(GetCvar("vietdoomwaterripples") > 0) { GiveInventory("Clip2", 10); }
if (CheckActorFloorTexture(0, "WATER01"))    GiveInventory("IsOverDarkWater", 1);
if (CheckActorFloorTexture(0, "TIDAL01"))    GiveInventory("IsOverClearWater", 1);
if (CheckActorFloorTexture(0, "WATMD01"))    GiveInventory("IsOverMuddyWater", 1);
}

Script "BDDisableFriendlyMarines" (VOID)
{
if	(GetCvar("bd_disablefriendlymarines") > 0) { GiveInventory("Clip2", 10); }
}


Script "BDShootableAmmo" (VOID)
{
if	(GetCvar("bd_shootablerocketammo") < 1) { GiveInventory("Clip1", 10); }
}


Script "BDFootsteps" (VOID)
{
if	(GetCvar("bd_footstepsounds") == 0) { GiveInventory("FootStepDisabled", 1); }
}


Script "DemonRuneCheck" (VOID)
{
if	(GetCvar("bd_disabledemonspheres") == 1) { SetACtorState(0, "Cancels"); }
}



Script "CheckRocketBackblast" (VOID)
{
if	(GetCvar("bd_rocketbackblast") == 0) { SetACtorState(0, "Disappear"); }
}


Script "CheckVoxels" (VOID)
{
if	(GetCvar("bd_voxeldec") == 0) { SetACtorState(0, "Disappear"); }
}









Script "BD_CheckBloodIntensity" (VOID)
{

	if	(GetCvar("isrunningzandronum") == 1)
	{
	if	(GetCvar( "bd_bloodamount") == 0) { SetActorState(0,"LowBlood"); }
	if	(GetCvar( "bd_bloodamount") == 1) { SetActorState(0,"LowBlood"); }
	if	(GetCvar( "bd_bloodamount") == 3) { SetActorState(0,"LotsOfBlood"); }
	if	(GetCvar( "bd_bloodamount") >= 4) { SetActorState(0,"AbsurdBlood"); }
	}


	if	(GetCvar("isrunningzandronum") == 0)
	{
	if	(GetCvar("zdoombrutalblood") == 0) { SetActorState(0,"LowBlood"); }
	if	(GetCvar("zdoombrutalblood") == 1) { SetActorState(0,"LowBlood"); }
	if	(GetCvar("zdoombrutalblood") == 3) { SetActorState(0,"LotsOfBlood"); }
	if	(GetCvar("zdoombrutalblood") == 4) { SetActorState(0,"AbsurdBlood"); }
	}


	if	(GetCvar("isrunningzandronum") == 1)
	{
		if	(GetCvar("bd_bloodamount") >= 5)
			{
			SetActorState(0,"AbsurdBlood"); 
			GiveInventory("AnimuGore", 1);
			}
	}

	if	(GetCvar("isrunningzandronum") == 0)
	{
	if	(GetCvar("zdoombrutalblood") >= 5)
		{
		SetActorState(0,"AbsurdBlood"); 
		GiveInventory("AnimuGore", 1);
		}
	}

}


Script "BD_CheckBloodExtra1" (VOID)
{
		if	(GetCvar("bd_morebloodmist") >= 1)
			{
			SetActorState(0,"AbsurdBlood"); 
			}
}


Script "BD_CheckIfLowBlood" (VOID)
{
if	(GetCvar("bd_bloodamount") == 1) { SetActorState(0,"Vanish"); }
if	(GetCvar("bd_bloodamount") == 0) { SetActorState(0,"Vanish"); }
}



script "BD_CheckIfOverLiquid" (void) //Water Small Splash
{
	if (CheckActorFloorTexture(0, "WATER01"))    GiveInventory("IsOverWater", 1);
}