Posts: 8
Threads: 1
Joined: Mar 2024
Reputation:
0
Hello,
I would need simple script, when monster throw fire field under my character, it gonna moves as fast as possible to sqm without fire.
Best regards
Posts: 2,911
Threads: 481
Joined: Jul 2018
Reputation:
82
03-08-2024, 03:30 PM
(This post was last modified: 03-08-2024, 03:33 PM by Arkilys.)
Will Targeting and Cavebot be enabled? Because the script would need to consider and pause those tools.
Should the script do that only when Targeting? There's any other requirement?
Please think carefully. So that I don't have to rework and depending on what it is, once i finish developing the script the way you wrote, I would no longer help you.
Posts: 8
Threads: 1
Joined: Mar 2024
Reputation:
0
Yes targeting and cavebot should be enabled.
Scenario should look like this:
Im fighting monster, if monster throw fire field under me, my character moves to safe spot without fire field, and if he is not standing on fire field anymore, he continues to attack monster. If monster is dead my character should continue walk on cavebot.
Posts: 2,911
Threads: 481
Joined: Jul 2018
Reputation:
82
03-08-2024, 04:04 PM
(This post was last modified: 03-08-2024, 04:06 PM by Arkilys.)
Thanks for the information. |Only Registered members can see download links. | Click here to buy subscription or here to register.|Only Registered members can see download links. | Click here to buy subscription or here to register.alt="Smile" title="Smile" class="smilie smilie_1" />
Are you standing next to the monster or keep away from it?
Are you using Chase (Attack mode -> Chase/Ofensive, etc.) or Stances (reach, circle, keep away, etc) to reach monsters? If it's a stance, which one? I need to consider that to find sqm to walk.
Posts: 8
Threads: 1
Joined: Mar 2024
Reputation:
0
03-08-2024, 04:05 PM
(This post was last modified: 03-08-2024, 04:07 PM by valhejm.)
Im using stance: "Reach" and standing next to the monster.
Posts: 2,911
Threads: 481
Joined: Jul 2018
Reputation:
82
03-08-2024, 04:12 PM
(This post was last modified: 03-08-2024, 07:01 PM by Arkilys.)
Hello.
Try this code. If you are standing at one of the listed fields then it will find an sqm around the monster to stand at.
This script should only be used when you are reaching creatures that you are attacking like Chase mode, Reach stance, Circle stance, etc., but not with distance stances like Keep Away, Lure, etc.
You can test if the script is working by adding gold coin id on FIELDS_IDS and add a creature on Targeting then let it attack the creature. When it starts attacking then drop a gold coin under your character, so it will try to find another place around the creature to walk.
local FIELDS_IDS = { 2118, 2119, 2123, 2124, 2131, 2132, 2137, 2138 } -- Fields IDs to avoid
if connected() and hastarget() then
local attackedCreature = attacked()
if attackedCreature.id > 0 and attackedCreature.hppc > 0 and attackedCreature.dist <= 1 then
local playerX, playerY, playerZ = posx(), posy(), posz()
local foundFieldOnCharacterSqm = false
local tile = gettile(playerX, playerY, playerZ)
for _, item in ipairs(tile.items) do
if table.find(FIELDS_IDS, item.id) ~= nil then
foundFieldOnCharacterSqm = true
break
end
end
if foundFieldOnCharacterSqm then
local closestSqm = { X = 0, Y = 0, Z = 0, Dist = 999 }
for x = -1, 1 do
for y = -1, 1 do
if x ~= 0 and y ~= 0 then
local tile = gettile(attackedCreature.posx + x, attackedCreature.posy + y, playerZ)
if tile ~= nil and tile.itemcount > 0 then
local fieldFound = false
for _, item in ipairs(tile.items) do
if table.find(FIELDS_IDS, item.id) ~= nil then
fieldFound = true
break
end
end
if fieldFound == false and closestSqm.Dist > proximity(playerX, playerY, attackedCreature.posx + x, attackedCreature.posy + y) then
closestSqm = { X = tile.posx, Y = tile.posy, Z = tile.posz, Dist = proximity(playerX, playerY, attackedCreature.posx + x, attackedCreature.posy + y) }
end
end
end
end
end
if closestSqm.X > 0 then
pausewalking(3000)
reachlocation(closestSqm.X, closestSqm.Y, closestSqm.Z)
wait(100, 200)
pausewalking(0)
end
end
end
end
Or
local FIELDS_IDS = { 2118, 2119, 2123, 2124, 2131, 2132, 2137, 2138 } -- Fields IDs to avoid
if connected() and hastarget() then
local attackedCreature = attacked()
if attackedCreature.id > 0 and attackedCreature.hppc > 0 and attackedCreature.dist <= 1 then
local playerX, playerY, playerZ = posx(), posy(), posz()
local foundFieldOnCharacterSqm = false
local tile = gettile(playerX, playerY, playerZ)
for _, item in ipairs(tile.items) do
if table.find(FIELDS_IDS, item.id) ~= nil then
foundFieldOnCharacterSqm = true
break
end
end
if foundFieldOnCharacterSqm then
local closestSqm = { X = 0, Y = 0, Z = 0, Dist = 999 }
local tiles = gettiles()
for _, tile in ipairs(tiles) do
if tile ~= nil and tile.itemcount > 0 and tile.posx ~= attackedCreature.posx and tile.posy ~= attackedCreature.posy and math.abs(tile.posx - attackedCreature.posx) <= 1 and math.abs(tile.posy - attackedCreature.posy) <= 1 then
local fieldFound = false
for __, item in ipairs(tile.items) do
if table.find(FIELDS_IDS, item.id) ~= nil then
fieldFound = true
break
end
end
if fieldFound == false and closestSqm.Dist > proximity(playerX, playerY, tile.posx, tile.posy) then
closestSqm = { X = tile.posx, Y = tile.posy, Z = tile.posz, Dist = proximity(playerX, playerY, tile.posx, tile.posy) }
end
end
end
if closestSqm.X > 0 then
pausewalking(3000)
reachlocation(closestSqm.X, closestSqm.Y, closestSqm.Z)
wait(100, 200)
pausewalking(0)
end
end
end
end
Posts: 8
Threads: 1
Joined: Mar 2024
Reputation:
0
03-08-2024, 04:17 PM
(This post was last modified: 03-08-2024, 04:27 PM by valhejm.)
Thank you, gonna check if it works and msg after.
There is some problem, I got this error in console:
LUA Script -> Run fire: 32: attempt to perform arithmetic on a KasteriaOTBot.Core.Lua+CreatureInfo, Build, Version=1.1.27.6, Culture=neutral, PublicKeyToken=null value (local 'attackedCreature')
Posts: 2,911
Threads: 481
Joined: Jul 2018
Reputation:
82
Hello.
Just fixed it. Please, try again.
Posts: 8
Threads: 1
Joined: Mar 2024
Reputation:
0
It works buuuuut sometimes he moves instantly, but another time it takes too long to move. I need character to move instantly otherwise he would be dead after few secs.
Posts: 2,911
Threads: 481
Joined: Jul 2018
Reputation:
82
Then use lower intervals on your Persistent, because the only delay on script is 500ms AFTER moving.
|