share/hedgewars/Data/Scripts/Multiplayer/Space_Invasion.lua
changeset 5629 c24d29a538af
parent 5334 ce404661aac6
child 5825 a6eab1b7c00d
equal deleted inserted replaced
5626:82e1811c5e70 5629:c24d29a538af
     3 loadfile(GetDataPath() .. "Scripts/Tracker.lua")()
     3 loadfile(GetDataPath() .. "Scripts/Tracker.lua")()
     4 
     4 
     5 ---------------------------------------------------
     5 ---------------------------------------------------
     6 ---------------------------------------------------
     6 ---------------------------------------------------
     7 ---------------------------------------------------
     7 ---------------------------------------------------
     8 --- Space Invasion Code Follows (0.7)
     8 --- Space Invasion Code Follows (0.8)
     9 ---------------------------------------------------
     9 ---------------------------------------------------
    10 ---------------------------------------------------
    10 ---------------------------------------------------
    11 -- VERSION HISTORY
    11 -- VERSION HISTORY
    12 ----------------
    12 ----------------
    13 -- version 0.1
    13 -- version 0.1
    97 
    97 
    98 -- Accuracy Bonus (80% accuracy at the end of your turn with more than 5 shots fired) 15pts
    98 -- Accuracy Bonus (80% accuracy at the end of your turn with more than 5 shots fired) 15pts
    99 
    99 
   100 --(during the length of the game) aka non-repeatable
   100 --(during the length of the game) aka non-repeatable
   101 -- 10/25/50 kills (+25/+50/+100 points)
   101 -- 10/25/50 kills (+25/+50/+100 points)
       
   102 
       
   103 -----------------
       
   104 --0.8
       
   105 -----------------
       
   106 -- added a HUD for turntimeleft, ammo, shield
       
   107 -- shieldhealth hits 0 properly
   102 
   108 
   103 --------------------------
   109 --------------------------
   104 --notes for later
   110 --notes for later
   105 --------------------------
   111 --------------------------
   106 -- maybe add a check for a tie, NAH
   112 -- maybe add a check for a tie, NAH
   240 local pShield
   246 local pShield
   241 local shieldHealth
   247 local shieldHealth
   242 
   248 
   243 local Timer100 = 0
   249 local Timer100 = 0
   244 
   250 
       
   251 local vTag = {}
   245 
   252 
   246 -----------------------------------------------
   253 -----------------------------------------------
   247 -- CIRCLY GOODIES
   254 -- CIRCLY GOODIES
   248 -----------------------------------------------
   255 -----------------------------------------------
   249 
   256 
   287 local vCircCol = {}
   294 local vCircCol = {}
   288 
   295 
   289 -------------------------------------------
   296 -------------------------------------------
   290 -- some lazy copypasta/modified methods
   297 -- some lazy copypasta/modified methods
   291 -------------------------------------------
   298 -------------------------------------------
       
   299 
       
   300 
       
   301 
       
   302 function HideTags()
       
   303 
       
   304 	for i = 0, 3 do 	
       
   305 		SetVisualGearValues(vTag[i],0,0,0,0,0,1,0, 0, 240000, 0xffffff00)
       
   306 	end
       
   307 
       
   308 end
       
   309 
       
   310 function DrawTag(i)
       
   311 	
       
   312 	zoomL = 1.3
       
   313 
       
   314 	xOffset = 40
       
   315 
       
   316 	if i == 0 then
       
   317 		yOffset = 40	
       
   318 		tCol = 0xffba00ff
       
   319 		tValue = TimeLeft
       
   320 	elseif i == 1 then
       
   321 		zoomL = 1.1		
       
   322 		yOffset = 70	
       
   323 		tCol = 0x00ff00ff
       
   324 		tValue = primShotsLeft
       
   325 	elseif i == 2 then
       
   326 		zoomL = 1.1		
       
   327 		xOffset = 40 + 35
       
   328 		yOffset = 70		
       
   329 		tCol = 0xa800ffff
       
   330 		tValue = shieldHealth - 80
       
   331 	end
       
   332 
       
   333 	DeleteVisualGear(vTag[i])
       
   334 	vTag[i] = AddVisualGear(0, 0, vgtHealthTag, 0, false)
       
   335 	g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(vTag[i])
       
   336 	SetVisualGearValues	(	
       
   337 				vTag[i], 		--id
       
   338 				-(ScreenWidth/2) + xOffset,	--xoffset
       
   339 				ScreenHeight - yOffset, --yoffset
       
   340 				0, 			--dx
       
   341 				0, 			--dy
       
   342 				zoomL, 			--zoom
       
   343 				1, 			--~= 0 means align to screen
       
   344 				g7, 			--frameticks
       
   345 				tValue, 		--value
       
   346 				240000, 		--timer
       
   347 				tCol		--GetClanColor( GetHogClan(CurrentHedgehog) )
       
   348 				)
       
   349 
       
   350 end
   292 
   351 
   293 function RebuildTeamInfo()
   352 function RebuildTeamInfo()
   294 
   353 
   295 	-- make a list of individual team names
   354 	-- make a list of individual team names
   296 	for i = 0, (TeamsCount-1) do
   355 	for i = 0, (TeamsCount-1) do
   595 			PlaySound(sndSuddenDeath)
   654 			PlaySound(sndSuddenDeath)
   596 			AddCaption(loc("Ammo Depleted!"),0xff0000ff,capgrpMessage)
   655 			AddCaption(loc("Ammo Depleted!"),0xff0000ff,capgrpMessage)
   597 		else
   656 		else
   598 			AddCaption(loc("Ammo") .. ": " .. primShotsLeft)
   657 			AddCaption(loc("Ammo") .. ": " .. primShotsLeft)
   599 		end
   658 		end
       
   659 		DrawTag(1)
   600 
   660 
   601 		CopyPV(CurrentHedgehog, morte) -- new addition
   661 		CopyPV(CurrentHedgehog, morte) -- new addition
   602 		x,y = GetGearVelocity(morte)
   662 		x,y = GetGearVelocity(morte)
   603 		--WriteLnToConsole("I'm going to shoot a barrel so I just got the velocity of currenthedgehog. It is dx: " .. x .. "; dy: " .. y)
   663 		--WriteLnToConsole("I'm going to shoot a barrel so I just got the velocity of currenthedgehog. It is dx: " .. x .. "; dy: " .. y)
   604 		--WriteLnToConsole("The above event occured game Time: " .. GameTime .. "; luaTicks: " .. luaGameTicks)
   664 		--WriteLnToConsole("The above event occured game Time: " .. GameTime .. "; luaTicks: " .. luaGameTicks)
   687 	Theme = "EarthRise"
   747 	Theme = "EarthRise"
   688 	CaseFreq = 0
   748 	CaseFreq = 0
   689 	HealthCaseProb = 0
   749 	HealthCaseProb = 0
   690 	MinesNum = 0
   750 	MinesNum = 0
   691 	Explosives = 0
   751 	Explosives = 0
       
   752 
       
   753 	for i = 0, 3 do 	
       
   754 		vTag[0] = AddVisualGear(0, 0, vgtHealthTag, 0, false)	
       
   755 	end
       
   756 
       
   757 	HideTags()
       
   758 
   692 end
   759 end
   693 
   760 
   694 function onGameStart()
   761 function onGameStart()
   695 
   762 
   696 	if (MinesTime == -1000) or (MinesTime == 0) then
   763 	if (MinesTime == -1000) or (MinesTime == 0) then
   766 		gameBegun = false
   833 		gameBegun = false
   767 		stopMovement = true
   834 		stopMovement = true
   768 		tumbleStarted = false
   835 		tumbleStarted = false
   769 		SetMyCircles(false)
   836 		SetMyCircles(false)
   770 	end
   837 	end
       
   838 	
       
   839 	HideTags()
       
   840 
   771 	---------------
   841 	---------------
   772 	---------------
   842 	---------------
   773 	--AddCaption("num g: " .. numGears() )
   843 	--AddCaption("num g: " .. numGears() )
   774 
   844 
   775 	--WriteLnToConsole("onNewTurn, I just set a bunch of variables to their necessary states. This was done at:")
   845 	--WriteLnToConsole("onNewTurn, I just set a bunch of variables to their necessary states. This was done at:")
   802 	if Timer100 >= 100 then
   872 	if Timer100 >= 100 then
   803 		Timer100 = 0
   873 		Timer100 = 0
   804 
   874 
   805 		if beam == true then
   875 		if beam == true then
   806 			shieldHealth = shieldHealth - 1
   876 			shieldHealth = shieldHealth - 1
   807 			if shieldHealth <= 80 then
   877 			if shieldHealth < 80 then -- <= 80
   808 				shieldHealth = 80
   878 				shieldHealth = 80
   809 				beam = false
   879 				beam = false
   810 				AddCaption(loc("Shield Depleted"),0xff0000ff,capgrpMessage)
   880 				AddCaption(loc("Shield Depleted"),0xff0000ff,capgrpMessage)
   811 				PlaySound(sndMineTick)
   881 				PlaySound(sndMineTick)
   812 				PlaySound(sndSwitchHog)
   882 				PlaySound(sndSwitchHog)
   848 			--AddCaption(LOC_NOT("Good to go!"))
   918 			--AddCaption(LOC_NOT("Good to go!"))
   849 			tumbleStarted = true
   919 			tumbleStarted = true
   850 			TimeLeft = (TurnTime/1000)	--45
   920 			TimeLeft = (TurnTime/1000)	--45
   851 			FadeAlpha = 0
   921 			FadeAlpha = 0
   852 			AddGear(GetX(CurrentHedgehog), GetY(CurrentHedgehog), gtGrenade, 0, 0, 0, 1)
   922 			AddGear(GetX(CurrentHedgehog), GetY(CurrentHedgehog), gtGrenade, 0, 0, 0, 1)
       
   923 			DrawTag(0)
       
   924 			DrawTag(1)
       
   925 			DrawTag(2)
   853 			SetMyCircles(true)
   926 			SetMyCircles(true)
   854 		end
   927 		end
   855 	end
   928 	end
   856 
   929 
   857 	--WriteLnToConsole("Finished initial check")
   930 	--WriteLnToConsole("Finished initial check")
   866 			TimeLeftCounter = 0
   939 			TimeLeftCounter = 0
   867 			TimeLeft = TimeLeft - 1
   940 			TimeLeft = TimeLeft - 1
   868 
   941 
   869 			if TimeLeft >= 0 then
   942 			if TimeLeft >= 0 then
   870 				--AddCaption(LOC_NOT("Time Left: ") .. TimeLeft)
   943 				--AddCaption(LOC_NOT("Time Left: ") .. TimeLeft)
       
   944 				DrawTag(0)
   871 			end
   945 			end
   872 
   946 
   873 		end
   947 		end
   874 
   948 
   875 		--WriteLnToConsole("Finished timeleft calculations")
   949 		--WriteLnToConsole("Finished timeleft calculations")
   891 				upOn = false
   965 				upOn = false
   892 				down = false
   966 				down = false
   893 				leftOn = false
   967 				leftOn = false
   894 				rightOn = false
   968 				rightOn = false
   895 				SetMyCircles(false)
   969 				SetMyCircles(false)
       
   970 				HideTags()
   896 				--nw WriteLnToConsole("Player is out of luck")
   971 				--nw WriteLnToConsole("Player is out of luck")
   897 
   972 
   898 				if shieldMiser == true then
   973 				if shieldMiser == true then
   899 					AddCaption(loc("Shield Miser!") .. " +20 " .. loc("points") .. "!",0xffba00ff,capgrpAmmoinfo)
   974 					AddCaption(loc("Shield Miser!") .. " +20 " .. loc("points") .. "!",0xffba00ff,capgrpAmmoinfo)
   900 					AwardPoints(20)
   975 					AwardPoints(20)
  1204 
  1279 
  1205 		if (vType[i] == "drone") then
  1280 		if (vType[i] == "drone") then
  1206 			PlaySound(sndHellishImpact4)
  1281 			PlaySound(sndHellishImpact4)
  1207 			TimeLeft = TimeLeft + 4
  1282 			TimeLeft = TimeLeft + 4
  1208 			AddCaption(loc("Time Extended!") .. "+" .. 4 .. loc("sec"), 0xff0000ff,capgrpMessage )
  1283 			AddCaption(loc("Time Extended!") .. "+" .. 4 .. loc("sec"), 0xff0000ff,capgrpMessage )
       
  1284 			DrawTag(0)
  1209 
  1285 
  1210 			morte = AddGear(vCircX[i], vCircY[i], gtExplosives, 0, 0, 0, 1)
  1286 			morte = AddGear(vCircX[i], vCircY[i], gtExplosives, 0, 0, 0, 1)
  1211 			SetHealth(morte, 0)
  1287 			SetHealth(morte, 0)
  1212 
  1288 
  1213 			RK = RK + 1
  1289 			RK = RK + 1
  1221 			AddVisualGear(vCircX[i], vCircY[i], vgtExplosion, 0, false)
  1297 			AddVisualGear(vCircX[i], vCircY[i], vgtExplosion, 0, false)
  1222 			PlaySound(sndExplosion)
  1298 			PlaySound(sndExplosion)
  1223 			PlaySound(sndShotgunReload)
  1299 			PlaySound(sndShotgunReload)
  1224 			primShotsLeft = primShotsLeft + 3
  1300 			primShotsLeft = primShotsLeft + 3
  1225 			AddCaption("+" .. 3 .. " " .. loc("Ammo"), 0x00ff00ff,capgrpMessage)
  1301 			AddCaption("+" .. 3 .. " " .. loc("Ammo"), 0x00ff00ff,capgrpMessage)
       
  1302 			DrawTag(1)
  1226 
  1303 
  1227 			GK = GK + 1
  1304 			GK = GK + 1
  1228 			if GK == 3 then
  1305 			if GK == 3 then
  1229 				GK = 0
  1306 				GK = 0
  1230 				AddCaption(loc("Ammo Maniac!") .. " +5 " .. loc("points") .. "!",0xffba00ff,capgrpMessage2)
  1307 				AddCaption(loc("Ammo Maniac!") .. " +5 " .. loc("points") .. "!",0xffba00ff,capgrpMessage2)
  1250 			AddCaption(loc("Shield boosted! +30 power"), 0xa800ffff,capgrpMessage)
  1327 			AddCaption(loc("Shield boosted! +30 power"), 0xa800ffff,capgrpMessage)
  1251 			if shieldHealth >= 250 then
  1328 			if shieldHealth >= 250 then
  1252 				shieldHealth = 250
  1329 				shieldHealth = 250
  1253 				AddCaption(loc("Shield is fully recharged!"),0xa800ffff,capgrpMessage)
  1330 				AddCaption(loc("Shield is fully recharged!"),0xa800ffff,capgrpMessage)
  1254 			end
  1331 			end
       
  1332 			DrawTag(2)
  1255 
  1333 
  1256 			OK = OK + 1
  1334 			OK = OK + 1
  1257 			if OK == 3 then
  1335 			if OK == 3 then
  1258 				OK = 0
  1336 				OK = 0
  1259 				AddCaption(loc("Shield Seeker!") .. " + 10 " .. loc("points") .. "!",0xffba00ff,capgrpMessage2)
  1337 				AddCaption(loc("Shield Seeker!") .. " + 10 " .. loc("points") .. "!",0xffba00ff,capgrpMessage2)
  1813 
  1891 
  1814 	if (CurrentHedgehog ~= nil) and (beam == true) then
  1892 	if (CurrentHedgehog ~= nil) and (beam == true) then
  1815 		g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(pShield)
  1893 		g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(pShield)
  1816 		--SetVisualGearValues(pShield, GetX(CurrentHedgehog), GetY(CurrentHedgehog), g3, g4, g5, g6, g7, 200, g9, g10 )
  1894 		--SetVisualGearValues(pShield, GetX(CurrentHedgehog), GetY(CurrentHedgehog), g3, g4, g5, g6, g7, 200, g9, g10 )
  1817 		SetVisualGearValues(pShield, GetX(CurrentHedgehog), GetY(CurrentHedgehog), g3, g4, g5, g6, g7, 200, g9, 0xa800ffff-0x000000ff - -shieldHealth )
  1895 		SetVisualGearValues(pShield, GetX(CurrentHedgehog), GetY(CurrentHedgehog), g3, g4, g5, g6, g7, 200, g9, 0xa800ffff-0x000000ff - -shieldHealth )
       
  1896 		DrawTag(2)
  1818 	else
  1897 	else
  1819 		SetVisualGearValues(pShield, GetX(CurrentHedgehog), GetY(CurrentHedgehog), g3, g4, g5, g6, g7, 0, g9, g10 )
  1898 		SetVisualGearValues(pShield, GetX(CurrentHedgehog), GetY(CurrentHedgehog), g3, g4, g5, g6, g7, 0, g9, g10 )
  1820 	end
  1899 	end
  1821 
  1900 
  1822 end
  1901 end