[SOLVED] Checking Party Members health without targething them.

Runes of Magic/Radiant Arcana (http://www.runesofmagic.com)
Post Reply
Message
Author
kutalmismete
Posts: 25
Joined: Thu May 26, 2016 6:26 am

[SOLVED] Checking Party Members health without targething them.

#1 Post by kutalmismete » Fri Oct 07, 2016 6:45 pm

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.

kenzu38
Posts: 279
Joined: Sun Dec 02, 2012 8:52 am

Re: Checking Party Members health without targething them.

#2 Post by kenzu38 » Sat Oct 22, 2016 8:27 am

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

kutalmismete
Posts: 25
Joined: Thu May 26, 2016 6:26 am

Re: Checking Party Members health without targething them.

#3 Post by kutalmismete » Sun Oct 23, 2016 7:51 am

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

kenzu38
Posts: 279
Joined: Sun Dec 02, 2012 8:52 am

Re: Checking Party Members health without targething them.

#4 Post by kenzu38 » Sun Oct 23, 2016 8:58 am

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.

kutalmismete
Posts: 25
Joined: Thu May 26, 2016 6:26 am

Re: Checking Party Members health without targething them.

#5 Post by kutalmismete » Sun Oct 23, 2016 5:20 pm

Thanks, its working.

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 20 guests