Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add gdi08a
  • Loading branch information
fruestueck authored and abcdefg30 committed Mar 17, 2020
1 parent 989d147 commit 77e38ce
Show file tree
Hide file tree
Showing 8 changed files with 1,389 additions and 0 deletions.
2 changes: 2 additions & 0 deletions OpenRA.sln
Expand Up @@ -30,6 +30,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tiberian Dawn Lua scripts",
mods\cnc\maps\gdi05b\gdi05b.lua = mods\cnc\maps\gdi05b\gdi05b.lua
mods\cnc\maps\gdi06\gdi06.lua = mods\cnc\maps\gdi06\gdi06.lua
mods\cnc\maps\gdi07\gdi07.lua = mods\cnc\maps\gdi07\gdi07.lua
mods\cnc\maps\gdi08a\gdi08a-AI.lua = mods\cnc\maps\gdi08a\gdi08a-AI.lua
mods\cnc\maps\gdi08a\gdi08a.lua = mods\cnc\maps\gdi08a\gdi08a.lua
mods\cnc\maps\nod01\nod01.lua = mods\cnc\maps\nod01\nod01.lua
mods\cnc\maps\nod02a\nod02a.lua = mods\cnc\maps\nod02a\nod02a.lua
mods\cnc\maps\nod02b\nod02b.lua = mods\cnc\maps\nod02b\nod02b.lua
Expand Down
194 changes: 194 additions & 0 deletions mods/cnc/maps/gdi08a/gdi08a-AI.lua
@@ -0,0 +1,194 @@
--[[
Copyright 2007-2020 The OpenRA Developers (see AUTHORS)
This file is part of OpenRA, which is free software. It is made
available to you under the terms of the GNU General Public License
as published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version. For more
information, see COPYING.
]]

AttackPaths = { WaypointGroup3, WaypointGroup4, WaypointGroup5 }
NodBase = { handofnod, nodairfield, nodrefinery, NodYard, nodpower1, nodpower2, nodpower3, nodpower4, gun1, gun2, nodsilo1, nodsilo2, nodsilo3, nodsilo4}

PatrolProductionQueue = { }

InfantryAttackGroup = { }
InfantryGroupSize = 5
InfantryProductionCooldown = DateTime.Minutes(3)
InfantryProductionTypes = { "e1", "e1", "e1", "e3", "e3", "e4" }
HarvesterProductionType = { "harv" }

VehicleAttackGroup = { }
VehicleGroupSize = 5
VehicleProductionCooldown = DateTime.Minutes(3)
VehicleProductionTypes = { "bggy", "bggy", "bike", "ltnk", "ltnk" }

StartingCash = 14000

BaseRefinery = { type = "proc", pos = CPos.New(24, 16), cost = 1500 }
BaseGun1 = { type = "gun", pos = CPos.New( 21, 19), cost = 600 }
BaseGun2 = { type = "gun", pos = CPos.New( 26, 21), cost = 600 }
BaseNuke1 = { type = "nuke", pos = CPos.New( 23, 14), cost = 500 }
BaseNuke2 = { type = "nuke", pos = CPos.New( 10, 9), cost = 500 }
BaseNuke3 = { type = "nuke", pos = CPos.New( 6, 8), cost = 500 }
BaseNuke4 = { type = "nuke", pos = CPos.New( 8, 8), cost = 500 }
InfantryProduction = { type = "hand", pos = CPos.New(27, 17), cost = 500 }
VehicleProduction = { type = "afld", pos = CPos.New(27, 14), cost = 2000 }

NodGuards = { Actor154, Actor155, Actor218, Actor219 }

BaseBuildings = { BaseRefinery, BaseNuke1, BaseNuke2, BaseNuke3, BaseNuke4, InfantryProduction, VehicleProduction, BaseGun1, BaseGun2 }

BuildBuilding = function(building, cyard)
if CyardIsBuilding or Nod.Cash < building.cost then
Trigger.AfterDelay(DateTime.Seconds(10), function() BuildBuilding(building, cyard) end)
return
end

CyardIsBuilding = true

Nod.Cash = Nod.Cash - building.cost
Trigger.AfterDelay(Actor.BuildTime(building.type), function()
CyardIsBuilding = false

if cyard.IsDead or cyard.Owner ~= Nod then
Nod.Cash = Nod.Cash + building.cost
return
end

local actor = Actor.Create(building.type, true, { Owner = Nod, Location = building.pos })

if actor.Type == 'hand' or actor.Type == 'pyle' then
Trigger.AfterDelay(DateTime.Seconds(10), function() ProduceInfantry(actor) end)
elseif actor.Type == 'afld' or actor.Type == 'weap' then
Trigger.AfterDelay(DateTime.Seconds(10), function() ProduceVehicle(actor) end)
end

Trigger.OnKilled(actor, function()
BuildBuilding(building, cyard)
end)

RepairBuilding(GDI, actor, 0.75)
end)
end

CheckForHarvester = function()
local harv = Nod.GetActorsByType("harv")
return #harv > 0
end

GuardBase = function()
Utils.Do(NodBase, function(building)
Trigger.OnDamaged(building, function()
Utils.Do(NodGuards, function(guard)
if not guard.IsDead and not building.IsDead then
guard.Stop()
guard.Guard(building)
end
end)
end)
end)
end

ProduceHarvester = function(building)
if not buildingHarvester then
buildingHarvester = true
building.Build(HarvesterProductionType, function()
buildingHarvester = false
end)
end
end

ProduceInfantry = function(building)
if building.IsDead or building.Owner ~= Nod then
return
elseif not CheckForHarvester() then
Trigger.AfterDelay(DateTime.Seconds(10), function() ProduceInfantry(building) end)
return
end

local delay = Utils.RandomInteger(DateTime.Seconds(3), DateTime.Seconds(9))
local toBuild = { Utils.Random(InfantryProductionTypes) }
local Path = Utils.Random(AttackPaths)
building.Build(toBuild, function(unit)
InfantryAttackGroup[#InfantryAttackGroup + 1] = unit[1]

if #InfantryAttackGroup >= InfantryGroupSize then
MoveAndHunt(InfantryAttackGroup, Path)
InfantryAttackGroup = { }
Trigger.AfterDelay(InfantryProductionCooldown, function() ProduceInfantry(building) end)
else
Trigger.AfterDelay(delay, function() ProduceInfantry(building) end)
end
end)
end

ProduceVehicle = function(building)
if building.IsDead or building.Owner ~= Nod then
return
elseif not CheckForHarvester() then
ProduceHarvester(building)
Trigger.AfterDelay(DateTime.Seconds(10), function() ProduceVehicle(building) end)
return
end

local delay = Utils.RandomInteger(DateTime.Seconds(12), DateTime.Seconds(17))
local toBuild = { Utils.Random(VehicleProductionTypes) }
local Path = Utils.Random(AttackPaths)
building.Build(toBuild, function(unit)
VehicleAttackGroup[#VehicleAttackGroup + 1] = unit[1]

if #VehicleAttackGroup >= VehicleGroupSize then
MoveAndHunt(VehicleAttackGroup, Path)
VehicleAttackGroup = { }
Trigger.AfterDelay(VehicleProductionCooldown, function() ProduceVehicle(building) end)
else
Trigger.AfterDelay(delay, function() ProduceVehicle(building) end)
end
end)
end

StartAI = function()
Nod.Cash = StartingCash
GuardBase()
end

Trigger.OnAllKilledOrCaptured(NodBase, function()
Utils.Do(Nod.GetGroundAttackers(), IdleHunt)
end)

Trigger.OnKilled(nodrefinery, function()
BuildBuilding(BaseRefinery, NodYard)
end)

Trigger.OnKilled(nodpower1, function()
BuildBuilding(BaseNuke1, NodYard)
end)

Trigger.OnKilled(nodpower2, function()
BuildBuilding(BaseNuke2, NodYard)
end)

Trigger.OnKilled(nodpower3, function()
BuildBuilding(BaseNuke3, NodYard)
end)

Trigger.OnKilled(nodpower4, function()
BuildBuilding(BaseNuke4, NodYard)
end)

Trigger.OnKilled(gun1, function()
BuildBuilding(BaseGun1, NodYard)
end)

Trigger.OnKilled(gun2, function()
BuildBuilding(BaseGun2, NodYard)
end)

Trigger.OnKilled(handofnod, function()
BuildBuilding(InfantryProduction, NodYard)
end)

Trigger.OnKilled(nodairfield, function()
BuildBuilding(VehicleProduction, NodYard)
end)
152 changes: 152 additions & 0 deletions mods/cnc/maps/gdi08a/gdi08a.lua
@@ -0,0 +1,152 @@
--[[
Copyright 2007-2020 The OpenRA Developers (see AUTHORS)
This file is part of OpenRA, which is free software. It is made
available to you under the terms of the GNU General Public License
as published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version. For more
information, see COPYING.
]]

SamSites = { sam1, sam2, sam3 }

WaypointGroup1 = { waypoint4, waypoint5, waypoint6, waypoint7, waypoint10, waypoint11, waypoint12 }
WaypointGroup2 = { waypoint4, waypoint5, waypoint13, waypoint16 }
WaypointGroup3 = { waypoint4, waypoint5, waypoint6, waypoint8 }
WaypointGroup4 = { waypoint4, waypoint5, waypoint6, waypoint7, waypoint9 }
WaypointGroup5 = { waypoint4, waypoint5, waypoint6 }
WaypointGroup6 = { waypoint4, waypoint5, waypoint6, waypoint7, waypoint14, waypoint15 }
WaypointGroup7 = { waypoint4, waypoint5 }
WaypointGroupCiv = { waypoint0, waypoint1, waypoint2, waypoint3 }

Atk1 = { units = { ['ltnk'] = 1 }, waypoints = WaypointGroup1, delay = 0 }
Atk2 = { units = { ['ltnk'] = 1 }, waypoints = WaypointGroup2, delay = 0 }
Civ1 = { units = { ['c3'] = 1 }, waypoints = WaypointGroupCiv, delay = 0 }
Nod1 = { units = { ['e1'] = 2, ['e2'] = 2, ['e4'] = 2 }, waypoints = WaypointGroup3, delay = 90 }
Nod2 = { units = { ['e3'] = 2, ['e4'] = 2 }, waypoints = WaypointGroup3, delay = 130 }
Nod3 = { units = { ['e1'] = 2, ['e3'] = 3 }, waypoints = WaypointGroup3, delay = 50 }
Nod4 = { units = { ['bggy'] = 2 }, waypoints = WaypointGroup3, delay = 200 }
Nod5 = { units = { ['e4'] = 2, ['ltnk'] = 1 }, waypoints = WaypointGroup1, delay = 250 }
Nod6 = { units = { ['arty'] = 1 }, waypoints = WaypointGroup4, delay = 40 }
Nod7 = { units = { ['e3'] = 2, ['e4'] = 2 }, waypoints = WaypointGroup4, delay = 40 }
Nod8 = { units = { ['ltnk'] = 1, ['bggy'] = 1 }, waypoints = WaypointGroup3, delay = 170 }
Auto1 = { units = { ['e1'] = 2, ['e2'] = 2 }, waypoints = WaypointGroup5, delay = 50 }
Auto2 = { units = { ['e3'] = 3, ['e4'] = 2 }, waypoints = WaypointGroup3, delay = 50 }
Auto3 = { units = { ['ltnk'] = 1, ['bggy'] = 1 }, waypoints = WaypointGroup3, delay = 50 }
Auto4 = { units = { ['bggy'] = 2 }, waypoints = WaypointGroup7, delay = 50 }
Auto5 = { units = { ['ltnk'] = 1 }, waypoints = WaypointGroup6, delay = 50 }
Auto6 = { units = { ['arty'] = 1 }, waypoints = WaypointGroup4, delay = 50 }
Auto7 = { units = { ['e3'] = 3, ['e4'] = 2 }, waypoints = WaypointGroup6, delay = 50 }

AutoAttackWaves = { Atk1, Atk2, Nod1, Nod2, Nod3, Nod4, Nod5, Nod6, Nod7, Nod8, Auto1, Auto2, Auto3, Auto4, Auto5, Auto6, Auto7 }

StationaryGuardUnits = { Actor181, Actor182, Actor183, Actor184, Actor198, Actor199, Actor157, Actor175, Actor176, Actor173, Actor174, Actor158, Actor200, Actor159, Actor179, Actor180, Actor184, Actor185, Actor216, Actor217, Actor153, Actor215, Actor214, Actor213}

DamagedGDIAssets = { Actor126, Actor127, Actor128, Actor129, Actor130,Actor131, Actor132, Actor133, Actor134, Actor135, Actor136, Actor137, Actor138, Actor160, Actor161, Actor162, Actor163, Actor164, Actor165, Actor166, Actor168, Actor169, Actor170}

StartStationaryGuards = function(StationaryGuards)
Utils.Do(StationaryGuards, function(unit)
if not unit.IsDead then
unit.Patrol( { unit.Location } , true, 20)
end
end)
end

SendWaves = function(counter, Waves)
if counter <= #Waves then
local team = Waves[counter]

for type, amount in pairs(team.units) do
MoveAndHunt(Utils.Take(amount, Nod.GetActorsByType(type)), team.waypoints)
end

Trigger.AfterDelay(DateTime.Seconds(team.delay), function() SendWaves(counter + 1, Waves) end)
end
end

SendAttackWave = function(team)
for type, amount in pairs(team.units) do
count = 0
local actors = Nod.GetActorsByType(type)
Utils.Do(actors, function(actor)
if actor.IsIdle and count < amount then
SetAttackWaypoints(actor, team.waypoints)
IdleHunt(actor)
count = count + 1
end
end)
end
end

SetAttackWaypoints = function(actor, waypoints)
if not actor.IsDead then
Utils.Do(waypoints, function(waypoint)
actor.AttackMove(waypoint.Location)
end)
end
end

CeckRepairGDIAssetsObjective = function()
local failed = false
local repaired = true
Utils.Do(DamagedGDIAssets, function(actor)
if actor.IsDead then
failed = true
elseif actor.Health < actor.MaxHealth then
repaired = false
end
end)

if failed then
GDI.MarkFailedObjective(RepairAssets)
return
elseif repaired then
GDI.MarkCompletedObjective(RepairAssets)
return
end
Trigger.AfterDelay(DateTime.Seconds(3), function() CeckRepairGDIAssetsObjective() end)
end

WorldLoaded = function()
GDI = Player.GetPlayer("GDI")
Nod = Player.GetPlayer("Nod")

Camera.Position = DefaultCameraPosition.CenterPosition

StartStationaryGuards(StationaryGuardUnits)

StartAI()

InitObjectives(GDI)

SecureArea = GDI.AddObjective("Destroy the Nod strike force.")
KillGDI = Nod.AddObjective("Kill all enemies!")

RepairAssets = GDI.AddObjective("Repair GDI base and vehicles.", "Secondary", false)
Trigger.AfterDelay(DateTime.Seconds(5), function() CeckRepairGDIAssetsObjective() end)

AirSupport = GDI.AddObjective("Destroy the SAM sites to receive air support.", "Secondary", false)
Trigger.OnAllKilled(SamSites, function()
GDI.MarkCompletedObjective(AirSupport)
Actor.Create("airstrike.proxy", true, { Owner = GDI })
end)

local InitialArrivingUnits = { Actor166 }
Utils.Do(InitialArrivingUnits, function(unit)
unit.Move(unit.Location + CVec.New(1, 1), 0)
end)

Trigger.AfterDelay(DateTime.Minutes(1), function() SendWaves(1, AutoAttackWaves) end)
Trigger.AfterDelay(DateTime.Minutes(2), function() ProduceInfantry(handofnod) end)
Trigger.AfterDelay(DateTime.Minutes(2), function() ProduceVehicle(nodairfield) end)
end

Tick = function()
if DateTime.GameTime > DateTime.Seconds(5) then
if GDI.HasNoRequiredUnits() then
Nod.MarkCompletedObjective(KillGDI)
end
if Nod.HasNoRequiredUnits() then
GDI.MarkCompletedObjective(SecureArea)
end
end
end
Binary file added mods/cnc/maps/gdi08a/map.bin
Binary file not shown.
Binary file added mods/cnc/maps/gdi08a/map.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 77e38ce

Please sign in to comment.