Log in

View Full Version : Lua Scripts



Mexen
11-22-2015, 01:45 PM
I used the wayback machine and found some old scripts that may still be useful now.
If there are any errors with them. Let me know and I will remove them.

Universal Ring Equip
--[[
valid flags:
strenghthened
hasted mshielded paralyzed
poisoned burning electrified
cursed freezing drunk
drowning dazzled bleeding
inbattle ispzlocked inpz

params:
RING - Item name or id to equip
PRIO - First list to check
PVET - Creature list to consider
PVPT - Player list to whitelist
SKUL - Count only skulled players
PVER - Creature radius from self
PVPR - Player radius from self
CCOU - Creature count to trigger equip
PCOU - Player count to trigger equip
HPPC - Health percent to trigger equip {MIN, MAX}
MPPC - Mana percent to trigger equip {MIN, MAX}
FLAG - Flag to trigger equip
]]--

local SETTING = {
{
RING = "Crystal Ring", PRIO = 10, PVET = {}, PVPT = {}, SKUL = true, PVER = 5,
PVPR = 5, CCOU = 10, PCOU = 10, HPPC = {95, 100}, MPPC = {95, 100}, FLAG = {"inpz"}
},
{
RING = "Life Ring", PRIO = 20, PVET = {}, PVPT = {}, SKUL = true, PVER = 5,
PVPR = 5, CCOU = 10, PCOU = 10, HPPC = {70, 95}, MPPC = {40, 95}, FLAG = {}
},
{
RING = "Energy Ring", PRIO = 30, PVET = {"Water Elemental", "Quara Mantassin Scout"}, PVPT = {},
SKUL = true, PVER = 7, PVPR = 5, CCOU = 3, PCOU = 2, HPPC = {0, 70}, MPPC = {10, 40}, FLAG = {"paralyzed"}
}
}

table.sort(SETTING, function(A, B) return A.PRIO > B.PRIO end)
for i = 1, #SETTING do
SETTING[i]["RING"] = Item.GetItemIDFromDualInput(SETTING[i]["RING"])
if (SETTING[i]["PVET"] ~= nil) then
for j = 1, #SETTING[i]["PVET"] do
SETTING[i]["PVET"][j] = SETTING[i]["PVET"][j]:lower()
end
end
if (SETTING[i]["PVPT"] ~= nil) then
for j = 1, #SETTING[i]["PVPT"] do
SETTING[i]["PVPT"][j] = SETTING[i]["PVPT"][j]:lower()
end
end
if (SETTING[i]["FLAG"] ~= nil) then
for j = 1, #SETTING[i]["FLAG"] do
SETTING[i]["FLAG"][j] = SETTING[i]["FLAG"][j]:lower()
end
end
end

local flag = {["hasted"] = false, ["mshielded"] = false, ["paralyzed"] = false, ["poisoned"] = false, ["burning"] = false, ["electrified"] = false, ["cursed"] = false, ["freezing"] = false, ["drunk"] = false, ["drowning"] = false, ["dazzled"] = false, ["bleeding"] = false, ["inbattle"] = false, ["ispzlocked"] = false, ["inpz"] = false, ["strenghthened"] = false}

function Self.HPPC()
return math.ceil((Self.Health() * 100 / Self.MaxHealth()))
end

function Self.MPPC()
return math.ceil((Self.Mana() * 100 / Self.MaxMana()))
end

function PlayersAround(skullOnly, whitelist, radius)
local k = 0
for name, creature in Creature.iPlayers({distancefromself = {lt, radius}}) do
if not table.contains(whitelist, name:lower()) then
if (skullOnly) then
if table.contains({1, 2, 3, 4, 5}, creature:Skull()) then
k = k + 1
end
else
k = k + 1
end
end
end
return k
end

function MonstersAround(list, radius)
local k = 0
for name, creature in Creature.iMonsters({distancefromself = {lt, radius}}) do
if (list ~= nil) then
if table.contains(list, name:lower()) then
k = k + 1
end
else
k = k + 1
end
end
return k
end

function equipRing(id)
if (Self.Ring().id ~= Item.GetRingActiveID(id)) then
return Self.Equip(id, "ring")
end
end

function ringTrigger(list)
for i = 1, #list do
if (list[i]["FLAG"] ~= nil and Self.ItemCount(list[i]["RING"]) > 0) then
for j = 1, #list[i]["FLAG"] do
if (flag[list[i]["FLAG"][j]]) then
return equipRing(list[i]["RING"])
end
end
end
end
for i = 1, #list do
if (list[i]["PVET"] ~= nil and Self.ItemCount(list[i]["RING"]) > 0) then
if MonstersAround(list[i]["PVET"], list[i]["PVER"]) >= list[i]["CCOU"] then
return equipRing(list[i]["RING"])
end
end
end
for i = 1, #list do
if (list[i]["PVPT"] ~= nil and Self.ItemCount(list[i]["RING"]) > 0) then
if PlayersAround(list[i]["SKUL"], list[i]["PVPT"], list[i]["PVPR"]) >= list[i]["PCOU"] then
return equipRing(list[i]["RING"])
end
end
end
for i = 1, #list do
if (Self.MPPC() >= list[i]["MPPC"][1] and Self.MPPC() < list[i]["MPPC"][2] and Self.ItemCount(list[i]["RING"]) > 0) then
return equipRing(list[i]["RING"])
end
end
for i = 1, #list do
if (Self.HPPC() >= list[i]["HPPC"][1] and Self.HPPC() < list[i]["HPPC"][2] and Self.ItemCount(list[i]["RING"]) > 0) then
return equipRing(list[i]["RING"])
end
end
end

Module.New("Flag", function(mod)
flag = {["hasted"] = getSelfFlag("hasted"), ["mshielded"] = getSelfFlag("mshielded"), ["paralyzed"] = getSelfFlag("paralyzed"), ["poisoned"] = getSelfFlag("poisoned"), ["burning"] = getSelfFlag("burning"), ["electrified"] = getSelfFlag("electrified"), ["cursed"] = getSelfFlag("cursed"), ["freezing"] = getSelfFlag("freezing"), ["drunk"] = getSelfFlag("drunk"), ["drowning"] = getSelfFlag("drowning"), ["dazzled"] = getSelfFlag("dazzled"), ["bleeding"] = getSelfFlag("bleeding"), ["inbattle"] = getSelfFlag("inbattle"), ["ispzlocked"] = getSelfFlag("ispzlocked"), ["inpz"] = getSelfFlag("inpz"), ["strenghthened"] = getSelfFlag("strenghthened")}
mod:Delay(5000)
end)

Module.New("UniversalRingEquip", function(mod)
ringTrigger(SETTING)
mod:Delay(1000)
end)

Manual Speed Looter
local CONFIG = {
{BP = 'Green Backpack', -- BP name or index
LIST =
{'glooth blade', 'glooth club', 'glooth axe', 'small diamond', 'guardian shield', 'glooth amulet',
'red piece of cloth', 'blue piece of cloth', 'green piece of cloth', 'knight armor',
'underworld rod', 'purple robe', 'small topaz', 'small emerald', 'small ruby', 'cowtana',
'small amethyst', 'poisoned fang', 'minotaur horn', 'minotaur leather', 'knight legs',
'slime heart', 'soul orb', 'mooh\'tah shell', 'mooh\'tah plate', 'small sapphire', 'mino shield'}},
{BP = 2, -- BP name or index
LIST =
{'platinum coin'}}
}

for i = 1, #CONFIG do
for j = 1, #CONFIG[i]['LIST'] do
CONFIG[i]['LIST'][j] = Item.GetItemIDFromDualInput(CONFIG[i]['LIST'][j])
end
end

local bodies = {'The', 'Demonic', 'Dead', 'Slain', 'Dissolved', 'Remains', 'Elemental'}

function Container:isFull(id)
for spot = 0, self:ItemCount()-1 do
local data = self:GetItemData(spot)
if (isItemStackable(id) and data.id == id and data.count ~= 100) then
return false
elseif not isItemStackable(id) then
return getContainerItemCount(self._index) == getContainerItemCapacity(self._index)
end
end
end

while (true) do
for i = #Container.GetAll()-1, 0, -1 do
local c = Container.New(i)
if (c:isOpen() and table.contains(bodies, string.match(c:Name(), '%a+'))) then
for j = 1, #CONFIG do
for spot = c:ItemCount()-1, 0, -1 do
local spotData = c:GetItemData(spot)
if table.contains(CONFIG[j]['LIST'], spotData.id) then
local desti = Container.New(CONFIG[j]['BP'])
if (Self.Cap() > (Item.GetWeight(spotData.id)*spotData.count) and not desti:isFull(spotData.id)) then
if isItemStackable(spotData.id) then
c:MoveItemToContainer(spot, desti:Index(), 0)
else
c:MoveItemToContainer(spot, desti:Index(), desti:ItemCount())
end
elseif (desti:isFull(spotData.id) and Item.isContainer(desti:GetItemData(desti:ItemCount ()-1).id)) then
desti:UseItem(desti:ItemCount()-1, true)
end
end
end
end
end
end
wait(400)
end

If X Monsters use energy ring

local config = {
monsterLimit = 3,
monsterList = {"Banshee", "Necromancer", "Lich", "Vampire", "Vampire Bride"},
EnergyRingID = 3051, --Energy Ring ID
SecondRingID = 3052, -- Life Ring or what ever ring you want to use instead .. if nothing leave it that way
TrashRingID = 3007 -- Change to the ring you are wearing as standard.. Crystal Ring/Golden Ring??
}
function getMonsterCount()
local count = 0
for i = CREATURES_LOW, CREATURES_HIGH do
local creature = Creature.GetFromIndex(i)
if (creature:isValid()) and creature:ID() ~= Self.ID() then
if (creature:isOnScreen() and creature:isVisible() and creature:isAlive()) then
local name = creature:Name()
if(table.find(config.monsterList, name, true))then
count = count + 1
end
end
end
end
return count
end
while(true)do
local curRing = Self.Ring().id
local eneRing = getActiveRingID(config.EnergyRingID)
local secRing = getActiveRingID(config.SecondRingID)
if (getMonsterCount() >= config.monsterLimit and curRing ~= eneRing) then
Self.Equip(config.EnergyRingID, "ring")
elseif (getMonsterCount() < config.monsterLimit) then
if ((Self.ItemCount(config.SecondRingID) > 0 or Self.ItemCount(secRing) > 0) and curRing ~= secRing) then
Self.Equip(config.SecondRingID, "ring")
elseif ((Self.ItemCount(config.SecondRingID) < 1 and Self.ItemCount(secRing) < 1) and curRing ~= TrashRingID) then
Self.Equip(config.TrashRingID, "ring")
end
end
sleep(400)
end

If X Monster is on screen use stealth ring

local RingID = 3049 --stealth ring
local amount = 3 -- monster amount to put ring on
local range = 4 -- range to consider when looking for monster on screen (NO MORE THAN 7!)
local monsterList =
{
'Corym Charlatan',
'Corym Skirmisher',
'Corym Vanguard'
}

function getMonsterCount2()
local count = 0
for k, v in ipairs(Self.GetTargets(range)) do
if table.find(monsterList, v:Name()) then
count = count + 1
end
end
return count
end

function stealthring()
if getMonsterCount2() >= amount and Self.Ring().id ~= getActiveRingID(RingID) and Self.ItemCount(RingID) >= 1 then
Self.Equip(RingID, "ring")
elseif getMonsterCount2() < 3 and Self.Ring().id == getActiveRingID(RingID) then
Self.Dequip("ring")
end
end

Module('StealthRing', function(stealth)
stealthring()
stealth:Delay(200 * math.random(1,3))
end)

Use Life ring when x mana

local RingID = 3052

Module('life shit', function(mod)
if Self.Ring().id ~= 3089 and Self.ItemCount(RingID) >= 1 and (not Self.isInPz()) and (Self.Mana() < Self.MaxMana()*(85/100)) then
Self.Equip(RingID, "ring")
elseif Self.isInPz() or (Self.Mana() > Self.MaxMana()*(90/100)) then
Self.Dequip("ring")
end
mod:Delay(2000)
end)

I DID NOT MAKE THESE SCRIPTS - CREDITS TO THE CREATORS. IF YOU MADE THEM, LET ME KNOW I WILL ADD CREDITS. SOME MAY BE BUGGED WITH NEW XENOBOT BINARY. LET ME KNOW AND I WILL REMOVE.

shadowart
11-22-2015, 02:23 PM
The first 5 snippets are good examples of the kind of stuff we wanted to get rid of when we purged the forum. I'd rather see they remain hidden.

Although I can understand if some people feel the universal ring equipper is a bit too universal and hard to understand, it still feels redundant to include 3 other rings equipper. And perhaps even worse, the different ring equippers aren't going to play nicely with each other. The energy ring one also features a very bad way of counting monsters that we don't want to spread.

I've also edited your post to use xcode tags instead of code ones. This preserves syntax highlighting and adds a scroll pane instead of introducing artificial, and poorly placed, line breaks.

Mexen
11-22-2015, 03:29 PM
The first 5 snippets are good examples of the kind of stuff we wanted to get rid of when we purged the forum. I'd rather see they remain hidden.

Although I can understand if some people feel the universal ring equipper is a bit too universal and hard to understand, it still feels redundant to include 3 other rings equipper. And perhaps even worse, the different ring equippers aren't going to play nicely with each other. The energy ring one also features a very bad way of counting monsters that we don't want to spread.

I've also edited your post to use xcode tags instead of code ones. This preserves syntax highlighting and adds a scroll pane instead of introducing artificial, and poorly placed, line breaks.

If the staff prefers they were not brought back then feel free to take them off.
Thanks for the xcode edit I couldn't remember it.

zxzero
08-22-2016, 08:29 PM
Stealth ring one works decent. Thanks!