share/hedgewars/Data/Scripts/Multiplayer/Tumbler.lua
changeset 5598 265429f7ba85
parent 5325 261b79ba22b1
child 5720 a962d0823f49
equal deleted inserted replaced
5596:555c4fc1f3bd 5598:265429f7ba85
     1 -- enable awesome translaction support so we can use loc() wherever we want
     1 ------------------------------------
       
     2 -- TUMBLER
       
     3 -- v.0.6
       
     4 ------------------------------------
       
     5 
     2 loadfile(GetDataPath() .. "Scripts/Locale.lua")()
     6 loadfile(GetDataPath() .. "Scripts/Locale.lua")()
     3 
     7 loadfile(GetDataPath() .. "Scripts/Tracker.lua")()
       
     8 
       
     9 --local fMod = 1	--.15
       
    10 local fMod = 1000000 -- use this for dev and .16+ games
     4 local moveTimer = 0
    11 local moveTimer = 0
     5 local leftOn = false
    12 local leftOn = false
     6 local rightOn = false
    13 local rightOn = false
     7 local upOn = false
    14 local upOn = false
     8 local downOn = false
    15 local downOn = false
     9 
    16 
    10 local shotsMax = 10
    17 local preciseOn = false
    11 local shotsLeft = 50
    18 --local HJumpOn = false
       
    19 --local LJumpON = false
       
    20 local fireTimer = 0
       
    21 local scoreTag = nil
       
    22 local wep = {}
       
    23 local wepAmmo = {}
       
    24 local wepIndex = 0
       
    25 local wepCount = 0
       
    26 local roundKills = 0
    12 
    27 
    13 local TimeLeftCounter = 0
    28 local TimeLeftCounter = 0
    14 local TimeLeft = 30--000
    29 local TimeLeft = 0
    15 local stopMovement = false
    30 local stopMovement = false
    16 local tumbleStarted = false
    31 local tumbleStarted = false
    17 
    32 
       
    33 local beam = false
       
    34 
    18 ------------------------
    35 ------------------------
    19 
    36 -- version 0.4
    20 function GetSpeed()
    37 ------------------------
    21 
    38 
    22 	dx, dy = GetGearVelocity(CurrentHedgehog)
    39 -- removed some old code/comments
    23 
    40 -- removed both shell and mortar as the primary and secondary weapons
    24 	x = dx*dx
    41 -- the primary weapon is now an explosive(barrel)
    25 	y = dy*dy
    42 
    26 	z = x+y
    43 -- added support for picking up barrels scattered about the map (backspace)
    27 
    44 -- added support for dragging around mines (enter toggles on/off)
    28 	z = z*100
    45 -- added support for primary fire being onAttackUp
    29 
    46 -- added a trail to indicate when the player has 5s or less left to tumble
    30 	k = z%1
    47 -- updated showmission to reflect changed controls and options
    31 
    48 
    32 	if k ~= 0 then
    49 ------------------------
    33 	 z = z - k
    50 -- version 0.5
    34 	end
    51 ------------------------
    35 
    52 
    36 	return(z)
    53 -- changed some of the user feedback
    37 
    54 -- i can't remember??
    38 end
    55 -- substituted onAttackUp for onPrecise()
    39 
    56 -- brought in line with new velocity changes
    40 function onGameInit()
    57 
    41 	--Theme = "Hell"
    58 ------------------------
    42 end
    59 -- version 0.6
    43 
    60 ------------------------
    44 
    61 
    45 function onGameStart()
    62 -- reduced starting "ammo"
    46 	ShowMission("TUMBLER", "a Hedgewars mini-game", "- Use the arrow keys to move|- Use [enter] and [backspace] to fire", 4, 4000)
    63 -- randomly spawn new barrels/mines on new turn
       
    64 -- updated user feedback
       
    65 -- better locs and coloured addcaptions
       
    66 -- added tag for turntime
       
    67 -- removed tractor beam
       
    68 -- added two new weapons and changed ammo handling
       
    69 -- health crates now give tumbler time, and wep/utility give flamer ammo
       
    70 -- explosives AND mines can be picked up to increase their relative ammo
       
    71 -- replaced "no weapon" selected message that hw serves
       
    72 -- modified crate frequencies a bit
       
    73 -- added some simple kill-based achievements, i think
       
    74 
       
    75 ---------------------------
       
    76 -- some other ideas/things
       
    77 ---------------------------
       
    78 --[[
       
    79 -- fix "ammo extended" message to be non-generic
       
    80 -- fix flamer "shots remaining" message on start or choose a standard versus %
       
    81 -- add more sounds
       
    82 -- make barrels always explode?
       
    83 -- persistent ammo?
       
    84 -- allow custom turntime?
       
    85 -- dont hurt tumblers and restore their health at turn end?
       
    86 ]]
       
    87 
       
    88 function DrawTags()
       
    89 	
       
    90 	zoomL = 1.3
       
    91 
       
    92 	DeleteVisualGear(scoreTag)
       
    93 	scoreTag = AddVisualGear(0, 0, vgtHealthTag, 0, false)
       
    94 	g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(scoreTag)
       
    95 	SetVisualGearValues	(	
       
    96 				scoreTag, 		--id
       
    97 				-(ScreenWidth/2) + 45,	--xoffset
       
    98 				ScreenHeight - 50, 	--yoffset
       
    99 				0, 			--dx
       
   100 				0, 			--dy
       
   101 				zoomL, 			--zoom
       
   102 				1, 			--~= 0 means align to screen
       
   103 				g7, 			--frameticks
       
   104 				TimeLeft, 		--value
       
   105 				240000, 		--timer
       
   106 				0xffba00ff		--GetClanColor( GetHogClan(CurrentHedgehog) )
       
   107 				)
       
   108 
       
   109 end
       
   110 
       
   111 function GetGearDistance(gear)
       
   112 
       
   113 	g1X, g1Y = GetGearPosition(gear)
       
   114 	g2X, g2Y = GetGearPosition(CurrentHedgehog)
       
   115 
       
   116 	q = g1X - g2X
       
   117 	w = g1Y - g2Y
       
   118 	return( (q*q) + (w*w) )
       
   119 
       
   120 end
       
   121 
       
   122 -- add to your ammo ***WHEN YOU PUSH A KEY*** near them
       
   123 -- yes that was my justification for a non generic method
       
   124 function CheckProximityToExplosives(gear)
       
   125 
       
   126 	if (GetGearDistance(gear) < 1300) then 
       
   127 
       
   128 		if (GetGearType(gear) == gtExplosives) then
       
   129 		
       
   130 			wepAmmo[0] = wepAmmo[0] + 1			
       
   131 			PlaySound(sndShotgunReload)
       
   132 			DeleteGear(gear)
       
   133 			AddCaption(loc("Ammo extended!"))
       
   134 
       
   135 		elseif (GetGearType(gear) == gtMine) then
       
   136 			wepAmmo[2] = wepAmmo[2] + 1			
       
   137 			PlaySound(sndShotgunReload)
       
   138 			DeleteGear(gear)
       
   139 			AddCaption(loc("Ammo extended!"))
       
   140 		end 
       
   141 
       
   142 
       
   143 	else
       
   144 		--AddCaption("There is nothing here...")
       
   145 	end
       
   146 
       
   147 end
       
   148 
       
   149 -- check proximity on crates
       
   150 function CheckProximity(gear)
       
   151 
       
   152 	dist = GetGearDistance(gear)
       
   153 				--15000
       
   154 	if ((dist < 15000) and (beam == true)) and
       
   155 	( (GetGearType(gear) == gtMine) or (GetGearType(gear) == gtExplosives) ) then
       
   156 	--	ndx, ndy = GetGearVelocity(CurrentHedgehog)
       
   157 	--	SetGearVelocity(gear, ndx, ndy)
       
   158 		--AddCaption("hello???")
       
   159 	elseif (dist < 1600) and (GetGearType(gear) == gtCase) then
       
   160 	
       
   161 		if GetHealth(gear) > 0 then		
       
   162 
       
   163 			AddCaption(loc("Tumbling Time Extended!"))
       
   164 			TimeLeft = TimeLeft + 5 --5s
       
   165 			DrawTags()
       
   166 			--PlaySound(sndShotgunReload)
       
   167 		else
       
   168 			wepAmmo[1] = wepAmmo[1] + 800	
       
   169 			PlaySound(sndShotgunReload)
       
   170 			AddCaption(loc("Ammo extended!"))
       
   171 		end
       
   172 		
       
   173 		DeleteGear(gear)
       
   174 
       
   175 	end
       
   176 
       
   177 end
       
   178 
       
   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()
       
   241 
       
   242 	--new
       
   243 	wepIndex = wepIndex + 1
       
   244 	if wepIndex == wepCount then
       
   245 		wepIndex = 0	
       
   246 	end
       
   247 
       
   248 	AddCaption(wep[wepIndex] .. " " .. loc("selected!"), GetClanColor(GetHogClan(CurrentHedgehog)),capgrpAmmoinfo )
       
   249 	AddCaption(wepAmmo[wepIndex] .. " " .. loc("shots remaining."), GetClanColor(GetHogClan(CurrentHedgehog)),capgrpMessage2)
       
   250 
       
   251 end
       
   252 
       
   253 ---------------
       
   254 -- action keys
       
   255 ---------------
       
   256 
       
   257 function onPrecise()
       
   258 
       
   259 	if (CurrentHedgehog ~= nil) and (stopMovement == false) and (tumbleStarted == true) and (wepAmmo[wepIndex] > 0) then
       
   260 
       
   261 		wepAmmo[wepIndex] = wepAmmo[wepIndex] - 1
       
   262 		AddCaption(wepAmmo[wepIndex] .. " " .. loc("shots remaining."), GetClanColor(GetHogClan(CurrentHedgehog)),capgrpMessage2)		
       
   263 
       
   264 		if wep[wepIndex] == loc("Barrel Launcher") then
       
   265 			morte = AddGear(GetX(CurrentHedgehog), GetY(CurrentHedgehog), gtExplosives, 0, 0, 0, 1)
       
   266 			CopyPV(CurrentHedgehog, morte) -- new addition
       
   267 			x,y = GetGearVelocity(morte)
       
   268 			x = x*2
       
   269 			y = y*2
       
   270 			SetGearVelocity(morte, x, y)
       
   271 		
       
   272 		elseif wep[wepIndex] == loc("Mine Deployer") then
       
   273 			morte = AddGear(GetX(CurrentHedgehog), GetY(CurrentHedgehog), gtMine, 0, 0, 0, 0)
       
   274 			SetTimer(morte, 1000)
       
   275 		end
       
   276 
       
   277 	end
       
   278 
       
   279 	preciseOn = true
       
   280 
       
   281 end
       
   282 
       
   283 function onPreciseUp()
       
   284 	preciseOn = false
    47 end
   285 end
    48 
   286 
    49 function onHJump()
   287 function onHJump()
    50 	if (shotsLeft > 0) and (CurrentHedgehog ~= nil) and (stopMovement == false) and (tumbleStarted == true) then -- seems to not work with a hedgehog nil chek
   288 	-- pick up explosives if nearby them
    51 		shotsLeft = shotsLeft - 1
   289 	if (CurrentHedgehog ~= nil) and (stopMovement == false) and (tumbleStarted == true) then
    52 		AddGear(GetX(CurrentHedgehog), GetY(CurrentHedgehog), gtMortar, 0, 0, 0, 1)
   290 		runOnGears(CheckProximityToExplosives)
    53 		AddCaption(loc("Shots Left: ") .. shotsLeft)
       
    54 	end
   291 	end
    55 end
   292 end
    56 
   293 
    57 function onLJump()
   294 function onLJump()
    58 	if (shotsLeft > 0) and (CurrentHedgehog ~= nil) and (stopMovement == false) and (tumbleStarted == true) then -- seems to not work with a hedgehog nil chek
   295 	-- for attracting mines and explosives if the beam is on
    59 
   296 	--[[if (CurrentHedgehog ~= nil) and (stopMovement == false) and (tumbleStarted == true) then
    60 		dx, dy = GetGearVelocity(CurrentHedgehog)
   297 		if beam == false then
    61 
   298 			beam = true
    62 		--boosts in the direction you're already going
   299 			AddCaption(loc("Mine-attractor on!"))
    63 		--[[if dx >= 0 then
   300 		else
    64 			x = -15
   301 			beam = false
    65 		elseif dx < 0 then
   302 			AddCaption(loc("Mine-attractor off!"))
    66 			x = 15
   303 		end
    67 		end
   304 	end]]
    68 
   305 
    69 		if dy >= 0 then
   306 	ChangeWeapon()
    70 			y = -15
   307 
    71 		elseif dy < 0 then
   308 end
    72 			y = 15
   309 
    73 		end]]
   310 -----------------
    74 
   311 -- movement keys
    75 
   312 -----------------
    76 		-- this repositions where the explosions are going to appear
       
    77 		-- based on the users INTENDED (keypress) direction
       
    78 		-- thus allowing to boost yourself or change direction with
       
    79 		-- a blast
       
    80 
       
    81 		-- naturally, it's also an anti-hog weapon
       
    82 
       
    83 		x = 0
       
    84 		y = 0
       
    85 
       
    86 		if leftOn == true then
       
    87 			x = x + 15
       
    88 		end
       
    89 		if rightOn == true then
       
    90 			x = x - 15
       
    91 		end
       
    92 
       
    93 		if upOn == true then
       
    94 			y = y + 15
       
    95 		end
       
    96 		if downOn == true then
       
    97 			y = y - 15
       
    98 		end
       
    99 
       
   100 
       
   101 		shotsLeft = shotsLeft - 1
       
   102 		AddGear((GetX(CurrentHedgehog) + x), (GetY(CurrentHedgehog) + y), gtGrenade, 0, 0, 0, 1)
       
   103 		AddCaption(loc("Shots Left: ") .. shotsLeft)
       
   104 
       
   105 	end
       
   106 end
       
   107 
   313 
   108 function onLeft()
   314 function onLeft()
   109 	if (CurrentHedgehog ~= nil) and (stopMovement == false) then
   315 	if (CurrentHedgehog ~= nil) and (stopMovement == false) then
   110 		leftOn = true
   316 		leftOn = true
   111 	end
   317 	end
   140 end
   346 end
   141 function onRightUp()
   347 function onRightUp()
   142 	rightOn = false
   348 	rightOn = false
   143 end
   349 end
   144 
   350 
       
   351 --------------------------
       
   352 -- other event handlers
       
   353 --------------------------
       
   354 
       
   355 function onGameInit()
       
   356 	--Theme = "Hell"
       
   357 	CaseFreq = 0
       
   358 	HealthCaseProb = 0 
       
   359 end
       
   360 
       
   361 function onGameStart()
       
   362 	
       
   363 	ShowMission	(
       
   364 			"TUMBLER",
       
   365 			loc("a Hedgewars mini-game"),
       
   366 			loc("Eliminate the enemy hogs to win.") .. "|" ..
       
   367 			" " .. "|" ..
       
   368 
       
   369 			--loc("Round Limit") .. ": " .. roundLimit .. "|" ..
       
   370 			--loc("Turn Time") .. ": " .. (TurnTime/1000) .. loc("sec") .. "|" ..
       
   371 			--" " .. "|" ..
       
   372 
       
   373 			loc("Movement: [Up], [Down], [Left], [Right]") .. "|" ..
       
   374 			loc("Fire") .. ": " .. loc("[Left Shift]") .. "|" ..
       
   375 			loc("Change Weapon") .. ": " .. loc("[Enter]") .. "|" ..
       
   376 			loc("Grab Mines/Explosives") .. ": " .. loc("[Backspace]") .. "|" ..
       
   377 
       
   378 			" " .. "|" ..
       
   379 
       
   380 			loc("Health crates extend your time.") .. "|" ..
       
   381 			loc("Ammo is reset at the end of your turn.") .. "|" ..
       
   382 
       
   383 			"", 4, 4000
       
   384 			)	
       
   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 
       
   396 end
       
   397 
       
   398 
   145 function onNewTurn()
   399 function onNewTurn()
   146 	shotsLeft = shotsMax
   400 	
   147 	stopMovement = false
   401 	stopMovement = false
   148 	tumbleStarted = false
   402 	tumbleStarted = false
   149 	--SetInputMask(band(0xFFFFFFFF, bnot(gmAnimate+gmAttack+gmDown+gmHJump+gmLeft+gmLJump+gmPrecise+gmRight+gmSlot+gmSwitch+gmTimer+gmUp+gmWeapon)))
   403 	beam = false
   150 	--AddGear(GetX(CurrentHedgehog), GetY(CurrentHedgehog), gtGrenade, 0, 0, 0, 1)
   404 
       
   405 	-- randomly create 2 new barrels and 3 mines on the map every turn
       
   406 	for i = 0, 1 do
       
   407 		gear = AddGear(0, 0, gtExplosives, 0, 0, 0, 0)
       
   408 		SetHealth(gear, 100)
       
   409 		FindPlace(gear, false, 0, LAND_WIDTH)
       
   410 		tempE = AddVisualGear(GetX(gear), GetY(gear), vgtBigExplosion, 0, false)
       
   411 	end
       
   412 	for i = 0, 2 do
       
   413 		gear = AddGear(0, 0, gtMine, 0, 0, 0, 0)
       
   414 		FindPlace(gear, false, 0, LAND_WIDTH)
       
   415 		tempE = AddVisualGear(GetX(gear), GetY(gear), vgtBigExplosion, 0, false)
       
   416 	end
       
   417 
       
   418 	r = GetRandom(100)
       
   419 	if r > 50 then
       
   420 		SpawnHealthCrate(0, 0)
       
   421 	end
       
   422 	r = GetRandom(100)
       
   423 	if r > 70 then
       
   424 		SpawnAmmoCrate(0, 0, amSkip)
       
   425 	end
       
   426 
       
   427 	--DrawTags()
       
   428 	SetVisualGearValues(scoreTag,0,0,0,0,0,1,0, 0, 240000, 0xffffff00)
       
   429 
       
   430 	--reset ammo counts
       
   431 	wepAmmo[0] = 2
       
   432 	wepAmmo[1] = 50
       
   433 	wepAmmo[2] = 1
       
   434 	wepIndex = 2
       
   435 	ChangeWeapon()
       
   436 
       
   437 	roundKills = 0
       
   438 
       
   439 end
       
   440 
       
   441 
       
   442 function DisableTumbler()
       
   443 	stopMovement = true
       
   444 	beam = false
       
   445 	upOn = false
       
   446 	down = false
       
   447 	leftOn = false
       
   448 	rightOn = false
       
   449 	SetVisualGearValues(scoreTag,0,0,0,0,0,1,0, 0, 240000, 0xffffff00)
   151 end
   450 end
   152 
   451 
   153 function onGameTick()
   452 function onGameTick()
   154 
   453 
   155 	-- start the player tumbling with a boom once their turn has actually begun
   454 	-- start the player tumbling with a boom once their turn has actually begun
   156 	if tumbleStarted == false then
   455 	if tumbleStarted == false then
   157 		if (TurnTimeLeft > 0) and (TurnTimeLeft ~= TurnTime) then
   456 		if (TurnTimeLeft > 0) and (TurnTimeLeft ~= TurnTime) then
   158 			AddCaption("Good to go!")
   457 			--AddCaption(loc("Good to go!"))
   159 			tumbleStarted = true
   458 			tumbleStarted = true
   160 			TimeLeft = 45
   459 			TimeLeft = 30
   161 			AddGear(GetX(CurrentHedgehog), GetY(CurrentHedgehog), gtGrenade, 0, 0, 0, 1)
   460 			AddGear(GetX(CurrentHedgehog), GetY(CurrentHedgehog), gtGrenade, 0, 0, 0, 1)
       
   461 			DrawTags()
   162 		end
   462 		end
   163 	end
   463 	end
   164 
   464 
   165 	if (CurrentHedgehog ~= nil) and (tumbleStarted == true) then
   465 	if (CurrentHedgehog ~= nil) and (tumbleStarted == true) then
   166 
   466 
   167 		--AddCaption(LOC_NOT("Speed: ") .. GetSpeed())
   467 		--AddCaption(GetX(CurrentHedgehog) .. ";" .. GetY(CurrentHedgehog) )
       
   468 
       
   469 		runOnGears(CheckProximity) -- crates and mines
       
   470 
       
   471 		--if beam == true then
       
   472 		--	runOnGears(ProjectileTrack)
       
   473 		--end
   168 
   474 
   169 		-- Calculate and display turn time
   475 		-- Calculate and display turn time
   170 		TimeLeftCounter = TimeLeftCounter + 1
   476 		TimeLeftCounter = TimeLeftCounter + 1
   171 		if TimeLeftCounter == 1000 then
   477 		if TimeLeftCounter == 1000 then
   172 			TimeLeftCounter = 0
   478 			TimeLeftCounter = 0
   173 			TimeLeft = TimeLeft - 1
   479 			TimeLeft = TimeLeft - 1
       
   480 		
       
   481 			
   174 
   482 
   175 			if TimeLeft >= 0 then
   483 			if TimeLeft >= 0 then
   176 				--TurnTimeLeft = TimeLeft
   484 				--AddCaption(TimeLeft)
   177 				AddCaption(loc("Time Left: ") .. TimeLeft)
   485 				DrawTags()
   178 			end
   486 			end
   179 
   487 
   180 		end
   488 		end
   181 
       
   182 		--if TimeLeft >= 0 then
       
   183 		--	--TurnTimeLeft = TimeLeft
       
   184 		--	AddCaption(LOC_NOT("Time Left: ") .. TimeLeft)
       
   185 		--end
       
   186 
       
   187 		--ShowMission("TUMBLER", "v0.2", LOC_NOT("Speed: ") .. GetSpeed() .. "|" .. LOC_NOT("Ammo: ") .. shotsLeft, 4, 0)
       
   188 
   489 
   189 		if TimeLeft == 0 then
   490 		if TimeLeft == 0 then
   190 			stopMovement = true
   491 			DisableTumbler()
   191 			upOn = false
   492 		end
   192 			down = false
       
   193 			leftOn = false
       
   194 			rightOn = false
       
   195 		end
       
   196 
       
   197 
       
   198 
       
   199 
   493 
   200 		-- handle movement based on IO
   494 		-- handle movement based on IO
   201 		moveTimer = moveTimer + 1
   495 		moveTimer = moveTimer + 1
   202 		if moveTimer == 100 then -- 100
   496 		if moveTimer == 100 then -- 100
   203 			moveTimer = 0
   497 			moveTimer = 0
   204 
   498 
       
   499 			---------------
       
   500 			-- new trail code
       
   501 			---------------
       
   502 			-- the trail lets you know you have 5s left to pilot, akin to birdy feathers
       
   503 			if (TimeLeft <= 5) and (TimeLeft > 0) then
       
   504 				tempE = AddVisualGear(GetX(CurrentHedgehog), GetY(CurrentHedgehog), vgtSmoke, 0, false)
       
   505 				g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(tempE)
       
   506 				SetVisualGearValues(tempE, g1, g2, g3, g4, g5, g6, g7, g8, g9, GetClanColor(GetHogClan(CurrentHedgehog)) )
       
   507 			end
       
   508 			--------------
       
   509 
   205 			dx, dy = GetGearVelocity(CurrentHedgehog)
   510 			dx, dy = GetGearVelocity(CurrentHedgehog)
   206 
   511 
   207 			dxlimit = 0.4
   512 			dxlimit = 0.4*fMod
   208 			dylimit = 0.4
   513 			dylimit = 0.4*fMod
   209 
   514 
   210 			if dx > dxlimit then
   515 			if dx > dxlimit then
   211 				dx = dxlimit
   516 				dx = dxlimit
   212 			end
   517 			end
   213 			if dy > dylimit then
   518 			if dy > dylimit then
   220 				dy = -dylimit
   525 				dy = -dylimit
   221 			end
   526 			end
   222 
   527 
   223 
   528 
   224 			if leftOn == true then
   529 			if leftOn == true then
   225 				dx = dx - 0.1
   530 				dx = dx - 0.1*fMod
   226 			end
   531 			end
   227 			if rightOn == true then
   532 			if rightOn == true then
   228 				dx = dx + 0.1
   533 				dx = dx + 0.1*fMod
   229 			end
   534 			end
   230 
   535 
   231 			if upOn == true then
   536 			if upOn == true then
   232 				dy = dy - 0.1
   537 				dy = dy - 0.1*fMod
   233 			end
   538 			end
   234 			if downOn == true then
   539 			if downOn == true then
   235 				dy = dy + 0.1
   540 				dy = dy + 0.1*fMod
   236 			end
   541 			end
   237 
   542 
   238 			--if leftOn == true then
   543 		
   239 			--	dx = dx - 0.04
       
   240 			--end
       
   241 			--if rightOn == true then
       
   242 			--	dx = dx + 0.04
       
   243 			--end
       
   244 
       
   245 			--if upOn == true then
       
   246 			--	dy = dy - 0.1
       
   247 			--end
       
   248 			--if downOn == true then
       
   249 			--	dy = dy + 0.06
       
   250 			--end
       
   251 
   544 
   252 			SetGearVelocity(CurrentHedgehog, dx, dy)
   545 			SetGearVelocity(CurrentHedgehog, dx, dy)
   253 
   546 
   254 		end
   547 		end
   255 
   548 
   256 
   549 		--
   257 
   550 		--flamer
   258 
   551 		--
   259 
   552 		fireTimer = fireTimer + 1
   260 
   553 		if fireTimer == 5 then	-- 5 --10
   261 
   554 			fireTimer = 0
   262 	end
   555 
   263 
   556 			if (wep[wepIndex] == loc("Flamer") ) and (preciseOn == true) and (wepAmmo[wepIndex] > 0) and (stopMovement == false) and (tumbleStarted == true) then
   264 
   557 
   265 
   558 				wepAmmo[wepIndex] = wepAmmo[wepIndex] - 1	
   266 end
   559 				AddCaption(	
   267 
   560 						loc("Flamer") .. ": " .. 
   268 
   561 						(wepAmmo[wepIndex]/800*100) - (wepAmmo[wepIndex]/800*100)%2 .. "%", 
   269 function onGearDamage(gear, damage)
   562 						GetClanColor(GetHogClan(CurrentHedgehog)),
       
   563 						capgrpMessage2
       
   564 						)	
       
   565 
       
   566 				dx, dy = GetGearVelocity(CurrentHedgehog)
       
   567 				shell = AddGear(GetX(CurrentHedgehog), GetY(CurrentHedgehog), gtFlame, 0, 0, 0, 0)
       
   568 
       
   569 				xdev = 1 + GetRandom(25)	--15
       
   570 				xdev = xdev / 100
       
   571 
       
   572 				r = GetRandom(2)
       
   573 				if r == 1 then
       
   574 					xdev = xdev*-1
       
   575 				end
       
   576 
       
   577 				ydev = 1 + GetRandom(25)	--15
       
   578 				ydev = ydev / 100
       
   579 
       
   580 				r = GetRandom(2)
       
   581 				if r == 1 then
       
   582 					ydev = ydev*-1
       
   583 				end
       
   584 
       
   585 				--*13	--8
       
   586 				SetGearVelocity(shell, (dx*4)+(xdev*fMod), (dy*4)+(ydev*fMod))	--10
       
   587 
       
   588 			end
       
   589 
       
   590 		end
       
   591 		--
       
   592 
       
   593 
       
   594 
       
   595 	end
       
   596 
       
   597 
       
   598 end
       
   599 
       
   600 function isATrackedGear(gear)
       
   601 	if 	(GetGearType(gear) == gtExplosives) or
       
   602 		(GetGearType(gear) == gtMine) or
       
   603 		(GetGearType(gear) == gtShell) or	-- new -- gtBall
       
   604 		(GetGearType(gear) == gtCase)
       
   605 	then
       
   606 		return(true)
       
   607 	else
       
   608 		return(false)
       
   609 	end
       
   610 end
       
   611 
       
   612 
       
   613 --[[function onGearDamage(gear, damage)
   270 	if gear == CurrentHedgehog then
   614 	if gear == CurrentHedgehog then
   271 		-- You are now tumbling
   615 		-- You are now tumbling
   272 	end
   616 	end
   273 end
   617 end]]
   274 
       
   275 
   618 
   276 function onGearAdd(gear)
   619 function onGearAdd(gear)
       
   620 
       
   621 	if isATrackedGear(gear) then
       
   622 		trackGear(gear)
       
   623 	end
       
   624 
       
   625 	--if GetGearType(gear) == gtBall then
       
   626 	--	SetTimer(gear, 15000)
       
   627 	--end
       
   628 
   277 end
   629 end
   278 
   630 
   279 function onGearDelete(gear)
   631 function onGearDelete(gear)
       
   632 
       
   633 	if isATrackedGear(gear) then
       
   634 		trackDeletion(gear)
       
   635 	end
   280 
   636 
   281 	if CurrentHedgehog ~= nil then
   637 	if CurrentHedgehog ~= nil then
   282 		FollowGear(CurrentHedgehog)
   638 		FollowGear(CurrentHedgehog)
   283 	end
   639 	end
   284 
   640 
   285 end
   641 	if gear == CurrentHedgehog then
       
   642 		DisableTumbler()
       
   643 	end
       
   644 
       
   645 
       
   646 	-- achievements? prototype
       
   647 	if GetGearType(gear) == gtHedgehog then	
       
   648 		if GetHogTeamName(gear) ~= GetHogTeamName(CurrentHedgehog) then
       
   649 						
       
   650 			roundKills = roundKills + 1 		
       
   651 			if roundKills == 2 then
       
   652 				AddCaption(loc("Double Kill!"),0xffba00ff,capgrpMessage2)
       
   653 			elseif roundKills == 3 then
       
   654 				AddCaption(loc("Killing spree!"),0xffba00ff,capgrpMessage2)
       
   655 			elseif roundKills >= 4 then
       
   656 				AddCaption(loc("Unstoppable!"),0xffba00ff,capgrpMessage2)			
       
   657 			end		
       
   658 	
       
   659 		elseif gear ~= CurrentHedgehog then
       
   660 			AddCaption(loc("Friendly Fire!"),0xffba00ff,capgrpMessage2)
       
   661 		end
       
   662 
       
   663 	end
       
   664 
       
   665 
       
   666 
       
   667 end