|
楼主 |
发表于 2011-7-21 18:37:39
|
显示全部楼层
呃...剛去找hashtable的教學....自己試試弄了個....不過不知道為什麼沒效果.....
globals- globals
-     integer   udg_sid        
-     hashtable CF_hash = InitHashtable()        
- endglobals
复制代码 這是每次施放技能後記錄在hashtable
- function Trig___________u_Actions takes nothing returns nothing
-     local integer pid = GetPlayerId(GetTriggerPlayer())  
-    //取得施放技能的player的playerid...啊..加上注解時才發現..是不是要改成GetPlayerId(GetOwningPlayer(GetTriggerUnit()))
-     call SaveAbilityHandle(CF_hash, 0, pid, GetSpellAbility())          //存在hashtable....childkey是playerid....
- endfunction
- function InitTrig___________u takes nothing returns nothing
-     set gg_trg___________u = CreateTrigger()
-     call TriggerRegisterAnyUnitEventBJ( gg_trg___________u, EVENT_PLAYER_UNIT_SPELL_EFFECT )
-     call TriggerAddAction(gg_trg___________u, function Trig___________u_Actions)
- endfunction
复制代码 這是spell steal...- function Trig___________004_Conditions takes nothing returns boolean
-     return (GetSpellAbilityId()=='A003')
- endfunction
- function Trig___________004_Actions takes nothing returns nothing
-     local integer pid = GetPlayerId(GetOwningPlayer(GetSpellTargetUnit()))        //取得目標的playerid
-     call UnitRemoveAbility(GetTriggerUnit(), udg_sid)                  //先移除上次偷的技能
-     set udg_sid = GetHandleId(LoadAbilityHandle(CF_hash, 0, pid))                  
-     call UnitAddAbility(GetTriggerUnit(), udg_sid)                       //再取得這次偷的技能
- endfunction
- function InitTrig___________004 takes nothing returns nothing
-     set gg_trg___________004 = CreateTrigger()
-     call TriggerRegisterAnyUnitEventBJ( gg_trg___________004, EVENT_PLAYER_UNIT_SPELL_EFFECT )
-     call TriggerAddCondition( gg_trg___________004, Condition( function Trig___________004_Conditions ) )
-     call TriggerAddAction( gg_trg___________004, function Trig___________004_Actions )
- endfunction
复制代码
以上......昨晚才開始找jass相關的教學看看.........所以....有什麼奇怪的錯誤請別見怪...
原來編輯在上面...我在回復,引用那邊看不到...以為沒開放編輯功能
呃...我把call SaveAbilityHandle(CF_hash, 0, pid, GetSpellAbility()) 改成 call SaveInteger(udg_hash, 0, pid, GetSpellAbilityId())
其他再跟著改....就成功了.....- -''''不過還是不懂上面哪裡出錯....是GetHandleId不能用來取得ability的id嗎?
|
|