1 | var cmpTrigger = Engine.QueryInterface(SYSTEM_ENTITY, IID_Trigger);
|
---|
2 |
|
---|
3 | // define some globally accessible variables
|
---|
4 | g_Triggers.movingTutorial1Completed = false;
|
---|
5 | g_Triggers.movingTutorial2Completed = false;
|
---|
6 | g_Triggers.gatheringFruitComepleted = false;
|
---|
7 | g_Triggers.gatheringTreeComepleted = false;
|
---|
8 | g_Triggers.gatheringStoneComepleted = false;
|
---|
9 | g_Triggers.gatheringMetalComepleted = false;
|
---|
10 | g_Triggers.gatheringTreasureComepleted = false;
|
---|
11 | g_Triggers.exploredTerrain = false;
|
---|
12 | g_Triggers.movingTutorial2EntitiesOrdered = 0;
|
---|
13 |
|
---|
14 | ////////////////////////////////////////////////////////////////////////////////
|
---|
15 | // Function defenitions //
|
---|
16 | ////////////////////////////////////////////////////////////////////////////////
|
---|
17 |
|
---|
18 | // Thse actions set the next stage of the tutorial after the player has successfully done the previous ones
|
---|
19 | g_Triggers.HandleOrders = function(data)
|
---|
20 | {
|
---|
21 | if (data.order == "Order.Walk" || data.order == "Order.FormationWalk")
|
---|
22 | g_Triggers.PlayerMovedAUnit(data);
|
---|
23 | else if (data.order == "Order.Gather")
|
---|
24 | {
|
---|
25 | var type = GetEntityResourceType(data.target);
|
---|
26 | if (!type)
|
---|
27 | return;
|
---|
28 | else if (type.specific == "fruit")
|
---|
29 | g_Triggers.UnitOrderedToGatherFruit(data);
|
---|
30 | else if (type.specific == "tree")
|
---|
31 | g_Triggers.UnitOrderedToGatherTree(data);
|
---|
32 | else if (type.specific == "rock")
|
---|
33 | g_Triggers.UnitOrderedToGatherStoneQuarry(data);
|
---|
34 | else if (type.specific == "ore")
|
---|
35 | g_Triggers.UnitOrderedToGatherMetalMine(data);
|
---|
36 | else if (type.generic == "treasure")
|
---|
37 | g_Triggers.UnitOrderedToGatherTreasure(data);
|
---|
38 | }
|
---|
39 | }
|
---|
40 | cmpTrigger.RegisterTrigger("OnUnitIssuedOrder", "HandleOrders");
|
---|
41 |
|
---|
42 | // These actions control the tutorials in which the player has no interactin with.
|
---|
43 | cmpTrigger.DoAfterDelay(1000, "WelcomeMessage", {});
|
---|
44 | g_Triggers.WelcomeMessage = function(data)
|
---|
45 | {
|
---|
46 | PushNotification(1, "Welcome to the basic tutorial of the 0 A.D.!");
|
---|
47 | cmpTrigger.DoAfterDelay(3000, "IntroductionMessage", {});
|
---|
48 | }
|
---|
49 |
|
---|
50 | g_Triggers.IntroductionMessage = function(data)
|
---|
51 | {
|
---|
52 | PushNotification([1], "In this tutorial you will learn the basics of the gameplay of 0 A.D.");
|
---|
53 | cmpTrigger.DoAfterDelay(6000, "CameraMovementTutorial1", {});
|
---|
54 | }
|
---|
55 |
|
---|
56 | g_Triggers.CameraMovementTutorial1 = function(data)
|
---|
57 | {
|
---|
58 | PushNotification([1], "First, we try the camera movements. To move your camera, move the mouse pointer to the edge of the screen.");
|
---|
59 | cmpTrigger.DoAfterDelay(8000, "CameraMovementTutorial2", {});
|
---|
60 | }
|
---|
61 |
|
---|
62 | g_Triggers.CameraMovementTutorial2 = function(data)
|
---|
63 | {
|
---|
64 | PushNotification([1], "You can also move the camera using W,A,S,D or arrow keys on the keyboard, or by holding the middle mouse button and moving it.");
|
---|
65 | cmpTrigger.DoAfterDelay(12000, "CameraMovementTutorial3", {});
|
---|
66 | }
|
---|
67 |
|
---|
68 | g_Triggers.CameraMovementTutorial3 = function(data)
|
---|
69 | {
|
---|
70 | PushNotification([1], "To rotate the camera, hold Ctrl and one of the arrow keys.");
|
---|
71 | cmpTrigger.DoAfterDelay(7000, "IntroductionToUnits", {});
|
---|
72 | }
|
---|
73 |
|
---|
74 | // MOVING
|
---|
75 | // This one is called when the player moves a unit.
|
---|
76 | g_Triggers.PlayerMovedAUnit = function(data)
|
---|
77 | {
|
---|
78 | if (!g_Triggers.movingTutorial1Completed)
|
---|
79 | {
|
---|
80 | g_Triggers.movingTutorial1Completed = true;
|
---|
81 | PushNotification([1], "Good. You can also select a group of units by holding the left mouse button and dragging it. Select a group of units and order them to move.");
|
---|
82 | cmpTrigger.DoAfterDelay(12000, "MovingAGroupOfUnitsTutorial");
|
---|
83 | }
|
---|
84 | else if (!g_Triggers.movingTutorial2Completed)
|
---|
85 | {
|
---|
86 | ++g_Triggers.movingTutorial2EntitiesOrdered;
|
---|
87 | if (g_Triggers.movingTutorial2EntitiesOrdered >= 2)
|
---|
88 | {
|
---|
89 | g_Triggers.movingTutorial2Completed = true;
|
---|
90 | PushNotification([1], "Very Good.");
|
---|
91 | cmpTrigger.DoAfterDelay(6000, "IntroductionToResources", {});
|
---|
92 | }
|
---|
93 | }
|
---|
94 | }
|
---|
95 |
|
---|
96 | g_Triggers.IntroductionToUnits = function(data)
|
---|
97 | {
|
---|
98 | PushNotification([1], "Now it is time to work with units. Move the mouse pointer on one of the units present in the screen, and left-click to select it. Then, right-click on an open part of the terrain.");
|
---|
99 | cmpTrigger.DoAfterDelay(12000, "MovingUnitsTutorial");
|
---|
100 | }
|
---|
101 |
|
---|
102 | g_Triggers.MovingUnitsTutorial = function(data)
|
---|
103 | {
|
---|
104 | if (g_Triggers.movingTutorial1Completed)
|
---|
105 | return;
|
---|
106 | PushNotification([1], "Select a unit by left clicking on it, and then, right-click on an open part of the terrain.");
|
---|
107 | cmpTrigger.DoAfterDelay(12000, "MovingUnitsTutorial");
|
---|
108 | }
|
---|
109 |
|
---|
110 | g_Triggers.MovingAGroupOfUnitsTutorial = function(data)
|
---|
111 | {
|
---|
112 | if (g_Triggers.movingTutorial2EntitiesOrdered >= 2)
|
---|
113 | return;
|
---|
114 | PushNotification([1], "Hold the left button of the mouse and drag it to select a group of units. Then, order them to move.");
|
---|
115 | cmpTrigger.DoAfterDelay(12000, "MovingAGroupOfUnitsTutorial");
|
---|
116 | }
|
---|
117 |
|
---|
118 | // RESOURCES
|
---|
119 | g_Triggers.IntroductionToResources = function(data)
|
---|
120 | {
|
---|
121 | PushNotification([1], "Resource gathering play a central role in 0 A.D.. There are four resources found in the game. Food, Wood, Stone and metal. You can find your current stockpile in the upper left section of the screen.");
|
---|
122 | cmpTrigger.DoAfterDelay(12000, "MoreDescriptionAboutResources", {});
|
---|
123 | }
|
---|
124 |
|
---|
125 | g_Triggers.MoreDescriptionAboutResources = function(data)
|
---|
126 | {
|
---|
127 | PushNotification([1], "Resources are required to train units, build structures and research technologies.");
|
---|
128 | cmpTrigger.DoAfterDelay(4000, "TutorialOnGatheringFood", {});
|
---|
129 | }
|
---|
130 |
|
---|
131 | g_Triggers.TutorialOnGatheringFood = function(data)
|
---|
132 | {
|
---|
133 | if (g_Triggers.gatheringFruitComepleted)
|
---|
134 | return;
|
---|
135 | PushNotification([1], "Food is gathered from farms, fruit trees and bushes, animals, fishes and farms. Select some of your units and right-click on the berry bushes in the east to gather food.");
|
---|
136 | cmpTrigger.DoAfterDelay(12000, "TutorialOnGatheringFood", {});
|
---|
137 | }
|
---|
138 |
|
---|
139 | g_Triggers.UnitOrderedToGatherFruit = function(data)
|
---|
140 | {
|
---|
141 | if (g_Triggers.gatheringFruitComepleted)
|
---|
142 | return;
|
---|
143 | PushNotification([1], "Excelent. Now your units will move and gather food from those bushes.");
|
---|
144 |
|
---|
145 | cmpTrigger.DoAfterDelay(2000, "TutorialOnGatheringWood");
|
---|
146 | g_Triggers.gatheringFruitComepleted = true;
|
---|
147 | }
|
---|
148 |
|
---|
149 | g_Triggers.TutorialOnGatheringWood = function(data)
|
---|
150 | {
|
---|
151 | if (g_Triggers.gatheringTreeComepleted)
|
---|
152 | return;
|
---|
153 | PushNotification([1], "Wood is gathered from trees. Select some of your units and right-click on a tree to gather wood.");
|
---|
154 | cmpTrigger.DoAfterDelay(12000, "TutorialOnGatheringWood", {});
|
---|
155 | }
|
---|
156 |
|
---|
157 | g_Triggers.UnitOrderedToGatherTree = function(data)
|
---|
158 | {
|
---|
159 | if (g_Triggers.gatheringTreeComepleted)
|
---|
160 | return;
|
---|
161 | PushNotification([1], "Perfect. Now your units will move and gather wood from the trees.");
|
---|
162 | cmpTrigger.DoAfterDelay(2000, "TutorialOnGatheringStone");
|
---|
163 | g_Triggers.gatheringTreeComepleted = true;
|
---|
164 | }
|
---|
165 |
|
---|
166 | g_Triggers.TutorialOnGatheringStone = function(data)
|
---|
167 | {
|
---|
168 | if (g_Triggers.gatheringStoneComepleted)
|
---|
169 | return;
|
---|
170 | PushNotification([1], "Stone is gathered from stone quarries. Select some of your units and right-click on the quarry in the south of your town to gather stone.");
|
---|
171 | cmpTrigger.DoAfterDelay(12000, "TutorialOnGatheringStone", {});
|
---|
172 | }
|
---|
173 |
|
---|
174 | // This one is called when the player orders a unit to gather from stone quarries
|
---|
175 | g_Triggers.UnitOrderedToGatherStoneQuarry = function(data)
|
---|
176 | {
|
---|
177 | if (g_Triggers.gatheringStoneComepleted)
|
---|
178 | return;
|
---|
179 | PushNotification([1], "Good. Now your units will move and gather stone from the quarry.");
|
---|
180 | cmpTrigger.DoAfterDelay(2000, "TutorialOnGatheringMetal");
|
---|
181 | g_Triggers.gatheringStoneComepleted = true;
|
---|
182 | }
|
---|
183 |
|
---|
184 | g_Triggers.TutorialOnGatheringMetal = function(data)
|
---|
185 | {
|
---|
186 | if (g_Triggers.gatheringMetalComepleted)
|
---|
187 | return;
|
---|
188 | PushNotification([1], "Metal is gathered from metal ores. Select some of your units and right-click on the rock in the north-east of your town to gather metal.");
|
---|
189 | cmpTrigger.DoAfterDelay(12000, "TutorialOnGatheringMetal", {});
|
---|
190 | }
|
---|
191 |
|
---|
192 | // This one is called when the player orders a unit to gather from metal mines
|
---|
193 | g_Triggers.UnitOrderedToGatherMetalMine = function(data)
|
---|
194 | {
|
---|
195 | if (g_Triggers.gatheringMetalComepleted)
|
---|
196 | return;
|
---|
197 | PushNotification([1], "Very Good. Now your units will move and gather metal from the ore.");
|
---|
198 |
|
---|
199 | // Spawn a cavalry unit for the player in his/her civic center.
|
---|
200 | var playerEntities = GetEntitiesByPlayer(1); // Get all of the player's entities
|
---|
201 | for each (entity in playerEntities)
|
---|
202 | {
|
---|
203 | if (EntityHasClass(entity, "CivilCentre"))
|
---|
204 | {
|
---|
205 | BuildingSpawnUnits(entity, "skirmish/units/default_cavalry", 1);
|
---|
206 | break;
|
---|
207 | }
|
---|
208 | }
|
---|
209 |
|
---|
210 | cmpTrigger.DoAfterDelay(2000, "TutorialOnExploration");
|
---|
211 | cmpTrigger.RegisterOnUnitRangeFromEntityTrigger(226, 50, "StartTreasureTutorial", [1], IID_DamageReceiver); // This special trigger calls the action when an entity owned by player 1 enters a circular area of 50 game meters centered around entity 226 (the gaia market).
|
---|
212 |
|
---|
213 | g_Triggers.gatheringMetalComepleted = true;
|
---|
214 | }
|
---|
215 |
|
---|
216 | g_Triggers.TutorialOnExploration = function(data)
|
---|
217 | {
|
---|
218 | if (g_Triggers.exploredTerrain)
|
---|
219 | return;
|
---|
220 | PushNotification([1], "Notice that you can only see the immidiate surroundings of you town. To see further, select your rider and order him to move along the south-eastern road into the black area.");
|
---|
221 | cmpTrigger.DoAfterDelay(12000, "TutorialOnExploration");
|
---|
222 | }
|
---|
223 |
|
---|
224 | // This one is called when a unit gets near the market in the south-east
|
---|
225 | g_Triggers.StartTreasureTutorial = function(data)
|
---|
226 | {
|
---|
227 | if (!data.added.length || g_Triggers.exploredTerrain)
|
---|
228 | return;
|
---|
229 | PushNotification([1], "You have found some treasures. Treasures give large ammount of their representing resources instantly. Order your rider to gather the treasures.");
|
---|
230 | g_Triggers.exploredTerrain = true;
|
---|
231 | cmpTrigger.DisableRangeTrigger("StartTreasureTutorial");
|
---|
232 | cmpTrigger.DoAfterDelay(2000, "TutorialOnGatheringTreasure");
|
---|
233 | }
|
---|
234 |
|
---|
235 | g_Triggers.TutorialOnGatheringTreasure = function(data)
|
---|
236 | {
|
---|
237 | if (g_Triggers.gatheringTreasureComepleted)
|
---|
238 | return;
|
---|
239 | PushNotification([1], "Order your rider to gather the treasures. To do so, select your rider and right-click on one of the treasures near the road.");
|
---|
240 | cmpTrigger.DoAfterDelay(12000, "TutorialOnGatheringTreasure");
|
---|
241 | }
|
---|
242 |
|
---|
243 | // This one is called when the player orders a unit to gather from treasures
|
---|
244 | g_Triggers.UnitOrderedToGatherTreasure = function(data)
|
---|
245 | {
|
---|
246 | if (g_Triggers.gatheringTreasureComepleted)
|
---|
247 | return;
|
---|
248 | PushNotification([1], "Outstanding. This tutorial is now done.");
|
---|
249 | g_Triggers.gatheringTreasureComepleted = true;
|
---|
250 |
|
---|
251 | cmpTrigger.DoAfterDelay(2000, "Victory", {});
|
---|
252 | }
|
---|
253 |
|
---|
254 | g_Triggers.Victory = function(data)
|
---|
255 | {
|
---|
256 | DefeatPlayer(2);
|
---|
257 | }
|
---|
258 |
|
---|
259 |
|
---|