|
发表于 2008-9-7 09:25:18
|
显示全部楼层
[codes=jass]
//返回距离 角度
//GetUnitDistance(单位,单位)返回距离
//GetUnitPointDistance(单位,点,是否删除点 布尔值)返回距离
//GetPointDistance(点,点,是否删除点 布尔值)返回距离
//GetUnitAngle(单位,单位)返回角度
//GetUnitPointAngle(单位,点,是否删除点 布尔值)返回角度
//GetPointAngle(点,点,是否删除点 布尔值)返回角度
function GetUnitDistance takes unit a,unit b returns real
local real dx = GetUnitX(a) - GetUnitX(b)
local real dy = GetUnitY(a) - GetUnitY(b)
return SquareRoot(dx * dx + dy * dy)
endfunction
function GetUnitPointDistance takes unit a,location b,boolean c returns real
local real dx = GetUnitX(a) - GetLocationX(b)
local real dy = GetUnitY(a) - GetLocationY(b)
if c==true then
call RemoveLocation(b)
endif
return SquareRoot(dx * dx + dy * dy)
endfunction
function GetPointDistance takes location a,location b,boolean c returns real
local real dx = GetLocationX(a) - GetLocationX(b)
local real dy = GetLocationY(a) - GetLocationY(b)
if c==true then
call RemoveLocation(a)
call RemoveLocation(b)
endif
return SquareRoot(dx * dx + dy * dy)
endfunction
function GetUnitAngle takes unit a,unit b returns real
local real dx = GetUnitX(a) - GetUnitX(b)
local real dy = GetUnitY(a) - GetUnitY(b)
return Atan(dy/dx)
endfunction
function GetUnitPointAngle takes unit a,location b,boolean c returns real
local real dx = GetUnitX(a) - GetLocationX(b)
local real dy = GetUnitY(a) - GetLocationY(b)
if c==true then
call RemoveLocation(b)
endif
return Atan(dy/dx)
endfunction
function GetPointAngle takes location a,location b,boolean c returns real
local real dx = GetLocationX(a) - GetLocationX(b)
local real dy = GetLocationY(a) - GetLocationY(b)
if c==true then
call RemoveLocation(a)
call RemoveLocation(b)
endif
return Atan(dy/dx)
endfunction
[\\codes]
你就用call GetUnitAngle(新建的单位,触发单位)吧 |
|