share/hedgewars/Data/Scripts/Multiplayer/Construction_Mode.lua
changeset 13022 1e7ac94d9d3c
parent 13019 880662cf41ee
child 13026 ca7fdb431b34
equal deleted inserted replaced
13021:af35e22fb533 13022:1e7ac94d9d3c
   107 local tempID_CheckProximity = nil -- temporary structure variable for CheckProximity
   107 local tempID_CheckProximity = nil -- temporary structure variable for CheckProximity
   108 local cGear = nil -- detects placement of girders and objects (using airattack)
   108 local cGear = nil -- detects placement of girders and objects (using airattack)
   109 local uniqueStructureID = 0 -- Counter and ID for structures. Is incremented each time a structure spawns
   109 local uniqueStructureID = 0 -- Counter and ID for structures. Is incremented each time a structure spawns
   110 
   110 
   111 -- Colors
   111 -- Colors
   112 local colorClanTag = 0x00ff00ff
       
   113 
       
   114 local colorSupportStation = 0xFFFF00FF
   112 local colorSupportStation = 0xFFFF00FF
   115 local colorConstructionStation = 0xFFFFFFFF
   113 local colorConstructionStation = 0xFFFFFFFF
   116 local colorTeleportationNode = 0x0000FFFF
   114 local colorTeleportationNode = 0x0000FFFF
   117 local colorHealingStation = 0xFF808040 -- Just a slight glow
   115 local colorHealingStation = 0xFF808040 -- Just a slight glow
   118 local colorBioFilter = 0xFF0000FF
   116 local colorBioFilter = 0xFF0000FF
   285 	ammoType == amGirder or
   283 	ammoType == amGirder or
   286 	ammoType == amRubber or
   284 	ammoType == amRubber or
   287 	ammoType == amTeleport
   285 	ammoType == amTeleport
   288 end
   286 end
   289 
   287 
       
   288 function RenderClanPower()
       
   289 	for i=0, TeamsCount-1 do
       
   290 		local name = GetTeamName(i)
       
   291 		SetTeamLabel(name, clanPower[GetTeamClan(name)])
       
   292 	end
       
   293 
       
   294 	DrawClanPowerTag()
       
   295 end
       
   296 
   290 function DrawClanPowerTag()
   297 function DrawClanPowerTag()
   291 
   298 
   292 	local zoomL = 1.1
   299 	local zoomL = 1.1
   293 	local xOffset = 45
   300 	local xOffset = 45
   294 	local yOffset = 70
   301 	local yOffset = 70
   295 	local tValue = clanPower[GetHogClan(CurrentHedgehog)]
   302 	local tValue = clanPower[GetHogClan(CurrentHedgehog)]
   296 	local tCol = colorClanTag
   303 	local tCol = GetClanColor(GetHogClan(CurrentHedgehog))
   297 	-- alternatively:  tCol = GetClanColor(GetHogClan(CurrentHedgehog))
       
   298 
   304 
   299 	DeleteVisualGear(clanPowerTag)
   305 	DeleteVisualGear(clanPowerTag)
   300 	clanPowerTag = AddVisualGear(-div(ScreenWidth, 2) + xOffset, ScreenHeight - yOffset, vgtHealthTag, tValue, false)
   306 	clanPowerTag = AddVisualGear(-div(ScreenWidth, 2) + xOffset, ScreenHeight - yOffset, vgtHealthTag, tValue, false)
   301 
   307 
   302 	SetVisualGearValues(
   308 	SetVisualGearValues(
   303 		clanPowerTag, 	-- id
   309 		clanPowerTag,   -- id
   304 		nil,		-- x offset (set above)
   310 		nil,            -- x offset (set above)
   305 		nil,		-- y offset (set above)
   311 		nil,            -- y offset (set above)
   306 		0, 		-- dx
   312 		0,              -- dx
   307 		0, 		-- dy
   313 		0,              -- dy
   308 		zoomL, 		-- zoom
   314 		zoomL,          -- zoom
   309 		1, 		-- ~= 0 means align to screen
   315 		1,              -- ~= 0 means align to screen
   310 		nil, 		-- frameticks
   316 		nil,            -- frameticks
   311 		nil, 		-- value (set above)
   317 		nil,            -- value (set above)
   312 		240000, 	-- timer
   318 		240000,         -- timer
   313 		tCol		-- color
   319 		tCol            -- color
   314 	)
   320 	)
   315 
   321 
   316 end
   322 end
   317 
   323 
   318 function DeleteClanPowerTag()
   324 function DeleteClanPowerTag()
  1071 		end
  1077 		end
  1072 
  1078 
  1073 		if placed then
  1079 		if placed then
  1074 			-- Pay the price
  1080 			-- Pay the price
  1075 			clanPower[GetHogClan(CurrentHedgehog)] = clanPower[GetHogClan(CurrentHedgehog)] - placedExpense
  1081 			clanPower[GetHogClan(CurrentHedgehog)] = clanPower[GetHogClan(CurrentHedgehog)] - placedExpense
  1076 			DrawClanPowerTag()
  1082 			RenderClanPower()
  1077 		else
  1083 		else
  1078 			if IsHogLocal(CurrentHedgehog) then
  1084 			if IsHogLocal(CurrentHedgehog) then
  1079 				AddCaption(loc("Invalid Placement"), colorMessageError, capgrpVolume)
  1085 				AddCaption(loc("Invalid Placement"), colorMessageError, capgrpVolume)
  1080 			end
  1086 			end
  1081 			PlaySound(sndDenied)
  1087 			PlaySound(sndDenied)
  1330 
  1336 
  1331 			-- Force-update the construction mode tools every 100ms.
  1337 			-- Force-update the construction mode tools every 100ms.
  1332 			-- This makes sure the announcer messages don't disappear
  1338 			-- This makes sure the announcer messages don't disappear
  1333 			-- while the tool is selected.
  1339 			-- while the tool is selected.
  1334 			if (band(GetState(CurrentHedgehog), gstHHDriven) ~= 0) then
  1340 			if (band(GetState(CurrentHedgehog), gstHHDriven) ~= 0) then
  1335 				DrawClanPowerTag()
  1341 				RenderClanPower()
  1336 				curWep = GetCurAmmoType()
  1342 				curWep = GetCurAmmoType()
  1337 				HandleConstructionModeTools()
  1343 				HandleConstructionModeTools()
  1338 			else
  1344 			else
  1339 				DeleteClanPowerTag()
  1345 				DeleteClanPowerTag()
  1340 				curWep = amNothing
  1346 				curWep = amNothing
  1747 		teamLObjectMode[team] = "Mine Placement Mode"
  1753 		teamLObjectMode[team] = "Mine Placement Mode"
  1748 		teamLCrateMode[team] = "Weapon Crate Placement Mode"
  1754 		teamLCrateMode[team] = "Weapon Crate Placement Mode"
  1749 		teamLMineIndex[team] = 1
  1755 		teamLMineIndex[team] = 1
  1750 		teamLWeapIndex[team] = 1
  1756 		teamLWeapIndex[team] = 1
  1751 		teamLUtilIndex[team] = 1
  1757 		teamLUtilIndex[team] = 1
       
  1758 		SetTeamLabel(team, tostring(clanPower[GetTeamClan(team)]))
  1752 	end
  1759 	end
  1753 
  1760 
  1754 	local tMapWidth = RightX - LeftX
  1761 	local tMapWidth = RightX - LeftX
  1755 	local tMapHeight = WaterLine - TopY
  1762 	local tMapHeight = WaterLine - TopY
  1756 	local clanInterval = div(tMapWidth,ClansCount)
  1763 	local clanInterval = div(tMapWidth,ClansCount)
  1803 		end
  1810 		end
  1804 	end
  1811 	end
  1805 	clanUsedExtraTime[clan] = false
  1812 	clanUsedExtraTime[clan] = false
  1806 	clanCratesSpawned[clan] = 0
  1813 	clanCratesSpawned[clan] = 0
  1807 
  1814 
  1808 	DrawClanPowerTag()
  1815 	RenderClanPower()
  1809 end
  1816 end
  1810 
  1817 
  1811 function onEndTurn()
  1818 function onEndTurn()
  1812 	curWep = amNothing
  1819 	curWep = amNothing
  1813 	HandleConstructionModeTools()
  1820 	HandleConstructionModeTools()
  1819 end
  1826 end
  1820 
  1827 
  1821 function onScreenResize()
  1828 function onScreenResize()
  1822 	-- redraw Tags so that their screen locations are updated
  1829 	-- redraw Tags so that their screen locations are updated
  1823 	if (CurrentHedgehog ~= nil) then
  1830 	if (CurrentHedgehog ~= nil) then
  1824 		DrawClanPowerTag()
  1831 		RenderClanPower()
  1825 	end
  1832 	end
  1826 end
  1833 end
  1827 
  1834 
  1828 
  1835 
  1829 function onGearResurrect(gear)
  1836 function onGearResurrect(gear)