--Initial campaign triggers (static file, not updated)
--Copied to Status/camp_triggers.lua in first mission and subsequently read and updated there
--Campaign triggers are defined with conditions and actions
-------------------------------------------------------------------------------------------------------

--List of Return functions to build conditions:
--Return.Time()												returns time of day in seconds
--Return.Day()												returns day of month
--Return.Month()											returns month as number
--Return.Year()												returns year as number
--Return.Mission()											returns campaign mission number
--Return.CampFlag(flag-n)									returns value of campaign flag
--Return.AirUnitActive("UnitName")							returned boolean whether the air unit is active			
--Return.AirUnitReady("UnitName")							returns amount of ready aircraft in unit
--Return.AirUnitAlive("UnitName")							returns amount of ready and damaged aircraft in unit
--Return.AirUnitBase("UnitName")							returns the name of the airbase the unit operats from
--Return.AirUnitPlayer("UnitName")							returns boolean whether the air units is playable
--Return.TargetAlive("TargetName")							returns percentage of alive sub elements in target
--Return.UnitDead(unitname)									(ADD) return vehicle/ship units dead (ADD)
--Return.GroupHidden("GroupName")							returns group hidden status
--Return.GroupProbability("GroupName")						returns group spawn probability value between 0 and 1
--Return.ShipGroupInPoly(GroupName, PolyZonesTable)			(ADD) return boolean whether ship group is in polygon (ADD)

--List of Action functions for trigger actions:
--Action.None()
--Action.Text("your briefing text")
--Action.TextPlayMission(arg)																--add trigger text to briefing text of this mission only if it is playable
--Action.SetCampFlag(flag-n, boolean/number)												--
--Action.AddCampFlag(flag-n, number)														--
--Action.AddImage("filname.jpg")															--
--Action.CampaignEnd("win"/"draw"/"loss")													--
--Action.TargetActive("TargetName", boolean)												--
--Action.AirUnitActive("UnitName", boolean)													--
--Action.AirUnitBase("UnitName", "BaseName")												--
--Action.AirUnitPlayer("UnitName", boolean)													--
--Action.AirUnitReinforce("SourceUnitName", "DestinationUnitName", destNumber)				--
--Action.AirUnitRepair()																	--
--Action.GroundUnitRepair()																	-- (ADD) M19.f : Repair Ground
--Action.AddGroundTargetIntel("sideName")													--
--Action.GroupHidden("GroupName", boolean)													--
--Action.GroupProbability("GroupName", number 0-1)											--
--Action.GroupMove(GroupName, ZoneName)														-- (ADD) move vehicle group to refpoint (See the DC_CheckTriggers.lua file for more explanation)
--Action.GroupSlave(GroupName, master, bearing, distance)									-- (ADD)
--Action.ShipMission(GroupName, WPtable, CruiseSpeed, PatrolSpeed, StartTime)				-- (ADD) assign and run a movement mission to a ship group (See the DC_CheckTriggers.lua file for more explanation)
--Action.TemplateActive(TabFile)															-- (ADD) M40 : Template Active GroundGroup moving front (single file : active template) (if tab file: random activation)



--Important notes:
--for condition and action strings: outside with single quotes '', inside with double quotes ""!

camp_triggers = {
	
	----- CAMPAIGN INTRO ----
	["Campaign Briefing"] = {										--Trigger name
		active = true,												--Trigger is active
		once = true,												--Trigger is fired once
		condition = 'true',											--Condition of the trigger to return true or false embedded as string
		action = {													--Trigger action function embedded as string
			[1] = 'Action.Text("December the 7th of 1971. India is ready to attack our country one more time. We are in highest alert state ready to repulse any air and ground attacks. Enemy missiles boat are near our coasts and can be a major threat for our forces. The main ground danger will come from both frontiers with numerous Indian infantry units.")',
			[2] = 'Action.Text("Our Air forces are ready with No 11 Squadron flying on Shenyang F-6, No 14 Squadron and No 15 Squadron flying on F-86F Sabre.")',
			[3] = 'Action.Text("The Indian forces are mainly flying on Mig-21 with 2 squadrons in east bases and 1 squadron in West base. One squadron of Su-7 is active on east base. Our goal will be to gain air superiority by neutralizing main bases and destroying as many planes as possible. Then we will attack Indian ground forces to prevent any offensives.")',
			[4] = 'Action.AddImage("Newspaper_FirstNight_red.jpg", "red")',
			[5] = 'Action.AddImage("Newspaper_FirstNight_blue.jpg", "blue")',
		},
	},
	
----- CAMPAIGN SITUATION -----
	["Campaign first destructions"] = {
		active = true,
		once = true,
		condition = 'GroundTarget["blue"].percent < 100',
		action = {
			[1] = 'Action.Text("First targets have been destroyed. Keep up the good work")',
		},
	},
	["Campaign 20 percents destructions"] = {
		active = true,
		once = true,
		condition = 'GroundTarget["blue"].percent < 80',
		action = {
			[1] = 'Action.Text("Enemy targets have sustained fair damages. Keep up the good work")',
		},
	},
	["Campaign 40 percents destructions"] = {
		active = true,
		once = true,
		condition = 'GroundTarget["blue"].percent < 60',
		action = {
			[1] = 'Action.Text("Enemy targets have sustained great damages. Strike missions are really efficient and we will win this war soon")',
		},
	},
	["Campaign 50 percents destructions"] = {
		active = true,
		once = true,
		condition = 'GroundTarget["blue"].percent < 50',
		action = {
			[1] = 'Action.Text("More than half of our targets are neutralized. Intelligence think that the enemy will ask for a cease fire soon")',
		},
	},

	
	----- CAMPAIGN END -----
	["Campaign End Victory 1"] = {
		active = true,
		once = false,
		condition = 'GroundTarget["blue"].percent < 45',
		action = {
			[1] = 'Action.CampaignEnd("win")',
			[2] = 'Action.Text("The Pakistan Air Force have successfully destroyed all the targets that they were assigned by Central Command. With the heavy losses inflicted to the Indian ground forces, any enemy offensive will be stopped. Well done.")',
			[3] = 'Action.AddImage("Newspaper_Victory_blue.jpg", "blue")',
			[4] = 'Action.AddImage("Newspaper_Defeat_red.jpg", "red")',
			[5] = 'NoMoreNewspaper = true',
		},
	},
	["Campaign End Victory 2"] = {
		active = true,
		once = false,
		condition = 'Return.AirUnitReady("No 4 Squadron") + Return.AirUnitReady("No 28 Squadron") + Return.AirUnitReady("No 30 Squadron") + Return.AirUnitReady("No 221 Squadron") < 4',
		action = {
			[1] = 'Action.CampaignEnd("win")',
			[2] = 'Action.Text("The Indian Air Force is in ruins. After repeated air strikes and disastrous losses in air-air combat, the Indians are no longer able to produce any sorties or offer any resistance. Our forces now owns complete air superiority. Well done.")',
			[3] = 'Action.AddImage("Newspaper_Victory.jpg", "blue")',
			[4] = 'NoMoreNewspaper = true',
		},
	},
	["Campaign End Victory 3"] = {
		active = true,
		once = false,
		condition = 'Return.TargetAlive("Senaki Airbase") < 12 and Return.TargetAlive("Kutaisi Airbase") < 11 and Return.TargetAlive("Maykop-Khanskaya Airbase") < 6 and Return.TargetAlive("Kobuleti Airbase") < 11',
		action = {
			[1] = 'Action.CampaignEnd("win")',
			[2] = 'Action.Text("The Indian Air Force is in ruins. All their bases are destroyed, they are no longer able to produce any sorties or offer any resistance. The Pakistan air forces now owns complete air superiority.")',
			[3] = 'Action.AddImage("Newspaper_Defeat_red.jpg", "red")',
			[4] = 'Action.AddImage("Newspaper_Victory_blue.jpg", "blue")',
			[5] = 'NoMoreNewspaper = true',
		},
	},
	["Campaign End Loss"] = {
		active = true,
		once = false,
		condition = 'Return.AirUnitAlive("No 11 Squadron") + Return.AirUnitReady("R/No 11 Squadron") < 4',
		action = {
			[1] = 'Action.CampaignEnd("loss")',
			[2] = 'Action.Text("Ongoing combat operations have exhausted No 11 Squadron. Loss rate has reached a level where reinforcements are no longer able to sustain combat operations. With the failure of Pakistan Air Force to attain air superiority, Central Command has decided to call of the air campaign against the Indians. They will be able to attack our country and our diplomatic power in the world is really weaked by this defeat.")',
			[3] = 'Action.AddImage("Newspaper_Victory_red.jpg", "red")',
			[4] = 'Action.AddImage("Newspaper_Defeat_blue.jpg", "blue")',
			[5] = 'NoMoreNewspaper = true',
		},
	},
	["Campaign End Loss 2"] = {
		active = true,
		once = false,
		condition = 'Return.TargetAlive("Gudauta Airbase") < 10',
		action = {
			[1] = 'db_airbases["Gudauta"].inactive = true',
			[2] = 'Action.CampaignEnd("loss")',
			[3] = 'Action.Text("After the Gudauta airbase has been hit and is nearly disable, No 11 Squadron is no longer able to fly. Our troops will have to continue the fight without our Squadron. This is a bitter failure for the Air Force")',
			[3] = 'Action.AddImage("Newspaper_Victory_red.jpg", "red")',
			[4] = 'Action.AddImage("Newspaper_Defeat_blue.jpg", "blue")',
			[5] = 'NoMoreNewspaper = true',
			
		}
	},
	["Campaign End Draw"] = {
		active = true,
		once = false,
		condition = 'Return.Mission() >= 50',
		action = {
			[1] = 'Action.CampaignEnd("draw")',
			[2] = 'Action.Text("The air campaign has seen a sustained period of inactivity. Seemingly unable to complete the destruction of the Indian Air Force and infrastructure, Pakistan Central Command has called off all squadrons from offensive operations. We hope negociations with India will convince them to stop the war")',
			[3] = 'NoMoreNewspaper = true',
		},
	},

	
	----- Missile boat movements -----
	["Missile Boat first zone ATest Sea"] = {
		active = true,
		once = false,
		condition = 'Return.Mission() >= 1',
		action = 'Action.ShipMission("Missile Boat 1", {{"Indy 1-1", "Indy 1-2", "Indy 1-3", "Indy 1-4"}}, 12, 8, nil)',
	},
	["Missile Boat second zone ATest Sea"] = {
		active = true,
		once = false,
		condition = 'Return.Mission() >= 1',
		action = 'Action.ShipMission("Missile Boat 2", {{"Indy 2-1", "Indy 2-2", "Indy 2-3", "Indy 2-4"}}, 12, 8, nil)',
	},

	----- CONVOY MOVEMENT -----
	["Patrol Boat 1 Patrol ATest Sea"] = {
		active = true,
		once = false,
		condition = 'Return.Mission() >= 1',
		action = 'Action.ShipMission("Patrol Boat 1", {{"Ships 1-1", "Ships 1-2", "Ships 1-3", "Ships 1-4"}}, 8, 5, nil)',
	},
	["Patrol boat 2 Patrol ATest Sea"] = {
		active = true,
		once = false,
		condition = 'Return.Mission() >= 1',
		action = 'Action.ShipMission("Patrol Boat 2", {{"Ships 1-5", "Ships 1-4", "Ships 1-3", "Ships 1-6"}}, 8, 5, nil)',
	},


	----- AIRBASE STRIKES -----
	["Gudauta Airbase Disabled"] = {
		active = true,
		condition = 'Return.TargetAlive("Gudauta Airbase") < 10',
		action = {
			[1] = 'db_airbases["Gudauta"].inactive = true',
		}
	},
	["Gudauta Airbase Disabled Text"] = {
		active = true,
		once = false,
		condition = 'Return.TargetAlive("Gudauta Airbase") < 10',
		action = {
			[1] = 'Action.Text("After the facilities at Gudauta Airbase have been hit by air strikes, air operations at this base came to a complete stop. Intelligence believes that due to the heavy damage inflicted, the base is no longer ably to produce any aviation sorties.")',
		}
	},
	["Kobuleti Airbase Disabled"] = {
		active = true,
		condition = 'Return.TargetAlive("Kobuleti Airbase") < 11',
		action = {
			[1] = 'db_airbases["Kobuleti"].inactive = true',
		}
	},
	["Kobuleti Airbase Disabled Text"] = {
		active = true,
		once = false,
		condition = 'Return.TargetAlive("Kobuleti Airbase") < 11',
		action = {
			[1] = 'Action.Text("After the facilities at Kobuleti Airbase have been hit by air strikes, air operations at this base came to a complete stop. Intelligence believes that due to the heavy damage inflicted, the base is no longer ably to produce any aviation sorties.")',
		}
	},
	["Senaki Airbase Disabled"] = {
		active = true,
		condition = 'Return.TargetAlive("Senaki Airbase") < 12',
		action = {
			[1] = 'db_airbases["Senaki-Kolkhi"].inactive = true',
		}
	},
	["Senaki Airbase Disabled Text"] = {
		active = true,
		once = false,
		condition = 'Return.TargetAlive("Senaki Airbase") < 12',
		action = {
			[1] = 'Action.Text("After the facilities at Senaki-Kolkhi Airbase have been hit by air strikes, air operations at this base came to a complete stop. Intelligence believes that due to the heavy damage inflicted, the base is no longer ably to produce any aviation sorties.")',
		}
	},	
	["Kutaisi Airbase Disabled"] = {
		active = true,
		condition = 'Return.TargetAlive("Kutaisi Airbase") < 11',
		action = {
			[1] = 'db_airbases["Kutaisi"].inactive = true',
		}
	},
	["Kutaisi Airbase Disabled Text"] = {
		active = true,
		once = false,
		condition = 'Return.TargetAlive("Kutaisi Airbase") < 11',
		action = {
			[1] = 'Action.Text("The infrastructure at Kutaisi Airbase has been destroyed by air strikes. Flying operations at this base have ceased completely and are unlikely to resume. This will ease our efforts to hit other targets in the Kutaisi Country area.")',
		}
	},
	["Sukhumi Airbase Disabled"] = {
		active = true,
		condition = 'Return.TargetAlive("Sukhumi Airbase") < 4 and Return.TargetAlive("Sukhumi Airbase Strategics") < 5',
		action = {
			[1] = 'db_airbases["Sukhumi"].inactive = true',
		}
	},
	["Sukhumi Airbase Disabled Text"] = {
		active = true,
		once = true,
		condition = 'Return.TargetAlive("Sukhumi Airbase") < 4 and Return.TargetAlive("Sukhumi Airbase Strategics") < 5',
		action = {
			[1] = 'Action.Text("Recent air strikes have destroyed enemy ground elements running operations at Sukhumi Airbase. Without their ground support, any remaining aircraft at the airstrip will no longer be able to launch on sorties.")',
		}
	},
	["Maykop-Khanskaya Airbase Disabled"] = {
		active = true,
		condition = 'Return.TargetAlive("Maykop-Khanskaya Airbase") < 6',
		action = {
			[1] = 'db_airbases["Maykop-Khanskaya"].inactive = true',
		}
	},
	["Maykop-Khanskaya Airbase Disabled Text"] = {
		active = true,
		once = true,
		condition = 'Return.TargetAlive("Maykop-Khanskaya Airbase") < 6',
		action = {
			[1] = 'Action.Text("Recent air strikes have destroyed enemy ground elements running operations at Maykop-Khanskaya Airbase. Without their ground support, any remaining aircraft at the airstrip will no longer be able to launch on sorties.")',
		}
	},
	
	----- RED INTERCEPTIONS -----
	["CAP After SouthEWR Destroyed"] = {
		active = true,
		once = true,
		condition = 'Return.TargetAlive("EWR South IND - Jaguar 121") == 0',
		action = {
			[1] = 'Action.Text("With the recent destruction of South Early Warning Radar site in the operations area, the ability of the enemy to launch interceptors against our strike packages was severely degraded. Intelligence expects that the enemy will increasingly depend on Combat Air Patrols to compensate, though without the support of ground controllers these are estimated to be of limited effectiveness.")',
		},
	},
	["CAP After SouthEWR Destroyed"] = {
		active = true,
		condition = 'Return.TargetAlive("EWR South IND - Jaguar 121") == 0',
		action = {
			[1] = 'Action.TargetActive("Senaki-Kolkhi Interception 1", false)',
			[2] = 'Action.TargetActive("Kutaisi Interception 1", false)',
		},
	},		
	["CAP After North EWR Destroyed"] = {
		active = true,
		once = true,
		condition = 'Return.TargetAlive("EWR North IND - Jaguar 122") == 0',
		action = {
			[1] = 'Action.Text("With the recent destruction of North Early Warning Radar site in the operations area, the ability of the enemy to launch interceptors against our strike packages was severely degraded. Intelligence expects that the enemy will increasingly depend on Combat Air Patrols to compensate, though without the support of ground controllers these are estimated to be of limited effectiveness.")',
		},
	},
	["CAP After North EWR Destroyed"] = {
		active = true,
		condition = 'Return.TargetAlive("EWR North IND - Jaguar 122") == 0',
		action = {
			[1] = 'Action.TargetActive("Maykop-Khanskaya Interception 1", false)',
			[2] = 'Action.TargetActive("Maykop-Khanskaya Interception 2", false)',
		},
	},

	----- BLUE INTERCEPTIONS -----
	["CAP After PAK EWR Destroyed"] = {
        active = true,
        once = true,
        condition = 'Return.TargetAlive("EWR 1 PAK - Axeman 130") == 0',
        action = {
            [1] = 'Action.Text("With the recent destruction of Early Warning Radar site in the operations area, our ability to launch interceptors against enemy strike packages is severely degraded. We will increasingly depend on Combat Air Patrols to compensate, though without the support of ground controllers these will be of limited effectiveness.")',
        },
    },
	["CAP After PAK EWR Destroyed"] = {
        active = true,
        condition = 'Return.TargetAlive("EWR 1 PAK - Axeman 130") == 0',
        action = {
            [1] = 'Action.TargetActive("Sukhumi Interception 1", false)',
            [2] = 'Action.TargetActive("Gudauta Interception 1", false)',
            [3] = 'Action.TargetActive("CAP Blue West", true)',
            [4] = 'Action.TargetActive("CAP Blue East 1", true)',
            [5] = 'Action.TargetActive("CAP Blue East 2", true)',
        },
    },
	
	----- REPAIR AND REINFORCEMENTS -----
	["Repair"] = {
		active = true,
		condition = 'true',
		action = 'Action.AirUnitRepair()',
	},
	-- Miguel21 modification M19 : Repair SAM
	["GroundUnitRepair"] = {
		active = true,
		condition = 'true',
		action = 'Action.GroundUnitRepair()',
	},
	["Reinforce No 11 Squadron"] = {
		active = true,
		condition = 'true',
		action = 'Action.AirUnitReinforce("R/No 11 Squadron", "No 11 Squadron", 12)',
	},
	["Reinforce No 14 Squadron"] = {
		active = true,
		condition = 'true',
		action = 'Action.AirUnitReinforce("R/No 14 Squadron", "No 14 Squadron", 12)',
	},	
	["Reinforce No 15 Squadron"] = {
		active = true,
		condition = 'true',
		action = 'Action.AirUnitReinforce("R/No 15 Squadron", "No 15 Squadron", 12)',
	},
	["Reinforce No 4 Squadron"] = {
		active = true,
		condition = 'true',
		action = 'Action.AirUnitReinforce("R/No 4 Squadron", "No 4 Squadron", 10)',
	},
	["Reinforce No 28 Squadron"] = {
		active = true,
		condition = 'true',
		action = 'Action.AirUnitReinforce("R/No 28 Squadron", "No 28 Squadron", 12)',
	},
	["Reinforce No 30 Squadron"] = {
		active = true,
		condition = 'true',
		action = 'Action.AirUnitReinforce("R/No 30 Squadron", "No 30 Squadron", 12)',
	},
	["Reinforce No 221 Squadron"] = {
		active = true,
		condition = 'true',
		action = 'Action.AirUnitReinforce("R/No 221 Squadron", "No 221 Squadron", 12)',
	},	

	----- AVIATION UNIT STATUS -----
	["No 11 Squadron Alive 75%"] = {
		active = true,
		once = true,
		condition = 'Return.AirUnitAlive("No 11 Squadron") + Return.AirUnitReady("R/No 11 Squadron") < 10',
		action = 'Action.Text("Aircraft strength of the No 11 Squadron has fallen below 75%.")',
	},
	["No 11 Squadron Alive 50%"] = {
		active = true,
		once = true,
		condition = 'Return.AirUnitAlive("No 11 Squadron") + Return.AirUnitReady("R/No 11 Squadron") < 7',
		action = 'Action.Text("Aircraft strength of the No 11 Squadron has fallen below 50%. If losses continue at the present rate, the combat capability of the squadron is in jeopardy.")',
	},
	["No 11 Squadron Alive 25%"] = {
		active = true,
		once = true,
		condition = 'Return.AirUnitAlive("No 11 Squadron") + Return.AirUnitReady("R/No 11 Squadron") < 5',
		action = 'Action.Text("Aircraft strength of the No 11 Squadron has fallen below 25%. The number of available airframes is critically low. The squadron is short of destruction.")',
	},
	
	---- GROUND TARGET STATUS ---
	["Blue Ground Target Briefing Intel"] = {
		active = true,
		condition = 'true',
		action = 'Action.AddGroundTargetIntel("blue")',
	},
	["Red Ground Target Briefing Intel"] = {
		active = true,
		condition = 'true',
		action = 'Action.AddGroundTargetIntel("red")',
	},
}
