//用途:移动单位.. 可以代替所有每0.02秒移动单位的触发
//多次调用函数不冲突(就是可以多人使用)
//必须做的是地图初始化的时候,创建游戏缓存
//在触发器里设置一个变量 GC , 类型为游戏缓存
//然后设置 GC = 最后创建的游戏缓存
//函数调用方法:
//call MoveUnit(单位,实数,整数,实数,"字符串")
//参数类型:说明
//单位:要移动的单位whichUnit
//实数:要移动的方向angle
//整数:移动速度speed
//实数:持续时间time
//字符串:特效
//实例:
// 事件
// 单位 - 任意单位 发动技能效果
// 条件
// (施放技能) 等于 月牙天冲
// 动作
// 设置 l[0] = ((触发单位) 的位置)
// 设置 l[1] = (技能施放点)
// 设置 r = (l[0] 到 l[1] 的角度)
// 设置 u = (新建 ((触发单位) 的所有者) 的 月牙 在 l[0] 面向角度:r 度)
// 设置 e = Abilities\Spells\Undead\FrostNova\FrostNovaTarget.mdl
// 单位 - 设置 1.00 秒 水元素 类型的生命周期对 u
// 自定义代码: call MoveUnit(udg_u,udg_r,1500,1,udg_e)
//地图自定义脚本:
//必须函数h2i 如果地图里有就不用复制了
function h2i takes handle h returns integer
return h
return 0
endfunction
//同上
function i2u takes integer i returns unit
return i
return null
endfunction
//同上
function i2l takes integer i returns location
return i
return null
endfunction
//循环移动
function MoveUnit_actions takes nothing returns nothing
local location array l
local timer t = GetExpiredTimer()
local unit ua = i2u(GetStoredInteger(udg_GC,"unit",I2S(h2i(t))))
set l[0] = GetUnitLoc(ua)
set l[1] = PolarProjectionBJ(l[0], I2R(GetStoredInteger(udg_GC,"speed",I2S(h2i(t)))), GetStoredReal(udg_GC,"angle",I2S(h2i(t))))
call SetUnitPositionLoc( ua, l[1] )
call AddSpecialEffectLocBJ( l[0], GetStoredString(udg_GC,"effect",I2S(h2i(t))) )
call DestroyEffect( GetLastCreatedEffectBJ() )
call RemoveLocation( l[0] )
call RemoveLocation( l[1] )
set l[0] = null
set l[1] = null
set t = null
set ua = null
endfunction
//主体
function MoveUnit takes unit whichUnit , real angle , integer speed , real time , string effects returns nothing
local timer t = CreateTimer()
local integer i = speed/50
call StoreInteger(udg_GC,"unit",I2S(h2i(t)),h2i(whichUnit))
call StoreInteger(udg_GC,"speed",I2S(h2i(t)),i)
call StoreReal(udg_GC,"angle",I2S(h2i(t)),angle)
call StoreString(udg_GC,"effect",I2S(h2i(t)),effects)
call TimerStart(t,0.02,true,function MoveUnit_actions)
call PolledWait( time )
call FlushStoredInteger(udg_GC,"unit",I2S(h2i(t)))
call FlushStoredString(udg_GC,"effect",I2S(h2i(t)))
call FlushStoredInteger(udg_GC,"speed",I2S(h2i(t)))
call FlushStoredReal(udg_GC,"angle",I2S(h2i(t)))
call PauseTimer(t)
call DestroyTimer(t)
set t = null
endfunction
//多次调用函数不冲突(就是可以多人使用)
//必须做的是地图初始化的时候,创建游戏缓存
//在触发器里设置一个变量 GC , 类型为游戏缓存
//然后设置 GC = 最后创建的游戏缓存
//函数调用方法:
//call MoveUnit(单位,实数,整数,实数,"字符串")
//参数类型:说明
//单位:要移动的单位whichUnit
//实数:要移动的方向angle
//整数:移动速度speed
//实数:持续时间time
//字符串:特效
//实例:
// 事件
// 单位 - 任意单位 发动技能效果
// 条件
// (施放技能) 等于 月牙天冲
// 动作
// 设置 l[0] = ((触发单位) 的位置)
// 设置 l[1] = (技能施放点)
// 设置 r = (l[0] 到 l[1] 的角度)
// 设置 u = (新建 ((触发单位) 的所有者) 的 月牙 在 l[0] 面向角度:r 度)
// 设置 e = Abilities\Spells\Undead\FrostNova\FrostNovaTarget.mdl
// 单位 - 设置 1.00 秒 水元素 类型的生命周期对 u
// 自定义代码: call MoveUnit(udg_u,udg_r,1500,1,udg_e)
//地图自定义脚本:
//必须函数h2i 如果地图里有就不用复制了
function h2i takes handle h returns integer
return h
return 0
endfunction
//同上
function i2u takes integer i returns unit
return i
return null
endfunction
//同上
function i2l takes integer i returns location
return i
return null
endfunction
//循环移动
function MoveUnit_actions takes nothing returns nothing
local location array l
local timer t = GetExpiredTimer()
local unit ua = i2u(GetStoredInteger(udg_GC,"unit",I2S(h2i(t))))
set l[0] = GetUnitLoc(ua)
set l[1] = PolarProjectionBJ(l[0], I2R(GetStoredInteger(udg_GC,"speed",I2S(h2i(t)))), GetStoredReal(udg_GC,"angle",I2S(h2i(t))))
call SetUnitPositionLoc( ua, l[1] )
call AddSpecialEffectLocBJ( l[0], GetStoredString(udg_GC,"effect",I2S(h2i(t))) )
call DestroyEffect( GetLastCreatedEffectBJ() )
call RemoveLocation( l[0] )
call RemoveLocation( l[1] )
set l[0] = null
set l[1] = null
set t = null
set ua = null
endfunction
//主体
function MoveUnit takes unit whichUnit , real angle , integer speed , real time , string effects returns nothing
local timer t = CreateTimer()
local integer i = speed/50
call StoreInteger(udg_GC,"unit",I2S(h2i(t)),h2i(whichUnit))
call StoreInteger(udg_GC,"speed",I2S(h2i(t)),i)
call StoreReal(udg_GC,"angle",I2S(h2i(t)),angle)
call StoreString(udg_GC,"effect",I2S(h2i(t)),effects)
call TimerStart(t,0.02,true,function MoveUnit_actions)
call PolledWait( time )
call FlushStoredInteger(udg_GC,"unit",I2S(h2i(t)))
call FlushStoredString(udg_GC,"effect",I2S(h2i(t)))
call FlushStoredInteger(udg_GC,"speed",I2S(h2i(t)))
call FlushStoredReal(udg_GC,"angle",I2S(h2i(t)))
call PauseTimer(t)
call DestroyTimer(t)
set t = null
endfunction










