Skip to content

Commit

Permalink
Adjust difficulty, add speeches to allies-06a
Browse files Browse the repository at this point in the history
  • Loading branch information
JovialFeline committed Apr 11, 2024
1 parent 150e28a commit f955be1
Show file tree
Hide file tree
Showing 5 changed files with 360 additions and 72 deletions.
107 changes: 56 additions & 51 deletions mods/ra/maps/allies-06a/allies06a-AI.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
information, see COPYING.
]]

SovietsActivated = false
SubPenStarted = false

WTransWays =
{
{ WaterUnloadEntry1.Location, WaterUnload1.Location },
Expand All @@ -20,23 +23,23 @@ WTransUnits =
}
WTransDelays =
{
easy = 4,
normal = 3,
hard = 1
easy = DateTime.Seconds(240),
normal = DateTime.Seconds(180),
hard = DateTime.Seconds(140)
}

BuildDelays =
{
easy = 90,
normal = 60,
hard = 30
easy = DateTime.Seconds(90),
normal = DateTime.Seconds(60),
hard = DateTime.Seconds(30)
}

WaterAttacks =
FirstAirDelays =
{
easy = 1,
normal = 2,
hard = 3
easy = DateTime.Seconds(180),
normal = DateTime.Seconds(120),
hard = DateTime.Seconds(90)
}

WaterAttackTypes =
Expand All @@ -52,6 +55,7 @@ InfTypes =
{
{ "e1", "e1", "e1"},
{ "e2", "e1", "e1"},
{ "e2", "e2", "e1"},
{ "e4", "e4", "e1"}
}

Expand All @@ -62,14 +66,12 @@ AttackRallyPoints =
{ SovietOreAttack2.Location }
}

ImportantBuildings = { WeaponsFactory, Airfield, dome2, SovietConyard }
ImportantBuildings = { WeaponsFactory, Airfield, EastRadarDome, SovietConyard }
SovietAircraftType = { "yak" }
Yaks = { }
IdlingUnits = { }
IdlingTanks = { tank1, tank2, tank3, tank4, tank5, tank6, tank7, tank8 }
IdlingNavalUnits = { }

InitialiseAttack = function()
PrepareTankDefenders = function()
Utils.Do(ImportantBuildings, function(a)
Trigger.OnDamaged(a, function()
Utils.Do(IdlingTanks, function(unit)
Expand All @@ -81,23 +83,23 @@ InitialiseAttack = function()
end)
end

Attack = 0
InfantryWave = 0
ProduceInfantry = function()
if SovietBarracks.IsDead or SovietBarracks.Owner ~= USSR then
return
end

Attack = Attack + 1
InfantryWave = InfantryWave + 1
local toBuild = Utils.Random(InfTypes)
USSR.Build(toBuild, function(units)
if Attack == 2 and not AttackTnk1.IsDead then
if InfantryWave == 2 and not AttackTnk1.IsDead then
units[#units + 1] = AttackTnk1
elseif Attack == 4 and not AttackTnk2.IsDead then
elseif InfantryWave == 4 and not AttackTnk2.IsDead then
units[#units + 1] = AttackTnk2
end

SendAttack(units, Utils.Random(AttackRallyPoints))
Trigger.AfterDelay(DateTime.Seconds(BuildDelays), ProduceInfantry)
Trigger.AfterDelay(BuildDelays[Difficulty], ProduceInfantry)
end)
end

Expand All @@ -115,24 +117,24 @@ ProduceVehicles = function()
end

ProduceNaval = function()
if not ShouldProduce and #Utils.Where(Map.ActorsInWorld, function(self) return self.Owner == Greece and self.Type == "syrd" end) < 1 then
Trigger.AfterDelay(DateTime.Minutes(1), ProduceNaval)
if not SubPenStarted and not Greece.HasPrerequisites({ "syrd" }) then
Trigger.AfterDelay(DateTime.Seconds(6), ProduceNaval)
return
end

ShouldProduce = true

if SubPen.IsDead or SubPen.Owner ~= USSR then
return
end

USSR.Build(WaterAttackTypes, function(units)
SubPenStarted = true

USSR.Build(WaterAttackTypes[Difficulty], function(units)
Utils.Do(units, function(unit)
IdlingNavalUnits[#IdlingNavalUnits + 1] = unit
end)

Trigger.AfterDelay(DateTime.Minutes(1) + DateTime.Seconds(40), ProduceNaval)
if #IdlingNavalUnits >= WaterAttacks then
if #IdlingNavalUnits >= #WaterAttackTypes[Difficulty] then
Trigger.AfterDelay(DateTime.Seconds(20), function()
SendAttack(SetupNavalAttackGroup(), { Harbor.Location })
end)
Expand All @@ -146,15 +148,12 @@ ProduceAircraft = function()
end

USSR.Build(SovietAircraftType, function(units)
local yak = units[1]
Yaks[#Yaks + 1] = yak

Trigger.OnKilled(yak, ProduceAircraft)
if #Yaks == 1 then
Trigger.AfterDelay(DateTime.Seconds(BuildDelays), ProduceAircraft)
end

InitializeAttackAircraft(yak, Greece)
Utils.Do(units, function(yak)
InitializeAttackAircraft(yak, Greece)
Trigger.OnKilled(yak, function()
Trigger.AfterDelay(BuildDelays[Difficulty], ProduceAircraft)
end)
end)
end)
end

Expand All @@ -167,7 +166,7 @@ end

SetupNavalAttackGroup = function()
local units = { }
for i = 0, 3 do
for i = 1, 3 do
if #IdlingNavalUnits == 0 then
return units
end
Expand All @@ -184,7 +183,7 @@ end

WTransWaves = function()
local way = Utils.Random(WTransWays)
local units = Utils.Random(WTransUnits)
local units = Utils.Random(WTransUnits[Difficulty])
local attackUnits = Reinforcements.ReinforceWithTransport(USSR, "lst", units , way, { way[2], way[1] })[2]
Utils.Do(attackUnits, function(a)
Trigger.OnAddedToWorld(a, function()
Expand All @@ -193,25 +192,31 @@ WTransWaves = function()
end)
end)

Trigger.AfterDelay(DateTime.Minutes(WTransDelays), WTransWaves)
Trigger.AfterDelay(WTransDelays[Difficulty], WTransWaves)
end

ActivateAI = function()
WaterAttackTypes = WaterAttackTypes[Difficulty]
WaterAttacks = WaterAttacks[Difficulty]
WTransUnits = WTransUnits[Difficulty]
WTransDelays = WTransDelays[Difficulty]
BuildDelays = BuildDelays[Difficulty]

InitialiseAttack()
Trigger.AfterDelay(DateTime.Seconds(10), ProduceInfantry)
Trigger.AfterDelay(DateTime.Minutes(1) + DateTime.Seconds(10), function()
ProduceAircraft()
ProduceVehicles()
end)
if SovietsActivated then
return
end
SovietsActivated = true

WeaponsFactory.RallyPoint = WeaponMeetPoint.Location
SubPen.RallyPoint = SubMeetPoint.Location
Trigger.AfterDelay(DateTime.Minutes(5) + DateTime.Seconds(10), ProduceNaval)
Trigger.AfterDelay(DateTime.Minutes(WTransDelays), WTransWaves)
PrepareTankDefenders()
ProduceInfantry()
Trigger.AfterDelay(DateTime.Minutes(1), ProduceVehicles)

Trigger.AfterDelay(FirstAirDelays[Difficulty], ProduceAircraft)
Trigger.OnProduction(Airfield, function()
if not YakCamera.IsInWorld then
return
end

-- This begins neutral to lessen its effect on ground attacks.
YakCamera.Owner = USSR
end)

Trigger.AfterDelay(DateTime.Minutes(5), ProduceNaval)
Trigger.AfterDelay(WTransDelays[Difficulty], WTransWaves)
end
77 changes: 60 additions & 17 deletions mods/ra/maps/allies-06a/allies06a.lua
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ GroupPatrol = function(units, waypoints, delay)
return
end
if unit.Location == waypoints[i] then
local bool = Utils.All(units, function(actor) return actor.IsIdle end)
local bool = Utils.All(units, function(actor) return actor.IsIdle or actor.IsDead end)
if bool then
stop = true
i = i + 1
Expand Down Expand Up @@ -103,7 +103,8 @@ InitialAlliedReinforcements = function()
Reinforcements.Reinforce(Greece, AlliedReinforcementsB, { AlliedEntry2.Location, UnitAStopLocation.Location }, 2)
end)
Trigger.AfterDelay(DateTime.Seconds(5), function()
Reinforcements.Reinforce(Greece, { "mcv" }, { AlliedEntry3.Location, MCVStopLocation.Location })
local mcv = Reinforcements.Reinforce(Greece, { "mcv" }, { AlliedEntry3.Location, MCVStopLocation.Location })[1]
Trigger.OnRemovedFromWorld(mcv, ActivateAI)
end)
end

Expand Down Expand Up @@ -135,39 +136,80 @@ CaptureRadarDome = function()
end

InfiltrateTechCenter = function()
local infiltrated = false
local allKilled = false

Utils.Do(SovietTechLabs, function(a)
Trigger.OnInfiltrated(a, function()
if Infiltrated then
if infiltrated then
return
end
Infiltrated = true
DestroySovietsObj = AddPrimaryObjective(Greece, "destroy-soviet-buildings-units")
Greece.MarkCompletedObjective(InfiltrateTechCenterObj)

local Proxy = Actor.Create("powerproxy.paratroopers", false, { Owner = USSR })
Utils.Do(ParadropWaypoints[Difficulty], function(waypoint)
Proxy.TargetParatroopers(waypoint.CenterPosition, Angle.South)
infiltrated = true

-- Let the infiltration speech play first.
Trigger.AfterDelay(38, function()
Media.PlaySpeechNotification(Greece, "FirstObjectiveMet")
DestroySovietsObj = AddPrimaryObjective(Greece, "destroy-soviet-buildings-units")
Greece.MarkCompletedObjective(InfiltrateTechCenterObj)

local proxy = Actor.Create("powerproxy.paratroopers", false, { Owner = USSR })
Utils.Do(ParadropWaypoints[Difficulty], function(waypoint)
local plane = proxy.TargetParatroopers(waypoint.CenterPosition, Angle.South)[1]
Trigger.OnPassengerExited(plane, function(_, passenger)
IdleHunt(passenger)
end)
end)
proxy.Destroy()
end)
Proxy.Destroy()
end)

Trigger.OnCapture(a, function()
if not Infiltrated then
if not infiltrated then
Media.PlaySoundNotification(Greece, "AlertBleep")
Media.DisplayMessage(UserInterface.Translate("dont-capture-tech-centers"))
end
end)
end)

Trigger.OnAllKilled(SovietTechLabs, function()
allKilled = true
end)

Trigger.OnAllKilledOrCaptured(SovietTechLabs, function()
if not Greece.IsObjectiveCompleted(InfiltrateTechCenterObj) then
Greece.MarkFailedObjective(InfiltrateTechCenterObj)
if infiltrated then
return
end

Trigger.AfterDelay(1, function()
FailTechCenter(allKilled)
end)
end)
end

Tick = function()
if DateTime.GameTime > DateTime.Seconds(10) and Greece.HasNoRequiredUnits() then
FailTechCenter = function(killed)
local speechDelay = 0

if not killed then
-- Let the capture speech play first.
speechDelay = 36
end

Trigger.AfterDelay(speechDelay, function()
Media.PlaySpeechNotification(Greece, "ObjectiveNotMet")
end)

Trigger.AfterDelay(speechDelay + DateTime.Seconds(1), function()
Greece.MarkFailedObjective(InfiltrateTechCenterObj)
end)
end

Tick = function()
if Greece.HasNoRequiredUnits() then
if DestroySovietsObj then
Greece.MarkFailedObjective(DestroySovietsObj)
elseif DateTime.GameTime > DateTime.Seconds(10) then
Greece.MarkFailedObjective(InfiltrateTechCenterObj)
end
end

if DestroySovietsObj and USSR.HasNoRequiredUnits() then
Expand Down Expand Up @@ -205,5 +247,6 @@ WorldLoaded = function()

CaptureRadarDome()
InfiltrateTechCenter()
Trigger.AfterDelay(0, ActivateAI)
-- Prepare Soviet attacks if Greece still has an undeployed MCV.
Trigger.AfterDelay(DateTime.Seconds(30), ActivateAI)
end

0 comments on commit f955be1

Please sign in to comment.