-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
/
nod01.lua
88 lines (73 loc) · 3.07 KB
/
nod01.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
InitialForcesA = { "bggy", "e1", "e1", "e1", "e1" }
InitialForcesB = { "e1", "e1", "bggy", "e1", "e1" }
RifleInfantryReinforcements = { "e1", "e1" }
RocketInfantryReinforcements = { "e3", "e3", "e3", "e3", "e3" }
SendInitialForces = function()
Media.PlaySpeechNotification(nod, "Reinforce")
Reinforcements.Reinforce(nod, InitialForcesA, { StartSpawnPointLeft.Location, StartRallyPoint.Location }, 5)
Reinforcements.Reinforce(nod, InitialForcesB, { StartSpawnPointRight.Location, StartRallyPoint.Location }, 10)
end
SendFirstInfantryReinforcements = function()
Media.PlaySpeechNotification(nod, "Reinforce")
Reinforcements.Reinforce(nod, RifleInfantryReinforcements, { StartSpawnPointRight.Location, StartRallyPoint.Location }, 15)
end
SendSecondInfantryReinforcements = function()
Media.PlaySpeechNotification(nod, "Reinforce")
Reinforcements.Reinforce(nod, RifleInfantryReinforcements, { StartSpawnPointLeft.Location, StartRallyPoint.Location }, 15)
end
SendLastInfantryReinforcements = function()
Media.PlaySpeechNotification(nod, "Reinforce")
-- Move the units properly into the map before they start attacking
local forces = Reinforcements.Reinforce(nod, RocketInfantryReinforcements, { VillageSpawnPoint.Location, VillageRallyPoint.Location }, 8)
Utils.Do(forces, function(a)
a.Stance = "Defend"
a.CallFunc(function() a.Stance = "AttackAnything" end)
end)
end
WorldLoaded = function()
nod = Player.GetPlayer("Nod")
gdi = Player.GetPlayer("GDI")
villagers = Player.GetPlayer("Villagers")
Trigger.OnObjectiveAdded(nod, function(p, id)
Media.DisplayMessage(p.GetObjectiveDescription(id), "New " .. string.lower(p.GetObjectiveType(id)) .. " objective")
end)
Trigger.OnObjectiveCompleted(nod, function(p, id)
Media.DisplayMessage(p.GetObjectiveDescription(id), "Objective completed")
end)
Trigger.OnObjectiveFailed(nod, function(p, id)
Media.DisplayMessage(p.GetObjectiveDescription(id), "Objective failed")
end)
Trigger.OnPlayerWon(nod, function()
Media.PlaySpeechNotification(nod, "Win")
end)
Trigger.OnPlayerLost(nod, function()
Media.PlaySpeechNotification(nod, "Lose")
end)
NodObjective1 = nod.AddPrimaryObjective("Kill Nikoomba.")
NodObjective2 = nod.AddPrimaryObjective("Destroy the village.")
NodObjective3 = nod.AddSecondaryObjective("Destroy all GDI troops in the area.")
GDIObjective1 = gdi.AddPrimaryObjective("Eliminate all Nod forces.")
Trigger.OnKilled(Nikoomba, function()
nod.MarkCompletedObjective(NodObjective1)
Trigger.AfterDelay(DateTime.Seconds(1), function()
SendLastInfantryReinforcements()
end)
end)
Camera.Position = StartRallyPoint.CenterPosition
SendInitialForces()
Trigger.AfterDelay(DateTime.Seconds(30), SendFirstInfantryReinforcements)
Trigger.AfterDelay(DateTime.Seconds(60), SendSecondInfantryReinforcements)
end
Tick = function()
if DateTime.GameTime > 2 then
if nod.HasNoRequiredUnits() then
gdi.MarkCompletedObjective(GDIObjective1)
end
if villagers.HasNoRequiredUnits() then
nod.MarkCompletedObjective(NodObjective2)
end
if gdi.HasNoRequiredUnits() then
nod.MarkCompletedObjective(NodObjective3)
end
end
end