share/hedgewars/Data/Missions/Training/User_Mission_-_Rope_Knock_Challenge.lua
changeset 7094 f5a5578be66b
child 7095 b20dfa82f453
equal deleted inserted replaced
7092:c9ca770fd7fc 7094:f5a5578be66b
       
     1 loadfile(GetDataPath() .. "Scripts/Locale.lua")()
       
     2 
       
     3 local hhs = {}
       
     4 local missionWon = nil
       
     5 local endTimer = 1000
       
     6 local hogsKilled = 0
       
     7 
       
     8 local HogData =	{
       
     9 					{"Bufon", 			"ShaggyYeti",false},
       
    10 					{"burp", 			"lambda",false},
       
    11 					{"Blue", 			"cap_blue",false},
       
    12 					{"bender", 			"NoHat",false},
       
    13 					{"Castell",			"NoHat",false},
       
    14 					{"cekoto", 			"NoHat",false},
       
    15 					{"CheezeMonkey",	"NoHat",false},
       
    16 					{"claymore", 		"NoHat",false},
       
    17 					{"CIA-144", 		"cyborg1",false},
       
    18 					{"doomy ", 			"NoHat",false},
       
    19 					{"Falkenauge", 		"NoHat",false},
       
    20 					{"FadeOne", 		"NoHat",false},
       
    21 					{"hayaa", 			"NoHat",false},
       
    22 					{"Hermes", 			"laurel",false},
       
    23 					{"HedgeKing",		"NoHat",false},
       
    24 					{"Izack1535", 		"NoHat",false},
       
    25 					{"Kiofspa", 		"NoHat",false},
       
    26 					{"Komplex", 		"NoHat",false},
       
    27 					{"koda", 			"poke_mudkip",false},
       
    28 					{"Lalo", 			"NoHat",false},
       
    29 					{"Logan", 			"NoHat",false},
       
    30 					{"lollkiller", 		"NoHat",false},
       
    31 					{"Luelle", 			"NoHat",false},
       
    32 					{"mikade", 			"Skull",false},
       
    33 					{"Mushi", 			"sm_daisy",false},
       
    34 					{"Naboo", 			"NoHat",false},
       
    35 					{"nemo", 			"bb_bub",false},
       
    36 					{"practice", 		"NoHat",false},
       
    37 					{"Prof. Panic",  	"NoHat",false},
       
    38 					{"Randy",			"zoo_Sheep",false},
       
    39 					{"rhino", 			"NinjaTriangle",false},
       
    40 					{"Radissthor",  	"NoHat",false},
       
    41 					{"Sami",			"sm_peach",false},
       
    42 					{"soreau", 			"NoHat",false},
       
    43 					{"sdw195", 			"NoHat",false},
       
    44 					{"sphrix", 			"TeamTopHat",false},
       
    45 					{"sheepluva",		"zoo_Sheep",false},
       
    46 					{"Smaxx", 			"NoHat",false},
       
    47 					{"shadowzero", 		"NoHat",false},
       
    48 					{"Star and Moon",	"NoHat",false},
       
    49 					{"The 24",			"NoHat",false},
       
    50 					{"TLD",				"NoHat",false},
       
    51 					{"Tiyuri", 			"sf_ryu",false},
       
    52 					{"unC0Rr", 			"cyborg1",false},
       
    53 					{"Waldsau", 		"cyborg1",false},
       
    54 					{"wolfmarc", 		"knight",false},
       
    55 					{"Xeli", 			"android",false}
       
    56 
       
    57 				}
       
    58 
       
    59 function GenericEnd()
       
    60 	ParseCommand("teamgone " .. loc("Wannabe Shoppsta"))
       
    61 	ParseCommand("teamgone " .. loc("Unsuspecting Louts"))
       
    62 	ParseCommand("teamgone " .. loc("Unlucky Sods"))
       
    63 end
       
    64 
       
    65 function GameOverMan()
       
    66 	missionWon = false
       
    67 	ShowMission(loc("ROPE-KNOCKING"), loc("MISSION FAILED"), loc("Oh no! Just try again!"), -amSkip, 0)
       
    68 	PlaySound(sndHellish)
       
    69 end
       
    70 
       
    71 function GG()
       
    72 	missionWon = true
       
    73 	ShowMission(loc("ROPE-KNOCKING"), loc("MISSION SUCCESS"), loc("Congratulations!") .. "|" .. loc("COMPLETION TIME") .. ": " .. (TurnTime - TurnTimeLeft) / 1000, 0, 0)
       
    74 	PlaySound(sndHomerun)
       
    75 end
       
    76 
       
    77 function AssignCharacter(p)
       
    78 
       
    79 	done = false
       
    80 	sanityCheck = 0
       
    81 
       
    82 	while(done == false) do
       
    83 
       
    84 		i = 1+ GetRandom(#HogData)
       
    85 		if HogData[i][3] == false then
       
    86 			HogData[i][3] = true
       
    87 			done = true
       
    88 			SetHogName(hhs[p], HogData[i][1])
       
    89 			SetHogHat(hhs[p], HogData[i][2])
       
    90 		elseif HogData[i][3] == true then
       
    91 			sanityCheck = sanityCheck +1
       
    92 			if sanityCheck == 100 then
       
    93 				done = true
       
    94 				SetHogName(hhs[p], "Newbie")
       
    95 				SetHogHat(hhs[p], "NoHat")
       
    96 			end
       
    97 		end
       
    98 
       
    99 	end
       
   100 
       
   101 end
       
   102 
       
   103 function onGameInit()
       
   104 
       
   105 	--Seed = 1
       
   106 	GameFlags = gfBorder + gfSolidLand
       
   107 
       
   108 	TurnTime = 180 * 1000
       
   109 	Delay = 500
       
   110 	Map = "Ropes"
       
   111 	Theme = "Eyes"
       
   112 
       
   113 	CaseFreq = 0
       
   114 	MinesNum = 0
       
   115 	Explosives = 0
       
   116 
       
   117 	AddTeam(loc("Wannabe Shoppsta"), 1175851, "Simple", "Island", "Default", "Hedgewars")
       
   118 	hhs[0] = AddHog(loc("Ace"), 0, 1, "Gasmask")
       
   119 	SetGearPosition(player, 1380, 1500)
       
   120 
       
   121 	AddTeam(loc("Unsuspecting Louts"), 14483456, "Simple", "Island", "Default", "Hedgewars")
       
   122 	for i = 1, 8 do
       
   123 		hhs[i] = AddHog("generic", 0, 1, "NoHat")
       
   124 	end
       
   125 
       
   126 	AddTeam(loc("Unlucky Sods"), 14483456, "Simple", "Island", "Default", "Hedgewars")
       
   127 	for i = 9, 16 do
       
   128 		hhs[i] = AddHog("generic", 0, 1, "NoHat")
       
   129 	end
       
   130 
       
   131 end
       
   132 
       
   133 
       
   134 
       
   135 function onGameStart()
       
   136 
       
   137 	ShowMission     (
       
   138                         loc("ROPE-KNOCKING"),
       
   139                         loc("a Hedgewars challenge"),
       
   140                         loc("Use the rope to knock your enemies to their doom.") .. "|" ..
       
   141 
       
   142 						"", -amRope, 4000
       
   143 					)
       
   144 
       
   145 	SetGearPosition(hhs[0], 2419, 1769)
       
   146 	SetGearPosition(hhs[1], 3350, 570)
       
   147 	SetGearPosition(hhs[2], 3039, 1300)
       
   148 	SetGearPosition(hhs[3], 2909, 430)
       
   149 	SetGearPosition(hhs[4], 2150, 879)
       
   150 	SetGearPosition(hhs[5], 1735, 1136)
       
   151 	SetGearPosition(hhs[6], 1563, 553)
       
   152 	SetGearPosition(hhs[7], 679, 859)
       
   153 	SetGearPosition(hhs[8], 1034, 251)
       
   154 	SetGearPosition(hhs[9], 255, 67)
       
   155 	SetGearPosition(hhs[10], 2671, 7)
       
   156 	SetGearPosition(hhs[11], 2929, 244)
       
   157 	SetGearPosition(hhs[12], 1946, 221)
       
   158 	SetGearPosition(hhs[13], 3849, 1067)
       
   159 	SetGearPosition(hhs[14], 3360, 659)
       
   160 	SetGearPosition(hhs[15], 3885, 285)
       
   161 	SetGearPosition(hhs[16], 935, 1160)
       
   162 
       
   163 	for i = 1, 16 do
       
   164 		AssignCharacter(i)
       
   165 	end
       
   166 
       
   167 end
       
   168 
       
   169 function onGameTick()
       
   170 
       
   171 	if (TurnTimeLeft == 1) and (missionWon == nil) then
       
   172 		GameOverMan()
       
   173 	end
       
   174 
       
   175 	if missionWon ~= nil then
       
   176 
       
   177 		endTimer = endTimer - 1
       
   178 		if endTimer == 1 then
       
   179 			GenericEnd()
       
   180 		end
       
   181 
       
   182 		if missionWon == true then
       
   183 			AddCaption(loc("GG!"), 0xffba00ff,capgrpGameState)
       
   184 		else
       
   185 			AddCaption(loc("Ouch!"), 0xffba00ff,capgrpGameState)
       
   186 		end
       
   187 
       
   188 	end
       
   189 
       
   190 end
       
   191 
       
   192 function onGearDamage(gear, damage)
       
   193 
       
   194 	if gear ~= hhs[0] then
       
   195 
       
   196 		AddVisualGear(GetX(gear), GetY(gear), vgtBigExplosion, 0, false)
       
   197 		DeleteGear(gear)
       
   198 		PlaySound(sndExplosion)
       
   199 
       
   200 		hogsKilled = hogsKilled +1
       
   201 		if hogsKilled == 15 then
       
   202 			PlaySound(sndRideOfTheValkyries)
       
   203 		elseif hogsKilled == 16 then
       
   204 			GG()
       
   205 		end
       
   206 
       
   207 	end
       
   208 
       
   209 end
       
   210 
       
   211 function onGearDelete(gear)
       
   212 
       
   213 	if (gear == hhs[0]) and (missionWon == nil) then
       
   214 		GameOverMan()
       
   215 	end
       
   216 
       
   217 end
       
   218 
       
   219 function onAmmoStoreInit()
       
   220 	SetAmmo(amRope, 9, 0, 0, 0)
       
   221 end