[SOLVED] Checking Party Members health without targething them.
-
- Posts: 25
- Joined: Thu May 26, 2016 6:26 am
[SOLVED] Checking Party Members health without targething them.
My problem is exactly same with title. For additional, I need to use spells on them without targeting them as well. Thanks in advance.
Last edited by kutalmismete on Tue Nov 01, 2016 12:54 am, edited 1 time in total.
Re: Checking Party Members health without targething them.
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):
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
-
- Posts: 25
- Joined: Thu May 26, 2016 6:26 am
Re: Checking Party Members health without targething them.
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.
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:
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.
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
-
- Posts: 25
- Joined: Thu May 26, 2016 6:26 am
Re: Checking Party Members health without targething them.
Thanks, its working.
Who is online
Users browsing this forum: Ahrefs [Bot], Bing [Bot] and 90 guests