Log in

View Full Version : Creature Functions, Please Help.



Eion
02-26-2013, 10:01 AM
I am trying to use the Creature functions but having a very hard time. I want to get the X,Y,Z coords of my current targeted creature and then check if that map tile is walkable. If I cannot check my current target then I want to check the X,Y,Z coords of all creatures on screen, I actually think this would be the best way to do it...

I don't understand how it defines which creature to look for. Does it look for all creatures or what? Where or how do I define the creatures?


function AntiSummonTargeting()
local pos1 = Creature:Position()
local iswalkable = Map.IsTileWalkable(pos1.x,pos1.y,pos1.z)
local currenttarget = Creature:isTarget()
if iswalkable == true and currenttarget == true then
setTargetingEnabled(false)
wait (15000, 30000)
setTargetingEnabled(true)
end
end

Spectrus
02-26-2013, 10:05 AM
First off, XenoBot's functions are divided in to classes. You are dealing with the creature class in this case, so what you first want to do is create an object of that class that you can interact with. We do this by calling Creature.New(), like so.
local target = Creature.New(Self.TargetID()) --This will return a creature object called 'target' based off your current target's ID.

Next, we want to store this creatures position in a table.
local pos = target:Position()

Next we want to check if that tile is walkable.
if Map.IsTileWalkable(pos.x, pos.y, pos.z) then
-- execute other code
end

Eion
02-26-2013, 10:12 AM
Ok thanks for the awesome and fast response.

Let's say that it wont retrieve the Self.TargetID() due to my bot not being able to attack summons on non-pvp worlds. What is the best way to go about checking every creature close to you? or on screen?

Spectrus
02-26-2013, 10:15 AM
Self.GetTargets(range) returns a table full of creature objects within given range.

Meaning you can do:


local mob = Self.GetTargets(7) -- full screen

for i = 1, #mob do
local pos = mob[i]:Position()
if Map.IsTileWalkable(pos.x, pos.y, pos.z) then
-- execute other code
end
end

Eion
02-26-2013, 10:17 AM
You are awesome man, thanks. This should help me a lot.

Eion
02-26-2013, 11:04 AM
The only problem I have now is that the creatures change position before the check happens casing a false check. Any way to avoid this?

Spectrus
02-26-2013, 11:17 AM
The only problem I have now is that the creatures change position before the check happens casing a false check. Any way to avoid this?

How are you implementing the code I gave you. You could run that like 100 times before the creatures had a chance to move.

Eion
02-26-2013, 11:25 AM
function AntiSummonTargeting()
local mob = Self.GetTargets(7) -- full screen
for i = 1, #mob do
local pos = mob[i]:Position()
if Map.IsTileWalkable(pos.x, pos.y, pos.z) then
setTargetingEnabled(false)
print("Summon Detected, Targetting Disabled!")
wait (5000, 10000)
setTargetingEnabled(true)
print("Targetting Enabled!")
end
end
end

while true do
AntiSummonTargeting()
wait(1000, 5000)
end

Spectrus
02-26-2013, 11:27 AM
Decrease the wait in your while true do loop to like 50-100ms.

Eion
02-26-2013, 11:39 AM
That doesn't change anything. It is still is being triggered falsely for some reason.

Eion
02-26-2013, 09:12 PM
Well, I guess the problem is in the part of the bot that detects a sqm walkable there is a slight delay or something. Not sure how to fix it.

Eion
02-27-2013, 08:48 PM
Bump.... can anyone help me make this work correctly?


function AntiSummonTargeting()
local mob = Self.GetTargets(7) -- full screen
for i = 1, #mob do
local pos = mob[i]:Position()
if Map.IsTileWalkable(pos.x, pos.y, pos.z) then
setTargetingEnabled(false)
print("Summon Detected, Targetting Disabled!")
wait (5000, 10000)
setTargetingEnabled(true)
print("Targetting Enabled!")
end
end
end

while true do
AntiSummonTargeting()
wait(50, 100)
end

Eion
02-28-2013, 08:57 AM
The problem here is not the script.

The function "Map.IsTileWalkable(x,y,z)" always returns true instead of false when there is a creature there. It seems to be looking at the Items on that square only and not the creatures. I need an ability to read what the pathfinder diagnostic window views the squares as walkable/nonwalkable.