share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/desert01.lua
changeset 12525 767920fd03a1
parent 12521 1877ca9e8703
child 12526 6115bf1156ec
equal deleted inserted replaced
12524:a5ddc6b4abbd 12525:767920fd03a1
   286 	return false
   286 	return false
   287 end
   287 end
   288 
   288 
   289 function onHeroAtFirstBattle(gear)
   289 function onHeroAtFirstBattle(gear)
   290 	if not hero.dead and not heroIsInBattle and GetHealth(smuggler1.gear) and GetX(hero.gear) <= 1450 and GetX(hero.gear) > 80
   290 	if not hero.dead and not heroIsInBattle and GetHealth(smuggler1.gear) and GetX(hero.gear) <= 1450 and GetX(hero.gear) > 80
   291 			and GetY(hero.gear) <= GetY(smuggler1.gear)+5 and GetY(hero.gear) >= GetY(smuggler1.gear)-40 and StoppedGear(hero.gear) then
   291 			and GetY(hero.gear) <= GetY(smuggler1.gear)+5 and GetY(hero.gear) >= GetY(smuggler1.gear)-40 and
       
   292 			-- If hero is standing or at a rope
       
   293 			(StoppedGear(hero.gear) or GetGearElasticity(hero.gear) ~= 0) then
   292 		return true
   294 		return true
   293 	end
   295 	end
   294 	return false
   296 	return false
   295 end
   297 end
   296 
   298 
   304 end
   306 end
   305 
   307 
   306 -- saves the location of the hero and prompts him for the second battle
   308 -- saves the location of the hero and prompts him for the second battle
   307 function onHeroAtBattlePoint1(gear)
   309 function onHeroAtBattlePoint1(gear)
   308 	if not hero.dead and GetX(hero.gear) > 1000 and GetX(hero.gear) < 1100
   310 	if not hero.dead and GetX(hero.gear) > 1000 and GetX(hero.gear) < 1100
   309 			and GetY(hero.gear) > 590 and GetY(hero.gear) < 700 and StoppedGear(hero.gear) then
   311 			and GetY(hero.gear) > 590 and GetY(hero.gear) < 700 and StoppedGear(hero.gear)
       
   312 			and (StoppedGear(hero.gear) or GetGearElasticity(hero.gear) ~= 0) then
   310 		return true
   313 		return true
   311 	end
   314 	end
   312 	return false
   315 	return false
   313 end
   316 end
   314 
   317 
   315 function onHeroAtBattlePoint2(gear)
   318 function onHeroAtBattlePoint2(gear)
   316 	if not hero.dead and GetX(hero.gear) > 1610 and GetX(hero.gear) < 1680
   319 	if not hero.dead and GetX(hero.gear) > 1610 and GetX(hero.gear) < 1680
   317 			and GetY(hero.gear) > 850 and GetY(hero.gear) < 1000 and StoppedGear(hero.gear) then
   320 			and GetY(hero.gear) > 850 and GetY(hero.gear) < 1000
       
   321 			and (StoppedGear(hero.gear) or GetGearElasticity(hero.gear) ~= 0) then
   318 		return true
   322 		return true
   319 	end
   323 	end
   320 	return false
   324 	return false
   321 end
   325 end
   322 
   326 
   355 	lose()
   359 	lose()
   356 end
   360 end
   357 
   361 
   358 function heroAtFirstBattle(gear)
   362 function heroAtFirstBattle(gear)
   359 	AnimCaption(hero.gear, loc("A smuggler! Prepare for battle"), 5000)
   363 	AnimCaption(hero.gear, loc("A smuggler! Prepare for battle"), 5000)
       
   364 	-- Hog gets scared if on rope
       
   365 	if GetGearElasticity(hero.gear) ~= 0 then
       
   366 		HogSay(hero.gear, loc("Gasp! A smuggler!"), SAY_SHOUT)
       
   367 	end
       
   368 	-- Remember velocity to restore it later
       
   369 	local dx, dy = GetGearVelocity(hero.gear)
   360 	EndTurn(true)
   370 	EndTurn(true)
   361 	heroIsInBattle = true
   371 	heroIsInBattle = true
   362 	ongoingBattle = 1
   372 	ongoingBattle = 1
   363 	AnimSwitchHog(smuggler1.gear)
   373 	AnimSwitchHog(smuggler1.gear)
   364 	EndTurn(true)
   374 	EndTurn(true)
       
   375 	SetGearVelocity(hero.gear, dx, dy)
   365 end
   376 end
   366 
   377 
   367 function heroFleeFirstBattle(gear)
   378 function heroFleeFirstBattle(gear)
   368 	AnimSay(smuggler1.gear, loc("Run away, you coward!"), SAY_SHOUT, 4000)
   379 	AnimSay(smuggler1.gear, loc("Run away, you coward!"), SAY_SHOUT, 4000)
   369 	EndTurn(true)
   380 	EndTurn(true)
   381 
   392 
   382 function heroAtThirdBattle(gear)
   393 function heroAtThirdBattle(gear)
   383 	heroIsInBattle = true
   394 	heroIsInBattle = true
   384 	ongoingBattle = 3
   395 	ongoingBattle = 3
   385 	AnimSay(smuggler3.gear, loc("Who's there?! I'll get you!"), SAY_SHOUT, 5000)
   396 	AnimSay(smuggler3.gear, loc("Who's there?! I'll get you!"), SAY_SHOUT, 5000)
       
   397 	-- Hog gets scared and falls from rope
       
   398 	if GetGearElasticity(hero.gear) ~= 0 then
       
   399 		HogSay(hero.gear, loc("Yikes!"), SAY_SHOUT)
       
   400 	end
       
   401 	local dx, dy = GetGearVelocity(hero.gear)
   386 	AnimSwitchHog(smuggler3.gear)
   402 	AnimSwitchHog(smuggler3.gear)
   387 	EndTurn(true)
   403 	EndTurn(true)
       
   404 	SetGearVelocity(hero.gear, dx, dy)
   388 end
   405 end
   389 
   406 
   390 function crateDestroyed(gear)
   407 function crateDestroyed(gear)
   391 	lose()
   408 	lose()
   392 end
   409 end
   447 function secondBattle()
   464 function secondBattle()
   448 	-- second battle
   465 	-- second battle
   449 	if heroIsInBattle and ongoingBattle == 1 then
   466 	if heroIsInBattle and ongoingBattle == 1 then
   450 		AnimSay(smuggler1.gear, loc("Get him, Spike!"), SAY_SHOUT, 4000)
   467 		AnimSay(smuggler1.gear, loc("Get him, Spike!"), SAY_SHOUT, 4000)
   451 	end
   468 	end
       
   469 	-- Hog gets scared if on rope
       
   470 	if GetGearElasticity(hero.gear) ~= 0 then
       
   471 		HogSay(hero.gear, loc("Gasp!"), SAY_SHOUT)
       
   472 	end
       
   473 	local dx, dy = GetGearVelocity(hero.gear)
   452 	heroIsInBattle = true
   474 	heroIsInBattle = true
   453 	ongoingBattle = 2
   475 	ongoingBattle = 2
   454 	AnimSay(smuggler2.gear, loc("This is seems like a wealthy hedgehog, nice ..."), SAY_THINK, 5000)
   476 	AnimSay(smuggler2.gear, loc("This is seems like a wealthy hedgehog, nice ..."), SAY_THINK, 5000)
   455 	AnimSwitchHog(smuggler2.gear)
   477 	AnimSwitchHog(smuggler2.gear)
   456 	EndTurn(true)
   478 	EndTurn(true)
       
   479 	SetGearVelocity(hero.gear, dx, dy)
   457 end
   480 end
   458 
   481 
   459 function checkForWin()
   482 function checkForWin()
   460 	if cratesFound ==  0 then
   483 	if cratesFound ==  0 then
   461 		-- have to look more
   484 		-- have to look more