{

	saved_OnGun01 [0]
	saved_OnGun02 [0]
	saved_OnGun03 [0]

	saved_Comrades [0]
	saved_GroupComplete [0]
	saved_SniperArea [0]
	saved_HallArea [0]

	saved_MakarovHere [0]

	saved_Guards [0]

	saved_CityOne [0]
	saved_CityTwo [0]
	saved_CityThree [0]
	saved_CityFour [0]
	saved_CityFive [0]
	saved_CitySix [0]
	
	saved_BereshDead [0]

	saved_CityHall [0]

	saved_GunFight [0]
	saved_GunFight2 [0]
	saved_HallBattle [0]
	saved_EnteredFlak [0]

	saved_NumDeadPlanes [0]
	saved_NumBombWaves [0]

	saved_RaisedMG42 [0]

	saved_CurObjective [0]
	NumObjectives [7]

	saved_yet [0]
	saved_also [0]

	OnLevelLoad[()
	{
		PlayAmbient(52);
		
		if (saved_also = 0)
		{
			saved_also = 1;
			Makarov = GetEntity("makarov");
			Makarov.Delay(1,5);

			Comrade4 = GetEntity("com4");
			Comrade4.Delay(6,5);

			Comrade5 = GetEntity("com5");
			Comrade5.Delay(6,10);
		
			SetMessage("Kursk, Kharkova",75,35);
			SetMessage2(544,75,50);
			SetMessage3(518,75,65);
			
		}
	}]

	Init[ (s)
	{

		PlayAmbient(52);

		if (saved_yet = 0)
		{
			saved_yet = 1;
			
			AddObjective( 216, 6546, 14299);
			SetObjectiveActive(0, true);

			AddObjective( 217, 14829, 24988);
			SetObjectiveActive(1, false);

			AddObjective( 144, 6784, 30352);
			SetObjectiveActive(2, false);

			AddObjective( 218, 14829, 24988);
			SetObjectiveActive(3, false);

			AddObjective( 219, 14829, 24988);
			SetObjectiveActive(4, false);

			AddObjective( 220, 29056, 19821);
			SetObjectiveActive(5, false);

			AddObjective( 221, 29056, 19821);
			SetObjectiveActive(6, false);

			Self=GetPlayer();
			Self.SetNationality(3);
			Self.GiveWeapon(62, 5);
			Self.GiveWeapon(61, 5);
			Self.SetInvulnerable(false);

			GetPlayer().SetFrozen(true);

			SetCellBlocking(69,95,true);
			SetCellBlocking(70,95,true);
			SetCellBlocking(71,95,true);
			SetCellBlocking(72,95,true);
			SetCellBlocking(73,95,true);

//			Makarov = GetEntity("makarov");
//			Makarov.Delay(1,5);
//
//			Comrade4 = GetEntity("com4");
//			Comrade4.Delay(6,5);
//
//			Comrade5 = GetEntity("com5");
//			Comrade5.Delay(6,10);
//		
//			SetMessage("Kursk, Kharkova",75,35);
//			SetMessage2("August 22, 1943 ",75,50);
//			SetMessage3(518,75,65);

			AutoSave();
		}
	}]

	AdvanceObjectives[ (hideLast)
	{
		if( saved_CurObjective < NumObjectives )
		{
			NextObj = (saved_CurObjective+1);
			DropObj = (saved_CurObjective-2);

			ObjectiveComplete( saved_CurObjective );

			if( NextObj < NumObjectives )
			{
				if( hideLast = 1 )
				{
					SetObjectiveActive( saved_CurObjective, false );
				}

				SetObjectiveActive( NextObj, true );

				if( Level.saved_CurObjective > 1 )
				{
					Level.SetObjectiveActive( NextObj, true );
					if( hideLast = 0 )
					{
						Level.SetObjectiveActive( DropObj, false );
					}
				}
			}
			saved_CurObjective = NextObj;
		}
	}]

	EnterZone[( zone )
	{
		if (zone = "gunzone1" )
		{
			if (saved_OnGun01 = 0)
			{
				saved_OnGun01 = 1;
				GunDude1 = GetEntity("gunguy1");
				GunDude1.SetState_MG42( GetEntity("mg42-01"));
			}
		}

		if (zone = "gunzone2" )
		{
			if (saved_OnGun02 = 0)
			{
				saved_OnGun02 = 1;
				FinalGun1 = GetEntity("gunguy2");
				FinalGun1.Respawn(0);
				FinalGun2 = GetEntity("gunguy3");
				FinalGun2.Respawn(1);
				FinalRush1 = GetEntity("rush1");
				FinalRush1.Respawn(0);
				FinalRush3 = GetEntity("rush3");
				FinalRush3.Respawn(1);
			}
		}

		if (zone = "gunzone3" )
		{
			if (saved_OnGun03 = 0)
			{
				saved_OnGun03 = 1;
				GunDude4 = GetEntity("gunguy4");
				GunDude4.SetState_MG42( GetEntity("mg42-04"));
//				CR02 = GetEntity("cr02");
//				CR02.SetActive();
			}
		}

		if (zone = "comrades" )
		{
			if (saved_Comrades = 0)
			{
				saved_Comrades = 1;
				saved_GroupComplete = (saved_GroupComplete +1);
				CheckGroup();
				CheckMakarov();
				GetPlayer().SetFrozen(true);
				
				if (saved_RaisedMG42 = 0)
				{
					saved_RaisedMG42 = 1;
					MG42guy = GetEntity("gunguy4");
					MG42guy.SetState_Idle();
					MG42guy.ShowEntity( false );
				}
			}
		}

		if (zone = "city1" )
		{
			if (saved_CityOne = 0)
			{
				saved_CityOne = 1;
				Makarov = GetEntity("makarov");
				Makarov.NextPath(2);
			}
		}

		if (zone = "city2" )
		{
			if (saved_CityTwo = 0)
			{
				saved_CityTwo = 1;
				CR01 = GetEntity("cr01");
				CR01.SetActive();
				ST01 = GetEntity("st01");
				ST01.SetActive();
			}
		}

		if (zone = "city3" )
		{
			if (saved_CityThree = 0)
			{
				saved_CityThree = 1;
				Makarov = GetEntity("makarov");
				Makarov.NextPath(3);
			}
		}

		if (zone = "city4" )
		{
			if (saved_CityFour = 0)
			{
				saved_CityFour = 1;
				Makarov = GetEntity("makarov");
				Makarov.NextPath(4);
			}
		}

		if (zone = "city5" )
		{
			if (saved_CityFive = 0)
			{
				saved_CityFive = 1;
				GetPlayer().SetFrozen(true);
				saved_SniperArea = (saved_SniperArea +1);
				Target = GetEntity("com50");
				Target.PlaySound(173);
				Target.Delay(2,45);
				CheckSniper();
			}
		}

		if (zone = "city6" )
		{
			if (saved_CitySix = 0)
			{
				saved_CitySix = 1;
				Makarov = GetEntity("makarov");
				Makarov.NextPath(8);
			}
		}

		if (zone = "cityhall" )
		{
			if (saved_CityHall = 0)
			{
				saved_CityHall = 1;
				saved_HallArea = (saved_HallArea +1);
				GetPlayer().SetFrozen(true);
				CheckHall();

			}
		}

		if (zone = "blockade")
		{
			if (saved_HallBattle < 4)
			{
//				Log("DUDE, HELP YOUR HOMIES!!");
				return;
			}
		}

		if (zone = "flakzone")
		{
			if (saved_EnteredFlak < 1)
			{
				saved_EnteredFlak  = (saved_EnteredFlak +1);
				SpawnBomberWave();
				AdvanceObjectives(1);
			}
		}
		
		if (zone = "sniperzone")
		{
			if (saved_BereshDead < 1)
			{
					GetPlayer().PlaySound(29);
					GetPlayer().Kill();
			}
		}
	}]

	CheckMakarov[()
	{
		if (saved_MakarovHere = 0)
		{
//			Log("MAKAROV NEVER MADE IT!!!");
			Level.GetPlayer().PlaySound(175);
			saved_MakarovHere = toInt(saved_MakarovHere +1);

			Makarov = GetEntity("makarov");
			Makarov.ClearQueuedPaths();
			Makarov.StopFollowingPath();
			Makarov.SetState_Idle();
			Makarov.SetPosition(4516,13037);
			Makarov.NextPath(10);
		}
	}]

	CheckGroup[()
	{
		if (saved_GroupComplete = 2)
		{
			Makarov = GetEntity("makarov");
			Makarov.Delay(1,15);
		}
	}]

	CheckSniper[()
	{
//		Log("CHECKing SNIPER!");
		if (saved_SniperArea = 2)
		{
//				PlaySound "stop! there is a sniper out there! brashenkov wait!!!"
				Beresh = GetEntity("com50");
				Beresh.Delay(3,50);
		}
	}]

	CheckHall[()
	{
		if (saved_HallArea = 2)
		{
			Makarov = GetEntity("makarov");
			Makarov.Delay(2,45);
		}
	}]

	ActorKilled[(who)
	{
		if (who = "gunguy1")
		{
			if (saved_OnGun01 = 0)
			{
				saved_OnGun01 = 1;
			}

			return;
		}

		if (who = "gunguy4")
		{
			if (saved_OnGun03 = 0)
			{
				saved_OnGun03 = 1;
				saved_RaisedMG42 = 1;
			}

			return;
		}

		if (who = "guard1")
		{
			saved_Guards = (saved_Guards +1);
			CheckGuards();

			return;
		}

		if (who = "guard2")
		{
			saved_Guards = (saved_Guards +1);
			CheckGuards();

			return;
		}

		if (who = "com50")
		{
			Makarov = GetEntity("makarov");
			Makarov.Delay(1,25);

			return;
		}

		if (who = "sniper")
		{
			Makarov = GetEntity("makarov");
			Makarov.Delay(1,35);
			saved_BereshDead = toInt(saved_BereshDead +1);
			return;
		}

		if (who = "gunguy2")
		{
			if (saved_GunFight < 10)
			{
				GetEntity("gunguy2").Delay(2,5);
			}
			else
			{
				GetEntity("gunguy2").SetState_Idle();
				saved_HallBattle = (saved_HallBattle +1);
				CheckHallComplete();
			}

			return;
		}

		if (who = "gunguy3")
		{
			if (saved_GunFight < 10)
			{
				GetEntity("gunguy3").Delay(2,10);
			}
			else
			{
				GetEntity("gunguy3").SetState_Idle();
				saved_HallBattle = (saved_HallBattle +1);
				CheckHallComplete();
			}

			return;
		}

		if (who = "rush1")
		{
			if (saved_GunFight2 < 10)
			{
				GetEntity("rush1").Delay(2,5);
			}
			else
			{
				GetEntity("rush1").SetState_Idle();
				saved_HallBattle = (saved_HallBattle +1);
				CheckHallComplete();
			}

			return;
		}

		if (who = "rush3")
		{
			if (saved_GunFight2 < 10)
			{
				GetEntity("rush3").Delay(2,10);

			}
			else
			{
				GetEntity("rush3").SetState_Idle();
				saved_HallBattle = (saved_HallBattle +1);
				CheckHallComplete();
			}

			return;
		}

		if(who ="gPlane" )
		{
			saved_NumDeadPlanes = toInt( saved_NumDeadPlanes + 1 );
			CheckBomberRunOver();
			return;
		}

	}]

	CheckHallComplete[()
	{
//		Log("CHECKING HALL");

		if (saved_HallBattle = 4)
		{
			Log("HALL BATTLE IS COMPLETE!");
			SetCellBlocking(69,95,false);
			SetCellBlocking(70,95,false);
			SetCellBlocking(71,95,false);
			SetCellBlocking(72,95,false);
			SetCellBlocking(73,95,false);

			Makarov = GetEntity("makarov");
			Makarov.Delay(3,70);
		}
	}]

	CheckGuards[()
	{
//		Log("Checking Guards!!!");
		if (saved_Guards = 2)
		{
			Makarov = GetEntity("makarov");
			Makarov.NextPath(6);

			Comrade2 = GetEntity("com2");
			Comrade2.Delay(2,25);

//			Beresh = GetEntity("com50");
//			Beresh.SetPosition(4224, 25472, 192);
		}
	}]

	SpawnBomberWave[()
	{
//		Log("--> SpawnBomberWave()");

		// adjust counters
		saved_NumBombWaves = toInt( saved_NumBombWaves + 1 );
		saved_NumDeadPlanes = 0;

		if( saved_NumBombWaves < 6 )
		{
			for i = 0 to 2
			{
				Plane = CreateEntity( 193, 0, 0, 0);
				Plane.ShowEntity(false);
				Plane.SetInvulnerable(true);
				doffset = ((i*10) + 10);
				Plane.Delay(doffset, 10 );
			}
		}
		else
		{
			Makarov = GetEntity("makarov");
			Makarov.Delay(2,60);
		}

//		Log("   <-- SpawnBomberWave()");
	}]

	CheckBomberRunOver[()
	{
//		Log("--> CheckBomberRunOver()");
//		Log("        bombWaves:   " # saved_NumBombWaves);
//		Log("        deadPlanes:  " # saved_NumDeadPlanes);

		if( saved_NumDeadPlanes > 1)
		{
//			Log(" AERIAL WAVE COMPLETE ");
			SpawnBomberWave();
		}
	}]
}