actions.display_message("Hello world!")
local hp = game.get_player_hp()
local fp = game.get_player_fp()
local sp = game.get_player_sp()
print("HP:", hp, "FP:", fp, "SP:", sp)
function select_target()
local pos = game.get_player_coord()
if pos then
actions.target_closest_character(
ActorGroup.Monsters,
pos.x, pos.y, pos.z, -- anchor
500.0, -- radius
{"Young Flem", "Digger Clan"}, -- filters
false -- checkRange
)
end
end
function auto_attack()
local target = game.get_player_target()
if target ~= 0 then
actions.click_on_target(target)
end
end
while true do
if not game.is_target_valid() then
select_target()
else
auto_attack()
end
sleep(200)
end
local pos = game.get_player_coord()
if pos then
local loot = game.get_closest_lootable_item(pos.x, pos.y, pos.z, 200.0)
if loot ~= 0 then actions.pick_up_item(loot) end
end
local pos = game.get_player_coord()
if not pos then return end
-- move 20 units on X and Z
local newX = pos.x + 20
local newY = pos.y
local newZ = pos.z + 20
actions.move_player(newX, newY, newZ)
Продать все предметы с подстрокой "sword" НПСу "CHARGER"
Код:
local npc = game.find_character_by_name(
ActorGroup.NPCs,
"CHARGER"
)
if npc == 0 then
return
end
actions.perform_npc_action(npc, 0)
sleep(1000)
actions.switch_tab_window(1)
sleep(400)
for bag = 0, 4 do
for cell = 0, 19 do
local ptr = game.get_bag_item(bag, cell)
if ptr ~= 0 then
local name = game.get_bag_item_name(ptr)
local isSword = string.find(string.lower(name), "sword", 1, true)
if name and isSword then
actions.put_item_into_sell_window(bag, cell)
sleep(200)
actions.confirm_sell_window()
sleep(200)
end
end
end
end
local inv = game.get_inventory()
for bagIdx, bag in ipairs(inv) do
for cellIdx, ptr in ipairs(bag) do
if ptr ~= 0 then
local name = game.get_bag_item_name(ptr)
print(("Bag %d Cell %d: %s"):format(bagIdx-1, cellIdx-1, name or "unknown"))
end
end
end
while true do
local debuffs = game.get_debuff_count()
if debuffs > 0 then
-- change bar/cell if needed
actions.use_bar_action(0, 0, true)
end
sleep(200)
end
Скрипт запускает основного бота. При появлении ГМ-а бот останавливается, и шлется пакет на прыжок.
Код:
bot.start()
-- jump
local pkt_type = string.char(0x0D, 0x16)
local pkt_body = string.char(0x46)
while true do
if game.get_is_gm_present()
or game.has_gm_appeared_recently(30000) then
bot.stop()
while true do
actions.send_packet(pkt_type, pkt_body, true)
sleep(300)
end
end
sleep(100)
end
Скрипт держится в радиусе ~75 от заданного персонажа и атакует указаную цель.
Код:
local group = ActorGroup.Monsters -- or ActorGroup.OtherPlayers / ActorGroup.NPCs
local fallback_name = "qweqwe" -- name to search when no party-assist target is present
while true do
local assist_ptr = game.find_party_assist_marked_character(ActorGroup.Monsters)
if assist_ptr ~= 0 then
-- Ensure we are targeting the assist-marked character
local current_target = game.get_player_target()
if current_target ~= assist_ptr then
actions.set_target(assist_ptr, true)
end
else
-- No party assist: try to find by name and move to that character
local found_ptr = game.find_character_by_name(ActorGroup.OtherPlayers, fallback_name)
if found_ptr ~= 0 then
local coord = game.get_character_coord(found_ptr)
if coord ~= nil and coord.x and coord.y and coord.z then
local player_coord = game.get_player_coord()
if player_coord ~= nil then
local dx = player_coord.x - coord.x
local dy = player_coord.y - coord.y
local dz = player_coord.z - coord.z
local distance = math.sqrt(dx * dx + dy * dy + dz * dz)
local radius = 75
if distance > radius then
-- pick a random offset inside a 50-unit radius
local angle = math.random() * math.pi * 2
local dist = math.random() * radius
local rx = coord.x + math.cos(angle) * dist
local ry = coord.y + math.sin(angle) * dist
local rz = coord.z
actions.move_player(rx, ry, rz)
end
end
end
end
end
-- If we have any target, auto-attack and use bar action (1,1)
local current_target = game.get_player_target()
if current_target ~= 0 then
actions.click_on_target(current_target)
sleep(100)
actions.use_bar_action(1, 1)
end
sleep(100) -- wait 100 ms before checking again
end
local function apply_buff(player_name, bar_index, cell_index)
local group = ActorGroup.OtherPlayers;
local characterPtr = game.find_character_by_name(group, player_name)
if characterPtr == 0 then return end
actions.use_bar_action(bar_index, cell_index, true)
sleep(500)
actions.click_on_target(characterPtr)
end
local function callback(sender, message)
print("[PRIVATE] " .. sender .. ": " .. message)
local lower = message:lower()
if lower:match("velo") or lower:match("вв") then
apply_buff(sender, 0, 0)
end
if lower:match("shield") or lower:match("щит") then
apply_buff(sender, 0, 1)
end
if lower:match("dodge") or lower:match("додж") then
apply_buff(sender, 0, 2)
end
end
actions.on_private_message(callback)
print("Listening for private messages ...")
while true do
sleep(250)
end
game.get_closest_characters(group, ox, oy, oz, radius[, {filters}]) : массив таблиц { {ptr=<addr>, dist=<float>}, ... }, отсортированный по дистанции (и по %HP при равенстве).
game.find_character_by_name(group, name) : number (адрес или 0)
game.get_inventory() : массив сумок (Lua-массив с 1), каждая сумка — массив адресов предметов (0 если пусто). Пример доступа: inv[1][5] — 5-я ячейка 1-й сумки.
game.get_bag_item(bagIndex0, cellIndex0) : number (адрес или 0). Индексация с нуля.
Скрипт держится в радиусе ~75 от заданного персонажа и атакует указаную цель.
Код:
local group = ActorGroup.Monsters -- or ActorGroup.OtherPlayers / ActorGroup.NPCs
local fallback_name = "qweqwe" -- name to search when no party-assist target is present
while true do
local assist_ptr = game.find_party_assist_marked_character(ActorGroup.Monsters)
if assist_ptr ~= 0 then
-- Ensure we are targeting the assist-marked character
local current_target = game.get_player_target()
if current_target ~= assist_ptr then
actions.set_target(assist_ptr, true)
end
else
-- No party assist: try to find by name and move to that character
local found_ptr = game.find_character_by_name(ActorGroup.OtherPlayers, fallback_name)
if found_ptr ~= 0 then
local coord = game.get_character_coord(found_ptr)
if coord ~= nil and coord.x and coord.y and coord.z then
local player_coord = game.get_player_coord()
if player_coord ~= nil then
local dx = player_coord.x - coord.x
local dy = player_coord.y - coord.y
local dz = player_coord.z - coord.z
local distance = math.sqrt(dx * dx + dy * dy + dz * dz)
local radius = 75
if distance > radius then
-- pick a random offset inside a 50-unit radius
local angle = math.random() * math.pi * 2
local dist = math.random() * radius
local rx = coord.x + math.cos(angle) * dist
local ry = coord.y + math.sin(angle) * dist
local rz = coord.z
actions.move_player(rx, ry, rz)
end
end
end
end
end
-- If we have any target, auto-attack and use bar action (1,1)
local current_target = game.get_player_target()
if current_target ~= 0 then
actions.click_on_target(current_target)
sleep(100)
actions.use_bar_action(1, 1)
end
sleep(100) -- wait 100 ms before checking again
end
local function apply_buff(player_name, bar_index, cell_index)
local group = ActorGroup.OtherPlayers;
local characterPtr = game.find_character_by_name(group, player_name)
if characterPtr == 0 then return end
actions.use_bar_action(bar_index, cell_index, true)
sleep(500)
actions.click_on_target(characterPtr)
end
local function callback(sender, message)
print("[PRIVATE] " .. sender .. ": " .. message)
local lower = message:lower()
if lower:match("velo") or lower:match("вв") then
apply_buff(sender, 0, 0)
end
if lower:match("shield") or lower:match("щит") then
apply_buff(sender, 0, 1)
end
if lower:match("dodge") or lower:match("додж") then
apply_buff(sender, 0, 2)
end
end
actions.on_private_message(callback)
print("Listening for private messages ...")
while true do
sleep(250)
end
Последний раз редактировалось Diantro; 15.10.2025 в 20:07.