闪避脚本,20% 闪避所有伤害,50% 免疫致命伤害,15% 暴击,敌我距离大于 400 伤害加成 1.5 倍
首先制作一个物品 id 为penr
,作为 20% 闪避所有伤害,50% 免疫致命伤害的承载物
制作一个物品 id 为rst1
,作为 15% 暴击的承载物
制作一个物品 id 为hval
,作为敌我距离大于 400 伤害加成 1.5 倍的承载物
初始化一个触发
globals
constant boolean LIBRARY_YDWEGetItemOfTypeFromUnitBJNull=true
item yd_NullTempItem
constant boolean LIBRARY_YDWETriggerEvent=true
trigger yd_DamageEventTrigger=null
trigger array YDWETriggerEvent__DamageEventQueue
integer YDWETriggerEvent__DamageEventNumber=0
item bj_lastMovedItemInItemSlot=null
trigger YDWETriggerEvent__MoveItemEventTrigger=null
trigger array YDWETriggerEvent__MoveItemEventQueue
integer YDWETriggerEvent__MoveItemEventNumber=0
constant boolean LIBRARY_YDWEUnitHasItemOfTypeBJNull=true
integer array udg_a
location array udg_d
real array udg_s
trigger gg_trg_b=null
endglobals
设置要执行的操作,这里我们设定 20% 闪避所有伤害,50% 免疫致命伤害
function Trig_bActions takes nothing returns nothing
call DisableTrigger(GetTriggeringTrigger())
set udg_d[0]=GetUnitLoc(GetTriggerUnit())
set udg_d[1]=GetUnitLoc(GetEventDamageSource())
set udg_s[0]=DistanceBetweenPoints(udg_d[0],udg_d[1])
call RemoveLocation(udg_d[0])
call RemoveLocation(udg_d[1])
if((YDWEUnitHasItemOfTypeBJNull(GetTriggerUnit(),'penr')==true))then
set udg_a[0]=GetRandomInt(1,100)
set udg_a[1]=0
if((udg_a[0]<=20)and(udg_a[1]==0))then
call SetUnitLifeBJ(GetTriggerUnit(),(GetUnitStateSwap(UNIT_STATE_LIFE,GetTriggerUnit())+GetEventDamage()))
set udg_a[1]=1
else
endif
if((udg_a[1]==0)and(GetEventDamage()>=GetUnitStateSwap(UNIT_STATE_LIFE,GetTriggerUnit())))then
set udg_a[0]=GetRandomInt(1,100)
if((udg_a[0]<=50))then
call SetUnitLifeBJ(GetTriggerUnit(),(GetUnitStateSwap(UNIT_STATE_LIFE,GetTriggerUnit())+GetEventDamage()))
set udg_a[1]=1
else
endif
else
endif
else
endif
if((YDWEUnitHasItemOfTypeBJNull(GetEventDamageSource(),'rst1')==true))then
set udg_a[0]=GetRandomInt(1,100)
if((udg_a[0]<=15))then
call UnitDamageTargetBJ(GetEventDamageSource(),GetTriggerUnit(),GetEventDamage(),ATTACK_TYPE_NORMAL,DAMAGE_TYPE_NORMAL)
else
endif
else
endif
if((YDWEUnitHasItemOfTypeBJNull(GetEventDamageSource(),'hval')==true)and(udg_s[0]>=400.00))then
call UnitDamageTargetBJ(GetEventDamageSource(),GetTriggerUnit(),(GetEventDamage()*1.50),ATTACK_TYPE_NORMAL,DAMAGE_TYPE_NORMAL)
else
endif
call EnableTrigger(GetTriggeringTrigger())
endfunction
根据难度设定倍数
function Trig_bActions takes nothing returns nothing
call DisableTrigger(GetTriggeringTrigger())
set udg_d[0]=GetUnitLoc(GetTriggerUnit())
set udg_d[1]=GetUnitLoc(GetEventDamageSource())
set udg_s[0]=DistanceBetweenPoints(udg_d[0],udg_d[1])
call RemoveLocation(udg_d[0])
call RemoveLocation(udg_d[1])
if((YDWEUnitHasItemOfTypeBJNull(GetTriggerUnit(),'penr')==true))then
set udg_a[0]=GetRandomInt(1,100)
set udg_a[1]=0
if ((GetClickedButtonBJ()==udg_selevt[0])) then
if((udg_a[0]<=10)and(udg_a[1]==0))then
call SetUnitLifeBJ(GetTriggerUnit(),(GetUnitStateSwap(UNIT_STATE_LIFE,GetTriggerUnit())+GetEventDamage()))
set udg_a[1]=1
else
endif
if((udg_a[1]==0)and(GetEventDamage()>=GetUnitStateSwap(UNIT_STATE_LIFE,GetTriggerUnit())))then
set udg_a[0]=GetRandomInt(1,100)
if((udg_a[0]<=10))then
call SetUnitLifeBJ(GetTriggerUnit(),(GetUnitStateSwap(UNIT_STATE_LIFE,GetTriggerUnit())+GetEventDamage()))
set udg_a[1]=1
else
endif
else
endif
else
if ((GetClickedButtonBJ()==udg_selevt[1])) then
if((udg_a[0]<=10)and(udg_a[1]==0))then
call SetUnitLifeBJ(GetTriggerUnit(),(GetUnitStateSwap(UNIT_STATE_LIFE,GetTriggerUnit())+GetEventDamage()))
set udg_a[1]=1
else
endif
if((udg_a[1]==0)and(GetEventDamage()>=GetUnitStateSwap(UNIT_STATE_LIFE,GetTriggerUnit())))then
set udg_a[0]=GetRandomInt(1,100)
if((udg_a[0]<=10))then
call SetUnitLifeBJ(GetTriggerUnit(),(GetUnitStateSwap(UNIT_STATE_LIFE,GetTriggerUnit())+GetEventDamage()))
set udg_a[1]=1
else
endif
else
endif
else
if ((GetClickedButtonBJ()==udg_selevt[2])) then
if((udg_a[0]<=20)and(udg_a[1]==0))then
call SetUnitLifeBJ(GetTriggerUnit(),(GetUnitStateSwap(UNIT_STATE_LIFE,GetTriggerUnit())+GetEventDamage()))
set udg_a[1]=1
else
endif
if((udg_a[1]==0)and(GetEventDamage()>=GetUnitStateSwap(UNIT_STATE_LIFE,GetTriggerUnit())))then
set udg_a[0]=GetRandomInt(1,100)
if((udg_a[0]<=20))then
call SetUnitLifeBJ(GetTriggerUnit(),(GetUnitStateSwap(UNIT_STATE_LIFE,GetTriggerUnit())+GetEventDamage()))
set udg_a[1]=1
else
endif
else
endif
else
if ((GetClickedButtonBJ()==udg_selevt[3])) then
if((udg_a[0]<=30)and(udg_a[1]==0))then
call SetUnitLifeBJ(GetTriggerUnit(),(GetUnitStateSwap(UNIT_STATE_LIFE,GetTriggerUnit())+GetEventDamage()))
set udg_a[1]=1
else
endif
if((udg_a[1]==0)and(GetEventDamage()>=GetUnitStateSwap(UNIT_STATE_LIFE,GetTriggerUnit())))then
set udg_a[0]=GetRandomInt(1,100)
if((udg_a[0]<=30))then
call SetUnitLifeBJ(GetTriggerUnit(),(GetUnitStateSwap(UNIT_STATE_LIFE,GetTriggerUnit())+GetEventDamage()))
set udg_a[1]=1
else
endif
else
endif
else
if ((GetClickedButtonBJ()==udg_selevt[4])) then
if((udg_a[0]<=40)and(udg_a[1]==0))then
call SetUnitLifeBJ(GetTriggerUnit(),(GetUnitStateSwap(UNIT_STATE_LIFE,GetTriggerUnit())+GetEventDamage()))
set udg_a[1]=1
else
endif
if((udg_a[1]==0)and(GetEventDamage()>=GetUnitStateSwap(UNIT_STATE_LIFE,GetTriggerUnit())))then
set udg_a[0]=GetRandomInt(1,100)
if((udg_a[0]<=40))then
call SetUnitLifeBJ(GetTriggerUnit(),(GetUnitStateSwap(UNIT_STATE_LIFE,GetTriggerUnit())+GetEventDamage()))
set udg_a[1]=1
else
endif
else
endif
else
if ((GetClickedButtonBJ()==udg_selevt[5])) then
if((udg_a[0]<=50)and(udg_a[1]==0))then
call SetUnitLifeBJ(GetTriggerUnit(),(GetUnitStateSwap(UNIT_STATE_LIFE,GetTriggerUnit())+GetEventDamage()))
set udg_a[1]=1
else
endif
if((udg_a[1]==0)and(GetEventDamage()>=GetUnitStateSwap(UNIT_STATE_LIFE,GetTriggerUnit())))then
set udg_a[0]=GetRandomInt(1,100)
if((udg_a[0]<=50))then
call SetUnitLifeBJ(GetTriggerUnit(),(GetUnitStateSwap(UNIT_STATE_LIFE,GetTriggerUnit())+GetEventDamage()))
set udg_a[1]=1
else
endif
else
endif
else
if ((GetClickedButtonBJ()==udg_selevt[6])) then
if((udg_a[0]<=60)and(udg_a[1]==0))then
call SetUnitLifeBJ(GetTriggerUnit(),(GetUnitStateSwap(UNIT_STATE_LIFE,GetTriggerUnit())+GetEventDamage()))
set udg_a[1]=1
else
endif
if((udg_a[1]==0)and(GetEventDamage()>=GetUnitStateSwap(UNIT_STATE_LIFE,GetTriggerUnit())))then
set udg_a[0]=GetRandomInt(1,100)
if((udg_a[0]<=60))then
call SetUnitLifeBJ(GetTriggerUnit(),(GetUnitStateSwap(UNIT_STATE_LIFE,GetTriggerUnit())+GetEventDamage()))
set udg_a[1]=1
else
endif
else
endif
endif
endif
endif
endif
endif
endif
endif
else
endif
if((YDWEUnitHasItemOfTypeBJNull(GetEventDamageSource(),'hval')==true)and(udg_s[0]>=400.00))then
if ((GetClickedButtonBJ()==udg_selevt[0])) then
call UnitDamageTargetBJ(GetEventDamageSource(),GetTriggerUnit(),(GetEventDamage()*1.5),ATTACK_TYPE_NORMAL,DAMAGE_TYPE_NORMAL)
else
if ((GetClickedButtonBJ()==udg_selevt[1])) then
call UnitDamageTargetBJ(GetEventDamageSource(),GetTriggerUnit(),(GetEventDamage()*2),ATTACK_TYPE_NORMAL,DAMAGE_TYPE_NORMAL)
else
if ((GetClickedButtonBJ()==udg_selevt[2])) then
call UnitDamageTargetBJ(GetEventDamageSource(),GetTriggerUnit(),(GetEventDamage()*3),ATTACK_TYPE_NORMAL,DAMAGE_TYPE_NORMAL)
else
if ((GetClickedButtonBJ()==udg_selevt[3])) then
call UnitDamageTargetBJ(GetEventDamageSource(),GetTriggerUnit(),(GetEventDamage()*4),ATTACK_TYPE_NORMAL,DAMAGE_TYPE_NORMAL)
else
if ((GetClickedButtonBJ()==udg_selevt[4])) then
call UnitDamageTargetBJ(GetEventDamageSource(),GetTriggerUnit(),(GetEventDamage()*7),ATTACK_TYPE_NORMAL,DAMAGE_TYPE_NORMAL)
else
if ((GetClickedButtonBJ()==udg_selevt[5])) then
call UnitDamageTargetBJ(GetEventDamageSource(),GetTriggerUnit(),(GetEventDamage()*13),ATTACK_TYPE_NORMAL,DAMAGE_TYPE_NORMAL)
else
if ((GetClickedButtonBJ()==udg_selevt[6])) then
call UnitDamageTargetBJ(GetEventDamageSource(),GetTriggerUnit(),(GetEventDamage()*25),ATTACK_TYPE_NORMAL,DAMAGE_TYPE_NORMAL)
endif
endif
endif
endif
endif
endif
endif
else
endif
call EnableTrigger(GetTriggeringTrigger())
endfunction
初始化触发器
function InitTrig_b takes nothing returns nothing
set gg_trg_b=CreateTrigger()
call YDWESyStemAnyUnitDamagedRegistTrigger(gg_trg_b)
call TriggerAddAction(gg_trg_b,function Trig_bActions)
endfunction
初始化触发器放入系统个性化触发器系统中
function InitCustomTriggers takes nothing returns nothing
call InitTrig_b()
endfunction
个性化触发器系统放入 main 函数中
function main takes nothing returns nothing
call InitCustomTriggers()
endfunction