changed map and fixed some bugs regarding hog turning and adding more teleport spacecampaign
authorPeriklis Ntanasis <pntanasis@gmail.com>
Thu, 29 Aug 2013 19:36:27 +0300
branchspacecampaign
changeset 9593 ac522dd06f00
parent 9592 a39cb287e83e
child 9594 749ef5bd0eaf
changed map and fixed some bugs regarding hog turning and adding more teleport
share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/fruit03.hwp
share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/fruit03.lua
Binary file share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/fruit03.hwp has changed
--- a/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/fruit03.lua	Thu Aug 29 16:18:13 2013 +0300
+++ b/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/fruit03.lua	Thu Aug 29 19:36:27 2013 +0300
@@ -11,32 +11,33 @@
 ----------------- VARIABLES --------------------
 -- globals
 local missionName = loc("Precise shooting")
+local timeLeft = 10000
+local lastWeaponUsed = amSniperRifle
 -- hogs
 local hero = {
 	name = loc("Hog Solo"),
-	x = 1830,
-	y = 560,
-	dead = false
+	x = 1100,
+	y = 560
 }
 local enemiesOdd = {
-	{name = "Hog 1", x = 3670 , y = 175},
-	{name = "Hog 3", x = 3795 , y = 1110},
-	{name = "Hog 5", x = 1950 , y = 1480},
-	{name = "Hog 7", x = 400 , y = 920},
-	{name = "Hog 9", x = 1100 , y = 1950},
-	{name = "Hog 11", x = 1200 , y = 1950},
-	{name = "Hog 13", x = 2300 , y = 1950},
-	{name = "Hog 15", x = 2400 , y = 1950},
+	{name = "Hog 1", x = 2000 , y = 175},
+	{name = "Hog 3", x = 1950 , y = 1110},
+	{name = "Hog 5", x = 1270 , y = 1480},
+	{name = "Hog 7", x = 240 , y = 790},
+	{name = "Hog 9", x = 620 , y = 1950},
+	{name = "Hog 11", x = 720 , y = 1950},
+	{name = "Hog 13", x = 1620 , y = 1950},
+	{name = "Hog 15", x = 1720 , y = 1950},
 }
 local enemiesEven = {
-	{name = "Hog 2", x = 660, y = 170},
-	{name = "Hog 4", x = 1900, y = 1320},
-	{name = "Hog 6", x = 2030, y = 1335},
-	{name = "Hog 8", x = 1300, y = 1950},
-	{name = "Hog 10", x = 1400, y = 1950},
-	{name = "Hog 12", x = 2500, y = 1950},
-	{name = "Hog 14", x = 2600, y = 1950},
-	{name = "Hog 16", x = 1850, y = 560},
+	{name = "Hog 2", x = 660, y = 140},
+	{name = "Hog 4", x = 1120, y = 1250},
+	{name = "Hog 6", x = 1290, y = 1250},
+	{name = "Hog 8", x = 820, y = 1950},
+	{name = "Hog 10", x = 920, y = 1950},
+	{name = "Hog 12", x = 1820, y = 1950},
+	{name = "Hog 14", x = 1920, y = 1950},
+	{name = "Hog 16", x = 1200, y = 560},
 }
 -- teams
 local teamA = {
@@ -57,7 +58,7 @@
 function onGameInit()
 	GameFlags = gfDisableWind + gfInfAttack
 	Seed = 1
-	TurnTime = 25000
+	TurnTime = 15000
 	CaseFreq = 0
 	MinesNum = 0
 	MinesTime = 1
@@ -74,13 +75,11 @@
 	for i=1,table.getn(enemiesEven) do
 		enemiesEven[i].gear = AddHog(enemiesEven[i].name, 1, 100, "war_desertgrenadier1")
 		AnimSetGearPosition(enemiesEven[i].gear, enemiesEven[i].x, enemiesEven[i].y)
-		enemiesEven[i].turnLeft = false
 	end	
 	AddTeam(teamB.name, teamB.color, "Bone", "Island", "HillBilly", "cm_birdy")
 	for i=1,table.getn(enemiesOdd) do
 		enemiesOdd[i].gear = AddHog(enemiesOdd[i].name, 1, 100, "war_desertgrenadier1")
 		AnimSetGearPosition(enemiesOdd[i].gear, enemiesOdd[i].x, enemiesOdd[i].y)
-		enemiesOdd[i].turnLeft = false
 	end
 	
 	initCheckpoint("fruit03")
@@ -96,24 +95,42 @@
 	AddEvent(onHeroDeath, {hero.gear}, heroDeath, {hero.gear}, 0)
 	
 	--hero ammo
+	AddAmmo(hero.gear, amSkip, 1)
 	AddAmmo(hero.gear, amTeleport, 2)
 	AddAmmo(hero.gear, amSniperRifle, 2)
 	AddAmmo(hero.gear, amWatermelon, 2)
 	--enemies ammo
+	AddAmmo(enemiesOdd[1].gear, amDEagle, 100)
 	AddAmmo(enemiesOdd[1].gear, amSniperRifle, 100)
 	AddAmmo(enemiesOdd[1].gear, amWatermelon, 1)
+	AddAmmo(enemiesOdd[1].gear, amGrenade, 5)
+	AddAmmo(enemiesEven[1].gear, amDEagle, 100)
 	AddAmmo(enemiesEven[1].gear, amSniperRifle, 100)
 	AddAmmo(enemiesEven[1].gear, amWatermelon, 1)
+	AddAmmo(enemiesEven[1].gear, amGrenade, 5)
 	
 	SendHealthStatsOff()
 end
 
 function onNewTurn()
+	if CurrentHedgehog == hero.gear then
+		TurnTimeLeft = TurnTime + timeLeft
+		timeLeft = 0
+	end
+	turnHogs()
 	WriteLnToConsole("NEW TURN")
 end
 
 function onGameTick20()
-	turnHogs()
+	--WriteLnToConsole("TURN TIME LEFT : "..timeLeft)
+	if CurrentHedgehog == hero.gear and GetAmmoCount(hero.gear, amSkip) == 0 then
+		AddAmmo(hero.gear, amSkip, 1)
+		--WriteLnToConsole("----- TURN TIME LEFT : "..TurnTimeLeft)
+		timeLeft = TurnTimeLeft
+		--WriteLnToConsole("***** TURN TIME LEFT : "..timeLeft)
+		TurnTimeLeft = 0
+	--WriteLnToConsole("NEW TURN TIME LEFT : "..timeLeft)
+	end
 end
 
 function onGearDamage(gear, damage)
@@ -122,12 +139,22 @@
 end
 
 function onGearDelete(gear)
-	if gear == hero.gear then
-		hero.dead = true
-	else
-		AddAmmo(hero.gear, amTeleport, 2)
-		AddAmmo(hero.gear, amSniperRifle, 2)
-		AddAmmo(hero.gear, amWatermelon, 2)
+	WriteLnToConsole("HERO : "..hero.gear)
+	WriteLnToConsole("GEAR : "..gear)
+	WriteLnToConsole("UPPER BOUND : "..enemiesOdd[table.getn(enemiesOdd)].gear)
+	WriteLnToConsole("UPPER BOUND : "..enemiesEven[table.getn(enemiesEven)].gear)
+	
+	if (gear > hero.gear and gear <= enemiesOdd[table.getn(enemiesOdd)].gear) or 
+			(gear > hero.gear and gear <= enemiesEven[table.getn(enemiesEven)].gear) then
+		WriteLnToConsole("NOT HERO GEAR")
+		local availableTeleports = GetAmmoCount(hero.gear,amTeleport)
+		local availableSniper = GetAmmoCount(hero.gear,amSniperRifle)
+		if availableTeleports < 2 then
+			AddAmmo(hero.gear, amTeleport, availableTeleports + 1 )
+		end
+		if availableSniper < 3 then
+			AddAmmo(hero.gear, amSniperRifle, availableSniper + 1 )
+		end
 	end
 	WriteLnToConsole("GEAR KILLED")
 end
@@ -135,7 +162,7 @@
 -------------- EVENTS ------------------
 
 function onHeroDeath(gear)
-	if hero.dead then
+	if not GetHealth(hero.gear) then
 		return true
 	end
 	return false
@@ -145,7 +172,7 @@
 
 -- game ends anyway but I want to sent custom stats probably...
 function heroDeath(gear)
-	heroLost()
+	EndGame()
 end
 
 ------------------ Other Functions -------------------
@@ -154,18 +181,18 @@
 	if GetHealth(hero.gear) then
 		for i=1,table.getn(enemiesEven) do
 			if GetHealth(enemiesEven[i].gear) then
-				if GetX(enemiesEven[i].gear) < GetX(hero.gear) and enemiesEven[i].turnLeft then
+				if GetX(enemiesEven[i].gear) < GetX(hero.gear) then
 					HogTurnLeft(enemiesEven[i].gear, false)
-				elseif GetX(enemiesEven[i].gear) > GetX(hero.gear) and not enemiesEven[i].turnLeft then
+				elseif GetX(enemiesEven[i].gear) > GetX(hero.gear) then
 					HogTurnLeft(enemiesEven[i].gear, true)
 				end
 			end
 		end
 		for i=1,table.getn(enemiesOdd) do
 			if GetHealth(enemiesOdd[i].gear) then
-				if GetX(enemiesOdd[i].gear) < GetX(hero.gear) and enemiesOdd[i].turnLeft then
+				if GetX(enemiesOdd[i].gear) < GetX(hero.gear) then
 					HogTurnLeft(enemiesOdd[i].gear, false)
-				elseif GetX(enemiesOdd[i].gear) > GetX(hero.gear) and not enemiesOdd[i].turnLeft then
+				elseif GetX(enemiesOdd[i].gear) > GetX(hero.gear) then
 					HogTurnLeft(enemiesOdd[i].gear, true)
 				end
 			end