Log in

View Full Version : Get position from target.



mastomania
07-22-2013, 07:42 PM
Hi.

I'm struggling with some code.
I'm making Demona warlock script to bot my ms, but the warlocks going invisible is a problem.

I've been using the following script by Syntax, however this script uses rune on characters position, when target goes off(monster goes invisible)
I'm looking for a way to store variable monsterPosition every time the script loops, the variable stores the current targets position, and when the monster goes invisible the bot shoots a rune on the last saved monsterPosition.

edit: I tried with function Creature:Position(), which i thought was supposed to return the coordinates of the target, but it's not working for me.



local info = [[
Name: Invisible Monster Attacker
Description: Executes an AoE when monsters go invisible
Author: Cavitt Glover (Syntax)
Version: 1.0.00 (updated 04.25.2012)]]

local config = {
attacks = {
--[[
runes/spells should be prioritized from top to bottom, eg: exori gran will be attempted before exori or exori mas.

aggressive:
0 = attack triggers when no players are in the area.
1 = attack triggers when only war enemies and skulled players, noone else.
2 = attack triggers when innocents are in the area but not when friendlies are.
3 = attack triggers when friendlies are in the area but not when innocents are.
4 = attack triggers without any regards to players in the area.
]]
--{spell="exori gran", threshold=5, mana=50, radius=1, aggressive=0},
{rune=3191, threshold=2, radius=5, aggressive=0},
--{spell="exori mas", threshold =7, mana=80, radius=4, aggressive=0}
}
}

local attack = false
local function think()
local target = Creature.GetByID(Self.TargetID())
if(target:isVisible() and target:isAlive() and target:isValid())then -- target is visible, record it
attack = true
elseif(not target:isVisible() and attack)then -- creature went invisible, attack it
attack = false -- for next check
for _, info in ipairs(config.attacks)do
local check = getTargetsInArea(Self.Position(), info.radius, info.aggressiveness, true)
if(check)then -- if its not false from a security check, continue
if(info.spell)then
Self.Cast(info.spell, info.mana)
elseif(info.rune)then
Self.UseItemWithMyPosition(info.rune)
end
wait(2000,2500)
end
end
end
end

print(info)
wait(5000)
while (true) do
think()
wait(500)
end

mastomania
07-24-2013, 02:49 PM
Bump, if you know please answer, checking this thread way too often :P

Nakuu
07-24-2013, 02:55 PM
Here is an example:
local mobs = Self.GetTargets(7)
for i = 1, #mobs do
local x = mobs[i]:Position().x
local y = mobs[i]:Position().y
end

or to get position from target use
Creature:DistanceFromSelf()

mastomania
07-24-2013, 03:50 PM
Here is an example:
local mobs = Self.GetTargets(7)
for i = 1, #mobs do
local x = mobs[i]:Position().x
local y = mobs[i]:Position().y
end

or to get position from target use
Creature:DistanceFromSelf()

Works good, thanks alot man :)

local mobs = Self.GetTargets(7)
for i = 1, #mobs do
x = mobs[i]:Position().x
y = mobs[i]:Position().y
z = mobs[i]:Position().z

Self.UseItemWithGround(3161, x, y, z)

Nakuu
07-24-2013, 03:56 PM
I'm glad it works ^^

Kyrus Infinity
09-23-2013, 10:46 PM
Hey guys! What would the fully functioning script to this look like? I'm trying hard to find something that will make hunting invisible units much easier, and this looks great! Let me know!