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

targeting unit or player?

hazard

Well-Known Member
Joined
Sep 16, 2010
Messages
1,854
Reaction score
55
Is there a way that I can change this line so when in battlegrounds it loads as:
Code:
WoWUnit u = ObjectManager.GetObjectsOfType'WoWPlayer'<wowplayer><wowplayer>(false, false).FirstOrDefault(unit => Me.IsAlive && unit.IsHostile && unit.IsAlive && unit.Distance2D < 40 && !unit.Mounted && unit.InLineOfSight);

and when in dungeons, raids, solo it loads this instead:
Code:
WoWUnit u = ObjectManager.GetObjectsOfType</wowplayer></wowplayer>'WoWUnit'<wowplayer><wowplayer><wowunit><wowunit>(false, false).FirstOrDefault(unit => Me.IsAlive && unit.IsHostile && unit.IsAlive && unit.Distance2D < 40 && !unit.Mounted && unit.InLineOfSight);
</wowunit></wowunit></wowplayer></wowplayer>
 
Thread: targeting unit or player?

You can perform this kind of tests

PHP:
var unit = ...
bool blnIfUnitIsPlayer = unit is WoWPlayer
 
Sorry I don't understand what you mean?

Edit: Ow think I figured out what you mean. Thank you.
 
Last edited:
Code:
WoWUnit unit = StyxWoW.Me.CurrentTarget;
unit is WoWPlayer
unit.IsPlayer 
(unit as WoWPlayer) != null

You can use any of the above to check if a unit is a player.
 
This is what I am using at the moment but it is not working?

Code:
var u = ObjectManager.GetObjectsOfType<wowplayer> < WoWPlayer > (false, false).FirstOrDefault(unit => Me.IsAlive && unit.IsHostile && unit.IsAlive && unit.Distance2D < 30 && !unit.Mounted && unit.InLineOfSight);

bool blnIfUnitIsUnit = u is WoWUnit;

if (u != null)
</wowplayer>
 
Last edited:
I don't think you understand the inheritance we use.

A WoWPlayer is a WoWUnit, a WoWUnit is a WoWObject. (So, checking somePlayer is WoWUnit will always be true, since a WoWPlayer *is* a WoWUnit)
 
Back
Top