API Lua Recolte & Combat

64 entries — WGRetro bot reference for Dofus Retro

Full documentation
Recolte
if bot.hasResourcesOnMap() then
    local nb = bot.gatherAll()
    log("Recolte: " .. nb .. " ressources")
end
Combat — Lancer
if bot.hasMonstersOnMap() then
    bot.fight()
    bot.waitForFightEnd()
end
Combat — Actions
-- Lancer sort 3 sur la cellule de l'ennemi
local enemy = bot.getNearestEnemy()
if enemy then
    bot.castSpell(3, enemy.cell)
end
bot.endTurn()
Combat — Informations
-- Boucle de combat
while bot.inFight() do
    local myTurn = bot.waitForTurn()
    if not myTurn then break end

    local enemy = bot.getNearestEnemy()
    if enemy then
        bot.castSpell(3, enemy.cell)
    end
    bot.passTurn()
end
Filtres de monstres
-- Ne combattre que les groupes de 1 a 3 monstres
bot.setMinMonsters(1)
bot.setMaxMonsters(3)

-- Eviter les Bouftous Royaux (id 42)
bot.setForbiddenMonsters({42})
Filtres de monstres avances
-- Exiger 2 Bouftous (id 42) et 1 Tofu (id 45)
bot.setMonsterComposition({ [42] = 2, [45] = 1 })

Recolte

Property / MethodTypeDescription
bot.gather()booleanRecolte la ressource la plus proche
bot.gatherAll()numberRecolte tout, retourne le nombre
bot.gatherResource(cellId)booleanRecolte une ressource specifique
bot.hasResourcesOnMap()booleanRessources disponibles ?
bot.getResources()table{{ cellId, skillId }}

Combat — Lancer

Property / MethodTypeDescription
bot.attack(entityId)voidAttaquer un monstre par ID
bot.fight()booleanAttaquer le groupe de monstres le plus proche
bot.hasMonstersOnMap()booleanMonstres sur la map ?
bot.getMonsterGroups()table{{ id, cellId, name, level, monsters }}

Combat — Actions

Property / MethodTypeDescription
bot.castSpell(spellId, cellId)voidLancer un sort
bot.castSpellOnCell(spellId, cellId)voidAlias castSpell
bot.castSpellOnEnemy(spellId, index?)booleanSort sur le Neme ennemi (0=plus proche)
bot.endTurn()voidFin de tour
bot.passTurn()voidAlias endTurn
bot.moveInFight(cellId)voidDeplacement en combat
bot.moveToward(entityId)voidSe rapprocher d'un combattant
bot.moveAway(entityId)voidS'eloigner d'un combattant
bot.chooseCell(cellId)voidChoisir cellule de placement
bot.fightReady()voidSignal pret (placement)
bot.abandon()voidAbandonner le combat
bot.getPlacementCells()tableCellules de placement
bot.getEnemyPlacementCells()tableCellules de placement ennemies (si disponible)
bot.fightDelay(ms)voidPause en combat (alias de sleep)
bot.fightLog(msg)voidLog en contexte combat

Combat — Informations

Property / MethodTypeDescription
bot.getFighters()tableTous les combattants { id, cellId, hp, hpMax, hpPercent, ap, mp, cell, teamId, alive, name, level, isEnemy, isSummon, summonerId, invisible, templateId, distance }
bot.getAllFighters()tableAlias de getFighters
bot.getEnemies()tableEnnemis vivants
bot.getAllies()tableAllies vivants
bot.getNearestEnemy()table\nil | Ennemi le plus proche
bot.getFarthestEnemy()table\nil | Ennemi le plus loin
bot.getWeakestEnemy()table\nil | Ennemi le plus faible (HP)
bot.getNearestAlly()table\nil | Allie le plus proche (hors soi)
bot.enemyCount()numberNombre d'ennemis vivants
bot.allyCount()numberNombre d'allies vivants
bot.distanceTo(cellId)numberDistance Manhattan depuis cellule actuelle
bot.cellDistance(a, b)numberDistance Manhattan entre deux cellules
bot.waitForTurn(timeout?)booleanAttendre mon tour (false si combat fini)
bot.waitForFight(timeout?)voidAttendre debut combat
bot.waitForFightEnd(timeout?)anyAttendre fin combat

Combat — Etat

Property / MethodTypeDescription
bot.turnNumber()numberNumero du tour actuel (incremente a chaque tour du bot)
bot.currentFighterId()string\nil | ID de l'entite dont c'est le tour
bot.turnOrdertableOrdre des tours (liste d'IDs de combattants)
bot.myFightId()stringNotre ID d'entite en combat
bot.myFightCell()numberNotre cellule actuelle en combat
bot.myAP()numberPA actuels en combat (depuis GTM)
bot.myMP()numberPM actuels en combat (depuis GTM)
bot.myFightHP()numberPV actuels en combat
bot.myFightHPMax()numberPV max en combat
bot.myFightLifePercent()numberPV en % en combat (0-100)
bot.myLevel()numberNiveau du personnage
bot.myRange()numberPortee du personnage
bot.myTeamId()numberID d'equipe (0 ou 1)

Filtres de monstres

Property / MethodTypeDescription
bot.setMandatoryMonsters(ids)voidMonstres obligatoires dans le groupe
bot.getMandatoryMonsters()tableIDs obligatoires
bot.setForbiddenMonsters(ids)voidMonstres a eviter
bot.getForbiddenMonsters()tableIDs interdits
bot.setMinMonsters(n)voidTaille min du groupe
bot.getMinMonsters()numberMin actuel
bot.setMaxMonsters(n)voidTaille max du groupe
bot.getMaxMonsters()numberMax actuel
bot.matchesMonsterFilter(group)booleanGroupe correspond aux filtres ?

Filtres de monstres avances

Property / MethodTypeDescription
bot.setMonsterComposition(comp)voidComposition obligatoire { [monsterId] = quantite }
bot.getMonsterComposition()tableComposition actuelle
bot.clearMonsterComposition()voidSupprimer la composition

These functions are used in the WGRetro bot Lua scripts — testable with the free plan (1 bot, no time limit). Ready-to-use scripts on the marketplace.