Как проверить точку на проходимость без использования функции IsTerrainPathable и поставки дамми?
Code
function OtrCondition takes nothing returns boolean return GetSpellAbilityId()=='A003' endfunction
function Trig_Otr_Act3 takes nothing returns nothing local timer t=GetExpiredTimer() local integer th=GetHandleId(t) local unit u=LoadUnitHandle(udg_HMDU,th,0) local real angle=LoadReal(udg_HMDU,th,1) local real speed=LoadReal(udg_HMDU,th,2) local real x=GetUnitX(u) local real y=GetUnitY(u) local real x1=PolarX(x,speed,angle) local real y1=PolarY(y,speed,angle) local integer i=GetRandomInt(1,2) if IsTerrainPathable(x1,y1,PATHING_TYPE_WALKABILITY) then loop if i==1 then set angle=angle-45 elseif i==2 then set angle=angle+45 endif set x1=PolarX(x,speed,angle) set y1=PolarY(y,speed,angle) exitwhen IsTerrainPathable(x1,y1,PATHING_TYPE_WALKABILITY)==false endloop set speed=speed-2 endif if IsTerrainPathable(PolarX(x,speed,angle),PolarY(y,speed,angle),PATHING_TYPE_WALKABILITY)==false then set x1=PolarX(x,speed,angle) set y1=PolarY(y,speed,angle) call SetUnitX(u,x1) call SetUnitY(u,y1) call DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Human\\FlakCannons\\FlakTarget.mdl",x,y)) set speed=speed-0.5 endif if speed<=0 then call FlushChildHashtable(udg_HMDU,th) call PauseTimer(t) call DestroyTimer(t) else call SaveReal(udg_HMDU,th,1,angle) call SaveReal(udg_HMDU,th,2,speed) endif set t=null set u=null endfunction
function Trig_Otr_Act2 takes unit u,unit u2 returns nothing local timer t=CreateTimer() local integer th=GetHandleId(t) local real x1=GetUnitX(u) local real y1=GetUnitY(u) local real x2=GetUnitX(u2) local real y2=GetUnitY(u2) local real angle=bj_RADTODEG*Atan2(y2-y1,x2-x1) local real speed=20-XYdist(x1,y1,x2,y2)/100
function Trig_Otr_Actions takes nothing returns nothing local unit u=GetTriggerUnit() local unit uu local group g=CreateGroup() call GroupEnumUnitsInRange(g,GetUnitX(u),GetUnitY(u),500,null) loop set uu=FirstOfGroup(g) exitwhen uu==null if IsUnitEnemy(uu,GetOwningPlayer(u)) and GetUnitState(uu,UNIT_STATE_LIFE)>0 then call Trig_Otr_Act2(u,uu) endif call GroupRemoveUnit(g,uu) endloop call DestroyGroup(g) set u=null set g=null endfunction
//=========================================================================== function InitTrig_Otr takes nothing returns nothing local trigger tr=CreateTrigger() local integer i=0 loop call TriggerRegisterPlayerUnitEvent(tr,Player(i),EVENT_PLAYER_UNIT_SPELL_EFFECT,null) set i=i+1 exitwhen i==12 endloop call TriggerAddCondition(tr,Condition(function OtrCondition)) call TriggerAddAction(tr, function Trig_Otr_Actions ) set tr=null endfunction
XYdist - это дистанция между точками, а PolarX и Y смещение соответственно просто я забыл CustomCode скопировать
Сообщение отредактировал rixt7956 - Суббота, 08 Января 2011, 15:01:40
function OtrCondition takes nothing returns boolean return GetSpellAbilityId()=='A003' endfunction
function Trig_Otr_Act3 takes nothing returns nothing local timer t=GetExpiredTimer() local integer th=GetHandleId(t) local unit u=LoadUnitHandle(udg_HMDU,th,0) local real angle=LoadReal(udg_HMDU,th,1) local real speed=LoadReal(udg_HMDU,th,2) local real x=GetUnitX(u) local real y=GetUnitY(u) local real x1=PolarX(x,speed,angle) local real y1=PolarY(y,speed,angle) local integer i=GetRandomInt(1,2) if IsTerrainPathable(x1,y1,PATHING_TYPE_WALKABILITY) then loop if i==1 then set angle=angle-45 elseif i==2 then set angle=angle+45 endif set x1=PolarX(x,speed,angle) set y1=PolarY(y,speed,angle) exitwhen IsTerrainPathable(x1,y1,PATHING_TYPE_WALKABILITY)==false endloop set speed=speed-2 endif if IsTerrainPathable(PolarX(x,speed,angle),PolarY(y,speed,angle),PATHING_TYPE_WALKABILITY)==false then set x1=PolarX(x,speed,angle) set y1=PolarY(y,speed,angle) call SetUnitX(u,x1) call SetUnitY(u,y1) call DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Human\\FlakCannons\\FlakTarget.mdl",x,y)) set speed=speed-0.5 endif if speed<=0 then call FlushChildHashtable(udg_HMDU,th) call PauseTimer(t) call DestroyTimer(t) else call SaveReal(udg_HMDU,th,1,angle) call SaveReal(udg_HMDU,th,2,speed) endif set t=null set u=null endfunction
function Trig_Otr_Act2 takes unit u,unit u2 returns nothing local timer t=CreateTimer() local integer th=GetHandleId(t) local real x1=GetUnitX(u) local real y1=GetUnitY(u) local real x2=GetUnitX(u2) local real y2=GetUnitY(u2) local real angle=bj_RADTODEG*Atan2(y2-y1,x2-x1) local real speed=20-XYdist(x1,y1,x2,y2)/100
function Trig_Otr_Actions takes nothing returns nothing local unit u=GetTriggerUnit() local unit uu local group g=CreateGroup() call GroupEnumUnitsInRange(g,GetUnitX(u),GetUnitY(u),500,null) loop set uu=FirstOfGroup(g) exitwhen uu==null if IsUnitEnemy(uu,GetOwningPlayer(u)) and GetUnitState(uu,UNIT_STATE_LIFE)>0 then call Trig_Otr_Act2(u,uu) endif call GroupRemoveUnit(g,uu) endloop call DestroyGroup(g) set u=null set g=null endfunction
//=========================================================================== function InitTrig_Otr takes nothing returns nothing local trigger tr=CreateTrigger() local integer i=0 loop call TriggerRegisterPlayerUnitEvent(tr,Player(i),EVENT_PLAYER_UNIT_SPELL_EFFECT,null) set i=i+1 exitwhen i==12 endloop call TriggerAddCondition(tr,Condition(function OtrCondition)) call TriggerAddAction(tr, function Trig_Otr_Actions ) set tr=null endfunction
XYdist - это дистанция между точками, а PolarX и Y смещение соответственно просто я забыл CustomCode скопировать
Сообщение отредактировал rixt7956 - Суббота, 08 Января 2011, 14:52:20
local real x //нужная тебе X точка для проверки local real y //нужная тебе Y точка для проверки local item t = CreateItem('texp',x,y) local real x2 = GetItemX(t) local real y2 = GetItemY(t) call SetItemVisible(t,false ) if y == y2 and x == x2 then //точка прохадима else //точка не проходима endif call RemoveItem(t) set t = null