Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- TargetSelector Class
- --[[
- TargetSelector Class :
- Methods:
- ts = TargetSelector(mode, range, damageType (opt), targetSelected (opt), enemyTeam (opt))
- Goblal Functions :
- TS_Print(enemyTeam (opt)) -> print Priority (global)
- TS_SetFocus() -> set priority to the selected champion (you need to use PRIORITY modes to use it) (global)
- TS_SetFocus(id) -> set priority to the championID (you need to use PRIORITY modes to use it) (global)
- TS_SetFocus(charName, enemyTeam (opt)) -> set priority to the champion charName (you need to use PRIORITY modes to use it) (global)
- TS_SetFocus(hero) -> set priority to the hero object (you need to use PRIORITY modes to use it) (global)
- TS_SetHeroPriority(priority, target, enemyTeam (opt)) -> set the priority to target
- TS_SetPriority(target1, target2, target3, target4, target5) -> set priority in order to enemy targets
- TS_SetPriorityA(target1, target2, target3, target4, target5) -> set priority in order to ally targets
- TS_GetPriority(target, enemyTeam) -> return the current priority, and the max allowed
- TargetSelector__OnSendChat(msg) -- to add to OnSendChat(msg) function if you want the chat command
- Functions :
- ts:update() -- update the instance target
- ts:SetDamages(magicDmgBase, physicalDmgBase, trueDmg)
- ts:SetPrediction() -- prediction off
- ts:SetPrediction(delay) -- predict movement for champs (need Prediction__OnTick())
- ts:SetMinionCollision() -- minion colission off
- ts:SetMinionCollision(spellWidth) -- avoid champ if minion between player
- ts:SetConditional() -- erase external function use
- ts:SetConditional(func) -- set external function that return true/false to allow filter -- function(hero, index (opt))
- ts:SetProjectileSpeed(pSpeed) -- set projectile speed (need Prediction__OnTick())
- Members:
- ts.mode -> TARGET_LOW_HP, TARGET_MOST_AP, TARGET_MOST_AD, TARGET_PRIORITY, TARGET_NEAR_MOUSE, TARGET_LOW_HP_PRIORITY, TARGET_LESS_CAST, TARGET_LESS_CAST_PRIORITY
- ts.range -> number > 0
- ts.targetSelected -> true/false
- ts.target -> return the target (object or nil)
- ts.index -> index of target (if hero)
- ts.nextPosition -> nextPosition predicted
- ts.nextHealth -> nextHealth predicted
- Usage :
- variable = TargetSelector(mode, range, damageType (opt), targetSelected (opt), enemyTeam (opt))
- targetSelected is set to true if not filled
- Damages are set as default to magic 100 if none is set
- enemyTeam is false if ally, nil or true if enemy
- when you want to update, call variable:update()
- Values you can change on instance :
- variable.mode -> TARGET_LOW_HP, TARGET_MOST_AP, TARGET_PRIORITY, TARGET_NEAR_MOUSE, TARGET_LOW_HP_PRIORITY, TARGET_LESS_CAST, TARGET_LESS_CAST_PRIORITY
- variable.range -> number > 0
- variable.targetSelected -> true/false (if you clicked on a champ)
- ex :
- function OnLoad()
- ts = TargetSelector(TARGET_LESS_CAST, 600, DAMAGE_MAGIC, true)
- end
- function OnTick()
- ts:update()
- if ts.target ~= nil then
- PrintChat(ts.target.charName)
- ts:SetDamages((player.ap * 10), 0, 0)
- end
- end
- function OnSendChat(msg)
- TargetSelector__OnSendChat(msg)
- end
- ]]
- -- Class related constants
- TARGET_LOW_HP = 1
- TARGET_MOST_AP = 2
- TARGET_MOST_AD = 3
- TARGET_LESS_CAST = 4
- TARGET_NEAR_MOUSE = 5
- TARGET_PRIORITY = 6
- TARGET_LOW_HP_PRIORITY = 7
- TARGET_LESS_CAST_PRIORITY = 8
- DAMAGE_MAGIC = 1
- DAMAGE_PHYSICAL = 2
- -- Class related global
- _gameHeros, _gameAllyCount, _gameEnemyCount = {}, 0, 0
- _TargetSelector__texted = {"LowHP", "MostAP", "MostAD", "LessCast", "NearMouse", "Priority", "LowHPPriority", "LessCastPriority"}
- -- Class related function
- function _gameHeros__init()
- if #_gameHeros == 0 then
- _gameAllyCount, _gameEnemyCount = 0, 0
- for i = 1, heroManager.iCount do
- local hero = heroManager:getHero(i)
- if hero ~= nil then
- if hero.team == player.team then
- _gameAllyCount = _gameAllyCount + 1
- table.insert(_gameHeros, {hero = hero, index = i, tIndex = _gameAllyCount, ignore = false, priority = 1, enemy = false})
- else
- _gameEnemyCount = _gameEnemyCount + 1
- table.insert(_gameHeros, {hero = hero, index = i, tIndex = _gameEnemyCount, ignore = false, priority = 1, enemy = true})
- end
- end
- end
- end
- end
- function _gameHeros__extended(target, assertText)
- local assertText = assertText or ""
- if type(target) == "number" then
- return _gameHeros[target]
- elseif target ~= nil then
- assert(type(target.networkID) == "number", assertText..": wrong argument types (<charName> or <heroIndex> or <hero> expected)")
- for index,_gameHero in ipairs(_gameHeros) do
- if _gameHero.hero.networkID == target.networkID then
- return _gameHero
- end
- end
- end
- end
- function _gameHeros__hero(target, assertText, enemyTeam)
- local assertText = assertText or ""
- enemyTeam = (enemyTeam ~= false)
- if type(target) == "string" then
- for index,_gameHero in ipairs(_gameHeros) do
- if _gameHero.hero.charName == target and (_gameHero.hero.team ~= player.team) == enemyTeam then
- return _gameHero.hero
- end
- end
- elseif type(target) == "number" then
- return heroManager:getHero(target)
- elseif target == nil then
- return GetTarget()
- else
- assert(type(target.networkID) == "number", assertText..": wrong argument types (<charName> or <heroIndex> or <hero> or nil expected)")
- return target
- end
- end
- function _gameHeros__index(target, assertText, enemyTeam)
- local assertText = assertText or ""
- local enemyTeam = (enemyTeam ~= false)
- if type(target) == "string" then
- for index,_gameHero in ipairs(_gameHeros) do
- if _gameHero.hero.charName == target and (_gameHero.hero.team ~= player.team) == enemyTeam then
- return _gameHero.index
- end
- end
- elseif type(target) == "number" then
- return target
- else
- assert(type(target.networkID) == "number", assertText..": wrong argument types (<charName> or <heroIndex> or <hero> or nil expected)")
- return _gameHeros__index(target.charName, assertText, (target.team ~= player.team))
- end
- end
- function TS_Print(enemyTeam)
- local enemyTeam = (enemyTeam ~= false)
- for i, target in ipairs(_gameHeros) do
- if target.hero ~= nil and target.enemy == enemyTeam then
- PrintChat("[TS] "..(enemyTeam and "Enemy " or "Ally ")..target.tIndex.." ("..target.index..") : " .. target.hero.charName .. " Mode=" .. (target.ignore and "ignore" or "target") .." Priority=" .. target.priority)
- end
- end
- end
- function TS_SetFocus(target, enemyTeam)
- local enemyTeam = (enemyTeam ~= false)
- local selected = _gameHeros__hero(target, "TS_SetFocus")
- if selected ~= nil and selected.type == "obj_AI_Hero" and (selected.team ~= player.team) == enemyTeam then
- for index,_gameHero in ipairs(_gameHeros) do
- if _gameHero.enemy == enemyTeam then
- if _gameHero.hero.networkID == selected.networkID then
- _gameHero.priority = 1
- PrintChat("[TS] Focusing " .. _gameHero.hero.charName)
- else
- _gameHero.priority = (enemyTeam and _gameEnemyCount or _gameAllyCount)
- end
- end
- end
- end
- end
- function TS_SetHeroPriority(priority, target, enemyTeam)
- local enemyTeam = (enemyTeam ~= false)
- local heroCount = (enemyTeam and _gameEnemyCount or _gameAllyCount)
- assert(type(priority) == "number" and priority >= 0 and priority <= heroCount, "TS_SetHeroPriority: wrong argument types (<number> 1 to "..heroCount.." expected)")
- local selected = _gameHeros__index(target, "TS_SetHeroPriority: wrong argument types (<charName> or <heroIndex> or <hero> or nil expected)", enemyTeam)
- if selected ~= nil then
- local oldPriority = _gameHeros[selected].priority
- if oldPriority == nil or oldPriority == priority then return end
- for index,_gameHero in ipairs(_gameHeros) do
- if _gameHero.enemy == enemyTeam then
- if index == selected then
- _gameHero.priority = priority
- --PrintChat("[TS] "..(enemyTeam and "Enemy " or "Ally ").._gameHero.tIndex.." (".._gameHero.index..") : " .. _gameHero.hero.charName .. " Mode=" .. (_gameHero.ignore and "ignore" or "target") .." Priority=" .. _gameHero.priority)
- end
- end
- end
- end
- end
- function TS_SetPriority(target1, target2, target3, target4, target5)
- assert((target5 ~= nil and _gameEnemyCount == 5) or (target4 ~= nil and _gameEnemyCount < 5) or (target3 ~= nil and _gameEnemyCount == 3) or (target2 ~= nil and _gameEnemyCount == 2) or (target1 ~= nil and _gameEnemyCount == 1), "TS_SetPriority: wrong argument types (".._gameEnemyCount.." <target> expected)")
- TS_SetHeroPriority(1, target1)
- TS_SetHeroPriority(2, target2)
- TS_SetHeroPriority(3, target3)
- TS_SetHeroPriority(4, target4)
- TS_SetHeroPriority(5, target5)
- end
- function TS_SetPriorityA(target1, target2, target3, target4, target5)
- assert((target5 ~= nil and _gameAllyCount == 5) or (target4 ~= nil and _gameAllyCount < 5) or (target3 ~= nil and _gameAllyCount == 3) or (target2 ~= nil and _gameAllyCount == 2) or (target1 ~= nil and _gameAllyCount == 1), "TS_SetPriorityA: wrong argument types (".._gameAllyCount.." <target> expected)")
- TS_SetHeroPriority(1, target1, false)
- TS_SetHeroPriority(2, target2, false)
- TS_SetHeroPriority(3, target3, false)
- TS_SetHeroPriority(4, target4, false)
- TS_SetHeroPriority(5, target5, false)
- end
- function TS_GetPriority(target, enemyTeam)
- local enemyTeam = (enemyTeam ~= false)
- local index = _gameHeros__index(target, "TS_GetPriority", enemyTeam)
- return (index and _gameHeros[index].priority or nil), (enemyTeam and _gameEnemyCount or _gameAllyCount)
- end
- function TS_Ignore(target, enemyTeam)
- local enemyTeam = (enemyTeam ~= false)
- local selected = _gameHeros__hero(target, "TS_Ignore")
- if selected ~= nil and selected.type == "obj_AI_Hero" and (selected.team ~= player.team) == enemyTeam then
- for index,_gameHero in ipairs(_gameHeros) do
- if _gameHero.hero.networkID == selected.networkID and _gameHero.enemy == enemyTeam then
- _gameHero.ignore = not _gameHero.ignore
- --PrintChat("[TS] "..(_gameHero.ignore and "Ignoring " or "Re-targetting ").._gameHero.hero.charName)
- break
- end
- end
- end
- end
- function _TS_Draw_Init()
- if not _TS_Draw then
- if not WINDOW_H or not WINDOW_W then PrintChat("WINDOW value not good, please reload") end
- _TS_Draw = {y1 = 0, heigth = 0, fontSize = WINDOW_H and math.round(WINDOW_H / 54) or 14, width = WINDOW_W and math.round(WINDOW_W / 4.8) or 213, border = 2, background = 1413167931, textColor = 4290427578, redColor = 1422721024, greenColor = 1409321728, blueColor = 2684354716}
- _TS_Draw.cellSize, _TS_Draw.midSize, _TS_Draw.row1, _TS_Draw.row2, _TS_Draw.row3, _TS_Draw.row4 = _TS_Draw.fontSize + _TS_Draw.border, _TS_Draw.fontSize / 2, _TS_Draw.width * 0.6, _TS_Draw.width * 0.7, _TS_Draw.width * 0.8, _TS_Draw.width * 0.9
- end
- end
- function TS__DrawMenu(x, y, enemyTeam)
- assert(type(x) == "number" and type(y) == "number", "TS__DrawMenu: wrong argument types (<number>, <number> expected)")
- _TS_Draw_Init()
- local enemyTeam = (enemyTeam ~= false)
- local y1 = y
- for index,_gameHero in ipairs(_gameHeros) do
- if _gameHero.enemy == enemyTeam then
- DrawLine(x - _TS_Draw.border, y1 + _TS_Draw.midSize, x + _TS_Draw.row1 - _TS_Draw.border, y1 + _TS_Draw.midSize, _TS_Draw.cellSize, (_gameHero.ignore and _TS_Draw.redColor or _TS_Draw.background))
- DrawText(_gameHero.hero.charName, _TS_Draw.fontSize, x, y1, _TS_Draw.textColor)
- DrawLine(x + _TS_Draw.row1, y1 + _TS_Draw.midSize, x + _TS_Draw.row2 - _TS_Draw.border, y1 + _TS_Draw.midSize, _TS_Draw.cellSize, _TS_Draw.background)
- DrawText(" "..(_gameHero.ignore and "-" or tostring(_gameHero.priority)), _TS_Draw.fontSize, x + _TS_Draw.row1, y1, _TS_Draw.textColor)
- DrawLine(x + _TS_Draw.row2, y1 + _TS_Draw.midSize, x + _TS_Draw.row3 - _TS_Draw.border, y1 + _TS_Draw.midSize, _TS_Draw.cellSize, _TS_Draw.blueColor)
- DrawText(" -", _TS_Draw.fontSize, x + _TS_Draw.row2, y1, _TS_Draw.textColor)
- DrawLine(x + _TS_Draw.row3, y1 + _TS_Draw.midSize, x + _TS_Draw.row4 - _TS_Draw.border, y1 + _TS_Draw.midSize, _TS_Draw.cellSize, _TS_Draw.blueColor)
- DrawText(" +", _TS_Draw.fontSize, x + _TS_Draw.row3, y1, _TS_Draw.textColor)
- DrawLine(x + _TS_Draw.row4, y1 + _TS_Draw.midSize, x + _TS_Draw.width, y1 + _TS_Draw.midSize, _TS_Draw.cellSize, _TS_Draw.redColor)
- DrawText(" X", _TS_Draw.fontSize, x + _TS_Draw.row4, y1, _TS_Draw.textColor)
- y1 = y1 + _TS_Draw.cellSize
- end
- end
- return y1
- end
- function TS_ClickMenu(x, y, enemyTeam)
- assert(type(x) == "number" and type(y) == "number", "TS__DrawMenu: wrong argument types (<number>, <number> expected)")
- _TS_Draw_Init()
- local enemyTeam = (enemyTeam ~= false)
- local y1 = y
- for index,_gameHero in ipairs(_gameHeros) do
- if _gameHero.enemy == enemyTeam then
- if CursorIsUnder(x + _TS_Draw.row2, y1, _TS_Draw.fontSize, _TS_Draw.fontSize) then
- TS_SetHeroPriority(math.max(1, _gameHero.priority - 1), index)
- elseif CursorIsUnder(x + _TS_Draw.row3, y1, _TS_Draw.fontSize, _TS_Draw.fontSize) then
- TS_SetHeroPriority(math.min((enemyTeam and _gameEnemyCount or _gameAllyCount), _gameHero.priority + 1), index)
- elseif CursorIsUnder(x + _TS_Draw.row4, y1, _TS_Draw.fontSize, _TS_Draw.fontSize) then TS_Ignore(index) end
- y1 = y1 + _TS_Draw.cellSize
- end
- end
- return y1
- end
- function TargetSelector__OnSendChat(msg)
- if msg:sub(1,3) ~= ".ts" then return end
- BlockChat()
- local args = {}
- while string.find(msg," ") do
- local index = string.find(msg," ")
- table.insert(args, msg:sub(1,index-1))
- msg = string.sub(msg,index+1)
- end
- table.insert(args, msg)
- local cmd = args[1]:lower()
- if cmd == ".tsprint" then
- TS_Print()
- elseif cmd == ".tsprinta" then
- TS_Print(false)
- elseif cmd == ".tsfocus" then
- PrintChat(cmd.." - "..args[2])
- TS_SetFocus(args[2])
- elseif cmd == ".tsfocusa" then
- TS_SetFocus(args[2], false)
- elseif cmd == ".tspriorityhero" then
- TS_SetHeroPriority(args[2], args[3])
- elseif cmd == ".tspriorityheroa" then
- TS_SetHeroPriority(args[2], args[3], false)
- elseif cmd == ".tspriority" then
- TS_SetPriority(args[2], args[3], args[4], args[5], args[6])
- elseif cmd == ".tsprioritya" then
- TS_SetPriorityA(args[2], args[3], args[4], args[5], args[6])
- elseif cmd == ".tsignore" then
- TS_Ignore(args[2])
- elseif cmd == ".tsignorea" then
- TS_Ignore(args[2], false)
- end
- end
- class 'TargetSelector'
- function TargetSelector:__init(mode, range, damageType, targetSelected, enemyTeam)
- -- Init Global
- assert(type(mode) == "number" and type(range) == "number", "TargetSelector: wrong argument types (<mode>, <number> expected)")
- _gameHeros__init()
- self.mode = mode
- self.range = range
- self._mDmgBase, self._pDmgBase, self._tDmg = 0, 0, 0
- self._dmgType = damageType or DAMAGE_MAGIC
- if self._dmgType == DAMAGE_MAGIC then self._mDmgBase = 100 else self._tDmg = player.totalDamage end
- self.targetSelected = (targetSelected ~= false)
- self.enemyTeam = (enemyTeam ~= false)
- self.target = nil
- self._conditional = nil
- self._spellWidth = nil
- self._pDelay = nil
- end
- function TargetSelector:printMode()
- PrintChat("[TS] Target mode: " .._TargetSelector__texted[self.mode])
- end
- function TargetSelector:SetDamages(magicDmgBase, physicalDmgBase, trueDmg)
- assert(magicDmgBase == nil or type(magicDmgBase) == "number", "SetDamages: wrong argument types (<number> or nil expected) for magicDmgBase")
- assert(physicalDmgBase == nil or type(physicalDmgBase) == "number", "SetDamages: wrong argument types (<number> or nil expected) for physicalDmgBase")
- assert(trueDmg == nil or type(trueDmg) == "number", "SetDamages: wrong argument types (<number> or nil expected) for trueDmg")
- self._dmgType = 0
- self._mDmgBase = magicDmgBase or 0
- self._pDmgBase = physicalDmgBase or 0
- self._tDmg = trueDmg or 0
- end
- function TargetSelector:SetMinionCollision(spellWidth)
- assert(spellWidth == nil or type(spellWidth) == "number", "SetMinionCollision: wrong argument types (<number> or nil expected)")
- self._spellWidth = ((spellWidth ~= nil or spellWidth > 0) and spellWidth or nil)
- end
- function TargetSelector:SetPrediction(delay)
- assert(delay == nil or type(delay) == "number", "SetPrediction: wrong argument types (<number> or nil expected)")
- _Prediction__OnLoad()
- self._pDelay = ((delay ~= nil and delay > 0) and delay or nil)
- end
- function TargetSelector:SetProjectileSpeed(pSpeed)
- assert(delay == nil or type(delay) == "number", "SetProjectileSpeed: wrong argument types (<number> or nil expected)")
- _Prediction__OnLoad()
- self._pSpeed = ((pSpeed ~= nil and pSpeed > 0) and pSpeed or nil)
- end
- function TargetSelector:SetConditional(func)
- assert (func == nil or type(func) == "function", "SetConditional : wrong argument types (<function> or nil expected)")
- self._conditional = func
- end
- function TargetSelector:_targetSelectedByPlayer()
- if self.targetSelected then
- local currentTarget = GetTarget()
- if ValidTarget(currentTarget, self.range, self.enemyTeam) and (currentTarget.type == "obj_AI_Hero" or currentTarget.type == "obj_AI_Minion") and (self._conditional == nil or self._conditional(currentTarget)) then
- if self.target == nil or self.target.networkID ~= currentTarget.networkID then
- self.target = currentTarget
- self.index = _gameHeros__index(currentTarget, "_targetSelectedByPlayer")
- end
- local delay = 0
- if self._pDelay ~= nil and self._pDelay > 0 then
- delay = delay + self._pDelay
- end
- if self._pSpeed ~= nil and self._pSpeed > 0 then
- delay = delay + (GetDistance(currentTarget) / self._pSpeed)
- end
- if self.index and delay > 0 then
- self.nextPosition = _PredictionPosition(self.index, delay)
- self.nextHealth = _PredictionHealth(self.index, delay)
- else
- self.nextPosition = Vector(currentTarget)
- self.nextHealth = currentTarget.health
- end
- return true
- end
- end
- return false
- end
- function TargetSelector:update()
- -- Resets the target if player died
- if player.dead then
- self.target = nil
- return
- end
- -- Get current selected target (by player) if needed
- if self:_targetSelectedByPlayer() then return end
- local selected, index, value, nextPosition, nextHealth
- local range = (self.mode == TARGET_NEAR_MOUSE and 2000 or self.range)
- for i, _gameHero in ipairs(_gameHeros) do
- local hero = _gameHero.hero
- if ValidTarget(hero, range, self.enemyTeam) and not _gameHero.ignore and (self._conditional == nil or self._conditional(hero, i)) then
- local minionCollision = false
- local delay = 0
- if self._pDelay ~= nil and self._pDelay > 0 then
- delay = delay + self._pDelay
- end
- if self._pSpeed ~= nil and self._pSpeed > 0 then
- delay = delay + (GetDistance(hero) / self._pSpeed)
- end
- if delay > 0 then
- nextPosition = _PredictionPosition(i, delay)
- nextHealth = _PredictionHealth(i, delay)
- else
- nextPosition, nextHealth = Vector(hero), hero.health
- end
- if self._spellWidth then minionCollision = GetMinionCollision(player, nextPosition, self._spellWidth) end
- if GetDistance(nextPosition) <= range and minionCollision == false then
- if self.mode == TARGET_LOW_HP or self.mode == TARGET_LOW_HP_PRIORITY or self.mode == TARGET_LESS_CAST or self.mode == TARGET_LESS_CAST_PRIORITY then
- -- Returns lowest effective HP target that is in range
- -- Or lowest cast to kill target that is in range
- if self._dmgType == DAMAGE_PHYSICAL then self._pDmgBase = player.totalDamage end
- local mDmg = (self._mDmgBase > 0 and player:CalcMagicDamage(hero, self._mDmgBase) or 0)
- local pDmg = (self._pDmgBase > 0 and player:CalcDamage(hero, self._pDmgBase) or 0)
- local totalDmg = mDmg + pDmg + self._tDmg
- -- priority mode
- if self.mode == TARGET_LOW_HP_PRIORITY or self.mode == TARGET_LESS_CAST_PRIORITY then
- totalDmg = totalDmg / _gameHero.priority
- end
- local heroValue
- if self.mode == TARGET_LOW_HP or self.mode == TARGET_LOW_HP_PRIORITY then
- heroValue = hero.health - totalDmg
- else
- heroValue = hero.health / totalDmg
- end
- if not selected or heroValue < value then selected, index, value = hero, i, heroValue end
- elseif self.mode == TARGET_MOST_AP then
- -- Returns target that has highest AP that is in range
- if not selected or hero.ap > selected.ap then selected, index = hero, i end
- elseif self.mode == TARGET_MOST_AD then
- -- Returns target that has highest AD that is in range
- if not selected or hero.totalDamage > selected.totalDamage then selected, index = hero, i end
- elseif self.mode == TARGET_PRIORITY then
- -- Returns target with highest priority # that is in range
- if not selected or _gameHero.priority < value then selected, index, value = hero, i, _gameHero.priority end
- elseif self.mode == TARGET_NEAR_MOUSE then
- -- Returns target that is the closest to the mouse cursor.
- local distance = GetDistance(mousePos, hero)
- if not selected or distance < value then selected, index, value = hero, i, distance end
- end
- end
- end
- end
- self.index = index
- self.target = selected
- self.nextPosition = nextPosition
- self.nextHealth = nextHealth
- end
- function TargetSelector:OnSendChat(msg, prefix)
- assert(type(prefix) == "string" and prefix ~= "" and prefix:lower() ~= "ts", "TS OnSendChat: wrong argument types (<string> (not TS) expected for prefix)")
- if msg:sub(1,1) ~= "." then return end
- local prefix = prefix:lower()
- local length = prefix:len() + 1
- if msg:sub(1,length) ~= "."..prefix then return end
- BlockChat()
- local args = {}
- while string.find(msg," ") do
- local index = string.find(msg," ")
- table.insert(args, msg:sub(1,index-1))
- msg = msg:sub(index+1)
- end
- table.insert(args, msg)
- local cmd = args[1]:lower()
- if cmd == "."..prefix.."mode" then
- assert(args[2] ~= nil, "TS OnSendChat: wrong argument types (LowHP, MostAP, MostAD, LessCast, NearMouse, Priority, LowHPPriority, LessCastPriority expected)")
- local index = 0
- for i, mode in ipairs({"LowHP", "MostAP", "MostAD", "LessCast", "NearMouse", "Priority", "LowHPPriority", "LessCastPriority"}) do
- if mode:lower() == args[2]:lower() then
- index = i
- break
- end
- end
- assert(index ~= 0, "TS OnSendChat: wrong argument types (LowHP, MostAP, MostAD, LessCast, NearMouse, Priority, LowHPPriority, LessCastPriority expected)")
- self.mode = index
- self:printMode()
- end
- end
- function TargetSelector:DrawMenu(x, y)
- assert(type(x) == "number" and type(y) == "number", "ts:DrawMenu: wrong argument types (<number>, <number> expected)")
- _TS_Draw_Init()
- DrawLine(x - _TS_Draw.border, y + _TS_Draw.midSize, x + _TS_Draw.row3 - _TS_Draw.border, y + _TS_Draw.midSize, _TS_Draw.cellSize, _TS_Draw.background)
- DrawText((self.name or "ts").." Mode : ".._TargetSelector__texted[self.mode], _TS_Draw.fontSize, x, y, _TS_Draw.textColor)
- DrawLine(x + _TS_Draw.row3, y + _TS_Draw.midSize, x + _TS_Draw.row4 - _TS_Draw.border, y + _TS_Draw.midSize, _TS_Draw.cellSize, _TS_Draw.blueColor)
- DrawText( " <", _TS_Draw.fontSize, x + _TS_Draw.row3, y, _TS_Draw.textColor)
- DrawLine(x + _TS_Draw.row4, y + _TS_Draw.midSize, x + _TS_Draw.width, y + _TS_Draw.midSize, _TS_Draw.cellSize, _TS_Draw.blueColor)
- DrawText( " >", _TS_Draw.fontSize, x + _TS_Draw.row4, y, _TS_Draw.textColor)
- return y + _TS_Draw.cellSize
- end
- function TargetSelector:ClickMenu(x, y)
- assert(type(x) == "number" and type(y) == "number", "ts:ClickMenu: wrong argument types (<number>, <number>, <string> expected)")
- _TS_Draw_Init()
- if CursorIsUnder(x + _TS_Draw.row3, y, _TS_Draw.fontSize, _TS_Draw.fontSize) then
- self.mode = (self.mode == 1 and #_TargetSelector__texted or self.mode - 1)
- elseif CursorIsUnder(x + _TS_Draw.row4, y, _TS_Draw.fontSize, _TS_Draw.fontSize) then
- self.mode = (self.mode == #_TargetSelector__texted and 1 or self.mode + 1)
- end
- return y + _TS_Draw.cellSize
- end
- -- Prediction Functions
- --[[
- Globals Functions
- Prediction__OnTick() -- OnTick()
- GetPredictionPos(iHero, delay) -- return nextPosition in delay (ms) for iHero (index)
- GetPredictionPos(Hero, delay) -- return nextPosition in delay (ms) for Hero
- GetPredictionPos(charName, delay, enemyTeam) -- return nextPosition in delay (ms) for charName in enemyTeam (true/false, default true)
- GetPredictionHealth(iHero, delay) -- return next Health in delay (ms) for iHero (index)
- GetPredictionHealth(Hero, delay) -- return next Health in delay (ms) for Hero
- GetPredictionHealth(charName, delay, enemyTeam) -- return next Health in delay (ms) for charName in enemyTeam (true/false, default true)
- ]]
- _Prediction = {init = true, delta = 1}
- function _Prediction__OnLoad()
- if _Prediction.init then
- _gameHeros__init()
- _Prediction.tick = GetTickCount()
- for i, _gameHero in ipairs(_gameHeros) do
- if _gameHero.hero ~= nil then
- _gameHero.pVector = Vector()
- _gameHero.lastPos = Vector(_gameHero.hero)
- _gameHero.pHealth = 0
- _gameHero.lastHealth = _gameHero.hero.health
- end
- end
- _Prediction.init = nil
- end
- end
- function _PredictionPosition(iHero, delay)
- local _gameHero = _gameHeros[iHero]
- if _gameHero and VectorType(_gameHero.pVector) and VectorType(_gameHero.lastPos) then
- local heroPosition = _gameHero.lastPos + (_gameHero.pVector * (_Prediction.delta * delay))
- heroPosition.y = _gameHero.hero.y
- return heroPosition
- end
- end
- function _PredictionHealth(iHero, delay)
- local _gameHero = _gameHeros[iHero]
- if _gameHero and _gameHero.pHealth ~= nil and _gameHero.lastHealth ~= nil then
- return _gameHero.lastHealth + (_gameHero.pHealth * (_Prediction.delta * delay))
- end
- end
- function Prediction__OnTick()
- _Prediction__OnLoad()
- local tick = GetTickCount()
- _Prediction.delta = 1 / (tick - _Prediction.tick)
- _Prediction.tick = tick
- for i, _gameHero in ipairs(_gameHeros) do
- if _gameHero.hero ~= nil and _gameHero.hero.dead == false and _gameHero.hero.visible then
- _gameHero.pVector = ( Vector(_gameHero.hero) - _gameHero.lastPos )
- _gameHero.lastPos = Vector(_gameHero.hero)
- _gameHero.pHealth = _gameHero.hero.health - _gameHero.lastHealth
- _gameHero.lastHealth = _gameHero.hero.health
- end
- end
- end
- function GetPredictionPos(target, delay, enemyTeam)
- local enemyTeam = (enemyTeam ~= false)
- local iHero = _gameHeros__index(target, "GetPredictionPos", enemyTeam)
- return _PredictionPosition(iHero, delay)
- end
- function GetPredictionHealth(target, delay, enemyTeam)
- local enemyTeam = (enemyTeam ~= false)
- local iHero = _gameHeros__index(target, "GetPredictionHealth", enemyTeam)
- return _PredictionHealth(iHero, delay)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement