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.
|
||||
]]
|
||||
|
||||
IslandSamSites = { SAM01, SAM02 }
|
||||
NodBase = { PowerPlant1, PowerPlant2, PowerPlant3, PowerPlant4, PowerPlant5, Refinery, HandOfNod, Silo1, Silo2, Silo3, Silo4, ConYard, CommCenter }
|
||||
|
||||
@@ -13,7 +14,8 @@ FlameSquad = { FlameGuy1, FlameGuy2, FlameGuy3 }
|
||||
FlameSquadRoute = { waypoint4.Location, waypoint12.Location, waypoint4.Location, waypoint6.Location }
|
||||
|
||||
FootPatrol1Squad = { MiniGunner1, MiniGunner2, RocketSoldier1 }
|
||||
FootPatrol1Route = {
|
||||
FootPatrol1Route =
|
||||
{
|
||||
waypoint4.Location,
|
||||
waypoint12.Location,
|
||||
waypoint13.Location,
|
||||
@@ -24,24 +26,28 @@ FootPatrol1Route = {
|
||||
}
|
||||
|
||||
FootPatrol2Squad = { MiniGunner3, MiniGunner4 }
|
||||
FootPatrol2Route = {
|
||||
FootPatrol2Route =
|
||||
{
|
||||
waypoint14.Location,
|
||||
waypoint16.Location
|
||||
}
|
||||
|
||||
FootPatrol3Squad = { MiniGunner5, MiniGunner6 }
|
||||
FootPatrol3Route = {
|
||||
FootPatrol3Route =
|
||||
{
|
||||
waypoint15.Location,
|
||||
waypoint17.Location
|
||||
}
|
||||
|
||||
FootPatrol4Route = {
|
||||
FootPatrol4Route =
|
||||
{
|
||||
waypoint4.Location,
|
||||
waypoint5.Location
|
||||
}
|
||||
|
||||
FootPatrol5Squad = { RocketSoldier2, RocketSoldier3, RocketSoldier4 }
|
||||
FootPatrol5Route = {
|
||||
FootPatrol5Route =
|
||||
{
|
||||
waypoint4.Location,
|
||||
waypoint12.Location,
|
||||
waypoint13.Location,
|
||||
@@ -49,7 +55,8 @@ FootPatrol5Route = {
|
||||
waypoint9.Location,
|
||||
}
|
||||
|
||||
Buggy1Route = {
|
||||
Buggy1Route =
|
||||
{
|
||||
waypoint6.Location,
|
||||
waypoint7.Location,
|
||||
waypoint2.Location,
|
||||
@@ -60,7 +67,8 @@ Buggy1Route = {
|
||||
waypoint7.Location
|
||||
}
|
||||
|
||||
Buggy2Route = {
|
||||
Buggy2Route =
|
||||
{
|
||||
waypoint6.Location,
|
||||
waypoint10.Location,
|
||||
waypoint11.Location,
|
||||
@@ -75,32 +83,15 @@ AttackUnits = { LightTank2, LightTank3 }
|
||||
KillCounter = 0
|
||||
|
||||
WorldLoaded = function()
|
||||
player = Player.GetPlayer("GDI")
|
||||
enemy = Player.GetPlayer("Nod")
|
||||
civilian = Player.GetPlayer("Neutral")
|
||||
GDI = Player.GetPlayer("GDI")
|
||||
Nod = Player.GetPlayer("Nod")
|
||||
|
||||
Trigger.OnObjectiveAdded(player, function(p, id)
|
||||
Media.DisplayMessage(p.GetObjectiveDescription(id), "New " .. string.lower(p.GetObjectiveType(id)) .. " objective")
|
||||
end)
|
||||
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)
|
||||
InitObjectives(GDI)
|
||||
|
||||
Trigger.OnPlayerWon(player, function()
|
||||
Media.PlaySpeechNotification(player, "Win")
|
||||
end)
|
||||
|
||||
Trigger.OnPlayerLost(player, function()
|
||||
Media.PlaySpeechNotification(player, "Lose")
|
||||
end)
|
||||
|
||||
if Map.LobbyOption("difficulty") == "easy" then
|
||||
if Difficulty == "easy" then
|
||||
CommandoType = "rmbo.easy"
|
||||
KillCounterHuntThreshold = 30
|
||||
elseif Map.LobbyOption("difficulty") == "hard" then
|
||||
elseif Difficulty == "hard" then
|
||||
CommandoType = "rmbo.hard"
|
||||
KillCounterHuntThreshold = 15
|
||||
else
|
||||
@@ -108,21 +99,21 @@ WorldLoaded = function()
|
||||
KillCounterHuntThreshold = 20
|
||||
end
|
||||
|
||||
destroyObjective = player.AddPrimaryObjective("Destroy the Nod ********.")
|
||||
DestroyObjective = GDI.AddObjective("Destroy the Nod ********.")
|
||||
|
||||
Trigger.OnKilled(Airfield, function()
|
||||
player.MarkCompletedObjective(destroyObjective)
|
||||
GDI.MarkCompletedObjective(DestroyObjective)
|
||||
end)
|
||||
|
||||
Utils.Do(NodBase, function(structure)
|
||||
Trigger.OnKilled(structure, function()
|
||||
player.MarkCompletedObjective(destroyObjective)
|
||||
GDI.MarkCompletedObjective(DestroyObjective)
|
||||
end)
|
||||
end)
|
||||
|
||||
Trigger.OnAllKilled(IslandSamSites, function()
|
||||
TransportFlare = Actor.Create('flare', true, { Owner = player, Location = Flare.Location })
|
||||
Reinforcements.ReinforceWithTransport(player, 'tran', nil, { lstStart.Location, TransportRally.Location })
|
||||
TransportFlare = Actor.Create('flare', true, { Owner = GDI, Location = Flare.Location })
|
||||
Reinforcements.ReinforceWithTransport(GDI, 'tran', nil, { lstStart.Location, TransportRally.Location })
|
||||
end)
|
||||
|
||||
Trigger.OnKilled(CivFleeTrigger, function()
|
||||
@@ -140,7 +131,7 @@ WorldLoaded = function()
|
||||
end)
|
||||
|
||||
Trigger.OnEnteredFootprint(AttackCellTriggerActivator, function(a, id)
|
||||
if a.Owner == player then
|
||||
if a.Owner == GDI then
|
||||
Utils.Do(AttackUnits, function(unit)
|
||||
if not unit.IsDead then
|
||||
unit.AttackMove(waypoint10.Location)
|
||||
@@ -151,10 +142,21 @@ WorldLoaded = function()
|
||||
end)
|
||||
|
||||
Utils.Do(HuntTriggerActivator, function(unit)
|
||||
Trigger.OnDamaged(unit, HuntTriggerFunction)
|
||||
Trigger.OnDamaged(unit, function()
|
||||
Utils.Do(Nod.GetGroundAttackers(), IdleHunt)
|
||||
end)
|
||||
end)
|
||||
|
||||
Trigger.AfterDelay(5, NodKillCounter)
|
||||
Trigger.AfterDelay(5, function()
|
||||
Utils.Do(Nod.GetGroundAttackers(), function(unit)
|
||||
Trigger.OnKilled(unit, function()
|
||||
KillCounter = KillCounter + 1
|
||||
if KillCounter >= KillCounterHuntThreshold then
|
||||
Utils.Do(Nod.GetGroundAttackers(), IdleHunt)
|
||||
end
|
||||
end)
|
||||
end)
|
||||
end)
|
||||
|
||||
Utils.Do(FootPatrol1Squad, function(unit)
|
||||
unit.Patrol(FootPatrol1Route, true)
|
||||
@@ -178,68 +180,12 @@ WorldLoaded = function()
|
||||
Buggy2.Patrol(Buggy2Route, true, 25)
|
||||
|
||||
Camera.Position = UnitsRally.CenterPosition
|
||||
Reinforce({ CommandoType })
|
||||
Media.PlaySpeechNotification(GDI, "Reinforce")
|
||||
ReinforceWithLandingCraft(GDI, { CommandoType }, lstStart.Location, lstEnd.Location, UnitsRally.Location)
|
||||
end
|
||||
|
||||
Tick = function()
|
||||
if DateTime.GameTime > DateTime.Seconds(5) and player.HasNoRequiredUnits() then
|
||||
player.MarkFailedObjective(destroyObjective)
|
||||
end
|
||||
end
|
||||
|
||||
Reinforce = function(units)
|
||||
Media.PlaySpeechNotification(player, "Reinforce")
|
||||
ReinforceWithLandingCraft(units, lstStart.Location, lstEnd.Location, UnitsRally.Location)
|
||||
end
|
||||
|
||||
ReinforceWithLandingCraft = function(units, transportStart, transportUnload, rallypoint)
|
||||
local transport = Actor.Create("oldlst", true, { Owner = player, 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)
|
||||
|
||||
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
|
||||
|
||||
NodKillCounter = function()
|
||||
local enemyUnits = enemy.GetGroundAttackers()
|
||||
Utils.Do(enemyUnits, function(unit)
|
||||
Trigger.OnKilled(unit, function()
|
||||
KillCounter = KillCounter + 1
|
||||
if KillCounter >= KillCounterHuntThreshold then
|
||||
HuntTriggerFunction()
|
||||
end
|
||||
end)
|
||||
end)
|
||||
end
|
||||
|
||||
HuntTriggerFunction = function()
|
||||
local list = enemy.GetGroundAttackers()
|
||||
Utils.Do(list, function(unit)
|
||||
IdleHunt(unit)
|
||||
end)
|
||||
end
|
||||
|
||||
IdleHunt = function(unit)
|
||||
if not unit.IsDead then
|
||||
Trigger.OnIdle(unit, unit.Hunt)
|
||||
if DateTime.GameTime > DateTime.Seconds(5) and GDI.HasNoRequiredUnits() then
|
||||
GDI.MarkFailedObjective(DestroyObjective)
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user