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