share/hedgewars/Data/Scripts/Multiplayer/Construction_Mode.lua
changeset 14742 2e8213c0951f
parent 14348 ffebbcc40c9b
child 15242 0986513cd6e1
equal deleted inserted replaced
14741:37a781d28e43 14742:2e8213c0951f
   104 local curWep = amNothing -- current weapon, used to reduce # of calls to GetCurAmmoType()
   104 local curWep = amNothing -- current weapon, used to reduce # of calls to GetCurAmmoType()
   105 
   105 
   106 local fortMode = false -- is using a fort map?
   106 local fortMode = false -- is using a fort map?
   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 cGearPlacementDone = false
   109 local uniqueStructureID = 0 -- Counter and ID for structures. Is incremented each time a structure spawns
   110 local uniqueStructureID = 0 -- Counter and ID for structures. Is incremented each time a structure spawns
   110 
   111 
   111 -- Colors
   112 -- Colors
   112 local colorSupportStation = 0xFFFF00FF
   113 local colorSupportStation = 0xFFFF00FF
   113 local colorConstructionStation = 0xFFFFFFFF
   114 local colorConstructionStation = 0xFFFFFFFF
  1383 	if cGear ~= nil then
  1384 	if cGear ~= nil then
  1384 
  1385 
  1385 		local x,y = GetGearTarget(cGear)
  1386 		local x,y = GetGearTarget(cGear)
  1386 
  1387 
  1387 		if GetGearType(cGear) == gtAirAttack then
  1388 		if GetGearType(cGear) == gtAirAttack then
  1388 			DeleteGear(cGear)
  1389 			SetGearMessage(cGear, bor(GetGearMessage(cGear), gmDestroy))
       
  1390 			if not cGearPlacementDone then
       
  1391 				PlaceObject(x, y)
       
  1392 				cGearPlacementDone = true
       
  1393 			end
       
  1394 		elseif GetGearType(cGear) == gtTeleport then
       
  1395 			CheckTeleport(cGear, x, y)
       
  1396 			cGear = nil
       
  1397 			cGearPlacementDone = true
       
  1398 		elseif GetGearType(cGear) == gtGirder then
       
  1399 			currentGirderRotation = GetState(cGear)
  1389 			PlaceObject(x, y)
  1400 			PlaceObject(x, y)
  1390 		elseif GetGearType(cGear) == gtTeleport then
  1401 			cGearPlacementDone = true
  1391 
       
  1392 				CheckTeleport(cGear, x, y)
       
  1393 				cGear = nil
       
  1394 		elseif GetGearType(cGear) == gtGirder then
       
  1395 
       
  1396 			currentGirderRotation = GetState(cGear)
       
  1397 
       
  1398 			PlaceObject(x, y)
       
  1399 		end
  1402 		end
  1400 
  1403 
  1401 	end
  1404 	end
  1402 
  1405 
  1403 end
  1406 end
  1875 function onGearAdd(gear)
  1878 function onGearAdd(gear)
  1876 
  1879 
  1877 	local gt = GetGearType(gear)
  1880 	local gt = GetGearType(gear)
  1878 	if (gt == gtAirAttack) or (gt == gtTeleport) or (gt == gtGirder) then
  1881 	if (gt == gtAirAttack) or (gt == gtTeleport) or (gt == gtGirder) then
  1879 		cGear = gear
  1882 		cGear = gear
       
  1883 		cGearPlacementDone = false
  1880 	end
  1884 	end
  1881 
  1885 
  1882 	if isATrackedGear(gear) then
  1886 	if isATrackedGear(gear) then
  1883 		trackGear(gear)
  1887 		trackGear(gear)
  1884 	elseif gearCanBeDeflected(gear) then
  1888 	elseif gearCanBeDeflected(gear) then