马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
[jass]//远离一个单位一定距离
function LeaveUnit takes unit AiUnit,unit target,real length returns nothing
local real a=GetUnitX(AiUnit)-GetUnitX(target)
local real b=GetUnitY(AiUnit)-GetUnitY(target)
local real c=SquareRoot(a*a+b*b)
local real x=(length/c)*a+GetUnitX(AiUnit)
local real y=(length/c)*b+GetUnitY(AiUnit)
call IssuePointOrder(AiUnit,"move",x,y)
call DisplayTextToForce( GetPlayersAll(),"123456")
endfunction
//找到周围最弱的单位并A之
function KillWeakestUnit takes unit center,real range,real hpkill returns nothing
local unit temp
local unit weakest
local group g=CreateGroup()
call GroupEnumUnitsInRange(g,GetUnitX(center),GetUnitY(center),range,null)
call GroupRemoveUnit(g,center)
loop
set weakest=FirstOfGroup(g)
if weakest==null then
call DestroyGroup(g)
set temp = null
set g = null
return
endif
call GroupRemoveUnit(g,weakest)
exitwhen GetUnitState(weakest,UNIT_STATE_LIFE)>0 //IsUnitEnemy(weakest,GetOwningPlayer(center)) and
endloop
loop
set temp=FirstOfGroup(g)
exitwhen temp == null
if GetUnitState(temp, UNIT_STATE_LIFE)>0 then
if GetUnitState(weakest,UNIT_STATE_LIFE)>GetUnitState(temp, UNIT_STATE_LIFE) then
set weakest = temp
endif
endif
call GroupRemoveUnit(g,temp)
endloop
call DestroyGroup(g)
set temp = null
set g = null
if IsUnitAliveBJ(weakest)and(weakest != null)and(GetUnitState(weakest,UNIT_STATE_LIFE)<hpkill)and(GetUnitCurrentOrder(center) != String2OrderIdBJ("attack"))and(not(IsUnitType(weakest, UNIT_TYPE_HERO))) then
//call DisplayTextToForce( GetPlayersAll(), ("===|c000000FF"+GetUnitName(center)+ "|R当前尝试补刀目标单位是:" + ( GetUnitName(weakest) + ( "|||||当前血量" + R2S(GetUnitStateSwap(UNIT_STATE_LIFE,weakest ))))))
call IssueTargetOrder(center,"attack",weakest)
endif
endfunction
//单位是否死亡或者存活
function IsDead takes unit TheUnit returns boolean
return (TheUnit==null)or(IsUnitType(TheUnit,UNIT_TYPE_DEAD))or(IsUnitDeadBJ(TheUnit))
endfunction
function IsAlive takes unit TheUnit returns boolean
return (TheUnit!=null)and(IsDead(TheUnit)==false)
endfunction
//取得单位身后的点
function GetUnitBackLoc takes unit TheTarget,real TheRange returns location
local real TheDir
if (TheTarget!=null)and(GetUnitState(TheTarget,UNIT_STATE_LIFE)>0) then
set TheDir=Deg2Rad(GetUnitFacing(TheTarget)+180)
return (Location(TheRange*Cos(TheDir)+GetUnitX(TheTarget),TheRange*Sin(TheDir)+GetUnitY(TheTarget)))
endif
return null
endfunction
//单位组前面的点
function GetUnitFrontLoc takes group whichGroup,real TheRange returns location
local real TheDir
local unit TheTarget
set TheTarget=FirstOfGroup(whichGroup)
if (TheTarget!=null)and(IsAlive(TheTarget)) then
set TheDir=Deg2Rad(GetUnitFacing(TheTarget))
return (Location(TheRange*Cos(TheDir)+GetUnitX(TheTarget),TheRange*Sin(TheDir)+GetUnitY(TheTarget)))
endif
return null
endfunction
[/jass] 复制代码