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.
]]
NodStartUnitsRight =
{
tough = { 'ltnk', 'bike', 'e1', 'e1', 'e3', 'e3' },
@@ -13,6 +14,7 @@ NodStartUnitsRight =
normal = { 'ltnk', 'bike', 'bike', 'e1', 'e1', 'e1', 'e3', 'e3', 'e3', 'e3' },
easy = { 'ltnk', 'ltnk', 'bike', 'bike', 'e1', 'e1', 'e1', 'e1', 'e3', 'e3', 'e3', 'e3' }
}
NodStartUnitsLeft =
{
tough = { 'ltnk', 'ltnk', 'bggy', 'e1', 'e1', 'e1', 'e3', 'e3', 'e3' },
@@ -20,21 +22,22 @@ NodStartUnitsLeft =
normal = { 'ltnk', 'ltnk', 'bggy', 'bggy', 'e1', 'e1', 'e1', 'e1', 'e3', 'e3', 'e3', 'e3', 'e3' },
easy = { 'ltnk', 'ltnk', 'ltnk', 'bggy', 'e1', 'e1', 'e1', 'e1', 'e1', 'e1', 'e3', 'e3', 'e3', 'e3', 'e3' }
}
Chn1Units = { 'e1', 'e1', 'e1', 'e1', 'e1' }
Chn2Units = { 'e2', 'e2', 'e2', 'e2', 'e2' }
Obj2Units = { 'ltnk', 'bike', 'e1', 'e1', 'e1' }
Chn3CellTriggerActivator = { CPos.New(49,58), CPos.New(48,58), CPos.New(49,57), CPos.New(48,57), CPos.New(49,56), CPos.New(48,56), CPos.New(49,55), CPos.New(48,55) }
DzneCellTriggerActivator = { CPos.New(61,45), CPos.New(60,45), CPos.New(59,45), CPos.New(58,45), CPos.New(57,45), CPos.New(61,44), CPos.New(60,44), CPos.New(59,44), CPos.New(58,44), CPos.New(57,44), CPos.New(61,43), CPos.New(60,43), CPos.New(58,43), CPos.New(57,43), CPos.New(61,42), CPos.New(60,42), CPos.New(59,42), CPos.New(58,42), CPos.New(57,42), CPos.New(61,41), CPos.New(60,41), CPos.New(59,41), CPos.New(58,41), CPos.New(57,41) }
Win1CellTriggerActivator = { CPos.New(59,43) }
Win2CellTriggerActivator = { CPos.New(54,58), CPos.New(53,58), CPos.New(52,58), CPos.New(54,57), CPos.New(53,57), CPos.New(52,57), CPos.New(54,56), CPos.New(53,56), CPos.New(52,56), CPos.New(54,55), CPos.New(53,55), CPos.New(52,55) }
DetonatorArea = { CPos.New(59,43) }
EvacuationArea = { CPos.New(54,58), CPos.New(53,58), CPos.New(52,58), CPos.New(54,57), CPos.New(53,57), CPos.New(52,57), CPos.New(54,56), CPos.New(53,56), CPos.New(52,56), CPos.New(54,55), CPos.New(53,55), CPos.New(52,55) }
Grd2ActorTriggerActivator = { Guard1, Guard2, Guard3 }
Atk1ActorTriggerActivator = { Atk1Activator1, Atk1Activator2 }
Atk2ActorTriggerActivator = { Atk2Activator1, Atk2Activator2 }
Chn1ActorTriggerActivator = { Chn1Activator1, Chn1Activator2, Chn1Activator3, Chn1Activator4, Chn1Activator5 }
Chn2ActorTriggerActivator = { Chn2Activator1, Chn2Activator2, Chn2Activator3 }
Obj2ActorTriggerActivator = { Chn1Activator1, Chn1Activator2, Chn1Activator3, Chn1Activator4, Chn1Activator5, Chn2Activator1, Chn2Activator2, Chn2Activator3, Atk3Activator }
GDIVillage = { Chn1Activator1, Chn1Activator2, Chn1Activator3, Chn1Activator4, Chn1Activator5, Chn2Activator1, Chn2Activator2, Chn2Activator3, Atk3Activator }
Chn1Waypoints = { ChnEntry.Location, waypoint5.Location }
Chn2Waypoints = { ChnEntry.Location, waypoint6.Location }
@@ -43,22 +46,10 @@ Gdi4Waypoints = { waypoint4, waypoint10, waypoint9, waypoint11, waypoint9, waypo
Gdi5Waypoints = { waypoint1, waypoint4 }
Gdi6Waypoints = { waypoint2, waypoints3 }
Grd1TriggerFunctionTime = DateTime.Seconds(3)
Grd1TriggerFunction = function()
MyActors = Utils.Take(2, enemy.GetActorsByType('mtnk'))
Utils.Do(MyActors, function(actor)
MovementAndHunt(actor, Gdi3Waypoints)
end)
end
Grd2TriggerFunction = function()
if not Grd2Switch then
for type, count in pairs({ ['e1'] = 2, ['e2'] = 1, ['jeep'] = 1 }) do
MyActors = Utils.Take(count, enemy.GetActorsByType(type))
Utils.Do(MyActors, function(actor)
MovementAndHunt(actor, Gdi4Waypoints)
end)
MoveAndHunt(Utils.Take(count, GDI.GetActorsByType(type)), Gdi4Waypoints)
end
Grd2Swicth = true
end
@@ -67,10 +58,7 @@ end
Atk1TriggerFunction = function()
if not Atk1Switch then
for type, count in pairs({ ['e1'] = 3, ['e2'] = 3, ['jeep'] = 1 }) do
MyActors = Utils.Take(count, enemy.GetActorsByType(type))
Utils.Do(MyActors, function(actor)
MovementAndHunt(actor, Gdi5Waypoints)
end)
MoveAndHunt(Utils.Take(count, GDI.GetActorsByType(type)), Gdi5Waypoints)
end
Atk1Switch = true
end
@@ -79,10 +67,7 @@ end
Atk2TriggerFunction = function()
if not Atk2Switch then
for type, count in pairs({ ['mtnk'] = 1, ['jeep'] = 1 }) do
MyActors = Utils.Take(count, enemy.GetActorsByType(type))
Utils.Do(MyActors, function(actor)
MovementAndHunt(actor, Gdi6Waypoints)
end)
MoveAndHunt(Utils.Take(count, GDI.GetActorsByType(type)), Gdi6Waypoints)
end
Atk2Switch = true
end
@@ -92,7 +77,7 @@ Atk3TriggerFunction = function()
if not Atk3Switch then
Atk3Switch = true
if not CommCenter.IsDead then
local targets = player.GetGroundAttackers()
local targets = Nod.GetGroundAttackers()
local target = targets[DateTime.GameTime % #targets + 1].CenterPosition
if target then
@@ -102,143 +87,101 @@ Atk3TriggerFunction = function()
end
end
Chn1TriggerFunction = function()
local cargo = Reinforcements.ReinforceWithTransport(enemy, 'tran', Chn1Units, Chn1Waypoints, { waypoint14.Location })[2]
Utils.Do(cargo, function(actor)
IdleHunt(actor)
end)
end
Chn2TriggerFunction = function()
local cargo = Reinforcements.ReinforceWithTransport(enemy, 'tran', Chn2Units, Chn2Waypoints, { waypoint14.Location })[2]
Utils.Do(cargo, function(actor)
IdleHunt(actor)
end)
end
Obj2TriggerFunction = function()
player.MarkCompletedObjective(NodObjective2)
Media.PlaySpeechNotification(player, "Reinforce")
Reinforcements.Reinforce(player, Obj2Units, { Obj2UnitsEntry.Location, waypoint13.Location }, 15)
end
MovementAndHunt = function(unit, waypoints)
if unit ~= nil then
Utils.Do(waypoints, function(waypoint)
unit.AttackMove(waypoint.Location)
end)
IdleHunt(unit)
end
end
InsertNodUnits = function()
local difficulty = Map.LobbyOption("difficulty")
NodStartUnitsRight = NodStartUnitsRight[difficulty]
NodStartUnitsLeft = NodStartUnitsLeft[difficulty]
NodStartUnitsRight = NodStartUnitsRight[Difficulty]
NodStartUnitsLeft = NodStartUnitsLeft[Difficulty]
Camera.Position = UnitsRallyRight.CenterPosition
Media.PlaySpeechNotification(player, "Reinforce")
Reinforcements.Reinforce(player, NodStartUnitsLeft, { UnitsEntryLeft.Location, UnitsRallyLeft.Location }, 15)
Reinforcements.Reinforce(player, NodStartUnitsRight, { UnitsEntryRight.Location, UnitsRallyRight.Location }, 15)
Media.PlaySpeechNotification(Nod, "Reinforce")
Reinforcements.Reinforce(Nod, NodStartUnitsLeft, { UnitsEntryLeft.Location, UnitsRallyLeft.Location }, 15)
Reinforcements.Reinforce(Nod, NodStartUnitsRight, { UnitsEntryRight.Location, UnitsRallyRight.Location }, 15)
end
WorldLoaded = function()
player = Player.GetPlayer("Nod")
enemy = Player.GetPlayer("GDI")
Nod = Player.GetPlayer("Nod")
GDI = Player.GetPlayer("GDI")
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("Steal the GDI nuclear detonator.")
NodObjective2 = player.AddSecondaryObjective("Destroy the houses of the GDI supporters\nin the village.")
GDIObjective = enemy.AddPrimaryObjective("Stop the Nod taskforce from escaping with the detonator.")
StealDetonator = Nod.AddObjective("Steal the GDI nuclear detonator.")
DestroyVillage = Nod.AddObjective("Destroy the houses of the GDI supporters\nin the village.", "Secondary", false)
InsertNodUnits()
Trigger.AfterDelay(Grd1TriggerFunctionTime, Grd1TriggerFunction)
Trigger.AfterDelay(DateTime.Seconds(3), function()
MoveAndHunt(Utils.Take(2, GDI.GetActorsByType("mtnk")), Gdi3Waypoints)
end)
Utils.Do(Grd2ActorTriggerActivator, function(actor)
Trigger.OnDiscovered(actor, Grd2TriggerFunction)
end)
OnAnyDamaged(Atk1ActorTriggerActivator, Atk1TriggerFunction)
Utils.Do(Atk1ActorTriggerActivator, function(actor)
Trigger.OnDamaged(actor, Atk1TriggerFunction)
end)
OnAnyDamaged(Atk2ActorTriggerActivator, Atk2TriggerFunction)
Utils.Do(Atk2ActorTriggerActivator, function(actor)
Trigger.OnDamaged(actor, Atk2TriggerFunction)
end)
if Map.LobbyOption("difficulty") == "tough" then
if Difficulty == "tough" then
Trigger.OnDamaged(Atk3Activator, Atk3TriggerFunction)
end
Trigger.OnAllKilled(Chn1ActorTriggerActivator, Chn1TriggerFunction)
Trigger.OnAllKilled(Chn1ActorTriggerActivator, function()
local cargo = Reinforcements.ReinforceWithTransport(GDI, 'tran', Chn1Units, Chn1Waypoints, { waypoint14.Location })[2]
Utils.Do(cargo, IdleHunt)
end)
Trigger.OnAllKilled(Chn2ActorTriggerActivator, Chn2TriggerFunction)
Trigger.OnAllKilled(Chn2ActorTriggerActivator, function()
local cargo = Reinforcements.ReinforceWithTransport(GDI, 'tran', Chn2Units, Chn2Waypoints, { waypoint14.Location })[2]
Utils.Do(cargo, IdleHunt)
end)
Trigger.OnEnteredFootprint(Chn3CellTriggerActivator, function(a, id)
if a.Owner == player then
Media.PlaySpeechNotification(player, "Reinforce")
Reinforcements.ReinforceWithTransport(player, 'tran', nil, { ChnEntry.Location, waypoint17.Location }, nil, nil, nil)
if a.Owner == Nod then
Media.PlaySpeechNotification(Nod, "Reinforce")
Reinforcements.ReinforceWithTransport(Nod, 'tran', nil, { ChnEntry.Location, waypoint17.Location })
Trigger.RemoveFootprintTrigger(id)
end
end)
Trigger.OnEnteredFootprint(DzneCellTriggerActivator, function(a, id)
if a.Owner == player then
Actor.Create('flare', true, { Owner = player, Location = waypoint17.Location })
if a.Owner == Nod then
Actor.Create('flare', true, { Owner = Nod, Location = waypoint17.Location })
Trigger.RemoveFootprintTrigger(id)
end
end)
Trigger.OnAllRemovedFromWorld(Obj2ActorTriggerActivator, Obj2TriggerFunction)
Trigger.OnAllRemovedFromWorld(GDIVillage, function()
Nod.MarkCompletedObjective(DestroyVillage)
Media.PlaySpeechNotification(Nod, "Reinforce")
Reinforcements.Reinforce(Nod, Obj2Units, { Obj2UnitsEntry.Location, waypoint13.Location }, 15)
end)
Trigger.OnEnteredFootprint(Win1CellTriggerActivator, function(a, id)
if a.Owner == player then
NodObjective3 = player.AddPrimaryObjective("Move to the evacuation point.")
player.MarkCompletedObjective(NodObjective1)
Trigger.OnEnteredFootprint(DetonatorArea, function(a, id)
if a.Owner == Nod then
EvacuateObjective = Nod.AddObjective("Move to the evacuation point.")
Nod.MarkCompletedObjective(StealDetonator)
Trigger.RemoveFootprintTrigger(id)
end
end)
Trigger.OnEnteredFootprint(Win2CellTriggerActivator, function(a, id)
if a.Owner == player and NodObjective3 then
player.MarkCompletedObjective(NodObjective3)
Trigger.OnEnteredFootprint(EvacuationArea, function(a, id)
if a.Owner == Nod and EvacuateObjective then
Nod.MarkCompletedObjective(EvacuateObjective)
Trigger.RemoveFootprintTrigger(id)
end
end)
end
Tick = function()
if DateTime.GameTime > 2 and player.HasNoRequiredUnits() then
enemy.MarkCompletedObjective(GDIObjective)
if DateTime.GameTime > 2 and Nod.HasNoRequiredUnits() then
Nod.MarkFailedObjective(StealDetonator)
if EvacuateObjective then
Nod.MarkFailedObjective(EvacuateObjective)
end
end
end
IdleHunt = function(unit)
if not unit.IsDead then
Trigger.OnIdle(unit, unit.Hunt)
end
end
OnAnyDamaged = function(actors, func)
Utils.Do(actors, function(actor)
Trigger.OnDamaged(actor, func)
end)
end