Use the new lua UserInterface in the missions
This commit is contained in:
@@ -7,6 +7,8 @@ JeepPath = { ReinforcementsEntryPoint.Location, ReinforcementsRallyPoint.Locatio
|
|||||||
TruckReinforcements = { "truk", "truk", "truk" }
|
TruckReinforcements = { "truk", "truk", "truk" }
|
||||||
TruckPath = { TruckEntryPoint.Location, TruckRallyPoint.Location }
|
TruckPath = { TruckEntryPoint.Location, TruckRallyPoint.Location }
|
||||||
|
|
||||||
|
TimerTicks = DateTime.Minutes(10)
|
||||||
|
|
||||||
SendConstructionVehicleReinforcements = function()
|
SendConstructionVehicleReinforcements = function()
|
||||||
local mcv = Reinforcements.Reinforce(player, ConstructionVehicleReinforcements, ConstructionVehiclePath)[1]
|
local mcv = Reinforcements.Reinforce(player, ConstructionVehicleReinforcements, ConstructionVehiclePath)[1]
|
||||||
end
|
end
|
||||||
@@ -28,6 +30,7 @@ MissionFailed = function()
|
|||||||
Media.PlaySpeechNotification(player, "MissionFailed")
|
Media.PlaySpeechNotification(player, "MissionFailed")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
ticked = TimerTicks
|
||||||
Tick = function()
|
Tick = function()
|
||||||
ussr.Resources = ussr.Resources - (0.01 * ussr.ResourceCapacity / 25)
|
ussr.Resources = ussr.Resources - (0.01 * ussr.ResourceCapacity / 25)
|
||||||
|
|
||||||
@@ -39,6 +42,27 @@ Tick = function()
|
|||||||
if player.HasNoRequiredUnits() then
|
if player.HasNoRequiredUnits() then
|
||||||
player.MarkFailedObjective(ConquestObjective)
|
player.MarkFailedObjective(ConquestObjective)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if ticked > 0 then
|
||||||
|
UserInterface.SetMissionText("The convoy arrives in " .. Utils.FormatTime(ticked), TimerColor)
|
||||||
|
ticked = ticked - 1
|
||||||
|
elseif ticked == 0 then
|
||||||
|
FinishTimer()
|
||||||
|
SendTrucks()
|
||||||
|
ticked = ticked - 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
FinishTimer = function()
|
||||||
|
for i = 0, 5, 1 do
|
||||||
|
local c = TimerColor
|
||||||
|
if i % 2 == 0 then
|
||||||
|
c = HSLColor.White
|
||||||
|
end
|
||||||
|
|
||||||
|
Trigger.AfterDelay(DateTime.Seconds(i), function() UserInterface.SetMissionText("The convoy arrived!", c) end)
|
||||||
|
end
|
||||||
|
Trigger.AfterDelay(DateTime.Seconds(6), function() UserInterface.SetMissionText("") end)
|
||||||
end
|
end
|
||||||
|
|
||||||
ConvoyOnSite = false
|
ConvoyOnSite = false
|
||||||
@@ -113,9 +137,8 @@ WorldLoaded = function()
|
|||||||
Trigger.AfterDelay(DateTime.Seconds(5), SendJeepReinforcements)
|
Trigger.AfterDelay(DateTime.Seconds(5), SendJeepReinforcements)
|
||||||
Trigger.AfterDelay(DateTime.Seconds(10), SendJeepReinforcements)
|
Trigger.AfterDelay(DateTime.Seconds(10), SendJeepReinforcements)
|
||||||
|
|
||||||
Trigger.AfterDelay(DateTime.Minutes(10), SendTrucks)
|
|
||||||
|
|
||||||
Camera.Position = ReinforcementsEntryPoint.CenterPosition
|
Camera.Position = ReinforcementsEntryPoint.CenterPosition
|
||||||
|
TimerColor = player.Color
|
||||||
|
|
||||||
ConvoyTimer(DateTime.Seconds(3), "TenMinutesRemaining")
|
ConvoyTimer(DateTime.Seconds(3), "TenMinutesRemaining")
|
||||||
ConvoyTimer(DateTime.Minutes(5), "WarningFiveMinutesRemaining")
|
ConvoyTimer(DateTime.Minutes(5), "WarningFiveMinutesRemaining")
|
||||||
|
|||||||
@@ -197,6 +197,31 @@ SetupWorld = function()
|
|||||||
SubPen.IsPrimaryBuilding = true
|
SubPen.IsPrimaryBuilding = true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
SetupMissionText = function()
|
||||||
|
TextColorNormal = HSLColor.White
|
||||||
|
TextColorDamaged = HSLColor.Yellow
|
||||||
|
TextColorCritical = HSLColor.Red
|
||||||
|
|
||||||
|
CurrentColor = TextColorNormal
|
||||||
|
local villageHousesLeft = #Village
|
||||||
|
VillagePercentage = 100 - villageHousesLeft * 10
|
||||||
|
|
||||||
|
Utils.Do(Village, function(house)
|
||||||
|
Trigger.OnKilled(house, function()
|
||||||
|
villageHousesLeft = villageHousesLeft - 1
|
||||||
|
VillagePercentage = 100 - villageHousesLeft * 10
|
||||||
|
|
||||||
|
if VillagePercentage > 69 then
|
||||||
|
CurrentColor = TextColorCritical
|
||||||
|
elseif VillagePercentage > 49 then
|
||||||
|
CurrentColor = TextColorDamaged
|
||||||
|
else
|
||||||
|
CurrentColor = TextColorNormal
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
Tick = function()
|
Tick = function()
|
||||||
if DateTime.GameTime > 2 then
|
if DateTime.GameTime > 2 then
|
||||||
if soviets.Resources > soviets.ResourceCapacity * 0.75 then
|
if soviets.Resources > soviets.ResourceCapacity * 0.75 then
|
||||||
@@ -206,6 +231,8 @@ Tick = function()
|
|||||||
if player.HasNoRequiredUnits() then
|
if player.HasNoRequiredUnits() then
|
||||||
player.MarkFailedObjective(villageObjective)
|
player.MarkFailedObjective(villageObjective)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
UserInterface.SetMissionText(VillagePercentage .. "% of the village destroyed.", CurrentColor)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -286,6 +313,7 @@ WorldLoaded = function()
|
|||||||
Trigger.OnAllKilled(Village, function() player.MarkFailedObjective(villageObjective) end)
|
Trigger.OnAllKilled(Village, function() player.MarkFailedObjective(villageObjective) end)
|
||||||
|
|
||||||
SetupWorld()
|
SetupWorld()
|
||||||
|
SetupMissionText()
|
||||||
|
|
||||||
Trigger.AfterDelay(VillageRaidInterval, VillageRaid)
|
Trigger.AfterDelay(VillageRaidInterval, VillageRaid)
|
||||||
|
|
||||||
|
|||||||
@@ -144,6 +144,7 @@ SuperTankDomeInfiltrated = function()
|
|||||||
|
|
||||||
player.MarkCompletedObjective(InfiltrateRadarDome)
|
player.MarkCompletedObjective(InfiltrateRadarDome)
|
||||||
Trigger.AfterDelay(DateTime.Minutes(3), SuperTanksDestruction)
|
Trigger.AfterDelay(DateTime.Minutes(3), SuperTanksDestruction)
|
||||||
|
ticked = DateTime.Minutes(3)
|
||||||
|
|
||||||
Trigger.AfterDelay(DateTime.Seconds(2), function()
|
Trigger.AfterDelay(DateTime.Seconds(2), function()
|
||||||
Media.PlaySpeechNotification(player, "ControlCenterDeactivated")
|
Media.PlaySpeechNotification(player, "ControlCenterDeactivated")
|
||||||
@@ -210,6 +211,7 @@ CreateDemitri = function()
|
|||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
ticked = -1
|
||||||
Tick = function()
|
Tick = function()
|
||||||
ussr.Resources = ussr.Resources - (0.01 * ussr.ResourceCapacity / 25)
|
ussr.Resources = ussr.Resources - (0.01 * ussr.ResourceCapacity / 25)
|
||||||
|
|
||||||
@@ -220,11 +222,32 @@ Tick = function()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if ticked > 0 then
|
||||||
|
UserInterface.SetMissionText("The super tanks self-destruct in " .. Utils.FormatTime(ticked), TimerColor)
|
||||||
|
ticked = ticked - 1
|
||||||
|
elseif ticked == 0 then
|
||||||
|
FinishTimer()
|
||||||
|
ticked = ticked - 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
FinishTimer = function()
|
||||||
|
for i = 0, 9, 1 do
|
||||||
|
local c = TimerColor
|
||||||
|
if i % 2 == 0 then
|
||||||
|
c = HSLColor.White
|
||||||
|
end
|
||||||
|
|
||||||
|
Trigger.AfterDelay(DateTime.Seconds(i), function() UserInterface.SetMissionText("The super tanks are destroyed!", c) end)
|
||||||
|
end
|
||||||
|
Trigger.AfterDelay(DateTime.Seconds(10), function() UserInterface.SetMissionText("") end)
|
||||||
end
|
end
|
||||||
|
|
||||||
SetupMission = function()
|
SetupMission = function()
|
||||||
TestCamera = Actor.Create("camera" ,true , { Owner = player, Location = ProvingGroundsCameraPoint.Location })
|
TestCamera = Actor.Create("camera" ,true , { Owner = player, Location = ProvingGroundsCameraPoint.Location })
|
||||||
Camera.Position = ProvingGroundsCameraPoint.CenterPosition
|
Camera.Position = ProvingGroundsCameraPoint.CenterPosition
|
||||||
|
TimerColor = player.Color
|
||||||
|
|
||||||
Trigger.AfterDelay(DateTime.Seconds(12), function()
|
Trigger.AfterDelay(DateTime.Seconds(12), function()
|
||||||
Media.PlaySpeechNotification(player, "StartGame")
|
Media.PlaySpeechNotification(player, "StartGame")
|
||||||
|
|||||||
@@ -109,6 +109,7 @@ IdleTrigger = function(units, dest)
|
|||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
ticked = TimerTicks
|
||||||
Tick = function()
|
Tick = function()
|
||||||
if KillObj and soviets.HasNoRequiredUnits() then
|
if KillObj and soviets.HasNoRequiredUnits() then
|
||||||
allies.MarkCompletedObjective(KillObj)
|
allies.MarkCompletedObjective(KillObj)
|
||||||
@@ -122,16 +123,65 @@ Tick = function()
|
|||||||
soviets.Resources = soviets.ResourceCapacity / 2
|
soviets.Resources = soviets.ResourceCapacity / 2
|
||||||
end
|
end
|
||||||
|
|
||||||
if DateTime.Minutes(20) == TimerTicks - DateTime.GameTime then
|
if ticked > 0 then
|
||||||
Media.PlaySpeechNotification(allies, "TwentyMinutesRemaining")
|
if DateTime.Minutes(20) == ticked then
|
||||||
elseif DateTime.Minutes(10) == TimerTicks - DateTime.GameTime then
|
Media.PlaySpeechNotification(allies, "TwentyMinutesRemaining")
|
||||||
Media.PlaySpeechNotification(allies, "TenMinutesRemaining")
|
|
||||||
elseif DateTime.Minutes(5) == TimerTicks - DateTime.GameTime then
|
elseif DateTime.Minutes(10) == ticked then
|
||||||
Media.PlaySpeechNotification(allies, "WarningFiveMinutesRemaining")
|
Media.PlaySpeechNotification(allies, "TenMinutesRemaining")
|
||||||
InitTimer()
|
|
||||||
|
elseif DateTime.Minutes(5) == ticked then
|
||||||
|
Media.PlaySpeechNotification(allies, "WarningFiveMinutesRemaining")
|
||||||
|
|
||||||
|
elseif DateTime.Minutes(4) == ticked then
|
||||||
|
Media.PlaySpeechNotification(allies, "WarningFourMinutesRemaining")
|
||||||
|
|
||||||
|
Trigger.AfterDelay(ParadropTicks, function()
|
||||||
|
SendSovietParadrops(ParadropWaypoints[3])
|
||||||
|
SendSovietParadrops(ParadropWaypoints[2])
|
||||||
|
end)
|
||||||
|
Trigger.AfterDelay(ParadropTicks * 2, function()
|
||||||
|
SendSovietParadrops(ParadropWaypoints[4])
|
||||||
|
SendSovietParadrops(ParadropWaypoints[1])
|
||||||
|
end)
|
||||||
|
|
||||||
|
elseif DateTime.Minutes(3) == ticked then
|
||||||
|
Media.PlaySpeechNotification(allies, "WarningThreeMinutesRemaining")
|
||||||
|
|
||||||
|
elseif DateTime.Minutes(2) == ticked then
|
||||||
|
Media.PlaySpeechNotification(allies, "WarningTwoMinutesRemaining")
|
||||||
|
|
||||||
|
AttackAtFrameIncrement = DateTime.Seconds(4)
|
||||||
|
AttackAtFrameIncrementInf = DateTime.Seconds(4)
|
||||||
|
|
||||||
|
elseif DateTime.Minutes(1) == ticked then
|
||||||
|
Media.PlaySpeechNotification(allies, "WarningOneMinuteRemaining")
|
||||||
|
|
||||||
|
elseif DateTime.Seconds(45) == ticked then
|
||||||
|
Media.PlaySpeechNotification(allies, "AlliedForcesApproaching")
|
||||||
|
end
|
||||||
|
|
||||||
|
UserInterface.SetMissionText("French reinforcements arrive in " .. Utils.FormatTime(ticked), TimerColor)
|
||||||
|
ticked = ticked - 1
|
||||||
|
elseif ticked == 0 then
|
||||||
|
FinishTimer()
|
||||||
|
TimerExpired()
|
||||||
|
ticked = ticked - 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
FinishTimer = function()
|
||||||
|
for i = 0, 9, 1 do
|
||||||
|
local c = TimerColor
|
||||||
|
if i % 2 == 0 then
|
||||||
|
c = HSLColor.White
|
||||||
|
end
|
||||||
|
|
||||||
|
Trigger.AfterDelay(DateTime.Seconds(i), function() UserInterface.SetMissionText("Our french allies have arrived!", c) end)
|
||||||
|
end
|
||||||
|
Trigger.AfterDelay(DateTime.Seconds(10), function() UserInterface.SetMissionText("") end)
|
||||||
|
end
|
||||||
|
|
||||||
SendSovietParadrops = function(table)
|
SendSovietParadrops = function(table)
|
||||||
local units = powerproxy.SendParatroopers(table[2].CenterPosition, false, table[1])
|
local units = powerproxy.SendParatroopers(table[2].CenterPosition, false, table[1])
|
||||||
|
|
||||||
@@ -208,33 +258,6 @@ SendVehicleWave = function()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
InitTimer = function()
|
|
||||||
Trigger.AfterDelay(DateTime.Minutes(1), function()
|
|
||||||
Media.PlaySpeechNotification(allies, "WarningFourMinutesRemaining")
|
|
||||||
|
|
||||||
Trigger.AfterDelay(ParadropTicks, function()
|
|
||||||
SendSovietParadrops(ParadropWaypoints[3])
|
|
||||||
SendSovietParadrops(ParadropWaypoints[2])
|
|
||||||
end)
|
|
||||||
Trigger.AfterDelay(ParadropTicks * 2, function()
|
|
||||||
SendSovietParadrops(ParadropWaypoints[4])
|
|
||||||
SendSovietParadrops(ParadropWaypoints[1])
|
|
||||||
end)
|
|
||||||
end)
|
|
||||||
|
|
||||||
Trigger.AfterDelay(DateTime.Minutes(2), function() Media.PlaySpeechNotification(allies, "WarningThreeMinutesRemaining") end)
|
|
||||||
Trigger.AfterDelay(DateTime.Minutes(3), function()
|
|
||||||
Media.PlaySpeechNotification(allies, "WarningTwoMinutesRemaining")
|
|
||||||
|
|
||||||
AttackAtFrameIncrement = DateTime.Seconds(4)
|
|
||||||
AttackAtFrameIncrementInf = DateTime.Seconds(4)
|
|
||||||
end)
|
|
||||||
|
|
||||||
Trigger.AfterDelay(DateTime.Minutes(4), function() Media.PlaySpeechNotification(allies, "WarningOneMinuteRemaining") end)
|
|
||||||
Trigger.AfterDelay(DateTime.Minutes(4) + DateTime.Seconds(45), function() Media.PlaySpeechNotification(allies, "AlliedForcesApproaching") end)
|
|
||||||
Trigger.AfterDelay(DateTime.Minutes(5), TimerExpired)
|
|
||||||
end
|
|
||||||
|
|
||||||
TimerExpired = function()
|
TimerExpired = function()
|
||||||
SpawningSovietUnits = false
|
SpawningSovietUnits = false
|
||||||
SpawningInfantry = false
|
SpawningInfantry = false
|
||||||
@@ -345,6 +368,7 @@ InitMission = function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
Trigger.AfterDelay(DateTime.Seconds(1), function() Media.PlaySpeechNotification(allies, "MissionTimerInitialised") end)
|
Trigger.AfterDelay(DateTime.Seconds(1), function() Media.PlaySpeechNotification(allies, "MissionTimerInitialised") end)
|
||||||
|
TimerColor = allies.Color
|
||||||
end
|
end
|
||||||
|
|
||||||
SetupSoviets = function()
|
SetupSoviets = function()
|
||||||
|
|||||||
@@ -104,10 +104,10 @@ Tick = function()
|
|||||||
InitCountDown()
|
InitCountDown()
|
||||||
end
|
end
|
||||||
|
|
||||||
if 0 < ticked then
|
if ticked > 0 then
|
||||||
UserInterface.SetMissionText("Soviet reinforcements arrive in " .. Utils.FormatTime(ticked), TimerColor)
|
UserInterface.SetMissionText("Soviet reinforcements arrive in " .. Utils.FormatTime(ticked), TimerColor)
|
||||||
ticked = ticked - 1
|
ticked = ticked - 1
|
||||||
elseif 0 == ticked then
|
elseif ticked == 0 then
|
||||||
FinishTimer()
|
FinishTimer()
|
||||||
ticked = ticked - 1
|
ticked = ticked - 1
|
||||||
end
|
end
|
||||||
@@ -208,7 +208,7 @@ FinishTimer = function()
|
|||||||
for i = 0, 9, 1 do
|
for i = 0, 9, 1 do
|
||||||
local c = TimerColor
|
local c = TimerColor
|
||||||
if i % 2 == 0 then
|
if i % 2 == 0 then
|
||||||
c = HSLColor.New(255, 255, 255)
|
c = HSLColor.White
|
||||||
end
|
end
|
||||||
|
|
||||||
Trigger.AfterDelay(DateTime.Seconds(i), function() UserInterface.SetMissionText("Soviet reinforcements have arrived!", c) end)
|
Trigger.AfterDelay(DateTime.Seconds(i), function() UserInterface.SetMissionText("Soviet reinforcements have arrived!", c) end)
|
||||||
@@ -298,7 +298,7 @@ end
|
|||||||
|
|
||||||
InitMission = function()
|
InitMission = function()
|
||||||
Camera.Position = AlliesBase.CenterPosition
|
Camera.Position = AlliesBase.CenterPosition
|
||||||
TimerColor = HSLColor.New(0, 255, 128)
|
TimerColor = HSLColor.Red
|
||||||
|
|
||||||
Trigger.AfterDelay(DateTime.Seconds(1), function() Media.PlaySpeechNotification(allies, "MissionTimerInitialised") end)
|
Trigger.AfterDelay(DateTime.Seconds(1), function() Media.PlaySpeechNotification(allies, "MissionTimerInitialised") end)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user