share/hedgewars/Data/Missions/Challenge/User_Mission_-_RCPlane_Challenge.lua
changeset 11968 1de4d6b35748
parent 11689 c0ad9cf7db65
child 12049 030464f34d47
equal deleted inserted replaced
11967:7dd85fe00de3 11968:1de4d6b35748
       
     1 HedgewarsScriptLoad("/Scripts/Locale.lua")
       
     2 
       
     3 local player = nil
       
     4 local RCGear = nil
       
     5 local planesUsed = 0
       
     6 local planeTimer = 0
       
     7 local planeUhOh = false
       
     8 local cratesLeft = 0
       
     9 local crateStreak = 0
       
    10 local longestCrateStreak = 0
       
    11 local commentTimer = 0
       
    12 local missiles = 0
       
    13 local totalMissiles = 0
       
    14 local missileScanTimer = 0
       
    15 local nextComment = sndNone
       
    16 
       
    17 function onGameInit()
       
    18 
       
    19 	Seed = 1
       
    20 	GameFlags = gfInfAttack + gfInvulnerable + gfOneClanMode + gfSolidLand
       
    21 
       
    22 	TurnTime = 90 * 1000
       
    23 
       
    24 	Map = "Ropes"
       
    25 	Theme = "Eyes"
       
    26 
       
    27 	CaseFreq = 0
       
    28 	MinesNum = 0
       
    29 	Explosives = 0
       
    30 
       
    31 	AddTeam(loc("Wannabe Flyboys"), 14483456, "Simple", "Island", "Default", "Hedgewars")
       
    32 	player = AddHog(loc("Ace"), 0, 80, "Gasmask")
       
    33 	SetGearPosition(player, 1380, 1500)
       
    34 
       
    35 end
       
    36 
       
    37 
       
    38 
       
    39 function onGameStart()
       
    40 
       
    41 	SendHealthStatsOff()
       
    42 
       
    43 	ShowMission     (
       
    44                                 loc("RC PLANE TRAINING"),
       
    45                                 loc("a Hedgewars challenge"),
       
    46 
       
    47                                 loc("Collect or destroy all the health crates.") .. "|" ..
       
    48                                 loc("Compete to use as few planes as possible!") .. "|" ..
       
    49 								"", -amRCPlane, 4000
       
    50                                 )
       
    51 
       
    52 	PlaceGirder(2192, 508, 6)
       
    53 	PlaceGirder(2192, 670, 6)
       
    54 	PlaceGirder(2193, 792, 2)
       
    55 	PlaceGirder(2100, 825, 4)
       
    56 	PlaceGirder(2009, 899, 6)
       
    57 	PlaceGirder(2084, 992, 4)
       
    58 	PlaceGirder(2145, 1087, 6)
       
    59 	PlaceGirder(2199, 1235, 5)
       
    60 	PlaceGirder(2308, 1296, 0)
       
    61 	PlaceGirder(2424, 1234, 7)
       
    62 	PlaceGirder(2473, 1129, 2)
       
    63 	PlaceGirder(2437, 1046, 1)
       
    64 	PlaceGirder(2409, 927, 6)
       
    65 	PlaceGirder(2408, 763, 6)
       
    66 	PlaceGirder(2404, 540, 6)
       
    67 	PlaceGirder(2426, 423, 3)
       
    68 	PlaceGirder(2550, 400, 4)
       
    69 	PlaceGirder(2668, 425, 1)
       
    70 	PlaceGirder(2707, 541, 6)
       
    71 	PlaceGirder(2706, 703, 6)
       
    72 	PlaceGirder(2705, 867, 6)
       
    73 	PlaceGirder(2779, 962, 4)
       
    74 	PlaceGirder(2894, 924, 3)
       
    75 	PlaceGirder(2908, 802, 6)
       
    76 	PlaceGirder(2907, 639, 6)
       
    77 	PlaceGirder(3052, 566, 4)
       
    78 	PlaceGirder(2971, 394, 4)
       
    79 	PlaceGirder(3103, 448, 7)
       
    80 	PlaceGirder(3047, 654, 0)
       
    81 	PlaceGirder(3043, 746, 6)
       
    82 	PlaceGirder(3265, 1583, 6)
       
    83 	PlaceGirder(3256, 1491, 4)
       
    84 	PlaceGirder(3187, 1401, 6)
       
    85 	PlaceGirder(3326, 1400, 6)
       
    86 	PlaceGirder(774, 530, 5)
       
    87 	PlaceGirder(922, 595, 4)
       
    88 	PlaceGirder(1079, 533, 7)
       
    89 	PlaceGirder(1139, 386, 6)
       
    90 	PlaceGirder(1074, 237, 5)
       
    91 	PlaceGirder(723, 381, 6)
       
    92 	PlaceGirder(781, 229, 7)
       
    93 	PlaceGirder(927, 746, 6)
       
    94 	PlaceGirder(874, 736, 0)
       
    95 	PlaceGirder(982, 737, 0)
       
    96 	PlaceGirder(2430, 1730, 4)
       
    97 
       
    98 	PlaceGirder(1613, 1104, 7)
       
    99 	PlaceGirder(1564, 1256, 6)
       
   100 	PlaceGirder(1643, 1341, 5)
       
   101 	PlaceGirder(1780, 1372, 4)
       
   102 	PlaceGirder(1869, 1296, 7)
       
   103 	PlaceGirder(1858, 1163, 5)
       
   104 	PlaceGirder(1739, 1044, 5)
       
   105 	PlaceGirder(1621, 926, 5)
       
   106 	PlaceGirder(1597, 985, 5)
       
   107 	PlaceGirder(1449, 939, 4)
       
   108 	PlaceGirder(1473, 874, 4)
       
   109 	PlaceGirder(2092, 1352, 7)
       
   110 	PlaceGirder(2145, 1444, 7)
       
   111 	PlaceGirder(2004, 1443, 3)
       
   112 	PlaceGirder(1978, 1523, 2)
       
   113 	PlaceGirder(2021, 1596, 1)
       
   114 	PlaceGirder(2103, 1625, 0)
       
   115 	PlaceGirder(2208, 1551, 7)
       
   116 	PlaceGirder(2327, 1431, 7)
       
   117 	PlaceGirder(2395, 1478, 6)
       
   118 	PlaceGirder(2396, 1600, 2)
       
   119 	PlaceGirder(2495, 1285, 6)
       
   120 	PlaceGirder(2494, 1408, 2)
       
   121 	PlaceGirder(2547, 530, 0)
       
   122 
       
   123 	PlaceGirder(2451, 1551, 0)
       
   124 	PlaceGirder(2551, 706, 6)
       
   125 	PlaceGirder(2551, 869, 6)
       
   126 	PlaceGirder(2623, 1016, 5)
       
   127 	PlaceGirder(2773, 1083, 4)
       
   128 	PlaceGirder(2924, 1019, 7)
       
   129 	PlaceGirder(2568, 1491, 7)
       
   130 	PlaceGirder(2618, 1346, 6)
       
   131 	PlaceGirder(2674, 1195, 7)
       
   132 	PlaceGirder(2822, 1142, 4)
       
   133 	PlaceGirder(2963, 1069, 7)
       
   134 	PlaceGirder(3067, 938, 5)
       
   135 	PlaceGirder(2803, 1373, 2)
       
   136 	PlaceGirder(2811, 1559, 2)
       
   137 
       
   138 	tempG = SpawnHealthCrate(930, 557)
       
   139 	SetHealth(tempG, 25)
       
   140 	tempG = SpawnHealthCrate(979, 692)
       
   141 	SetHealth(tempG, 25)
       
   142 	tempG = SpawnHealthCrate(876, 703)
       
   143 	SetHealth(tempG, 25)
       
   144 	tempG = SpawnHealthCrate(2309, 1260)
       
   145 	SetHealth(tempG, 25)
       
   146 	tempG = SpawnHealthCrate(1733, 1127)
       
   147 	SetHealth(tempG, 25)
       
   148 	tempG = SpawnHealthCrate(1738, 1320)
       
   149 	SetHealth(tempG, 25)
       
   150 	tempG = SpawnHealthCrate(3249, 1460)
       
   151 	SetHealth(tempG, 25)
       
   152 	tempG = SpawnHealthCrate(3051, 617)
       
   153 	SetHealth(tempG, 25)
       
   154 	tempG = SpawnHealthCrate(2972, 353)
       
   155 	SetHealth(tempG, 25)
       
   156 	tempG = SpawnHealthCrate(2548, 358)
       
   157 
       
   158 	SetHealth(tempG, 25)
       
   159 	tempG = SpawnHealthCrate(2090, 1580)
       
   160 	SetHealth(tempG, 25)
       
   161 	tempG = SpawnHealthCrate(1752, 1753)
       
   162 	SetHealth(tempG, 25)
       
   163 	tempG = SpawnHealthCrate(1865, 1758)
       
   164 	SetHealth(tempG, 25)
       
   165 	tempG = SpawnHealthCrate(1985, 1760)
       
   166 	SetHealth(tempG, 25)
       
   167 	tempG = SpawnHealthCrate(2429, 1760)
       
   168 	SetHealth(tempG, 25)
       
   169 	tempG = SpawnHealthCrate(2810, 1480)
       
   170 	SetHealth(tempG, 25)
       
   171 	tempG = SpawnHealthCrate(2800, 1277)
       
   172 	SetHealth(tempG, 25)
       
   173 	tempG = SpawnHealthCrate(2806, 1107)
       
   174 	SetHealth(tempG, 25)
       
   175 
       
   176 	PlaceGirder(1897, 903, 6)
       
   177 	PlaceGirder(1916, 784, 3)
       
   178 	PlaceGirder(2010, 732, 4)
       
   179 	PlaceGirder(2082, 639, 6)
       
   180 	PlaceGirder(2081, 516, 2)
       
   181 	PlaceGirder(1985, 487, 4)
       
   182 	PlaceGirder(1862, 407, 5)
       
   183 	PlaceGirder(1855, 224, 7)
       
   184 	PlaceGirder(2006, 163, 4)
       
   185 	PlaceGirder(2128, 187, 1)
       
   186 	PlaceGirder(2251, 213, 4)
       
   187 	PlaceGirder(2413, 213, 4)
       
   188 	PlaceGirder(1952, 618, 0)
       
   189 	PlaceGirder(957, 1068, 4)
       
   190 	PlaceGirder(794, 1069, 4)
       
   191 	PlaceGirder(728, 1163, 6)
       
   192 	PlaceGirder(728, 1287, 2)
       
   193 	PlaceGirder(802, 1342, 4)
       
   194 	PlaceGirder(966, 1342, 4)
       
   195 	PlaceGirder(674, 1032, 1)
       
   196 	PlaceGirder(554, 1011, 4)
       
   197 	PlaceGirder(445, 1056, 3)
       
   198 	PlaceGirder(422, 1174, 6)
       
   199 	PlaceGirder(369, 1341, 5)
       
   200 	PlaceGirder(495, 1313, 5)
       
   201 	PlaceGirder(568, 1379, 3)
       
   202 	PlaceGirder(577, 1202, 2)
       
   203 	PlaceGirder(744, 1490, 5)
       
   204 	PlaceGirder(760, 1617, 7)
       
   205 	PlaceGirder(622, 1693, 4)
       
   206 	PlaceGirder(476, 1623, 5)
       
   207 	PlaceGirder(376, 1697, 1)
       
   208 	PlaceGirder(955, 1746, 2)
       
   209 	PlaceGirder(1025, 1746, 2)
       
   210 	PlaceGirder(1090, 1745, 2)
       
   211 	PlaceGirder(1156, 1746, 2)
       
   212 	PlaceGirder(3806, 1530, 2)
       
   213 	PlaceGirder(3880, 1464, 2)
       
   214 	PlaceGirder(3738, 1458, 2)
       
   215 	PlaceGirder(3806, 1390, 2)
       
   216 	PlaceGirder(3805, 1588, 0)
       
   217 	PlaceGirder(3676, 1609, 3)
       
   218 	PlaceGirder(3930, 1615, 1)
       
   219 	PlaceGirder(3719, 1295, 0)
       
   220 	PlaceGirder(3888, 1294, 0)
       
   221 	PlaceGirder(3661, 1385, 2)
       
   222 	PlaceGirder(3955, 1377, 2)
       
   223 	PlaceGirder(3982, 1518, 0)
       
   224 	PlaceGirder(3378, 440, 2)
       
   225 	PlaceGirder(3447, 492, 4)
       
   226 	PlaceGirder(3564, 529, 1)
       
   227 	PlaceGirder(3596, 647, 6)
       
   228 	PlaceGirder(3521, 740, 4)
       
   229 	PlaceGirder(3524, 838, 4)
       
   230 	PlaceGirder(3644, 819, 3)
       
   231 	PlaceGirder(3691, 708, 6)
       
   232 	PlaceGirder(3690, 545, 6)
       
   233 	PlaceGirder(3612, 433, 5)
       
   234 	PlaceGirder(3463, 383, 4)
       
   235 	PlaceGirder(2815, 122, 7)
       
   236 	PlaceGirder(2960, 72, 4)
       
   237 	PlaceGirder(3032, 123, 2)
       
   238 	PlaceGirder(3063, 174, 0)
       
   239 	PlaceGirder(3095, 124, 2)
       
   240 	PlaceGirder(3169, 71, 4)
       
   241 	PlaceGirder(3320, 124, 5)
       
   242 	PlaceGirder(3210, 179, 2)
       
   243 	PlaceGirder(2932, 181, 2)
       
   244 
       
   245 	tempG = SpawnHealthCrate(3804, 1461)
       
   246 	SetHealth(tempG, 25)
       
   247 	tempG = SpawnHealthCrate(3269, 1742)
       
   248 	SetHealth(tempG, 25)
       
   249 	tempG = SpawnHealthCrate(3066, 121)
       
   250 	SetHealth(tempG, 25)
       
   251 	tempG = SpawnHealthCrate(3207, 104)
       
   252 	SetHealth(tempG, 25)
       
   253 	tempG = SpawnHealthCrate(2928, 103)
       
   254 	SetHealth(tempG, 25)
       
   255 	tempG = SpawnHealthCrate(1997, 202)
       
   256 	SetHealth(tempG, 25)
       
   257 	tempG = SpawnHealthCrate(2253, 159)
       
   258 	SetHealth(tempG, 25)
       
   259 	tempG = SpawnHealthCrate(2132, 774)
       
   260 	SetHealth(tempG, 25)
       
   261 	tempG = SpawnHealthCrate(2549, 490)
       
   262 	SetHealth(tempG, 25)
       
   263 	tempG = SpawnHealthCrate(3527, 694)
       
   264 	SetHealth(tempG, 25)
       
   265 	tempG = SpawnHealthCrate(3777, 78)
       
   266 	SetHealth(tempG, 25)
       
   267 	tempG = SpawnHealthCrate(1124, 1746)
       
   268 	SetHealth(tempG, 25)
       
   269 	tempG = SpawnHealthCrate(1056, 1740)
       
   270 	SetHealth(tempG, 25)
       
   271 	tempG = SpawnHealthCrate(993, 1742)
       
   272 	SetHealth(tempG, 25)
       
   273 	tempG = SpawnHealthCrate(799, 1298)
       
   274 	SetHealth(tempG, 25)
       
   275 	tempG = SpawnHealthCrate(577, 1126)
       
   276 	SetHealth(tempG, 25)
       
   277 	tempG = SpawnHealthCrate(596, 1463)
       
   278 	SetHealth(tempG, 25)
       
   279 	tempG = SpawnHealthCrate(3854, 1043)
       
   280 	SetHealth(tempG, 25)
       
   281 	tempG = SpawnHealthCrate(1944, 567)
       
   282 	SetHealth(tempG, 25)
       
   283 	tempG = SpawnHealthCrate(338, 1748)
       
   284 	SetHealth(tempG, 25)
       
   285 
       
   286 
       
   287 end
       
   288 
       
   289 --function onGameTick()
       
   290 
       
   291 	--if RCGear ~= nil then
       
   292 	--	AddCaption(GetTimer(RCGear))
       
   293 	--end
       
   294 
       
   295 --end
       
   296 
       
   297 function onGameTick20()
       
   298 	if RCGear ~= nil then
       
   299 		if(GetTimer(RCGear) < 3000 and planeUhOh == false) then
       
   300 			PlaySound(sndUhOh, player)
       
   301 			planeUhOh = true
       
   302 		end
       
   303 		planeTimer = planeTimer + 20
       
   304 	end
       
   305 	if commentTimer > 0 then
       
   306 		commentTimer = commentTimer - 20
       
   307 	elseif(nextComment ~= sndNone) then
       
   308 		PlaySound(nextComment, player)
       
   309 		nextComment = sndNone
       
   310 	end
       
   311 	if missileScanTimer > 0 then
       
   312 		missileScanTimer = missileScanTimer - 20
       
   313 	else
       
   314 		if crateStreak == 0 and missiles == 3 then
       
   315 			PlaySound(sndMissed, player)
       
   316 			missiles = 4
       
   317 		end
       
   318 	end
       
   319 end
       
   320 
       
   321 function onNewTurn()
       
   322 	TurnTimeLeft = -1
       
   323 end
       
   324 
       
   325 function onGearAdd(gear)
       
   326 
       
   327 	if GetGearType(gear) == gtRCPlane then
       
   328 		RCGear = gear
       
   329 		planesUsed = planesUsed + 1
       
   330 		planeTimer = 0
       
   331 		missiles = 0
       
   332 	end
       
   333 
       
   334 	if GetGearType(gear) == gtCase then
       
   335 		cratesLeft = cratesLeft + 1
       
   336 	end
       
   337 
       
   338 	if GetGearType(gear) == gtAirBomb then
       
   339 		totalMissiles = totalMissiles + 1
       
   340 	end
       
   341 end
       
   342 
       
   343 function onGearDelete(gear)
       
   344 
       
   345 	if GetGearType(gear) == gtRCPlane then
       
   346 
       
   347 		RCGear = nil
       
   348 		planeUhOh = false
       
   349 		missiles = 0
       
   350 		AddCaption(string.format(loc("Planes used: %d"), planesUsed))
       
   351 
       
   352 		if(planeTimer < 2000 and crateStreak == 0) then
       
   353 			nextComment = sndStupid
       
   354 			commentTimer = math.min(2000-planeTimer, 800)
       
   355 		elseif(planeTimer < 5000 and crateStreak == 0) then
       
   356 			PlaySound(sndOops, player)
       
   357 		elseif(planesUsed == 72) then
       
   358 			PlaySound(sndStupid, player)
       
   359 		elseif(planesUsed == 50) then
       
   360 			PlaySound(sndNutter, player)
       
   361 		elseif(planesUsed == 30) then
       
   362 			PlaySound(sndOops, player)
       
   363 		end
       
   364 
       
   365 		crateStreak = 0
       
   366 
       
   367 	elseif GetGearType(gear) == gtAirBomb then
       
   368 		missiles = missiles + 1
       
   369 		missileScanTimer = 500
       
   370 
       
   371 	elseif GetGearType(gear) == gtCase then
       
   372 
       
   373 		cratesLeft = cratesLeft - 1
       
   374 		crateStreak = crateStreak + 1
       
   375 		if(crateStreak > longestCrateStreak) then
       
   376 			longestCrateStreak = crateStreak
       
   377 		end
       
   378 
       
   379 		AddCaption(string.format(loc("Crates left: %d"), cratesLeft))
       
   380 
       
   381 		if cratesLeft == 0 then
       
   382 
       
   383 			local rank = "unknown"
       
   384 			local color = 0xFFFFFFFF
       
   385 			local sound = sndVictory
       
   386 			if planesUsed >= 156 then
       
   387 				rank = loc("Destroyer of planes")	
       
   388 				color = 0xD06700FF
       
   389 				sound = sndLaugh
       
   390 			elseif planesUsed >= 98 then
       
   391 				rank = loc("Hopeless case")
       
   392 				color = 0xFF0000FF
       
   393 			elseif planesUsed >= 72 then
       
   394 				rank = loc("Drunk greenhorn")
       
   395 				color = 0xFF0040FF
       
   396 			elseif planesUsed >= 50 then
       
   397 				rank = loc("Greenhorn") -- a.k.a. "absolute beginner"
       
   398 				color = 0xFF0080FF
       
   399 			elseif planesUsed >= 39 then
       
   400 				rank = loc("Beginner")
       
   401 				color = 0xFF00BFFF
       
   402 			elseif planesUsed >= 30 then
       
   403 				rank = loc("Experienced beginner")
       
   404 				color = 0xFF00CCFF
       
   405 			elseif planesUsed >= 21 then
       
   406 				rank = loc("Below-average pilot")
       
   407 				color = 0xFF00FFFF
       
   408 			elseif planesUsed >= 17 then
       
   409 				rank = loc("Average pilot")				
       
   410 				color = 0xBF00FFFF
       
   411 			elseif planesUsed >= 13 then
       
   412 				rank = loc("Above-average pilot")
       
   413 				color = 0x8000FFFF
       
   414 			elseif planesUsed >= 8 then
       
   415 				rank = loc("Professional pilot")
       
   416 				color = 0x4000FFFF
       
   417 			elseif planesUsed >= 5 then
       
   418 				rank = loc("Professional stunt pilot")
       
   419 				color = 0x0000FFFF
       
   420 			elseif planesUsed >= 3 then
       
   421 				rank = loc("Elite pilot")
       
   422 				color = 0x0040FFFF
       
   423 			elseif planesUsed == 2 then
       
   424 				rank = loc("Upper-class elite pilot")
       
   425 				color = 0x0080FFFF
       
   426 			elseif planesUsed == 1 then
       
   427 				rank = loc("Top-class elite pilot")
       
   428 				color = 0x00FFFFFF
       
   429 				sound = sndFlawless
       
   430 			else
       
   431 				rank = loc("Cheater")
       
   432 				color = 0xFF0000FF
       
   433 				sound = sndCoward
       
   434 			end
       
   435 			AddCaption(string.format(loc("Rank: %s"), rank), color, capgrpMessage2)
       
   436 			SendStat(siCustomAchievement, string.format(loc("Your rank: %s"), rank))
       
   437 			if planesUsed == 1 then
       
   438 				AddCaption(loc("Flawless victory!"))
       
   439 				SendStat(siGameResult, loc("You have perfectly beaten the challenge!"))
       
   440 				SendStat(siCustomAchievement, loc("You have used only 1 RC plane. Outstanding!"))
       
   441 			else
       
   442 				AddCaption(loc("Victory!"))
       
   443 				SendStat(siGameResult, loc("You have finished the challenge!"))
       
   444 				SendStat(siCustomAchievement, string.format(loc("You have used %d RC planes."), planesUsed))
       
   445 			end
       
   446 		
       
   447 			if(totalMissiles > 1) then
       
   448 				SendStat(siCustomAchievement, string.format(loc("You have dropped %d missiles."), totalMissiles))
       
   449 			end
       
   450 
       
   451 			if(longestCrateStreak > 5) then
       
   452 				if(planesUsed == 1) then
       
   453 					SendStat(siCustomAchievement, string.format(loc("In your best (and only) flight you took out %d crates with one RC plane!"), longestCrateStreak))
       
   454 				else
       
   455 					SendStat(siCustomAchievement, string.format(loc("In your best flight you took out %d crates with one RC plane."), longestCrateStreak))
       
   456 				end
       
   457 			end
       
   458 
       
   459 			if(planesUsed == 2) then
       
   460 				SendStat(siCustomAchievement, loc("This was an awesome performance! But this challenge can be finished with even just one RC plane. Can you figure out how?"))
       
   461 			end
       
   462 			if(planesUsed == 1) then
       
   463 				SendStat(siCustomAchievement, loc("Congratulations! You have truly mastered this challenge! Don't forget to save the demo."))
       
   464 				SendStat(siCustomAchievement, string.format(loc("You have gained an achievement: %s"), loc("Prestigious Pilot")))
       
   465 			end
       
   466 
       
   467 			ShowMission     (
       
   468                                 loc("CHALLENGE COMPLETE"),
       
   469                                 loc("Congratulations!"),
       
   470                                 string.format(loc("Planes used: %d"), planesUsed) .. "|" ..
       
   471                                 "", 0, 0
       
   472                                 )
       
   473 			SetState(player, gstWinner)
       
   474 			PlaySound(sound, player)
       
   475 
       
   476 
       
   477 			DismissTeam(loc("Wannabe Flyboys"))
       
   478 			EndGame()
       
   479 		end
       
   480 
       
   481 		if RCGear ~= nil then
       
   482 			SetTimer(RCGear, GetTimer(RCGear) + 10000)
       
   483 		end
       
   484 	end
       
   485 
       
   486 end
       
   487 
       
   488 function onAmmoStoreInit()
       
   489 	SetAmmo(amRCPlane, 9, 0, 0, 0)
       
   490 end
       
   491 
       
   492 function onNewTurn()
       
   493  	SetWeapon(amRCPlane)
       
   494 end