Advertisement
redefrec

Untitled

Sep 8th, 2018
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.10 KB | None | 0 0
  1. function U.CanDodgeIncomingProjectile(npcBot, delaySeconds, invulnerabilitySeconds)
  2.     local projectileSpeeds = {
  3.         ['vengefulspirit_magic_missile'] = 1250,
  4.         ['sniper_assassinate'] = 2500,
  5.         ['chaos_knight_chaos_bolt'] = 1000,
  6.         ['alchemist_unstable_concoction_throw'] = 900,
  7.         ['sven_storm_hammer'] = 1000,
  8.         ['skeleton_king_hellfire_blast'] = 1000
  9.     }
  10.     local incProj = npcBot:GetIncomingTrackingProjectiles()
  11.     for _,p in pairs(incProj)
  12.     do
  13.         local projectileSpeed = projectileSpeeds[p.ability:GetName()]
  14.         if not p.is_attack and projectileSpeed ~= nil then
  15.             local distance = GetUnitToLocationDistance(npcBot, p.location)
  16.             local hitTime = distance / projectileSpeed
  17.             if hitTime > delaySeconds and hitTime < delaySeconds + invulnerabilitySeconds then
  18.                 npcBot:ActionImmediate_Chat( "Dodging: " .. p.ability:GetName() , true );
  19.                 return true;
  20.             end
  21.         end
  22.     end
  23. end
  24.  
  25. -----
  26.  
  27.     local manta=IsItemAvailable("item_manta");
  28.     if manta~=nil and manta:IsFullyCastable()
  29.     then
  30.         if mutil.CanDodgeIncomingProjectile(bot, 0, 0.1)
  31.         then
  32.             bot:Action_UseAbility(manta);
  33.             return;
  34.         end
  35.     end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement