What's new
  • Visit Rebornbuddy
  • Visit Panda Profiles
  • Visit LLamamMagic
  • Visit Resources
  • Visit Downloads
  • Visit Portal
RebornBuddy Forums

Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

PartyMember as Character?

Exmortem

Community Developer
Joined
Mar 28, 2010
Messages
799
I'm trying to sort through all my current party members, the goal is to eventually find heal targets.

Code:
foreach (PartyMember partyMember in PartyManager.Members)
         {
            Log(partyMember.Name);
         }

That code works, but the issue is that I can't get current health from partyMember.CurrentHealthPercent, so I try to use partyMember.GameObject as Character ...

Code:
foreach (PartyMember partyMember in PartyManager.Members)
         {
            Log((partyMember.GameObject as Character).Name);
         }

and it's throwing an object reference. In the past we could use party.GameObject.ToCharacter.CurrentHealthPercent but that was changed in the API. I don't know if this is an API error or if i'm doing something wrong. Obviously i'm in a party when i'm trying to run this code from the console.
 
I'd also like to know how to check party member's HP. The PartyMember object has no such parameter it seems.
 
I'm trying to sort through all my current party members, the goal is to eventually find heal targets.

Code:
foreach (PartyMember partyMember in PartyManager.Members)
         {
            Log(partyMember.Name);
         }

That code works, but the issue is that I can't get current health from partyMember.CurrentHealthPercent, so I try to use partyMember.GameObject as Character ...

Code:
foreach (PartyMember partyMember in PartyManager.Members)
         {
            Log((partyMember.GameObject as Character).Name);
         }

and it's throwing an object reference. In the past we could use party.GameObject.ToCharacter.CurrentHealthPercent but that was changed in the API. I don't know if this is an API error or if i'm doing something wrong. Obviously i'm in a party when i'm trying to run this code from the console.

I'll look into why this is throwing errors.

I'd also like to know how to check party member's HP. The PartyMember object has no such parameter it seems.

You need to use the partymember.gameobject to get that sort of information.
 
I'm trying to sort through all my current party members, the goal is to eventually find heal targets.

Code:
foreach (PartyMember partyMember in PartyManager.Members)
         {
            Log(partyMember.Name);
         }

That code works, but the issue is that I can't get current health from partyMember.CurrentHealthPercent, so I try to use partyMember.GameObject as Character ...

Code:
foreach (PartyMember partyMember in PartyManager.Members)
         {
            Log((partyMember.GameObject as Character).Name);
         }

and it's throwing an object reference. In the past we could use party.GameObject.ToCharacter.CurrentHealthPercent but that was changed in the API. I don't know if this is an API error or if i'm doing something wrong. Obviously i'm in a party when i'm trying to run this code from the console.


Code:
            foreach (var partyMember in PartyManager.Members.Where(r=>r.ObjectId > 0))
            {
                Log((partyMember.GameObject as Character).Name);
            }

Use this for now. Next version will have two properties instead of one, allmembers and visiblemembers.
 
Code you provided is returning a reference error.

Code:
] System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.NullReferenceException: Object reference not set to an instance of an object.
   at Driver.Run() in c:\Users\Public\Documents\RB\Plugins\RebornConsole\Temp\c3qn4wli.0.cs:line 31
   --- End of inner exception stack trace ---
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
   at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)
   at System.Type.InvokeMember(String name, BindingFlags invokeAttr, Binder binder, Object target, Object[] args)
   at HighVoltz.CodeDriver.CompileAndRun(String input) in c:\Users\Public\Documents\RB\Plugins\RebornConsole\RebornConsole.cs:line 419
   at HighVoltz.AppDomainDriver.CompileAndRun(String code) in c:\Users\Public\Documents\RB\Plugins\RebornConsole\RebornConsole.cs:line 289

Above you told Shifted that he could use PartyMember.GameObject to return HP, that's not the case for me as health, tp, mana and a lot of other info doesn't popup in the Intellisense when use PartyMember.GameObject.When I use (PartyMember.GameObject as Character) health etc become available but that's when the object error is thrown.
 
Code you provided is returning a reference error.

Code:
] System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.NullReferenceException: Object reference not set to an instance of an object.
   at Driver.Run() in c:\Users\Public\Documents\RB\Plugins\RebornConsole\Temp\c3qn4wli.0.cs:line 31
   --- End of inner exception stack trace ---
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
   at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)
   at System.Type.InvokeMember(String name, BindingFlags invokeAttr, Binder binder, Object target, Object[] args)
   at HighVoltz.CodeDriver.CompileAndRun(String input) in c:\Users\Public\Documents\RB\Plugins\RebornConsole\RebornConsole.cs:line 419
   at HighVoltz.AppDomainDriver.CompileAndRun(String code) in c:\Users\Public\Documents\RB\Plugins\RebornConsole\RebornConsole.cs:line 289

Above you told Shifted that he could use PartyMember.GameObject to return HP, that's not the case for me as it Health, TP, Mana and a lot of other info doesn't popup in the Intellisense. I'm able to print all party members names in the console use PartyMember.Name or PartyMember.GameObject.Name but if I need to get health, I use (PartyMember.GameObject as Character).CurrentHealth and that's when the object error is thrown.

Please show the code you were trying to use to print the health. I need to make it so it shows that in the log :/
 
This code...

Code:
foreach (var partyMember in PartyManager.Members.Where(r=>r.ObjectId > 0))
        {
         Log((partyMember.GameObject as Character).CurrentHealthPercent.ToString());
        }

returned this from the console...

Code:
100
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.NullReferenceException: Object reference not set to an instance of an object.
   at Driver.Run() in c:\Users\Public\Documents\RB\Plugins\RebornConsole\Temp\lfknphbl.0.cs:line 31
   --- End of inner exception stack trace ---
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
   at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)
   at System.Type.InvokeMember(String name, BindingFlags invokeAttr, Binder binder, Object target, Object[] args)
   at HighVoltz.CodeDriver.CompileAndRun(String input) in c:\Users\Public\Documents\RB\Plugins\RebornConsole\RebornConsole.cs:line 419
   at HighVoltz.AppDomainDriver.CompileAndRun(String code) in c:\Users\Public\Documents\RB\Plugins\RebornConsole\RebornConsole.cs:line 289

It prints the first 100, which I assume is my health.
 
This code...

Code:
foreach (var partyMember in PartyManager.Members.Where(r=>r.ObjectId > 0))
        {
         Log((partyMember.GameObject as Character).CurrentHealthPercent.ToString());
        }

returned this from the console...

Code:
100
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.NullReferenceException: Object reference not set to an instance of an object.
   at Driver.Run() in c:\Users\Public\Documents\RB\Plugins\RebornConsole\Temp\lfknphbl.0.cs:line 31
   --- End of inner exception stack trace ---
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
   at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)
   at System.Type.InvokeMember(String name, BindingFlags invokeAttr, Binder binder, Object target, Object[] args)
   at HighVoltz.CodeDriver.CompileAndRun(String input) in c:\Users\Public\Documents\RB\Plugins\RebornConsole\RebornConsole.cs:line 419
   at HighVoltz.AppDomainDriver.CompileAndRun(String code) in c:\Users\Public\Documents\RB\Plugins\RebornConsole\RebornConsole.cs:line 289

It prints the first 100, which I assume is my health.

How many people are in the party when your doing this and what are you doing at the time?
 
Was able to reproduce it. I rewrote most of the partymanager for the next version anyway today and most of that information can be fetched from the partymember object in the next version.
 
Was able to reproduce it. I rewrote most of the partymanager for the next version anyway today and most of that information can be fetched from the partymember object in the next version.

That's awesome, thanks much!
 
Back
Top