share/hedgewars/Data/Scripts/Multiplayer/Tumbler.lua
changeset 5720 a962d0823f49
parent 5598 265429f7ba85
child 5825 a6eab1b7c00d
equal deleted inserted replaced
5719:0ed1f543f301 5720:a962d0823f49
     1 ------------------------------------
     1 ------------------------------------
     2 -- TUMBLER
     2 -- TUMBLER
     3 -- v.0.6
     3 -- v.0.7
     4 ------------------------------------
     4 ------------------------------------
     5 
     5 
     6 loadfile(GetDataPath() .. "Scripts/Locale.lua")()
     6 loadfile(GetDataPath() .. "Scripts/Locale.lua")()
     7 loadfile(GetDataPath() .. "Scripts/Tracker.lua")()
     7 loadfile(GetDataPath() .. "Scripts/Tracker.lua")()
     8 
     8 
     9 --local fMod = 1	--.15
       
    10 local fMod = 1000000 -- use this for dev and .16+ games
     9 local fMod = 1000000 -- use this for dev and .16+ games
    11 local moveTimer = 0
    10 
    12 local leftOn = false
    11 local leftOn = false
    13 local rightOn = false
    12 local rightOn = false
    14 local upOn = false
    13 local upOn = false
    15 local downOn = false
    14 local downOn = false
    16 
       
    17 local preciseOn = false
    15 local preciseOn = false
    18 --local HJumpOn = false
    16 
    19 --local LJumpON = false
       
    20 local fireTimer = 0
       
    21 local scoreTag = nil
       
    22 local wep = {}
    17 local wep = {}
    23 local wepAmmo = {}
    18 local wepAmmo = {}
       
    19 local wepCol = {}
    24 local wepIndex = 0
    20 local wepIndex = 0
    25 local wepCount = 0
    21 local wepCount = 0
       
    22 local fGears = 0
       
    23 
       
    24 local mineSpawn
       
    25 local barrelSpawn
       
    26 
    26 local roundKills = 0
    27 local roundKills = 0
    27 
    28 local barrelsEaten = 0
       
    29 local minesEaten = 0
       
    30 
       
    31 local moveTimer = 0
       
    32 local fireTimer = 0
    28 local TimeLeftCounter = 0
    33 local TimeLeftCounter = 0
    29 local TimeLeft = 0
    34 local TimeLeft = 0
    30 local stopMovement = false
    35 local stopMovement = false
    31 local tumbleStarted = false
    36 local tumbleStarted = false
    32 
    37 
    33 local beam = false
    38 local vTag = {}
    34 
    39 
    35 ------------------------
    40 ------------------------
    36 -- version 0.4
    41 -- version 0.4
    37 ------------------------
    42 ------------------------
    38 
    43 
    70 -- explosives AND mines can be picked up to increase their relative ammo
    75 -- explosives AND mines can be picked up to increase their relative ammo
    71 -- replaced "no weapon" selected message that hw serves
    76 -- replaced "no weapon" selected message that hw serves
    72 -- modified crate frequencies a bit
    77 -- modified crate frequencies a bit
    73 -- added some simple kill-based achievements, i think
    78 -- added some simple kill-based achievements, i think
    74 
    79 
       
    80 ------------------------
       
    81 -- version 0.7
       
    82 ------------------------
       
    83 
       
    84 -- a few code optimisations/performance tweaks
       
    85 -- removed some deprecated code
       
    86 -- fix a potential spawn bug
       
    87 
       
    88 -- improved HUD (now shows ammo counts)
       
    89 -- improved user feedback (less generic messages)
       
    90 -- colour-coded addcaptions to match hud :)
       
    91 
       
    92 -- base tumbling time now equals scheme turntime
       
    93 -- tumbling time extension is now based on the amount of health contained in crate
       
    94 -- new mines per turn based on minesnum
       
    95 -- new barrels per turn based on explosives
       
    96 
       
    97 -- added 2 more achievements: barrel eater and mine eater (like kills, don't do anything atm)
       
    98 -- slightly increased grab distance for explosives/mines
       
    99 -- slightly increased flamer velocity
       
   100 -- slightly decreased flamer volume
       
   101 -- added a flame vaporiser (based on number of flame gears?)
       
   102 -- give tumblers an extra 47 health on the start of their tumble to counter the grenade (exp)
       
   103 -- refocus camera on tumbler on newturn (not on crates, barrels etc)
       
   104 -- increase delay: yes, yes, eat your hearts out
       
   105 
       
   106 -- commit log
       
   107 -- Better HUD
       
   108 -- Allow more user customization
       
   109 -- Bugfix for new gear spawns
       
   110 -- Performance tweaks
       
   111 -- Variety of small gameplay changes
       
   112 
    75 ---------------------------
   113 ---------------------------
    76 -- some other ideas/things
   114 -- some other ideas/things
    77 ---------------------------
   115 ---------------------------
    78 --[[
   116 --[[
    79 -- fix "ammo extended" message to be non-generic
   117 -- add better gameflag handling
    80 -- fix flamer "shots remaining" message on start or choose a standard versus %
   118 -- fix flamer "shots remaining" message on start or choose a standard versus %
    81 -- add more sounds
   119 -- add more sounds
    82 -- make barrels always explode?
   120 -- better barrel/minespawn effects
    83 -- persistent ammo?
   121 -- separate grab distance for mines/barrels
    84 -- allow custom turntime?
   122 -- [probably not] make barrels always explode?
    85 -- dont hurt tumblers and restore their health at turn end?
   123 -- [probably not] persistent ammo?
       
   124 -- [probably not] dont hurt tumblers and restore their health at turn end?
    86 ]]
   125 ]]
    87 
   126 
    88 function DrawTags()
   127 
       
   128 ----------------------------------------------------------------
       
   129 ----------------------------------------------------------------
       
   130 
       
   131 local flames = {}
       
   132 local fGearValues = {}
       
   133 
       
   134 function runOnflames(func)
       
   135     for k, gear in ipairs(flames) do
       
   136         func(gear)
       
   137     end
       
   138 end
       
   139 
       
   140 function trackFGear(gear)
       
   141     table.insert(flames, gear)
       
   142 end
       
   143 
       
   144 function trackFGearDeletion(gear)
       
   145     fGearValues[gear] = nil
       
   146     for k, g in ipairs(flames) do
       
   147         if g == gear then
       
   148             table.remove(flames, k)
       
   149             break
       
   150         end
       
   151     end
       
   152 end
       
   153 
       
   154 function getFGearValue(gear, key)
       
   155     if fGearValues[gear] ~= nil then
       
   156         return fGearValues[gear][key]
       
   157     end
       
   158     return nil
       
   159 end
       
   160 
       
   161 function setFGearValue(gear, key, value)
       
   162     found = false
       
   163     for id, values in pairs(fGearValues) do
       
   164         if id == gear then
       
   165             values[key] = value
       
   166             found = true
       
   167         end
       
   168     end
       
   169     if not found then
       
   170         fGearValues[gear] = { [key] = value }
       
   171     end
       
   172 end
       
   173 
       
   174 function decreaseFGearValue(gear, key)
       
   175     for id, values in pairs(fGearValues) do
       
   176         if id == gear then
       
   177             values[key] = values[key] - 1
       
   178         end
       
   179     end
       
   180 end
       
   181 
       
   182 function HandleLife(gear)
       
   183 
       
   184 	decreaseFGearValue(gear, "L")
       
   185 	if getFGearValue(gear, "L") == 0 then
       
   186 		AddVisualGear(GetX(gear), GetY(gear), vgtSmoke, 0, false)
       
   187 		DeleteGear(gear)
       
   188 	end
       
   189 
       
   190 end
       
   191 
       
   192 ----------------------------------------------------------------
       
   193 ----------------------------------------------------------------
       
   194 
       
   195 function HideTags()
       
   196 
       
   197 	for i = 0, 3 do 	
       
   198 		SetVisualGearValues(vTag[i],0,0,0,0,0,1,0, 0, 240000, 0xffffff00)
       
   199 	end
       
   200 
       
   201 end
       
   202 
       
   203 function DrawTag(i)
    89 	
   204 	
    90 	zoomL = 1.3
   205 	zoomL = 1.3
    91 
   206 
    92 	DeleteVisualGear(scoreTag)
   207 	xOffset = 40
    93 	scoreTag = AddVisualGear(0, 0, vgtHealthTag, 0, false)
   208 
    94 	g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(scoreTag)
   209 	if i == 0 then
       
   210 		yOffset = 40	
       
   211 		tCol = 0xffba00ff --0xffed09ff --0xffba00ff
       
   212 		tValue = TimeLeft
       
   213 	elseif i == 1 then
       
   214 		zoomL = 1.1		
       
   215 		yOffset = 70	
       
   216 		tCol = wepCol[0]
       
   217 		tValue = wepAmmo[0]
       
   218 	elseif i == 2 then
       
   219 		zoomL = 1.1		
       
   220 		xOffset = 40 + 35
       
   221 		yOffset = 70		
       
   222 		tCol = wepCol[1]
       
   223 		tValue = wepAmmo[1]
       
   224 	elseif i == 3 then
       
   225 		zoomL = 1.1		
       
   226 		xOffset = 40 + 70
       
   227 		yOffset = 70		
       
   228 		tCol = wepCol[2]
       
   229 		tValue = wepAmmo[2]
       
   230 	end
       
   231 
       
   232 	DeleteVisualGear(vTag[i])
       
   233 	vTag[i] = AddVisualGear(0, 0, vgtHealthTag, 0, false)
       
   234 	g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(vTag[i])
    95 	SetVisualGearValues	(	
   235 	SetVisualGearValues	(	
    96 				scoreTag, 		--id
   236 				vTag[i], 		--id
    97 				-(ScreenWidth/2) + 45,	--xoffset
   237 				-(ScreenWidth/2) + xOffset,	--xoffset
    98 				ScreenHeight - 50, 	--yoffset
   238 				ScreenHeight - yOffset, --yoffset
    99 				0, 			--dx
   239 				0, 			--dx
   100 				0, 			--dy
   240 				0, 			--dy
   101 				zoomL, 			--zoom
   241 				zoomL, 			--zoom
   102 				1, 			--~= 0 means align to screen
   242 				1, 			--~= 0 means align to screen
   103 				g7, 			--frameticks
   243 				g7, 			--frameticks
   104 				TimeLeft, 		--value
   244 				tValue, 		--value
   105 				240000, 		--timer
   245 				240000, 		--timer
   106 				0xffba00ff		--GetClanColor( GetHogClan(CurrentHedgehog) )
   246 				tCol		--GetClanColor( GetHogClan(CurrentHedgehog) )
   107 				)
   247 				)
   108 
   248 
   109 end
   249 end
   110 
   250 
   111 function GetGearDistance(gear)
   251 function GetGearDistance(gear)
   121 
   261 
   122 -- add to your ammo ***WHEN YOU PUSH A KEY*** near them
   262 -- add to your ammo ***WHEN YOU PUSH A KEY*** near them
   123 -- yes that was my justification for a non generic method
   263 -- yes that was my justification for a non generic method
   124 function CheckProximityToExplosives(gear)
   264 function CheckProximityToExplosives(gear)
   125 
   265 
   126 	if (GetGearDistance(gear) < 1300) then 
   266 	if (GetGearDistance(gear) < 1400) then
   127 
   267 
   128 		if (GetGearType(gear) == gtExplosives) then
   268 		if (GetGearType(gear) == gtExplosives) then
   129 		
   269 
   130 			wepAmmo[0] = wepAmmo[0] + 1			
   270 			wepAmmo[0] = wepAmmo[0] + 1
   131 			PlaySound(sndShotgunReload)
   271 			PlaySound(sndShotgunReload)
   132 			DeleteGear(gear)
   272 			DeleteGear(gear)
   133 			AddCaption(loc("Ammo extended!"))
   273 			AddCaption(wep[0] .. " " .. loc("ammo extended!"), wepCol[0], capgrpAmmoinfo )
   134 
   274 			DrawTag(1)
       
   275 			
       
   276 			barrelsEaten = barrelsEaten + 1
       
   277 			if barrelsEaten == 5 then
       
   278 				AddCaption(loc("Achievement Unlocked") .. ": " .. loc("Barrel Eater!"),0xffba00ff,capgrpMessage2)
       
   279 			end
       
   280 		
   135 		elseif (GetGearType(gear) == gtMine) then
   281 		elseif (GetGearType(gear) == gtMine) then
   136 			wepAmmo[2] = wepAmmo[2] + 1			
   282 			wepAmmo[1] = wepAmmo[1] + 1
   137 			PlaySound(sndShotgunReload)
   283 			PlaySound(sndShotgunReload)
   138 			DeleteGear(gear)
   284 			DeleteGear(gear)
   139 			AddCaption(loc("Ammo extended!"))
   285 			AddCaption(wep[1] .. " " .. loc("ammo extended!"), wepCol[1], capgrpAmmoinfo )
   140 		end 
   286 			DrawTag(2)
   141 
   287 			
       
   288 			minesEaten = minesEaten + 1
       
   289 			if minesEaten == 5 then
       
   290 				AddCaption(loc("Achievement Unlocked") .. ": " .. loc("Mine Eater!"),0xffba00ff,capgrpMessage2)
       
   291 			end
       
   292 
       
   293 		end
   142 
   294 
   143 	else
   295 	else
   144 		--AddCaption("There is nothing here...")
   296 		--AddCaption("There is nothing here...")
   145 	end
   297 	end
   146 
   298 
   148 
   300 
   149 -- check proximity on crates
   301 -- check proximity on crates
   150 function CheckProximity(gear)
   302 function CheckProximity(gear)
   151 
   303 
   152 	dist = GetGearDistance(gear)
   304 	dist = GetGearDistance(gear)
   153 				--15000
   305 
   154 	if ((dist < 15000) and (beam == true)) and
   306 	if (dist < 1600) and (GetGearType(gear) == gtCase) then
   155 	( (GetGearType(gear) == gtMine) or (GetGearType(gear) == gtExplosives) ) then
   307 
   156 	--	ndx, ndy = GetGearVelocity(CurrentHedgehog)
   308 		if GetHealth(gear) > 0 then
   157 	--	SetGearVelocity(gear, ndx, ndy)
   309 
   158 		--AddCaption("hello???")
   310 			AddCaption(loc("Tumbling Time Extended!"), 0xffba00ff, capgrpMessage2 )
   159 	elseif (dist < 1600) and (GetGearType(gear) == gtCase) then
   311 			
   160 	
   312 			TimeLeft = TimeLeft + HealthCaseAmount  --5 --5s
   161 		if GetHealth(gear) > 0 then		
   313 			DrawTag(0)
   162 
       
   163 			AddCaption(loc("Tumbling Time Extended!"))
       
   164 			TimeLeft = TimeLeft + 5 --5s
       
   165 			DrawTags()
       
   166 			--PlaySound(sndShotgunReload)
   314 			--PlaySound(sndShotgunReload)
   167 		else
   315 		else
   168 			wepAmmo[1] = wepAmmo[1] + 800	
   316 			wepAmmo[2] = wepAmmo[2] + 800
   169 			PlaySound(sndShotgunReload)
   317 			PlaySound(sndShotgunReload)
   170 			AddCaption(loc("Ammo extended!"))
   318 			AddCaption(wep[2] .. " " .. loc("fuel extended!"), wepCol[2], capgrpAmmoinfo )
   171 		end
   319 			DrawTag(3)
   172 		
   320 		end
       
   321 
   173 		DeleteGear(gear)
   322 		DeleteGear(gear)
   174 
   323 
   175 	end
   324 	end
   176 
   325 
   177 end
   326 end
   178 
   327 
   179 --[[function ProjectileTrack(gear)
       
   180 
       
   181 	if (GetGearType(gear) == gtMine) or (GetGearType(gear) == gtExplosives) then
       
   182 
       
   183 		dist = GetGearDistance(gear)
       
   184 
       
   185 		alt = 1
       
   186 		if (dist < 30000) then
       
   187 			alt = -1
       
   188 		end
       
   189 
       
   190 		if (dist < 60000)
       
   191 		--and (dist > 16000)
       
   192 		then
       
   193 
       
   194 			--if (GetGearType(gear) == gtShell) then
       
   195 				turningSpeed = 0.1*fMod*alt
       
   196 			--end
       
   197 
       
   198 			dx, dy = GetGearVelocity(gear)
       
   199 
       
   200 			if GetX(gear) > GetX(CurrentHedgehog) then
       
   201 				dx = dx - turningSpeed
       
   202 			else
       
   203 				dx = dx + turningSpeed
       
   204 			end
       
   205 
       
   206 			if GetY(gear) > GetY(CurrentHedgehog) then
       
   207 				dy = dy - turningSpeed
       
   208 			else
       
   209 				dy = dy + turningSpeed
       
   210 			end
       
   211 
       
   212 
       
   213 			if (GetGearType(gear) == gtShell) then
       
   214 				dxlimit = 0.4*fMod
       
   215 				dylimit = 0.4*fMod
       
   216 			end
       
   217 
       
   218 			if dx > dxlimit then
       
   219 				dx = dxlimit
       
   220 			end
       
   221 			if dy > dylimit then
       
   222 				dy = dylimit
       
   223 			end
       
   224 			if dx < -dxlimit then
       
   225 				dx = -dxlimit
       
   226 			end
       
   227 			if dy < -dylimit then
       
   228 				dy = -dylimit
       
   229 			end
       
   230 
       
   231 			SetGearVelocity(gear, dx, dy)
       
   232 
       
   233 		end
       
   234 
       
   235 	end
       
   236 
       
   237 end]]
       
   238 
       
   239 
       
   240 function ChangeWeapon()
   328 function ChangeWeapon()
   241 
   329 
   242 	--new
       
   243 	wepIndex = wepIndex + 1
   330 	wepIndex = wepIndex + 1
   244 	if wepIndex == wepCount then
   331 	if wepIndex == wepCount then
   245 		wepIndex = 0	
   332 		wepIndex = 0
   246 	end
   333 	end
   247 
   334 
   248 	AddCaption(wep[wepIndex] .. " " .. loc("selected!"), GetClanColor(GetHogClan(CurrentHedgehog)),capgrpAmmoinfo )
   335 	AddCaption(wep[wepIndex] .. " " .. loc("selected!"), wepCol[wepIndex],capgrpAmmoinfo )
   249 	AddCaption(wepAmmo[wepIndex] .. " " .. loc("shots remaining."), GetClanColor(GetHogClan(CurrentHedgehog)),capgrpMessage2)
   336 	AddCaption(wepAmmo[wepIndex] .. " " .. loc("shots remaining."), wepCol[wepIndex],capgrpMessage2)
   250 
   337 
   251 end
   338 end
   252 
   339 
   253 ---------------
   340 ---------------
   254 -- action keys
   341 -- action keys
   257 function onPrecise()
   344 function onPrecise()
   258 
   345 
   259 	if (CurrentHedgehog ~= nil) and (stopMovement == false) and (tumbleStarted == true) and (wepAmmo[wepIndex] > 0) then
   346 	if (CurrentHedgehog ~= nil) and (stopMovement == false) and (tumbleStarted == true) and (wepAmmo[wepIndex] > 0) then
   260 
   347 
   261 		wepAmmo[wepIndex] = wepAmmo[wepIndex] - 1
   348 		wepAmmo[wepIndex] = wepAmmo[wepIndex] - 1
   262 		AddCaption(wepAmmo[wepIndex] .. " " .. loc("shots remaining."), GetClanColor(GetHogClan(CurrentHedgehog)),capgrpMessage2)		
   349 		AddCaption(wepAmmo[wepIndex] .. " " .. loc("shots remaining."), wepCol[wepIndex],capgrpMessage2)
   263 
   350 
   264 		if wep[wepIndex] == loc("Barrel Launcher") then
   351 		if wep[wepIndex] == loc("Barrel Launcher") then
   265 			morte = AddGear(GetX(CurrentHedgehog), GetY(CurrentHedgehog), gtExplosives, 0, 0, 0, 1)
   352 			morte = AddGear(GetX(CurrentHedgehog), GetY(CurrentHedgehog), gtExplosives, 0, 0, 0, 1)
   266 			CopyPV(CurrentHedgehog, morte) -- new addition
   353 			CopyPV(CurrentHedgehog, morte) -- new addition
   267 			x,y = GetGearVelocity(morte)
   354 			x,y = GetGearVelocity(morte)
   268 			x = x*2
   355 			x = x*2
   269 			y = y*2
   356 			y = y*2
   270 			SetGearVelocity(morte, x, y)
   357 			SetGearVelocity(morte, x, y)
   271 		
   358 			DrawTag(1)
       
   359 
   272 		elseif wep[wepIndex] == loc("Mine Deployer") then
   360 		elseif wep[wepIndex] == loc("Mine Deployer") then
   273 			morte = AddGear(GetX(CurrentHedgehog), GetY(CurrentHedgehog), gtMine, 0, 0, 0, 0)
   361 			morte = AddGear(GetX(CurrentHedgehog), GetY(CurrentHedgehog), gtMine, 0, 0, 0, 0)
   274 			SetTimer(morte, 1000)
   362 			SetTimer(morte, 1000)
       
   363 			DrawTag(2)
   275 		end
   364 		end
   276 
   365 
   277 	end
   366 	end
   278 
   367 
   279 	preciseOn = true
   368 	preciseOn = true
   283 function onPreciseUp()
   372 function onPreciseUp()
   284 	preciseOn = false
   373 	preciseOn = false
   285 end
   374 end
   286 
   375 
   287 function onHJump()
   376 function onHJump()
   288 	-- pick up explosives if nearby them
   377 	-- pick up explosives/mines if nearby them
   289 	if (CurrentHedgehog ~= nil) and (stopMovement == false) and (tumbleStarted == true) then
   378 	if (CurrentHedgehog ~= nil) and (stopMovement == false) and (tumbleStarted == true) then
   290 		runOnGears(CheckProximityToExplosives)
   379 		runOnGears(CheckProximityToExplosives)
   291 	end
   380 	end
   292 end
   381 end
   293 
   382 
   294 function onLJump()
   383 function onLJump()
   295 	-- for attracting mines and explosives if the beam is on
       
   296 	--[[if (CurrentHedgehog ~= nil) and (stopMovement == false) and (tumbleStarted == true) then
       
   297 		if beam == false then
       
   298 			beam = true
       
   299 			AddCaption(loc("Mine-attractor on!"))
       
   300 		else
       
   301 			beam = false
       
   302 			AddCaption(loc("Mine-attractor off!"))
       
   303 		end
       
   304 	end]]
       
   305 
       
   306 	ChangeWeapon()
   384 	ChangeWeapon()
   307 
       
   308 end
   385 end
   309 
   386 
   310 -----------------
   387 -----------------
   311 -- movement keys
   388 -- movement keys
   312 -----------------
   389 -----------------
   351 --------------------------
   428 --------------------------
   352 -- other event handlers
   429 -- other event handlers
   353 --------------------------
   430 --------------------------
   354 
   431 
   355 function onGameInit()
   432 function onGameInit()
   356 	--Theme = "Hell"
       
   357 	CaseFreq = 0
   433 	CaseFreq = 0
   358 	HealthCaseProb = 0 
   434 	HealthCaseProb = 0
       
   435 	Delay = 1000
       
   436 
       
   437 	mineSpawn = MinesNum
       
   438 	if mineSpawn > 4 then
       
   439 		mineSpawn = 4	
       
   440 	end
       
   441 
       
   442 	barrelSpawn = Explosives
       
   443 	if barrelSpawn > 4 then
       
   444 		barrelSpawn = 4	
       
   445 	end
       
   446 
       
   447 	--MinesNum = 0
       
   448 	--Explosives = 0
       
   449 
       
   450 	for i = 0, 3 do 	
       
   451 		vTag[0] = AddVisualGear(0, 0, vgtHealthTag, 0, false)	
       
   452 	end
       
   453 
       
   454 	HideTags()
       
   455 
       
   456 	wep[0] = loc("Barrel Launcher")
       
   457 	wep[1] = loc("Mine Deployer")	
       
   458 	wep[2] = loc("Flamer")
       
   459 
       
   460 	wepCol[0] = 0x78818eff
       
   461 	wepCol[1] = 0xa12a77ff
       
   462 	wepCol[2] = 0xf49318ff
       
   463 	
       
   464 	wepCount = 3
       
   465 
   359 end
   466 end
   360 
   467 
   361 function onGameStart()
   468 function onGameStart()
   362 	
   469 
   363 	ShowMission	(
   470 	ShowMission	(
   364 			"TUMBLER",
   471 			"TUMBLER",
   365 			loc("a Hedgewars mini-game"),
   472 			loc("a Hedgewars mini-game"),
   366 			loc("Eliminate the enemy hogs to win.") .. "|" ..
   473 			loc("Eliminate the enemy hogs to win.") .. "|" ..
   367 			" " .. "|" ..
   474 			" " .. "|" ..
   368 
   475 
   369 			--loc("Round Limit") .. ": " .. roundLimit .. "|" ..
   476 			loc("New Mines Per Turn") .. ": " .. (mineSpawn) .. "|" ..
   370 			--loc("Turn Time") .. ": " .. (TurnTime/1000) .. loc("sec") .. "|" ..
   477 			loc("New Barrels Per Turn") .. ": " .. (barrelSpawn) .. "|" ..
   371 			--" " .. "|" ..
   478 			loc("Time Extension") .. ": " .. (HealthCaseAmount) .. loc("sec") .. "|" ..
       
   479 			" " .. "|" ..
   372 
   480 
   373 			loc("Movement: [Up], [Down], [Left], [Right]") .. "|" ..
   481 			loc("Movement: [Up], [Down], [Left], [Right]") .. "|" ..
   374 			loc("Fire") .. ": " .. loc("[Left Shift]") .. "|" ..
   482 			loc("Fire") .. ": " .. loc("[Left Shift]") .. "|" ..
   375 			loc("Change Weapon") .. ": " .. loc("[Enter]") .. "|" ..
   483 			loc("Change Weapon") .. ": " .. loc("[Enter]") .. "|" ..
   376 			loc("Grab Mines/Explosives") .. ": " .. loc("[Backspace]") .. "|" ..
   484 			loc("Grab Mines/Explosives") .. ": " .. loc("[Backspace]") .. "|" ..
   379 
   487 
   380 			loc("Health crates extend your time.") .. "|" ..
   488 			loc("Health crates extend your time.") .. "|" ..
   381 			loc("Ammo is reset at the end of your turn.") .. "|" ..
   489 			loc("Ammo is reset at the end of your turn.") .. "|" ..
   382 
   490 
   383 			"", 4, 4000
   491 			"", 4, 4000
   384 			)	
   492 			)
   385 
       
   386 	scoreTag = AddVisualGear(0, 0, vgtHealthTag, 0, false)
       
   387 	--DrawTags()
       
   388 
       
   389 	SetVisualGearValues(scoreTag,0,0,0,0,0,1,0, 0, 240000, 0xffffff00)
       
   390 
       
   391 	wep[0] = loc("Barrel Launcher")
       
   392 	wep[1] = loc("Flamer")
       
   393 	wep[2] = loc("Mine Deployer")
       
   394 	wepCount = 3
       
   395 
   493 
   396 end
   494 end
   397 
   495 
   398 
   496 
   399 function onNewTurn()
   497 function onNewTurn()
   400 	
   498 
   401 	stopMovement = false
   499 	stopMovement = false
   402 	tumbleStarted = false
   500 	tumbleStarted = false
   403 	beam = false
   501 
   404 
   502 	-- randomly create new barrels mines on the map every turn (can be disabled by setting mine/barrels to 0 in scheme)
   405 	-- randomly create 2 new barrels and 3 mines on the map every turn
   503 	for i = 0, barrelSpawn-1 do
   406 	for i = 0, 1 do
   504 		gear = AddGear(100, 100, gtExplosives, 0, 0, 0, 0)
   407 		gear = AddGear(0, 0, gtExplosives, 0, 0, 0, 0)
       
   408 		SetHealth(gear, 100)
   505 		SetHealth(gear, 100)
   409 		FindPlace(gear, false, 0, LAND_WIDTH)
   506 		if FindPlace(gear, false, 0, LAND_WIDTH, false) ~= nil then
   410 		tempE = AddVisualGear(GetX(gear), GetY(gear), vgtBigExplosion, 0, false)
   507 			tempE = AddVisualGear(GetX(gear), GetY(gear), vgtBigExplosion, 0, false)
   411 	end
   508 		end
   412 	for i = 0, 2 do
   509 	end
   413 		gear = AddGear(0, 0, gtMine, 0, 0, 0, 0)
   510 	for i = 0, mineSpawn-1 do
   414 		FindPlace(gear, false, 0, LAND_WIDTH)
   511 		gear = AddGear(100, 100, gtMine, 0, 0, 0, 0)
   415 		tempE = AddVisualGear(GetX(gear), GetY(gear), vgtBigExplosion, 0, false)
   512 		if FindPlace(gear, false, 0, LAND_WIDTH, false) ~= nil then
   416 	end
   513 			tempE = AddVisualGear(GetX(gear), GetY(gear), vgtBigExplosion, 0, false)
   417 
   514 		end
       
   515 	end
       
   516 
       
   517 	-- randomly spawn time extension crates / flamer fuel on the map
   418 	r = GetRandom(100)
   518 	r = GetRandom(100)
   419 	if r > 50 then
   519 	if r > 50 then
   420 		SpawnHealthCrate(0, 0)
   520 		gear = SpawnHealthCrate(0, 0)
   421 	end
   521 	end
   422 	r = GetRandom(100)
   522 	r = GetRandom(100)
   423 	if r > 70 then
   523 	if r > 70 then
   424 		SpawnAmmoCrate(0, 0, amSkip)
   524 		gear = SpawnAmmoCrate(0, 0, amSkip)
   425 	end
   525 	end
   426 
   526 
   427 	--DrawTags()
   527 	HideTags()
   428 	SetVisualGearValues(scoreTag,0,0,0,0,0,1,0, 0, 240000, 0xffffff00)
       
   429 
   528 
   430 	--reset ammo counts
   529 	--reset ammo counts
   431 	wepAmmo[0] = 2
   530 	wepAmmo[0] = 2
   432 	wepAmmo[1] = 50
   531 	wepAmmo[1] = 1 
   433 	wepAmmo[2] = 1
   532 	wepAmmo[2] = 50 -- 50000 -- 50
   434 	wepIndex = 2
   533 	wepIndex = 2
   435 	ChangeWeapon()
   534 	ChangeWeapon()
   436 
   535 
   437 	roundKills = 0
   536 	roundKills = 0
       
   537 	barrelsEaten = 0
       
   538 	minesEaten = 0
       
   539 
       
   540 	FollowGear(CurrentHedgehog)
   438 
   541 
   439 end
   542 end
   440 
   543 
   441 
   544 
   442 function DisableTumbler()
   545 function DisableTumbler()
   443 	stopMovement = true
   546 	stopMovement = true
   444 	beam = false
       
   445 	upOn = false
   547 	upOn = false
   446 	down = false
   548 	down = false
   447 	leftOn = false
   549 	leftOn = false
   448 	rightOn = false
   550 	rightOn = false
   449 	SetVisualGearValues(scoreTag,0,0,0,0,0,1,0, 0, 240000, 0xffffff00)
   551 	HideTags()
   450 end
   552 end
   451 
   553 
   452 function onGameTick()
   554 function onGameTick()
   453 
   555 
   454 	-- start the player tumbling with a boom once their turn has actually begun
   556 	-- start the player tumbling with a boom once their turn has actually begun
   455 	if tumbleStarted == false then
   557 	if tumbleStarted == false then
   456 		if (TurnTimeLeft > 0) and (TurnTimeLeft ~= TurnTime) then
   558 		if (TurnTimeLeft > 0) and (TurnTimeLeft ~= TurnTime) then
   457 			--AddCaption(loc("Good to go!"))
   559 			--AddCaption(loc("Good to go!"))
   458 			tumbleStarted = true
   560 			tumbleStarted = true
   459 			TimeLeft = 30
   561 			TimeLeft = (TurnTime/1000)
   460 			AddGear(GetX(CurrentHedgehog), GetY(CurrentHedgehog), gtGrenade, 0, 0, 0, 1)
   562 			AddGear(GetX(CurrentHedgehog), GetY(CurrentHedgehog), gtGrenade, 0, 0, 0, 1)
   461 			DrawTags()
   563 			SetHealth(CurrentHedgehog, GetHealth(CurrentHedgehog) + 47) -- new
       
   564 			for i = 0, 3 do
       
   565 				DrawTag(i)
       
   566 			end			
   462 		end
   567 		end
   463 	end
   568 	end
   464 
   569 
   465 	if (CurrentHedgehog ~= nil) and (tumbleStarted == true) then
   570 	if (CurrentHedgehog ~= nil) and (tumbleStarted == true) then
   466 
   571 
   467 		--AddCaption(GetX(CurrentHedgehog) .. ";" .. GetY(CurrentHedgehog) )
   572 		runOnGears(CheckProximity) -- crates
   468 
       
   469 		runOnGears(CheckProximity) -- crates and mines
       
   470 
       
   471 		--if beam == true then
       
   472 		--	runOnGears(ProjectileTrack)
       
   473 		--end
       
   474 
   573 
   475 		-- Calculate and display turn time
   574 		-- Calculate and display turn time
   476 		TimeLeftCounter = TimeLeftCounter + 1
   575 		TimeLeftCounter = TimeLeftCounter + 1
   477 		if TimeLeftCounter == 1000 then
   576 		if TimeLeftCounter == 1000 then
   478 			TimeLeftCounter = 0
   577 			TimeLeftCounter = 0
   479 			TimeLeft = TimeLeft - 1
   578 			TimeLeft = TimeLeft - 1
   480 		
       
   481 			
       
   482 
   579 
   483 			if TimeLeft >= 0 then
   580 			if TimeLeft >= 0 then
   484 				--AddCaption(TimeLeft)
   581 				DrawTag(0)
   485 				DrawTags()
       
   486 			end
   582 			end
   487 
   583 
   488 		end
   584 		end
   489 
   585 
   490 		if TimeLeft == 0 then
   586 		if TimeLeft == 0 then
   493 
   589 
   494 		-- handle movement based on IO
   590 		-- handle movement based on IO
   495 		moveTimer = moveTimer + 1
   591 		moveTimer = moveTimer + 1
   496 		if moveTimer == 100 then -- 100
   592 		if moveTimer == 100 then -- 100
   497 			moveTimer = 0
   593 			moveTimer = 0
       
   594 
       
   595 			runOnflames(HandleLife)
   498 
   596 
   499 			---------------
   597 			---------------
   500 			-- new trail code
   598 			-- new trail code
   501 			---------------
   599 			---------------
   502 			-- the trail lets you know you have 5s left to pilot, akin to birdy feathers
   600 			-- the trail lets you know you have 5s left to pilot, akin to birdy feathers
   538 			end
   636 			end
   539 			if downOn == true then
   637 			if downOn == true then
   540 				dy = dy + 0.1*fMod
   638 				dy = dy + 0.1*fMod
   541 			end
   639 			end
   542 
   640 
   543 		
       
   544 
       
   545 			SetGearVelocity(CurrentHedgehog, dx, dy)
   641 			SetGearVelocity(CurrentHedgehog, dx, dy)
   546 
   642 
   547 		end
   643 		end
   548 
   644 
   549 		--
   645 		--
   550 		--flamer
   646 		--flamer
   551 		--
   647 		--
   552 		fireTimer = fireTimer + 1
   648 		fireTimer = fireTimer + 1
   553 		if fireTimer == 5 then	-- 5 --10
   649 		if fireTimer == 6 then	-- 5 --10
   554 			fireTimer = 0
   650 			fireTimer = 0
   555 
   651 
   556 			if (wep[wepIndex] == loc("Flamer") ) and (preciseOn == true) and (wepAmmo[wepIndex] > 0) and (stopMovement == false) and (tumbleStarted == true) then
   652 			if (wep[wepIndex] == loc("Flamer") ) and (preciseOn == true) and (wepAmmo[wepIndex] > 0) and (stopMovement == false) and (tumbleStarted == true) then
   557 
   653 
   558 				wepAmmo[wepIndex] = wepAmmo[wepIndex] - 1	
   654 				wepAmmo[wepIndex] = wepAmmo[wepIndex] - 1
   559 				AddCaption(	
   655 				AddCaption(
   560 						loc("Flamer") .. ": " .. 
   656 						loc("Flamer") .. ": " ..
   561 						(wepAmmo[wepIndex]/800*100) - (wepAmmo[wepIndex]/800*100)%2 .. "%", 
   657 						(wepAmmo[wepIndex]/800*100) - (wepAmmo[wepIndex]/800*100)%2 .. "%",
   562 						GetClanColor(GetHogClan(CurrentHedgehog)),
   658 						wepCol[2],
   563 						capgrpMessage2
   659 						capgrpMessage2
   564 						)	
   660 						)
       
   661 				DrawTag(3)
   565 
   662 
   566 				dx, dy = GetGearVelocity(CurrentHedgehog)
   663 				dx, dy = GetGearVelocity(CurrentHedgehog)
   567 				shell = AddGear(GetX(CurrentHedgehog), GetY(CurrentHedgehog), gtFlame, 0, 0, 0, 0)
   664 				shell = AddGear(GetX(CurrentHedgehog), GetY(CurrentHedgehog), gtFlame, 0, 0, 0, 0)
   568 
   665 
   569 				xdev = 1 + GetRandom(25)	--15
   666 				xdev = 1 + GetRandom(25)	--15
   580 				r = GetRandom(2)
   677 				r = GetRandom(2)
   581 				if r == 1 then
   678 				if r == 1 then
   582 					ydev = ydev*-1
   679 					ydev = ydev*-1
   583 				end
   680 				end
   584 
   681 
   585 				--*13	--8
   682 				--*13	--8	*-4
   586 				SetGearVelocity(shell, (dx*4)+(xdev*fMod), (dy*4)+(ydev*fMod))	--10
   683 				SetGearVelocity(shell, (dx*4.5)+(xdev*fMod), (dy*4.5)+(ydev*fMod))	--10
   587 
   684 
   588 			end
   685 			end
   589 
   686 
   590 		end
   687 		end
   591 		--
   688 		--
   592 
       
   593 
       
   594 
   689 
   595 	end
   690 	end
   596 
   691 
   597 
   692 
   598 end
   693 end
   599 
   694 
   600 function isATrackedGear(gear)
   695 function isATrackedGear(gear)
   601 	if 	(GetGearType(gear) == gtExplosives) or
   696 	if 	(GetGearType(gear) == gtExplosives) or
   602 		(GetGearType(gear) == gtMine) or
   697 		(GetGearType(gear) == gtMine) or
   603 		(GetGearType(gear) == gtShell) or	-- new -- gtBall
       
   604 		(GetGearType(gear) == gtCase)
   698 		(GetGearType(gear) == gtCase)
   605 	then
   699 	then
   606 		return(true)
   700 		return(true)
   607 	else
   701 	else
   608 		return(false)
   702 		return(false)
   609 	end
   703 	end
   610 end
   704 end
   611 
   705 
   612 
       
   613 --[[function onGearDamage(gear, damage)
   706 --[[function onGearDamage(gear, damage)
   614 	if gear == CurrentHedgehog then
   707 	if gear == CurrentHedgehog then
   615 		-- You are now tumbling
   708 		-- You are now tumbling
   616 	end
   709 	end
   617 end]]
   710 end]]
   618 
   711 
   619 function onGearAdd(gear)
   712 function onGearAdd(gear)
   620 
   713 
   621 	if isATrackedGear(gear) then
   714 	if GetGearType(gear) == gtFlame then
       
   715 
       
   716 		trackFGear(gear)
       
   717 
       
   718 		fGears = fGears +1
       
   719 
       
   720 		if fGears < 80 then
       
   721 			setFGearValue(gear,"L",30)
       
   722 		else
       
   723 			setFGearValue(gear,"L",5) --3
       
   724 		end
       
   725 
       
   726 	elseif isATrackedGear(gear) then
   622 		trackGear(gear)
   727 		trackGear(gear)
   623 	end
   728 	end
   624 
   729 
   625 	--if GetGearType(gear) == gtBall then
       
   626 	--	SetTimer(gear, 15000)
       
   627 	--end
       
   628 
       
   629 end
   730 end
   630 
   731 
   631 function onGearDelete(gear)
   732 function onGearDelete(gear)
   632 
   733 
   633 	if isATrackedGear(gear) then
   734 	if GetGearType(gear) == gtFlame then
       
   735 		trackFGearDeletion(gear)
       
   736 		fGears = fGears -1
       
   737 
       
   738 	elseif isATrackedGear(gear) then
   634 		trackDeletion(gear)
   739 		trackDeletion(gear)
   635 	end
       
   636 
       
   637 	if CurrentHedgehog ~= nil then
       
   638 		FollowGear(CurrentHedgehog)
       
   639 	end
       
   640 
       
   641 	if gear == CurrentHedgehog then
       
   642 		DisableTumbler()
       
   643 	end
       
   644 
       
   645 
   740 
   646 	-- achievements? prototype
   741 	-- achievements? prototype
   647 	if GetGearType(gear) == gtHedgehog then	
   742 	elseif GetGearType(gear) == gtHedgehog then
       
   743 
   648 		if GetHogTeamName(gear) ~= GetHogTeamName(CurrentHedgehog) then
   744 		if GetHogTeamName(gear) ~= GetHogTeamName(CurrentHedgehog) then
   649 						
   745 
   650 			roundKills = roundKills + 1 		
   746 			roundKills = roundKills + 1
   651 			if roundKills == 2 then
   747 			if roundKills == 2 then
   652 				AddCaption(loc("Double Kill!"),0xffba00ff,capgrpMessage2)
   748 				AddCaption(loc("Double Kill!"),0xffba00ff,capgrpMessage2)
   653 			elseif roundKills == 3 then
   749 			elseif roundKills == 3 then
   654 				AddCaption(loc("Killing spree!"),0xffba00ff,capgrpMessage2)
   750 				AddCaption(loc("Killing spree!"),0xffba00ff,capgrpMessage2)
   655 			elseif roundKills >= 4 then
   751 			elseif roundKills >= 4 then
   656 				AddCaption(loc("Unstoppable!"),0xffba00ff,capgrpMessage2)			
   752 				AddCaption(loc("Unstoppable!"),0xffba00ff,capgrpMessage2)
   657 			end		
   753 			end
   658 	
   754 
       
   755 		elseif gear == CurrentHedgehog then
       
   756 			DisableTumbler()
       
   757 
   659 		elseif gear ~= CurrentHedgehog then
   758 		elseif gear ~= CurrentHedgehog then
   660 			AddCaption(loc("Friendly Fire!"),0xffba00ff,capgrpMessage2)
   759 			AddCaption(loc("Friendly Fire!"),0xffba00ff,capgrpMessage2)
   661 		end
   760 		end
   662 
   761 
   663 	end
   762 	end
   664 
   763 
   665 
   764 	if CurrentHedgehog ~= nil then
   666 
   765 		FollowGear(CurrentHedgehog)
   667 end
   766 	end
       
   767 
       
   768 end
       
   769 
       
   770