|
楼主 |
发表于 2009-7-31 23:49:57
|
显示全部楼层
当然是用混合事件 用命令事件捕捉ID 技能事件捕捉技能
因为他才刚学JASS 我暂时还不想用retrn bug 1.24 中国啊... 有指望吗?
[codes=jass]
function Trig_DoubleSpell_Delete_Actions takes nothing returns nothing
call RemoveUnit(GetSpellAbilityUnit())
call DestroyTrigger(GetTriggeringTrigger())
endfunction
function Trigger_DoubleSpell_Conditions takes nothing returns boolean
if ( GetUnitAbilityLevel(GetTriggerUnit(),'Aloc') == 0 and IsUnitType(GetTriggerUnit(),UNIT_TYPE_HERO)) then
if ( GetTriggerEventId() == EVENT_PLAYER_UNIT_ISSUED_TARGET_ORDER ) then
call BJDebugMsg("指定目标命令事件 触发玩家ID:"+I2S(GetPlayerId(GetTriggerPlayer())))
set udg_AbilityOrder[GetPlayerId(GetTriggerPlayer())] = GetIssuedOrderId()
return false
elseif ( GetTriggerEventId() == EVENT_PLAYER_UNIT_ISSUED_TARGET_ORDER ) then
set udg_AbilityOrder[GetPlayerId(GetTriggerPlayer())] = GetIssuedOrderId()
return false
elseif ( GetTriggerEventId() == EVENT_PLAYER_UNIT_ISSUED_POINT_ORDER ) then
set udg_AbilityOrder[GetPlayerId(GetTriggerPlayer())] = GetIssuedOrderId()
return false
elseif ( GetTriggerEventId() == EVENT_PLAYER_UNIT_SPELL_EFFECT ) then
call BJDebugMsg("技能效果发动事件 触发玩家ID:"+I2S(GetPlayerId(GetTriggerPlayer())))
return true
endif
endif
return false
endfunction
function Trig_DoubleSpell_Actions takes nothing returns nothing
local unit spellUnit = GetSpellAbilityUnit()
local location spellLoc = null
local unit helper = CreateUnit(GetTriggerPlayer(),'ewsp',GetUnitX(spellUnit),GetUnitY(spellUnit),0)
local integer abilityId = GetSpellAbilityId()
local integer orderId = udg_AbilityOrder[GetPlayerId(GetTriggerPlayer())]
local boolean suceess = false
local trigger tempTrigger = null
call BJDebugMsg(I2S(orderId))
call UnitAddAbility(helper, abilityId)
call SetUnitAbilityLevel(helper,abilityId,GetUnitAbilityLevel(spellUnit,abilityId))
if ( GetSpellTargetUnit() != null ) then
set suceess = IssueTargetOrderById(helper,orderId,GetSpellTargetUnit())
else
set spellLoc = GetSpellTargetLoc()
if ( spellLoc != null) then
call BJDebugMsg("点目标技能")
set suceess = IssuePointOrderById(helper,orderId,GetLocationX(spellLoc),GetLocationY(spellLoc))
call RemoveLocation(spellLoc)
set spellLoc = null
else
call BJDebugMsg("无目标目标技能")
set suceess = IssueImmediateOrderById(helper, orderId )
endif
endif
if (suceess) then
set tempTrigger = CreateTrigger()
call TriggerRegisterUnitEvent(tempTrigger,helper,EVENT_UNIT_SPELL_FINISH)
call TriggerRegisterUnitEvent(tempTrigger,spellUnit,EVENT_UNIT_SPELL_ENDCAST)
call TriggerAddAction(tempTrigger,function Trig_DoubleSpell_Delete_Actions)
set tempTrigger = null
else
call DisplayTextToPlayer(GetTriggerPlayer(),0,0,"双重施法失败")
endif
set spellUnit = null
set helper = null
endfunction
//===========================================================================
function InitTrig_DoubleSpell takes nothing returns nothing
local integer index = 0
set gg_trg_DoubleSpell = CreateTrigger( )
loop
call TriggerRegisterPlayerUnitEvent(gg_trg_DoubleSpell, Player(index), EVENT_PLAYER_UNIT_SPELL_EFFECT, null)
call TriggerRegisterPlayerUnitEvent(gg_trg_DoubleSpell, Player(index), EVENT_PLAYER_UNIT_ISSUED_TARGET_ORDER, null)
call TriggerRegisterPlayerUnitEvent(gg_trg_DoubleSpell, Player(index), EVENT_PLAYER_UNIT_ISSUED_POINT_ORDER, null)
call TriggerRegisterPlayerUnitEvent(gg_trg_DoubleSpell, Player(index), EVENT_PLAYER_UNIT_ISSUED_ORDER, null)
set index = index + 1
exitwhen index == bj_MAX_PLAYER_SLOTS
endloop
call TriggerAddCondition( gg_trg_DoubleSpell, Condition(function Trigger_DoubleSpell_Conditions))
call TriggerAddAction( gg_trg_DoubleSpell, function Trig_DoubleSpell_Actions )
endfunction
[/codes] |
|