Page 1 of 1

Buff player in range

Posted: Sun Jun 10, 2012 9:53 am
by gloover
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!

Re: Buff player in range

Posted: Sun Jun 10, 2012 10:02 am
by lisa
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>

Re: Buff player in range

Posted: Sun Jun 10, 2012 10:10 am
by rock5
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

Code: Select all

<![CDATA[
...
]]>
tags, like what you can see in the default profile.

Re: Buff player in range

Posted: Sun Jun 10, 2012 10:55 am
by gloover
@ 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?

Re: Buff player in range

Posted: Wed Oct 03, 2012 5:43 am
by gloover
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!