Use a global script in Tiberian Dawn

This commit is contained in:
abcdefg30
2019-05-01 23:13:39 +02:00
committed by reaperrr
parent dbe73a06ad
commit b1f6c69fce
71 changed files with 2001 additions and 3877 deletions

View File

@@ -6,9 +6,10 @@
the License, or (at your option) any later version. For more
information, see COPYING.
]]
if Map.LobbyOption("difficulty") == "easy" then
if Difficulty == "easy" then
Rambo = "rmbo.easy"
elseif Map.LobbyOption("difficulty") == "hard" then
elseif Difficulty == "hard" then
Rambo = "rmbo.hard"
else
Rambo = "rmbo"
@@ -45,61 +46,14 @@ RocketTrigger = { CPos.New(20, 15), CPos.New(21, 15), CPos.New(22, 15), CPos.New
AirstrikeDelay = DateTime.Minutes(2) + DateTime.Seconds(30)
CheckForSams = function(player)
local sams = player.GetActorsByType("sam")
CheckForSams = function(Nod)
local sams = Nod.GetActorsByType("sam")
return #sams >= 3
end
searches = 0
getAirstrikeTarget = function()
local list = player.GetGroundAttackers()
if #list == 0 then
return
end
local target = list[DateTime.GameTime % #list + 1].CenterPosition
local sams = Map.ActorsInCircle(target, WDist.New(8 * 1024), function(actor)
return actor.Type == "sam" end)
if #sams == 0 then
searches = 0
return target
elseif searches < 6 then
searches = searches + 1
return getAirstrikeTarget()
else
searches = 0
return nil
end
end
SendAttackWave = function(team)
for type, amount in pairs(team.units) do
count = 0
local actors = enemy.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
SendGDIAirstrike = function(hq, delay)
if not hq.IsDead and hq.Owner == enemy then
local target = getAirstrikeTarget()
if not hq.IsDead and hq.Owner == GDI then
local target = GetAirstrikeTarget(Nod)
if target then
hq.SendAirstrike(target, false, Facing.NorthEast + 4)
@@ -113,14 +67,18 @@ end
SendWaves = function(counter, Waves)
if counter <= #Waves then
local team = Waves[counter]
SendAttackWave(team)
for type, amount in pairs(team.units) do
MoveAndHunt(Utils.Take(amount, GDI.GetActorsByType(type)), team.waypoints)
end
Trigger.AfterDelay(DateTime.Seconds(team.delay), function() SendWaves(counter + 1, Waves) end)
end
end
StartPatrols = function()
local mtnks = enemy.GetActorsByType("mtnk")
local msams = enemy.GetActorsByType("msam")
local mtnks = GDI.GetActorsByType("mtnk")
local msams = GDI.GetActorsByType("msam")
if #mtnks >= 1 then
mtnks[1].Patrol(Patrol1Waypoints, true, 20)
@@ -131,82 +89,82 @@ StartPatrols = function()
end
end
StartWaves = function()
SendWaves(1, AutoAttackWaves)
end
Trigger.OnEnteredFootprint(NodBaseTrigger, function(a, id)
if not nodBaseTrigger and a.Owner == player then
nodBaseTrigger = true
player.MarkCompletedObjective(NodObjective3)
NodCYard.Owner = player
if not Nod.IsObjectiveCompleted(LocateNodBase) and a.Owner == Nod then
Trigger.RemoveFootprintTrigger(id)
local walls = nodBase.GetActorsByType("brik")
Nod.MarkCompletedObjective(LocateNodBase)
NodCYard.Owner = Nod
local walls = NodBase.GetActorsByType("brik")
Utils.Do(walls, function(actor)
actor.Owner = player
actor.Owner = Nod
end)
Trigger.AfterDelay(DateTime.Seconds(2), function()
Media.PlaySpeechNotification(player, "NewOptions")
Media.PlaySpeechNotification(Nod, "NewOptions")
end)
end
end)
Trigger.OnEnteredFootprint(RocketTrigger, function(a, id)
if not rocketTrigger and a.Owner == player then
rocketTrigger = true
player.MarkCompletedObjective(NodObjective1)
if not Nod.IsObjectiveCompleted(SecureFirstLanding) and a.Owner == Nod then
Trigger.RemoveFootprintTrigger(id)
Nod.MarkCompletedObjective(SecureFirstLanding)
Trigger.AfterDelay(DateTime.Seconds(5), function()
Media.PlaySpeechNotification(player, "Reinforce")
Reinforcements.ReinforceWithTransport(player, 'tran.in', RocketReinforcements, { HelicopterEntryRocket.Location, HelicopterGoalRocket.Location }, { HelicopterEntryRocket.Location }, nil, nil)
Media.PlaySpeechNotification(Nod, "Reinforce")
Reinforcements.ReinforceWithTransport(Nod, "tran.in", RocketReinforcements, { HelicopterEntryRocket.Location, HelicopterGoalRocket.Location }, { HelicopterEntryRocket.Location }, nil, nil)
end)
Trigger.AfterDelay(DateTime.Seconds(10), function()
FlareEngineerCamera1 = Actor.Create("camera", true, { Owner = player, Location = FlareEngineer.Location })
FlareEngineerCamera2 = Actor.Create("camera", true, { Owner = player, Location = CameraEngineerPath.Location })
FlareEngineer = Actor.Create("flare", true, { Owner = player, Location = FlareEngineer.Location })
EngineerFlareCamera1 = Actor.Create("camera", true, { Owner = Nod, Location = FlareEngineer.Location })
EngineerFlareCamera2 = Actor.Create("camera", true, { Owner = Nod, Location = CameraEngineerPath.Location })
EngineerFlare = Actor.Create("flare", true, { Owner = Nod, Location = FlareEngineer.Location })
end)
Trigger.AfterDelay(DateTime.Minutes(1), function()
FlareRocketCamera.Destroy()
FlareRocket.Destroy()
RocketFlareCamera.Destroy()
RocketFlare.Destroy()
end)
end
end)
Trigger.OnEnteredFootprint(EngineerTrigger, function(a, id)
if not engineerTrigger and a.Owner == player then
engineerTrigger = true
player.MarkCompletedObjective(NodObjective2)
if not Nod.IsObjectiveCompleted(SecureSecondLanding) and a.Owner == Nod then
Trigger.RemoveFootprintTrigger(id)
Nod.MarkCompletedObjective(SecureSecondLanding)
Trigger.AfterDelay(DateTime.Seconds(5), function()
Media.PlaySpeechNotification(player, "Reinforce")
Reinforcements.ReinforceWithTransport(player, 'tran.in', EngineerReinforcements, { HelicopterEntryEngineer.Location, HelicopterGoalEngineer.Location }, { HelicopterEntryEngineer.Location }, nil, nil)
Media.PlaySpeechNotification(Nod, "Reinforce")
Reinforcements.ReinforceWithTransport(Nod, "tran.in", EngineerReinforcements, { HelicopterEntryEngineer.Location, HelicopterGoalEngineer.Location }, { HelicopterEntryEngineer.Location }, nil, nil)
end)
Trigger.AfterDelay(DateTime.Minutes(1), function()
FlareEngineerCamera1.Destroy()
FlareEngineerCamera2.Destroy()
FlareEngineer.Destroy()
if EngineerFlareCamera1 then
EngineerFlareCamera1.Destroy()
EngineerFlareCamera2.Destroy()
EngineerFlare.Destroy()
end
end)
end
end)
Trigger.OnKilledOrCaptured(OutpostProc, function()
if not outpostCaptured then
outpostCaptured = true
if not Nod.IsObjectiveCompleted(CaptureRefinery) then
if OutpostProc.IsDead then
player.MarkFailedObjective(NodObjective4)
Nod.MarkFailedObjective(CaptureRefinery)
else
player.MarkCompletedObjective(NodObjective4)
player.Cash = 1000
Nod.MarkCompletedObjective(CaptureRefinery)
Nod.Cash = 1000
end
StartPatrols()
Trigger.AfterDelay(DateTime.Minutes(1), function() StartWaves() end)
Trigger.AfterDelay(DateTime.Minutes(1), function() SendWaves(1, AutoAttackWaves) end)
Trigger.AfterDelay(AirstrikeDelay, function() SendGDIAirstrike(GDIHQ, AirstrikeDelay) end)
Trigger.AfterDelay(DateTime.Minutes(3), function() ProduceInfantry(GDIPyle) end)
Trigger.AfterDelay(DateTime.Minutes(3), function() ProduceVehicle(GDIWeap) end)
@@ -214,58 +172,42 @@ Trigger.OnKilledOrCaptured(OutpostProc, function()
end)
WorldLoaded = function()
player = Player.GetPlayer("Nod")
enemy = Player.GetPlayer("GDI")
nodBase = Player.GetPlayer("NodBase")
Nod = Player.GetPlayer("Nod")
GDI = Player.GetPlayer("GDI")
NodBase = Player.GetPlayer("NodBase")
Camera.Position = CameraIntro.CenterPosition
Media.PlaySpeechNotification(player, "Reinforce")
Reinforcements.ReinforceWithTransport(player, 'tran.in', RmboReinforcements, { HelicopterEntryRmbo.Location, HelicopterGoalRmbo.Location }, { HelicopterEntryRmbo.Location }, nil, nil)
FlareRocketCamera = Actor.Create("camera", true, { Owner = player, Location = FlareRocket.Location })
FlareRocket = Actor.Create("flare", true, { Owner = player, Location = FlareRocket.Location })
StartAI(GDICYard)
AutoGuard(enemy.GetGroundAttackers())
Media.PlaySpeechNotification(Nod, "Reinforce")
Reinforcements.ReinforceWithTransport(Nod, "tran.in", RmboReinforcements, { HelicopterEntryRmbo.Location, HelicopterGoalRmbo.Location }, { HelicopterEntryRmbo.Location })
Trigger.OnObjectiveAdded(player, function(p, id)
Media.DisplayMessage(p.GetObjectiveDescription(id), "New " .. string.lower(p.GetObjectiveType(id)) .. " objective")
end)
RocketFlareCamera = Actor.Create("camera", true, { Owner = Nod, Location = FlareRocket.Location })
RocketFlare = Actor.Create("flare", true, { Owner = Nod, Location = FlareRocket.Location })
Trigger.OnObjectiveCompleted(player, function(p, id)
Media.DisplayMessage(p.GetObjectiveDescription(id), "Objective completed")
end)
StartAI()
AutoGuard(GDI.GetGroundAttackers())
Trigger.OnObjectiveFailed(player, function(p, id)
Media.DisplayMessage(p.GetObjectiveDescription(id), "Objective failed")
end)
InitObjectives(Nod)
Trigger.OnPlayerWon(player, function()
Media.PlaySpeechNotification(player, "Win")
end)
Trigger.OnPlayerLost(player, function()
Media.PlaySpeechNotification(player, "Lose")
end)
NodObjective1 = player.AddPrimaryObjective("Secure the first landing zone.")
NodObjective2 = player.AddPrimaryObjective("Secure the second landing zone.")
NodObjective3 = player.AddPrimaryObjective("Locate the Nod base.")
NodObjective4 = player.AddPrimaryObjective("Capture the refinery.")
NodObjective5 = player.AddPrimaryObjective("Eliminate all GDI forces in the area.")
NodObjective6 = player.AddSecondaryObjective("Build 3 SAMs to fend off the GDI bombers.")
GDIObjective = enemy.AddPrimaryObjective("Eliminate all Nod forces in the area.")
SecureFirstLanding = Nod.AddObjective("Secure the first landing zone.")
SecureSecondLanding = Nod.AddObjective("Secure the second landing zone.")
LocateNodBase = Nod.AddObjective("Locate the Nod base.")
CaptureRefinery = Nod.AddObjective("Capture the refinery.")
EliminateGDI = Nod.AddObjective("Eliminate all GDI forces in the area.")
BuildSAMs = Nod.AddObjective("Build 3 SAMs to fend off the GDI bombers.", "Secondary", false)
GDIObjective = GDI.AddObjective("Eliminate all Nod forces in the area.")
end
Tick = function()
if DateTime.GameTime > 2 and player.HasNoRequiredUnits() then
enemy.MarkCompletedObjective(GDIObjective)
if DateTime.GameTime > 2 and Nod.HasNoRequiredUnits() then
GDI.MarkCompletedObjective(GDIObjective)
end
if DateTime.GameTime > 2 and enemy.HasNoRequiredUnits() then
player.MarkCompletedObjective(NodObjective5)
if DateTime.GameTime > 2 and GDI.HasNoRequiredUnits() then
Nod.MarkCompletedObjective(EliminateGDI)
end
if not player.IsObjectiveCompleted(NodObjective6) and CheckForSams(player) then
player.MarkCompletedObjective(NodObjective6)
if not Nod.IsObjectiveCompleted(BuildSAMs) and CheckForSams(Nod) then
Nod.MarkCompletedObjective(BuildSAMs)
end
end