Advertisement
I_GRIN_I

Untitled

Jul 29th, 2019
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import { Ability, ArrayExtensions, EntityManager, Game, MenuManager, Unit, Utils } from "./wrapper/Imports"
  2.  
  3. var available_at = 0
  4.  
  5. function GetBuggedAbils(hero: C_DOTA_Unit_Hero_Morphling): C_DOTABaseAbility[] {
  6.     let spells = hero.m_hAbilities.filter(abil => abil !== undefined)
  7.     let ar = Entities.AllEntities.filter(ent =>
  8.         ent instanceof C_DOTABaseAbility
  9.         && !(ent instanceof C_DOTA_Ability_Morphling_Waveform)
  10.         && !(ent instanceof C_DOTA_Item)
  11.         && (ent.m_pAbilityData.m_iAbilityBehavior & BigInt(DOTA_ABILITY_BEHAVIOR.DOTA_ABILITY_BEHAVIOR_PASSIVE)) === 0n
  12.         && ent.m_hOwnerEntity === hero
  13.         && !spells.includes(ent),
  14.     ) as C_DOTABaseAbility[]
  15.     let ar2 = []
  16.     let obj = []
  17.     ArrayExtensions.orderBy(ar, abil => -abil.m_iLevel).forEach(abil => abil instanceof C_DOTA_Ability_LoneDruid_SpiritBear ? ar2.push(abil) : obj[abil.m_pAbilityData.m_pszAbilityName] = abil)
  18.     return [...Object.values(obj), ...ar2]
  19. }
  20.  
  21. function castabil(id: number) {
  22.     if (!IsInGame() || available_at > Game.RawGameTime)
  23.         return
  24.     let hero = Entities.AllEntities.find(ent => ent instanceof C_DOTA_Unit_Hero_Morphling) as C_DOTA_Unit_Hero_Morphling
  25.     if (hero === undefined)
  26.         return
  27.     let abils = GetBuggedAbils(hero)
  28.     if (id >= abils.length)
  29.         return
  30.     let abil = EntityManager.GetEntityByNative(abils[id]) as Ability
  31.     let target = ArrayExtensions.orderBy(EntityManager.GetEntitiesInRange(Utils.CursorWorldVec, 200).filter(ent => {
  32.         return (
  33.             (
  34.                 ent.IsVisible
  35.                 && ent.IsAlive
  36.                 && (!(ent instanceof Unit) || !ent.m_pBaseEntity.m_bIsWaitingToSpawn)
  37.             )
  38.             && (
  39.                 (abil.TargetTeam.includes(DOTA_UNIT_TARGET_TEAM.DOTA_UNIT_TARGET_TEAM_FRIENDLY) && !ent.IsEnemy())
  40.                 || (abil.TargetTeam.includes(DOTA_UNIT_TARGET_TEAM.DOTA_UNIT_TARGET_TEAM_ENEMY) && ent.IsEnemy())
  41.                 || abil.TargetTeam.includes(DOTA_UNIT_TARGET_TEAM.DOTA_UNIT_TARGET_TEAM_CUSTOM)
  42.                 || abil.TargetTeam.includes(DOTA_UNIT_TARGET_TEAM.DOTA_UNIT_TARGET_TEAM_BOTH)
  43.             )
  44.             && (
  45.                 abil.TargetType.includes(DOTA_UNIT_TARGET_TYPE.DOTA_UNIT_TARGET_ALL)
  46.                 || (ent instanceof Unit && abil.TargetType.includes(DOTA_UNIT_TARGET_TYPE.DOTA_UNIT_TARGET_BUILDING) && ent.IsBuilding)
  47.                 || (ent instanceof Unit && abil.TargetType.includes(DOTA_UNIT_TARGET_TYPE.DOTA_UNIT_TARGET_COURIER) && ent.IsCourier)
  48.                 || (ent instanceof Unit && abil.TargetType.includes(DOTA_UNIT_TARGET_TYPE.DOTA_UNIT_TARGET_CREEP) && ent.IsCreep)
  49.                 || (ent instanceof Unit && abil.TargetType.includes(DOTA_UNIT_TARGET_TYPE.DOTA_UNIT_TARGET_HERO) && ent.IsHero)
  50.             )
  51.         )
  52.     }), ent => ent.Distance(Utils.CursorWorldVec))[0]
  53.     let native_target = target !== undefined ? target.m_pBaseEntity : undefined
  54.     Utils.CursorWorldVec.toIOBuffer()
  55.  
  56.     let beh = abil.AbilityBehavior
  57.     PrepareUnitOrders({
  58.         OrderType: beh.includes(DOTA_ABILITY_BEHAVIOR.DOTA_ABILITY_BEHAVIOR_NO_TARGET)
  59.                     ? dotaunitorder_t.DOTA_UNIT_ORDER_CAST_NO_TARGET
  60.                     : native_target !== undefined && (beh.includes(DOTA_ABILITY_BEHAVIOR.DOTA_ABILITY_BEHAVIOR_UNIT_TARGET) || beh.length === 0)
  61.                         ? dotaunitorder_t.DOTA_UNIT_ORDER_CAST_TARGET
  62.                         : beh.includes(DOTA_ABILITY_BEHAVIOR.DOTA_ABILITY_BEHAVIOR_POINT)
  63.                             ? dotaunitorder_t.DOTA_UNIT_ORDER_CAST_POSITION
  64.                             : dotaunitorder_t.DOTA_UNIT_ORDER_CAST_NO_TARGET,
  65.         Ability: abil.m_pBaseEntity,
  66.         Queue: false,
  67.         ShowEffects: true,
  68.         Unit: hero,
  69.         Target: native_target,
  70.     })
  71.     available_at = Game.RawGameTime + abil.CastPoint + 0.01
  72. }
  73.  
  74. const Menu = MenuManager.MenuFactory("Morphling Exploit")
  75. const enableHUD = Menu.AddToggle("Enable HUD", true)
  76. for (let i = 0; i < 10; i++)
  77.     Menu.AddKeybind("Hotkey " + (i + 1)).OnPressed(() => castabil(i))
  78. const alwaysHotkey = Menu.AddKeybind("Hotkey hold")
  79. const alwaysHotkeySlider = Menu.AddSlider("Hotkey hold number", 0, 0, 20)
  80. const xOffset = Menu.AddSlider("X Offset", 0, 0, 10000)
  81. const yOffset = Menu.AddSlider("Y Offset", 200, 0, 10000)
  82. const fontSize = Menu.AddSlider("Font size", 30, 0, 100)
  83.  
  84. Events.on("Draw", () => {
  85.     if (!IsInGame())
  86.         return
  87.     let hero = Entities.AllEntities.find(ent => ent instanceof C_DOTA_Unit_Hero_Morphling) as C_DOTA_Unit_Hero_Morphling
  88.     if (hero === undefined)
  89.         return
  90.     let abils = GetBuggedAbils(hero)
  91.     for (let i = abils.length; i--; )
  92.         if (abils[i] instanceof C_DOTA_Ability_LoneDruid_SpiritBear || abils[i] instanceof C_DOTA_Ability_MonkeyKing_TreeDance) {
  93.             let j = 30
  94.             while (hero.m_hAbilities[--j] !== undefined);
  95.             hero.m_hAbilities[j] = abils[i]
  96.         }
  97.     if (enableHUD.value) {
  98.         // loop-optimizer: KEEP
  99.         abils.forEach((abil, i) => Renderer.Text (
  100.             xOffset.value,
  101.             yOffset.value + i * fontSize.value,
  102.             `${abil.m_pAbilityData.m_pszAbilityName} ${abil.m_fCooldown.toFixed(1)}`,
  103.             255, 255, 255, 255, "Calibri", fontSize.value,
  104.         ))
  105.     }
  106. })
  107.  
  108. Events.on("PrepareUnitOrders", order => {
  109.     if (order.order_type === dotaunitorder_t.DOTA_UNIT_ORDER_STOP)
  110.         available_at = Game.RawGameTime
  111. })
  112. Events.on("GameEnded", () => available_at = 0)
  113.  
  114. setInterval(() => {
  115.     if (!IsInGame())
  116.         return
  117.     if (alwaysHotkey.IsPressed)
  118.         castabil(alwaysHotkeySlider.value)
  119. }, 30)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement