Making a script

Posts 1–15 of 19 · Page 1 of 2
Making a script
Today I will be braking down how to develop a script for a specific league champion.

Scripts and assets for the scripts are coded in the LUA language

I will be going over the champion script and not the asset files:

Credits to Inspired

We will be creating a script for Twitch



We start with checking if they are playing Twitch to know if the script will run

if GetObjectName(GetMyHero()) ~= "Twitch" then return end

Then we load in game messages to let the user know that the script was loaded correctly

PrintChat("Twitch loaded.")
PrintChat("by Law")

Then we will create the interface

local mainMenu = Menu("Twitch", "Twitch")
mainMenu:Menu("Combo", "Combo")
mainMenu.Combo:Boolean("useW", "Use W in combo", true)
mainMenu.Combo:Boolean("useE", "E at max stacks", true)
mainMenu.Combo:Key("Combo1", "Combo", string.byte(" "))

We will continue with this for the rest of the selective interfaces

------------------------------------------------------
mainMenu:Menu("Killsteal", "Killsteal")
mainMenu.Killsteal:Boolean("ksE", "Use E - KS", true)
mainMenu.Killsteal:Boolean("ksEp", "Poison + E - KS", true)
------------------------------------------------------
mainMenu:Menu("Items", "Items")
mainMenu.Items:Boolean("useCut", "Bilgewater Cutlass", true)
mainMenu.Items:Boolean("useBork", "Blade of the Ruined King", true)
mainMenu.Items:Boolean("useGhost", "Youmuu's Ghostblade", true)
mainMenu.Items:Boolean("useRedPot", "Elixir of Wrath", true)
------------------------------------------------------
mainMenu:Menu("Drawings", "Drawings")
mainMenu.Drawings:Boolean("drawPoison", "Draw Posion-Damage", true)
mainMenu.Drawings:Boolean("drawE", "Draw E-Damage", true)
mainMenu.Drawings:Boolean("drawR", "Draw R-Range", true)
mainMenu.Drawings:Slider("Quality","Circle Quality", 100 , 1, 255, 1)
------------------------------------------------------
mainMenu:Menu("Misc", "Misc")
mainMenu.Misc:Boolean("iR", "Invisible Recall", true)
mainMenu.Misc:Key("recall", "Recall Key", string.byte("T"))

PassiveStacks = {}
PassiveApply = {}

Now we will create a function for his passive stacks

OnUpdateBuff(function(Object,buff)

if buff.Name == "twitchdeadlyvenom" and GetTeam(Object) ~= GetTeam(myHero) and GetObjectType(Object) == Obj_AI_Hero then
if PassiveStacks[GetNetworkID(Object)] == nil then
PassiveStacks[GetNetworkID(Object)] = 0
end
if PassiveStacks[GetNetworkID(Object)] and PassiveStacks[GetNetworkID(Object)] < 6 then
PassiveStacks[GetNetworkID(Object)] = PassiveStacks[GetNetworkID(Object)] + 1
end
PassiveApply[GetNetworkID(Object)] = buff.StartTime

-----------------------
if GetLevel(myHero) >= 1 and GetLevel(myHero) <= 4 then
pDMG = 12
elseif GetLevel(myHero) >= 5 and GetLevel(myHero) <= 8 then
pDMG = 18
elseif GetLevel(myHero) >= 9 and GetLevel(myHero) <= 12 then
pDMG = 24
elseif GetLevel(myHero) >= 13 and GetLevel(myHero) <= 16 then
pDMG = 30
elseif GetLevel(myHero) >= 17 and GetLevel(myHero) <= 18 then
pDMG = 36
end
-----------------------
end
end)

OnRemoveBuff(function(Object,buff)

if buff.Name == "twitchdeadlyvenom" and GetTeam(Object) ~= GetTeam(myHero) and GetObjectType(Object) == Obj_AI_Hero then
PassiveStacks[GetNetworkID(Object)] = 0
PassiveApply[GetNetworkID(Object)] = 0
end

end)

After that we will create the Draw functions


OnDraw(function(myHero)
local target = GetCurrentTarget()
-- DRAWINGS
if mainMenu.Drawings.drawPoison:Value() or mainMenu.Drawings.drawE:Value() then
if ValidTarget(target,2000) and eDMG ~= nil and truepoisonDMG ~= nil then
for i,enemy in pairs(GetEnemyHeroes()) do
if CanUseSpell(myHero,_E) == READY and mainMenu.Drawings.drawE:Value() and mainMenu.Drawings.drawPoison:Value() then
DrawDmgOverHpBar(enemy,GetCurrentHP(enemy),eDMG,0, 0xff00ff00)
DrawDmgOverHpBar(enemy,GetCurrentHP(enemy)-eDMG,truepoisonDMG,0,0xffff00ff)
elseif CanUseSpell(myHero,_E) == ONCOOLDOWN and mainMenu.Drawings.drawE:Value() and mainMenu.Drawings.drawPoison:Value() then
DrawDmgOverHpBar(enemy,GetCurrentHP(enemy),truepoi sonDMG,0,0xffff00ff)
end

if mainMenu.Drawings.drawE:Value() and not mainMenu.Drawings.drawPoison:Value() then
DrawDmgOverHpBar(enemy,GetCurrentHP(enemy),eDMG,0, 0xff00ff00)
end

if mainMenu.Drawings.drawPoison:Value() and not mainMenu.Drawings.drawE:Value() then
DrawDmgOverHpBar(enemy,GetCurrentHP(enemy),truepoi sonDMG,0,0xffff00ff)
end
end
end
end

-- Draw R
if mainMenu.Drawings.drawR:Value() and CanUseSpell(myHero,_R) == READY and ValidTarget(target,2000) then
DrawCircle(GetOrigin(myHero),900,0,mainMenu.Drawin gs.Quality:Value(),ARGB(100,33,139,6))
end

end)

Now we must create the functions that activate items for the combo key

OnTick(function(myHero)

local target = GetCurrentTarget()
local myHeroPos = GetOrigin(myHero)

-- Items
local CutBlade = GetItemSlot(myHero,3144)
local bork = GetItemSlot(myHero,3153)
local ghost = GetItemSlot(myHero,3142)
local redpot = GetItemSlot(myHero,2140)

-- Use Items
if mainMenu.Combo.Combo1:Value() then
if CutBlade >= 1 and ValidTarget(target,550+50) and mainMenu.Items.useCut:Value() then
if CanUseSpell(myHero,GetItemSlot(myHero,3144)) == READY then
CastTargetSpell(target, GetItemSlot(myHero,3144))
end
elseif bork >= 1 and ValidTarget(target,550+50) and (GetMaxHP(myHero) / GetCurrentHP(myHero)) >= 1.25 and mainMenu.Items.useBork:Value() then
if CanUseSpell(myHero,GetItemSlot(myHero,3153)) == READY then
CastTargetSpell(target,GetItemSlot(myHero,3153))
end
end

if ghost >= 1 and ValidTarget(target,GetRange(myHero)+50) and mainMenu.Items.useGhost:Value() then
if CanUseSpell(myHero,GetItemSlot(myHero,3142)) == READY then
CastSpell(GetItemSlot(myHero,3142))
end
end

if redpot >= 1 and ValidTarget(target,GetRange(myHero)+50) and mainMenu.Items.useRedPot:Value() then
if CanUseSpell(myHero,GetItemSlot(myHero,2140)) == READY then
CastSpell(GetItemSlot(myHero,2140))
end
end
end

We continue by making the combo function (Used for fighting)

-- Combo
if mainMenu.Combo.Combo1:Value() and ValidTarget(target, 1500) then

if mainMenu.Combo.useW:Value() and ValidTarget(target, 1500) and CanUseSpell(myHero,_W) == READY then
local WPred = GetPredictionForPlayer(myHeroPos,target,GetMoveSpe ed(target),1400,250,940,220,false,true)
if WPred.HitChance == 1 then
CastSkillShot(_W,WPred.PredPos.x,WPred.PredPos.y,W Pred.PredPos.z)
end
end

if mainMenu.Combo.useE:Value() and ValidTarget(target,1200) and CanUseSpell(myHero,_E) == READY and PassiveStacks[GetNetworkID(target)] == 6 then
CastSpell(_E)
end

end


if ValidTarget(GetCurrentTarget(), 2000) then
for i,enemy in pairs(GetEnemyHeroes()) do
if PassiveStacks[GetNetworkID(enemy)] ~= nil then
if CanUseSpell(myHero,_E) == READY then
eDMG = CalcDamage(myHero,enemy,(15*GetCastLevel(myHero,_E )+5+(5*GetCastLevel(myHero,_E)+10+(0.2*GetBonusAP( myHero)+0.25*GetBonusDmg(myHero)))*PassiveStacks[GetNetworkID(enemy)]),0)
else eDMG = 0 end
end
-- Posion-Damage
if PassiveApply[GetNetworkID(enemy)] ~= nil and pDMG ~= nil and PassiveStacks[GetNetworkID(enemy)] > 0 and PassiveApply[GetNetworkID(enemy)] > 0 then
local p = GetGameTimer() - PassiveApply[GetNetworkID(enemy)]
local pp = 6 - p
truepoisonDMG = (((pDMG/6) * PassiveStacks[GetNetworkID(enemy)]) * pp -(GetHPRegen(enemy)* pp ))
end
end
end

Now we are going to add a function for a E kill steal


-- Killsteal E
if mainMenu.Killsteal.ksE:Value() and eDMG ~= nil then
for i,enemy in pairs(GetEnemyHeroes()) do
if CanUseSpell(myHero,_E) == READY and ValidTarget(enemy, 1200) and GetCurrentHP(enemy) + GetDmgShield(enemy) < eDMG and mainMenu.Killsteal.ksE:Value() then
CastSpell(_E)
end

if CanUseSpell(myHero,_E) == READY and ValidTarget(enemy, 1200) and truepoisonDMG ~= nil and GetCurrentHP(enemy) + GetDmgShield(enemy) < eDMG + truepoisonDMG and mainMenu.Killsteal.ksE:Value() and mainMenu.Killsteal.ksEp:Value() then
CastSpell(_E)
end
end
end

We will end it with a stealth recall option


-- Recall
if mainMenu.Misc.iR:Value() then
if CanUseSpell(myHero,_Q) == READY then
if mainMenu.Misc.recall:Value() then
CastSpell(_Q)
DelayAction(function()
CastSpell(RECALL)
end, 10)
end
end
end

end)





 
Full Code
if GetObjectName(GetMyHero()) ~= "Twitch" then return end

if not pcall( require, "Inspired" ) then PrintChat("You are missing Inspired.lua!") return end

PrintChat("Twitch loaded.")
PrintChat("by Law")

local mainMenu = Menu("Twitch", "Twitch")
mainMenu:Menu("Combo", "Combo")
mainMenu.Combo:Boolean("useW", "Use W in combo", true)
mainMenu.Combo:Boolean("useE", "E at max stacks", true)
mainMenu.Combo:Key("Combo1", "Combo", string.byte(" "))
------------------------------------------------------
mainMenu:Menu("Killsteal", "Killsteal")
mainMenu.Killsteal:Boolean("ksE", "Use E - KS", true)
mainMenu.Killsteal:Boolean("ksEp", "Poison + E - KS", true)
------------------------------------------------------
mainMenu:Menu("Items", "Items")
mainMenu.Items:Boolean("useCut", "Bilgewater Cutlass", true)
mainMenu.Items:Boolean("useBork", "Blade of the Ruined King", true)
mainMenu.Items:Boolean("useGhost", "Youmuu's Ghostblade", true)
mainMenu.Items:Boolean("useRedPot", "Elixir of Wrath", true)
------------------------------------------------------
mainMenu:Menu("Drawings", "Drawings")
mainMenu.Drawings:Boolean("drawPoison", "Draw Posion-Damage", true)
mainMenu.Drawings:Boolean("drawE", "Draw E-Damage", true)
mainMenu.Drawings:Boolean("drawR", "Draw R-Range", true)
mainMenu.Drawings:Slider("Quality","Circle Quality", 100 , 1, 255, 1)
------------------------------------------------------
mainMenu:Menu("Misc", "Misc")
mainMenu.Misc:Boolean("iR", "Invisible Recall", true)
mainMenu.Misc:Key("recall", "Recall Key", string.byte("T"))

PassiveStacks = {}
PassiveApply = {}

OnUpdateBuff(function(Object,buff)

if buff.Name == "twitchdeadlyvenom" and GetTeam(Object) ~= GetTeam(myHero) and GetObjectType(Object) == Obj_AI_Hero then
if PassiveStacks[GetNetworkID(Object)] == nil then
PassiveStacks[GetNetworkID(Object)] = 0
end
if PassiveStacks[GetNetworkID(Object)] and PassiveStacks[GetNetworkID(Object)] < 6 then
PassiveStacks[GetNetworkID(Object)] = PassiveStacks[GetNetworkID(Object)] + 1
end
PassiveApply[GetNetworkID(Object)] = buff.StartTime

-----------------------
if GetLevel(myHero) >= 1 and GetLevel(myHero) <= 4 then
pDMG = 12
elseif GetLevel(myHero) >= 5 and GetLevel(myHero) <= 8 then
pDMG = 18
elseif GetLevel(myHero) >= 9 and GetLevel(myHero) <= 12 then
pDMG = 24
elseif GetLevel(myHero) >= 13 and GetLevel(myHero) <= 16 then
pDMG = 30
elseif GetLevel(myHero) >= 17 and GetLevel(myHero) <= 18 then
pDMG = 36
end
-----------------------
end
end)

OnRemoveBuff(function(Object,buff)

if buff.Name == "twitchdeadlyvenom" and GetTeam(Object) ~= GetTeam(myHero) and GetObjectType(Object) == Obj_AI_Hero then
PassiveStacks[GetNetworkID(Object)] = 0
PassiveApply[GetNetworkID(Object)] = 0
end

end)

OnDraw(function(myHero)
local target = GetCurrentTarget()
-- DRAWINGS
if mainMenu.Drawings.drawPoison:Value() or mainMenu.Drawings.drawE:Value() then
if ValidTarget(target,2000) and eDMG ~= nil and truepoisonDMG ~= nil then
for i,enemy in pairs(GetEnemyHeroes()) do
if CanUseSpell(myHero,_E) == READY and mainMenu.Drawings.drawE:Value() and mainMenu.Drawings.drawPoison:Value() then
DrawDmgOverHpBar(enemy,GetCurrentHP(enemy),eDMG,0, 0xff00ff00)
DrawDmgOverHpBar(enemy,GetCurrentHP(enemy)-eDMG,truepoisonDMG,0,0xffff00ff)
elseif CanUseSpell(myHero,_E) == ONCOOLDOWN and mainMenu.Drawings.drawE:Value() and mainMenu.Drawings.drawPoison:Value() then
DrawDmgOverHpBar(enemy,GetCurrentHP(enemy),truepoi sonDMG,0,0xffff00ff)
end

if mainMenu.Drawings.drawE:Value() and not mainMenu.Drawings.drawPoison:Value() then
DrawDmgOverHpBar(enemy,GetCurrentHP(enemy),eDMG,0, 0xff00ff00)
end

if mainMenu.Drawings.drawPoison:Value() and not mainMenu.Drawings.drawE:Value() then
DrawDmgOverHpBar(enemy,GetCurrentHP(enemy),truepoi sonDMG,0,0xffff00ff)
end
end
end
end

-- Draw R
if mainMenu.Drawings.drawR:Value() and CanUseSpell(myHero,_R) == READY and ValidTarget(target,2000) then
DrawCircle(GetOrigin(myHero),900,0,mainMenu.Drawin gs.Quality:Value(),ARGB(100,33,139,6))
end

end)

OnTick(function(myHero)

local target = GetCurrentTarget()
local myHeroPos = GetOrigin(myHero)

-- Items
local CutBlade = GetItemSlot(myHero,3144)
local bork = GetItemSlot(myHero,3153)
local ghost = GetItemSlot(myHero,3142)
local redpot = GetItemSlot(myHero,2140)

-- Use Items
if mainMenu.Combo.Combo1:Value() then
if CutBlade >= 1 and ValidTarget(target,550+50) and mainMenu.Items.useCut:Value() then
if CanUseSpell(myHero,GetItemSlot(myHero,3144)) == READY then
CastTargetSpell(target, GetItemSlot(myHero,3144))
end
elseif bork >= 1 and ValidTarget(target,550+50) and (GetMaxHP(myHero) / GetCurrentHP(myHero)) >= 1.25 and mainMenu.Items.useBork:Value() then
if CanUseSpell(myHero,GetItemSlot(myHero,3153)) == READY then
CastTargetSpell(target,GetItemSlot(myHero,3153))
end
end

if ghost >= 1 and ValidTarget(target,GetRange(myHero)+50) and mainMenu.Items.useGhost:Value() then
if CanUseSpell(myHero,GetItemSlot(myHero,3142)) == READY then
CastSpell(GetItemSlot(myHero,3142))
end
end

if redpot >= 1 and ValidTarget(target,GetRange(myHero)+50) and mainMenu.Items.useRedPot:Value() then
if CanUseSpell(myHero,GetItemSlot(myHero,2140)) == READY then
CastSpell(GetItemSlot(myHero,2140))
end
end
end

-- Combo
if mainMenu.Combo.Combo1:Value() and ValidTarget(target, 1500) then

if mainMenu.Combo.useW:Value() and ValidTarget(target, 1500) and CanUseSpell(myHero,_W) == READY then
local WPred = GetPredictionForPlayer(myHeroPos,target,GetMoveSpe ed(target),1400,250,940,220,false,true)
if WPred.HitChance == 1 then
CastSkillShot(_W,WPred.PredPos.x,WPred.PredPos.y,W Pred.PredPos.z)
end
end

if mainMenu.Combo.useE:Value() and ValidTarget(target,1200) and CanUseSpell(myHero,_E) == READY and PassiveStacks[GetNetworkID(target)] == 6 then
CastSpell(_E)
end

end


if ValidTarget(GetCurrentTarget(), 2000) then
for i,enemy in pairs(GetEnemyHeroes()) do
if PassiveStacks[GetNetworkID(enemy)] ~= nil then
if CanUseSpell(myHero,_E) == READY then
eDMG = CalcDamage(myHero,enemy,(15*GetCastLevel(myHero,_E )+5+(5*GetCastLevel(myHero,_E)+10+(0.2*GetBonusAP( myHero)+0.25*GetBonusDmg(myHero)))*PassiveStacks[GetNetworkID(enemy)]),0)
else eDMG = 0 end
end
-- Posion-Damage
if PassiveApply[GetNetworkID(enemy)] ~= nil and pDMG ~= nil and PassiveStacks[GetNetworkID(enemy)] > 0 and PassiveApply[GetNetworkID(enemy)] > 0 then
local p = GetGameTimer() - PassiveApply[GetNetworkID(enemy)]
local pp = 6 - p
truepoisonDMG = (((pDMG/6) * PassiveStacks[GetNetworkID(enemy)]) * pp -(GetHPRegen(enemy)* pp ))
end
end
end

-- Killsteal E
if mainMenu.Killsteal.ksE:Value() and eDMG ~= nil then
for i,enemy in pairs(GetEnemyHeroes()) do
if CanUseSpell(myHero,_E) == READY and ValidTarget(enemy, 1200) and GetCurrentHP(enemy) + GetDmgShield(enemy) < eDMG and mainMenu.Killsteal.ksE:Value() then
CastSpell(_E)
end

if CanUseSpell(myHero,_E) == READY and ValidTarget(enemy, 1200) and truepoisonDMG ~= nil and GetCurrentHP(enemy) + GetDmgShield(enemy) < eDMG + truepoisonDMG and mainMenu.Killsteal.ksE:Value() and mainMenu.Killsteal.ksEp:Value() then
CastSpell(_E)
end
end
end

-- Recall
if mainMenu.Misc.iR:Value() then
if CanUseSpell(myHero,_Q) == READY then
if mainMenu.Misc.recall:Value() then
CastSpell(_Q)
DelayAction(function()
CastSpell(RECALL)
end, 10)
end
end
end

end)
Nice tutorial, That Will help some people for sure.
Damn i wanna learn this but its hard af
Awesome buddy, thanks for the tutorial!

How long did it take for you to compile this?
Quote Originally Posted by Democritus View Post
Awesome buddy, thanks for the tutorial!

How long did it take for you to compile this?
I've made multiple others so not to long around an hour. But the asset files took me much longer.


Edit: Since the platform I use to run these scripts has a advertisement on it I am working on my own so I can release it here and hopefully try to revive this section a little more.
I dont get how coding works ? so you make your own word like

Killsteal and PressW and its just magicaly works ?
Quote Originally Posted by EternalGamerz View Post
I dont get how coding works ? so you make your own word like

Killsteal and PressW and its just magicaly works ?
No, Kill Steal is a function. It gets information like player HP and if that HP drops however low it will press E or whatever key to kill the player when it is enough damage to do so.
Meh... kinda shitty tutorial.
Nice!!!!!!!!!! Very helpfull, with what program do u make this?
Quote Originally Posted by Miniature View Post
Nice!!!!!!!!!! Very helpfull, with what program do u make this?
I just use Notepad++
Quote Originally Posted by Law View Post


I just use Notepad++
Ok thanks.

MainMenu.Combo:Boolean("UseW", "Use W In Combo", True)
MainMenu.Combo:Boolean("UseE", "E At Max Stacks", True)

What does that Boolean mean? I'm new to this srry.
Quote Originally Posted by Miniature View Post
Ok thanks.

MainMenu.Combo:Boolean("UseW", "Use W In Combo", True)
MainMenu.Combo:Boolean("UseE", "E At Max Stacks", True)

What does that Boolean mean? I'm new to this srry.
A binary variable, saying "Yes" use W in combo

and "Yes" use E At Max stacks
very helpful
but i still dont understand coding..
do you have recommended videos?
Quote Originally Posted by dandan1331 View Post
very helpful
but i still dont understand coding..
do you have recommended videos?
Yeah, will give you the basics to LUA.
Posts 1–15 of 19 · Page 1 of 2

Post a Reply

Similar Threads

Tags for this Thread

None

Need help?