Created
January 7, 2017 18:43
-
-
Save MustaphaTR/6bab945373ac200f02cda0192cf03dcb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
OrdosReinf1 = { "trooper", "trooper", "trooper", "light_inf", "light_inf", "light_inf", "raider" } | |
OrdosReinf2 = { "quad", "combat_tank_o", "combat_tank_o", "stealth_raider" } | |
OrdosReinf3 = { "siege_tank", "siege_tank", "deviator" } | |
MercenaryReinf = { "sniper", "sniper", "sniper", "sniper", "sniper" } | |
OrdosReinf1Locations = { ordos_reinf1_entry.Location, ordos_reinf1_waypoint.Location } | |
OrdosReinf2Locations = { ordos_reinf2_entry.Location, ordos_reinf2_waypoint.Location } | |
OrdosReinf3Locations = { CargoVehicleEntry.Location, ordos_reinf3_waypoint.Location } | |
MercenaryReinfLocations = { mercenary_reinf_entry.Location, mercenary_reinf_waypoint.Location } | |
atr_barr1 = { name = "barracks", pos = CPos.New(35, 69), prize = 225, exists = true } | |
atr_barr2 = { name = "barracks", pos = CPos.New(59, 72), prize = 225, exists = true } | |
atr_ref1 = { name = "refinery", pos = CPos.New(67, 77), prize = 1500, exists = true } | |
atr_ref2 = { name = "refinery", pos = CPos.New(35, 65), prize = 1500, exists = true } | |
atr_outpost = { name = "outpost", pos = CPos.New(39, 77), prize = 750, exists = true } | |
atr_starport = { name = "starport", pos = CPos.New(47, 70), prize = 1500, exists = true } | |
atr_hfac = { name = "heavy_factory", pos = CPos.New(55, 69), prize = 1000, exists = true } | |
atr_lfac1 = { name = "light_factory", pos = CPos.New(37, 73), prize = 500, exists = true } | |
atr_lfac2 = { name = "light_factory", pos = CPos.New(43, 73), prize = 500, exists = true } | |
atr_htec = { name = "high_tech_factory", pos = CPos.New(59, 76), prize = 1150, exists = true } | |
atr_rpad = { name = "repair_pad", pos = CPos.New(51, 70), prize = 800, exists = true } | |
emp_barr1 = { name = "barracks", pos = CPos.New(22, 77), prize = 225, exists = true } | |
emp_barr2 = { name = "barracks", pos = CPos.New(2, 71), prize = 225, exists = true } | |
emp_ref1 = { name = "refinery", pos = CPos.New(2, 52), prize = 1500, exists = true } | |
emp_ref2 = { name = "refinery", pos = CPos.New(17, 66), prize = 1500, exists = true } | |
emp_palace = { name = "palace", pos = CPos.New(2, 77), prize = 1600, exists = true } | |
emp_outpost = { name = "outpost", pos = CPos.New(18, 77), prize = 750, exists = true } | |
emp_starport = { name = "starport", pos = CPos.New(6, 71), prize = 1500, exists = true } | |
emp_hfac = { name = "heavy_factory", pos = CPos.New(21, 67), prize = 1000, exists = true } | |
emp_lfac = { name = "light_factory", pos = CPos.New(12, 73), prize = 500, exists = true } | |
emp_rpad = { name = "repair_pad", pos = CPos.New(11, 69), prize = 800, exists = true } | |
AtreidesBaseBuildings = { | |
atr_barr1, | |
atr_barr2, | |
atr_ref1, | |
atr_ref2, | |
atr_outpost, | |
atr_starport, | |
atr_hfac, | |
atr_lfac1, | |
atr_lfac2, | |
atr_htec, | |
atr_rpad | |
} | |
AtreidesInitialBase = { | |
atreides_barr1, | |
atreides_barr2, | |
atreides_ref1, | |
atreides_ref2, | |
atreides_outpost, | |
atreides_starport, | |
atreides_hfac, | |
atreides_lfac1, | |
atreides_lfac2, | |
atreides_htec, | |
atreides_rpad | |
} | |
EmparorBaseBuildings = { | |
emp_barr1, | |
emp_barr2, | |
emp_ref1, | |
emp_ref2, | |
emp_palace, | |
emp_outpost, | |
emp_starport, | |
emp_hfac, | |
emp_lfac, | |
emp_rpad | |
} | |
EmparorInitialBase = { | |
emparor_barr1, | |
emparor_barr2, | |
emparor_ref1, | |
emparor_ref2, | |
emparor_palace, | |
emparor_outpost, | |
emparor_starport, | |
emparor_hfac, | |
emparor_lfac, | |
emparor_rpad | |
} | |
AtreidesSetDestroyedBuildings = function() | |
for i,v in ipairs(AtreidesInitialBase) do | |
Trigger.OnDamaged(v, function(building) | |
if building.Owner == Multi3 and building.Health < building.MaxHealth * 3/4 then | |
building.StartBuildingRepairs() | |
end | |
end) | |
Trigger.OnKilled(v, function() | |
AtreidesBaseBuildings[i].exists = false | |
end) | |
end | |
end | |
EmparorSetDestroyedBuildings = function() | |
for i,v in ipairs(EmparorInitialBase) do | |
Trigger.OnDamaged(v, function(building) | |
if building.Owner == Multi4 and building.Health < building.MaxHealth * 3/4 then | |
building.StartBuildingRepairs() | |
end | |
end) | |
Trigger.OnKilled(v, function() | |
AtreidesBaseBuildings[i].exists = false | |
end) | |
end | |
end | |
AtreidesBuildBase = function() | |
if atreides_cyard.IsDead or atreides_cyard.Owner ~= Multi3 then | |
return | |
elseif Multi3.Resources <= 499 then | |
return | |
end | |
for i,v in ipairs(AtreidesBaseBuildings) do | |
if not v.exists then | |
AtreidesBuildBuilding(v) | |
return | |
end | |
end | |
Trigger.AfterDelay(DateTime.Seconds(10), AtreidesBuildBase) | |
end | |
AtreidesBuildBuilding = function(building) | |
Trigger.AfterDelay(Actor.BuildTime(building.name), function() | |
local actor = Actor.Create(building.name, true, { Owner = Multi3, Location = building.pos }) | |
Multi3.Cash = Multi3.Cash - building.prize | |
building.exists = true | |
Trigger.OnKilled(actor, function() building.exists = false end) | |
Trigger.OnDamaged(actor, function(building) | |
if building.Owner == Multi3 and building.Health < building.MaxHealth * 3/4 then | |
building.StartBuildingRepairs() | |
DefendActor(actor) | |
end | |
end) | |
Trigger.AfterDelay(DateTime.Seconds(10), AtreidesBuildBase) | |
end) | |
end | |
EmparorBuildBase = function() | |
if emparor_cyard.IsDead or emparor_cyard.Owner ~= Multi4 then | |
return | |
elseif Multi4.Resources <= 499 then | |
return | |
end | |
for i,v in ipairs(EmparorBaseBuildings) do | |
if not v.exists then | |
EmparorBuildBuilding(v) | |
return | |
end | |
end | |
Trigger.AfterDelay(DateTime.Seconds(10), EmparorBuildBase) | |
end | |
EmparorBuildBuilding = function(building) | |
Trigger.AfterDelay(Actor.BuildTime(building.name), function() | |
local actor = Actor.Create(building.name, true, { Owner = Multi4, Location = building.pos }) | |
Multi3.Cash = Multi4.Cash - building.prize | |
building.exists = true | |
Trigger.OnKilled(actor, function() building.exists = false end) | |
Trigger.OnDamaged(actor, function(building) | |
if building.Owner == Multi4 and building.Health < building.MaxHealth * 3/4 then | |
building.StartBuildingRepairs() | |
DefendActor(actor) | |
end | |
end) | |
Trigger.AfterDelay(DateTime.Seconds(10), EmparorBuildBase) | |
end) | |
end | |
SendCargoVehicle = function() | |
local CargoVehicle = Actor.Create("cargo_vehicle", true, { Owner = Multi0, Location = CargoVehicleEntry.Location }) | |
CargoVehicle.Move(CargoVehicleWaypoint.Location) | |
Media.DisplayMessage("A Cargo Vehicle has arrived.", "Mentat") | |
Trigger.AfterDelay(DateTime.Seconds(60), SendCargoVehicle) | |
end | |
SendCarryallReinforcement = function(waypoint, units, side, t) | |
Trigger.AfterDelay(DateTime.Seconds(t), function() | |
Reinforcements.ReinforceWithTransport(side, "carryall.reinforce", units, waypoint, { waypoint[1] }) | |
end) | |
end | |
SetPlayerCash = function() | |
Multi1.Cash = 10000 | |
Multi3.Cash = 6000 | |
Multi4.Cash = 6000 | |
end | |
InitObjectives = function() | |
MercenaryObjective = Multi0.AddPrimaryObjective("Ensure the victory of Ordos.") | |
OrdosObjective = Multi1.AddPrimaryObjective("Destroy the Atreides and the Imperial Forces.") | |
Atreides2Objective = Multi2.AddPrimaryObjective("Destroy the Ordos forces and their Mercenaries.") | |
Atreides1Objective = Multi3.AddPrimaryObjective("Destroy the Ordos forces and their Mercenaries.") | |
EmparorObjective = Multi4.AddPrimaryObjective("Ensure the victory of Atreides.") | |
if Multi0.HasNoRequiredUnits() then | |
Multi0.MarkFailedObjective(MercenaryObjective) | |
Media.DisplayMessage("The Mercenaries have been annihilated!", "Mentat") | |
end | |
if Multi1.HasNoRequiredUnits() then | |
Multi0.MarkFailedObjective(MercenaryObjective) | |
Multi1.MarkFailedObjective(OrdosObjective) | |
Multi2.MarkCompletedObjective(Atreides2Objective) | |
Multi3.MarkCompletedObjective(Atreides1Objective) | |
Multi4.MarkCompletedObjective(EmparorObjective) | |
Media.DisplayMessage("The Ordos have been annihilated!", "Mentat") | |
end | |
if Multi2.HasNoRequiredUnits() and Multi3.HasNoRequiredUnits() and Multi4.HasNoRequiredUnits() then | |
Multi0.MarkCompletedObjective(MercenaryObjective) | |
Multi1.MarkCompletedObjective(OrdosObjective) | |
end | |
if Multi2.HasNoRequiredUnits() then | |
Multi2.MarkFailedObjective(Atreides2Objective) | |
end | |
if Multi3.HasNoRequiredUnits() then | |
Multi3.MarkFailedObjective(Atreides1Objective) | |
end | |
if Multi4.HasNoRequiredUnits() then | |
Multi4.MarkFailedObjective(EmparorObjective) | |
Media.DisplayMessage("The Imperial Forces have been annihilated!", "Mentat") | |
end | |
if Multi2.HasNoRequiredUnits() and Multi3.HasNoRequiredUnits() then | |
Media.DisplayMessage("The Atreides have been annihilated!", "Mentat") | |
end | |
Trigger.OnPlayerLost(Multi0, function() | |
Trigger.AfterDelay(DateTime.Seconds(1), function() | |
Media.PlaySpeechNotification(Multi0, "Lose") | |
end) | |
end) | |
Trigger.OnPlayerWon(Multi0, function() | |
Trigger.AfterDelay(DateTime.Seconds(1), function() | |
Media.PlaySpeechNotification(Multi0, "Win") | |
end) | |
end) | |
end | |
WorldLoaded = function() | |
Multi0 = Player.GetPlayer("Multi0") | |
Multi1 = Player.GetPlayer("Multi1") | |
Multi2 = Player.GetPlayer("Multi2") | |
Multi3 = Player.GetPlayer("Multi3") | |
Multi4 = Player.GetPlayer("Multi4") | |
Ordos = Player.GetPlayer("Ordos") | |
Atreides = Player.GetPlayer("Atreides") | |
Emparor = Player.GetPlayer("Emparor") | |
AtreidesSetDestroyedBuildings() | |
EmparorSetDestroyedBuildings() | |
InitObjectives() | |
SetPlayerCash() | |
SendCarryallReinforcement(OrdosReinf1Locations, OrdosReinf1, Ordos, 120) | |
SendCarryallReinforcement(OrdosReinf2Locations, OrdosReinf2, Ordos, 150) | |
SendCarryallReinforcement(OrdosReinf3Locations, OrdosReinf3, Ordos, 200) | |
SendCarryallReinforcement(MercenaryReinfLocations, MercenaryReinf, Multi0, 150) | |
SendCarryallReinforcement(MercenaryReinfLocations, MercenaryReinf, Multi0, 300) | |
Trigger.AfterDelay(DateTime.Seconds(125), function() | |
Media.DisplayMessage("Ordos Reinforcements have arrived.", "Mentat") | |
end) | |
Trigger.AfterDelay(DateTime.Seconds(155), function() | |
Media.DisplayMessage("Ordos Reinforcements have arrived.", "Mentat") | |
Media.DisplayMessage("Sniper Team has arrived.") | |
end) | |
Trigger.AfterDelay(DateTime.Seconds(205), function() | |
Media.DisplayMessage("Ordos Reinforcements have arrived.", "Mentat") | |
end) | |
Trigger.AfterDelay(DateTime.Seconds(305), function() | |
Media.DisplayMessage("Sniper Team has arrived.", "Mentat") | |
end) | |
Trigger.AfterDelay(DateTime.Seconds(60), SendCargoVehicle) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment