-
In the meantime, here's the contents of XenoLuaLib.lua located in Program Files/Xenobot/Data
EDIT: Woah, that's long. D:
Code:
-- UTILITIES
------------
--Numpad math
VK_MULTIPLY = 0x6A
VK_ADD = 0x6B
VK_SUBTRACT = 0x6D
VK_DIVIDE = 0x6F
--FKeys
VK_F1 = 0x70
VK_F2 = 0x71
VK_F3 = 0x72
VK_F4 = 0x73
VK_F5 = 0x74
VK_F6 = 0x75
VK_F7 = 0x76
VK_F8 = 0x77
VK_F9 = 0x78
VK_F10 = 0x79
VK_F11 = 0x7A
VK_F12 = 0x7B
VK_F13 = 0x7C
VK_F14 = 0x7D
VK_F15 = 0x7E
VK_F16 = 0x7F
VK_F17 = 0x80
VK_F18 = 0x81
VK_F19 = 0x82
VK_F20 = 0x83
VK_F21 = 0x84
VK_F22 = 0x85
VK_F23 = 0x86
VK_F24 = 0x87
--Home, insert, etc
VK_PRIOR = 0x21
VK_NEXT = 0x22
VK_INSERT = 0x2D
VK_DELETE = 0x2E
VK_END = 0x23
VK_HOME = 0x24
--Skull types
SKULL_WHITE = 1
SKULL_RED = 4
SKULL_ORANGE = 2
SKULL_YELLOW = 3
SKULL_BLACK = 5
--Party shield types
PARTY_YELLOW = 1
PARTY_YELLOW_SHAREDEXP = 2
PARTY_YELLOW_NOSHAREDEXP_BLINK = 3
PARTY_YELLOW_NOSHAREDEXP = 4
PARTY_BLUE = 1
PARTY_BLUE_SHAREDEXP = 2
PARTY_BLUE_NOSHAREDEXP_BLINK = 3
PARTY_BLUE_NOSHAREDEXP = 4
PARTY_WHITEBLUE = 5
PARTY_WHITEYELLOW = 6
--War shit
WAR_ENEMY = 1
WAR_ALLY = 2
WAR_INWAR = 3
function isPositionAdjacent(pos1, pos2)
return (math.abs(pos1.x - pos2.x) <= 1 and math.abs(pos1.y - pos2.y) <= 1 and pos1.z == pos2.z)
end
function getDistanceBetween(pos1, pos2)
return math.sqrt(math.abs(pos1.x - pos2.x) ^ 2 + math.abs(pos1.y - pos2.y) ^ 2)
end
function wait(a, b)
if not b then sleep(a) else sleep(math.random(a, b)) end
end
----------------------------------------------------------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------- CREATURE CLASS ----------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------------------------------------------------------
Creature = {}
Creature.__index = Creature
function Creature.GetByName(name)
local c = {}
setmetatable(c, Creature)
c._name = name
c._id = getCreatureID(name)
c._listindex = getCreatureListIndex(c._id)
return c
end
function Creature.GetByID(id)
local c = {}
setmetatable(c, Creature)
c._id = id
c._listindex = getCreatureListIndex(id)
c._name = getCreatureName(c._listindex)
return c
end
function Creature.GetFromIndex(index)
return Creature.GetByID(getCreatureIDFromIndex(index))
end
---------------------------------------------------
------------ Basic Properties -------------------
---------------------------------------------------
function Creature:isValid()
return (self._id > 0 and self._listindex < 1300 and self._listindex > 0)
end
function Creature:Name()
return self._name
end
function Creature:ID()
return self._id
end
function Creature:Index()
return self._listindex
end
function Creature:LookDirection()
return getCreatureLookDirection(self._listindex)
end
function Creature:Speed()
return getCreatureSpeed(self._listindex)
end
function Creature:Outfit()
return getCreatureOutfit(self._listindex)
end
function Creature:HealthPercent()
return getCreatureHealthPercent(self._listindex)
end
---------------------------------------------------
----------- Relational Properties ---------------
---------------------------------------------------
function Creature:isSelf()
return self._id == getSelfID()
end
function Creature:isTarget()
return self._id == getSelfTargetID()
end
function Creature:isFollowed()
return self._id == getSelfFollowID()
end
---------------------------------------------------
------------ Skull Properties ------------------
---------------------------------------------------
function Creature:Skull()
return getCreatureSkull(self._id)
end
function Creature:isWhiteSkull()
return self:Skull() == SKULL_WHITE
end
function Creature:isRedSkull()
return self:Skull() == SKULL_RED
end
function Creature:isOrangeSkull()
return self:Skull() == SKULL_ORANGE
end
function Creature:isYellowSkull()
return self:Skull() == SKULL_YELLOW
end
function Creature:isBlackSkull()
return self:Skull() == SKULL_BLACK
end
---------------------------------------------------
------------ Shield Properties ------------------
---------------------------------------------------
function Creature:PartyStatus()
return getCreaturePartyStatus(self._listindex)
end
function Creature:isPartyLeader()
return (self:PartyStatus() == PARTY_YELLOW or
self:PartyStatus() == PARTY_YELLOW_SHAREDEXP or
self:PartyStatus() == PARTY_YELLOW_NOSHAREDEXP_BLINK or
self:PartyStatus() == PARTY_YELLOW_NOSHAREDEXP)
end
function Creature:isPartyMember()
return (Creature:isPartyLeader() or
self:PartyStatus() == PARTY_BLUE or
self:PartyStatus() == PARTY_BLUE_SHAREDEXP or
self:PartyStatus() == PARTY_BLUE_NOSHAREDEXP_BLINK or
self:PartyStatus() == PARTY_BLUE_NOSHAREDEXP)
end
function Creature:isInvitedToParty()
return self:PartyStatus() == PARTY_WHITEBLUE
end
function Creature:isInvitingToParty()
return self:PartyStatus() == PARTY_WHITEYELLOW
end
function Creature:isSharingExp()
return (self:PartyStatus() == PARTY_BLUE_SHAREDEXP or
self:PartyStatus() == PARTY_YELLOW_SHAREDEXP)
end
---------------------------------------------------
------------ War Properties ------------------
---------------------------------------------------
function Creature:WarIcon()
return getCreatureWarIcon(self._listindex)
end
function Creature:isWarEnemy()
return self:WarIcon() == WAR_ENEMY
end
function Creature:isWarAlly()
return self:WarIcon() == WAR_ALLY
end
function Creature:isInWar()
return (self:WarIcon() == WAR_INWAR or self:isWarAlly() or self:isWarEnemy())
end
---------------------------------------------------
---------- Location Properties ---------------
---------------------------------------------------
function Creature:Position()
return getCreaturePosition(self._listindex)
end
function Creature:isReachable()
return "Not implemented"-- isPathFound(self:Position())
end
function Creature:isAdjacent()
return isPositionAdjacent(self:Position(), getSelfPosition())
end
function Creature:isOnScreen()
local selfloc = getSelfPosition()
local thisloc = self:Position()
return (math.abs(selfloc.x - thisloc.x) <= 7 and
math.abs(selfloc.y - thisloc.y) <= 5
and selfloc.z == thisloc.z)
end
function Creature:isAlive()
return getCreatureHealthPercent(self._listindex) > 0
end
function Creature:isVisible()
return getCreatureVisible(self._listindex)
end
function Creature:DistanceFromSelf()
return getDistanceBetween(self:Position(), getSelfPosition())
end
----------------------------------------------------------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------- Container CLASS ----------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------------------------------------------------------
Container = {}
Container.__index = Container
function Container.GetFirst()
return Container.GetNextOpen(-1)
end
function Container.GetNextOpen(index)
local found = false
while (found == false and index < 16) do
index = index + 1
found = getContainerOpen(index)
end
if (found == false) then
index = -1
end
return Container.GetFromIndex(index)
end
function Container.GetByName(name)
local index = -1
while (index < 16) do
index = index + 1
if (getContainerOpen(index)) then
if (getContainerName(index) == name) then
return Container.GetFromIndex(index)
end
end
end
return Container.GetFromIndex(-1)
end
function Container.GetFromIndex(index)
local c = {}
setmetatable(c, Container)
if (getContainerOpen(index)) then
c._index = index
else
c._index = -1
end
return c
end
---------------------------------------------------
------------ Basic Functions -------------------
---------------------------------------------------
function Container:GetNext()
return Container.GetNextOpen(self._index)
end
function Container:Index()
return self._index
end
function Container:ID()
return getContainerID(self._index)
end
function Container:Name()
return getContainerName(self._index)
end
function Container:ItemCount()
return getContainerItemCount(self._index)
end
function Container:ItemCapacity()
return getContainerItemCapacity(self._index)
end
function Container:isOpen()
return getContainerOpen(self._index)
end
---------------------------------------------------
------------ Working With Items ---------------
---------------------------------------------------
function Container:CountItemsOfID(id)
local count = 0
for spot = 0, self:ItemCount() do
local item = self:GetItemData(spot)
if (item.id == id) then
count = count + item.count
end
end
return count
end
function Container:GetItemData(spot)
return getContainerSpotData(self._index, spot)
end
function Container:UseItem(spot)
return containerUseItem(self._index, spot)
end
function Container:UseItemWithGround(spot, x, y, z)
return containerUseItemWithGround(self._index, spot, x, y, z)
end
function Container:UseItemWithCreature(spot, id)
return containerUseItemWithCreature(self._index, spot, id)
end
function Container:MoveItemToEquipment(spot, slot)
return containerMoveItemToSlot(self._index, spot, slot)
end
function Container:MoveItemToGround(spot, x, y, z)
return containerMoveItemToGround(self._index, spot, x, y, z)
end
function Container:MoveItemToContainer(spotfrom, containerto, spotto)
return containerMoveItemToContainer(self._index, spotfrom, containerto, spotto)
end
----------------------------------------------------------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------- SELF CLASS ----------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------------------------------------------------------
Self = {}
Self.Say = selfSay
Self.Yell = selfYell
Self.Whisper = selfWhisper
Self.SayToNpc = selfNpcSay
Self.ID = getSelfID
Self.TargetID = getSelfTargetID
Self.FollowID = getSelfFollowID
Self.Position = getSelfPosition
Self.LookDirection = getSelfLookDirection
Self.Speed = getSelfSpeed
Self.Outfit = getSelfOutfit
Self.Skull = getSelfSkull
Self.PartyStatus = getSelfPartyStatus
Self.WarIcon = getSelfWarIcon
Self.MaxHealth = getSelfMaxHealth
Self.Health = getSelfHealth
Self.MaxMana = getSelfMaxMana
Self.Mana = getSelfMana
Self.Experience = getSelfExperience
Self.Level = getSelfLevel
Self.Cap = getSelfCap
Self.UseItem = selfUseItem
Self.UseItemFromGround = selfUseItemFromGround
Self.UseItemWithGround = selfUseItemWithGround
Self.UseItemWithCreature = selfUseItemWithCreature
Self.UseItemFromMyPosition = function ()
return Self.UseItemFromGround(Self.Position().x, Self.Position().y, Self.Position().z)
end
Self.UseItemWithMyPosition = function (id)
return Self.UseItemWithGround(id, Self.Position().x, Self.Position().y, Self.Position().z)
end
Self.UseItemWithMe = function (id)
return Self.UseItemWithCreature(id, Self.ID())
end
Self.UseItemWithTarget = function (id)
return Self.UseItemWithCreature(id, Self.TargetID())
end
Self.UseItemWithFollow = function (id)
return Self.UseItemWithCreature(id, Self.FollowID())
end
Self.Head = getHeadSlotData
Self.Armor = getArmorSlotData
Self.Legs = getLegsSlotData
Self.Feet = getFeetSlotData
Self.Amulet = getAmuletSlotData
Self.Weapon = getWeaponSlotData
Self.Ring = getRingSlotData
Self.Backpack = getBackpackSlotData
Self.Shield = getShieldSlotData
Self.Ammo = getAmmoSlotData
----------------------------------------------------------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------- TABLE CLASS ----------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------------------------------------------------------
table.append = table.insert
table.empty = function (t)
return next(t) == nil
end
table.size = function (t)
return #t
end
table.find = function (table, value, sensitive)
local sensitive = sensitive or true
if(not sensitive and type(value) == "string") then
for i, v in pairs(table) do
if(type(v) == "string") then
if(v:lower() == value:lower()) then
return i
end
end
end
return nil
end
for i, v in pairs(table) do
if(v == value) then
return i
end
end
return nil
end
table.contains = function (txt, str)
for i, v in pairs(str) do
if(txt:find(v) and not txt:find('(%w+)' .. v) and not txt:find(v .. '(%w+)')) then
return true
end
end
return false
end
table.isStrIn = table.contains
table.count = function (table, item)
local count = 0
for i, n in pairs(table) do
if(item == n) then
count = count + 1
end
end
return count
end
table.countElements = table.count
table.getCombinations = function (table, num)
local a, number, select, newlist = {}, #table, num, {}
for i = 1, select do
a[#a + 1] = i
end
local newthing = {}
while(true) do
local newrow = {}
for i = 1, select do
newrow[#newrow + 1] = table[a[i]]
end
newlist[#newlist + 1] = newrow
i = select
while(a[i] == (number - select + i)) do
i = i - 1
end
if(i < 1) then
break
end
a[i] = a[i] + 1
for j = i, select do
a[j] = a[i] + j - i
end
end
return newlist
end
function table.serialize(x, recur)
local t = type(x)
recur = recur or {}
if(t == nil) then
return "nil"
elseif(t == "string") then
return string.format("%q", x)
elseif(t == "number") then
return tostring(x)
elseif(t == "boolean") then
return t and "true" or "false"
elseif(getmetatable(x)) then
error("Can not serialize a table that has a metatable associated with it.")
elseif(t == "table") then
if(table.find(recur, x)) then
error("Can not serialize recursive tables.")
end
table.append(recur, x)
local s = "{"
for k, v in pairs(x) do
s = s .. "[" .. table.serialize(k, recur) .. "]" .. " = " .. table.serialize(v, recur) .. ", "
end
return s:sub(0, s:len() - 2) .. "}"
end
error("Can not serialize value of type '" .. t .. "'.")
end
function table.unserialize(str)
return loadstring("return " .. str)()
end