share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/fruit02.lua
branchspacecampaign
changeset 9552 90d69a2c1729
parent 9550 59061246a25c
child 9554 054eede3b718
equal deleted inserted replaced
9550:59061246a25c 9552:90d69a2c1729
    25 	[dialog02] = {missionName, loc("Getting the Device"), loc("Explore the tunnel with the other hogs and search for the device").."|"..loc("Hog Solo has to reach the last crates"), 1, 4000},
    25 	[dialog02] = {missionName, loc("Getting the Device"), loc("Explore the tunnel with the other hogs and search for the device").."|"..loc("Hog Solo has to reach the last crates"), 1, 4000},
    26 	[dialog03] = {missionName, loc("Return to the Surface"), loc("Go to the surface!").."|"..loc("Attack Captain Lime before he attacks back"), 1, 4000},
    26 	[dialog03] = {missionName, loc("Return to the Surface"), loc("Go to the surface!").."|"..loc("Attack Captain Lime before he attacks back"), 1, 4000},
    27 	[dialog04] = {missionName, loc("Return to the Surface"), loc("Go to the surface!").."|"..loc("Attack the assasins before they attack back"), 1, 4000},
    27 	[dialog04] = {missionName, loc("Return to the Surface"), loc("Go to the surface!").."|"..loc("Attack the assasins before they attack back"), 1, 4000},
    28 }
    28 }
    29 -- crates
    29 -- crates
    30 local crates = {
    30 local eagleCrate = {name = amDEagle, x = 1680, y = 1650}
    31 	{name = amDEagle, x = 1680, y = 1650},
    31 local girderCrate =	{name = amGirder, x = 1680, y = 1160}
    32 	{name = amGirder, x = 1680, y = 1160},
    32 local ropeCrate = {name = amRope, x = 1400, y = 1870}
    33 	{name = amRope, x = 1400, y = 1870},
       
    34 }
       
    35 local weaponCrate = { x = 1360, y = 1870}
    33 local weaponCrate = { x = 1360, y = 1870}
    36 -- hogs
    34 -- hogs
    37 local hero = {}
    35 local hero = {}
    38 local green1 = {}
    36 local green1 = {}
    39 local green2 = {}
    37 local green2 = {}
    83 	Map = "fruit02_map"
    81 	Map = "fruit02_map"
    84 	Theme = "Fruit"
    82 	Theme = "Fruit"
    85 	
    83 	
    86 	WriteLnToConsole("CHECKPOINT IS "..checkPointReached)
    84 	WriteLnToConsole("CHECKPOINT IS "..checkPointReached)
    87 	-- load checkpoints, problem getting the campaign variable
    85 	-- load checkpoints, problem getting the campaign variable
    88 	--local h = GetCampaignVar("Desert01CheckPoint")
    86 	local health = 100
    89 	--WriteLnToCosnole("HERE "..GetCampaignVar("Fruit02CheckPoint"))
       
    90 	if tonumber(GetCampaignVar("Fruit02CheckPoint")) then
    87 	if tonumber(GetCampaignVar("Fruit02CheckPoint")) then
    91 		WriteLnToConsole("**TRUE**")
    88 		WriteLnToConsole("**TRUE**")
    92 		checkPointReached = tonumber(GetCampaignVar("Fruit02CheckPoint"))
    89 		checkPointReached = tonumber(GetCampaignVar("Fruit02CheckPoint"))
    93 		if checkPointReached == 2 or checkPointReached == 3 then
    90 		if checkPointReached ~= 1 then
    94 			WriteLnToConsole("++++++++++++++HEEEEEEEREEEEEEEEEEEEE")
    91 			WriteLnToConsole("++++++++++++++HEEEEEEEREEEEEEEEEEEEE")
    95 			loadHogsPositions()
    92 			loadHogsPositions()
       
    93 			health = tonumber(GetCampaignVar("HeroHealth"))
    96 		end
    94 		end
    97 	end
    95 	end
    98 	
    96 	
    99 	WriteLnToConsole("CHECKPOINT IS "..checkPointReached)
    97 	WriteLnToConsole("CHECKPOINT IS "..checkPointReached)
   100 	-- Hog Solo and Green Bananas
    98 	-- Hog Solo and Green Bananas
   101 	AddTeam(teamA.name, teamA.color, "Bone", "Island", "HillBilly", "cm_birdy")
    99 	AddTeam(teamA.name, teamA.color, "Bone", "Island", "HillBilly", "cm_birdy")
   102 	hero.gear = AddHog(hero.name, 0, 100, "war_desertgrenadier1")
   100 	hero.gear = AddHog(hero.name, 0, health, "war_desertgrenadier1")
   103 	AnimSetGearPosition(hero.gear, hero.x, hero.y)
   101 	AnimSetGearPosition(hero.gear, hero.x, hero.y)
   104 	HogTurnLeft(hero.gear, true)	
   102 	HogTurnLeft(hero.gear, true)	
   105 	green2.gear = AddHog(green2.name, 0, 100, "war_desertgrenadier1")
   103 	green2.gear = AddHog(green2.name, 0, 100, "war_desertgrenadier1")
   106 	AnimSetGearPosition(green2.gear, green2.x, green2.y)
   104 	AnimSetGearPosition(green2.gear, green2.x, green2.y)
   107 	HogTurnLeft(green2.gear, true)
   105 	HogTurnLeft(green2.gear, true)
   151 	AddAmmo(redHedgehogs[1].bot, amDEagle, 6)
   149 	AddAmmo(redHedgehogs[1].bot, amDEagle, 6)
   152 	for i=1,table.getn(redHedgehogs) do
   150 	for i=1,table.getn(redHedgehogs) do
   153 		HideHog(redHedgehogs[i].gear)
   151 		HideHog(redHedgehogs[i].gear)
   154 	end
   152 	end
   155 	
   153 	
   156 	-- place crates
       
   157 	for i=1,table.getn(crates) do
       
   158 		SpawnAmmoCrate(crates[i].x, crates[i].y, crates[i].name)
       
   159 	end
       
   160 	if tookPartInBattle then
       
   161 		SpawnAmmoCrate(weaponCrate.x, weaponCrate.y, amWatermelon)
       
   162 	else
       
   163 		SpawnAmmoCrate(weaponCrate.x, weaponCrate.y, amSniperRifle)		
       
   164 	end
       
   165 	
       
   166 	-- explosives
   154 	-- explosives
   167 	-- I wanted to use FindPlace but doesn't accept height values...
   155 	-- I wanted to use FindPlace but doesn't accept height values...
   168 	local x1 = 950
   156 	local x1 = 950
   169 	local x2 = 1306
   157 	local x2 = 1306
   170 	local y1 = 1210
   158 	local y1 = 1210
   192 	AddGear(3175, 1680, gtMine, 0, 0, 0, 0)
   180 	AddGear(3175, 1680, gtMine, 0, 0, 0, 0)
   193 	AddGear(3115, 1680, gtMine, 0, 0, 0, 0)
   181 	AddGear(3115, 1680, gtMine, 0, 0, 0, 0)
   194 	AddGear(3105, 1680, gtMine, 0, 0, 0, 0)
   182 	AddGear(3105, 1680, gtMine, 0, 0, 0, 0)
   195 	AddGear(3095, 1680, gtMine, 0, 0, 0, 0)
   183 	AddGear(3095, 1680, gtMine, 0, 0, 0, 0)
   196 	AddGear(3085, 1680, gtMine, 0, 0, 0, 0)
   184 	AddGear(3085, 1680, gtMine, 0, 0, 0, 0)
   197 	AddGear(3075, 1680, gtMine, 0, 0, 0, 0)
   185 	AddGear(3075, 1680, gtMine, 0, 0, 0, 0)	
   198 	
   186 
   199 	if tookPartInBattle then
       
   200 		AddAnim(dialog01)
       
   201 	else
       
   202 		AddAnim(dialog02)
       
   203 	end
       
   204 	WriteLnToConsole("CHECKPOINT IS "..checkPointReached)
   187 	WriteLnToConsole("CHECKPOINT IS "..checkPointReached)
   205 	if checkPointReached == 1 then
   188 	if checkPointReached == 1 then
   206 		AddAmmo(hero.gear, amFirePunch, 3)
   189 		AddAmmo(hero.gear, amFirePunch, 3)
   207 		AddEvent(onCheckPoint1, {hero.gear}, checkPoint1, {hero.gear}, 0)
   190 		AddEvent(onCheckPoint1, {hero.gear}, checkPoint1, {hero.gear}, 0)
   208 		AddEvent(onCheckPoint2, {hero.gear}, checkPoint2, {hero.gear}, 0)	
   191 		AddEvent(onCheckPoint2, {hero.gear}, checkPoint2, {hero.gear}, 0)
       
   192 		AddEvent(onCheckPoint3, {hero.gear}, checkPoint3, {hero.gear}, 0)
       
   193 		AddEvent(onCheckPoint4, {hero.gear}, checkPoint4, {hero.gear}, 0)
       
   194 		if tookPartInBattle then
       
   195 			AddAnim(dialog01)
       
   196 		else
       
   197 			AddAnim(dialog02)
       
   198 		end
   209 	elseif checkPointReached == 2 then
   199 	elseif checkPointReached == 2 then
       
   200 		AddEvent(onCheckPoint2, {hero.gear}, checkPoint2, {hero.gear}, 0)
       
   201 		AddEvent(onCheckPoint3, {hero.gear}, checkPoint3, {hero.gear}, 0)
       
   202 		AddEvent(onCheckPoint4, {hero.gear}, checkPoint4, {hero.gear}, 0)
       
   203 	elseif checkPointReached == 3 then
       
   204 		AddEvent(onCheckPoint1, {hero.gear}, checkPoint1, {hero.gear}, 0)
       
   205 		AddEvent(onCheckPoint3, {hero.gear}, checkPoint3, {hero.gear}, 0)
       
   206 		AddEvent(onCheckPoint4, {hero.gear}, checkPoint4, {hero.gear}, 0)
       
   207 	elseif checkPointReached == 4 then
       
   208 		AddEvent(onCheckPoint4, {hero.gear}, checkPoint4, {hero.gear}, 0)		
       
   209 	elseif checkPointReached == 5 then
       
   210 		-- EMPTY
       
   211 	end
       
   212 	if checkPointReached ~= 1 then
   210 		loadWeapons()
   213 		loadWeapons()
   211 		AddEvent(onCheckPoint2, {hero.gear}, checkPoint2, {hero.gear}, 0)
   214 	end
   212 	elseif checkPointReached == 3 then
   215 	
   213 		loadWeapons()
   216 	-- girders
   214 		AddEvent(onCheckPoint1, {hero.gear}, checkPoint1, {hero.gear}, 0)
   217 	if checkPointReached > 1 then
       
   218 		PlaceGirder(1580, 875, 4)
       
   219 		PlaceGirder(1800, 875, 4)
       
   220 	end
       
   221 	
       
   222 	-- place crates
       
   223 	if checkPointReached < 2 then
       
   224 		SpawnAmmoCrate(girderCrate.x, girderCrate.y, girderCrate.name)
       
   225 	end
       
   226 	if checkPointReached < 5 then
       
   227 		SpawnAmmoCrate(eagleCrate.x, eagleCrate.y, eagleCrate.name)
       
   228 	end
       
   229 	SpawnAmmoCrate(ropeCrate.x, ropeCrate.y, ropeCrate.name)
       
   230 
       
   231 	if tookPartInBattle then
       
   232 		SpawnAmmoCrate(weaponCrate.x, weaponCrate.y, amWatermelon)
       
   233 	else
       
   234 		SpawnAmmoCrate(weaponCrate.x, weaponCrate.y, amSniperRifle)		
   215 	end
   235 	end
   216 	
   236 	
   217 	SendHealthStatsOff()
   237 	SendHealthStatsOff()
   218 end
   238 end
   219 
   239 
   283 	end
   303 	end
   284 	return false
   304 	return false
   285 end
   305 end
   286 
   306 
   287 function onDeviceCrates(gear)
   307 function onDeviceCrates(gear)
   288 	if not hero.dead and GetY(hero.gear)>1850 and GetX(hero.gear)>1340 then
   308 	if not hero.dead and GetY(hero.gear)>1850 and GetX(hero.gear)>1340 and GetX(hero.gear)<1640 then
   289 		return true
   309 		return true
   290 	end
   310 	end
   291 	return false
   311 	return false
   292 end
   312 end
   293 
   313 
   316 	return redDead
   336 	return redDead
   317 end
   337 end
   318 
   338 
   319 function onCheckPoint1(gear)
   339 function onCheckPoint1(gear)
   320 	-- before barrel jump
   340 	-- before barrel jump
   321 	if GetX(hero.gear) > 2850 and GetX(hero.gear) < 2945 and GetY(hero.gear) > 808 and GetY(hero.gear) < 852
   341 	if not hero.dead and GetX(hero.gear) > 2850 and GetX(hero.gear) < 2945 
   322 			and	not isHeroAtWrongPlace() then
   342 			and GetY(hero.gear) > 808 and GetY(hero.gear) < 852 and	not isHeroAtWrongPlace() then
   323 		return true
   343 		return true
   324 	end
   344 	end
   325 	return false
   345 	return false
   326 end
   346 end
   327 
   347 
   328 function onCheckPoint2(gear)
   348 function onCheckPoint2(gear)
   329 	-- before barrel jump
   349 	-- before barrel jump
   330 	if ((GetX(green2.gear) > 2850 and GetX(green2.gear) < 2945 and GetY(green2.gear) > 808 and GetY(green2.gear) < 852)
   350 	if ((GetHealth(green2.gear) and GetX(green2.gear) > 2850 and GetX(green2.gear) < 2945 and GetY(green2.gear) > 808 and GetY(green2.gear) < 852)
   331 			or (GetX(green3.gear) > 2850 and GetX(green3.gear) < 2945 and GetY(green3.gear) > 808 and GetY(green3.gear) < 852))
   351 			or (GetHealth(green3.gear) and GetX(green3.gear) > 2850 and GetX(green3.gear) < 2945 and GetY(green3.gear) > 808 and GetY(green3.gear) < 852))
   332 			and not isHeroAtWrongPlace() then
   352 			and not isHeroAtWrongPlace() then
       
   353 		return true
       
   354 	end
       
   355 	return false
       
   356 end
       
   357 
       
   358 function onCheckPoint3(gear)
       
   359 	-- after barrel jump
       
   360 	if ((GetHealth(green2.gear) and GetY(green2.gear) > 1550 and GetX(green2.gear) < 3000 and StoppedGear(green2.gear)) 
       
   361 			or (GetHealth(green3.gear) and GetY(green3.gear) > 1550 and GetX(green3.gear) < 3000 and StoppedGear(green2.gear)))
       
   362 			and not isHeroAtWrongPlace() then
       
   363 		return true
       
   364 	end
       
   365 	return false
       
   366 end
       
   367 
       
   368 function onCheckPoint4(gear)
       
   369 	-- hero at crates
       
   370 	if not hero.dead and GetX(hero.gear) > 1288 and GetX(hero.gear) < 1420 
       
   371 			and GetY(hero.gear) > 1840 and	not isHeroAtWrongPlace() then
   333 		return true
   372 		return true
   334 	end
   373 	end
   335 	return false
   374 	return false
   336 end
   375 end
   337 
   376 
   405 	SendStat('siPlayerKills','0',teamC.name)
   444 	SendStat('siPlayerKills','0',teamC.name)
   406 	EndGame()
   445 	EndGame()
   407 end
   446 end
   408 
   447 
   409 function checkPoint1(gear)
   448 function checkPoint1(gear)
   410 	AnimCaption(hero.gear, loc("Checkpoint reached!"), 3000)
   449 	saveCheckPoint(2)
   411 	SaveCampaignVar("Fruit02CheckPoint", 2)
       
   412 	saveHogsPositions()
       
   413 	saveWeapons()
       
   414 end
   450 end
   415 
   451 
   416 function checkPoint2(gear)
   452 function checkPoint2(gear)
   417 	AnimCaption(hero.gear, loc("Checkpoint reached!"), 3000)
   453 	saveCheckPoint(3)
   418 	SaveCampaignVar("Fruit02CheckPoint", 3)
   454 end
   419 	saveHogsPositions()
   455 
   420 	saveWeapons()
   456 function checkPoint3(gear)
       
   457 	saveCheckPoint(4)
       
   458 end
       
   459 
       
   460 function checkPoint4(gear)
       
   461 	saveCheckPoint(5)
   421 end
   462 end
   422 
   463 
   423 -------------- ANIMATIONS ------------------
   464 -------------- ANIMATIONS ------------------
   424 
   465 
   425 function Skipanim(anim)
   466 function Skipanim(anim)
   519 		green2.y = tonumber(positions[4])
   560 		green2.y = tonumber(positions[4])
   520 	end
   561 	end
   521 	if positions[5] then
   562 	if positions[5] then
   522 		green3.x = tonumber(positions[5])
   563 		green3.x = tonumber(positions[5])
   523 		green3.y = tonumber(positions[6])
   564 		green3.y = tonumber(positions[6])
       
   565 		WriteLnToConsole("---------"..green3.y)
   524 	end
   566 	end
   525 end
   567 end
   526 
   568 
   527 function saveWeapons()
   569 function saveWeapons()
   528 	-- firepunch - gilder - deagle - watermelon - sniper
   570 	-- firepunch - gilder - deagle - watermelon - sniper
   529 	WriteLnToConsole("SAVE WEAPONS TRIGGERED: "..GetAmmoCount(hero.gear, amFirePunch)..GetAmmoCount(hero.gear, amGilder)..
   571 	WriteLnToConsole("SAVE WEAPONS TRIGGERED: "..GetAmmoCount(hero.gear, amFirePunch)..GetAmmoCount(hero.gear, amGilder)..
   530 			GetAmmoCount(hero.gear, amDEagle)..GetAmmoCount(hero.gear, amWatermelon)..GetAmmoCount(hero.gear, amSniperRifle))
   572 			GetAmmoCount(hero.gear, amDEagle)..GetAmmoCount(hero.gear, amWatermelon)..GetAmmoCount(hero.gear, amSniperRifle))
   531 	SaveCampaignVar("HeroAmmo", GetAmmoCount(hero.gear, amFirePunch)..GetAmmoCount(hero.gear, amGilder)..
   573 	SaveCampaignVar("HeroAmmo", GetAmmoCount(hero.gear, amFirePunch)..GetAmmoCount(hero.gear, amGirder)..
   532 			GetAmmoCount(hero.gear, amDEagle)..GetAmmoCount(hero.gear, amWatermelon)..GetAmmoCount(hero.gear, amSniperRifle))
   574 			GetAmmoCount(hero.gear, amDEagle)..GetAmmoCount(hero.gear, amWatermelon)..GetAmmoCount(hero.gear, amSniperRifle))
   533 end
   575 end
   534 
   576 
   535 function loadWeapons()
   577 function loadWeapons()
   536 	local ammo = GetCampaignVar("HeroAmmo")
   578 	local ammo = GetCampaignVar("HeroAmmo")
   537 	WriteLnToConsole("LOAD WEAPONS "..ammo)
   579 	WriteLnToConsole("GILDER "..tonumber(ammo:sub(2,2)))
   538 	WriteLnToConsole("LOAD WEAPONS "..ammo:sub(1,1))
       
   539 	AddAmmo(hero.gear, amFirePunch, tonumber(ammo:sub(1,1)))
   580 	AddAmmo(hero.gear, amFirePunch, tonumber(ammo:sub(1,1)))
   540 	AddAmmo(hero.gear, amGilder, tonumber(ammo:sub(2,2)))
   581 	AddAmmo(hero.gear, amGirder, tonumber(ammo:sub(2,2)))
   541 	AddAmmo(hero.gear, amDEagle, tonumber(ammo:sub(3,3)))
   582 	AddAmmo(hero.gear, amDEagle, tonumber(ammo:sub(3,3)))
   542 	AddAmmo(hero.gear, amWatermelon, tonumber(ammo:sub(4,4)))
   583 	AddAmmo(hero.gear, amWatermelon, tonumber(ammo:sub(4,4)))
   543 	AddAmmo(hero.gear, amSniperRifle, tonumber(ammo:sub(5,5)))
   584 	AddAmmo(hero.gear, amSniperRifle, tonumber(ammo:sub(5,5)))
   544 end
   585 end
   545 
   586 
   561 		else
   602 		else
   562 			first = first..s:sub(1,1)
   603 			first = first..s:sub(1,1)
   563 		end
   604 		end
   564 		s = s:sub(2)
   605 		s = s:sub(2)
   565 	end
   606 	end
       
   607 	if first:len() > 0 then
       
   608 		table.insert(res, tonumber(first))
       
   609 	end
   566 	return res
   610 	return res
   567 end
   611 end
       
   612 
       
   613 function saveCheckPoint(cpoint)
       
   614 	AnimCaption(hero.gear, loc("Checkpoint reached!"), 3000)
       
   615 	SaveCampaignVar("Fruit02CheckPoint", cpoint)
       
   616 	SaveCampaignVar("HeroHealth", GetHealth(hero.gear))
       
   617 	saveHogsPositions()
       
   618 	saveWeapons()
       
   619 end