|
本帖最后由 LichKel 于 2016-1-17 11:48 编辑
RT,原理是用马甲单位模拟投射物
以下是代码
按顺序复制粘贴到地图的自定义文本即可
- globals
- hashtable H = InitHashtable()
- unit Mis_tt = null
- unit Mis_mis = null
- real Mis_aoed = 0.00
- endglobals
- function missile_groupcondition takes nothing returns boolean
- return (((IsUnitAliveBJ(GetFilterUnit()) == true) and ((IsUnitEnemy(GetFilterUnit(), GetOwningPlayer(Mis_mis)) == true) and (GetFilterUnit() != Mis_tt))))
- endfunction
- function missile_aoedamage takes nothing returns nothing
- call UnitDamageTargetBJ(Mis_mis,GetEnumUnit(),Mis_aoed,ATTACK_TYPE_HERO,DAMAGE_TYPE_MAGIC)
- endfunction
- function MissileMove takes nothing returns nothing
- local integer parentKey = GetHandleId(GetExpiredTimer())
- local unit mis = LoadUnitHandle(H,parentKey,1)
- local unit tt = LoadUnitHandle(H,parentKey,2)
- local boolean aoe = LoadBoolean(H,parentKey,3)
- local real dmg = LoadReal(H,parentKey,4)
- local real spd = LoadReal(H,parentKey,5)
- local real aoer = LoadReal(H,parentKey,6)
- local real aoed = LoadReal(H,parentKey,7)
- local string Eff = LoadStr(H,parentKey,8)
- local location p1 = GetUnitLoc(mis)
- local location p2 = GetUnitLoc(tt)
- local location p3 = null
- local group aoeg = CreateGroup()
- local real dis = DistanceBetweenPoints(p1,p2)
- if (IsUnitDeadBJ(tt) == true) then//判断目标是否死亡,死亡则立刻杀死马甲
- call KillUnit(mis)
- call RemoveLocation(p1)
- call RemoveLocation(p2)
- set mis = null
- set tt = null
- set p1 = null
- set p2 = null
- call FlushChildHashtable(H,parentKey)
- call DestroyTimer(GetExpiredTimer())
- elseif dis<=26.0 then//命中判定
- call DestroyEffect(AddSpecialEffectLoc(Eff,p2))
- call UnitDamageTargetBJ(mis,tt,dmg,ATTACK_TYPE_HERO,DAMAGE_TYPE_MAGIC)
- if aoe == true then
- set Mis_aoed = dmg*aoed
- set Mis_mis = mis
- set Mis_tt = tt
- set aoeg = GetUnitsInRangeOfLocMatching(aoer,p2,Condition(function missile_groupcondition))
- call ForGroup(aoeg,function missile_aoedamage)
- endif
- call RemoveLocation(p1)
- call RemoveLocation(p2)
- call KillUnit(mis)
- set mis = null
- set tt = null
- set p1 = null
- set p2 = null
- call FlushChildHashtable(H,parentKey)
- call DestroyTimer(GetExpiredTimer())
- else//移动投射物
- set p3 = PolarProjectionBJ(p1,spd/100.0,AngleBetweenPoints(p1,p2))
- call SetUnitPositionLoc(mis,p3)
- call SetUnitFacing(mis,AngleBetweenPoints(p1,p2))
- call RemoveLocation(p1)
- call RemoveLocation(p2)
- call RemoveLocation(p3)
- set p3 = null
- set p2 = null
- set p1 = null
- endif
- set mis = null
- set tt = null//排泄单位
- call DestroyGroup(aoeg)
- set aoeg = null
- endfunction
- function MissileStart takes unit Missile,unit Target,boolean aoe,real damage,real speed,real aoer,real aoed,string eff returns nothing
- local timer tm = CreateTimer()
- local integer parentKey = GetHandleId(tm)
- call SaveUnitHandle(H,parentKey,1,Missile)
- call SaveUnitHandle(H,parentKey,2,Target)
- call SaveBoolean(H,parentKey,3,aoe)
- call SaveReal(H,parentKey,4,damage)
- call SaveReal(H,parentKey,5,speed)
- call SaveReal(H,parentKey,6,aoer)
- call SaveReal(H,parentKey,7,aoed)
- call SaveStr(H,parentKey,8,eff)
- call TimerStart(tm,0.01,true,function MissileMove)
- set tm = null
- set Missile = null
- set Target = null
- endfunction
复制代码
使用时,在触发器的动作栏用自定义代码写:
call MissileStart($unit$,$unit$,$boolean$,$real$,$real$,$real$,$real$,$string$)
注意:将$***$依次替换为:
投射物马甲[单位],投射物马甲的目标[单位],是否AOE[布尔值],命中后伤害[实数],投射物速度[实数],AOE半径[实数],AOE伤害(其实是主伤害的倍数)[实数],命中后产出特效的路径[字符串]
注意:变量编辑器中的全局变量引用时需加入udg_前缀。是否AOE填写false则AOE半径和伤害无效
以上
|
|