Retrieving group member info in C#

Eania

Active Member
Having a bit of a tough time figuring out how to get group member info (like health) in C#

I can get it easy using Lavascript via ${Group[1].Health} but im racking my brain trying to figure out an easy way of doing it in C#.

Issue im having is i cant seem to get anything from the groupmember type.

The only way I know how to get the info is by targeting each member of the group in range and pulling the info from the charater object.

Any help would be great... ps. new to C#

Code:
        public void Find_Group_Members(Character Me, VG vg)
        {
            Clear_Screen();
            Pawn pawn = new Pawn();;
            for (int x = 1; x < vg.PawnCount; x++)
            {
                pawn = new Pawn(x.ToString());
                if (pawn.IsGroupMember)
                {
                    InnerSpace.Echo("Pawn: " + pawn.Name + " Level: " + pawn.Level + " TYPE " + pawn.Type + " Location " + pawn.X + "," + pawn.Y);
                    pawn.Target();
                    Me = GetUpdate(Me);
                    InnerSpace.Echo("Target Name: " + Me.DTarget.Name + " Health: " + Me.DTargetHealth.ToString());
                }
            }
        }



        private Character GetUpdate(Character Me)
        {
            do
            {
                LavishVMAPI.Frame.Unlock(); 
                Me = new Character();
                LavishVMAPI.Frame.Lock(); 
            }
            while (Me.DTargetHealth < 1);
            return Me;

        }
 

Karye

Active Member
your biggest issue is not having the frame locked when you access an extension member or method. You must implicitly lock the frame, do what you need to do with the extension then unlock the frame.

an example:
sets the Pawn ID for the member with the lowest the lowest health, their health in % and their class. It also increments groupHealCount if more than 1 group member needs a heal.

Code:
public class SomeClass
{
        private Int64 lowestHealthID;
        private float lowestHealthPercent;
        private string lowestHealthClass;
        private int groupHealCount;
        
        public SomeClass()
        {

        }

        public void CheckLowestHealth()
        {
            
            int groupCount;
            int i;
            float groupMemberHealth;

            try
            {
                groupHealCount = 0;

                LavishVMAPI.Frame.Lock();
                lowestHealthID = ext.Me.ToPawn.ID;
                lowestHealthPercent = ext.Me.HealthPct;
                lowestHealthClass = ext.Me.Class;
                groupCount = ext.Group().Count;

                if (lowestHealthPercent < 70)
                {
                    groupHealCount++;
                }
                i = 0;

                while (i++ < groupCount)
                {
                    groupMemberHealth = ext.Group(i).Health;

                    if (groupMemberHealth < 70 && groupMemberHealth > 0)
                    {
                        groupHealCount++;
                    }

                    if (groupMemberHealth < lowestHealthPercent && groupMemberHealth > 0)
                    {
                        lowestHealthPercent = ext.Group(i).Health;
                        lowestHealthID = ext.Group(i).ID;
                        lowestHealthClass = ext.Group(i).Class;
                    }

                }
            }
            catch (Exception ex)
            {
                //handle your errors
            }
            finally
            {
                //never forget to unlock your frame
                LavishVMAPI.Frame.Unlock();
            }
        }

}
 

Eania

Active Member
Thanks. Found the issue. It was not locking I was doing that right just didn't show all my code. Your sample however showed "ext.Group(i).Health" which I found the Extention type which makes things much easier for me now.

I know im going to have issues later with locking though.

Thanks again.
 

stardog_2006

Active Member
Eania said:
Your sample however showed "ext.Group(i).Health" which I found the Extention type which makes things much easier for me now.
Thanks again.

If I had a Nickle for every time Karye helped me out. .

come to think of it this just helped me out too. LOL thanks


/*Ponders The possibilties */
 
Top Bottom