Use a global script in Tiberian Dawn
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
the License, or (at your option) any later version. For more
|
||||
information, see COPYING.
|
||||
]]
|
||||
|
||||
WaypointGroup1 = { waypoint0, waypoint1, waypoint2, waypoint3, waypoint6, waypoint10 }
|
||||
WaypointGroup2 = { waypoint0, waypoint1, waypoint2, waypoint3, waypoint6, waypoint7, waypoint8, waypoint9, waypoint10 }
|
||||
WaypointGroup3 = { waypoint0, waypoint1, waypoint2, waypoint3, waypoint4, waypoint5 }
|
||||
@@ -38,79 +39,36 @@ NodBaseTrigger = { CPos.New(52, 52), CPos.New(52, 53), CPos.New(52, 54), CPos.Ne
|
||||
AirstrikeDelay = DateTime.Minutes(2) + DateTime.Seconds(20)
|
||||
|
||||
NodBaseCapture = function()
|
||||
nodBaseTrigger = true
|
||||
player.MarkCompletedObjective(NodObjective1)
|
||||
FlareCamera = Actor.Create("camera", true, { Owner = Nod, Location = waypoint25.Location })
|
||||
Flare = Actor.Create("flare", true, { Owner = Nod, Location = waypoint25.Location })
|
||||
|
||||
SendHelicopter()
|
||||
|
||||
Nod.MarkCompletedObjective(LocateNodBase)
|
||||
|
||||
Utils.Do(NodBase, function(actor)
|
||||
actor.Owner = player
|
||||
actor.Owner = Nod
|
||||
end)
|
||||
|
||||
Trigger.AfterDelay(DateTime.Seconds(1), function()
|
||||
Media.PlaySpeechNotification(player, "NewOptions")
|
||||
Media.PlaySpeechNotification(Nod, "NewOptions")
|
||||
end)
|
||||
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
|
||||
|
||||
--Provide the player with a helicopter until the outpost got captured
|
||||
-- Provide the Nod with a helicopter until the outpost got captured
|
||||
SendHelicopter = function()
|
||||
Trigger.AfterDelay(DateTime.Seconds(5), function()
|
||||
if not outpostCaptured then
|
||||
Media.PlaySpeechNotification(player, "Reinforce")
|
||||
TransportHelicopter = Reinforcements.ReinforceWithTransport(player, 'tran', nil, { ReinforcementsHelicopterSpawn.Location, waypoint15.Location })[1]
|
||||
Trigger.OnKilled(TransportHelicopter, function()
|
||||
SendHelicopter()
|
||||
end)
|
||||
if not Nod.IsObjectiveCompleted(CaptureGDIOutpost) then
|
||||
Media.PlaySpeechNotification(Nod, "Reinforce")
|
||||
TransportHelicopter = Reinforcements.ReinforceWithTransport(Nod, 'tran', nil, { ReinforcementsHelicopterSpawn.Location, waypoint15.Location })[1]
|
||||
Trigger.OnKilled(TransportHelicopter, SendHelicopter)
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
SendAttackWave = function(team)
|
||||
for type, amount in pairs(team.units) do
|
||||
count = 0
|
||||
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)
|
||||
@@ -124,40 +82,35 @@ 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
|
||||
|
||||
StartWaves = function()
|
||||
SendWaves(1, AutoAttackWaves)
|
||||
end
|
||||
|
||||
Trigger.OnAllKilled(IntroGuards, function()
|
||||
FlareCamera = Actor.Create("camera", true, { Owner = player, Location = waypoint25.Location })
|
||||
Flare = Actor.Create("flare", true, { Owner = player, Location = waypoint25.Location })
|
||||
SendHelicopter()
|
||||
player.MarkCompletedObjective(NodObjective1)
|
||||
NodBaseCapture()
|
||||
if not Nod.IsObjectiveCompleted(LocateNodBase) then
|
||||
NodBaseCapture()
|
||||
end
|
||||
end)
|
||||
|
||||
Trigger.OnAllKilledOrCaptured(Outpost, function()
|
||||
if not outpostCaptured then
|
||||
outpostCaptured = true
|
||||
if not Nod.IsObjectiveCompleted(CaptureGDIOutpost) then
|
||||
Nod.MarkCompletedObjective(CaptureGDIOutpost)
|
||||
|
||||
Trigger.AfterDelay(DateTime.Minutes(1), function()
|
||||
|
||||
if not GDIHQ.IsDead and (not NodHand.IsDead or not NodNuke.IsDead) then
|
||||
local airstrikeproxy = Actor.Create("airstrike.proxy", false, { Owner = enemy })
|
||||
local airstrikeproxy = Actor.Create("airstrike.proxy", false, { Owner = GDI })
|
||||
airstrikeproxy.SendAirstrike(AirstrikeTarget.CenterPosition, false, Facing.NorthEast + 4)
|
||||
airstrikeproxy.Destroy()
|
||||
end
|
||||
end)
|
||||
|
||||
Trigger.AfterDelay(DateTime.Seconds(15), function()
|
||||
Utils.Do(OutpostGuards, function(unit)
|
||||
IdleHunt(unit)
|
||||
end)
|
||||
Utils.Do(OutpostGuards, IdleHunt)
|
||||
end)
|
||||
|
||||
Trigger.AfterDelay(DateTime.Minutes(1), function()
|
||||
@@ -165,8 +118,7 @@ Trigger.OnAllKilledOrCaptured(Outpost, function()
|
||||
Flare.Destroy()
|
||||
end)
|
||||
|
||||
player.MarkCompletedObjective(NodObjective2)
|
||||
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(2), function() ProduceInfantry(GDIPyle) end)
|
||||
Trigger.AfterDelay(DateTime.Minutes(3), function() ProduceVehicle(GDIWeap) end)
|
||||
@@ -175,65 +127,50 @@ end)
|
||||
|
||||
Trigger.OnCapture(OutpostCYard, function()
|
||||
Trigger.AfterDelay(DateTime.Seconds(4), function()
|
||||
Media.PlaySpeechNotification(player, "NewOptions")
|
||||
Media.PlaySpeechNotification(Nod, "NewOptions")
|
||||
end)
|
||||
end)
|
||||
|
||||
Trigger.OnAnyKilled(Outpost, function()
|
||||
if not outpostCaptured then
|
||||
player.MarkFailedObjective(NodObjective2)
|
||||
if not Nod.IsObjectiveCompleted(CaptureGDIOutpost) then
|
||||
Nod.MarkFailedObjective(CaptureGDIOutpost)
|
||||
end
|
||||
end)
|
||||
|
||||
Trigger.OnEnteredFootprint(NodBaseTrigger, function(a, id)
|
||||
if not nodBaseTrigger and a.Owner == player then
|
||||
if not Nod.IsObjectiveCompleted(LocateNodBase) and a.Owner == Nod then
|
||||
NodBaseCapture()
|
||||
Trigger.RemoveFootprintTrigger(id)
|
||||
end
|
||||
end)
|
||||
|
||||
WorldLoaded = function()
|
||||
player = Player.GetPlayer("Nod")
|
||||
enemy = Player.GetPlayer("GDI")
|
||||
Camera.Position = waypoint26.CenterPosition
|
||||
Media.PlaySpeechNotification(player, "Reinforce")
|
||||
Reinforcements.ReinforceWithTransport(player, 'tran.in', IntroReinforcements, { ReinforcementsHelicopterSpawn.Location, ReinforcementsHelicopterRally.Location }, { ReinforcementsHelicopterSpawn.Location }, nil, nil)
|
||||
Nod = Player.GetPlayer("Nod")
|
||||
GDI = Player.GetPlayer("GDI")
|
||||
|
||||
StartAI(GDICYard)
|
||||
Camera.Position = waypoint26.CenterPosition
|
||||
|
||||
Media.PlaySpeechNotification(Nod, "Reinforce")
|
||||
Reinforcements.ReinforceWithTransport(Nod, "tran.in", IntroReinforcements, { ReinforcementsHelicopterSpawn.Location, ReinforcementsHelicopterRally.Location }, { ReinforcementsHelicopterSpawn.Location })
|
||||
|
||||
StartAI()
|
||||
AutoGuard(IntroGuards)
|
||||
AutoGuard(OutpostGuards)
|
||||
|
||||
Trigger.OnObjectiveAdded(player, function(p, id)
|
||||
Media.DisplayMessage(p.GetObjectiveDescription(id), "New " .. string.lower(p.GetObjectiveType(id)) .. " objective")
|
||||
end)
|
||||
InitObjectives(Nod)
|
||||
|
||||
Trigger.OnObjectiveCompleted(player, function(p, id)
|
||||
Media.DisplayMessage(p.GetObjectiveDescription(id), "Objective completed")
|
||||
end)
|
||||
|
||||
Trigger.OnObjectiveFailed(player, function(p, id)
|
||||
Media.DisplayMessage(p.GetObjectiveDescription(id), "Objective failed")
|
||||
end)
|
||||
|
||||
Trigger.OnPlayerWon(player, function()
|
||||
Media.PlaySpeechNotification(player, "Win")
|
||||
end)
|
||||
|
||||
Trigger.OnPlayerLost(player, function()
|
||||
Media.PlaySpeechNotification(player, "Lose")
|
||||
end)
|
||||
|
||||
NodObjective1 = player.AddPrimaryObjective("Locate the Nod base.")
|
||||
NodObjective2 = player.AddPrimaryObjective("Capture the GDI outpost.")
|
||||
NodObjective3 = player.AddPrimaryObjective("Eliminate all GDI forces in the area.")
|
||||
GDIObjective = enemy.AddPrimaryObjective("Eliminate all Nod forces in the area.")
|
||||
LocateNodBase = Nod.AddObjective("Locate the Nod base.")
|
||||
CaptureGDIOutpost = Nod.AddObjective("Capture the GDI outpost.")
|
||||
EliminateGDI = Nod.AddObjective("Eliminate all GDI forces in the area.")
|
||||
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(NodObjective3)
|
||||
if DateTime.GameTime > 2 and GDI.HasNoRequiredUnits() then
|
||||
Nod.MarkCompletedObjective(EliminateGDI)
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user