share/hedgewars/Data/Missions/Training/User_Mission_-_Rope_Knock_Challenge.lua
changeset 11687 594016813e06
parent 10290 42efccba0711
child 11689 c0ad9cf7db65
equal deleted inserted replaced
11645:e80fc50457a2 11687:594016813e06
     2 
     2 
     3 local hhs = {}
     3 local hhs = {}
     4 local missionWon = nil
     4 local missionWon = nil
     5 local endTimer = 1000
     5 local endTimer = 1000
     6 local hogsKilled = 0
     6 local hogsKilled = 0
       
     7 local finishTime
     7 
     8 
     8 local HogData =	{
     9 local HogData =	{
     9 					{"Bufon", 			"ShaggyYeti",false},
    10 					{"Bufon", 			"ShaggyYeti",false},
    10 					{"burp", 			"lambda",false},
    11 					{"burp", 			"lambda",false},
    11 					{"Blue", 			"cap_blue",false},
    12 					{"Blue", 			"cap_blue",false},
    55 					{"Xeli", 			"android",false}
    56 					{"Xeli", 			"android",false}
    56 
    57 
    57 				}
    58 				}
    58 
    59 
    59 function GenericEnd()
    60 function GenericEnd()
    60 	DismissTeam(loc("Wannabe Shoppsta"))
    61 	EndGame()
    61 	DismissTeam(loc("Unsuspecting Louts"))
       
    62 	DismissTeam(loc("Unlucky Sods"))
       
    63 end
    62 end
    64 
    63 
    65 function GameOverMan()
    64 function GameOverMan()
    66 	missionWon = false
    65 	missionWon = false
    67 	ShowMission(loc("ROPE-KNOCKING"), loc("MISSION FAILED"), loc("Oh no! Just try again!"), -amSkip, 0)
    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"))
    68 	PlaySound(sndHellish)
    72 	PlaySound(sndHellish)
    69 end
    73 end
    70 
    74 
    71 function GG()
    75 function GG()
    72 	missionWon = true
    76 	missionWon = true
    73 	ShowMission(loc("ROPE-KNOCKING"), loc("MISSION SUCCESS"), loc("Congratulations!") .. "|" .. loc("COMPLETION TIME") .. ": " .. (TurnTime - TurnTimeLeft) / 1000, 0, 0)
    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)
    74 	PlaySound(sndHomerun)
    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"))
    75 end
    88 end
    76 
    89 
    77 function AssignCharacter(p)
    90 function AssignCharacter(p)
    78 
    91 
    79 	done = false
    92 	done = false
   112 
   125 
   113 	CaseFreq = 0
   126 	CaseFreq = 0
   114 	MinesNum = 0
   127 	MinesNum = 0
   115 	Explosives = 0
   128 	Explosives = 0
   116 
   129 
   117 	AddTeam(loc("Wannabe Shoppsta"), 1175851, "Simple", "Island", "Default", "Hedgewars")
   130 	AddTeam(loc("Wannabe Shoppsta"), 0x11F12B, "Simple", "Island", "Default", "cm_shoppa")
   118 	hhs[0] = AddHog(loc("Ace"), 0, 1, "Gasmask")
   131 	hhs[0] = AddHog(loc("Ace"), 0, 1, "Gasmask")
   119 	SetGearPosition(player, 1380, 1500)
   132 	SetGearPosition(player, 1380, 1500)
   120 
   133 
   121 	AddTeam(loc("Unsuspecting Louts"), 14483456, "Simple", "Island", "Default", "Hedgewars")
   134 	AddTeam(loc("Unsuspecting Louts"), 0xDD0000, "Simple", "Island", "Default", "cm_face")
   122 	for i = 1, 8 do
   135 	for i = 1, 8 do
   123 		hhs[i] = AddHog("generic", 0, 1, "NoHat")
   136 		hhs[i] = AddHog("generic", 0, 1, "NoHat")
   124 	end
   137 	end
   125 
   138 
   126 	AddTeam(loc("Unlucky Sods"), 14483456, "Simple", "Island", "Default", "Hedgewars")
   139 	AddTeam(loc("Unlucky Sods"), 0xDD0000, "Simple", "Island", "Default", "cm_balrog")
   127 	for i = 9, 16 do
   140 	for i = 9, 16 do
   128 		hhs[i] = AddHog("generic", 0, 1, "NoHat")
   141 		hhs[i] = AddHog("generic", 0, 1, "NoHat")
   129 	end
   142 	end
   130 
   143 
   131 end
   144 end
   132 
   145 
   133 
   146 
   134 
   147 
   135 function onGameStart()
   148 function onGameStart()
       
   149 	SendHealthStatsOff()
   136 
   150 
   137 	ShowMission     (
   151 	ShowMission     (
   138                         loc("ROPE-KNOCKING"),
   152                         loc("Rope-knocking Challenge"),
   139                         loc("a Hedgewars challenge"),
   153                         loc("Challenge"),
   140                         loc("Use the rope to knock your enemies to their doom.") .. "|" ..
   154                         loc("Use the rope to knock your enemies to their doom.") .. "|" ..
   141 
   155                         loc("Finish this challenge as fast as possible to earn bonus points."),
   142 						"", -amRope, 4000
   156                         -amRope, 4000)
   143 					)
   157 
       
   158 	PlaceGirder(46,1783, 0)
   144 
   159 
   145 	SetGearPosition(hhs[0], 2419, 1769)
   160 	SetGearPosition(hhs[0], 2419, 1769)
   146 	SetGearPosition(hhs[1], 3350, 570)
   161 	SetGearPosition(hhs[1], 3350, 570)
   147 	SetGearPosition(hhs[2], 3039, 1300)
   162 	SetGearPosition(hhs[2], 3039, 1300)
   148 	SetGearPosition(hhs[3], 2909, 430)
   163 	SetGearPosition(hhs[3], 2909, 430)
   178 		if endTimer == 1 then
   193 		if endTimer == 1 then
   179 			GenericEnd()
   194 			GenericEnd()
   180 		end
   195 		end
   181 
   196 
   182 		if missionWon == true then
   197 		if missionWon == true then
   183 			AddCaption(loc("GG!"), 0xffba00ff,capgrpGameState)
   198 			AddCaption(loc("Victory!"), 0xFFFFFFFF,capgrpGameState)
   184 		else
   199 		else
   185 			AddCaption(loc("Ouch!"), 0xffba00ff,capgrpGameState)
   200 			AddCaption(loc("Challenge over!"), 0xFFFFFFFF,capgrpGameState)
   186 		end
   201 		end
   187 
   202 
   188 	end
   203 	end
   189 
   204 
   190 end
   205 end
   191 
   206 
   192 function onGearDamage(gear, damage)
   207 function onGearDamage(gear, damage)
   193 
   208 
   194 	if gear ~= hhs[0] then
   209 	if gear ~= hhs[0] and GetGearType(gear) == gtHedgehog then
   195 
   210 
   196 		AddVisualGear(GetX(gear), GetY(gear), vgtBigExplosion, 0, false)
   211 		AddVisualGear(GetX(gear), GetY(gear), vgtBigExplosion, 0, false)
   197 		DeleteGear(gear)
   212 		DeleteGear(gear)
   198 		PlaySound(sndExplosion)
   213 		PlaySound(sndExplosion)
       
   214 		AddCaption(string.format(knockTaunt(), GetHogName(gear)), 0xFFFFFFFF, capgrpMessage)
   199 
   215 
   200 		hogsKilled = hogsKilled +1
   216 		hogsKilled = hogsKilled +1
   201 		if hogsKilled == 15 then
   217 		if hogsKilled == 15 then
   202 			PlaySound(sndRideOfTheValkyries)
   218 			PlaySound(sndRideOfTheValkyries)
   203 		elseif hogsKilled == 16 then
   219 		elseif hogsKilled == 16 then
       
   220 			finishTime = TurnTimeLeft
   204 			GG()
   221 			GG()
   205 		end
   222 		end
   206 
   223 
   207 	end
   224 	end
   208 
   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
   209 end
   257 end
   210 
   258 
   211 function onGearDelete(gear)
   259 function onGearDelete(gear)
   212 
   260 
   213 	if (gear == hhs[0]) and (missionWon == nil) then
   261 	if (gear == hhs[0]) and (missionWon == nil) then