|
发表于 2007-11-22 16:44:17
|
显示全部楼层
算鸟~ 给你个DD参考下吧~~
Lich的冻结之矢技能,攻击时一定几率冻结目标并造成伤害
[codes=jass]
function Lich_FrostAttack_End takes nothing returns nothing
local integer tm = h2i(GetExpiredTimer())
local integer trg = GetStoredInteger(udg_GC,I2S(tm),"Trigger")
local integer tc = GetStoredInteger(udg_GC,I2S(tm),"TriggerCondition")
local integer u = GetStoredInteger(udg_GC,I2S(tm),"Target")
call FlushStoredInteger(udg_GC,I2S(u),"Lich_FrostAttack_Timer")
call FlushStoredMission(udg_GC,I2S(tm))
call TriggerRemoveCondition(i2tg(trg),i2tc(tc))
call DestroyTrigger(i2tg(trg))
call DestroyTimer(i2tm(tm))
endfunction
function Lich_FrostAttack_Cond takes nothing returns nothing
local unit u = GetTriggerUnit()
if GetUnitAbilityLevel(u,'B00I') > 0 then
call UnitRemoveAbility(u,'B00I')
set udg_TempUnit = GetEventDamageSource()
call SetUnitFrost(u,0.25*(3+GetUnitAbilityLevel(udg_TempUnit,'A08L'))+0.3*GetWiz(udg_TempUnit)) //冻结并对目标造成伤害, 这里有几个是自定义函数
call UnitDamageTarget(udg_TempUnit,u,30+10*GetUnitAbilityLevel(udg_TempUnit,'A08L'),true,true,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_COLD,WEAPON_TYPE_WHOKNOWS)
endif
set u = null
endfunction
function Lich_FrostAttack_Start takes nothing returns nothing
local integer u = h2i(GetEventTargetUnit())
local integer tm = GetStoredInteger(udg_GC,I2S(u),"Lich_FrostAttack_Timer")
local trigger trg
if tm == 0 then
set tm = h2i(CreateTimer())
set trg = CreateTrigger()
call TriggerRegisterUnitEvent(trg,i2u(u),EVENT_UNIT_DAMAGED)
call StoreInteger(udg_GC,I2S(tm),"TriggerCondition",h2i(TriggerAddCondition(trg, Condition(function Lich_FrostAttack_Cond))))
call StoreInteger(udg_GC,I2S(tm),"Trigger",h2i(trg))
call StoreInteger(udg_GC,I2S(tm),"Target",u)
call StoreInteger(udg_GC,I2S(u),"Lich_FrostAttack_Timer",tm)
endif
call UnitAddAbility(GetTriggerUnit(),'A08N')
call TimerStart(i2tm(tm),9,false,function Lich_FrostAttack_End) //被攻击单位在9秒内不受到攻击则删除take damage触发相关,如果受到攻击则重置计时为9秒,这么做要比多次的添加/删除触发有效率的多
set trg = null
endfunction
function Lich_FrostAttack takes nothing returns nothing //一定几率攻击时发动效果
local integer i = GetHeroInt(GetTriggerUnit(),true)
if i >= GetRandomInt(1,500+2*i) then
call Lich_FrostAttack_Start()
else
call UnitRemoveAbility(GetTriggerUnit(),'A08N') //A08N是辅助用致命一击技能,用来获取攻击时的buff的
endif
endfunction
function Lich_LearnSkill takes nothing returns nothing //第一次学习技能时注册触发
if GetLearnedSkillLevel()==1 and GetLearnedSkill() == 'A08L' then
call SetPlayerAbilityAvailable(GetOwningPlayer(GetTriggerUnit()),'A08N',false)
set udg_TempTrigger = CreateTrigger()
call TriggerRegisterUnitEvent(udg_TempTrigger,GetTriggerUnit(),EVENT_UNIT_TARGET_IN_RANGE)
call TriggerAddCondition(udg_TempTrigger, Condition(function Lich_FrostAttack))
endif
endfunction
function Skill_Lich takes nothing returns nothing //触发事件已在其它地方注册
local integer p = GetPlayerId(GetOwningPlayer(udg_TempUnit))
call TriggerAddCondition(trg_LearnSkill[p], Condition(function Lich_LearnSkill))
endfunction
[/codes] |
|