share/hedgewars/Data/Scripts/Multiplayer/Construction_Mode.lua
changeset 12687 b7fd7ab8ddf9
parent 12402 414bcb4ca5ee
child 12841 8610462e3d33
equal deleted inserted replaced
12686:4e5e725f2c56 12687:b7fd7ab8ddf9
   623 
   623 
   624 --Check for proximity of gears to structures, and make structures behave accordingly
   624 --Check for proximity of gears to structures, and make structures behave accordingly
   625 function CheckProximity(gear)
   625 function CheckProximity(gear)
   626 
   626 
   627 	dist = GetDistFromGearToXY(gear, GetX(strucGear[tempID]), GetY(strucGear[tempID]))
   627 	dist = GetDistFromGearToXY(gear, GetX(strucGear[tempID]), GetY(strucGear[tempID]))
       
   628 	if not dist then
       
   629 		return
       
   630 	end
   628 
   631 
   629 	-- calculate my real radius if I am an aura
   632 	-- calculate my real radius if I am an aura
   630 	if strucCircType[tempID] == 0 then
   633 	if strucCircType[tempID] == 0 then
   631 		NR = strucCircRadius[tempID]
   634 		NR = strucCircRadius[tempID]
   632 	else
   635 	else
  1078 ------------------------
  1081 ------------------------
  1079 
  1082 
  1080 function GetDistFromGearToXY(gear, g2X, g2Y)
  1083 function GetDistFromGearToXY(gear, g2X, g2Y)
  1081 
  1084 
  1082 	g1X, g1Y = GetGearPosition(gear)
  1085 	g1X, g1Y = GetGearPosition(gear)
       
  1086 	if not g1X then
       
  1087 		return nil
       
  1088 	end
  1083 	q = g1X - g2X
  1089 	q = g1X - g2X
  1084 	w = g1Y - g2Y
  1090 	w = g1Y - g2Y
  1085 
  1091 
  1086 	return ( (q*q) + (w*w) )
  1092 	return ( (q*q) + (w*w) )
  1087 
  1093