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,6 +6,7 @@
the License, or (at your option) any later version. For more
information, see COPYING.
]]
InfantryReinforcements = { "e1", "e1", "e2" }
JeepReinforcements = { "jeep" }
TankReinforcements = { "mtnk" }
@@ -16,68 +17,25 @@ SamSites = { sam1, sam2, sam3, sam4 }
NodBase = { handofnod, nodpower1, nodpower2, nodpower3, nodairfield, nodrefinery, nodconyard }
HiddenNodUnits = { sleeper1, sleeper2, sleeper3, sleeper4 }
ReinforceWithLandingCraft = function(units, transportStart, transportUnload, rallypoint)
local transport = Actor.Create("oldlst", true, { Owner = GDI, Facing = 0, Location = transportStart })
local subcell = 0
Utils.Do(units, function(a)
transport.LoadPassenger(Actor.Create(a, false, { Owner = transport.Owner, Facing = transport.Facing, Location = transportUnload, SubCell = subcell }))
subcell = subcell + 1
end)
transport.ScriptedMove(transportUnload)
Media.PlaySpeechNotification(player, "Reinforce")
transport.CallFunc(function()
Utils.Do(units, function()
local a = transport.UnloadPassenger()
a.IsInWorld = true
a.MoveIntoWorld(transport.Location - CVec.New(0, 1))
if rallypoint ~= nil then
a.Move(rallypoint)
end
end)
end)
transport.Wait(5)
transport.ScriptedMove(transportStart)
transport.Destroy()
end
CheckForBase = function(player)
local buildings = 0
Utils.Do(GDIBaseBuildings, function(name)
if #GDI.GetActorsByType(name) > 0 then
buildings = buildings + 1
end
end)
return buildings == #GDIBaseBuildings
end
SendReinforcements = function()
Trigger.AfterDelay(DateTime.Seconds(20), function()
ReinforceWithLandingCraft(BaseReinforcements, spawnpoint3.Location - CVec.New(0, -4), spawnpoint3.Location - CVec.New(0, -1), waypoint26.Location)
ReinforceWithLandingCraft(GDI, BaseReinforcements, spawnpoint3.Location - CVec.New(0, -4), spawnpoint3.Location - CVec.New(0, -1), waypoint26.Location)
end)
Trigger.AfterDelay(DateTime.Seconds(10), function()
ReinforceWithLandingCraft(TankReinforcements, spawnpoint2.Location - CVec.New(0, -4), spawnpoint2.Location - CVec.New(0, -1), waypoint10.Location)
ReinforceWithLandingCraft(TankReinforcements, spawnpoint3.Location - CVec.New(0, -4), spawnpoint3.Location - CVec.New(0, -1), waypoint10.Location)
ReinforceWithLandingCraft(GDI, TankReinforcements, spawnpoint2.Location - CVec.New(0, -4), spawnpoint2.Location - CVec.New(0, -1), waypoint10.Location)
ReinforceWithLandingCraft(GDI, TankReinforcements, spawnpoint3.Location - CVec.New(0, -4), spawnpoint3.Location - CVec.New(0, -1), waypoint10.Location)
end)
Trigger.AfterDelay(DateTime.Seconds(5), function()
ReinforceWithLandingCraft(JeepReinforcements, spawnpoint1.Location - CVec.New(0, -4), spawnpoint1.Location - CVec.New(0, -1), waypoint10.Location)
ReinforceWithLandingCraft(GDI, JeepReinforcements, spawnpoint1.Location - CVec.New(0, -4), spawnpoint1.Location - CVec.New(0, -1), waypoint10.Location)
end)
ReinforceWithLandingCraft(InfantryReinforcements, spawnpoint2.Location - CVec.New(0, -4), spawnpoint2.Location - CVec.New(0, -1), waypoint10.Location)
ReinforceWithLandingCraft(InfantryReinforcements, spawnpoint3.Location - CVec.New(0, -4), spawnpoint3.Location - CVec.New(0, -1), waypoint10.Location)
ReinforceWithLandingCraft(GDI, InfantryReinforcements, spawnpoint2.Location - CVec.New(0, -4), spawnpoint2.Location - CVec.New(0, -1), waypoint10.Location)
ReinforceWithLandingCraft(GDI, InfantryReinforcements, spawnpoint3.Location - CVec.New(0, -4), spawnpoint3.Location - CVec.New(0, -1), waypoint10.Location)
end
AttackPlayer = function()
Trigger.AfterDelay(DateTime.Seconds(40), function()
for type, count in pairs({ ['e3'] = 3, ['e4'] = 2 }) do
atk1Actors = Utils.Take(count, Nod.GetActorsByType(type))
@@ -145,16 +103,11 @@ AttackPlayer = function()
Utils.Do(NodBase, function(actor)
Trigger.OnRemovedFromWorld(actor, function()
Utils.Do(Nod.GetGroundAttackers(Nod), function(unit)
unit.Hunt()
end)
Utils.Do(Nod.GetGroundAttackers(Nod), IdleHunt)
end)
end)
Utils.Do(HiddenNodUnits, function(actor)
actor.Hunt()
end)
Utils.Do(HiddenNodUnits, IdleHunt)
end
WorldLoaded = function()
@@ -163,35 +116,16 @@ WorldLoaded = function()
Camera.Position = spawnpoint2.CenterPosition
Trigger.OnObjectiveAdded(GDI, function(p, id)
Media.DisplayMessage(p.GetObjectiveDescription(id), "New " .. string.lower(p.GetObjectiveType(id)) .. " objective")
end)
InitObjectives(GDI)
Trigger.OnObjectiveCompleted(GDI, function(p, id)
Media.DisplayMessage(p.GetObjectiveDescription(id), "Objective completed")
end)
Trigger.OnObjectiveFailed(GDI, function(p, id)
Media.DisplayMessage(p.GetObjectiveDescription(id), "Objective failed")
end)
Trigger.OnPlayerWon(GDI, function()
Media.PlaySpeechNotification(Nod, "Win")
end)
Trigger.OnPlayerLost(GDI, function()
Media.PlaySpeechNotification(Nod, "Lose")
end)
gdiMainObjective = GDI.AddPrimaryObjective("Destroy remaining Nod structures and units.")
gdiBaseObjective = GDI.AddSecondaryObjective("Construct all available buildings.")
nodObjective = Nod.AddPrimaryObjective("Kill all enemies!")
DestroyNod = GDI.AddObjective("Destroy remaining Nod structures and units.")
ConstructBase = GDI.AddObjective("Construct all available buildings.", "Secondary", false)
SendReinforcements()
gdiAirSupportObjective = GDI.AddSecondaryObjective("Destroy the SAM sites to receive air support.")
local destroySAMs = GDI.AddSecondaryObjective("Destroy the SAM sites to receive air support.")
Trigger.OnAllKilled(SamSites, function()
GDI.MarkCompletedObjective(gdiAirSupportObjective)
GDI.MarkCompletedObjective(destroySAMs)
Actor.Create("airstrike.proxy", true, { Owner = GDI })
end)
@@ -201,13 +135,15 @@ end
Tick = function()
if DateTime.GameTime > DateTime.Seconds(5) then
if GDI.HasNoRequiredUnits() then
Nod.MarkCompletedObjective(nodObjective)
GDI.MarkFailedObjective(DestroyNod)
end
if Nod.HasNoRequiredUnits() then
GDI.MarkCompletedObjective(gdiMainObjective)
GDI.MarkCompletedObjective(DestroyNod)
end
if not GDI.IsObjectiveCompleted(gdiBaseObjective) and DateTime.GameTime % DateTime.Seconds(1) == 0 and CheckForBase() then
GDI.MarkCompletedObjective(gdiBaseObjective)
if not GDI.IsObjectiveCompleted(ConstructBase) and DateTime.GameTime % DateTime.Seconds(1) == 0 and CheckForBase(GDI, GDIBaseBuildings) then
GDI.MarkCompletedObjective(ConstructBase)
end
end
end