// List of all terrain type codes you can use:
// [url]http://www.3ice.hu/blog/3ice-sliding...c/#comment-109[/url]
function SetTerrainTypes takes nothing returns nothing
//Change 'Nice' to the terrain type code you want to slide heroes:
set udg_Slide = 'Nice'
//Change 'Nsnw' to the terrain type code you want to kill heroes:
set udg_TerrainKill = 'Nsnw'
endfunction
function InitTrig_Setup2 takes nothing returns nothing
set gg_trg_Setup2=CreateTrigger()
call TriggerAddAction(gg_trg_Setup2,function SetTerrainTypes)
endfunction
// List of all terrain type codes you can use:
// [url]http://www.3ice.hu/blog/3ice-sliding...c/#comment-109[/url]
function SetTerrainTypes takes nothing returns nothing
//Change 'Nice' to the terrain type code you want to slide heroes:
set udg_Slide = 'Nice'
//Change 'Nsnw' to the terrain type code you want to kill heroes:
set udg_TerrainKill = 'Nsnw'
endfunction
function InitTrig_Setup2 takes nothing returns nothing
set gg_trg_Setup2=CreateTrigger()
call TriggerAddAction(gg_trg_Setup2,function SetTerrainTypes)
endfunction
function S takes nothing returns nothing
local unit u=GetEnumUnit()
local real x=GetUnitX(u)
local real y=GetUnitY(u)
local integer t=GetTerrainType(x,y)
if(t==udg_Slide)then
call SetUnitX(u,x+udg_Speed*Cos(0.017453278*GetUnitFacing(u)))
call SetUnitY(u,y+udg_Speed*Sin(0.017453278*GetUnitFacing(u)))
//Delete these two lines to remove terrainkill (Between START2 and END2)
//START2
elseif(t==udg_TerrainKill)and(GetUnitState(u,UNIT_STATE_LIFE)>0)then
call KillUnit(u)
//END2
endif
set u=null
endfunction
function Slide takes nothing returns nothing
call ForGroup(udg_H,function S)
endfunction
function InitTrig_Slide takes nothing returns nothing
set gg_trg_Slide=CreateTrigger()
call TriggerRegisterTimerEvent(gg_trg_Slide,0.01,true)
call TriggerAddAction(gg_trg_Slide,function Slide)
endfunction
function Turn takes nothing returns nothing
local unit u=GetTriggerUnit()
local real x=GetUnitX(u)
local real y=GetUnitY(u)
local location p=GetUnitLoc(GetOrderTargetUnit())
if(GetTerrainType(x,y)==udg_Slide)and(IsUnitInGroup(u,udg_H))then
call SetUnitFacing(u,57.295828*Atan2(GetLocationY(p)-y,GetLocationX(p)-x))
endif
call RemoveLocation(p)
set p=null
set u=null
endfunction
function Steer takes nothing returns nothing
local unit u=GetTriggerUnit()
local real x=GetUnitX(u)
local real y=GetUnitY(u)
local real a=GetOrderPointX()
local real b=GetOrderPointY()
if(GetTerrainType(x,y)==udg_Slide)and(IsUnitInGroup(u,udg_H))then
call SetUnitFacing(u,57.295828*Atan2(b-y,a-x))
endif
set u=null
endfunction
function ReturnTrue takes nothing returns boolean
return true
endfunction
function InitTrig_Steer takes nothing returns nothing
local integer i=0
local filterfunc nullboolexpr=Filter(function ReturnTrue)
local trigger gg_trg_Turn=CreateTrigger()
set gg_trg_Steer=CreateTrigger()
call TriggerAddAction(gg_trg_Turn,function Turn)
call TriggerAddAction(gg_trg_Steer,function Steer)
loop
exitwhen i>12
call TriggerRegisterPlayerUnitEvent(gg_trg_Turn,Player(i),EVENT_PLAYER_UNIT_ISSUED_TARGET_ORDER,nullboole xpr)
call TriggerRegisterPlayerUnitEvent(gg_trg_Steer,Player(i),EVENT_PLAYER_UNIT_ISSUED_POINT_ORDER,nullboole xpr)
set i=i+1
endloop
endfunction