找回密码
 点一下
查看: 1413|回复: 1

关于hashtable。自己解决了~~~

[复制链接]
发表于 2010-5-22 10:28:52 | 显示全部楼层 |阅读模式
好吧那我就,总结一下我的经验吧

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。无法传递点变量(貌似?),反正我是分成两个实数传的才有效

以下为我做的实例~~~
  1. function Trig_StarLight0J_Conditions takes nothing returns boolean
  2.     if ( not ( GetSpellAbilityId() == 'AUcs' ) ) then
  3.         return false
  4.     endif
  5.     return true
  6. endfunction
  7. function StarLight0J_MagicEffect takes nothing returns nothing
  8.      local timer t = GetExpiredTimer()
  9.      local integer Key
  10.      local real x       //GetLocationX(udg_BaswPoint)
  11.      local real y       //GetLocationY(udg_BaswPoint)
  12.      local real r
  13.      local real a
  14.      local real i
  15.      local unit u0
  16.      local unit u
  17.      local location p_1
  18.      local location p_2
  19.      set Key = GetHandleId( t )
  20.      set u0  = LoadUnitHandle( udg_HT, Key, 1 )
  21.      set x=LoadReal(udg_HT,Key,2)
  22.      set y=LoadReal(udg_HT,Key,3)
  23.      set a  = LoadReal(udg_HT,Key,4)
  24.      set i = LoadReal(udg_HT,Key,5)
  25.      set p_1 = Location(x,y)
  26.      set p_2 = PolarProjectionBJ(p_1, 256, (a+60-i*20))
  27.      set r=AngleBetweenPoints(p_1, p_2)
  28.      set u = CreateUnit(GetOwningPlayer(u0),'ewsp',x,y,r)
  29.      call UnitApplyTimedLife( u, 'BHwe', 0.01 )
  30.      call IssuePointOrderLoc( u, "carrionswarm", p_2 )
  31.      set i = ( i + 1 )
  32. if i<7 then
  33.      call SaveReal(udg_HT,Key,5,i)
  34. else
  35.    call DestroyTimer(t)
  36.    call FlushChildHashtable(udg_HT,Key)
  37. endif
  38.      call RemoveLocation(p_1)
  39.      set p_1=null
  40.      call RemoveLocation(p_2)
  41.      set p_2=null
  42.      set t = null
  43.      set u = null
  44.      set u0=null
  45.      return
  46. endfunction
  47. function Trig_StarLight0J_Actions takes nothing returns nothing
  48.      local timer t = CreateTimer()
  49.      local location p_1
  50.      local location p_2
  51.      local real a
  52.      local real i = 0
  53.      local integer Key = GetHandleId( t )
  54.      local real x
  55.      local real y
  56.      set p_1 = GetUnitLoc(GetTriggerUnit())
  57.      set p_2 = GetSpellTargetLoc()
  58.      set a = AngleBetweenPoints(p_1, p_2)
  59.      set x=GetLocationX(p_1)
  60.      set y=GetLocationY(p_1)
  61.      call SaveUnitHandle( udg_HT, Key, 1, GetTriggerUnit() )
  62.      call SaveReal(udg_HT,Key,2,x)
  63.      call SaveReal(udg_HT,Key,3,y)
  64.      call SaveReal(udg_HT,Key,4,a)
  65.      call SaveReal(udg_HT,Key,5,i)
  66.      call TimerStart(t,0.03,true,function StarLight0J_MagicEffect)
  67.      call RemoveLocation(p_1)
  68.      set p_1=null
  69.      call RemoveLocation(p_2)
  70.      set p_2=null
  71.      set t = null
  72. endfunction                        
  73. //==== Init Trigger StarLight0J ====
  74. function InitTrig_StarLight0J takes nothing returns nothing
  75.     set gg_trg_StarLight0J = CreateTrigger(  )
  76.     call TriggerRegisterAnyUnitEventBJ( gg_trg_StarLight0J, EVENT_PLAYER_UNIT_SPELL_EFFECT )
  77.     call TriggerAddCondition( gg_trg_StarLight0J, Condition( function Trig_StarLight0J_Conditions ) )
  78.     call TriggerAddAction( gg_trg_StarLight0J, function Trig_StarLight0J_Actions )
  79. endfunction
复制代码
 楼主| 发表于 2010-5-23 13:48:59 | 显示全部楼层
自己顶
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 点一下

本版积分规则

Archiver|移动端|小黑屋|地精研究院

GMT+8, 2024-12-26 09:41 , Processed in 0.088529 second(s), 18 queries .

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表