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" }
|
||||
TruckPath = { TruckEntryPoint.Location, TruckRallyPoint.Location }
|
||||
|
||||
TimerTicks = DateTime.Minutes(10)
|
||||
|
||||
SendConstructionVehicleReinforcements = function()
|
||||
local mcv = Reinforcements.Reinforce(player, ConstructionVehicleReinforcements, ConstructionVehiclePath)[1]
|
||||
end
|
||||
@@ -28,6 +30,7 @@ MissionFailed = function()
|
||||
Media.PlaySpeechNotification(player, "MissionFailed")
|
||||
end
|
||||
|
||||
ticked = TimerTicks
|
||||
Tick = function()
|
||||
ussr.Resources = ussr.Resources - (0.01 * ussr.ResourceCapacity / 25)
|
||||
|
||||
@@ -39,6 +42,27 @@ Tick = function()
|
||||
if player.HasNoRequiredUnits() then
|
||||
player.MarkFailedObjective(ConquestObjective)
|
||||
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
|
||||
|
||||
ConvoyOnSite = false
|
||||
@@ -113,9 +137,8 @@ WorldLoaded = function()
|
||||
Trigger.AfterDelay(DateTime.Seconds(5), SendJeepReinforcements)
|
||||
Trigger.AfterDelay(DateTime.Seconds(10), SendJeepReinforcements)
|
||||
|
||||
Trigger.AfterDelay(DateTime.Minutes(10), SendTrucks)
|
||||
|
||||
Camera.Position = ReinforcementsEntryPoint.CenterPosition
|
||||
TimerColor = player.Color
|
||||
|
||||
ConvoyTimer(DateTime.Seconds(3), "TenMinutesRemaining")
|
||||
ConvoyTimer(DateTime.Minutes(5), "WarningFiveMinutesRemaining")
|
||||
|
||||
@@ -197,6 +197,31 @@ SetupWorld = function()
|
||||
SubPen.IsPrimaryBuilding = true
|
||||
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()
|
||||
if DateTime.GameTime > 2 then
|
||||
if soviets.Resources > soviets.ResourceCapacity * 0.75 then
|
||||
@@ -206,6 +231,8 @@ Tick = function()
|
||||
if player.HasNoRequiredUnits() then
|
||||
player.MarkFailedObjective(villageObjective)
|
||||
end
|
||||
|
||||
UserInterface.SetMissionText(VillagePercentage .. "% of the village destroyed.", CurrentColor)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -286,6 +313,7 @@ WorldLoaded = function()
|
||||
Trigger.OnAllKilled(Village, function() player.MarkFailedObjective(villageObjective) end)
|
||||
|
||||
SetupWorld()
|
||||
SetupMissionText()
|
||||
|
||||
Trigger.AfterDelay(VillageRaidInterval, VillageRaid)
|
||||
|
||||
|
||||
@@ -144,6 +144,7 @@ SuperTankDomeInfiltrated = function()
|
||||
|
||||
player.MarkCompletedObjective(InfiltrateRadarDome)
|
||||
Trigger.AfterDelay(DateTime.Minutes(3), SuperTanksDestruction)
|
||||
ticked = DateTime.Minutes(3)
|
||||
|
||||
Trigger.AfterDelay(DateTime.Seconds(2), function()
|
||||
Media.PlaySpeechNotification(player, "ControlCenterDeactivated")
|
||||
@@ -210,6 +211,7 @@ CreateDemitri = function()
|
||||
end)
|
||||
end
|
||||
|
||||
ticked = -1
|
||||
Tick = function()
|
||||
ussr.Resources = ussr.Resources - (0.01 * ussr.ResourceCapacity / 25)
|
||||
|
||||
@@ -220,11 +222,32 @@ Tick = function()
|
||||
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
|
||||
|
||||
SetupMission = function()
|
||||
TestCamera = Actor.Create("camera" ,true , { Owner = player, Location = ProvingGroundsCameraPoint.Location })
|
||||
Camera.Position = ProvingGroundsCameraPoint.CenterPosition
|
||||
TimerColor = player.Color
|
||||
|
||||
Trigger.AfterDelay(DateTime.Seconds(12), function()
|
||||
Media.PlaySpeechNotification(player, "StartGame")
|
||||
|
||||
@@ -109,6 +109,7 @@ IdleTrigger = function(units, dest)
|
||||
end)
|
||||
end
|
||||
|
||||
ticked = TimerTicks
|
||||
Tick = function()
|
||||
if KillObj and soviets.HasNoRequiredUnits() then
|
||||
allies.MarkCompletedObjective(KillObj)
|
||||
@@ -122,16 +123,65 @@ Tick = function()
|
||||
soviets.Resources = soviets.ResourceCapacity / 2
|
||||
end
|
||||
|
||||
if DateTime.Minutes(20) == TimerTicks - DateTime.GameTime then
|
||||
Media.PlaySpeechNotification(allies, "TwentyMinutesRemaining")
|
||||
elseif DateTime.Minutes(10) == TimerTicks - DateTime.GameTime then
|
||||
Media.PlaySpeechNotification(allies, "TenMinutesRemaining")
|
||||
elseif DateTime.Minutes(5) == TimerTicks - DateTime.GameTime then
|
||||
Media.PlaySpeechNotification(allies, "WarningFiveMinutesRemaining")
|
||||
InitTimer()
|
||||
if ticked > 0 then
|
||||
if DateTime.Minutes(20) == ticked then
|
||||
Media.PlaySpeechNotification(allies, "TwentyMinutesRemaining")
|
||||
|
||||
elseif DateTime.Minutes(10) == ticked then
|
||||
Media.PlaySpeechNotification(allies, "TenMinutesRemaining")
|
||||
|
||||
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
|
||||
|
||||
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)
|
||||
local units = powerproxy.SendParatroopers(table[2].CenterPosition, false, table[1])
|
||||
|
||||
@@ -208,33 +258,6 @@ SendVehicleWave = function()
|
||||
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()
|
||||
SpawningSovietUnits = false
|
||||
SpawningInfantry = false
|
||||
@@ -345,6 +368,7 @@ InitMission = function()
|
||||
end)
|
||||
|
||||
Trigger.AfterDelay(DateTime.Seconds(1), function() Media.PlaySpeechNotification(allies, "MissionTimerInitialised") end)
|
||||
TimerColor = allies.Color
|
||||
end
|
||||
|
||||
SetupSoviets = function()
|
||||
|
||||
@@ -104,10 +104,10 @@ Tick = function()
|
||||
InitCountDown()
|
||||
end
|
||||
|
||||
if 0 < ticked then
|
||||
if ticked > 0 then
|
||||
UserInterface.SetMissionText("Soviet reinforcements arrive in " .. Utils.FormatTime(ticked), TimerColor)
|
||||
ticked = ticked - 1
|
||||
elseif 0 == ticked then
|
||||
elseif ticked == 0 then
|
||||
FinishTimer()
|
||||
ticked = ticked - 1
|
||||
end
|
||||
@@ -208,7 +208,7 @@ FinishTimer = function()
|
||||
for i = 0, 9, 1 do
|
||||
local c = TimerColor
|
||||
if i % 2 == 0 then
|
||||
c = HSLColor.New(255, 255, 255)
|
||||
c = HSLColor.White
|
||||
end
|
||||
|
||||
Trigger.AfterDelay(DateTime.Seconds(i), function() UserInterface.SetMissionText("Soviet reinforcements have arrived!", c) end)
|
||||
@@ -298,7 +298,7 @@ end
|
||||
|
||||
InitMission = function()
|
||||
Camera.Position = AlliesBase.CenterPosition
|
||||
TimerColor = HSLColor.New(0, 255, 128)
|
||||
TimerColor = HSLColor.Red
|
||||
|
||||
Trigger.AfterDelay(DateTime.Seconds(1), function() Media.PlaySpeechNotification(allies, "MissionTimerInitialised") end)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user