8 -- following "--" is ignored. |
8 -- following "--" is ignored. |
9 |
9 |
10 --------------------------------------------------------------- |
10 --------------------------------------------------------------- |
11 |
11 |
12 -- This variable will hold the number of destroyed targets. |
12 -- This variable will hold the number of destroyed targets. |
13 score = 0 |
13 local score = 0 |
14 -- This variable represents the number of targets to destroy. |
14 -- This variable represents the number of targets to destroy. |
15 score_goal = 5 |
15 local score_goal = 5 |
16 -- This variable controls how many milliseconds/ticks we'd |
16 -- This variable controls how many milliseconds/ticks we'd |
17 -- like to wait before we end the round once all targets |
17 -- like to wait before we end the round once all targets |
18 -- have been destroyed. |
18 -- have been destroyed. |
19 end_timer = 5000 -- 5000 ms = 5 s |
19 local end_timer = 5000 -- 5000 ms = 5 s |
|
20 -- This variable is set to true if the game is lost (i.e. |
|
21 -- time runs out). |
|
22 local game_lost = false |
|
23 -- This variable will point to the hog's gear |
|
24 local player = nil |
20 |
25 |
21 -- This is a custom function to make it easier to |
26 -- This is a custom function to make it easier to |
22 -- spawn more targets with just one line of code |
27 -- spawn more targets with just one line of code |
23 -- You may define as many custom functions as you |
28 -- You may define as many custom functions as you |
24 -- like. |
29 -- like. |
51 -- The base number for the random number generator |
56 -- The base number for the random number generator |
52 Seed = 0 |
57 Seed = 0 |
53 -- Game settings and rules |
58 -- Game settings and rules |
54 GameFlags = gfMultiWeapon + gfOneClanMode |
59 GameFlags = gfMultiWeapon + gfOneClanMode |
55 -- The time the player has to move each round (in ms) |
60 -- The time the player has to move each round (in ms) |
56 TurnTime = 90000 |
61 TurnTime = 25000 |
57 -- The frequency of crate drops |
62 -- The frequency of crate drops |
58 CaseFreq = 0 |
63 CaseFreq = 0 |
59 -- The number of land objects being placed |
64 -- The number of land objects being placed |
60 LandAdds = 0 |
65 LandAdds = 0 |
61 -- The delay between each round |
66 -- The delay between each round |
62 Delay = 0 |
67 Delay = 0 |
63 -- The map to be played |
68 -- The map to be played |
64 Map = "Bamboo" |
69 Map = "mushrooms" |
65 -- The theme to be used |
70 -- The theme to be used |
66 Theme = "Bamboo" |
71 Theme = "nature" |
67 |
72 |
68 -- Create the player team |
73 -- Create the player team |
69 AddTeam("Shotgun Team", 14483456, "Simple", "Island", "Default") |
74 AddTeam("Shotgun Team", 14483456, "Simple", "Island", "Default") |
70 -- And add a hog to it |
75 -- And add a hog to it |
71 hog = AddHog("Hunter", 0, 1, "NoHat") |
76 player = AddHog("Hunter", 0, 1, "NoHat") |
72 SetGearPosition(hog, 1960, 1160); |
77 SetGearPosition(player, 2334, 1254); |
73 end |
78 end |
74 |
79 |
75 -- This function is called when the round starts |
80 -- This function is called when the round starts |
76 -- it spawns the first target that has to be destroyed. |
81 -- it spawns the first target that has to be destroyed. |
77 -- In addition it shows the scenario goal(s). |
82 -- In addition it shows the scenario goal(s). |
91 -- This function is called every game tick. |
96 -- This function is called every game tick. |
92 -- Note that there are 1000 ticks within one second. |
97 -- Note that there are 1000 ticks within one second. |
93 -- You shouldn't try to calculate too complicated |
98 -- You shouldn't try to calculate too complicated |
94 -- code here as this might slow down your game. |
99 -- code here as this might slow down your game. |
95 function onGameTick() |
100 function onGameTick() |
96 -- If the goal is reached ... |
101 -- If time's up, set the game to be lost. |
97 if score == score_goal then |
102 -- We actually check the time to be "1 ms" as it |
|
103 -- will be at "0 ms" right at the start of the game. |
|
104 if TurnTimeLeft == 1 then |
|
105 game_lost = true |
|
106 -- ... and show a short message. |
|
107 ShowMission("Shotgun Training", "Aiming Practice", "Oh no! Time's up! Just try again.", -amSkip, 0); |
|
108 -- How about killing our poor hog due to his poor performance? |
|
109 SetHealth(player, 0); |
|
110 end |
|
111 -- If the goal is reached or we've lost ... |
|
112 if score == score_goal or game_lost then |
98 -- ... check to see if the time we'd like to |
113 -- ... check to see if the time we'd like to |
99 -- wait has passed and then ... |
114 -- wait has passed and then ... |
100 if end_timer == 0 then |
115 if end_timer == 0 then |
101 -- ... end the game ... |
116 -- ... end the game ... |
102 EndGame() |
117 EndGame() |
110 -- This function is called when the game is initialized |
125 -- This function is called when the game is initialized |
111 -- to request the available ammo and probabilities |
126 -- to request the available ammo and probabilities |
112 function onAmmoStoreInit() |
127 function onAmmoStoreInit() |
113 -- add an unlimited supply of shotgun ammo |
128 -- add an unlimited supply of shotgun ammo |
114 SetAmmo(amShotgun, 9, 0) |
129 SetAmmo(amShotgun, 9, 0) |
115 -- add one optional laser sight |
|
116 SetAmmo(amLaserSight, 1, 0) |
|
117 end |
130 end |
118 |
131 |
119 -- This function is called when a new gear is added. |
132 -- This function is called when a new gear is added. |
120 -- We don't need it for this training, so we can |
133 -- We don't need it for this training, so we can |
121 -- keep it empty. |
134 -- keep it empty. |
132 -- If we haven't reached the goal ... |
145 -- If we haven't reached the goal ... |
133 if score < score_goal then |
146 if score < score_goal then |
134 -- ... spawn another target. |
147 -- ... spawn another target. |
135 spawnTarget() |
148 spawnTarget() |
136 else |
149 else |
|
150 if not game_lost then |
137 -- Otherwise show that the goal was accomplished |
151 -- Otherwise show that the goal was accomplished |
138 ShowMission("Shotgun Training", "Aiming Practice", "Congratulations! You've eliminated all targets|within the allowed time frame.", 0, 0); |
152 ShowMission("Shotgun Training", "Aiming Practice", "Congratulations! You've eliminated all targets|within the allowed time frame.", 0, 0); |
139 -- Also let the hogs shout "victory!" |
153 -- Also let the hogs shout "victory!" |
140 PlaySound(sndVictory) |
154 PlaySound(sndVictory) |
|
155 end |
141 end |
156 end |
142 end |
157 end |
143 end |
158 end |