share/hedgewars/Data/Scripts/Multiplayer/GaudyRacer.lua
branchhedgeroid
changeset 5932 5164d17b6374
parent 5828 667fb58d7f18
parent 5930 89f5f5d3fdec
child 5934 9f05a0f43003
equal deleted inserted replaced
5828:667fb58d7f18 5932:5164d17b6374
     1 
       
     2 ------------------------------------------
       
     3 -- RACER
       
     4 -- a crazy, map-independant racing script
       
     5 -- by mikade
       
     6 -----------------------------------------
       
     7 
       
     8 -----------------------------------
       
     9 --0.1: with apologies to tumbler
       
    10 -----------------------------------
       
    11 -- added tumbler movement system
       
    12 -- added weapon systems
       
    13 -- added timer to stop tumbler
       
    14 -- added racer circle arrays
       
    15 -- added changing of circs on contact
       
    16 -- added a "track complete" etc
       
    17 
       
    18 -----------------------------------
       
    19 --0.2: for your racing convenience
       
    20 -----------------------------------
       
    21 
       
    22 -- added resurrection
       
    23 -- added team tracking
       
    24 -- added proper scoring (hopefully, finally)
       
    25 -- changed showmission icons to match feedback
       
    26 -- changed circles to be netural colours, and then change to team col
       
    27 -- cleaned up code
       
    28 -- cleaned up gameplay: removing control on resurrect, trackcomplete, maxpointset etc
       
    29 -- improved player feedback: race record, clan record, no record etc.
       
    30 
       
    31 -----------------------------------
       
    32 --0.3: user-requested features
       
    33 -----------------------------------
       
    34 
       
    35 -- hogs now start at the location of the first waypoint \o/
       
    36 -- added sticky camera. Hog will no longer lose focus on explosions etc.
       
    37 -- increased maximum complexity for tracks
       
    38 
       
    39 -----------------------------------
       
    40 --0.4: user-requested features
       
    41 -----------------------------------
       
    42 
       
    43 -- added movement trail
       
    44 -- removed exploder weapon
       
    45 -- removed mortar weapon
       
    46 
       
    47 -----------------------------------
       
    48 -- 0.5 gaudy feature experimentation
       
    49 -----------------------------------
       
    50 -- added a booster
       
    51 -- added flame trail for booster
       
    52 -- added and removed dx/dy on mortar launch
       
    53 -- added and removed keypress-based mortar fire
       
    54 -- changed mortar for a gtShell, probably more useful for tunneling
       
    55 -- added dx/dy *2 shell fire
       
    56 
       
    57 ----------------------------------
       
    58 -- 0.6 modesty / display mod
       
    59 ----------------------------------
       
    60 -- author branding removed
       
    61 -- version numbers removed
       
    62 
       
    63 -----------------------------
       
    64 -- SCRIPT BEGINS
       
    65 -----------------------------
       
    66 
       
    67 -- enable awesome translaction support so we can use loc() wherever we want
       
    68 loadfile(GetDataPath() .. "Scripts/Locale.lua")()
       
    69 
       
    70 ------------------
       
    71 -- Got Variables?
       
    72 ------------------
       
    73 
       
    74 local roundLimit = 3
       
    75 local roundNumber = 0
       
    76 local firstClan = 10
       
    77 
       
    78 local versionNo = loc("v.06")
       
    79 
       
    80 --------------------------
       
    81 -- hog and team tracking variales
       
    82 --------------------------
       
    83 
       
    84 local numhhs = 0 -- store number of hedgehogs
       
    85 local hhs = {} -- store hedgehog gears
       
    86 
       
    87 local numTeams --  store the number of teams in the game
       
    88 local teamNameArr = {}	-- store the list of teams
       
    89 local teamClan = {}
       
    90 local teamSize = {}	-- store how many hogs per team
       
    91 local teamIndex = {} -- at what point in the hhs{} does each team begin
       
    92 
       
    93 local teamComment = {}
       
    94 local teamScore = {}
       
    95 
       
    96 ---------
       
    97 -- tumbler stuff
       
    98 ---------
       
    99 
       
   100 local moveTimer = 0
       
   101 local leftOn = false
       
   102 local rightOn = false
       
   103 local upOn = false
       
   104 local downOn = false
       
   105 
       
   106 local shotsMax = 30	--10
       
   107 local shotsLeft = 10
       
   108 
       
   109 local TimeLeftCounter = 0
       
   110 local TimeLeft = 60
       
   111 local stopMovement = false
       
   112 local tumbleStarted = false
       
   113 
       
   114 -------
       
   115 -- racer vars
       
   116 --------
       
   117 
       
   118 local boosterOn = false
       
   119 local boosterFuel = 75
       
   120 local boosterPower = 0.3
       
   121 local boosterTimer = 0
       
   122 
       
   123 local bestClan = nil
       
   124 local bestTime = nil
       
   125 
       
   126 local gameBegun = false
       
   127 local gameOver = false
       
   128 local racerActive = false
       
   129 local trackTime = 0
       
   130 local wpCheckCounter = 0
       
   131 
       
   132 local wpCirc = {}
       
   133 local wpX = {}
       
   134 local wpY = {}
       
   135 local wpCol = {}
       
   136 local wpActive = {}
       
   137 local wpRad = 75
       
   138 local wpCount = 0
       
   139 local wpLimit = 20
       
   140 
       
   141 -------------------
       
   142 -- general methods
       
   143 -------------------
       
   144 
       
   145 function RebuildTeamInfo()
       
   146 
       
   147 
       
   148 	-- make a list of individual team names
       
   149 	for i = 0, 7 do
       
   150 		teamNameArr[i] = " " -- = i
       
   151 		teamSize[i] = 0
       
   152 		teamIndex[i] = 0
       
   153 		teamScore[i] = 100000
       
   154 	end
       
   155 	numTeams = 0
       
   156 
       
   157 	for i = 0, (numhhs-1) do
       
   158 
       
   159 		z = 0
       
   160 		unfinished = true
       
   161 		while(unfinished == true) do
       
   162 
       
   163 			newTeam = true
       
   164 			tempHogTeamName = GetHogTeamName(hhs[i]) -- this is the new name
       
   165 
       
   166 			if tempHogTeamName == teamNameArr[z] then
       
   167 				newTeam = false
       
   168 				unfinished = false
       
   169 			end
       
   170 
       
   171 			z = z + 1
       
   172 
       
   173 			if z == TeamsCount then
       
   174 				unfinished = false
       
   175 				if newTeam == true then
       
   176 					teamNameArr[numTeams] = tempHogTeamName
       
   177 					numTeams = numTeams + 1
       
   178 				end
       
   179 			end
       
   180 
       
   181 		end
       
   182 
       
   183 	end
       
   184 
       
   185 	-- find out how many hogs per team, and the index of the first hog in hhs
       
   186 	for i = 0, (numTeams-1) do
       
   187 		for z = 0, (numhhs-1) do
       
   188 			if GetHogTeamName(hhs[z]) == teamNameArr[i] then
       
   189 				teamClan[i] = GetHogClan(hhs[z])
       
   190 				if teamSize[i] == 0 then
       
   191 					teamIndex[i] = z -- should give starting index
       
   192 				end
       
   193 				teamSize[i] = teamSize[i] + 1
       
   194 				--add a pointer so this hog appears at i in hhs
       
   195 			end
       
   196 		end
       
   197 
       
   198 	end
       
   199 
       
   200 end
       
   201 
       
   202 
       
   203 -----------------
       
   204 -- RACER METHODS
       
   205 -----------------
       
   206 
       
   207 function GetSpeed()
       
   208 
       
   209 	dx, dy = GetGearVelocity(CurrentHedgehog)
       
   210 
       
   211 	x = dx*dx
       
   212 	y = dy*dy
       
   213 	z = x+y
       
   214 
       
   215 	z = z*100
       
   216 
       
   217 	k = z%1
       
   218 
       
   219 	if k ~= 0 then
       
   220 	 z = z - k
       
   221 	end
       
   222 
       
   223 	return(z)
       
   224 
       
   225 end
       
   226 
       
   227 function CheckWaypoints()
       
   228 
       
   229 	trackFinished = true
       
   230 
       
   231 	for i = 0, (wpCount-1) do
       
   232 
       
   233 		g1X, g1Y = GetGearPosition(CurrentHedgehog)
       
   234 		g2X, g2Y = wpX[i], wpY[i]
       
   235 
       
   236 		g1X = g1X - g2X
       
   237 		g1Y = g1Y - g2Y
       
   238 		dist = (g1X*g1X) + (g1Y*g1Y)
       
   239 
       
   240 		--if i == 0 then
       
   241 		--	AddCaption(dist .. "/" .. (wpRad*wpRad) )
       
   242 		--end
       
   243 
       
   244 		if dist < (wpRad*wpRad) then
       
   245 			--AddCaption("howdy")
       
   246 			wpActive[i] = true
       
   247 			wpCol[i] = GetClanColor(GetHogClan(CurrentHedgehog)) -- new				--GetClanColor(1)
       
   248 			SetVisualGearValues(wpCirc[i], wpX[i], wpY[i], 20, 100, 0, 10, 0, wpRad, 5, wpCol[i])
       
   249 		end
       
   250 
       
   251 		if wpActive[i] == false then
       
   252 			trackFinished = false
       
   253 		end
       
   254 
       
   255 	end
       
   256 
       
   257 	return(trackFinished)
       
   258 
       
   259 end
       
   260 
       
   261 function AdjustScores()
       
   262 
       
   263 	--[[if bestTime == nil then
       
   264 		bestTime = 100000
       
   265 		bestClan = 10
       
   266 		bestTimeComment = "N/A"
       
   267 	else
       
   268 		bestTimeComment = (bestTime/1000) ..loc("s")
       
   269 	end]]
       
   270 
       
   271 	if bestTime == nil then
       
   272 		bestTime = 100000
       
   273 		bestClan = 10
       
   274 		bestTimeComment = "N/A"
       
   275 	end
       
   276 
       
   277 	newScore = false
       
   278 
       
   279 	-- update this clan's time if the new track is better
       
   280 	for i = 0, (numTeams-1) do
       
   281 		if teamClan[i] == GetHogClan(CurrentHedgehog) then
       
   282 			if trackTime < teamScore[i] then
       
   283 				teamScore[i] = trackTime
       
   284 				newScore = true
       
   285 			else
       
   286 				newScore = false
       
   287 			end
       
   288 		end
       
   289 	end
       
   290 
       
   291 	--bestTime = 100000
       
   292 	--bestClan = 10
       
   293 
       
   294 	-- find the best time out of those so far
       
   295 	for i = 0, (numTeams-1) do
       
   296 		if teamScore[i] < bestTime then
       
   297 			bestTime = teamScore[i]
       
   298 			bestClan = teamClan[i]
       
   299 		end
       
   300 	end
       
   301 
       
   302 	if bestTime ~= 100000 then
       
   303 		bestTimeComment = (bestTime/1000) ..loc("s")
       
   304 	end
       
   305 
       
   306 	if newScore == true then
       
   307 		if trackTime == bestTime then -- best time of the race
       
   308 			ShowMission("RACER", loc("TRACK COMPLETED"), loc("NEW RACE RECORD: ") .. (trackTime/1000) ..loc("s") .. "|" .. loc("WINNING TIME: ") .. bestTimeComment, 0, 4000)
       
   309 		else	-- best time for the clan
       
   310 			ShowMission("RACER", loc("TRACK COMPLETED"), loc("NEW CLAN RECORD: ") .. (trackTime/1000) ..loc("s") .. "|" .. loc("WINNING TIME: ") .. bestTimeComment, 4, 4000)
       
   311 		end
       
   312 	else -- not any kind of new score
       
   313 		ShowMission("RACER", loc("TRACK COMPLETED"), loc("TIME: ") .. (trackTime/1000) ..loc("s") .. "|" .. loc("WINNING TIME: ") .. bestTimeComment, -amSkip, 4000)
       
   314 	end
       
   315 
       
   316 end
       
   317 
       
   318 function CheckForNewRound()
       
   319 
       
   320 	if GetHogClan(CurrentHedgehog) == firstClan then
       
   321 
       
   322 		roundNumber = roundNumber + 1
       
   323 
       
   324 		for i = 0, 7 do
       
   325 				if teamNameArr[i] ~= " " then				-- teamScore[teamClan[i]]
       
   326 					teamComment[i] = teamNameArr[i] .. ": " .. (teamScore[i]/1000) .. loc("s|")
       
   327 				elseif teamNameArr[i] == " " then
       
   328 					teamComment[i] = "|"
       
   329 				end
       
   330 		end
       
   331 		ShowMission("RACER", loc("STATUS UPDATE"), loc("Rounds Complete") .. ": " .. roundNumber .. "/" .. roundLimit .. "|" .. " " .. "|" .. loc("Best Team Times: ") .. "|" .. teamComment[0] .. teamComment[1] .. teamComment[2] .. teamComment[3] .. teamComment[4] .. teamComment[5] .. teamComment[6] .. teamComment[7], 0, 1600)
       
   332 
       
   333 		-- end game if its at round limit
       
   334 		if roundNumber == roundLimit then
       
   335 			for i = 0, (numhhs-1) do
       
   336 				if GetHogClan(hhs[i]) ~= bestClan then
       
   337 					SetEffect(hhs[i], heResurrectable, false)
       
   338 					SetHealth(hhs[i],0)
       
   339 				end
       
   340 			end
       
   341 			gameOver = true
       
   342 			TurnTimeLeft = 1
       
   343 		end
       
   344 
       
   345 	end
       
   346 
       
   347 end
       
   348 
       
   349 function DisableTumbler()
       
   350 	stopMovement = true
       
   351 	upOn = false
       
   352 	down = false
       
   353 	leftOn = false
       
   354 	rightOn = false
       
   355 	boosterOn = false
       
   356 end
       
   357 
       
   358 ----------------------------------
       
   359 -- GAME METHODS / EVENT HANDLERS
       
   360 ----------------------------------
       
   361 
       
   362 function onGameInit()
       
   363 	--Theme = "Hell"
       
   364 	--GameFlags
       
   365 	--GameFlags = gfDisableWind
       
   366 end
       
   367 
       
   368 
       
   369 function onGameStart()
       
   370 	RebuildTeamInfo()
       
   371 	ShowMission("RACER", "", "", 4, 4000)
       
   372 end
       
   373 
       
   374 function onHJump()
       
   375 	if (shotsLeft > 0) and (CurrentHedgehog ~= nil) and (stopMovement == false) and (tumbleStarted == true) then -- seems to not work with a hedgehog nil chek
       
   376 
       
   377 		shotsLeft = shotsLeft - 1
       
   378 		morte = AddGear(GetX(CurrentHedgehog), GetY(CurrentHedgehog), gtShell, 0, 0, 0, 1)
       
   379 		AddCaption(loc("Shots Left: ") .. shotsLeft)
       
   380 
       
   381 
       
   382 		-- based on player movement already
       
   383 		CopyPV(CurrentHedgehog, morte) -- new addition
       
   384 
       
   385 		--x2
       
   386 		x,y = GetGearVelocity(morte)
       
   387 		x = x*2
       
   388 		y = y*2
       
   389 		SetGearVelocity(morte, x, y)
       
   390 
       
   391 		--- or based on keys?
       
   392 		--[[x = 0
       
   393 		y = 0
       
   394 
       
   395 		launchPower = 0.5
       
   396 
       
   397 		if leftOn == true then
       
   398 			x = x - launchPower
       
   399 		end
       
   400 		if rightOn == true then
       
   401 			x = x + launchPower
       
   402 		end
       
   403 
       
   404 		if upOn == true then
       
   405 			y = y - launchPower
       
   406 		end
       
   407 		if downOn == true then
       
   408 			y = y + launchPower
       
   409 		end
       
   410 
       
   411 		SetGearVelocity(morte, x, y)]]
       
   412 
       
   413 
       
   414 	end
       
   415 end
       
   416 
       
   417 function onLJump()
       
   418 
       
   419 
       
   420 	if (wpCount < wpLimit) and (CurrentHedgehog ~= nil) and (stopMovement == false) and (tumbleStarted == true) and (gameBegun == false) then -- seems to not work with a hedgehog nil chek
       
   421 
       
   422 		wpX[wpCount] = GetX(CurrentHedgehog)
       
   423 		wpY[wpCount] = GetY(CurrentHedgehog)
       
   424 		wpCol[wpCount] = 0xffffffff
       
   425 		wpCirc[wpCount] = AddVisualGear(wpX[wpCount],wpY[wpCount],vgtCircle,0,true)
       
   426 																		--100	  --0		--75	--wpCol[wpCount]
       
   427 		SetVisualGearValues(wpCirc[wpCount], wpX[wpCount], wpY[wpCount], 20, 100, 0, 10, 0, wpRad, 5, wpCol[wpCount])
       
   428 
       
   429 		wpCount = wpCount + 1
       
   430 
       
   431 		AddCaption(loc("Waypoint placed.") .. " " .. loc("Available points remaining: ") .. (wpLimit-wpCount))
       
   432 
       
   433 		if wpCount == wpLimit then
       
   434 			AddCaption(loc("Race complexity limit reached."))
       
   435 			DisableTumbler()
       
   436 		end
       
   437 
       
   438 	end
       
   439 
       
   440 
       
   441 	if (boosterFuel > 0) and (CurrentHedgehog ~= nil) and (stopMovement == false) and (tumbleStarted == true) and (gameBegun == true) then
       
   442 
       
   443 		if boosterOn == false then
       
   444 			boosterOn = true
       
   445 		else
       
   446 			boosterOn = false
       
   447 		end
       
   448 
       
   449 	end
       
   450 
       
   451 end
       
   452 
       
   453 function onLeft()
       
   454 	if (CurrentHedgehog ~= nil) and (stopMovement == false) then
       
   455 		leftOn = true
       
   456 	end
       
   457 end
       
   458 
       
   459 function onRight()
       
   460 	if (CurrentHedgehog ~= nil) and (stopMovement == false) then
       
   461 		rightOn = true
       
   462 	end
       
   463 end
       
   464 
       
   465 function onUp()
       
   466 	if (CurrentHedgehog ~= nil) and (stopMovement == false) then
       
   467 		upOn = true
       
   468 	end
       
   469 end
       
   470 
       
   471 function onDown()
       
   472 	if (CurrentHedgehog ~= nil) and (stopMovement == false) then
       
   473 		downOn = true
       
   474 	end
       
   475 end
       
   476 
       
   477 function onDownUp()
       
   478 	downOn = false
       
   479 end
       
   480 function onUpUp()
       
   481 	upOn = false
       
   482 end
       
   483 function onLeftUp()
       
   484 	leftOn = false
       
   485 end
       
   486 function onRightUp()
       
   487 	rightOn = false
       
   488 end
       
   489 
       
   490 function onNewTurn()
       
   491 
       
   492 	CheckForNewRound()
       
   493 
       
   494 	--if gameOver == false then
       
   495 		shotsLeft = shotsMax
       
   496 		stopMovement = false
       
   497 		tumbleStarted = false
       
   498 		boosterOn = false
       
   499 		boosterFuel = 75
       
   500 		SetTag(AddGear(0, 0, gtATSmoothWindCh, 0, 0, 0, 1), boosterFuel)
       
   501 		--SetInputMask(band(0xFFFFFFFF, bnot(gmAnimate+gmAttack+gmDown+gmHJump+gmLeft+gmLJump+gmPrecise+gmRight+gmSlot+gmSwitch+gmTimer+gmUp+gmWeapon)))
       
   502 		--AddGear(GetX(CurrentHedgehog), GetY(CurrentHedgehog), gtGrenade, 0, 0, 0, 1)
       
   503 	--end
       
   504 
       
   505 
       
   506 
       
   507 	-- Set the waypoints to unactive on new round
       
   508 	for i = 0,(wpCount-1) do
       
   509 		wpActive[i] = false
       
   510 		wpCol[i] = 0xffffffff
       
   511 		SetVisualGearValues(wpCirc[i], wpX[i], wpY[i], 20, 100, 0, 10, 0, wpRad, 5, wpCol[i])
       
   512 	end
       
   513 
       
   514 	-- Handle Starting Stage of Game
       
   515 	if (gameOver == false) and (gameBegun == false) then
       
   516 		if wpCount >= 3 then
       
   517 			gameBegun = true
       
   518 			racerActive = true
       
   519 			roundNumber = 0 -- 0
       
   520 			firstClan = GetHogClan(CurrentHedgehog)
       
   521 			ShowMission("RACER", loc("GAME BEGUN!!!"), loc("Complete the track as fast as you can!"), 2, 4000)
       
   522 		else
       
   523 			ShowMission("RACER", loc("NOT ENOUGH WAYPOINTS"), loc("Place more waypoints using [ENTER]"), 2, 4000)
       
   524 		end
       
   525 	end
       
   526 
       
   527 	if gameOver == true then
       
   528 		gameBegun = false
       
   529 		stopMovement = true
       
   530 		tumbleStarted = false
       
   531 	end
       
   532 
       
   533 end
       
   534 
       
   535 function onGameTick()
       
   536 
       
   537 	-- start the player tumbling with a boom once their turn has actually begun
       
   538 	if tumbleStarted == false then
       
   539 		if (TurnTimeLeft > 0) and (TurnTimeLeft ~= TurnTime) then
       
   540 			AddCaption("Good to go!")
       
   541 			tumbleStarted = true
       
   542 			racerActive = true
       
   543 			trackTime = 0
       
   544 			TimeLeft = 60
       
   545 
       
   546 			-- if the gamehas started put the player in the middle of the first
       
   547 			--waypoint that was placed
       
   548 			if gameBegun == true then
       
   549 				SetGearPosition(CurrentHedgehog, wpX[0], wpY[0])
       
   550 				AddGear(GetX(CurrentHedgehog), GetY(CurrentHedgehog), gtGrenade, 0, 0, 0, 1)
       
   551 				FollowGear(CurrentHedgehog)
       
   552 			else -- otherwise just start him tumbling from wherever he is
       
   553 				AddGear(GetX(CurrentHedgehog), GetY(CurrentHedgehog), gtGrenade, 0, 0, 0, 1)
       
   554 			end
       
   555 
       
   556 		end
       
   557 	end
       
   558 
       
   559 	-- has the player started his tumbling spree?
       
   560 	if (CurrentHedgehog ~= nil) and (tumbleStarted == true) then
       
   561 
       
   562 		--AddCaption(LOC_NOT("Speed: ") .. GetSpeed())
       
   563 
       
   564 		-- if the RACE has started, show tracktimes and keep tabs on waypoints
       
   565 		if (racerActive == true) and (gameBegun == true) then
       
   566 
       
   567 			trackTime = trackTime + 1
       
   568 
       
   569 			wpCheckCounter = wpCheckCounter + 1
       
   570 			if (wpCheckCounter == 100) then
       
   571 
       
   572 				AddCaption(loc("Track Time: ") .. (trackTime/1000) .. loc("s") )
       
   573 				wpCheckCounter = 0
       
   574 				if (CheckWaypoints() == true) then
       
   575 					AdjustScores()
       
   576 					racerActive = false
       
   577 					DisableTumbler()
       
   578 				end
       
   579 
       
   580 			end
       
   581 
       
   582 		end
       
   583 
       
   584 		if boosterOn == true then
       
   585 			boosterTimer = boosterTimer + 1
       
   586 			if boosterTimer == 150 then --200
       
   587 				boosterTimer = 0
       
   588 				boosterFuel = boosterFuel - 1
       
   589 				SetTag(AddGear(0, 0, gtATSmoothWindCh, 0, 0, 0, 1), boosterFuel)
       
   590 				if boosterFuel == 0 then
       
   591 					boosterOn = false
       
   592 				end
       
   593 			end
       
   594 		end
       
   595 
       
   596 		-- Calculate and display turn time
       
   597 		TimeLeftCounter = TimeLeftCounter + 1
       
   598 		if TimeLeftCounter == 1000 then
       
   599 			TimeLeftCounter = 0
       
   600 			TimeLeft = TimeLeft - 1
       
   601 
       
   602 			if TimeLeft >= 0 then
       
   603 				--TurnTimeLeft = TimeLeft
       
   604 				--AddCaption(LOC_NOT("Time Left: ") .. TimeLeft)
       
   605 			end
       
   606 
       
   607 		end
       
   608 
       
   609 		-- if the player has expended his tunbling time, stop him tumbling
       
   610 		if TimeLeft == 0 then
       
   611 			DisableTumbler()
       
   612 		end
       
   613 
       
   614 
       
   615 		-- handle movement based on IO
       
   616 		moveTimer = moveTimer + 1
       
   617 		if moveTimer == 100 then -- 100
       
   618 			moveTimer = 0
       
   619 
       
   620 			-- keep in mind gravity is acting on the hog
       
   621 			-- so his down is more powerful than his up
       
   622 
       
   623 			dx, dy = GetGearVelocity(CurrentHedgehog)
       
   624 
       
   625 			dxlimit = 0.4 --0.4
       
   626 			dylimit = 0.4 --0.4
       
   627 
       
   628 			if boosterOn == true then
       
   629 
       
   630 				--flame trail, now removed
       
   631 				AddGear(GetX(CurrentHedgehog), GetY(CurrentHedgehog), gtFlame, 0, 0, 0, 0)
       
   632 				--tempE = AddVisualGear(GetX(CurrentHedgehog), GetY(CurrentHedgehog), vgtDust, 0, false)
       
   633 
       
   634 				dxlimit = dxlimit + boosterPower
       
   635 				dylimit = dylimit + boosterPower
       
   636 			else
       
   637 				tempE = AddVisualGear(GetX(CurrentHedgehog), GetY(CurrentHedgehog), vgtDust, 0, false)
       
   638 				g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(tempE)
       
   639 				SetVisualGearValues(tempE, g1, g2, g3, g4, g5, g6, g7, g8, g9, GetClanColor(GetHogClan(CurrentHedgehog)) )
       
   640 			end
       
   641 
       
   642 			if dx > dxlimit then
       
   643 				dx = dxlimit
       
   644 			end
       
   645 			if dy > dylimit then
       
   646 				dy = dylimit
       
   647 			end
       
   648 			if dx < -dxlimit then
       
   649 				dx = -dxlimit
       
   650 			end
       
   651 			if dy < -dylimit then
       
   652 				dy = -dylimit
       
   653 			end
       
   654 
       
   655 
       
   656 			dxPower = 0.1 --0.1
       
   657 			dyPower = 0.1 --0.1
       
   658 
       
   659 			if leftOn == true then
       
   660 				dx = dx - dxPower
       
   661 			end
       
   662 			if rightOn == true then
       
   663 				dx = dx + dxPower
       
   664 			end
       
   665 
       
   666 			if upOn == true then
       
   667 				dy = dy - dyPower -- -0.1 -- new addition
       
   668 			end
       
   669 			if downOn == true then
       
   670 				dy = dy + dyPower
       
   671 			end
       
   672 
       
   673 			--if leftOn == true then
       
   674 			--	dx = dx - 0.04
       
   675 			--end
       
   676 			--if rightOn == true then
       
   677 			--	dx = dx + 0.04
       
   678 			--end
       
   679 
       
   680 			--if upOn == true then
       
   681 			--	dy = dy - 0.1
       
   682 			--end
       
   683 			--if downOn == true then
       
   684 			--	dy = dy + 0.06
       
   685 			--end
       
   686 
       
   687 			SetGearVelocity(CurrentHedgehog, dx, dy)
       
   688 
       
   689 		end
       
   690 
       
   691 	end
       
   692 
       
   693 end
       
   694 
       
   695 function onGearDamage(gear, damage)
       
   696 	--if gear == CurrentHedgehog then
       
   697 		-- You are now tumbling
       
   698 	--end
       
   699 end
       
   700 
       
   701 function onGearResurrect(gear)
       
   702 
       
   703 	AddVisualGear(GetX(gear), GetY(gear), vgtBigExplosion, 0, false)
       
   704 
       
   705 	-- if the player stops and "dies" or flies into water, stop him tumbling
       
   706 	if gear == CurrentHedgehog then
       
   707 		DisableTumbler()
       
   708 	end
       
   709 
       
   710 end
       
   711 
       
   712 function onGearAdd(gear)
       
   713 
       
   714 	if GetGearType(gear) == gtHedgehog then
       
   715 		hhs[numhhs] = gear
       
   716 		numhhs = numhhs + 1
       
   717 		SetEffect(gear, heResurrectable, true)
       
   718 	end
       
   719 
       
   720 end
       
   721 
       
   722 function onGearDelete(gear)
       
   723 	--not needed today, yet
       
   724 
       
   725 	--sticky camera
       
   726 	if CurrentHedgehog ~= nil then
       
   727 		FollowGear(CurrentHedgehog)
       
   728 	end
       
   729 
       
   730 end