Format d'un step
{
map = "x,y", -- map a matcher (requis) ou "mapId"
path = "right", -- direction ou cellId ou "zaap(mapId)"
gather = true, -- recolter
fight = true, -- combattre
npcBank = true, -- deposer en banque (true=auto, number=npc cellId)
sale = true, -- vendre HDV
custom = function() end, -- action personnalisee
phoenix = true, -- utiliser statue phenix
fightManagement = function() end, -- IA de combat custom
prefightManagement = function(myCells, enemyCells) end, -- callback de placement
}
Route — fightManagement
bot.route({
{
map = "5,-24",
path = "right",
fight = true,
-- Phase de placement : choisir la cellule la plus eloignee des ennemis
prefightManagement = function(myCells, enemyCells)
local bestCell = myCells[1]
local bestDist = 0
for _, cell in ipairs(myCells) do
local nearest = bot.getNearestEnemy()
if nearest then
local d = bot.cellDistance(cell, nearest.cell)
if d > bestDist then
bestDist = d
bestCell = cell
end
end
end
bot.chooseCell(bestCell)
bot.fightReady()
end,
-- IA de combat custom : appelee chaque tour
fightManagement = function()
local enemy = bot.getNearestEnemy()
if not enemy then
bot.endTurn()
return
end
-- Lancer sort 3 tant qu'on peut
while bot.canCastSpellOnCell(3, enemy.cell) == "ok" do
bot.castSpell(3, enemy.cell)
sleep(0.3)
end
bot.endTurn()
end,
},
})
Evenements
bot.on("event", callback)
bot.once("event", callback)
Evenements
bot.on("fightEnded", function(result)
log("Combat termine !")
end)
bot.on("levelUp", function(info)
log("Level up !")
end)
Utilitaires
sleep(3) -- pause 3 secondes
bot.sleep(1500) -- pause 1500ms
log("Message") -- raccourci pour bot.log
Memoire de session
bot.memorySet("compteur", 0)
local c = bot.memoryGet("compteur")
bot.memorySet("compteur", c + 1)
Mort / Fantome / Phoenix
-- Route phoenix (revive automatique)
bot.setPhoenixRoute({
{ map = "5,-17", path = "bottom" },
{ map = "5,-16", phoenix = true },
})
-- Verifier si mort
if bot.isGhost() then
log("Bot est un fantome !")
end
Configuration Recolte
-- Ne recolter que le ble et le houblon
bot.setGatherList({"Ble", "Houblon"})
Paquets bruts
bot.onPacket("Im", function(data)
log("Paquet Im recu: " .. data)
end)
Exchange (Echange joueur)
bot.exchangeRequestByName("NomJoueur")
local senderId = bot.waitForExchangeRequest(30000)
bot.putItem(289, 5) -- mettre item
bot.putKamas(1000)
bot.exchangeGetItem(289, 5) -- recuperer item
bot.exchangeReady()
bot.acceptExchange()
-- ou: bot.refuseExchange() / bot.exchangeLeave()
Memory (Session)
bot.memorySet("key", value)
local v = bot.memoryGet("key")
bot.memoryHas("key") -- boolean
bot.memoryDelete("key")
Challenges / Invocations (Combat)
-- Dans fightManagement
if bot.hasChallenges() then
local c = bot.getActiveChallenges()
end
if bot.summonCount() < bot.summonMax() then
bot.summon(34, cells[1])
end
Syntaxe
-- Definir une fonction (end obligatoire)
function maFonction()
bot.log("Hello !")
end
-- Appeler
maFonction()
Avec parametres
function farmMap(direction, combattre)
bot.changeMap(direction)
if combattre and bot.hasMonstersOnMap() then
bot.fight()
bot.waitForFightEnd()
end
end
farmMap("right", true)
farmMap("bottom", false)
Avec retour
function doitAllerBanque()
return bot.isPodsFull(0.8) or bot.kamas() > 50000
end
if doitAllerBanque() then
bot.bankRoute()
end
Fonctions dans une route
function checkEtFarm()
if bot.hpPercent() < 50 then
bot.log("PV bas, on attend la regen")
bot.sit()
bot.waitForRegen()
end
if bot.hasMonstersOnMap() then
bot.fight()
bot.waitForFightEnd()
end
end
bot.route({
{ map = "5,-19", path = "right", custom = checkEtFarm },
{ map = "6,-19", path = "bottom", custom = checkEtFarm },
})
Fonction de combat reutilisable
function monIA()
local enemy = bot.getNearestEnemy()
if not enemy then bot.endTurn() return end
-- Sort principal
while bot.canCastSpellOnCell(161, enemy.cell) == "ok" do
bot.castSpell(161, enemy.cell)
sleep(0.3)
end
-- Se rapprocher si possible
if bot.myMP() > 0 then
bot.moveToward(enemy.id)
end
bot.endTurn()
end
bot.route({
{ map = "5,-19", path = "right", fight = true, fightManagement = monIA },
{ map = "6,-19", path = "bottom", fight = true, fightManagement = monIA },
{ map = "6,-18", path = "left", fight = true, fightManagement = monIA },
})
Variables globales entre fonctions
totalKamas = 0
function compterKamas()
local avant = bot.kamas()
bot.fight()
bot.waitForFightEnd()
local gain = bot.kamas() - avant
totalKamas = totalKamas + gain
bot.log("Gain: " .. gain .. " | Total: " .. totalKamas)
end
Boucle avec fonction
function farmNFois(n)
for i = 1, n do
bot.log("Combat " .. i .. "/" .. n)
if bot.hasMonstersOnMap() then
bot.fight()
bot.waitForFightEnd()
end
if bot.isPodsFull() then
bot.bankRoute()
end
sleep(1)
end
end
farmNFois(50)
Monture
| Propiedad / Método | Tipo | Descripción |
|---|
| bot.hasMount() | boolean | Monture equipee ? |
| bot.isRiding() | boolean | Monte ? |
| bot.toggleRide() | void | Monter/descendre |
| bot.setMountXp(percent) | void | % XP monture (0-90) |
| bot.getMountInfo() | table\ | nil | { name, level, energy, xp, stamina, love, maturity, serenity, riding, equipped } |
| bot.feedMount(itemUid, qty?) | void | Nourrir la monture |
| bot.renameMount(name) | void | Renommer la monture |
Metiers (Jobs)
| Propiedad / Método | Tipo | Descripción |
|---|
| bot.getJobs() | table | {{ id, level, xp, xpNext }} |
| bot.jobLevel(jobId) | number | Niveau d'un metier |
Route (Trajet)
| Propiedad / Método | Tipo | Descripción |
|---|
| bot.route(steps) | void | Lancer un trajet en boucle |
| bot.setBankRoute(steps) | void | Definir le trajet banque |
| bot.bankRoute(steps?) | void | Lancer le trajet banque |
| bot.stopRoute() | void | Arreter le trajet |
| bot.stopBankRoute() | void | Arreter le trajet banque |
Evenements
| Propiedad / Método | Tipo | Descripción |
|---|
| mapChanged | () | Changement de map |
| fightStarted | (info) | Combat commence |
| fightEnded | (result) | Combat termine |
| turned | (info) | Debut d'un tour |
| actorsUpdated | () | Acteurs mis a jour |
| chatMessage | (msg) | Message chat recu |
| statsUpdated | () | Stats modifiees |
| inventoryUpdated | () | Inventaire modifie |
| dialogQuestion | (info) | Question PNJ |
| dialogClose | () | Dialogue ferme |
| exchangeOpen | () | Echange ouvert |
| exchangeClose | () | Echange ferme |
| levelUp | (info) | Level up |
Utilitaires
| Propiedad / Método | Tipo | Descripción |
|---|
| sleep(seconds) | void | Pause en secondes (bloquant) |
| bot.sleep(ms) | void | Pause en ms (bloquant) |
| bot.log(message) | void | Log dans la console |
| bot.printMessage(msg) | void | Alias log |
| bot.printError(msg) | void | Log [ERROR] |
| bot.printSuccess(msg) | void | Log [SUCCESS] |
| bot.random(min, max) | number | Entier aleatoire (inclusif) |
| bot.elapsedTime() | number | Ms depuis le debut du script |
| bot.uptime() | number | Secondes depuis le debut |
| bot.getTime() | number | Timestamp Unix (secondes) |
| bot.getTimeMs() | number | Timestamp Unix (ms) |
| bot.afterFight() | boolean | Vient de finir un combat (auto-clear) |
| bot.finishScript() | void | Arreter le script |
| bot.disconnect() | void | Deconnecter le bot |
| bot.waitForMapChange(timeout?) | string | Attend changement map |
Memoire de session
| Propiedad / Método | Tipo | Descripción |
|---|
| bot.memorySet(key, value) | void | Stocker une valeur |
| bot.memoryGet(key) | any | Recuperer une valeur |
| bot.memoryDelete(key) | void | Supprimer une valeur |
| bot.memoryHas(key) | boolean | Cle existe ? |
Mort / Fantome / Phoenix
| Propiedad / Método | Tipo | Descripción |
|---|
| bot.isGhost() | boolean | Le bot est mort (energy=0 ou mode fantome) |
| bot.setPhoenixRoute(steps) | void | Definir la route phoenix (revive auto a la mort) |
| bot.getPhoenixRoute() | table\ | nil | Route phoenix configuree |
| bot.findPhoenixCell() | number\ | nil | Trouver la cellule phoenix sur la map actuelle |
Regeneration
| Propiedad / Método | Tipo | Descripción |
|---|
| Propriete / Methode | Type | Description |
| bot.isRegenerating() | boolean | Regen HP en cours (assis) |
| bot.waitForRegen(timeout?) | void | Attendre la fin de la regen HP |
Configuration Recolte
| Propiedad / Método | Tipo | Descripción |
|---|
| bot.setGatherList(list) | void | Ressources a recolter (noms) |
| bot.getGatherList() | table | Liste actuelle |
| bot.addGatherResource(name) | void | Ajouter une ressource |
| bot.removeGatherResource(name) | void | Retirer une ressource |
| bot.setHarvestMode(mode) | void | Mode 'whitelist' ou autre |
Anti-Aggro
| Propiedad / Método | Tipo | Descripción |
|---|
| bot.setAntiAggro(enabled, distance?) | void | Activer/desactiver anti-aggro |
| bot.getAntiAggro() | boolean | Anti-aggro actif ? |
Utilitaires avances
| Propiedad / Método | Tipo | Descripción |
|---|
| bot.getUID(templateId) | string\ | nil | UID depuis un template ID |
| bot.getGID(uid) | number\ | nil | Template ID depuis un UID |
| bot.accountTag() | string | Tag du compte |
| bot.accountId() | string | ID du compte |
| bot.isSubscribed() | boolean | Abonne ? |
| bot.reconnect() | void | Reconnexion |
| bot.interactiveObjects() | table | Objets interactifs sur la map {{ cellId, gfxId }} |
| bot.getNpcIdOnCell(cellId) | string\ | nil | ID du PNJ sur une cellule |
Paquets bruts
| Propiedad / Método | Tipo | Descripción |
|---|
| bot.sendPacket(packet) | void | Envoyer un paquet brut |
| bot.onPacket(header, callback) | void | Ecouter un type de paquet |
Duel / Challenge joueur
| Propiedad / Método | Tipo | Descripción |
|---|
| bot.challengePlayer(id) | void | Defier un joueur en duel |
| bot.acceptChallenge(id?) | void | Accepter un duel |
| bot.declineChallenge(id?) | void | Refuser un duel |
| bot.cancelChallenge() | void | Annuler un duel envoye |
Stats — Boost rapide
| Propiedad / Método | Tipo | Descripción |
|---|
| bot.UpgradeStrength(pts?) | void | Boost force (+1 ou pts points) |
| bot.UpgradeVitality(pts?) | void | Boost vitalite |
| bot.UpgradeWisdom(pts?) | void | Boost sagesse |
| bot.UpgradeChance(pts?) | void | Boost chance |
| bot.UpgradeAgility(pts?) | void | Boost agilite |
| bot.UpgradeIntelligence(pts?) | void | Boost intelligence |
Items — Utilitaires
| Propiedad / Método | Tipo | Descripción |
|---|
| bot.itemWeight(templateId) | number | Poids d'un item en pods |
| bot.getUID(templateId) | string\ | nil | UID depuis template ID |
| bot.getGID(uid) | number\ | nil | Template ID depuis UID |
Abonnement
| Propiedad / Método | Tipo | Descripción |
|---|
| bot.isSubscribed() | boolean | Compte abonne ? |
| bot.subscriptionEndEpoch() | number | Date fin abo (timestamp Unix) |
Monture — Details avances
| Propiedad / Método | Tipo | Descripción |
|---|
| bot.getMountName() | string | Nom monture |
| bot.getMountLevel() | number | Niveau monture |
| bot.getMountXp() | number | XP monture |
| bot.getMountEnergy() | number | Energie monture |
| bot.getMountStamina() | number | Endurance monture |
| bot.getMountLove() | number | Amour monture |
| bot.getMountMaturity() | number | Maturite monture |
| bot.getMountSerenity() | number | Serenite monture |
| bot.getMountFecondation() | number | Fecondation monture |
| bot.setXpRatio(pct) | void | Alias setMountXp |
| bot.toggleRiding() | void | Alias toggleRide |
| bot.feed(itemUid, qty?) | void | Alias feedMount |
| bot.rename(name) | void | Alias renameMount |
Metiers — Details
| Propiedad / Método | Tipo | Descripción |
|---|
| bot.jobName(jobId) | string | Nom du metier |
| bot.jobXp(jobId) | number | XP du metier |
| bot.jobXpNext(jobId) | number | XP pour le prochain niveau |
| bot.jobXpPercent(jobId) | number | XP en % du niveau |
Fichiers & Memoire
| Propiedad / Método | Tipo | Descripción |
|---|
| bot.fileExists(path) | boolean | Fichier existe ? |
| bot.remember(key, value) | void | Alias memory.set |
| bot.addInMemory(key, value) | void | Ajouter a la memoire |
| bot.editInMemory(key, value) | void | Modifier en memoire |
| bot.deleteMemory(key) | void | Alias memory.delete |
Presets d'equipement
| Propiedad / Método | Tipo | Descripción |
|---|
| bot.createPreset(name) | void | Creer un preset |
| bot.equipPreset(name) | void | Equiper un preset |
| bot.deletePreset(name) | void | Supprimer un preset |
| bot.savePreset(name) | void | Sauvegarder le preset actuel |
Dialogue — Details
| Propiedad / Método | Tipo | Descripción |
|---|
| bot.getQuestionText() | string | Texte de la question PNJ |
| bot.getResponseTexts() | table | Textes des reponses disponibles |
| bot.respond(index) | void | Alias npcReply |
Utilitaires — Alias
| Propiedad / Método | Tipo | Descripción |
|---|
| bot.delay(ms) | void | Alias sleep |
| bot.sleep_ms(ms) | void | Alias sleep |
| bot.send(packet) | void | Alias sendPacket |
| bot.sendPM(name, msg) | void | Alias whisper |
| bot.sendReply(index) | void | Alias npcReply |
| bot.close() | void | Fermer dialogue/echange/banque |
| bot.leave() | void | Quitter dialogue/echange/banque |
| bot.open() | void | Ouvrir (contexte dependant) |
| bot.count(templateId) | number | Alias countItem |
| bot.list() | table | Alias getInventory |
| bot.items() | table | Alias getInventory |
| bot.npc() | table | Alias getNpcs |
| bot.npcs() | table | Alias getNpcs |
| bot.players() | table | Alias getPlayers |
| bot.monsterGroups() | table | Alias getMonsterGroups |
Fonctions restantes — Alias et utilitaires
| Propiedad / Método | Tipo | Descripción |
|---|
| bot.getActors() | table | Tous les acteurs (monstres + joueurs + PNJ) |
| bot.getActorById(id) | table\ | nil | Acteur par ID |
| bot.getSpell(spellId) | table\ | nil | Donnees d'un sort |
| bot.upgradeSpell(spellId) | void | Alias boostSpell |
| bot.xpNext() | number | XP necessaire pour le prochain niveau |
| bot.clearGatherList() | void | Vider la liste de recolte |
| bot.getHarvestMode() | string | Mode recolte actuel |
| bot.setAntiAggroDefault(dist) | void | Distance anti-aggro par defaut |
| bot.removeItem(uid, qty?) | void | Alias deleteItem |
| bot.itemNameId(templateId) | string | Nom d'un item par template |
| bot.itemPods(templateId) | number | Poids d'un item |
| bot.npcBank(cellId?) | void | Ouvrir banque via PNJ (alias openBank) |
| bot.combine() | void | Alias craftCombine |
| bot.setQuantity(qty) | void | Alias craftSetQuantity |
| bot.waitForResult(timeout?) | table\ | nil | Alias craftWaitForResult |
| bot.enterMerchantMode() | void | Alias requestMerchantMode |
| bot.isOpen() | boolean | Interface ouverte (banque/HDV/craft/echange) |
| bot.isActive() | boolean | Bot actif |
| bot.isBoss() | boolean | Est leader du groupe |
| bot.isTypeAllowed(typeId) | boolean | Type de monstre autorise par filtre |
| bot.accept() | void | Accepter (echange/groupe/duel) |
| bot.refuse() | void | Refuser (echange/groupe/duel) |
| bot.requestById(id) | void | Demande echange par ID |
| bot.requestByName(name) | void | Alias exchangeRequestByName |
| bot.SendReply(index) | void | Alias npcReply |
| bot.mountFecondation() | number | Alias getMountFecondation |
| bot.thisAccountController() | table | Controleur du compte actuel |
| bot.getVitalityBase() | number | Vitalite base |
| bot.getWisdomBase() | number | Sagesse base |
| bot.getStrengthBase() | number | Force base |
| bot.getIntelligenceBase() | number | Intelligence base |
| bot.getChanceBase() | number | Chance base |
| bot.getAgilityBase() | number | Agilite base |
| bot.getTurnNumber() | number | Numero du tour (getter) |
| bot.getCurrentFighterId() | string | ID du combattant actuel (getter) |
| bot.getTurnOrder() | table | Ordre des tours (getter) |