|
好吧那我就,总结一下我的经验吧
0,自定义全局变量哈希表如:HT
1,在地图初始化时,运行以下两段代码:
call FlushParentHashtable( udg_HT )
set udg_HT = InitHashtable()
2.在每次使用完以后记得清空:
call FlushChildHashtable(udg_HT,Key) //Key为项目号
用这个的话,会把udg_HT全部清空,后果你知道的:
↓↓↓↓↓
call FlushParentHashtable(udg_HT)
3.hashtable。无法传递点变量(貌似?),反正我是分成两个实数传的才有效
以下为我做的实例~~~
-
- function Trig_StarLight0J_Conditions takes nothing returns boolean
- if ( not ( GetSpellAbilityId() == 'AUcs' ) ) then
- return false
- endif
- return true
- endfunction
- function StarLight0J_MagicEffect takes nothing returns nothing
- local timer t = GetExpiredTimer()
- local integer Key
- local real x //GetLocationX(udg_BaswPoint)
- local real y //GetLocationY(udg_BaswPoint)
- local real r
- local real a
- local real i
- local unit u0
- local unit u
- local location p_1
- local location p_2
- set Key = GetHandleId( t )
- set u0 = LoadUnitHandle( udg_HT, Key, 1 )
- set x=LoadReal(udg_HT,Key,2)
- set y=LoadReal(udg_HT,Key,3)
- set a = LoadReal(udg_HT,Key,4)
- set i = LoadReal(udg_HT,Key,5)
- set p_1 = Location(x,y)
- set p_2 = PolarProjectionBJ(p_1, 256, (a+60-i*20))
- set r=AngleBetweenPoints(p_1, p_2)
- set u = CreateUnit(GetOwningPlayer(u0),'ewsp',x,y,r)
- call UnitApplyTimedLife( u, 'BHwe', 0.01 )
- call IssuePointOrderLoc( u, "carrionswarm", p_2 )
- set i = ( i + 1 )
- if i<7 then
- call SaveReal(udg_HT,Key,5,i)
- else
- call DestroyTimer(t)
- call FlushChildHashtable(udg_HT,Key)
- endif
- call RemoveLocation(p_1)
- set p_1=null
- call RemoveLocation(p_2)
- set p_2=null
- set t = null
- set u = null
- set u0=null
- return
- endfunction
- function Trig_StarLight0J_Actions takes nothing returns nothing
- local timer t = CreateTimer()
- local location p_1
- local location p_2
- local real a
- local real i = 0
- local integer Key = GetHandleId( t )
- local real x
- local real y
- set p_1 = GetUnitLoc(GetTriggerUnit())
- set p_2 = GetSpellTargetLoc()
- set a = AngleBetweenPoints(p_1, p_2)
- set x=GetLocationX(p_1)
- set y=GetLocationY(p_1)
- call SaveUnitHandle( udg_HT, Key, 1, GetTriggerUnit() )
- call SaveReal(udg_HT,Key,2,x)
- call SaveReal(udg_HT,Key,3,y)
- call SaveReal(udg_HT,Key,4,a)
- call SaveReal(udg_HT,Key,5,i)
- call TimerStart(t,0.03,true,function StarLight0J_MagicEffect)
- call RemoveLocation(p_1)
- set p_1=null
- call RemoveLocation(p_2)
- set p_2=null
- set t = null
- endfunction
- //==== Init Trigger StarLight0J ====
- function InitTrig_StarLight0J takes nothing returns nothing
- set gg_trg_StarLight0J = CreateTrigger( )
- call TriggerRegisterAnyUnitEventBJ( gg_trg_StarLight0J, EVENT_PLAYER_UNIT_SPELL_EFFECT )
- call TriggerAddCondition( gg_trg_StarLight0J, Condition( function Trig_StarLight0J_Conditions ) )
- call TriggerAddAction( gg_trg_StarLight0J, function Trig_StarLight0J_Actions )
- endfunction
复制代码 |
|