share/hedgewars/Data/Missions/Training/User_Mission_-_Rope_Knock_Challenge.lua
branchqmlfrontend
changeset 12855 1b2b84315d27
parent 11843 01f88c3b7b66
parent 12854 28cb18c5e712
child 12856 95d903b976d0
equal deleted inserted replaced
11843:01f88c3b7b66 12855:1b2b84315d27
     1 HedgewarsScriptLoad("/Scripts/Locale.lua")
       
     2 
       
     3 local hhs = {}
       
     4 local missionWon = nil
       
     5 local endTimer = 1000
       
     6 local hogsKilled = 0
       
     7 local finishTime
       
     8 
       
     9 local HogData =	{
       
    10 					{"Bufon", 			"ShaggyYeti",false},
       
    11 					{"burp", 			"lambda",false},
       
    12 					{"Blue", 			"cap_blue",false},
       
    13 					{"bender", 			"NoHat",false},
       
    14 					{"Castell",			"NoHat",false},
       
    15 					{"cekoto", 			"NoHat",false},
       
    16 					{"CheezeMonkey",	"NoHat",false},
       
    17 					{"claymore", 		"NoHat",false},
       
    18 					{"CIA-144", 		"cyborg1",false},
       
    19 					{"doomy ", 			"NoHat",false},
       
    20 					{"Falkenauge", 		"NoHat",false},
       
    21 					{"FadeOne", 		"NoHat",false},
       
    22 					{"hayaa", 			"NoHat",false},
       
    23 					{"Hermes", 			"laurel",false},
       
    24 					{"HedgeKing",		"NoHat",false},
       
    25 					{"Izack1535", 		"NoHat",false},
       
    26 					{"Kiofspa", 		"NoHat",false},
       
    27 					{"Komplex", 		"NoHat",false},
       
    28 					{"koda", 			"poke_mudkip",false},
       
    29 					{"Lalo", 			"NoHat",false},
       
    30 					{"Logan", 			"NoHat",false},
       
    31 					{"lollkiller", 		"NoHat",false},
       
    32 					{"Luelle", 			"NoHat",false},
       
    33 					{"mikade", 			"Skull",false},
       
    34 					{"Mushi", 			"sm_daisy",false},
       
    35 					{"Naboo", 			"NoHat",false},
       
    36 					{"nemo", 			"bb_bub",false},
       
    37 					{"practice", 		"NoHat",false},
       
    38 					{"Prof. Panic",  	"NoHat",false},
       
    39 					{"Randy",			"zoo_Sheep",false},
       
    40 					{"rhino", 			"NinjaTriangle",false},
       
    41 					{"Radissthor",  	"NoHat",false},
       
    42 					{"Sami",			"sm_peach",false},
       
    43 					{"soreau", 			"NoHat",false},
       
    44 					{"sdw195", 			"NoHat",false},
       
    45 					{"sphrix", 			"TeamTopHat",false},
       
    46 					{"sheepluva",		"zoo_Sheep",false},
       
    47 					{"Smaxx", 			"NoHat",false},
       
    48 					{"shadowzero", 		"NoHat",false},
       
    49 					{"Star and Moon",	"SparkleSuperFun",false},
       
    50 					{"The 24",			"NoHat",false},
       
    51 					{"TLD",				"NoHat",false},
       
    52 					{"Tiyuri", 			"sf_ryu",false},
       
    53 					{"unC0Rr", 			"cyborg1",false},
       
    54 					{"Waldsau", 		"cyborg1",false},
       
    55 					{"wolfmarc", 		"knight",false},
       
    56 					{"Xeli", 			"android",false}
       
    57 
       
    58 				}
       
    59 
       
    60 function GenericEnd()
       
    61 	EndGame()
       
    62 end
       
    63 
       
    64 function GameOverMan()
       
    65 	missionWon = false
       
    66 	ShowMission(loc("Rope-knocking Challenge"), loc("Challenge over!"), loc("Oh no! Just try again!"), -amSkip, 0)
       
    67 	SendStat(siGameResult, loc("Challenge over!"))
       
    68 	local score = math.ceil((hogsKilled / 16)*6000)
       
    69 	SendStat(siCustomAchievement, string.format(loc("You have killed %d of 16 hedgehogs (+%d points)."), hogsKilled, score))
       
    70 	SendStat(siPointType, "points")
       
    71 	SendStat(siPlayerKills, tostring(score), loc("Wannabe Shoppsta"))
       
    72 	PlaySound(sndHellish)
       
    73 end
       
    74 
       
    75 function GG()
       
    76 	missionWon = true
       
    77 	local completeTime = (TurnTime - finishTime) / 1000
       
    78 	ShowMission(loc("Rope-knocking Challenge"), loc("Challenge completed!"), loc("Congratulations!") .. "|" .. string.format(loc("Completion time: %.2fs"), completeTime), 0, 0)
       
    79 	PlaySound(sndHomerun)
       
    80 	SendStat(siGameResult, loc("Challenge completed!"))
       
    81 	local hogScore = math.ceil((hogsKilled / 16)*6000)
       
    82 	local timeScore = math.ceil((finishTime/TurnTime)*6000)
       
    83 	local score = hogScore + timeScore
       
    84 	SendStat(siCustomAchievement, string.format(loc("You have killed %d of 16 hedgehogs (+%d points)."), hogsKilled, hogScore))
       
    85 	SendStat(siCustomAchievement, string.format(loc("You have completed this challenge in %.2f s (+%d points)."), completeTime, timeScore))
       
    86 	SendStat(siPointType, "points")
       
    87 	SendStat(siPlayerKills, tostring(score), loc("Wannabe Shoppsta"))
       
    88 end
       
    89 
       
    90 function AssignCharacter(p)
       
    91 
       
    92 	done = false
       
    93 	sanityCheck = 0
       
    94 
       
    95 	while(done == false) do
       
    96 
       
    97 		i = 1+ GetRandom(#HogData)
       
    98 		if HogData[i][3] == false then
       
    99 			HogData[i][3] = true
       
   100 			done = true
       
   101 			SetHogName(hhs[p], HogData[i][1])
       
   102 			SetHogHat(hhs[p], HogData[i][2])
       
   103 		elseif HogData[i][3] == true then
       
   104 			sanityCheck = sanityCheck +1
       
   105 			if sanityCheck == 100 then
       
   106 				done = true
       
   107 				SetHogName(hhs[p], "Newbie")
       
   108 				SetHogHat(hhs[p], "NoHat")
       
   109 			end
       
   110 		end
       
   111 
       
   112 	end
       
   113 
       
   114 end
       
   115 
       
   116 function onGameInit()
       
   117 
       
   118 	--Seed = 1
       
   119 	GameFlags = gfBorder + gfSolidLand
       
   120 
       
   121 	TurnTime = 180 * 1000
       
   122 	Delay = 500
       
   123 	Map = "Ropes"
       
   124 	Theme = "Eyes"
       
   125 
       
   126 	CaseFreq = 0
       
   127 	MinesNum = 0
       
   128 	Explosives = 0
       
   129 
       
   130 	AddTeam(loc("Wannabe Shoppsta"), 0x11F12B, "Simple", "Island", "Default", "cm_shoppa")
       
   131 	hhs[0] = AddHog(loc("Ace"), 0, 1, "Gasmask")
       
   132 	SetGearPosition(player, 1380, 1500)
       
   133 
       
   134 	AddTeam(loc("Unsuspecting Louts"), 0xDD0000, "Simple", "Island", "Default", "cm_face")
       
   135 	for i = 1, 8 do
       
   136 		hhs[i] = AddHog("generic", 0, 1, "NoHat")
       
   137 	end
       
   138 
       
   139 	AddTeam(loc("Unlucky Sods"), 0xDD0000, "Simple", "Island", "Default", "cm_balrog")
       
   140 	for i = 9, 16 do
       
   141 		hhs[i] = AddHog("generic", 0, 1, "NoHat")
       
   142 	end
       
   143 
       
   144 end
       
   145 
       
   146 
       
   147 
       
   148 function onGameStart()
       
   149 	SendHealthStatsOff()
       
   150 
       
   151 	ShowMission     (
       
   152                         loc("Rope-knocking Challenge"),
       
   153                         loc("Challenge"),
       
   154                         loc("Use the rope to knock your enemies to their doom.") .. "|" ..
       
   155                         loc("Finish this challenge as fast as possible to earn bonus points."),
       
   156                         -amRope, 4000)
       
   157 
       
   158 	PlaceGirder(46,1783, 0)
       
   159 
       
   160 	SetGearPosition(hhs[0], 2419, 1769)
       
   161 	SetGearPosition(hhs[1], 3350, 570)
       
   162 	SetGearPosition(hhs[2], 3039, 1300)
       
   163 	SetGearPosition(hhs[3], 2909, 430)
       
   164 	SetGearPosition(hhs[4], 2150, 879)
       
   165 	SetGearPosition(hhs[5], 1735, 1136)
       
   166 	SetGearPosition(hhs[6], 1563, 553)
       
   167 	SetGearPosition(hhs[7], 679, 859)
       
   168 	SetGearPosition(hhs[8], 1034, 251)
       
   169 	SetGearPosition(hhs[9], 255, 67)
       
   170 	SetGearPosition(hhs[10], 2671, 7)
       
   171 	SetGearPosition(hhs[11], 2929, 244)
       
   172 	SetGearPosition(hhs[12], 1946, 221)
       
   173 	SetGearPosition(hhs[13], 3849, 1067)
       
   174 	SetGearPosition(hhs[14], 3360, 659)
       
   175 	SetGearPosition(hhs[15], 3885, 285)
       
   176 	SetGearPosition(hhs[16], 935, 1160)
       
   177 
       
   178 	for i = 1, 16 do
       
   179 		AssignCharacter(i)
       
   180 	end
       
   181 
       
   182 end
       
   183 
       
   184 function onGameTick()
       
   185 
       
   186 	if (TurnTimeLeft == 1) and (missionWon == nil) then
       
   187 		GameOverMan()
       
   188 	end
       
   189 
       
   190 	if missionWon ~= nil then
       
   191 
       
   192 		endTimer = endTimer - 1
       
   193 		if endTimer == 1 then
       
   194 			GenericEnd()
       
   195 		end
       
   196 
       
   197 		if missionWon == true then
       
   198 			AddCaption(loc("Victory!"), 0xFFFFFFFF,capgrpGameState)
       
   199 		else
       
   200 			AddCaption(loc("Challenge over!"), 0xFFFFFFFF,capgrpGameState)
       
   201 		end
       
   202 
       
   203 	end
       
   204 
       
   205 end
       
   206 
       
   207 function onGearDamage(gear, damage)
       
   208 
       
   209 	if gear ~= hhs[0] and GetGearType(gear) == gtHedgehog then
       
   210 
       
   211 		AddVisualGear(GetX(gear), GetY(gear), vgtBigExplosion, 0, false)
       
   212 		DeleteGear(gear)
       
   213 		PlaySound(sndExplosion)
       
   214 		AddCaption(string.format(knockTaunt(), GetHogName(gear)), 0xFFFFFFFF, capgrpMessage)
       
   215 
       
   216 		hogsKilled = hogsKilled +1
       
   217 		if hogsKilled == 15 then
       
   218 			PlaySound(sndRideOfTheValkyries)
       
   219 		elseif hogsKilled == 16 then
       
   220 			finishTime = TurnTimeLeft
       
   221 			GG()
       
   222 		end
       
   223 
       
   224 	end
       
   225 
       
   226 end
       
   227 
       
   228 function knockTaunt()
       
   229 	local r = math.random(0,23)
       
   230 	local taunt
       
   231 	if r == 0 then taunt =		loc("%s has been knocked out.")
       
   232 	elseif r == 1 then taunt =	loc("%s hit the ground.")
       
   233 	elseif r == 2 then taunt =	loc("%s splatted.")
       
   234 	elseif r == 3 then taunt =	loc("%s was smashed.")
       
   235 	elseif r == 4 then taunt =	loc("%s felt unstable.")
       
   236 	elseif r == 5 then taunt =	loc("%s exploded.")
       
   237 	elseif r == 6 then taunt =	loc("%s fell from a high cliff.")
       
   238 	elseif r == 7 then taunt =	loc("%s goes the way of the lemming.")
       
   239 	elseif r == 8 then taunt =	loc("%s was knocked away.")
       
   240 	elseif r == 9 then taunt =	loc("%s was really unlucky.")
       
   241 	elseif r == 10 then taunt =	loc("%s felt victim to rope-knocking.")
       
   242 	elseif r == 11 then taunt =	loc("%s had no chance.")
       
   243 	elseif r == 12 then taunt =	loc("%s was a good target.")
       
   244 	elseif r == 13 then taunt =	loc("%s spawned at a really bad position.")
       
   245 	elseif r == 14 then taunt =	loc("%s was doomed from the beginning.")
       
   246 	elseif r == 15 then taunt =	loc("%s has fallen victim to gravity.")
       
   247 	elseif r == 16 then taunt =	loc("%s hates Newton.")		-- Isaac Newton
       
   248 	elseif r == 17 then taunt =	loc("%s had it coming.")
       
   249 	elseif r == 18 then taunt =	loc("%s is eliminated!")
       
   250 	elseif r == 19 then taunt =	loc("%s fell too fast.")
       
   251 	elseif r == 20 then taunt =	loc("%s flew like a rock.")
       
   252 	elseif r == 21 then taunt =	loc("%s stumpled.")
       
   253 	elseif r == 22 then taunt =	loc("%s was shoved away.")
       
   254 	elseif r == 23 then taunt =	loc("%s didn't expect that.")
       
   255 	end
       
   256 	return taunt
       
   257 end
       
   258 
       
   259 function onGearDelete(gear)
       
   260 
       
   261 	if (gear == hhs[0]) and (missionWon == nil) then
       
   262 		GameOverMan()
       
   263 	end
       
   264 
       
   265 end
       
   266 
       
   267 function onAmmoStoreInit()
       
   268 	SetAmmo(amRope, 9, 0, 0, 0)
       
   269 end
       
   270 
       
   271 function onNewTurn()
       
   272  	SetWeapon(amRope)
       
   273 end