Skip to content

Commit

Permalink
Add new Missions and some tile fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
MustaphaTR committed Mar 1, 2017
1 parent 5c6dda5 commit 4f49a8d
Show file tree
Hide file tree
Showing 74 changed files with 6,778 additions and 115 deletions.
126 changes: 126 additions & 0 deletions mtrsd2k/maps/atreides-02a/atreides02a-AI.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
IdlingUnits = { }

AttackGroupSize =
{
easy = 6,
normal = 8,
hard = 10
}
AttackDelays =
{
easy = { DateTime.Seconds(4), DateTime.Seconds(9) },
normal = { DateTime.Seconds(2), DateTime.Seconds(7) },
hard = { DateTime.Seconds(1), DateTime.Seconds(5) }
}

HarkonnenInfantryTypes = { "light_inf" }

AttackOnGoing = false
HoldProduction = false
HarvesterKilled = true

IdleHunt = function(unit) if not unit.IsDead then Trigger.OnIdle(unit, unit.Hunt) end end

SetupAttackGroup = function()
local units = { }

for i = 0, AttackGroupSize[Map.LobbyOption("difficulty")], 1 do
if #IdlingUnits == 0 then
return units
end

local number = Utils.RandomInteger(1, #IdlingUnits + 1)

if IdlingUnits[number] and not IdlingUnits[number].IsDead then
units[i] = IdlingUnits[number]
table.remove(IdlingUnits, number)
end
end

return units
end

SendAttack = function()
if Attacking then
return
end
Attacking = true
HoldProduction = true

local units = SetupAttackGroup()
Utils.Do(units, function(unit)
IdleHunt(unit)
end)

Trigger.OnAllRemovedFromWorld(units, function()
Attacking = false
HoldProduction = false
end)
end

DefendActor = function(unit)
Trigger.OnDamaged(unit, function(self, attacker)
if AttackOnGoing then
return
end
AttackOnGoing = true

local Guards = SetupAttackGroup()

if #Guards <= 0 then
AttackOnGoing = false
return
end

Utils.Do(Guards, function(unit)
if not self.IsDead then
unit.AttackMove(self.Location)
end
IdleHunt(unit)
end)

Trigger.OnAllRemovedFromWorld(Guards, function() AttackOnGoing = false end)
end)
end

InitAIUnits = function()
Utils.Do(HarkonnenBase, function(actor)
DefendActor(actor)
Trigger.OnDamaged(actor, function(building)
if building.Health < building.MaxHealth * 3/4 then
building.StartBuildingRepairs()
end
end)
end)
end

ProduceInfantry = function()
if HBarracks.IsDead then
return
end

if HoldProduction then
Trigger.AfterDelay(DateTime.Minutes(1), ProduceInfantry)
return
end

local delay = Utils.RandomInteger(AttackDelays[Map.LobbyOption("difficulty")][1], AttackDelays[Map.LobbyOption("difficulty")][2] + 1)
local toBuild = { Utils.Random(HarkonnenInfantryTypes) }
harkonnen.Build(toBuild, function(unit)
IdlingUnits[#IdlingUnits + 1] = unit[1]
Trigger.AfterDelay(delay, ProduceInfantry)

if #IdlingUnits >= (AttackGroupSize[Map.LobbyOption("difficulty")] * 2.5) then
SendAttack()
end
end)
end

ActivateAI = function()
Trigger.AfterDelay(0, InitAIUnits)

-- Finish the upgrades first before trying to build something
Trigger.AfterDelay(DateTime.Seconds(14), function()
ProduceInfantry()
end)
end
1 change: 1 addition & 0 deletions mtrsd2k/maps/atreides-02a/atreides02a.lua
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ WorldLoaded = function()
end)

SendHarkonnen()
ActivateAI()
end

InitObjectives = function()
Expand Down
Binary file modified mtrsd2k/maps/atreides-02a/map.bin
Binary file not shown.
2 changes: 1 addition & 1 deletion mtrsd2k/maps/atreides-02a/rules.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Player:

World:
LuaScript:
Scripts: atreides02a.lua
Scripts: atreides02a.lua, atreides02a-AI.lua
MissionData:
Briefing: Infiltrate the Imperial Basin and build up our forces until they are strong enough to eradicate the local Harkonnen presence.\n\nThe Harkonnen are reinforcing their troops by air, so be on your guard. Use the Outpost's radar to detect attacks from unexpected quarters.\n\nBe careful when mining the Spice. Spice mounds grow out of the sand. While a vital source of Spice, Spice mounds can damage or destroy any unit that blunders into them.\n\nGood luck.\n
BriefingVideo: A_BR02_E.VQA
Expand Down
126 changes: 126 additions & 0 deletions mtrsd2k/maps/atreides-02b/atreides02b-AI.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
IdlingUnits = { }

AttackGroupSize =
{
easy = 6,
normal = 8,
hard = 10
}
AttackDelays =
{
easy = { DateTime.Seconds(4), DateTime.Seconds(9) },
normal = { DateTime.Seconds(2), DateTime.Seconds(7) },
hard = { DateTime.Seconds(1), DateTime.Seconds(5) }
}

HarkonnenInfantryTypes = { "light_inf" }

AttackOnGoing = false
HoldProduction = false
HarvesterKilled = true

IdleHunt = function(unit) if not unit.IsDead then Trigger.OnIdle(unit, unit.Hunt) end end

SetupAttackGroup = function()
local units = { }

for i = 0, AttackGroupSize[Map.LobbyOption("difficulty")], 1 do
if #IdlingUnits == 0 then
return units
end

local number = Utils.RandomInteger(1, #IdlingUnits + 1)

if IdlingUnits[number] and not IdlingUnits[number].IsDead then
units[i] = IdlingUnits[number]
table.remove(IdlingUnits, number)
end
end

return units
end

SendAttack = function()
if Attacking then
return
end
Attacking = true
HoldProduction = true

local units = SetupAttackGroup()
Utils.Do(units, function(unit)
IdleHunt(unit)
end)

Trigger.OnAllRemovedFromWorld(units, function()
Attacking = false
HoldProduction = false
end)
end

DefendActor = function(unit)
Trigger.OnDamaged(unit, function(self, attacker)
if AttackOnGoing then
return
end
AttackOnGoing = true

local Guards = SetupAttackGroup()

if #Guards <= 0 then
AttackOnGoing = false
return
end

Utils.Do(Guards, function(unit)
if not self.IsDead then
unit.AttackMove(self.Location)
end
IdleHunt(unit)
end)

Trigger.OnAllRemovedFromWorld(Guards, function() AttackOnGoing = false end)
end)
end

InitAIUnits = function()
Utils.Do(HarkonnenBase, function(actor)
DefendActor(actor)
Trigger.OnDamaged(actor, function(building)
if building.Health < building.MaxHealth * 3/4 then
building.StartBuildingRepairs()
end
end)
end)
end

ProduceInfantry = function()
if HBarracks.IsDead then
return
end

if HoldProduction then
Trigger.AfterDelay(DateTime.Minutes(1), ProduceInfantry)
return
end

local delay = Utils.RandomInteger(AttackDelays[Map.LobbyOption("difficulty")][1], AttackDelays[Map.LobbyOption("difficulty")][2] + 1)
local toBuild = { Utils.Random(HarkonnenInfantryTypes) }
harkonnen.Build(toBuild, function(unit)
IdlingUnits[#IdlingUnits + 1] = unit[1]
Trigger.AfterDelay(delay, ProduceInfantry)

if #IdlingUnits >= (AttackGroupSize[Map.LobbyOption("difficulty")] * 2.5) then
SendAttack()
end
end)
end

ActivateAI = function()
Trigger.AfterDelay(0, InitAIUnits)

-- Finish the upgrades first before trying to build something
Trigger.AfterDelay(DateTime.Seconds(14), function()
ProduceInfantry()
end)
end
1 change: 1 addition & 0 deletions mtrsd2k/maps/atreides-02b/atreides02b.lua
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ WorldLoaded = function()
end)

SendHarkonnen()
ActivateAI()
end

InitObjectives = function()
Expand Down
Binary file modified mtrsd2k/maps/atreides-02b/map.bin
Binary file not shown.
2 changes: 1 addition & 1 deletion mtrsd2k/maps/atreides-02b/rules.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Player:

World:
LuaScript:
Scripts: atreides02b.lua
Scripts: atreides02b.lua, atreides02b-AI.lua
MissionData:
Briefing: Infiltrate the Imperial Basin and build up our forces until they are strong enough to eradicate the local Harkonnen presence.\n\nThe Harkonnen are reinforcing their troops by air, so be on your guard. Use the Outpost's radar to detect attacks from unexpected quarters.\n\nBe careful when mining the Spice. Spice mounds grow out of the sand. While a vital source of Spice, Spice mounds can damage or destroy any unit that blunders into them.\n\nGood luck.\n
BriefingVideo: A_BR02_E.VQA
Expand Down
Binary file modified mtrsd2k/maps/atreides-03a/map.bin
Binary file not shown.
12 changes: 11 additions & 1 deletion mtrsd2k/maps/atreides-03a/map.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MapFormat: 11

RequiresMod: d2k
RequiresMod: mtrsd2k

Title: Atreides 03a

Expand Down Expand Up @@ -134,5 +134,15 @@ Actors:
OrdosRally2: waypoint
Owner: Neutral
Location: 39,30
Actor30: wall
Owner: Ordos
Location: 53,24
Actor31: wall
Owner: Ordos
Location: 54,25
Actor32: artillery_platform
Owner: Ordos
Location: 53,25
TurretFacing: 92

Rules: d2k|rules/campaign-rules.yaml, rules.yaml
Binary file modified mtrsd2k/maps/atreides-03b/map.bin
Binary file not shown.
12 changes: 11 additions & 1 deletion mtrsd2k/maps/atreides-03b/map.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MapFormat: 11

RequiresMod: d2k
RequiresMod: mtrsd2k

Title: Atreides 03b

Expand Down Expand Up @@ -131,5 +131,15 @@ Actors:
OrdosRally2: waypoint
Owner: Neutral
Location: 15,34
Actor29: wall
Owner: Ordos
Location: 15,11
Actor30: wall
Owner: Ordos
Location: 17,11
Actor31: artillery_platform
Owner: Ordos
Location: 16,11
TurretFacing: 92

Rules: d2k|rules/campaign-rules.yaml, rules.yaml
Loading

0 comments on commit 4f49a8d

Please sign in to comment.