share/hedgewars/Data/Scripts/Multiplayer/Construction_Mode.lua
changeset 12957 08f91e9e3d2c
parent 12956 89930daecaab
child 12959 695cc142827b
equal deleted inserted replaced
12956:89930daecaab 12957:08f91e9e3d2c
   296 		nil, 		-- value (set above)
   296 		nil, 		-- value (set above)
   297 		240000, 	-- timer
   297 		240000, 	-- timer
   298 		tCol		-- color
   298 		tCol		-- color
   299 	)
   299 	)
   300 
   300 
       
   301 end
       
   302 
       
   303 function DeleteClanPowerTag()
       
   304 	DeleteVisualGear(clanPowerTag)
       
   305 	clanPowerTag = nil
   301 end
   306 end
   302 
   307 
   303 function XYisInRect(px, py, psx, psy, pex, pey)
   308 function XYisInRect(px, py, psx, psy, pex, pey)
   304 
   309 
   305 	if (px > psx) and (px < pex) and (py > psy) and (py < pey) then
   310 	if (px > psx) and (px < pex) and (py > psy) and (py < pey) then
  1011 			AddStruc(x,y, pMode[pIndex],GetHogClan(CurrentHedgehog))
  1016 			AddStruc(x,y, pMode[pIndex],GetHogClan(CurrentHedgehog))
  1012 			placed = true
  1017 			placed = true
  1013 		end
  1018 		end
  1014 
  1019 
  1015 		if placed then
  1020 		if placed then
       
  1021 			-- Pay the price
  1016 			clanPower[GetHogClan(CurrentHedgehog)] = clanPower[GetHogClan(CurrentHedgehog)] - placedExpense
  1022 			clanPower[GetHogClan(CurrentHedgehog)] = clanPower[GetHogClan(CurrentHedgehog)] - placedExpense
       
  1023 			DrawClanPowerTag()
  1017 		else
  1024 		else
  1018 			AddCaption(loc("Invalid Placement"), colorMessageError, capgrpVolume)
  1025 			AddCaption(loc("Invalid Placement"), colorMessageError, capgrpVolume)
  1019 			PlaySound(sndDenied)
  1026 			PlaySound(sndDenied)
  1020 		end
  1027 		end
  1021 
  1028 
  1174 			end
  1181 			end
  1175 		end
  1182 		end
  1176 
  1183 
  1177 		if GameTime % 100 == 0 then
  1184 		if GameTime % 100 == 0 then
  1178 
  1185 
  1179 			DrawClanPowerTag()
       
  1180 
       
  1181 			-- Force-update the construction mode tools every 100ms.
  1186 			-- Force-update the construction mode tools every 100ms.
  1182 			-- This makes sure the announcer messages don't disappear
  1187 			-- This makes sure the announcer messages don't disappear
  1183 			-- while the tool is selected.
  1188 			-- while the tool is selected.
  1184 			if (band(GetState(CurrentHedgehog), gstHHDriven) ~= 0) then
  1189 			if (band(GetState(CurrentHedgehog), gstHHDriven) ~= 0) then
       
  1190 				DrawClanPowerTag()
  1185 				curWep = GetCurAmmoType()
  1191 				curWep = GetCurAmmoType()
  1186 				HandleConstructionModeTools()
  1192 				HandleConstructionModeTools()
  1187 			else
  1193 			else
       
  1194 				DeleteClanPowerTag()
  1188 				curWep = amNothing
  1195 				curWep = amNothing
  1189 			end
  1196 			end
  1190 
  1197 
  1191 		end
  1198 		end
  1192 
  1199 
  1627 			clanPower[clan] = conf_maxEnergy
  1634 			clanPower[clan] = conf_maxEnergy
  1628 		end
  1635 		end
  1629 	end
  1636 	end
  1630 	clanUsedExtraTime[clan] = false
  1637 	clanUsedExtraTime[clan] = false
  1631 	clanCratesSpawned[clan] = 0
  1638 	clanCratesSpawned[clan] = 0
       
  1639 
       
  1640 	DrawClanPowerTag()
  1632 end
  1641 end
  1633 
  1642 
  1634 function onEndTurn()
  1643 function onEndTurn()
  1635 	curWep = amNothing
  1644 	curWep = amNothing
  1636 	HandleConstructionModeTools()
  1645 	HandleConstructionModeTools()
       
  1646 	DeleteClanPowerTag()
  1637 end
  1647 end
  1638 
  1648 
  1639 function onGameTick()
  1649 function onGameTick()
  1640 	HandleConstructionMode()
  1650 	HandleConstructionMode()
  1641 end
  1651 end