|
楼主 |
发表于 2007-7-2 07:05:41
|
显示全部楼层
代码太长,我就发上使用方法吧。
=========================================================================================
[codes=jass]
function echo takes nothing returns nothing
local TimerData td
local UnitData ud
set td=TimerData.GetExpired()
if(td.GetUnit(0)==null) then
call td.Destroy()
return
endif
set ud=UnitData.GetData(td.GetUnit(0))
if ( R2I(GetUnitX(ud.data))==ud.GetInteger(0) and R2I(GetUnitY(ud.data))==ud.GetInteger(1) ) then
call UnitMessage(ud.data,"stop")
call td.Destroy()
call ud.Destroy()
return
endif
call ud.SetInteger(0,R2I(GetUnitX(ud.data)))
call ud.SetInteger(1,R2I(GetUnitY(ud.data)))
call UnitMessage(td.GetUnit(0),"|cffff0000X: |r"+I2S(ud.GetInteger(0))+"|cffff0000Y: |r"+I2S(ud.GetInteger(1)))
endfunction
function Trig_echo_unit_Actions takes nothing returns nothing
local unit u= GetTriggerUnit()
local UnitData ud= UnitData.GetData(u)
local TimerData td
//己经在运行中,反回
if(ud.GetBoolean(0)==true) then
call ud.SetBoolean(0,true)
// return
endif
call UnitMessage(u,"select")
set td=TimerData.Run(1.0,true,function echo)
call td.SetUnit(0,u)
call ud.SetBoolean(0,true)
endfunction
//===========================================================================
function InitTrig_echo_unit takes nothing returns nothing
set gg_trg_echo_unit = CreateTrigger( )
call TriggerRegisterPlayerSelectionEventBJ( gg_trg_echo_unit, Player(0), true )
call TriggerAddAction( gg_trg_echo_unit, function Trig_echo_unit_Actions )
endfunction
[/codes]
上面的代码就可以在玩家选择一个单位时,开始每一秒在这个单位头上显示一次坐标,
如果这个单位停止移动,那么,这个过程也停止,并显示:Stoped!
引用的函数:
[codes=jass]
function FadingTextTag takes string text, real x, real y returns nothing
local texttag t = CreateTextTag()
call SetTextTagText(t, text, 0.02)
call SetTextTagPos(t, x, y, 0.00)
call SetTextTagVelocity(t, 0, 0.03)
call SetTextTagVisibility(t, true)
call SetTextTagFadepoint(t, 2)
call SetTextTagLifespan(t, 3)
call SetTextTagPermanent(t, false)
set t = null
endfunction
function UnitMessage takes unit u,string text returns nothing
local integer length=StringLength(text)
call FadingTextTag(text,GetUnitX(u)-length*2,GetUnitY(u)+100)
endfunction
[/codes] |
|