找回密码
 点一下
查看: 1733|回复: 1

【移植方便,可多人】投射物类技能的投射物模拟

[复制链接]
发表于 2016-1-17 09:34:52 | 显示全部楼层 |阅读模式
本帖最后由 LichKel 于 2016-1-17 11:48 编辑

RT,原理是用马甲单位模拟投射物
以下是代码
按顺序复制粘贴到地图的自定义文本即可
  1. globals
  2.     hashtable H = InitHashtable()
  3.     unit Mis_tt = null
  4.     unit Mis_mis = null
  5.     real Mis_aoed = 0.00
  6. endglobals


  7. function missile_groupcondition takes nothing returns boolean
  8.     return (((IsUnitAliveBJ(GetFilterUnit()) == true) and ((IsUnitEnemy(GetFilterUnit(), GetOwningPlayer(Mis_mis)) == true) and (GetFilterUnit() != Mis_tt))))
  9. endfunction

  10. function missile_aoedamage takes nothing returns nothing
  11.     call UnitDamageTargetBJ(Mis_mis,GetEnumUnit(),Mis_aoed,ATTACK_TYPE_HERO,DAMAGE_TYPE_MAGIC)
  12. endfunction

  13. function MissileMove takes nothing returns nothing
  14.     local integer parentKey = GetHandleId(GetExpiredTimer())
  15.     local unit mis = LoadUnitHandle(H,parentKey,1)
  16.     local unit tt = LoadUnitHandle(H,parentKey,2)
  17.     local boolean aoe = LoadBoolean(H,parentKey,3)
  18.     local real dmg = LoadReal(H,parentKey,4)
  19.     local real spd = LoadReal(H,parentKey,5)
  20.     local real aoer = LoadReal(H,parentKey,6)
  21.     local real aoed = LoadReal(H,parentKey,7)
  22.     local string Eff = LoadStr(H,parentKey,8)
  23.     local location p1 = GetUnitLoc(mis)
  24.     local location p2 = GetUnitLoc(tt)
  25.     local location p3 = null
  26.     local group aoeg = CreateGroup()
  27.     local real dis = DistanceBetweenPoints(p1,p2)
  28.     if (IsUnitDeadBJ(tt) == true) then//判断目标是否死亡,死亡则立刻杀死马甲
  29.         call KillUnit(mis)
  30.         call RemoveLocation(p1)
  31.         call RemoveLocation(p2)
  32.         set mis = null
  33.         set tt = null
  34.         set p1 = null
  35.         set p2 = null
  36.         call FlushChildHashtable(H,parentKey)
  37.         call DestroyTimer(GetExpiredTimer())
  38.     elseif dis<=26.0 then//命中判定
  39.         call DestroyEffect(AddSpecialEffectLoc(Eff,p2))
  40.         call UnitDamageTargetBJ(mis,tt,dmg,ATTACK_TYPE_HERO,DAMAGE_TYPE_MAGIC)
  41.         if aoe == true then
  42.             set Mis_aoed = dmg*aoed
  43.             set Mis_mis = mis
  44.             set Mis_tt = tt
  45.             set aoeg = GetUnitsInRangeOfLocMatching(aoer,p2,Condition(function missile_groupcondition))
  46.             call ForGroup(aoeg,function missile_aoedamage)
  47.         endif
  48.         call RemoveLocation(p1)
  49.         call RemoveLocation(p2)
  50.         call KillUnit(mis)
  51.         set mis = null
  52.         set tt = null
  53.         set p1 = null
  54.         set p2 = null
  55.         call FlushChildHashtable(H,parentKey)
  56.         call DestroyTimer(GetExpiredTimer())
  57.     else//移动投射物
  58.         set p3 = PolarProjectionBJ(p1,spd/100.0,AngleBetweenPoints(p1,p2))
  59.         call SetUnitPositionLoc(mis,p3)
  60.         call SetUnitFacing(mis,AngleBetweenPoints(p1,p2))
  61.         call RemoveLocation(p1)
  62.         call RemoveLocation(p2)
  63.         call RemoveLocation(p3)
  64.         set p3 = null
  65.         set p2 = null
  66.         set p1 = null
  67.     endif
  68.     set mis = null
  69.     set tt = null//排泄单位
  70.     call DestroyGroup(aoeg)
  71.     set aoeg = null
  72. endfunction

  73. function MissileStart takes unit Missile,unit Target,boolean aoe,real damage,real speed,real aoer,real aoed,string eff returns nothing
  74.     local timer tm = CreateTimer()
  75.     local integer parentKey = GetHandleId(tm)
  76.     call SaveUnitHandle(H,parentKey,1,Missile)
  77.     call SaveUnitHandle(H,parentKey,2,Target)
  78.     call SaveBoolean(H,parentKey,3,aoe)
  79.     call SaveReal(H,parentKey,4,damage)
  80.     call SaveReal(H,parentKey,5,speed)
  81.     call SaveReal(H,parentKey,6,aoer)
  82.     call SaveReal(H,parentKey,7,aoed)
  83.     call SaveStr(H,parentKey,8,eff)
  84.     call TimerStart(tm,0.01,true,function MissileMove)
  85.     set tm = null
  86.     set Missile = null
  87.     set Target = null
  88. endfunction
复制代码



使用时,在触发器的动作栏用自定义代码写:
call MissileStart($unit$,$unit$,$boolean$,$real$,$real$,$real$,$real$,$string$)
注意:将$***$依次替换为:
投射物马甲[单位],投射物马甲的目标[单位],是否AOE[布尔值],命中后伤害[实数],投射物速度[实数],AOE半径[实数],AOE伤害(其实是主伤害的倍数)[实数],命中后产出特效的路径[字符串]
注意:变量编辑器中的全局变量引用时需加入udg_前缀。是否AOE填写false则AOE半径和伤害无效
以上
发表于 2016-6-24 22:41:18 | 显示全部楼层
为何不放个演示
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 点一下

本版积分规则

Archiver|移动端|小黑屋|地精研究院

GMT+8, 2024-4-24 04:19 , Processed in 0.371969 second(s), 23 queries .

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表