Use a modular AI in soviet05
This commit is contained in:
@@ -1,6 +1,64 @@
|
|||||||
Player:
|
Player:
|
||||||
PlayerResources:
|
PlayerResources:
|
||||||
DefaultCash: 5000
|
DefaultCash: 5000
|
||||||
|
ExternalCondition@luaAI:
|
||||||
|
Condition: ai-active
|
||||||
|
HarvesterBotModule:
|
||||||
|
RequiresCondition: ai-active
|
||||||
|
BuildingRepairBotModule:
|
||||||
|
RequiresCondition: ai-active
|
||||||
|
McvManagerBotModule:
|
||||||
|
RequiresCondition: ai-active
|
||||||
|
BaseBuilderBotModule@campaign:
|
||||||
|
RequiresCondition: ai-active
|
||||||
|
MinimumExcessPower: 60
|
||||||
|
MaximumExcessPower: 160
|
||||||
|
ExcessPowerIncrement: 40
|
||||||
|
ExcessPowerIncreaseThreshold: 4
|
||||||
|
ConstructionYardTypes: fact
|
||||||
|
RefineryTypes: proc
|
||||||
|
PowerTypes: powr
|
||||||
|
BarracksTypes: tent
|
||||||
|
VehiclesFactoryTypes: weap
|
||||||
|
ProductionTypes: tent, weap
|
||||||
|
SiloTypes: silo
|
||||||
|
BuildingLimits:
|
||||||
|
powr: 6
|
||||||
|
tent: 1
|
||||||
|
hbox: 3
|
||||||
|
proc: 3
|
||||||
|
weap: 1
|
||||||
|
gun: 6
|
||||||
|
agun: 2
|
||||||
|
silo: 1
|
||||||
|
BuildingFractions:
|
||||||
|
tent: 50
|
||||||
|
hbox: 50
|
||||||
|
proc: 90
|
||||||
|
weap: 20
|
||||||
|
gun: 30
|
||||||
|
agun: 20
|
||||||
|
silo: 10
|
||||||
|
SquadManagerBotModule@campaign:
|
||||||
|
RequiresCondition: ai-active
|
||||||
|
SquadSize: 10
|
||||||
|
ExcludeFromSquadsTypes: harv, mcv
|
||||||
|
NavalUnitsTypes: dd, ca, lst, pt
|
||||||
|
ConstructionYardTypes: fact
|
||||||
|
UnitBuilderBotModule@campaign:
|
||||||
|
RequiresCondition: ai-active
|
||||||
|
UnitsToBuild:
|
||||||
|
e1: 60
|
||||||
|
e3: 30
|
||||||
|
jeep: 50
|
||||||
|
1tnk: 50
|
||||||
|
harv: 30
|
||||||
|
UnitLimits:
|
||||||
|
e1: 20
|
||||||
|
e3: 10
|
||||||
|
harv: 6
|
||||||
|
jeep: 10
|
||||||
|
1tnk: 10
|
||||||
|
|
||||||
World:
|
World:
|
||||||
LuaScript:
|
LuaScript:
|
||||||
|
|||||||
@@ -6,11 +6,12 @@
|
|||||||
the License, or (at your option) any later version. For more
|
the License, or (at your option) any later version. For more
|
||||||
information, see COPYING.
|
information, see COPYING.
|
||||||
]]
|
]]
|
||||||
|
|
||||||
IdleHunt = function(unit) if not unit.IsDead then Trigger.OnIdle(unit, unit.Hunt) end end
|
IdleHunt = function(unit) if not unit.IsDead then Trigger.OnIdle(unit, unit.Hunt) end end
|
||||||
|
|
||||||
IdlingUnits = function()
|
IdlingUnits = function()
|
||||||
local lazyUnits = Utils.Where(Map.ActorsInWorld, function(actor)
|
local lazyUnits = Utils.Where(Map.ActorsInWorld, function(actor)
|
||||||
return actor.HasProperty("Hunt") and (actor.Owner == GoodGuy or actor.Owner == Greece) end)
|
return actor.HasProperty("Hunt") and actor.Owner == Greece end)
|
||||||
|
|
||||||
Utils.Do(lazyUnits, function(unit)
|
Utils.Do(lazyUnits, function(unit)
|
||||||
Trigger.OnDamaged(unit, function()
|
Trigger.OnDamaged(unit, function()
|
||||||
@@ -20,64 +21,6 @@ IdlingUnits = function()
|
|||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
BaseBuildings =
|
|
||||||
{
|
|
||||||
{ type = "powr", pos = CVec.New(3, -2), cost = 300 },
|
|
||||||
{ type = "tent", pos = CVec.New(0, 4), cost = 400 },
|
|
||||||
{ type = "hbox", pos = CVec.New(3, 6), cost = 600 },
|
|
||||||
{ type = "proc", pos = CVec.New(4, 2), cost = 1400 },
|
|
||||||
{ type = "powr", pos = CVec.New(5, -3), cost = 300 },
|
|
||||||
{ type = "weap", pos = CVec.New(-5, 3), cost = 2000 },
|
|
||||||
{ type = "hbox", pos = CVec.New(-6, 5), cost = 600 },
|
|
||||||
{ type = "gun", pos = CVec.New(0, 8), cost = 600 },
|
|
||||||
{ type = "gun", pos = CVec.New(-4, 7), cost = 600 },
|
|
||||||
{ type = "powr", pos = CVec.New(-4, -3), cost = 300 },
|
|
||||||
{ type = "proc", pos = CVec.New(-9, 1), cost = 1400 },
|
|
||||||
{ type = "powr", pos = CVec.New(-8, -2), cost = 300 },
|
|
||||||
{ type = "silo", pos = CVec.New(6, 0), cost = 150 },
|
|
||||||
{ type = "agun", pos = CVec.New(-3, 0), cost = 800 },
|
|
||||||
{ type = "powr", pos = CVec.New(-6, -2), cost = 300 },
|
|
||||||
{ type = "agun", pos = CVec.New(4, 1), cost = 800 },
|
|
||||||
{ type = "gun", pos = CVec.New(-9, 5), cost = 600 },
|
|
||||||
{ type = "gun", pos = CVec.New(-2, -3), cost = 600 },
|
|
||||||
{ type = "powr", pos = CVec.New(4, 6), cost = 300 },
|
|
||||||
{ type = "gun", pos = CVec.New(3, -6), cost = 600 },
|
|
||||||
{ type = "hbox", pos = CVec.New(3, -4), cost = 600 },
|
|
||||||
{ type = "gun", pos = CVec.New(2, 3), cost = 600 }
|
|
||||||
}
|
|
||||||
|
|
||||||
BuildBase = function()
|
|
||||||
if not CheckForCYard() then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
for i,v in ipairs(BaseBuildings) do
|
|
||||||
if not v.exists then
|
|
||||||
BuildBuilding(v)
|
|
||||||
return
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
Trigger.AfterDelay(DateTime.Seconds(5), BuildBase)
|
|
||||||
end
|
|
||||||
|
|
||||||
BuildBuilding = function(building)
|
|
||||||
Trigger.AfterDelay(Actor.BuildTime(building.type), function()
|
|
||||||
local actor = Actor.Create(building.type, true, { Owner = GoodGuy, Location = MCVDeploy.Location + building.pos })
|
|
||||||
GoodGuy.Cash = GoodGuy.Cash - building.cost
|
|
||||||
|
|
||||||
building.exists = true
|
|
||||||
Trigger.OnKilled(actor, function() building.exists = false end)
|
|
||||||
Trigger.OnDamaged(actor, function(building)
|
|
||||||
if building.Owner == GoodGuy and building.Health < building.MaxHealth * 3/4 then
|
|
||||||
building.StartBuildingRepairs()
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
|
|
||||||
Trigger.AfterDelay(DateTime.Seconds(1), BuildBase)
|
|
||||||
end)
|
|
||||||
end
|
|
||||||
|
|
||||||
ProduceInfantry = function()
|
ProduceInfantry = function()
|
||||||
if Barr.IsDead then
|
if Barr.IsDead then
|
||||||
return
|
return
|
||||||
@@ -116,46 +59,6 @@ ProduceShips = function()
|
|||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
ProduceInfantryGG = function()
|
|
||||||
if not BaseBuildings[2][4] then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
local delay = Utils.RandomInteger(DateTime.Seconds(3), DateTime.Seconds(9))
|
|
||||||
local toBuild = { Utils.Random(AlliedInfantryTypes) }
|
|
||||||
GoodGuy.Build(toBuild, function(unit)
|
|
||||||
GGInfAttack[#GGInfAttack + 1] = unit[1]
|
|
||||||
|
|
||||||
if #GGInfAttack >= 10 then
|
|
||||||
SendUnits(GGInfAttack, InfantryGGWaypoints)
|
|
||||||
GGInfAttack = { }
|
|
||||||
Trigger.AfterDelay(DateTime.Minutes(2), ProduceInfantryGG)
|
|
||||||
else
|
|
||||||
Trigger.AfterDelay(delay, ProduceInfantryGG)
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
end
|
|
||||||
|
|
||||||
ProduceTanksGG = function()
|
|
||||||
if not BaseBuildings[6][4] then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
local delay = Utils.RandomInteger(DateTime.Seconds(12), DateTime.Seconds(17))
|
|
||||||
local toBuild = { Utils.Random(AlliedTankTypes) }
|
|
||||||
GoodGuy.Build(toBuild, function(unit)
|
|
||||||
TankAttackGG[#TankAttackGG + 1] = unit[1]
|
|
||||||
|
|
||||||
if #TankAttackGG >= 6 then
|
|
||||||
SendUnits(TankAttackGG, TanksGGWaypoints)
|
|
||||||
TankAttackGG = { }
|
|
||||||
Trigger.AfterDelay(DateTime.Minutes(3), ProduceTanksGG)
|
|
||||||
else
|
|
||||||
Trigger.AfterDelay(delay, ProduceTanksGG)
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
end
|
|
||||||
|
|
||||||
SendUnits = function(units, waypoints)
|
SendUnits = function(units, waypoints)
|
||||||
Utils.Do(units, function(unit)
|
Utils.Do(units, function(unit)
|
||||||
if not unit.IsDead then
|
if not unit.IsDead then
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
the License, or (at your option) any later version. For more
|
the License, or (at your option) any later version. For more
|
||||||
information, see COPYING.
|
information, see COPYING.
|
||||||
]]
|
]]
|
||||||
|
|
||||||
SovietStartReinf = { "e2", "e2" }
|
SovietStartReinf = { "e2", "e2" }
|
||||||
SovietStartToBasePath = { StartPoint.Location, SovietBasePoint.Location }
|
SovietStartToBasePath = { StartPoint.Location, SovietBasePoint.Location }
|
||||||
SovietMCVReinf = { "mcv", "3tnk", "3tnk", "e1", "e1" }
|
SovietMCVReinf = { "mcv", "3tnk", "3tnk", "e1", "e1" }
|
||||||
@@ -92,7 +93,7 @@ IslandTroops1 = function()
|
|||||||
end
|
end
|
||||||
|
|
||||||
IslandTroops2 = function()
|
IslandTroops2 = function()
|
||||||
local units = Reinforcements.ReinforceWithTransport(GoodGuy, "lst", ArmorReinfGreece, NorthReinfPath, { ReinfEastPoint.Location })[2]
|
local units = Reinforcements.ReinforceWithTransport(Greece, "lst", ArmorReinfGreece, NorthReinfPath, { ReinfEastPoint.Location })[2]
|
||||||
Utils.Do(units, function(unit)
|
Utils.Do(units, function(unit)
|
||||||
Trigger.OnIdle(unit, function(patrols)
|
Trigger.OnIdle(unit, function(patrols)
|
||||||
patrols.Patrol(GoodGuyOrefieldPatrolPath, true, 150)
|
patrols.Patrol(GoodGuyOrefieldPatrolPath, true, 150)
|
||||||
@@ -114,7 +115,7 @@ IslandTroops2 = function()
|
|||||||
end
|
end
|
||||||
|
|
||||||
IslandTroops3 = function()
|
IslandTroops3 = function()
|
||||||
local units = Reinforcements.ReinforceWithTransport(GoodGuy, "lst", SovExpansionPointGuard, SouthReinfPath, { ReinfEastPoint.Location })[2]
|
local units = Reinforcements.ReinforceWithTransport(Greece, "lst", SovExpansionPointGuard, SouthReinfPath, { ReinfEastPoint.Location })[2]
|
||||||
Utils.Do(units, function(unit)
|
Utils.Do(units, function(unit)
|
||||||
Trigger.OnIdle(unit, function(guards)
|
Trigger.OnIdle(unit, function(guards)
|
||||||
guards.AttackMove(USSRExpansionPoint.Location)
|
guards.AttackMove(USSRExpansionPoint.Location)
|
||||||
|
|||||||
@@ -100,39 +100,31 @@ Expand = function()
|
|||||||
|
|
||||||
mcvtransport.Move(GGUnloadPoint.Location)
|
mcvtransport.Move(GGUnloadPoint.Location)
|
||||||
mcvtransport.UnloadPassengers()
|
mcvtransport.UnloadPassengers()
|
||||||
Trigger.AfterDelay(DateTime.Seconds(12), function()
|
mcvtransport.CallFunc(function()
|
||||||
if mcvGG.IsDead then
|
if mcvGG.IsDead then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
mcvGG.Move(MCVDeploy.Location)
|
mcvGG.Move(MCVDeploy.Location)
|
||||||
Trigger.AfterDelay(DateTime.Seconds(4), function()
|
mcvGG.CallFunc(function()
|
||||||
if not mcvGG.IsDead then
|
|
||||||
mcvGG.Deploy()
|
-- Avoid crashing through modifying the actor list from mcvGG's tick
|
||||||
Trigger.AfterDelay(DateTime.Seconds(4), function()
|
Trigger.AfterDelay(0, function()
|
||||||
local fact = Map.ActorsInBox(mcvGGLoadPoint.CenterPosition, ReinfEastPoint.CenterPosition, function(actor)
|
mcvGG.Owner = GoodGuy
|
||||||
return actor.Type == "fact" and actor.Owner == GoodGuy end)
|
|
||||||
if #fact == 0 then
|
|
||||||
return
|
|
||||||
else
|
|
||||||
Trigger.OnDamaged(fact[1], function()
|
|
||||||
if fact[1].Owner == GoodGuy and fact[1].Health < fact[1].MaxHealth * 3/4 then
|
|
||||||
fact[1].StartBuildingRepairs()
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
|
|
||||||
IslandTroops1()
|
IslandTroops1()
|
||||||
Trigger.AfterDelay(DateTime.Minutes(3), IslandTroops2)
|
Trigger.AfterDelay(DateTime.Minutes(3), IslandTroops2)
|
||||||
Trigger.AfterDelay(DateTime.Minutes(6), IslandTroops3)
|
Trigger.AfterDelay(DateTime.Minutes(6), IslandTroops3)
|
||||||
Trigger.AfterDelay(DateTime.Seconds(7), BuildBase)
|
|
||||||
end
|
|
||||||
|
|
||||||
if not mcvtransport.IsDead then
|
if not mcvtransport.IsDead then
|
||||||
mcvtransport.Move(ReinfNorthPoint.Location)
|
mcvtransport.Move(ReinfNorthPoint.Location)
|
||||||
mcvtransport.Destroy()
|
mcvtransport.Destroy()
|
||||||
end
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
Trigger.AfterDelay(DateTime.Seconds(1), function()
|
||||||
|
GoodGuy.GrantCondition("ai-active")
|
||||||
|
end)
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
@@ -263,8 +255,6 @@ WorldLoaded = function()
|
|||||||
Trigger.RemoveProximityTrigger(id)
|
Trigger.RemoveProximityTrigger(id)
|
||||||
|
|
||||||
Para2()
|
Para2()
|
||||||
ProduceInfantryGG()
|
|
||||||
ProduceTanksGG()
|
|
||||||
|
|
||||||
local units = Reinforcements.ReinforceWithTransport(player, "lst", SovietMCVReinf, { ReinfSouthPoint.Location, USSRlstPoint.Location }, { ReinfSouthPoint.Location })[2]
|
local units = Reinforcements.ReinforceWithTransport(player, "lst", SovietMCVReinf, { ReinfSouthPoint.Location, USSRlstPoint.Location }, { ReinfSouthPoint.Location })[2]
|
||||||
Utils.Do(units, function(unit)
|
Utils.Do(units, function(unit)
|
||||||
|
|||||||
Reference in New Issue
Block a user