Page 1 of 1
[SOLVED] Checking Party Members health without targething them.
Posted: Fri Oct 07, 2016 6:45 pm
by kutalmismete
My problem is exactly same with title. For additional, I need to use spells on them without targeting them as well. Thanks in advance.
Re: Checking Party Members health without targething them.
Posted: Sat Oct 22, 2016 8:27 am
by kenzu38
Hmm, as far as I know, bot needs to target something before using a spell, unless of course the spell is AoE type that naturally allows casting without a target.
As for your main question, functions.lua has the GetPartyMemberAddress() function. If you tweak it a bit, then you'll be able to get your members' HP without targeting them.
Something like this should work (untested):
Code: Select all
function GetPartyMemberHP(membernum)
local name = GetPartyMemberName(membernum)
if name then
local member = player:findNearestNameOrId(name)
if member then
member:update()
return member.HP
end
end
return
end
Re: Checking Party Members health without targething them.
Posted: Sun Oct 23, 2016 7:51 am
by kutalmismete
player:findNearestNameOrId(name) returning true if it exists or returning a value that non checkable value then i think we can't check players identification with that function. so your code returning nil always :S still need help
Re: Checking Party Members health without targething them.
Posted: Sun Oct 23, 2016 8:58 am
by kenzu38
No, player:findNearestNameOrId returns a table if it finds something and returns nil if it finds nothing.
The problem is that I forgot that the table it returns is not a complete pawn table and does not include the HP. And that's why member.HP was always nil with the previous code. So we'll have to add a code to make a pawn of the returned value first before it works.
Try this:
Code: Select all
function GetPartyMemberHP(membernum)
local name = GetPartyMemberName(membernum)
if name then
local member = player:findNearestNameOrId(name)
if member then
member = CPawn(member.Address)
member:update()
return member.HP
end
end
return
end
Also, player:findNearestNameOrId has a limit to its range, can't remember exactly how far but I think it's 600. So just make sure the party member you are monitoring isn't too far.
Re: Checking Party Members health without targething them.
Posted: Sun Oct 23, 2016 5:20 pm
by kutalmismete
Thanks, its working.