|
发表于 2008-2-8 13:13:15
|
显示全部楼层
很抱歉,我只能用动态事件来作出这样的东西,不过只要你细读代码
还是可以理解的
[jass]
//===========================================================================
// Trigger: lengshang
//===========================================================================
//这个写到上面
function Trig_lengshang2_Actions takes nothing returns nothing
call DestroyTrigger(GetTriggeringTrigger())
if udg_LengshangNumber==1 and GetEventDamageSource()==udg_Lengshang_Caster and UnitHasBuffBJ(udg_Lengshang_Target,'B01U')then
//条件合并到这里
set udg_LengshangNumber = 1
if GetRandomInt(0,100) < 3 + ( GetUnitAbilityLevelSwapped('A0E9', udg_Lengshang_Caster) * 11 ) then
//这样更效率
call UnitDamageTarget( udg_Lengshang_Caster, udg_Lengshang_Target, GetEventDamage(), true, true, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_UNIVERSAL, WEAPON_TYPE_WHOKNOWS )
call AddSpecialEffectTargetUnitBJ( "head", udg_Lengshang_Target, "Abilities\\\\Spells\\\\Other\\\\CrushingWave\\\\CrushingWaveDamage.mdl" )
call DestroyEffect( GetLastCreatedEffectBJ() )
call DisableTrigger( GetTriggeringTrigger() )
else
endif
endif
endfunction
function Trig_lengshang_Conditions takes nothing returns boolean
return GetSpellAbilityId() == 'A02F'
endfunction
function Trig_lengshang_Actions takes nothing returns nothing
local trigger lengshang2=CreateTrigger()
set udg_LengshangNumber = 0
set udg_Lengshang_Caster = GetSpellAbilityUnit()
set udg_Lengshang_Target = GetSpellTargetUnit()
call TriggerAddAction(lengshang2,function Trig_lengshang2_Actions)
call TriggerRegisterUnitEvent( lengshang2, udg_Lengshang_Target, EVENT_UNIT_DAMAGED )
//这一行就不必了
//call EnableTrigger( gg_trg_lengshang2 )
endfunction
//===========================================================================
function InitTrig_lengshang takes nothing returns nothing
set gg_trg_lengshang = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_lengshang, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_lengshang, Condition( function Trig_lengshang_Conditions ) )
call TriggerAddAction( gg_trg_lengshang, function Trig_lengshang_Actions )
endfunction
//===========================================================================
// Trigger: lengshang2
//===========================================================================
//===========================================================================
function InitTrig_lengshang2 takes nothing returns nothing
//这个是必需要的,但什么都不用写 ,除非你删掉lengshang2这个触发器
endfunction
[/jass]
上面在有泄露问题,如果不添加全局变量,或者用缓存,是解决不了的。
为了解决泄露问题,还要创建一个触发动作的变量Lengshang_Action.不过好象用老狼的UI才可以。
修改后在代码是:
[jass]
//===========================================================================
// Trigger: lengshang
//===========================================================================
//这个写到上面
function Trig_lengshang2_Actions takes nothing returns nothing
call TriggerRemoveAction(GetTriggeringTrigger(),udg_Lengshang_Action)
call DestroyTrigger(GetTriggeringTrigger())
if udg_LengshangNumber==1 and GetEventDamageSource()==udg_Lengshang_Caster and UnitHasBuffBJ(udg_Lengshang_Target,'B01U')then
//条件合并到这里
set udg_LengshangNumber = 1
if GetRandomInt(0,100) < 3 + ( GetUnitAbilityLevelSwapped('A0E9', udg_Lengshang_Caster) * 11 ) then
//这样更效率
call UnitDamageTarget( udg_Lengshang_Caster, udg_Lengshang_Target, GetEventDamage(), true, true, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_UNIVERSAL, WEAPON_TYPE_WHOKNOWS )
call AddSpecialEffectTargetUnitBJ( "head", udg_Lengshang_Target, "Abilities\\\\Spells\\\\Other\\\\CrushingWave\\\\CrushingWaveDamage.mdl" )
call DestroyEffect( GetLastCreatedEffectBJ() )
call DisableTrigger( GetTriggeringTrigger() )
else
endif
endif
endfunction
function Trig_lengshang_Conditions takes nothing returns boolean
return GetSpellAbilityId() == 'A02F'
endfunction
function Trig_lengshang_Actions takes nothing returns nothing
local trigger lengshang2=CreateTrigger()
set udg_LengshangNumber = 0
set udg_Lengshang_Caster = GetSpellAbilityUnit()
set udg_Lengshang_Target = GetSpellTargetUnit()
set udg_Lengshang_Action = TriggerAddAction(lengshang2,function Trig_lengshang2_Actions)
call TriggerRegisterUnitEvent( lengshang2, udg_Lengshang_Target, EVENT_UNIT_DAMAGED )
//这一行就不必了
//call EnableTrigger( gg_trg_lengshang2 )
endfunction
//===========================================================================
function InitTrig_lengshang takes nothing returns nothing
set gg_trg_lengshang = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_lengshang, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_lengshang, Condition( function Trig_lengshang_Conditions ) )
call TriggerAddAction( gg_trg_lengshang, function Trig_lengshang_Actions )
endfunction
//===========================================================================
// Trigger: lengshang2
//===========================================================================
//===========================================================================
function InitTrig_lengshang2 takes nothing returns nothing
//这个是必需要的,但什么都不用写 ,除非你删掉lengshang2这个触发器
endfunction
[/jass]
----发错分了。。。。发成威望 |
|