share/hedgewars/Data/Scripts/Multiplayer/Space_Invasion.lua
changeset 12055 ddf0fee75449
parent 12054 0e6f044daeac
child 12056 b68ec446a111
equal deleted inserted replaced
12054:0e6f044daeac 12055:ddf0fee75449
   334 
   334 
   335 ----------------------------------
   335 ----------------------------------
   336 -- so I herd u liek wariables
   336 -- so I herd u liek wariables
   337 ----------------------------------
   337 ----------------------------------
   338 
   338 
   339 --local fMod = 1	-- for use in .15 single player only, otherwise desync
       
   340 local fMod = 1000000 -- use this for dev and .16+ games
   339 local fMod = 1000000 -- use this for dev and .16+ games
   341 
   340 
   342 -- some console stuff
   341 -- some console stuff
   343 local shellID = 0
   342 local shellID = 0
   344 local explosivesID = 0
   343 local explosivesID = 0
   387 local teamScore = {}
   386 local teamScore = {}
   388 local teamCircsKilled = {}
   387 local teamCircsKilled = {}
   389 local teamSurfer = {}
   388 local teamSurfer = {}
   390 
   389 
   391 -- stats variables
   390 -- stats variables
   392 --local teamRed = {}
       
   393 --local teamBlue = {}
       
   394 --local teamOrange = {}
       
   395 --local teamGreen = {}
       
   396 local roundKills = 0
   391 local roundKills = 0
   397 local roundScore = 0
   392 local roundScore = 0
   398 local RK = 0
   393 local RK = 0
   399 local GK = 0
   394 local GK = 0
   400 local BK = 0
   395 local BK = 0
   412 ---------------------
   407 ---------------------
   413 -- awards (for stats section, just for fun)
   408 -- awards (for stats section, just for fun)
   414 ---------------------
   409 ---------------------
   415 -- global awards
   410 -- global awards
   416 local awardTotalKills=0	-- overall killed invaders (min. 30)
   411 local awardTotalKills=0	-- overall killed invaders (min. 30)
   417 
       
   418 -- TODO: team awards (currently unused)
       
   419 local awardBoss 	-- most boss kills (min. 3)
       
   420 local awardKamikaze	-- most kamikaze bonuses (min. 3)
       
   421 local awardSniper	-- most sniper shots (min. 3)
       
   422 local awardAbsorber	-- most absorbed (with shield) projectiles (min. 20)
       
   423 local awardFierceComps	-- most fierce competition achievements
       
   424 local awardNoShield	-- no shield used in entire game (if there are multiple teams, award goes to team with most kills)
       
   425 local awardCollector	-- most ammo and shield invaders collected
       
   426 
   412 
   427 -- hog awards
   413 -- hog awards
   428 local awardRoundScore	-- hog with most score in 1 round (min. 50)
   414 local awardRoundScore	-- hog with most score in 1 round (min. 50)
   429 local awardRoundKills	-- most kills in 1 round (min. 5)
   415 local awardRoundKills	-- most kills in 1 round (min. 5)
   430 local awardAccuracy	-- awarded to hog who didn’t miss once in his round, with most kills (min. 5)
   416 local awardAccuracy	-- awarded to hog who didn’t miss once in his round, with most kills (min. 5)
   663 	for i = 0,(TeamsCount-1) do
   649 	for i = 0,(TeamsCount-1) do
   664 		if teamClan[i] == GetHogClan(CurrentHedgehog) then
   650 		if teamClan[i] == GetHogClan(CurrentHedgehog) then
   665 			teamCircsKilled[i] = teamCircsKilled[i] + 1
   651 			teamCircsKilled[i] = teamCircsKilled[i] + 1
   666 			awardTotalKills = awardTotalKills + 1
   652 			awardTotalKills = awardTotalKills + 1
   667 
   653 
   668 --[[
       
   669 TODO: Check if I actually want to remove this
       
   670 			if teamCircsKilled[i] == 10 then
       
   671 				AddCaption(loc("Boom!") .. " +25 " .. loc("points").."!",0xffba00ff,capgrpVolume)
       
   672 				AwardPoints(25)
       
   673 			elseif teamCircsKilled[i] == 25 then
       
   674 				AddCaption(loc("BOOM!") .. " +50 " .. loc("points") .. "!",0xffba00ff,capgrpVolume)
       
   675 				AwardPoints(50)
       
   676 			elseif teamCircsKilled[i] == 50 then
       
   677 				AddCaption(loc("BOOM!") .. loc("BOOM!") .. loc("BOOM!") .. " +100 " .. loc("points") .. "!",0xffba00ff,capgrpVolume)
       
   678 				AwardPoints(100)
       
   679 			end
       
   680 ]]
       
   681 
       
   682 			--[[
       
   683 			if t == "R" then
       
   684 				redCircsKilled[i] = redCircsKilled[i] + 1
       
   685 			end
       
   686 			--etc
       
   687 			--etc
       
   688 			]]
       
   689 		end
   654 		end
   690 	end
   655 	end
   691 
   656 
   692 end
   657 end
   693 
   658 
   939 end
   904 end
   940 
   905 
   941 -- gaudy racer
   906 -- gaudy racer
   942 function CheckForNewRound()
   907 function CheckForNewRound()
   943 
   908 
   944 	----------
       
   945 	-- new
       
   946 	----------
       
   947 
       
   948 	--[[if gameBegun == true then
       
   949 
       
   950 		if RoundHasChanged == true then
       
   951 			roundN = roundN + 1
       
   952 			RoundHasChanged = false
       
   953 			onNewRound()
       
   954 		end
       
   955 
       
   956 		if lastRound ~= TotalRounds then -- new round, but not really
       
   957 
       
   958 			if RoundHasChanged == false then
       
   959 				RoundHasChanged = true
       
   960 			end
       
   961 
       
   962 		end
       
   963 
       
   964 		--AddCaption("RoundN:" .. roundN .. "; " .. "TR: " .. TotalRounds)
       
   965 		lastRound = TotalRounds
       
   966 
       
   967 	end]]
       
   968 
       
   969 	----------
       
   970 	-- old
       
   971 	----------
       
   972 	if GetHogClan(CurrentHedgehog) == firstClan then
   909 	if GetHogClan(CurrentHedgehog) == firstClan then
   973 		onNewRound()
   910 		onNewRound()
   974 	end
   911 	end
   975 
   912 
   976 end
   913 end
   981 ----------------------------------------
   918 ----------------------------------------
   982 
   919 
   983 function isATrackedGear(gear)
   920 function isATrackedGear(gear)
   984 	if 	(GetGearType(gear) == gtExplosives) or
   921 	if 	(GetGearType(gear) == gtExplosives) or
   985 		(GetGearType(gear) == gtShell) or
   922 		(GetGearType(gear) == gtShell) or
   986 		(GetGearType(gear) == gtFlame) or-- new -- gtBall
   923 		(GetGearType(gear) == gtFlame) or
   987 		(GetGearType(gear) == gtBall)
   924 		(GetGearType(gear) == gtBall)
   988 	then
   925 	then
   989 		return(true)
   926 		return(true)
   990 	else
   927 	else
   991 		return(false)
   928 		return(false)
  1031 	if getGearValue(gear,"lifespan") == 0 then
   968 	if getGearValue(gear,"lifespan") == 0 then
  1032 
   969 
  1033 		if GetGearType(gear) == gtShell then
   970 		if GetGearType(gear) == gtShell then
  1034 			AddVisualGear(GetX(gear), GetY(gear), vgtExplosion, 0, false)
   971 			AddVisualGear(GetX(gear), GetY(gear), vgtExplosion, 0, false)
  1035 
   972 
  1036 			--AddVisualGear(GetX(gear), GetY(gear), vgtExplosion, 0, false)
       
  1037 			WriteLnToConsole("about to delete a shell due to lifespan == 0")
   973 			WriteLnToConsole("about to delete a shell due to lifespan == 0")
  1038 		--elseif GetGearType(gear) == gtBall then
       
  1039 		--	AddVisualGear(GetX(gear), GetY(gear), vgtSmoke, 0, true)
       
  1040 		elseif GetGearType(gear) == gtExplosives then
   974 		elseif GetGearType(gear) == gtExplosives then
  1041 			AddVisualGear(GetX(gear), GetY(gear), vgtBigExplosion, 0, false)
   975 			AddVisualGear(GetX(gear), GetY(gear), vgtBigExplosion, 0, false)
  1042 			PlaySound(sndExplosion)
   976 			PlaySound(sndExplosion)
  1043 			--nw WriteLnToConsole("about to delete a explosive due to lifespan == 0")
       
  1044 		elseif GetGearType(gear) == gtFlame then
   977 		elseif GetGearType(gear) == gtFlame then
  1045 			AddVisualGear(GetX(gear), GetY(gear), vgtSmoke, 0, false)
   978 			AddVisualGear(GetX(gear), GetY(gear), vgtSmoke, 0, false)
  1046 			--WriteLnToConsole("about to delete flame due to lifespan == 0")
       
  1047 		end
   979 		end
  1048 
   980 
  1049 		DeleteGear(gear)
   981 		DeleteGear(gear)
  1050 
   982 
  1051 	end
   983 	end
  1060 			(GetX(gear) > 6200) or
   992 			(GetX(gear) > 6200) or
  1061 			(GetY(gear) < -3400)
   993 			(GetY(gear) < -3400)
  1062 		then
   994 		then
  1063 			AddVisualGear(GetX(gear), GetY(gear), vgtBigExplosion, 0, false)
   995 			AddVisualGear(GetX(gear), GetY(gear), vgtBigExplosion, 0, false)
  1064 			DeleteGear(gear)
   996 			DeleteGear(gear)
  1065 			--SetHealth(gear, 0)
       
  1066 			--WriteLnToConsole("I'm setting barrel ID " .. getGearValue(gear,"ID") .. " to 0 health because it's been flung too close to the map edges. at Game Time: " .. GameTime .. "; luaTicks: " .. luaGameTicks)
   997 			--WriteLnToConsole("I'm setting barrel ID " .. getGearValue(gear,"ID") .. " to 0 health because it's been flung too close to the map edges. at Game Time: " .. GameTime .. "; luaTicks: " .. luaGameTicks)
  1067 		end
   998 		end
  1068 
   999 
  1069 	end
  1000 	end
  1070 
  1001 
  1093 			wepCol[2],
  1024 			wepCol[2],
  1094 			capgrpMessage2
  1025 			capgrpMessage2
  1095 			)
  1026 			)
  1096 			DrawTag(3)
  1027 			DrawTag(3)
  1097 
  1028 
  1098 			dx, dy = GetGearVelocity(CurrentHedgehog)					--gtFlame -- gtSnowball -- gtAirBomb
  1029 			dx, dy = GetGearVelocity(CurrentHedgehog)
  1099 			shell = AddGear(GetX(CurrentHedgehog), GetY(CurrentHedgehog), gtFlame, 0, 0, 0, 0)
  1030 			shell = AddGear(GetX(CurrentHedgehog), GetY(CurrentHedgehog), gtFlame, 0, 0, 0, 0)
  1100 
  1031 
  1101 			xdev = 1 + GetRandom(35)	--25
  1032 			xdev = 1 + GetRandom(35)
  1102 			xdev = xdev / 100
  1033 			xdev = xdev / 100
  1103 
  1034 
  1104 			r = GetRandom(2)
  1035 			r = GetRandom(2)
  1105 			if r == 1 then
  1036 			if r == 1 then
  1106 				xdev = xdev*-1
  1037 				xdev = xdev*-1
  1107 			end
  1038 			end
  1108 
  1039 
  1109 			ydev = 1 + GetRandom(35)	--25
  1040 			ydev = 1 + GetRandom(35)
  1110 			ydev = ydev / 100
  1041 			ydev = ydev / 100
  1111 
  1042 
  1112 			r = GetRandom(2)
  1043 			r = GetRandom(2)
  1113 			if r == 1 then
  1044 			if r == 1 then
  1114 				ydev = ydev*-1
  1045 				ydev = ydev*-1
  1115 			end
  1046 			end
  1116 
  1047 
  1117 								--4.5	or 2.5 nonflames				--4.5
  1048 			SetGearVelocity(shell, (dx*4.5)+(xdev*fMod), (dy*4.5)+(ydev*fMod))
  1118 			SetGearVelocity(shell, (dx*4.5)+(xdev*fMod), (dy*4.5)+(ydev*fMod))	--10
       
  1119 
  1049 
  1120 		end
  1050 		end
  1121 
  1051 
  1122 	end
  1052 	end
  1123 
  1053 
  1138 	AddCaption(wepAmmo[wepIndex] .. " " .. loc("shots remaining."), wepCol[wepIndex],capgrpMessage2)
  1068 	AddCaption(wepAmmo[wepIndex] .. " " .. loc("shots remaining."), wepCol[wepIndex],capgrpMessage2)
  1139 ]]
  1069 ]]
  1140 
  1070 
  1141 end
  1071 end
  1142 
  1072 
  1143 --function onTimer()
       
  1144 
       
  1145 	-- experimental wep
       
  1146 	--[[SetVisualGearValues(shockwave, GetX(CurrentHedgehog), GetY(CurrentHedgehog), 40, 255, 1, 10, 0, 300, 1, 0xff33ffff)
       
  1147 	AddCaption("boom")
       
  1148 	PlaySound(sndWarp)
       
  1149 	shockwaveHealth = 100
       
  1150 	shockwaveRad = 100]]
       
  1151 
       
  1152 
       
  1153 	--change wep
       
  1154 	--ChangeWeapon()
       
  1155 
       
  1156 	-- booster
       
  1157 	--[[if boosterOn == false then
       
  1158 		boosterOn = true
       
  1159 	else
       
  1160 		boosterOn = false
       
  1161 	end]]
       
  1162 
       
  1163 --end
       
  1164 
       
  1165 -- o rite dis wan iz liek synched n stuff hope full lee
       
  1166 -- old method
       
  1167 --[[function onPrecise()
       
  1168 
       
  1169 
       
  1170 	-- Fire Barrel
       
  1171 	if (primShotsLeft > 0) and (CurrentHedgehog ~= nil) and (stopMovement == false) and (tumbleStarted == true) then
       
  1172 
       
  1173 		shotsFired = shotsFired +1
       
  1174 
       
  1175 		morte = AddGear(GetX(CurrentHedgehog), GetY(CurrentHedgehog), gtExplosives, 0, 0, 0, 1)
       
  1176 
       
  1177 		primShotsLeft = primShotsLeft - 1
       
  1178 
       
  1179 		if primShotsLeft == 0 then
       
  1180 			PlaySound(sndSuddenDeath)
       
  1181 			AddCaption(loc("Ammo Depleted!"),0xff0000ff,capgrpMessage)
       
  1182 		else
       
  1183 			AddCaption(loc("Ammo") .. ": " .. primShotsLeft)
       
  1184 		end
       
  1185 		DrawTag(1)
       
  1186 
       
  1187 		CopyPV(CurrentHedgehog, morte) -- new addition
       
  1188 		x,y = GetGearVelocity(morte)
       
  1189 
       
  1190 		x = x*2
       
  1191 		y = y*2
       
  1192 		SetGearVelocity(morte, x, y)
       
  1193 
       
  1194 
       
  1195 	elseif (primShotsLeft == 0) and (CurrentHedgehog ~= nil) and (stopMovement == false) and (tumbleStarted == true) then
       
  1196 		AddCaption(loc("Ammo Depleted!"),0xff0000ff,capgrpMessage)
       
  1197 	end
       
  1198 
       
  1199 
       
  1200 end]]
       
  1201 
       
  1202 -- derp tumbler
  1073 -- derp tumbler
  1203 function onPrecise()
  1074 function onPrecise()
  1204 
  1075 
  1205 	if (CurrentHedgehog ~= nil) and (stopMovement == false) and (tumbleStarted == true) and (wepAmmo[wepIndex] > 0) then
  1076 	if (CurrentHedgehog ~= nil) and (stopMovement == false) and (tumbleStarted == true) and (wepAmmo[wepIndex] > 0) then
  1206 
  1077 
  1207 		wepAmmo[wepIndex] = wepAmmo[wepIndex] - 1
  1078 		wepAmmo[wepIndex] = wepAmmo[wepIndex] - 1
  1208 		--AddCaption(wepAmmo[wepIndex] .. " " .. loc("shots remaining."), wepCol[wepIndex],capgrpMessage2)
       
  1209 
  1079 
  1210 		if wep[wepIndex] == loc("Barrel Launcher") then
  1080 		if wep[wepIndex] == loc("Barrel Launcher") then
  1211 			shotsFired = shotsFired +1
  1081 			shotsFired = shotsFired +1
  1212 
  1082 
  1213 			morte = AddGear(GetX(CurrentHedgehog), GetY(CurrentHedgehog), gtExplosives, 0, 0, 0, 1)
  1083 			morte = AddGear(GetX(CurrentHedgehog), GetY(CurrentHedgehog), gtExplosives, 0, 0, 0, 1)
  1219 
  1089 
  1220 			if wepAmmo[wepIndex] == 0 then
  1090 			if wepAmmo[wepIndex] == 0 then
  1221 				PlaySound(sndSuddenDeath)
  1091 				PlaySound(sndSuddenDeath)
  1222 				AddCaption(loc("Ammo Depleted!"),0xff0000ff,capgrpMessage)
  1092 				AddCaption(loc("Ammo Depleted!"),0xff0000ff,capgrpMessage)
  1223 			else
  1093 			else
  1224 				--AddCaption(loc("Ammo") .. ": " .. wepAmmo[wepIndex])
       
  1225 				PlaySound(sndThrowRelease)
  1094 				PlaySound(sndThrowRelease)
  1226 			end
  1095 			end
  1227 			DrawTag(1)
  1096 			DrawTag(1)
  1228 
  1097 
  1229 		elseif wep[wepIndex] == loc("Mine Deployer") then
  1098 		elseif wep[wepIndex] == loc("Mine Deployer") then
  1419 				loc("Movement: [Up], [Down], [Left], [Right]") .. "|" ..
  1288 				loc("Movement: [Up], [Down], [Left], [Right]") .. "|" ..
  1420 				loc("Fire") .. ": " .. loc("[Left Shift]") .. "|" ..
  1289 				loc("Fire") .. ": " .. loc("[Left Shift]") .. "|" ..
  1421 				loc("Toggle Shield") .. ": " .. loc("[Enter]") .. "|" ..
  1290 				loc("Toggle Shield") .. ": " .. loc("[Enter]") .. "|" ..
  1422 				loc("Radar Ping") .. ": " .. loc("[Backspace]") .. "|" ..
  1291 				loc("Radar Ping") .. ": " .. loc("[Backspace]") .. "|" ..
  1423 
  1292 
  1424 				--" " .. "|" ..
       
  1425 				--LOC_NOT("Invaders List: ") .. "|" ..
       
  1426 				--LOC_NOT("Blue Jabberwock: (50 points)") .. "|" ..
       
  1427 				--LOC_NOT("Red Warbler: (10 points)") .. "|" ..
       
  1428 				--LOC_NOT("Orange Gob: (5 points)") .. "|" ..
       
  1429 				--LOC_NOT("Green Wrangler: (3 points)") .. "|" ..
       
  1430 
       
  1431 
       
  1432 				"", 4, 4000
  1293 				"", 4, 4000
  1433 				)
  1294 				)
  1434 
  1295 
  1435 	CreateMeSomeCircles()
  1296 	CreateMeSomeCircles()
  1436 	RebuildTeamInfo() -- control
  1297 	RebuildTeamInfo() -- control
  1450 
  1311 
  1451 end
  1312 end
  1452 
  1313 
  1453 function onNewTurn()
  1314 function onNewTurn()
  1454 
  1315 
  1455 	--primShotsLeft = primShotsMax
       
  1456 	radShotsLeft = startRadShots
  1316 	radShotsLeft = startRadShots
  1457 	stopMovement = false
  1317 	stopMovement = false
  1458 	tumbleStarted = false
  1318 	tumbleStarted = false
  1459 	boosterOn = false
  1319 	boosterOn = false
  1460 	beam = false
  1320 	beam = false
  1550 	--WriteLnToConsole("Start of GameTick")
  1410 	--WriteLnToConsole("Start of GameTick")
  1551 	luaGameTicks = luaGameTicks + 1 -- GameTime
  1411 	luaGameTicks = luaGameTicks + 1 -- GameTime
  1552 
  1412 
  1553 	HandleCircles()
  1413 	HandleCircles()
  1554 
  1414 
  1555 	-- derp
       
  1556 	--if shockwaveHealth > 0 then
       
  1557 	--	shockwaveHealth = shockwaveHealth - 1
       
  1558 	--	shockwaveRad = shockwaveRad + 5
       
  1559 	--end
       
  1560 
       
  1561 
       
  1562 	Timer100 = Timer100 + 1
  1415 	Timer100 = Timer100 + 1
  1563 	if Timer100 >= 100 then
  1416 	if Timer100 >= 100 then
  1564 		Timer100 = 0
  1417 		Timer100 = 0
  1565 
  1418 
  1566 		if beam == true then
  1419 		if beam == true then
  1580 
  1433 
  1581 		runOnGears(ThingsToBeRunOnGears)
  1434 		runOnGears(ThingsToBeRunOnGears)
  1582 
  1435 
  1583 		--nw WriteLnToConsole("Finished ThingsToBeRunOnGears()")
  1436 		--nw WriteLnToConsole("Finished ThingsToBeRunOnGears()")
  1584 
  1437 
  1585 		--runOnGears(HandleLifeSpan)
       
  1586 		--runOnGears(DeleteFarFlungBarrel)
       
  1587 
       
  1588 		if CirclesAreGo == true then
  1438 		if CirclesAreGo == true then
  1589 			CheckDistances()
  1439 			CheckDistances()
  1590 			--runOnGears(CheckVarious)	-- used to be in handletracking for some bizarre reason
       
  1591 			--runOnGears(ProjectileTrack)
       
  1592 		end
  1440 		end
  1593 
  1441 
  1594 		-- white smoke trail as player falls from the sky
  1442 		-- white smoke trail as player falls from the sky
  1595 		if (TimeLeft <= 0) and (stopMovement == true) and (CurrentHedgehog ~= nil) then
  1443 		if (TimeLeft <= 0) and (stopMovement == true) and (CurrentHedgehog ~= nil) then
  1596 			j,k = GetGearVelocity(CurrentHedgehog)
  1444 			j,k = GetGearVelocity(CurrentHedgehog)
  1605 
  1453 
  1606 
  1454 
  1607 	-- start the player tumbling with a boom once their turn has actually begun
  1455 	-- start the player tumbling with a boom once their turn has actually begun
  1608 	if (tumbleStarted == false) and (gameOver == false) then
  1456 	if (tumbleStarted == false) and (gameOver == false) then
  1609 		if (TurnTimeLeft > 0) and (TurnTimeLeft ~= TurnTime) then
  1457 		if (TurnTimeLeft > 0) and (TurnTimeLeft ~= TurnTime) then
  1610 			--AddCaption(LOC_NOT("Good to go!"))
       
  1611 			tumbleStarted = true
  1458 			tumbleStarted = true
  1612 			TimeLeft = (TurnTime/1000)	--45
  1459 			TimeLeft = (TurnTime/1000)
  1613 			FadeAlpha = 0
  1460 			FadeAlpha = 0
  1614 			rAlpha = 255
  1461 			rAlpha = 255
  1615 			AddGear(GetX(CurrentHedgehog), GetY(CurrentHedgehog), gtGrenade, 0, 0, 0, 1)
  1462 			AddGear(GetX(CurrentHedgehog), GetY(CurrentHedgehog), gtGrenade, 0, 0, 0, 1)
  1616 			DrawTag(0)
  1463 			DrawTag(0)
  1617 			DrawTag(1)
  1464 			DrawTag(1)
  1623 
  1470 
  1624 	--WriteLnToConsole("Finished initial check")
  1471 	--WriteLnToConsole("Finished initial check")
  1625 
  1472 
  1626 	if (CurrentHedgehog ~= nil) and (tumbleStarted == true) then
  1473 	if (CurrentHedgehog ~= nil) and (tumbleStarted == true) then
  1627 
  1474 
  1628 		--AddCaption(GetX(CurrentHedgehog) .. ";" .. GetY(CurrentHedgehog) )
       
  1629 
       
  1630 		-- Calculate and display turn time
  1475 		-- Calculate and display turn time
  1631 		TimeLeftCounter = TimeLeftCounter + 1
  1476 		TimeLeftCounter = TimeLeftCounter + 1
  1632 		if TimeLeftCounter == 1000 then
  1477 		if TimeLeftCounter == 1000 then
  1633 			TimeLeftCounter = 0
  1478 			TimeLeftCounter = 0
  1634 			TimeLeft = TimeLeft - 1
  1479 			TimeLeft = TimeLeft - 1
  1635 
  1480 
  1636 			if TimeLeft >= 0 then
  1481 			if TimeLeft >= 0 then
  1637 				--AddCaption(LOC_NOT("Time Left: ") .. TimeLeft)
       
  1638 				DrawTag(0)
  1482 				DrawTag(0)
  1639 			end
  1483 			end
  1640 
  1484 
  1641 		end
  1485 		end
  1642 
  1486 
  1835 	if isATrackedGear(gear) then
  1679 	if isATrackedGear(gear) then
  1836 		trackGear(gear)
  1680 		trackGear(gear)
  1837 		setNewGearValues(gear)
  1681 		setNewGearValues(gear)
  1838 	end
  1682 	end
  1839 
  1683 
  1840 	--if GetGearType(gear) == gtBall then
       
  1841 	--	SetTimer(gear, 5000)
       
  1842 	--end
       
  1843 
       
  1844 	if GetGearType(gear) == gtHedgehog then
  1684 	if GetGearType(gear) == gtHedgehog then
  1845 		SetEffect(gear, heResurrectable, 1)
  1685 		SetEffect(gear, heResurrectable, 1)
  1846 
  1686 
  1847 		-----------
  1687 		-----------
  1848 		-- control
  1688 		-- control
  1852 	end
  1692 	end
  1853 
  1693 
  1854 end
  1694 end
  1855 
  1695 
  1856 function onGearDelete(gear)
  1696 function onGearDelete(gear)
  1857 
       
  1858 
       
  1859 	--[[if GetGearType(gear) == gtShell then
       
  1860 		--nw WriteLnToConsole("on GearDelete call. Shell ID: " .. getGearValue(gear,"ID"))
       
  1861 		--WriteLnToConsole("The above event occured game Time: " .. GameTime .. "; luaTicks: " .. luaGameTicks)
       
  1862 
       
  1863 		--if CurrentHedgehog ~= nil then
       
  1864 		--	WriteLnToConsole("As it happens, player is at: " .. GetX(CurrentHedgehog) .. "; " .. GetY(CurrentHedgehog))
       
  1865 		--end
       
  1866 	elseif GetGearType(gear) == gtExplosives then
       
  1867 		--nw WriteLnToConsole("on GearDelete call. Explosives ID: " .. getGearValue(gear,"ID"))
       
  1868 		--WriteLnToConsole("The above event occured game Time: " .. GameTime .. "; luaTicks: " .. luaGameTicks)
       
  1869 
       
  1870 		--if CurrentHedgehog ~= nil then
       
  1871 		--	WriteLnToConsole("As it happens, player is at: " .. GetX(CurrentHedgehog) .. "; " .. GetY(CurrentHedgehog))
       
  1872 		--end
       
  1873 	elseif GetGearType(gear) == gtFlame then
       
  1874 		--WriteLnToConsole("on GearDelete flame")
       
  1875 	end]]
       
  1876 
  1697 
  1877 	if isATrackedGear(gear) then
  1698 	if isATrackedGear(gear) then
  1878 		trackDeletion(gear)
  1699 		trackDeletion(gear)
  1879 	end
  1700 	end
  1880 
  1701 
  1955 	g1X, g1Y = GetGearPosition(gear)
  1776 	g1X, g1Y = GetGearPosition(gear)
  1956 	g2X, g2Y = GetGearPosition(gear2)
  1777 	g2X, g2Y = GetGearPosition(gear2)
  1957 	q = g1X - g2X
  1778 	q = g1X - g2X
  1958 	w = g1Y - g2Y
  1779 	w = g1Y - g2Y
  1959 
  1780 
  1960 
       
  1961 	--[[
       
  1962 	WriteLnToConsole("I just got the position of two gears and calculated the distance betwen them")
       
  1963 	if gear == CurrentHedgehog then
       
  1964 		WriteLnToConsole("Gear 1 is CurrentHedgehog.")
       
  1965 	end
       
  1966 	if gear2 == CurrentHedgehog then
       
  1967 		WriteLnToConsole("Gear 2 is CurrentHedgehog.")
       
  1968 	end
       
  1969 	WriteLnToConsole("G1X: " .. g1X .. "; G1Y: " .. g1Y)
       
  1970 	WriteLnToConsole("G2X: " .. g2X .. "; G2Y: " .. g2Y)
       
  1971 	WriteLnToConsole("Their distance is " .. (q*q) + (w*w) )
       
  1972 	WriteLnToConsole("The above events occured game Time: " .. GameTime .. "; luaTicks: " .. luaGameTicks)
       
  1973 ]]
       
  1974 
       
  1975 
       
  1976 	return ( (q*q) + (w*w) )
  1781 	return ( (q*q) + (w*w) )
  1977 
  1782 
  1978 end
  1783 end
  1979 
  1784 
  1980 function GetDistFromGearToXY(gear, g2X, g2Y)
  1785 function GetDistFromGearToXY(gear, g2X, g2Y)
  1981 
  1786 
  1982 	g1X, g1Y = GetGearPosition(gear)
  1787 	g1X, g1Y = GetGearPosition(gear)
  1983 	q = g1X - g2X
  1788 	q = g1X - g2X
  1984 	w = g1Y - g2Y
  1789 	w = g1Y - g2Y
  1985 
  1790 
  1986 
       
  1987 	--[[WriteLnToConsole("I just got the position of a gear and calculated the distance betwen it and another xy")
       
  1988 	if gear == CurrentHedgehog then
       
  1989 		WriteLnToConsole("Gear 1 is CurrentHedgehog.")
       
  1990 	end
       
  1991 
       
  1992 	WriteLnToConsole("G1X: " .. g1X .. "; G1Y: " .. g1Y)
       
  1993 	WriteLnToConsole("Other X: " .. g2X .. "; Other Y: " .. g2Y)
       
  1994 	WriteLnToConsole("Their distance is " .. (q*q) + (w*w) )
       
  1995 	WriteLnToConsole("The above events occured game Time: " .. GameTime .. "; luaTicks: " .. luaGameTicks)
       
  1996 ]]
       
  1997 
       
  1998 
       
  1999 	return ( (q*q) + (w*w) )
  1791 	return ( (q*q) + (w*w) )
  2000 
       
  2001 
  1792 
  2002 end
  1793 end
  2003 
  1794 
  2004 function CreateMeSomeCircles()
  1795 function CreateMeSomeCircles()
  2005 
  1796 
  2018 		vCounter[i] = 0
  1809 		vCounter[i] = 0
  2019 		vCounterLim[i] = 3000
  1810 		vCounterLim[i] = 3000
  2020 		vCircScore[i] = 0
  1811 		vCircScore[i] = 0
  2021 		vCircHealth[i] = 1
  1812 		vCircHealth[i] = 1
  2022 
  1813 
  2023 		vCircMinA[i] = 80	--80 --20
  1814 		vCircMinA[i] = 80
  2024 		vCircMaxA[i] = 255
  1815 		vCircMaxA[i] = 255
  2025 		vCircType[i] = 1	--1
  1816 		vCircType[i] = 1
  2026 		vCircPulse[i] = 10
  1817 		vCircPulse[i] = 10
  2027 		vCircFuckAll[i] = 0
  1818 		vCircFuckAll[i] = 0
  2028 		vCircRadius[i] = 0
  1819 		vCircRadius[i] = 0
  2029 		vCircWidth[i] = 3 --5
  1820 		vCircWidth[i] = 3
  2030 
  1821 
  2031 		vCircRadMax[i] = 0
  1822 		vCircRadMax[i] = 0
  2032 		vCircRadMin[i] = 0
  1823 		vCircRadMin[i] = 0
  2033 		vCircRadDir[i] = -1
  1824 		vCircRadDir[i] = -1
  2034 		vCircRadCounter[i] = 0
  1825 		vCircRadCounter[i] = 0
  2042 		SetVisualGearValues(rCirc[i], 0, 0, 100, 255, 1, 10, 0, 40, 3, vCircCol[i])
  1833 		SetVisualGearValues(rCirc[i], 0, 0, 100, 255, 1, 10, 0, 40, 3, vCircCol[i])
  2043 
  1834 
  2044 	end
  1835 	end
  2045 
  1836 
  2046 	pShield = AddVisualGear(0,0,vgtCircle,0,true)
  1837 	pShield = AddVisualGear(0,0,vgtCircle,0,true)
  2047 	--SetVisualGearValues(pShield, GetX(CurrentHedgehog), GetY(CurrentHedgehog), 80, 200, 1, 10, 0, 200, 5, 0xff00ffff)
       
  2048 
       
  2049 
  1838 
  2050 	shockwave = AddVisualGear(0,0,vgtCircle,0,true)
  1839 	shockwave = AddVisualGear(0,0,vgtCircle,0,true)
  2051 
  1840 
  2052 end
  1841 end
  2053 
  1842 
  2054 function IGotMeASafeXYValue(i)
  1843 function IGotMeASafeXYValue(i)
  2055 
  1844 
  2056 	acceptibleDistance = 800
  1845 	acceptibleDistance = 800
  2057 
       
  2058 	-- put this in here to thwart attempts at repositioning and test sanity limit
       
  2059 	--vCircX[i] = GetX(CurrentHedgehog)+250
       
  2060 	--vCircY[i] = GetY(CurrentHedgehog)+250
       
  2061 
  1846 
  2062 	vCircX[i] = GetRandom(5000)
  1847 	vCircX[i] = GetRandom(5000)
  2063 	vCircY[i] = GetRandom(2000)
  1848 	vCircY[i] = GetRandom(2000)
  2064 	dist = GetDistFromGearToXY(CurrentHedgehog, vCircX[i], vCircY[i])
  1849 	dist = GetDistFromGearToXY(CurrentHedgehog, vCircX[i], vCircY[i])
  2065 	if dist > acceptibleDistance*acceptibleDistance then
  1850 	if dist > acceptibleDistance*acceptibleDistance then
  2099 		elseif (vType[i] == "ammo") then
  1884 		elseif (vType[i] == "ammo") then
  2100 			AddVisualGear(vCircX[i], vCircY[i], vgtExplosion, 0, false)
  1885 			AddVisualGear(vCircX[i], vCircY[i], vgtExplosion, 0, false)
  2101 			PlaySound(sndExplosion)
  1886 			PlaySound(sndExplosion)
  2102 			PlaySound(sndShotgunReload)
  1887 			PlaySound(sndShotgunReload)
  2103 			wepAmmo[0] = wepAmmo[0] + barrelBonus
  1888 			wepAmmo[0] = wepAmmo[0] + barrelBonus
  2104 			--primShotsLeft = primShotsLeft + 3
       
  2105 			AddCaption(string.format("+%d Ammo", barrelBonus), 0x00ff00ff,capgrpMessage)
  1889 			AddCaption(string.format("+%d Ammo", barrelBonus), 0x00ff00ff,capgrpMessage)
  2106 			DrawTag(1)
  1890 			DrawTag(1)
  2107 
  1891 
  2108 			GK = GK + 1
  1892 			GK = GK + 1
  2109 			if GK == 3 then
  1893 			if GK == 3 then
  2123 			AddVisualGear(vCircX[i], vCircY[i], vgtFire, 0, false)
  1907 			AddVisualGear(vCircX[i], vCircY[i], vgtFire, 0, false)
  2124 			AddVisualGear(vCircX[i], vCircY[i], vgtFire, 0, false)
  1908 			AddVisualGear(vCircX[i], vCircY[i], vgtFire, 0, false)
  2125 			AddVisualGear(vCircX[i], vCircY[i], vgtSmoke, 0, false)
  1909 			AddVisualGear(vCircX[i], vCircY[i], vgtSmoke, 0, false)
  2126 
  1910 
  2127 			PlaySound(sndVaporize)
  1911 			PlaySound(sndVaporize)
  2128 			--sndWarp sndMineTick --sndSwitchHog --sndSuddenDeath
       
  2129 
  1912 
  2130 			shieldHealth = shieldHealth + shieldBonus
  1913 			shieldHealth = shieldHealth + shieldBonus
  2131 			AddCaption(string.format(loc("Shield boosted! +%d power"),shieldBonus), 0xa800ffff,capgrpMessage)
  1914 			AddCaption(string.format(loc("Shield boosted! +%d power"),shieldBonus), 0xa800ffff,capgrpMessage)
  2132 			if shieldHealth >= 250 then
  1915 			if shieldHealth >= 250 then
  2133 				shieldHealth = 250
  1916 				shieldHealth = 250
  2188 
  1971 
  2189 function SetUpCircle(i)
  1972 function SetUpCircle(i)
  2190 
  1973 
  2191 
  1974 
  2192 	r = GetRandom(10)
  1975 	r = GetRandom(10)
  2193 	--r = 8
       
  2194 	-- 80% of spawning either red/green
  1976 	-- 80% of spawning either red/green
  2195 	if r <= 7 then
  1977 	if r <= 7 then
  2196 
  1978 
  2197 		--r = GetRandom(5)
       
  2198 		r = GetRandom(2)
  1979 		r = GetRandom(2)
  2199 		--r = 1
       
  2200 		if r == 0 then
  1980 		if r == 0 then
  2201 		--if r <= 2 then
       
  2202 			vCircCol[i] = 0xff0000ff -- red
  1981 			vCircCol[i] = 0xff0000ff -- red
  2203 			vType[i] = "drone"
  1982 			vType[i] = "drone"
  2204 			vCircRadMin[i] = 50	*5
  1983 			vCircRadMin[i] = 50	*5
  2205 			vCircRadMax[i] = 90	*5
  1984 			vCircRadMax[i] = 90	*5
  2206 			vCounterLim[i] = 3000
  1985 			vCounterLim[i] = 3000
  2207 			vCircScore[i] = 10
  1986 			vCircScore[i] = 10
  2208 			vCircHealth[i] = 1
  1987 			vCircHealth[i] = 1
  2209 		--else
       
  2210 		elseif r == 1 then
  1988 		elseif r == 1 then
  2211 			vCircCol[i] = 0x00ff00ff -- green
  1989 			vCircCol[i] = 0x00ff00ff -- green
  2212 			vType[i] = "ammo"
  1990 			vType[i] = "ammo"
  2213 			vCircRadMin[i] = 25	*7
  1991 			vCircRadMin[i] = 25	*7
  2214 			vCircRadMax[i] = 30	*7
  1992 			vCircRadMax[i] = 30	*7
  2217 		end
  1995 		end
  2218 
  1996 
  2219 	-- 20% chance of spawning boss or bonus
  1997 	-- 20% chance of spawning boss or bonus
  2220 	else
  1998 	else
  2221 		r = GetRandom(5)
  1999 		r = GetRandom(5)
  2222 		--r = GetRandom(2)
       
  2223 		--r = 0
       
  2224 		if r <= 1 then
  2000 		if r <= 1 then
  2225 		--if r == 0 then
       
  2226 			vCircCol[i] = 0x0050ffff -- sexy blue
  2001 			vCircCol[i] = 0x0050ffff -- sexy blue
  2227 			vType[i] = "blueboss"
  2002 			vType[i] = "blueboss"
  2228 			vCircRadMin[i] = 100*5
  2003 			vCircRadMin[i] = 100*5
  2229 			vCircRadMax[i] = 180*5
  2004 			vCircRadMax[i] = 180*5
  2230 			vCircWidth[i] = 1
  2005 			vCircWidth[i] = 1
  2231 			vCounterLim[i] = 2000
  2006 			vCounterLim[i] = 2000
  2232 			vCircScore[i] = 30
  2007 			vCircScore[i] = 30
  2233 			vCircHealth[i] = 3
  2008 			vCircHealth[i] = 3
  2234 		else
  2009 		else
  2235 		--elseif r == 1 then
       
  2236 			--vCircCol[i] = 0xffae00ff -- orange
       
  2237 			vCircCol[i] = 0xa800ffff -- purp
  2010 			vCircCol[i] = 0xa800ffff -- purp
  2238 			vType[i] = "bonus"
  2011 			vType[i] = "bonus"
  2239 			vCircRadMin[i] = 20 *7
  2012 			vCircRadMin[i] = 20 *7
  2240 			vCircRadMax[i] = 40 *7
  2013 			vCircRadMax[i] = 40 *7
  2241 			vCircScore[i] = 5
  2014 			vCircScore[i] = 5
  2244 
  2017 
  2245 	end
  2018 	end
  2246 
  2019 
  2247 	-- regenerate circle xy if too close to player or until sanity limit kicks in
  2020 	-- regenerate circle xy if too close to player or until sanity limit kicks in
  2248 	reN = 0
  2021 	reN = 0
  2249 	--zzz = 0
       
  2250 	while (reN < 10) do
  2022 	while (reN < 10) do
  2251 		if IGotMeASafeXYValue(i) == false then
  2023 		if IGotMeASafeXYValue(i) == false then
  2252 			reN = reN + 1
  2024 			reN = reN + 1
  2253 			--zzz = zzz + 1
       
  2254 		else
  2025 		else
  2255 			reN = 15
  2026 			reN = 15
  2256 		end
  2027 		end
  2257 	end
  2028 	end
  2258 	--AddCaption("Took me this many retries: " .. zzz) -- number of times it took to work
       
  2259 
  2029 
  2260 	vCircRadius[i] = vCircRadMax[i] - GetRandom(vCircRadMin[i])
  2030 	vCircRadius[i] = vCircRadMax[i] - GetRandom(vCircRadMin[i])
  2261 
  2031 
  2262 	g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(vCirc[i])
  2032 	g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(vCirc[i])
  2263 	SetVisualGearValues(vCirc[i], vCircX[i], vCircY[i], g3, g4, g5, g6, g7, vCircRadius[i], vCircWidth[i], vCircCol[i]-0x000000ff)
  2033 	SetVisualGearValues(vCirc[i], vCircX[i], vCircY[i], g3, g4, g5, g6, g7, vCircRadius[i], vCircWidth[i], vCircCol[i]-0x000000ff)
  2264 	-- - -0x000000ff
       
  2265 
  2034 
  2266 	g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(rCirc[i])
  2035 	g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(rCirc[i])
  2267 	SetVisualGearValues(rCirc[i], 0, 0, g3, g4, g5, g6, g7, g8, g9, vCircCol[i]-0x000000ff)
  2036 	SetVisualGearValues(rCirc[i], 0, 0, g3, g4, g5, g6, g7, g8, g9, vCircCol[i]-0x000000ff)
  2268 
  2037 
  2269 
  2038 
  2270 	vCircActive[i] = true -- new
  2039 	vCircActive[i] = true
  2271 
  2040 
  2272 	--nw WriteLnToConsole("CIRC " .. i .. ": X: " .. vCircX[i] .. "; Y: " .. vCircY[i])
  2041 	--nw WriteLnToConsole("CIRC " .. i .. ": X: " .. vCircX[i] .. "; Y: " .. vCircY[i])
  2273 	--nw WriteLnToConsole("CIRC " .. i .. ": dX: " .. vCircDX[i] .. "; dY: " .. vCircDY[i])
  2042 	--nw WriteLnToConsole("CIRC " .. i .. ": dX: " .. vCircDX[i] .. "; dY: " .. vCircDY[i])
  2274 	--nw WriteLnToConsole("CIRC " .. i .. ": RAD:" .. vCircRadius[i])
  2043 	--nw WriteLnToConsole("CIRC " .. i .. ": RAD:" .. vCircRadius[i])
  2275 
  2044 
  2320 end
  2089 end
  2321 
  2090 
  2322 --- collision detection for weapons fire
  2091 --- collision detection for weapons fire
  2323 function CheckVarious(gear)
  2092 function CheckVarious(gear)
  2324 
  2093 
  2325 	--if (GetGearType(gear) == gtExplosives) then
       
  2326 		--nw WriteLnToConsole("Start of CheckVarious(): Exp ID: " .. getGearValue(gear,"ID"))
       
  2327 	--elseif (GetGearType(gear) == gtShell) then
       
  2328 		--nw WriteLnToConsole("Start of CheckVarious(): Shell ID: " .. getGearValue(gear,"ID"))
       
  2329 	--end
       
  2330 
       
  2331 	targetHit = false
  2094 	targetHit = false
  2332 
  2095 
  2333 	-- if circle is hit by player fire
  2096 	-- if circle is hit by player fire
  2334 	if (GetGearType(gear) == gtExplosives) then
  2097 	if (GetGearType(gear) == gtExplosives) then
  2335 		circsHit = 0
  2098 		circsHit = 0
  2336 
  2099 
  2337 		for i = 0,(vCCount-1) do
  2100 		for i = 0,(vCCount-1) do
  2338 
  2101 
  2339 			--nw WriteLnToConsole("Is it neccessary to check for collision with circ " .. i)
  2102 			--nw WriteLnToConsole("Is it neccessary to check for collision with circ " .. i)
  2340 
  2103 
  2341 			--if (vCircActive[i] == true) and ( (vType[i] == "drone") ) then
  2104 			--nw WriteLnToConsole("YES. about to calc distance between gtExplosives and circ " .. i)
  2342 
  2105 
  2343 				--nw WriteLnToConsole("YES. about to calc distance between gtExplosives and circ " .. i)
  2106 			dist = GetDistFromGearToXY(gear, vCircX[i], vCircY[i])
  2344 
  2107 
  2345 				dist = GetDistFromGearToXY(gear, vCircX[i], vCircY[i])
  2108 			-- calculate my real radius if I am an aura
  2346 
  2109 			if vCircType[i] == 0 then
  2347 				-- calculate my real radius if I am an aura
  2110 				NR = vCircRadius[i]
  2348 				if vCircType[i] == 0 then
  2111 			else
  2349 					NR = vCircRadius[i]
  2112 				NR = (48/100*vCircRadius[i])/2
  2350 				else
  2113 			end
  2351 					NR = (48/100*vCircRadius[i])/2
  2114 
       
  2115 			if dist <= NR*NR then
       
  2116 
       
  2117 
       
  2118 				--nw WriteLnToConsole("Collision confirmed. The gtExplosives is within the circ radius!")
       
  2119 
       
  2120 				dist = (GetDistFromXYtoXY(vCircX[i], vCircY[i], getGearValue(gear,"XP"), getGearValue(gear,"YP")) - (NR*NR))
       
  2121 				--AddCaption(loc("Dist: ") .. dist .. "!",0xffba00ff,capgrpGameState)
       
  2122 				if dist >= 1000000 then
       
  2123 					sniperHits = sniperHits +1
       
  2124 					AddCaption(loc("Sniper!") .. " +8 " .. loc("points") .. "!",0xffba00ff,capgrpGameState)
       
  2125 					AwardPoints(8)
       
  2126 					if sniperHits == 3 then
       
  2127 						sniperHits = 0
       
  2128 						AddCaption(loc("They Call Me Bullseye!") .. " +16 " .. loc("points") .. "!",0xffba00ff,capgrpGameState)
       
  2129 						AwardPoints(16)
       
  2130 					end
       
  2131 				elseif dist <= 6000 then
       
  2132 					pointBlankHits = pointBlankHits +1
       
  2133 					if pointBlankHits == 3 then
       
  2134 						pointBlankHits = 0
       
  2135 						AddCaption(loc("Point Blank Combo!") .. " +5 " .. loc("points") .. "!",0xffba00ff,capgrpGameState)
       
  2136 						AwardPoints(5)
       
  2137 					end
  2352 				end
  2138 				end
  2353 
  2139 
  2354 				if dist <= NR*NR then
  2140 				AddVisualGear(GetX(gear), GetY(gear), vgtBigExplosion, 0, false)
  2355 
  2141 
  2356 
  2142 				targetHit = true
  2357 					--nw WriteLnToConsole("Collision confirmed. The gtExplosives is within the circ radius!")
  2143 				--WriteLnToConsole("set " .. "Exp ID: " .. getGearValue(gear,"ID") .. " health to 0")
  2358 
  2144 				--WriteLnToConsole("targetHit set to true, explosive is at distance " .. dist .. "(within range " .. NR*NR.. ") of circ" )
  2359 					dist = (GetDistFromXYtoXY(vCircX[i], vCircY[i], getGearValue(gear,"XP"), getGearValue(gear,"YP")) - (NR*NR))
  2145 
  2360 					--AddCaption(loc("Dist: ") .. dist .. "!",0xffba00ff,capgrpGameState)
  2146 				CircleDamaged(i)
  2361 					if dist >= 1000000 then
  2147 
  2362 						sniperHits = sniperHits +1
  2148 				circsHit = circsHit + 1
  2363 						AddCaption(loc("Sniper!") .. " +8 " .. loc("points") .. "!",0xffba00ff,capgrpGameState)
  2149 				if circsHit > 1 then
  2364 						AwardPoints(8)
  2150 					AddCaption(loc("Multi-shot!") .. " +15 " .. loc("points") .. "!",0xffba00ff,capgrpAmmostate)
  2365 						if sniperHits == 3 then
  2151 					AwardPoints(15)
  2366 							sniperHits = 0
       
  2367 							AddCaption(loc("They Call Me Bullseye!") .. " +16 " .. loc("points") .. "!",0xffba00ff,capgrpGameState)
       
  2368 							AwardPoints(16)
       
  2369 						end
       
  2370 					elseif dist <= 6000 then
       
  2371 						pointBlankHits = pointBlankHits +1
       
  2372 						if pointBlankHits == 3 then
       
  2373 							pointBlankHits = 0
       
  2374 							AddCaption(loc("Point Blank Combo!") .. " +5 " .. loc("points") .. "!",0xffba00ff,capgrpGameState)
       
  2375 							AwardPoints(5)
       
  2376 						end
       
  2377 					end
       
  2378 
       
  2379 					AddVisualGear(GetX(gear), GetY(gear), vgtBigExplosion, 0, false)
       
  2380 
       
  2381 					targetHit = true
       
  2382 					--DeleteGear(gear)
       
  2383 					--SetHealth(gear,0)
       
  2384 						--WriteLnToConsole("set " .. "Exp ID: " .. getGearValue(gear,"ID") .. " health to 0")
       
  2385 						--WriteLnToConsole("targetHit set to true, explosive is at distance " .. dist .. "(within range " .. NR*NR.. ") of circ" )
       
  2386 
       
  2387 					CircleDamaged(i)
       
  2388 
       
  2389 					circsHit = circsHit + 1
       
  2390 					if circsHit > 1 then
       
  2391 						AddCaption(loc("Multi-shot!") .. " +15 " .. loc("points") .. "!",0xffba00ff,capgrpAmmostate)
       
  2392 						AwardPoints(15)
       
  2393 						circsHit = 0
  2152 						circsHit = 0
  2394 					end
       
  2395 
       
  2396 					shotsHit = shotsHit + 1
       
  2397 
       
  2398 
       
  2399 
       
  2400 				end
  2153 				end
  2401 
  2154 
  2402 			--end
  2155 				shotsHit = shotsHit + 1
       
  2156 
       
  2157 			end
  2403 
  2158 
  2404 		end
  2159 		end
  2405 
  2160 
  2406 	-- if player is hit by circle bazooka
  2161 	-- if player is hit by circle bazooka
  2407 	elseif (GetGearType(gear) == gtShell) then --or (GetGearType(gear) == gtBall) then
  2162 	elseif (GetGearType(gear) == gtShell) then
  2408 
  2163 
  2409 		dist = GetDistFromGearToGear(gear, CurrentHedgehog)
  2164 		dist = GetDistFromGearToGear(gear, CurrentHedgehog)
  2410 
  2165 
  2411 		if beam == true then
  2166 		if beam == true then
  2412 
  2167 
  2427 
  2182 
  2428 		elseif dist < 1600 then
  2183 		elseif dist < 1600 then
  2429 			WellHeAintGonnaJumpNoMore(GetX(gear), GetY(gear), true)
  2184 			WellHeAintGonnaJumpNoMore(GetX(gear), GetY(gear), true)
  2430 		end
  2185 		end
  2431 
  2186 
  2432 		--[[if targetHit == true then
       
  2433 			WriteLnToConsole("about to delete shell due to targetHit being set to true earlier")
       
  2434 			DeleteGear(gear)
       
  2435 			WriteLnToConsole("there, I deleted it")
       
  2436 		end]]
       
  2437 
       
  2438 
       
  2439 	end
  2187 	end
  2440 
  2188 
  2441 	if targetHit == true then
  2189 	if targetHit == true then
  2442 			--nw WriteLnToConsole("about to delete something due to targetHit being set to true earlier")
  2190 			--nw WriteLnToConsole("about to delete something due to targetHit being set to true earlier")
  2443 			DeleteGear(gear)
  2191 			DeleteGear(gear)
  2462 		g2X, g2Y = vCircX[i], vCircY[i]
  2210 		g2X, g2Y = vCircX[i], vCircY[i]
  2463 
  2211 
  2464 		g1X = g1X - g2X
  2212 		g1X = g1X - g2X
  2465 		g1Y = g1Y - g2Y
  2213 		g1Y = g1Y - g2Y
  2466 		dist = (g1X*g1X) + (g1Y*g1Y)
  2214 		dist = (g1X*g1X) + (g1Y*g1Y)
  2467 
       
  2468 		--DoHorribleThings(i, g1X, g1Y, g2X, g2Y, dist)
       
  2469 
  2215 
  2470 		--nw WriteLnToConsole("Calcs done. Dist to CurrentHedgehog is " .. dist)
  2216 		--nw WriteLnToConsole("Calcs done. Dist to CurrentHedgehog is " .. dist)
  2471 
  2217 
  2472 		-- calculate my real radius if I am an aura
  2218 		-- calculate my real radius if I am an aura
  2473 		if vCircType[i] == 0 then
  2219 		if vCircType[i] == 0 then
  2494 				WellHeAintGonnaJumpNoMore(GetX(CurrentHedgehog),GetY(CurrentHedgehog),explosion)
  2240 				WellHeAintGonnaJumpNoMore(GetX(CurrentHedgehog),GetY(CurrentHedgehog),explosion)
  2495 
  2241 
  2496 				if ss == "fatal" then
  2242 				if ss == "fatal" then
  2497 
  2243 
  2498 					if (wepAmmo[0] == 0) and (TimeLeft <= 9) then
  2244 					if (wepAmmo[0] == 0) and (TimeLeft <= 9) then
  2499 					--if (primShotsLeft == 0) and (TimeLeft <= 9) then
       
  2500 						AddCaption(loc("Kamikaze Expert!") .. " +15 " .. loc("points") .. "!",0xffba00ff,capgrpMessage)
  2245 						AddCaption(loc("Kamikaze Expert!") .. " +15 " .. loc("points") .. "!",0xffba00ff,capgrpMessage)
  2501 						AwardPoints(15)
  2246 						AwardPoints(15)
  2502 						PlaySound(sndKamikaze, CurrentHedgehog)
  2247 						PlaySound(sndKamikaze, CurrentHedgehog)
  2503 					elseif (wepAmmo[0] == 0) then
  2248 					elseif (wepAmmo[0] == 0) then
  2504 						AddCaption(loc("Depleted Kamikaze!") .. " +5 " .. loc("points") .. "!",0xffba00ff,capgrpMessage)
  2249 						AddCaption(loc("Depleted Kamikaze!") .. " +5 " .. loc("points") .. "!",0xffba00ff,capgrpMessage)
  2522 
  2267 
  2523 end
  2268 end
  2524 
  2269 
  2525 function HandleCircles()
  2270 function HandleCircles()
  2526 
  2271 
  2527 	--[[if CirclesAreGo == true then
       
  2528 
       
  2529 		--CheckDistances()
       
  2530 		--runOnGears(CheckVarious)	-- used to be in handletracking for some bizarre reason
       
  2531 
       
  2532 		--pTimer = pTimer + 1
       
  2533 		--if pTimer == 100 then
       
  2534 		--	pTimer = 0
       
  2535 		--	runOnGears(ProjectileTrack)
       
  2536 		--end
       
  2537 
       
  2538 	end]]
       
  2539 
       
  2540 
       
  2541 	if rAlpha ~= 255 then
  2272 	if rAlpha ~= 255 then
  2542 
  2273 
  2543 		rPingTimer = rPingTimer + 1
  2274 		rPingTimer = rPingTimer + 1
  2544 		if rPingTimer == 100 then
  2275 		if rPingTimer == 100 then
  2545 			rPingTimer = 0
  2276 			rPingTimer = 0
  2552 
  2283 
  2553 	end
  2284 	end
  2554 
  2285 
  2555 	for i = 0,(vCCount-1) do
  2286 	for i = 0,(vCCount-1) do
  2556 
  2287 
  2557 		--if (vCircActive[i] == true) then
  2288 		SetVisualGearValues(rCirc[i], rCircX[i], rCircY[i], 100, 255, 1, 10, 0, 40, 3, vCircCol[i]-rAlpha)
  2558 			SetVisualGearValues(rCirc[i], rCircX[i], rCircY[i], 100, 255, 1, 10, 0, 40, 3, vCircCol[i]-rAlpha)
       
  2559 		--end
       
  2560 
       
  2561 
       
  2562 
  2289 
  2563 		vCounter[i] = vCounter[i] + 1
  2290 		vCounter[i] = vCounter[i] + 1
  2564 		if vCounter[i] >= vCounterLim[i] then
  2291 		if vCounter[i] >= vCounterLim[i] then
  2565 
  2292 
  2566 			vCounter[i] = 0
  2293 			vCounter[i] = 0
  2567 
  2294 
  2568 			if 	((vType[i] == "drone") or (vType[i] == "blueboss") ) and
  2295 			if 	((vType[i] == "drone") or (vType[i] == "blueboss") ) and
  2569 				(vCircActive[i] == true) then
  2296 				(vCircActive[i] == true) then
  2570 				AddGear(vCircX[i], vCircY[i], gtShell, 0, 0, 0, 1)
  2297 				AddGear(vCircX[i], vCircY[i], gtShell, 0, 0, 0, 1)
  2571 
  2298 
  2572 				--WriteLnToConsole("Circle " .. i .. " just fired/added a gtShell")
       
  2573 				--WriteLnToConsole("The above event occured game Time: " .. GameTime .. "; luaTicks: " .. luaGameTicks)
       
  2574 
       
  2575 			--elseif (vType[i] == "bluebottle") and (vCircActive[i] == true) then
       
  2576 			--	AddGear(vCircX[i], vCircY[i]-vCircRadius[i], gtBall, 0, 0, 0, 1)
       
  2577 			--	AddGear(vCircX[i], vCircY[i]+vCircRadius[i], gtBall, 0, 0, 0, 1)
       
  2578 			--	AddGear(vCircX[i]-vCircRadius[i], vCircY[i], gtBall, 0, 0, 0, 1)
       
  2579 			--	AddGear(vCircX[i]+vCircRadius[i], vCircY[i], gtBall, 0, 0, 0, 1)
       
  2580 			end
  2299 			end
  2581 
  2300 
  2582 		end
  2301 		end
  2583 
  2302 
  2584 		if (vCircActive[i] == true) then
  2303 		if (vCircActive[i] == true) then
  2611 				--vgtDust -- short trail on earthrise
  2330 				--vgtDust -- short trail on earthrise
  2612 				--vgtSmokeTrace
  2331 				--vgtSmokeTrace
  2613 				if vType[i] == "ammo" then
  2332 				if vType[i] == "ammo" then
  2614 
  2333 
  2615 					tempE = AddVisualGear(vCircX[i], vCircY[i], vgtSmoke, 0, true)
  2334 					tempE = AddVisualGear(vCircX[i], vCircY[i], vgtSmoke, 0, true)
  2616 					g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(tempE)	--0xff00ffff	--0x00ff00ff
  2335 					g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(tempE)
  2617 					SetVisualGearValues(tempE, vCircX[i], vCircY[i], g3, g4, g5, g6, g7, g8, g9, vCircCol[i] )
  2336 					SetVisualGearValues(tempE, vCircX[i], vCircY[i], g3, g4, g5, g6, g7, g8, g9, vCircCol[i] )
  2618 
  2337 
  2619 					--AddVisualGear(vCircX[i], vCircY[i], vgtDust, 0, true)
       
  2620 
       
  2621 				elseif vType[i] == "bonus" then
  2338 				elseif vType[i] == "bonus" then
  2622 
  2339 
  2623 					tempE = AddVisualGear(vCircX[i], vCircY[i], vgtDust, 0, true)
  2340 					tempE = AddVisualGear(vCircX[i], vCircY[i], vgtDust, 0, true)
  2624 					g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(tempE)	--0xff00ffff	--0x00ff00ff --vCircCol[i]
  2341 					g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(tempE)
  2625 					SetVisualGearValues(tempE, vCircX[i], vCircY[i], g3, g4, g5, g6, g7, 1, g9, 0xff00ffff )
  2342 					SetVisualGearValues(tempE, vCircX[i], vCircY[i], g3, g4, g5, g6, g7, 1, g9, 0xff00ffff )
  2626 
  2343 
  2627 
  2344 
  2628 				elseif vType[i] == "blueboss" then
  2345 				elseif vType[i] == "blueboss" then
  2629 
  2346 
  2633 
  2350 
  2634 					-- 0xffae00ff -- orange
  2351 					-- 0xffae00ff -- orange
  2635 					-- 0xae00ffff -- purp
  2352 					-- 0xae00ffff -- purp
  2636 
  2353 
  2637 					tempE = AddVisualGear(vCircX[i], vCircY[i], g, 0, true)
  2354 					tempE = AddVisualGear(vCircX[i], vCircY[i], g, 0, true)
  2638 					g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(tempE)	--0xff00ffff	--0x00ff00ff
  2355 					g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(tempE)
  2639 					SetVisualGearValues(tempE, vCircX[i], vCircY[i]+k, g3, g4, g5, g6, g7, g8, g9, trailColour-75 )
  2356 					SetVisualGearValues(tempE, vCircX[i], vCircY[i]+k, g3, g4, g5, g6, g7, g8, g9, trailColour-75 )
  2640 
  2357 
  2641 					tempE = AddVisualGear(vCircX[i], vCircY[i], g, 0, true)
  2358 					tempE = AddVisualGear(vCircX[i], vCircY[i], g, 0, true)
  2642 					g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(tempE)	--0xff00ffff	--0x00ff00ff
  2359 					g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(tempE)
  2643 					SetVisualGearValues(tempE, vCircX[i]+k, vCircY[i]-k, g3, g4, g5, g6, g7, g8, g9, trailColour-75 )
  2360 					SetVisualGearValues(tempE, vCircX[i]+k, vCircY[i]-k, g3, g4, g5, g6, g7, g8, g9, trailColour-75 )
  2644 
  2361 
  2645 					tempE = AddVisualGear(vCircX[i], vCircY[i], g, 0, true)
  2362 					tempE = AddVisualGear(vCircX[i], vCircY[i], g, 0, true)
  2646 					g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(tempE)	--0xff00ffff	--0x00ff00ff
  2363 					g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(tempE)
  2647 					SetVisualGearValues(tempE, vCircX[i]-k, vCircY[i]-k, g3, g4, g5, g6, g7, g8, g9, trailColour-75 )
  2364 					SetVisualGearValues(tempE, vCircX[i]-k, vCircY[i]-k, g3, g4, g5, g6, g7, g8, g9, trailColour-75 )
  2648 
  2365 
  2649 
  2366 
  2650 				end
  2367 				end
  2651 
  2368 
  2709 		for i = 0,(vCCount-1) do
  2426 		for i = 0,(vCCount-1) do
  2710 			vCircX[i] = vCircX[i] + vCircDX[i]
  2427 			vCircX[i] = vCircX[i] + vCircDX[i]
  2711 			vCircY[i] = vCircY[i] + vCircDY[i]
  2428 			vCircY[i] = vCircY[i] + vCircDY[i]
  2712 
  2429 
  2713 			if (CurrentHedgehog ~= nil) and (rAlpha ~= 255) then
  2430 			if (CurrentHedgehog ~= nil) and (rAlpha ~= 255) then
  2714 				DoHorribleThings(i)--(i, g1X, g1Y, g2X, g2Y, dist)
  2431 				DoHorribleThings(i)
  2715 			end
  2432 			end
  2716 
  2433 
  2717 		end
  2434 		end
  2718 
  2435 
  2719 		if (TimeLeft == 0) and (tumbleStarted == true) then
  2436 		if (TimeLeft == 0) and (tumbleStarted == true) then
  2720 
  2437 
  2721 			FadeAlpha = FadeAlpha + 1
  2438 			FadeAlpha = FadeAlpha + 1
  2722 			if FadeAlpha >= 255 then
  2439 			if FadeAlpha >= 255 then
  2723 				FadeAlpha = 255
  2440 				FadeAlpha = 255
  2724 			end
  2441 			end
  2725 
       
  2726 			--new
       
  2727 			--if FadeAlpha == 1 then
       
  2728 			--	AddCaption("GOT IT")
       
  2729 			--	for i = 0,(vCCount-1) do
       
  2730 			--		g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(vCirc[i])
       
  2731 			--		vCircCol[i] = g10
       
  2732 			--	end
       
  2733 			--end
       
  2734 
  2442 
  2735 		end
  2443 		end
  2736 
  2444 
  2737 
  2445 
  2738 		-- derp
  2446 		-- derp
  2739 		if shockwaveHealth > 0 then
  2447 		if shockwaveHealth > 0 then
  2740 			shockwaveHealth = shockwaveHealth - 1
  2448 			shockwaveHealth = shockwaveHealth - 1
  2741 			shockwaveRad = shockwaveRad + 80
  2449 			shockwaveRad = shockwaveRad + 80
  2742 
  2450 		end
  2743 			--mrm = ((48/100*shockwaveRad)/2)
       
  2744 			--AddVisualGear(GetX(CurrentHedgehog)-mrm+GetRandom(mrm*2),GetY(CurrentHedgehog)-mrm+GetRandom(mrm*2), vgtSmoke, 0, false)
       
  2745 		end
       
  2746 
       
  2747 
       
  2748 
  2451 
  2749 	end
  2452 	end
  2750 
  2453 
  2751 	for i = 0,(vCCount-1) do
  2454 	for i = 0,(vCCount-1) do
  2752 		g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(vCirc[i])		-- vCircCol[i] g10
  2455 		g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(vCirc[i])
  2753 		SetVisualGearValues(vCirc[i], vCircX[i], vCircY[i], g3, g4, g5, g6, g7, vCircRadius[i], g9, g10)
  2456 		SetVisualGearValues(vCirc[i], vCircX[i], vCircY[i], g3, g4, g5, g6, g7, vCircRadius[i], g9, g10)
  2754 	end
  2457 	end
  2755 
  2458 
  2756 	if 	(TimeLeft == 0) or
  2459 	if 	(TimeLeft == 0) or
  2757 		((tumbleStarted == false)) then
  2460 		((tumbleStarted == false)) then
  2758 		for i = 0,(vCCount-1) do
  2461 		for i = 0,(vCCount-1) do
  2759 			g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(vCirc[i])		-- vCircCol[i] g10
  2462 			g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(vCirc[i])
  2760 			SetVisualGearValues(vCirc[i], vCircX[i], vCircY[i], g3, g4, g5, g6, g7, vCircRadius[i], g9, (vCircCol[i]-FadeAlpha))
  2463 			SetVisualGearValues(vCirc[i], vCircX[i], vCircY[i], g3, g4, g5, g6, g7, vCircRadius[i], g9, (vCircCol[i]-FadeAlpha))
  2761 		end
  2464 		end
  2762 	end
  2465 	end
  2763 
  2466 
  2764 
  2467 
  2765 	if (CurrentHedgehog ~= nil) then
  2468 	if (CurrentHedgehog ~= nil) then
  2766 		if beam == true then
  2469 		if beam == true then
  2767 			g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(pShield)
  2470 			g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(pShield)
  2768 			--SetVisualGearValues(pShield, GetX(CurrentHedgehog), GetY(CurrentHedgehog), g3, g4, g5, g6, g7, 200, g9, g10 )
       
  2769 			SetVisualGearValues(pShield, GetX(CurrentHedgehog), GetY(CurrentHedgehog), g3, g4, g5, g6, g7, 200, g9, 0xa800ffff-0x000000ff - -shieldHealth )
  2471 			SetVisualGearValues(pShield, GetX(CurrentHedgehog), GetY(CurrentHedgehog), g3, g4, g5, g6, g7, 200, g9, 0xa800ffff-0x000000ff - -shieldHealth )
  2770 			DrawTag(2)
  2472 			DrawTag(2)
  2771 		else
  2473 		else
  2772 			SetVisualGearValues(pShield, GetX(CurrentHedgehog), GetY(CurrentHedgehog), g3, g4, g5, g6, g7, 0, g9, g10 )
  2474 			SetVisualGearValues(pShield, GetX(CurrentHedgehog), GetY(CurrentHedgehog), g3, g4, g5, g6, g7, 0, g9, g10 )
  2773 		end
  2475 		end
  2788 
  2490 
  2789 	if (GetGearType(gear) == gtShell) then
  2491 	if (GetGearType(gear) == gtShell) then
  2790 
  2492 
  2791 		--nw WriteLnToConsole("ProjectileTrack() for Shell ID: " .. getGearValue(gear,"ID"))
  2493 		--nw WriteLnToConsole("ProjectileTrack() for Shell ID: " .. getGearValue(gear,"ID"))
  2792 
  2494 
  2793 		-- newnew
       
  2794 		if (GetGearType(gear) == gtShell) then
  2495 		if (GetGearType(gear) == gtShell) then
  2795 			turningSpeed = 0.1*fMod
  2496 			turningSpeed = 0.1*fMod
  2796 		--elseif (GetGearType(gear) == gtBall) then
       
  2797 		--	turningSpeed = 0.2*fMod
       
  2798 		end
  2497 		end
  2799 
  2498 
  2800 		dx, dy = GetGearVelocity(gear)
  2499 		dx, dy = GetGearVelocity(gear)
  2801 
  2500 
  2802 		--WriteLnToConsole("I'm trying to track currenthedge with shell ID: " .. getGearValue(gear,"ID"))
  2501 		--WriteLnToConsole("I'm trying to track currenthedge with shell ID: " .. getGearValue(gear,"ID"))
  2803 		--WriteLnToConsole("I just got the velocity of the shell. It is dx: " .. dx .. "; dy: " .. dy)
  2502 		--WriteLnToConsole("I just got the velocity of the shell. It is dx: " .. dx .. "; dy: " .. dy)
  2804 		--WriteLnToConsole("CurrentHedgehog is at X: " .. GetX(CurrentHedgehog) .. "; Y: " .. GetY(CurrentHedgehog) )
  2503 		--WriteLnToConsole("CurrentHedgehog is at X: " .. GetX(CurrentHedgehog) .. "; Y: " .. GetY(CurrentHedgehog) )
  2805 
  2504 
  2806 		if GetX(gear) > GetX(CurrentHedgehog) then
  2505 		if GetX(gear) > GetX(CurrentHedgehog) then
  2807 			dx = dx - turningSpeed--0.1
  2506 			dx = dx - turningSpeed
  2808 		else
  2507 		else
  2809 			dx = dx + turningSpeed--0.1
  2508 			dx = dx + turningSpeed
  2810 		end
  2509 		end
  2811 
  2510 
  2812 		if GetY(gear) > GetY(CurrentHedgehog) then
  2511 		if GetY(gear) > GetY(CurrentHedgehog) then
  2813 			dy = dy - turningSpeed--0.1
  2512 			dy = dy - turningSpeed
  2814 		else
  2513 		else
  2815 			dy = dy + turningSpeed--0.1
  2514 			dy = dy + turningSpeed
  2816 		end
  2515 		end
  2817 
  2516 
  2818 
  2517 
  2819 		if (GetGearType(gear) == gtShell) then
  2518 		if (GetGearType(gear) == gtShell) then
  2820 			dxlimit = 0.4*fMod
  2519 			dxlimit = 0.4*fMod
  2821 			dylimit = 0.4*fMod
  2520 			dylimit = 0.4*fMod
  2822 		--elseif (GetGearType(gear) == gtBall) then
       
  2823 		--	dxlimit = 0.5	--  0.5 is about the same
       
  2824 		--	dylimit = 0.5 -- 0.6 is faster than player
       
  2825 		end
  2521 		end
  2826 
  2522 
  2827 		if dx > dxlimit then
  2523 		if dx > dxlimit then
  2828 			dx = dxlimit
  2524 			dx = dxlimit
  2829 		end
  2525 		end