Buff player in range
Posted: 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![Sad :-(](./images/smilies/icon_e_sad.gif)
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:
got xml parse error "missmatched tag" ?!
can someone check this.
thx in advance!
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
![Sad :-(](./images/smilies/icon_e_sad.gif)
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>
can someone check this.
thx in advance!