Jump to content

A few questions about the CustomClass


iMod
 Share

Recommended Posts

        // Get player around us
        List<WoWPlayer> randomPlayer = new List<WoWPlayer>();

        // Get specified player
        ObjectManager.GetNearestWoWPlayer(randomPlayer);

this code returns randomPlayer.Count == 0 even if there are player around me

 

Interact.InteractGameObject(ObjectManager.ObjectList.Single(o => o.Name == "CharName" && o.Type == WoWObjectType.Player).GetBaseAddress, false);

this code should target the player with the name "CharName" but in my test it doesnt target anything.

 

It seems that i'm doing something generally wrong. Hopefully someone can give me a hint.

Link to comment
Share on other sites

what are you trying to do ? If your interact returns null, wrobot will crash.

public WoWPlayer getNearestPlayer
        {
            get
            {
                var t = ObjectManager.GetObjectWoWPlayer().Where(p => p != null //from here on you can add checks
                    && p.IsAlive 

                    && p.IsHorde //or p.IsAlliance
                    && !TraceLine.TraceLineGo(p.Position) //test if no objects between you and target (target is in line of sight)
                    && p.GetDistance <= 40).OrderBy(p => p.HealthPercent).ThenBy(p => p.GetDistance).ToList(); //1st sort on healtpercent and if you want then by distance
                if (t.Count() > 0) // check if t > 0, what means he find something you ask
                {
                    WoWPlayer v = new WoWPlayer(t.FirstOrDefault().GetBaseAddress);
                    return v;
                }
                return null; //if t == 0 then return null
            }
        }

then yo can use getNearestPlayer to do something in your code

if (getNearestPlayer != null)

{

      try

    {

         Interact.InteractGameObject(getNearestPlayer.GetBaseAddress);

         spell.Launch();

     }
     catch (Exception e) { Logging.WriteError("ErrorDescription: " + e.ToString()); }

}

 

Link to comment
Share on other sites

Hello,

8 hours ago, iMod said:
        // Get player around us
        List<WoWPlayer> randomPlayer = new List<WoWPlayer>();

        // Get specified player
        ObjectManager.GetNearestWoWPlayer(randomPlayer);

this code returns randomPlayer.Count == 0 even if there are player around me

Use this code for it:

WoWPlayer randomPlayer = ObjectManager.GetNearestWoWPlayer(ObjectManager.GetObjectWoWPlayer());

 

8 hours ago, iMod said:

 

Interact.InteractGameObject(ObjectManager.ObjectList.Single(o => o.Name == "CharName" && o.Type == WoWObjectType.Player).GetBaseAddress, false);

this code should target the player with the name "CharName" but in my test it doesnt target anything.

 

It seems that i'm doing something generally wrong. Hopefully someone can give me a hint.

Try this: 

        WoWPlayer player = ObjectManager.GetObjectWoWPlayer().FirstOrDefault(o => o.Name == "CharName");
        if (player != null && player.IsValid)
        {
            Interact.InteractGameObject(player.GetBaseAddress, false);
        }

 

Link to comment
Share on other sites

It also seems that the settings don't save if you are using the same value as the default

Example: 

        [Setting]
        [DefaultValue(80)]
        [Category("HealSettings")]
        [DisplayName("Rejuvenation")]
        [Description("Player health procent")]
        public int RejuvenationProcent { get; set; }

If i load the setting the first time the value is 0 and if i try to save the same value (80) it wont work but 81 or 79 is working.

Link to comment
Share on other sites

I also have problems with a debuff as DK

Example: i'm trying to use icy touch only if the debuff "Frost Fever" does not exists.

public Spell FrostFever = new Spell("Frost Fever");

if(!this._target.HaveBuff(this.FrostFever.Id))
{
	// Use spell
}

This does not work for me. If i replace the "this.FrostFever.Id" with the string "HaveBuff("Frost Fever")" it works.

 

This is the function i wrote for my spells but it wont work if the framework dont detect the debuff with id

private void UseSpell(Spell spell, bool canMove, List<uint> dependencies)
  {
  // Set current target
  this._target = ObjectManager.Me.TargetObject;

  // Valid?
  if (this._target.IsValid && spell.KnownSpell && spell.IsSpellUsable && spell.IsDistanceGood && !this._target.HaveBuff(dependencies))
  {
  // Cast spell
  spell.Launch(canMove, true);
  }
  }

 

Link to comment
Share on other sites

  • 1 month later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...