Advertisement
kay1mov

что тут не так???

Jun 22nd, 2025 (edited)
446
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 9.15 KB | None | 0 0
  1. script = {}
  2.  
  3. --Menu.Find("Heroes", "Hero List", "Invoker", "Auto Usage", "Sun Strike Settings", "Auto Use")
  4.  
  5. update_list_queue = {}
  6. menu = Menu.Find("Heroes", "Hero List", "Invoker", "Auto Usage", "Sun Strike Settings")
  7. if menu then
  8.     switch = menu:Switch('Sun Strike for low HP teleport', false)
  9.     switch:Icon("\u{f0e7}")
  10.     input = menu:Input("Max no-vision time", "25")
  11.     input:Icon("\u{f017}")
  12. end
  13.  
  14. function contains(tbl, val)
  15.     for i = 1, #tbl do
  16.         if tbl[i] == val then
  17.             return true
  18.         end
  19.     end
  20.     return false
  21. end
  22.  
  23. local handled_positions = {}
  24. local particle_name_map = {}
  25. local particle_data = {}
  26.  
  27. local actionQueue = {}
  28. local nextActionTime = 0
  29. local heroes = {}
  30.  
  31. function AddAction(delay, callback)
  32.     table.insert(actionQueue, {time = GameRules.GetGameTime() + delay, action = callback})
  33. end
  34.  
  35. local function add_divider()
  36.     return
  37. end
  38.  
  39.  
  40. function script.OnUpdate()
  41.     local now = GameRules.GetGameTime()
  42.  
  43.     if #actionQueue > 0 then
  44.         local first = actionQueue[1]
  45.         if now >= first.time then
  46.             table.remove(actionQueue, 1)
  47.             if first.action then
  48.                 first.action()
  49.             end
  50.         end
  51.     end
  52.  
  53.  
  54.     local allheroes = Heroes.GetAll()
  55.     local localhero = Heroes.GetLocal()
  56.    
  57.     for i, hero in pairs(allheroes) do
  58.         if hero and localhero and not Entity.IsSameTeam(hero, localhero) and not NPC.IsIllusion(hero) and Entity.IsAlive(hero) then
  59.             local idx = Entity.GetIndex(hero)
  60.             local isVisible = NPC.IsVisible(hero)
  61.             --print(string.format("Hero: %s | Index: %d | IsVisible: %s", Entity.GetUnitName(hero), idx, tostring(isVisible)))
  62.            
  63.             if isVisible then
  64.                 heroes[idx] = os.time()
  65.                 --print("Seen update: " .. heroes[idx])
  66.             end
  67.         end
  68.     end
  69.  
  70.  
  71.     EMPCalc()
  72.     icewallrender()
  73. --    autosunstrike()
  74.  
  75. end
  76.  
  77. function script.OnParticleCreate(prt)
  78. ---@diagnostic disable-next-line: undefined-field
  79.     prt = table.copy(prt)
  80.  
  81.     local particle_info = {}
  82.  
  83.     if prt.entity and Entity.IsNPC(prt.entity) then
  84.         local unit_name = NPC.GetUnitName(prt.entity)
  85.         local health = Entity.GetHealth(prt.entity)
  86.         particle_info.unit_name = unit_name
  87.         particle_info.health = health
  88.         particle_info.unit = prt.entity
  89.         prt["[m]entity_name"] = unit_name
  90.     end
  91.  
  92.     if prt.entityForModifiers and Entity.IsNPC(prt.entityForModifiers) then
  93.         local unit_name = NPC.GetUnitName(prt.entityForModifiers)
  94.         local health = Entity.GetHealth(prt.entityForModifiers)
  95.         -- ⚠️ Важно: сохраняем `entityForModifiers`, а не `prt.entity`, как было у тебя
  96.         particle_info.unit_name = unit_name
  97.         particle_info.health = health
  98.         particle_info.unit = prt.entityForModifiers
  99.         prt["[m]entityForModifiers_name"] = unit_name
  100.  
  101.     end
  102.  
  103.     if next(particle_info) ~= nil then
  104.         particle_data[prt.index] = particle_info
  105.     end
  106.  
  107.     particle_name_map[prt.index] = prt.name
  108.     add_divider()
  109. end
  110.  
  111.  
  112. function script.OnParticleUpdate(prt)
  113.     if prt.controlPoint == 2 and prt.position == Vector(1.0, 1.0, 1.0) then
  114.         return
  115.     end
  116.  
  117.     local _localhero = Heroes.GetLocal()
  118.     if not _localhero then return end  -- тоже важно
  119.    
  120.     prt = table.copy(prt)
  121.  
  122.     if particle_name_map[prt.index] then
  123.         prt["[m]name"] = particle_name_map[prt.index]
  124.     end
  125.  
  126.     if prt["[m]name"] == "teleport_start" then
  127.         local data = particle_data[prt.index]
  128.         if not data then
  129.             print("No entity data for this particle")
  130.             return
  131.         end
  132.  
  133.         if Entity.IsSameTeam(_localhero, data.unit) then
  134.             print("Same team")
  135.             return
  136.         end    
  137.         local pos_key = tostring(math.floor(prt.position.x)) .. "_" .. tostring(math.floor(prt.position.y))
  138.         if handled_positions[pos_key] then
  139.             print("Already handled teleport at: " .. pos_key)
  140.             return
  141.         end
  142.         handled_positions[pos_key] = true
  143.         if Menu.Find("Heroes", "Hero List", "Invoker", "Auto Usage", "Sun Strike Settings", "Sun Strike for low HP teleport"):Get() == false then
  144.             print("Sun strike for low HP disabled")
  145.             return
  146.         end
  147.  
  148.         if Entity.GetUnitName(_localhero) ~= "npc_dota_hero_invoker" then return end
  149.        
  150.  
  151.         local sunstrike = NPC.GetAbility(_localhero, "invoker_sun_strike")
  152.         local exort = NPC.GetAbility(_localhero, "invoker_exort")
  153.         local invoke = NPC.GetAbility(_localhero, "invoker_invoke")
  154.         if not sunstrike or not exort then return end
  155.        
  156.         local enemy = data.unit
  157.         local exort_level = Ability.GetLevel(exort)
  158.         local damage = 125 + (50 * exort_level)
  159.         local player = Players.GetLocal()
  160.         if Ability.IsReady(sunstrike) then
  161.             print("Sunstrike is ready")
  162.             if data.health + 5 <= damage then
  163.                 print("Damage critical!")
  164.                 if enemy then
  165.                     local enemyid = Entity.GetIndex(enemy)
  166.  
  167.                     if heroes[enemyid] then
  168.                         print(data.unit_name .. " last seen at " .. heroes[enemyid])
  169.  
  170.                         local now = os.time()
  171.                         local seconds_passed = now - heroes[enemyid]
  172.  
  173.                         print("After " .. seconds_passed .. " seconds")
  174.                        
  175.                         local maxsleep = tonumber(Menu.Find("Heroes", "Hero List", "Invoker", "Auto Usage", "Sun Strike Settings", "Max no-vision time"):Get())
  176.                         print("Max no-vision time " .. maxsleep .. " sec.")
  177.                         if seconds_passed > maxsleep then
  178.                             print("Прошло более " .. maxsleep .. " секунд.")
  179.                             return
  180.                         end
  181.                     else
  182.                         print("Нет информации о последнем появлении для enemyid: " .. tostring(enemyid))
  183.                     end
  184.                 else
  185.                     print("data.unit is nil!")
  186.                 end
  187.  
  188.                 if not Ability.IsHidden(sunstrike) then
  189.                     Player.PrepareUnitOrders(player, Enum.UnitOrder.DOTA_UNIT_ORDER_CAST_POSITION, nil, prt.position, sunstrike, Enum.PlayerOrderIssuer.DOTA_ORDER_ISSUER_HERO_ONLY, _localhero, false, true, false, true, nil, true)
  190.                     Engine.LookAt(prt.position.x, prt.position.y)
  191.                     return
  192.                 end
  193.                 for i = 1, 3 do
  194.                     AddAction(0.01, function()
  195.                         Player.PrepareUnitOrders(player, Enum.UnitOrder.DOTA_UNIT_ORDER_CAST_NO_TARGET, nil, Vector(), exort, Enum.PlayerOrderIssuer.DOTA_ORDER_ISSUER_HERO_ONLY, _localhero, false, true, false, true, nil, true)                    
  196.                         print("prepare #" .. i .. " for exort")
  197.                     end)
  198.                 end
  199.  
  200.                 if invoke and Ability.IsReady(invoke) then
  201.                     print("invoke is ready and cast it")
  202.                     print("Начало " .. os.time())
  203.                     AddAction(0.25, function()
  204.                         Player.PrepareUnitOrders(player, Enum.UnitOrder.DOTA_UNIT_ORDER_CAST_NO_TARGET, nil, Vector(), invoke, Enum.PlayerOrderIssuer.DOTA_ORDER_ISSUER_HERO_ONLY, _localhero, false, true, false, true, nil, true)
  205.                         print("Конец ".. os.time())
  206.                     end)
  207.                    
  208.                 end
  209.  
  210.                 AddAction(0.15, function()
  211.                     print("Casting sunstrike")
  212.                     Player.PrepareUnitOrders(player, Enum.UnitOrder.DOTA_UNIT_ORDER_CAST_POSITION, nil, prt.position, sunstrike, Enum.PlayerOrderIssuer.DOTA_ORDER_ISSUER_HERO_ONLY, _localhero, false, true, false, true, nil, true)
  213. --                    Engine.ExecuteCommand("say Sunstrike casted at position: " .. tostring(prt.position) .. " for " .. data.unit_name)
  214.                     Engine.LookAt(prt.position.x, prt.position.y)
  215.                 end)
  216.             end
  217.         end
  218.     end
  219.     add_divider()
  220. end
  221.  
  222.  
  223. function script.OnParticleUpdateEntity(prt)
  224.     MiniMap.SendLine(prt.position, false, false)
  225.     prt = table.copy(prt)
  226.     if (prt.entity and Entity.IsNPC(prt.entity)) then
  227.         local unit_name = NPC.GetUnitName(prt.entity)
  228.         prt["[m]entity_name"] = unit_name
  229.     end
  230.  
  231.     if particle_name_map[prt.index] then
  232.         prt["[m]name"] = particle_name_map[prt.index]
  233.     end
  234.    
  235.     add_divider()
  236. end
  237.  
  238. function script.OnParticleUpdateFallback(prt)
  239.  
  240.     prt = table.copy(prt)
  241.     if particle_name_map[prt.index] then
  242.         prt["[m]name"] = particle_name_map[prt.index]
  243.     end
  244.    
  245.     add_divider()
  246. end
  247.  
  248. function script.OnParticleDestroy(prt)
  249.     prt = table.copy(prt)
  250.  
  251.     if particle_name_map[prt.index] then
  252.         prt["[m]name"] = particle_name_map[prt.index]
  253.     end
  254.  
  255.     particle_name_map[prt.index] = nil
  256.     particle_data[prt.index] = nil
  257.  
  258.    
  259.     add_divider()
  260. end
  261.  
  262.  
  263. --#endregion
  264.  
  265.  
  266.  
  267. return script
Advertisement
Comments
Add Comment
Please, Sign In to add comment
Advertisement