-
gloover
- Posts: 304
- Joined: Wed Jul 07, 2010 4:31 am
#1
Post
by gloover » Sun Jun 10, 2012 9:53 am
Hi experts,
based on Alkaiser scripts to detect player in range, now I want to buff listed player using this script, but it seems not to work
Using PartyHeals() is not the solution, because the bot should buff all listed player coming closer - not only the party members.
Here's my script:
Code: Select all
<?xml version="1.0" encoding="utf-8"?><waypoints>
<onLoad>
function CPlayer:PlayerInRange(_range,_X,_Z)
_range = _range or 150
_X = _X or self.X
_Z = _Z or self.Z
local dist = 0
local function isInDist(x1, y1, x2, y2, radius)
if( (x2 >= x1-radius) and (x1+radius >= x2) and (y2 >= y1-radius) and (y1+radius >= y2) ) then
dist = (x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)
if (radius*radius >= dist) then
dist = math.floor(math.sqrt(dist)+0.5)
return true
else
return false
end
end
return false
end
local function FriendPlayerName(_name)
local playerNames = {"Player1","Player2","Player3"}
for k, v in ipairs(playerNames) do
if _name == v then return true end
end
return false
end
local found = false
local doOnce = true
local obj = nil
local objectList = CObjectList()
objectList:update()
for i = 0,objectList:size() do
obj = objectList:getObject(i)
if( obj.Type == PT_PLAYER and obj.Name ~= self.Name and obj.Name ~= "<UNKNOWN>" and FriendPlayerName(obj.Name) ) then
if( isInDist(_X, _Z, obj.X, obj.Z, _range) ) then
if( doOnce ) then
cprintf(cli.red,"Player Detection! ")
printf("NAME\n")
printf(" ----\n")
doOnce = false
end
printf(" %s - ", obj.Name)
printf("%s\n", dist)
found = true
player:target(FriendPlayerName(obj.Name))
player:update()
player:clearTarget();
end
end
end
return found
end
while (true) do
player:PlayerInRange()
end
</onLoad>
</waypoints>
got xml parse error "missmatched tag" ?!
can someone check this.
thx in advance!
-
lisa
- Posts: 8332
- Joined: Tue Nov 09, 2010 11:46 pm
- Location: Australia
#2
Post
by lisa » Sun Jun 10, 2012 10:02 am
try this, you know this code checks for player names right?
Code: Select all
<?xml version="1.0" encoding="utf-8"?><waypoints>
<onLoad>
function PlayerInRange(_range,_X,_Z)
_range = _range or 150
_X = _X or player.X
_Z = _Z or player.Z
local dist = 0
local function isInDist(x1, y1, x2, y2, radius)
if( (x2 >= x1-radius) and (x1+radius >= x2) and (y2 >= y1-radius) and (y1+radius >= y2) ) then
dist = (x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)
if (radius*radius >= dist) then
dist = math.floor(math.sqrt(dist)+0.5)
return true
else
return false
end
end
return false
end
local function FriendPlayerName(_name)
local playerNames = {"Player1","Player2","Player3"}
for k, v in ipairs(playerNames) do
if _name == v then return true end
end
return false
end
local found = false
local doOnce = true
local obj = nil
local objectList = CObjectList()
objectList:update()
for i = 0,objectList:size() do
obj = objectList:getObject(i)
if( obj.Type == PT_PLAYER and obj.Name ~= player.Name and obj.Name ~= "<UNKNOWN>" and FriendPlayerName(obj.Name) ) then
if( isInDist(_X, _Z, obj.X, obj.Z, _range) ) then
if( doOnce ) then
cprintf(cli.red,"Player Detection! ")
printf("NAME\n")
printf(" ----\n")
doOnce = false
end
printf(" %s - ", obj.Name)
printf("%s\n", dist)
found = true
player:target(FriendPlayerName(obj.Name))
player:checkSkills(true);
player:update()
player:clearTarget();
end
end
end
return found
end
while (true) do
PlayerInRange()
end
</onLoad>
</waypoints>
-
rock5
- Posts: 12173
- Joined: Tue Jan 05, 2010 3:30 am
- Location: Australia
#3
Post
by rock5 » Sun Jun 10, 2012 10:10 am
You can't use '<' anywhere in your code in xml files, they get interpretted as the beginning of a tag.
There are a few solutions to this depending on why you need to use that symbol. In your case it is when checking the name of the obj, "<UNKNOWN>". I can think of 2 solutions, 1. don't check the name. Maybe check the id instead. I wouldn't be surprised if all invalid objects with the name of "<UNKNOWN>" had invalid ids. 2. Tell micromacro the code is a block of code with
tags, like what you can see in the default profile.
- Please consider making a small donation to me to support my continued contributions to the bot and this forum. Thank you. Donate
- I check all posts before reading PMs. So if you want a fast reply, don't PM me but post a topic instead. PM me for private or personal topics only.
- How to: copy and paste in micromacro
________________________
Quote:
- “They say hard work never hurt anybody, but I figure, why take the chance.”
-
gloover
- Posts: 304
- Joined: Wed Jul 07, 2010 4:31 am
#4
Post
by gloover » Sun Jun 10, 2012 10:55 am
@ Lisa, yes it should cheking the player name and buff only by matched (listed) names
You've right rock, using [[CDATA seems to solve the problem with "tag error" the part wich should detect the player by name seems to work, but it cant get the player in target and give some buffs - something is wrong in this part:
Code: Select all
player:target(FriendPlayerName(obj.Name))
player:checkSkills(true);
player:update()
player:clearTarget();
what is wrong on them?
-
gloover
- Posts: 304
- Joined: Wed Jul 07, 2010 4:31 am
#5
Post
by gloover » Wed Oct 03, 2012 5:43 am
Hey Rock, hello Lisa.
I would picking this issue again - have not succeeded atm.
I want to make a priest as a buffer character, to buff only in list selected Chars (not in group) when they're in range. The Idea is to using em in siege war standing near the resurection point.
So the problem is, the bot can find the character in range, but cant target them and also cant buff
Can u give me an advice? or may an elegant sample?
thx in advance!
Who is online
Users browsing this forum: Ahrefs [Bot], Google [Bot] and 2 guests