Resolve Lua language server diagnosed problems.
This commit is contained in:
committed by
abcdefg30
parent
3d0efa1cbe
commit
378f66a1ff
@@ -73,17 +73,17 @@ ReinforcementsUnits = { "2tnk", "2tnk", "2tnk", "2tnk", "2tnk", "2tnk", "1tnk",
|
||||
"e1", "e1", "e1", "e3", "e3", "mcv", "truk", "truk", "truk", "truk", "truk", "truk" }
|
||||
|
||||
SpawnAlliedReinforcements = function()
|
||||
if allies2.IsLocalPlayer then
|
||||
if Allies2.IsLocalPlayer then
|
||||
UserInterface.SetMissionText("")
|
||||
Media.PlaySpeechNotification(allies2, "AlliedReinforcementsArrived")
|
||||
Media.PlaySpeechNotification(Allies2, "AlliedReinforcementsArrived")
|
||||
end
|
||||
Reinforcements.Reinforce(allies2, ReinforcementsUnits, { ReinforcementsEntryPoint.Location, Allies2BasePoint.Location })
|
||||
Reinforcements.Reinforce(Allies2, ReinforcementsUnits, { ReinforcementsEntryPoint.Location, Allies2BasePoint.Location })
|
||||
end
|
||||
|
||||
Yak = nil
|
||||
YakAttack = function()
|
||||
local targets = Map.ActorsInCircle(YakAttackPoint.CenterPosition, WDist.FromCells(10), function(a)
|
||||
return a.Owner == allies1 and not a.IsDead and a ~= Einstein and a ~= Tanya and a ~= Engineer and Yak.CanTarget(a)
|
||||
return a.Owner == Allies1 and not a.IsDead and a ~= Einstein and a ~= Tanya and a ~= Engineer and Yak.CanTarget(a)
|
||||
end)
|
||||
|
||||
if (#targets > 0) then
|
||||
@@ -106,7 +106,7 @@ SovietTownAttack = function()
|
||||
end
|
||||
|
||||
SendParabombs = function()
|
||||
local proxy = Actor.Create("powerproxy.parabombs", false, { Owner = soviets })
|
||||
local proxy = Actor.Create("powerproxy.parabombs", false, { Owner = Soviets })
|
||||
proxy.TargetAirstrike(ParabombPoint1.CenterPosition, (BadgerEntryPoint2.CenterPosition - ParabombPoint1.CenterPosition).Facing)
|
||||
proxy.TargetAirstrike(ParabombPoint2.CenterPosition, (Map.CenterOfCell(BadgerEntryPoint2.Location + CVec.New(0, 3)) - ParabombPoint2.CenterPosition).Facing)
|
||||
proxy.Destroy()
|
||||
@@ -114,7 +114,7 @@ end
|
||||
|
||||
SendParatroopers = function()
|
||||
Utils.Do(Paratroopers, function(para)
|
||||
local proxy = Actor.Create(para.proxy, false, { Owner = soviets })
|
||||
local proxy = Actor.Create(para.proxy, false, { Owner = Soviets })
|
||||
local target = Map.CenterOfCell(para.drop)
|
||||
local dir = target - Map.CenterOfCell(para.entry)
|
||||
|
||||
@@ -143,11 +143,11 @@ SendAttackGroup = function()
|
||||
end
|
||||
|
||||
ProduceInfantry = function()
|
||||
if SovietBarracks.IsDead or SovietBarracks.Owner ~= soviets then
|
||||
if SovietBarracks.IsDead or SovietBarracks.Owner ~= Soviets then
|
||||
return
|
||||
end
|
||||
|
||||
soviets.Build({ Utils.Random(SovietInfantry) }, function(units)
|
||||
Soviets.Build({ Utils.Random(SovietInfantry) }, function(units)
|
||||
table.insert(AttackGroup, units[1])
|
||||
SendAttackGroup()
|
||||
Trigger.AfterDelay(ProductionInterval[Difficulty], ProduceInfantry)
|
||||
@@ -155,11 +155,11 @@ ProduceInfantry = function()
|
||||
end
|
||||
|
||||
ProduceVehicles = function()
|
||||
if SovietWarFactory.IsDead or SovietWarFactory.Owner ~= soviets then
|
||||
if SovietWarFactory.IsDead or SovietWarFactory.Owner ~= Soviets then
|
||||
return
|
||||
end
|
||||
|
||||
soviets.Build({ Utils.Random(SovietVehicles[SovietVehicleType]) }, function(units)
|
||||
Soviets.Build({ Utils.Random(SovietVehicles[SovietVehicleType]) }, function(units)
|
||||
table.insert(AttackGroup, units[1])
|
||||
SendAttackGroup()
|
||||
Trigger.AfterDelay(ProductionInterval[Difficulty], ProduceVehicles)
|
||||
@@ -168,7 +168,7 @@ end
|
||||
|
||||
NumBaseBuildings = function()
|
||||
local buildings = Map.ActorsInBox(AlliedBaseTopLeft.CenterPosition, AlliedBaseBottomRight.CenterPosition, function(a)
|
||||
return not a.IsDead and a.Owner == allies2 and a.HasProperty("StartBuildingRepairs")
|
||||
return not a.IsDead and a.Owner == Allies2 and a.HasProperty("StartBuildingRepairs")
|
||||
end)
|
||||
|
||||
return #buildings
|
||||
@@ -176,18 +176,18 @@ end
|
||||
|
||||
Tick = function()
|
||||
if DateTime.GameTime > 1 and DateTime.GameTime % 25 == 0 and NumBaseBuildings() == 0 then
|
||||
allies2.MarkFailedObjective(objHoldPosition)
|
||||
Allies2.MarkFailedObjective(HoldPositionObjective)
|
||||
end
|
||||
|
||||
if not allies2.IsObjectiveCompleted(objCutSovietPower) and soviets.PowerState ~= "Normal" then
|
||||
allies2.MarkCompletedObjective(objCutSovietPower)
|
||||
if not Allies2.IsObjectiveCompleted(CutSovietPowerObjective) and Soviets.PowerState ~= "Normal" then
|
||||
Allies2.MarkCompletedObjective(CutSovietPowerObjective)
|
||||
end
|
||||
|
||||
if not allies2.IsObjectiveCompleted(objLimitLosses) and allies2.UnitsLost > DeathThreshold[Difficulty] then
|
||||
allies2.MarkFailedObjective(objLimitLosses)
|
||||
if not Allies2.IsObjectiveCompleted(LimitLossesObjective) and Allies2.UnitsLost > DeathThreshold[Difficulty] then
|
||||
Allies2.MarkFailedObjective(LimitLossesObjective)
|
||||
end
|
||||
|
||||
if allies2.IsLocalPlayer and DateTime.GameTime <= ReinforcementsDelay then
|
||||
if Allies2.IsLocalPlayer and DateTime.GameTime <= ReinforcementsDelay then
|
||||
if DateTime.GameTime % DateTime.Seconds(1) == 0 then
|
||||
local time = Utils.FormatTime(ReinforcementsDelay - DateTime.GameTime)
|
||||
local timer = UserInterface.Translate("allied-reinforcements-arrive-in", { ["time"] = time })
|
||||
@@ -199,21 +199,21 @@ Tick = function()
|
||||
end
|
||||
|
||||
SetupSoviets = function()
|
||||
soviets.Cash = 1000
|
||||
Soviets.Cash = 1000
|
||||
|
||||
if Difficulty == "easy" then
|
||||
Utils.Do(Sams, function(sam)
|
||||
local camera = Actor.Create("Camera.SAM", true, { Owner = allies1, Location = sam.Location })
|
||||
local camera = Actor.Create("Camera.SAM", true, { Owner = Allies1, Location = sam.Location })
|
||||
Trigger.OnKilledOrCaptured(sam, function()
|
||||
camera.Destroy()
|
||||
end)
|
||||
end)
|
||||
end
|
||||
|
||||
local buildings = Utils.Where(Map.ActorsInWorld, function(self) return self.Owner == soviets and self.HasProperty("StartBuildingRepairs") end)
|
||||
local buildings = Utils.Where(Map.ActorsInWorld, function(self) return self.Owner == Soviets and self.HasProperty("StartBuildingRepairs") end)
|
||||
Utils.Do(buildings, function(actor)
|
||||
Trigger.OnDamaged(actor, function(building)
|
||||
if building.Owner == soviets and building.Health < (building.MaxHealth * RepairTriggerThreshold[Difficulty] / 100) then
|
||||
if building.Owner == Soviets and building.Health < (building.MaxHealth * RepairTriggerThreshold[Difficulty] / 100) then
|
||||
building.StartBuildingRepairs()
|
||||
end
|
||||
end)
|
||||
@@ -233,43 +233,43 @@ end
|
||||
|
||||
SetupTriggers = function()
|
||||
Trigger.OnKilled(Tanya, function()
|
||||
allies1.MarkFailedObjective(objTanyaMustSurvive)
|
||||
Allies1.MarkFailedObjective(TanyaMustSurviveObjective)
|
||||
end)
|
||||
|
||||
Trigger.OnAllKilledOrCaptured(Sams, function()
|
||||
allies1.MarkCompletedObjective(objDestroySamSites)
|
||||
objExtractEinstein = AddPrimaryObjective(allies1, "wait-for-helicopter-extract-einstein")
|
||||
Actor.Create("flare", true, { Owner = allies1, Location = ExtractionLZ.Location + CVec.New(1, -1) })
|
||||
Beacon.New(allies1, ExtractionLZ.CenterPosition)
|
||||
Media.PlaySpeechNotification(allies1, "SignalFlareNorth")
|
||||
Allies1.MarkCompletedObjective(DestroySamSitesObjective)
|
||||
ExtractEinsteinObjective = AddPrimaryObjective(Allies1, "wait-for-helicopter-extract-einstein")
|
||||
Actor.Create("flare", true, { Owner = Allies1, Location = ExtractionLZ.Location + CVec.New(1, -1) })
|
||||
Beacon.New(Allies1, ExtractionLZ.CenterPosition)
|
||||
Media.PlaySpeechNotification(Allies1, "SignalFlareNorth")
|
||||
|
||||
ExtractionHeli = Reinforcements.ReinforceWithTransport(allies1, "tran", nil, { ExtractionLZEntryPoint.Location, ExtractionLZ.Location })[1]
|
||||
ExtractionHeli = Reinforcements.ReinforceWithTransport(Allies1, "tran", nil, { ExtractionLZEntryPoint.Location, ExtractionLZ.Location })[1]
|
||||
Trigger.OnKilled(ExtractionHeli, function()
|
||||
allies1.MarkFailedObjective(objExtractEinstein)
|
||||
Allies1.MarkFailedObjective(ExtractEinsteinObjective)
|
||||
end)
|
||||
Trigger.OnPassengerEntered(ExtractionHeli, function(heli, passenger)
|
||||
if passenger == Einstein then
|
||||
heli.Move(ExtractionLZEntryPoint.Location)
|
||||
heli.Destroy()
|
||||
Trigger.OnRemovedFromWorld(heli, function()
|
||||
allies2.MarkCompletedObjective(objLimitLosses)
|
||||
allies2.MarkCompletedObjective(objHoldPosition)
|
||||
allies1.MarkCompletedObjective(objTanyaMustSurvive)
|
||||
allies1.MarkCompletedObjective(objEinsteinSurvival)
|
||||
allies1.MarkCompletedObjective(objExtractEinstein)
|
||||
Allies2.MarkCompletedObjective(LimitLossesObjective)
|
||||
Allies2.MarkCompletedObjective(HoldPositionObjective)
|
||||
Allies1.MarkCompletedObjective(TanyaMustSurviveObjective)
|
||||
Allies1.MarkCompletedObjective(EinsteinSurvivalObjective)
|
||||
Allies1.MarkCompletedObjective(ExtractEinsteinObjective)
|
||||
end)
|
||||
end
|
||||
end)
|
||||
end)
|
||||
|
||||
Trigger.OnEnteredProximityTrigger(TownPoint.CenterPosition, WDist.FromCells(15), function(actor, trigger)
|
||||
if actor.Owner == allies1 then
|
||||
ReassignActors(TownUnits, neutral, allies1)
|
||||
if actor.Owner == Allies1 then
|
||||
ReassignActors(TownUnits, Neutral, Allies1)
|
||||
Utils.Do(TownUnits, function(a) a.Stance = "Defend" end)
|
||||
allies1.MarkCompletedObjective(objFindEinstein)
|
||||
objEinsteinSurvival = AddPrimaryObjective(allies1, "keep-einstein-alive-at-all-costs")
|
||||
Allies1.MarkCompletedObjective(FindEinsteinObjective)
|
||||
EinsteinSurvivalObjective = AddPrimaryObjective(Allies1, "keep-einstein-alive-at-all-costs")
|
||||
Trigger.OnKilled(Einstein, function()
|
||||
allies1.MarkFailedObjective(objEinsteinSurvival)
|
||||
Allies1.MarkFailedObjective(EinsteinSurvivalObjective)
|
||||
end)
|
||||
Trigger.RemoveProximityTrigger(trigger)
|
||||
SovietTownAttack()
|
||||
@@ -277,11 +277,11 @@ SetupTriggers = function()
|
||||
end)
|
||||
|
||||
Trigger.OnEnteredProximityTrigger(YakAttackPoint.CenterPosition, WDist.FromCells(5), function(actor, trigger)
|
||||
if not (Yak == nil or Yak.IsDead) or actor.Owner ~= allies1 then
|
||||
if not (Yak == nil or Yak.IsDead) or actor.Owner ~= Allies1 then
|
||||
return
|
||||
end
|
||||
|
||||
Yak = Actor.Create("yak", true, { Owner = soviets, Location = YakEntryPoint.Location, CenterPosition = YakEntryPoint.CenterPosition + WVec.New(0, 0, Actor.CruiseAltitude("yak")) })
|
||||
Yak = Actor.Create("yak", true, { Owner = Soviets, Location = YakEntryPoint.Location, CenterPosition = YakEntryPoint.CenterPosition + WVec.New(0, 0, Actor.CruiseAltitude("yak")) })
|
||||
Yak.Move(YakAttackPoint.Location + CVec.New(0, -10))
|
||||
Yak.CallFunc(YakAttack)
|
||||
end)
|
||||
@@ -292,9 +292,9 @@ SetupTriggers = function()
|
||||
end
|
||||
|
||||
SpawnTanya = function()
|
||||
Tanya = Actor.Create(TanyaType, true, { Owner = allies1, Location = TanyaLocation.Location })
|
||||
Tanya = Actor.Create(TanyaType, true, { Owner = Allies1, Location = TanyaLocation.Location })
|
||||
|
||||
if Difficulty ~= "easy" and allies1.IsLocalPlayer then
|
||||
if Difficulty ~= "easy" and Allies1.IsLocalPlayer then
|
||||
Trigger.AfterDelay(DateTime.Seconds(2), function()
|
||||
Media.DisplayMessage(UserInterface.Translate("tanya-rules-of-engagement"), UserInterface.Translate("tanya"))
|
||||
end)
|
||||
@@ -311,46 +311,46 @@ ReassignActors = function(actors, from, to)
|
||||
end
|
||||
|
||||
WorldLoaded = function()
|
||||
neutral = Player.GetPlayer("Neutral")
|
||||
Neutral = Player.GetPlayer("Neutral")
|
||||
|
||||
-- Allies is the pre-set owner of units that get assigned to either the second player, if any, or the first player otherwise.
|
||||
allies = Player.GetPlayer("Allies")
|
||||
Allies = Player.GetPlayer("Allies")
|
||||
|
||||
-- Allies1 is the player starting on the right, controlling Tanya
|
||||
allies1 = Player.GetPlayer("Allies1")
|
||||
Allies1 = Player.GetPlayer("Allies1")
|
||||
|
||||
-- Allies2 is the player starting on the left, defending the base
|
||||
allies2 = Player.GetPlayer("Allies2")
|
||||
Allies2 = Player.GetPlayer("Allies2")
|
||||
|
||||
soviets = Player.GetPlayer("Soviets")
|
||||
Soviets = Player.GetPlayer("Soviets")
|
||||
|
||||
Utils.Do({ allies1, allies2 }, function(player)
|
||||
Utils.Do({ Allies1, Allies2 }, function(player)
|
||||
if player and player.IsLocalPlayer then
|
||||
InitObjectives(player)
|
||||
end
|
||||
end)
|
||||
|
||||
if not allies2 or allies2.IsLocalPlayer then
|
||||
if not Allies2 or Allies2.IsLocalPlayer then
|
||||
Camera.Position = Allies2BasePoint.CenterPosition
|
||||
else
|
||||
Camera.Position = ChinookHusk.CenterPosition
|
||||
end
|
||||
|
||||
if not allies2 then
|
||||
allies2 = allies1
|
||||
if not Allies2 then
|
||||
Allies2 = Allies1
|
||||
end
|
||||
|
||||
ReassignActors(Map.ActorsInWorld, allies, allies2)
|
||||
ReassignActors(Map.ActorsInWorld, Allies, Allies2)
|
||||
SpawnTanya()
|
||||
|
||||
objTanyaMustSurvive = AddPrimaryObjective(allies1, "tanya-survive")
|
||||
objFindEinstein = AddPrimaryObjective(allies1, "find-einstein-crashed-helicopter")
|
||||
objDestroySamSites = AddPrimaryObjective(allies1, "destroy-sam-sites")
|
||||
TanyaMustSurviveObjective = AddPrimaryObjective(Allies1, "tanya-survive")
|
||||
FindEinsteinObjective = AddPrimaryObjective(Allies1, "find-einstein-crashed-helicopter")
|
||||
DestroySamSitesObjective = AddPrimaryObjective(Allies1, "destroy-sam-sites")
|
||||
|
||||
objHoldPosition = AddPrimaryObjective(allies2, "hold-position-protect-base")
|
||||
HoldPositionObjective = AddPrimaryObjective(Allies2, "hold-position-protect-base")
|
||||
local dontLoseMoreThan = UserInterface.Translate("keep-civilians-alive", { ["units"] = DeathThreshold[Difficulty] })
|
||||
objLimitLosses = AddSecondaryObjective(allies2, dontLoseMoreThan)
|
||||
objCutSovietPower = AddSecondaryObjective(allies2, "take-out-the-soviet-power-grid")
|
||||
LimitLossesObjective = AddSecondaryObjective(Allies2, dontLoseMoreThan)
|
||||
CutSovietPowerObjective = AddSecondaryObjective(Allies2, "take-out-the-soviet-power-grid")
|
||||
|
||||
SetupTriggers()
|
||||
SetupSoviets()
|
||||
|
||||
Reference in New Issue
Block a user