本文整理汇总了C#中WoWUnit.ToPlayer方法的典型用法代码示例。如果您正苦于以下问题:C# WoWUnit.ToPlayer方法的具体用法?C# WoWUnit.ToPlayer怎么用?C# WoWUnit.ToPlayer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WoWUnit
的用法示例。
在下文中一共展示了WoWUnit.ToPlayer方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IsMeOrMyGroup
public static bool IsMeOrMyGroup(WoWUnit unit)
{
if (unit != null)
{
// find topmost unit in CreatedByUnit chain
while (unit.CreatedByUnit != null)
unit = unit.CreatedByUnit;
if (unit.IsMe)
return true;
if (unit.IsPlayer)
{
WoWPlayer p = unit.ToPlayer();
if (p.IsHorde == Me.IsHorde && PartyManager.GroupMembers.Contains(unit.ToPlayer()))
return true;
}
}
return false;
}
示例2: ShouldAttack
public static bool ShouldAttack(WoWUnit unit)
{
if (unit == null)
{
return false;
}
if (IsFocusTarget(unit) && unit.IsAlive) {
return true;
}
if (unit.Name == "Training Dummy" || unit.Name == "Raider's Training Dummy" )
{
return true;
}
return unit.Attackable
&& unit.IsValid
&& !unit.IsFriendly
&& !IsCrowdControlled(unit)
&& unit.IsAlive
&& unit.Combat
&& (!unit.IsPlayer || unit.ToPlayer().IsHorde != Me.IsHorde)
&& !IsMeOrMyGroup(unit)
// && (IsTargetingMeOrMyGroup(unit) || unit.CreatureType == WoWCreatureType.Totem)
&& !Blacklist.Contains(unit.Guid)
&& !IsIgnoreTarget(unit);
}
示例3: Safe_UnitName
private static string Safe_UnitName(WoWUnit unit)
{
if (unit == null)
return "(null)";
#if HIDE_PLAYER_NAMES
if (unit.IsMe)
return "-me-";
else if (unit.IsPlayer ) // && Safe_IsFriendly(unit)) // !unit.IsHostile ) // unit.IsFriendly)
return unit.Class.ToString() + "." + unit.MaxHealth.ToString();
#else
if (unit.IsPlayer) // && Safe_IsFriendly(unit)) // !unit.IsHostile ) // unit.IsFriendly)
return unit.Name + "." + unit.Class.ToString() + (unit.ToPlayer().IsHorde ? "[H]" : "[A]");
#endif
return unit.Name;
}
示例4: IsHostile
private bool IsHostile(WoWUnit unit)
{
if (unit == null)
return false;
if (unit.IsPlayer)
return Me.IsHorde != unit.ToPlayer().IsHorde;
return !unit.IsFriendly && unit.Attackable;
}
示例5: IsEnemy
public static bool IsEnemy(WoWUnit u)
{
if (u == null || !u.CanSelect || !u.Attackable || !u.IsAlive || u.IsNonCombatPet || u.IsCritter)
return false;
if (!u.IsPlayer)
return u.IsHostile || u.Aggro || u.PetAggro;
WoWPlayer p = u.ToPlayer();
/* // not supported currently
if (Battlegrounds.IsInsideBattleground)
return p.BattlefieldArenaFaction != Me.BattlefieldArenaFaction;
*/
return p.IsHorde != Me.IsHorde;
}
示例6: CheckTarget
private void CheckTarget(WoWUnit unit, ref WoWGuid prevGuid, string description, OnTargetChange onchg)
{
// there are moments where CurrentTargetGuid != 0 but CurrentTarget == null. following
// .. tries to handle by only checking CurrentTarget reference and treating null as guid = 0
if (unit == null)
{
if (prevGuid.IsValid)
{
prevGuid = WoWGuid.Empty;
onchg(unit);
if (SingularSettings.Debug)
Logger.WriteDebug(description + ": changed to: (null)");
}
}
else if (unit.Guid != prevGuid)
{
prevGuid = unit.Guid;
onchg(unit);
if (SingularSettings.Debug)
{
//Logger.WriteDebug( "GuidInfo: {0}", unit.Guid.ToString());
//Logger.WriteDebug("GuidInfo: {0:X4} {1:X4} {2:X4} {3:X4}", unit.Guid.Highest, unit.Guid.Higher, unit.Guid.Lower, unit.Guid.Lowest);
string info = "";
if (Styx.CommonBot.POI.BotPoi.Current.Guid == Me.CurrentTargetGuid)
info += string.Format(", IsBotPoi={0}", Styx.CommonBot.POI.BotPoi.Current.Type);
if (Styx.CommonBot.Targeting.Instance.TargetList.Contains(Me.CurrentTarget))
info += string.Format(", TargetIndex={0}", Styx.CommonBot.Targeting.Instance.TargetList.IndexOf(Me.CurrentTarget) + 1);
string playerInfo = "N";
if (unit.IsPlayer)
{
WoWPlayer p = unit.ToPlayer();
playerInfo = string.Format("Y, Friend={0}, IsPvp={1}, CtstPvp={2}, FfaPvp={3}", Me.IsHorde == p.IsHorde, p.IsPvPFlagged, p.ContestedPvPFlagged, p.IsFFAPvPFlagged);
}
else
{
info += string.Format(", creature={0}, tagme={1}, tagother={2}, tapall={3}",
unit.CreatureType,
unit.TaggedByMe.ToYN(),
unit.TaggedByOther.ToYN(),
unit.TappedByAllThreatLists.ToYN()
);
}
Logger.WriteDebug(description + ": changed to: {0} lvl={1} h={2:F1}%, maxh={3}, d={4:F1} yds, box={5:F1}, boss={6}, trivial={7}, player={8}, attackable={9}, neutral={10}, hostile={11}, entry={12}, faction={13}, loss={14}, facing={15}, blacklist={16}, combat={17}, flying={18}, abovgrnd={19}" + info,
unit.SafeName(),
unit.Level,
unit.HealthPercent,
unit.MaxHealth,
unit.Distance,
unit.CombatReach,
unit.IsBoss().ToYN(),
unit.IsTrivial().ToYN(),
playerInfo,
unit.Attackable.ToYN(),
unit.IsNeutral().ToYN(),
unit.IsHostile.ToYN(),
unit.Entry,
unit.FactionId,
unit.InLineOfSpellSight.ToYN(),
Me.IsSafelyFacing(unit).ToYN(),
Blacklist.Contains(unit.Guid, BlacklistFlags.Combat).ToYN(),
unit.Combat.ToYN(),
unit.IsFlying.ToYN(),
unit.IsAboveTheGround().ToYN()
);
}
}
}
示例7: CanCastHackInRange
public static bool CanCastHackInRange(WoWSpell spell, WoWUnit unit)
{
if (unit != null && !spell.IsSelfOnlySpell && !unit.IsMe)
{
#if USE_LUA_RANGECHECK
// will exercise the IsSpellInRange LUA if it can easily
// .. derive a UnitID for the target
string sTarget = null;
if (unit.Guid == Me.CurrentTargetGuid)
sTarget = "target";
else if (unit.IsPlayer && unit.ToPlayer().IsInMyPartyOrRaid())
sTarget = unit.Name;
else if (unit.IsPet && unit.OwnedByUnit != null && unit.OwnedByUnit.IsPlayer && unit.OwnedByUnit.ToPlayer().IsInMyPartyOrRaid())
sTarget = unit.OwnedByUnit.Name + "-pet";
else if (Me.GotAlivePet)
{
if (unit.Guid == Me.Pet.Guid)
sTarget = "pet";
else if (unit.Guid == Me.Pet.CurrentTargetGuid)
sTarget = "pettarget";
}
if (sTarget != null)
{
//
string lua = string.Format("return IsSpellInRange(\"{0}\",\"{1}\")", spell.Name, sTarget);
string inRange = Lua.GetReturnVal<string>(lua, 0);
if (inRange != "1")
{
if (SingularSettings.DebugSpellCanCast)
Logger.WriteFile( "CanCast[{0}]: target @ {1:F1} yds failed IsSpellInRange() = {2}", spell.Name, unit.Distance, inRange);
return false;
}
}
else
#endif
{
if (spell.IsMeleeSpell && !unit.IsWithinMeleeRange)
{
if (SingularSettings.DebugSpellCasting)
Logger.WriteFile( "CanCast[{0}]: target @ {1:F1} yds not in melee range", spell.Name, unit.Distance);
return false;
}
else if (spell.HasRange)
{
if (unit.Distance > spell.ActualMaxRange(unit))
{
if (SingularSettings.DebugSpellCasting)
Logger.WriteFile( "CanCast[{0}]: out of range - further than {1:F1}", spell.Name, spell.ActualMaxRange(unit));
return false;
}
if (unit.Distance < spell.ActualMinRange(unit))
{
if (SingularSettings.DebugSpellCasting)
Logger.WriteFile( "CanCast[{0}]: out of range - closer than {1:F1}", spell.Name, spell.ActualMinRange(unit));
return false;
}
}
}
if (!unit.InLineOfSpellSight)
{
if (SingularSettings.DebugSpellCasting)
Logger.WriteFile( "CanCast[{0}]: not in spell line of {1}", spell.Name, unit.SafeName());
return false;
}
}
return true;
}
示例8: IsEnemyPlayer
private static bool IsEnemyPlayer(WoWUnit u)
{
return u.IsPlayer
&& (u.ToPlayer().IsHorde != StyxWoW.Me.IsHorde || (Battlegrounds.IsInsideBattleground && !u.ToPlayer().IsInMyPartyOrRaid ));
}
示例9: IsEnemy
/// <summary>
/// Does minimal testing to see if a WoWUnit should be treated as an enemy. Avoids
/// searching lists (such as TargetList)
/// </summary>
/// <param name="u"></param>
/// <returns></returns>
public static bool IsEnemy(WoWUnit u)
{
if (u == null || !u.CanSelect || !u.Attackable || !u.IsAlive || u.IsNonCombatPet)
return false;
if (BotPoi.Current.Guid == u.Guid && BotPoi.Current.Type == PoiType.Kill)
return true;
if (u.IsCritter && u.ThreatInfo.ThreatValue == 0)
return true;
if (!u.IsPlayer)
return u.IsHostile || u.Aggro || u.PetAggro;
WoWPlayer p = u.ToPlayer();
/* // not supported currently
if (Battlegrounds.IsInsideBattleground)
return p.BattlefieldArenaFaction != Me.BattlefieldArenaFaction;
*/
return p.IsHostile; // || p.IsHorde != Me.IsHorde;
}
示例10: ValidUnit
public static bool ValidUnit(WoWUnit p, bool showReason = false)
{
if (p == null || !p.IsValid)
return false;
if (StyxWoW.Me.IsInInstance && IgnoreMobs.Contains(p.Entry))
{
if (showReason) Logger.Write(invalidColor, "invalid attack unit {0} is an Instance Ignore Mob", p.SafeName());
return false;
}
// Ignore shit we can't select
if (!p.CanSelect )
{
if (showReason) Logger.Write(invalidColor, "invalid attack unit {0} cannot be Selected", p.SafeName());
return false;
}
// Ignore shit we can't attack
if (!p.Attackable)
{
if (showReason) Logger.Write(invalidColor, "invalid attack unit {0} cannot be Attacked", p.SafeName());
return false;
}
// Duh
if (p.IsDead)
{
if (showReason) Logger.Write(invalidColor, "invalid attack unit {0} is already Dead", p.SafeName());
return false;
}
// check for enemy players here as friendly only seems to work on npc's
if (p.IsPlayer)
return p.ToPlayer().IsHorde != StyxWoW.Me.IsHorde;
// Ignore friendlies!
if (p.IsFriendly)
{
if (showReason) Logger.Write(invalidColor, "invalid attack unit {0} is Friendly", p.SafeName());
return false;
}
// Dummies/bosses are valid by default. Period.
if (p.IsTrainingDummy() || p.IsBoss())
return true;
// If it is a pet/minion/totem, lets find the root of ownership chain
WoWUnit pOwner = GetPlayerParent(p);
// ignore if owner is player, alive, and not blacklisted then ignore (since killing owner kills it)
if (pOwner != null && pOwner.IsAlive && !Blacklist.Contains(pOwner, BlacklistFlags.Combat))
{
if (showReason) Logger.Write(invalidColor, "invalid attack unit {0} has a Player as Parent", p.SafeName());
return false;
}
// And ignore critters (except for those ferocious ones) /non-combat pets
if (p.IsNonCombatPet)
{
if (showReason) Logger.Write(invalidColor, "{0} is a Noncombat Pet", p.SafeName());
return false;
}
// And ignore critters (except for those ferocious ones) /non-combat pets
if (p.IsCritter && p.ThreatInfo.ThreatValue == 0 && !p.IsTargetingMyRaidMember)
{
if (showReason) Logger.Write(invalidColor, "{0} is a Critter", p.SafeName());
return false;
}
/*
if (p.CreatedByUnitGuid != 0 || p.SummonedByUnitGuid != 0)
return false;
*/
return true;
}
示例11: ValidUnit
public static bool ValidUnit(WoWUnit p, bool showReason = false)
{
if (p == null || !p.IsValid)
return false;
if (StyxWoW.Me.IsInInstance && IgnoreMobs.Contains(p.Entry))
{
if (showReason) Logger.Write(invalidColor, "invalid attack unit {0} is an Instance Ignore Mob", p.SafeName());
return false;
}
// Ignore shit we can't select
if (!p.CanSelect )
{
if (showReason) Logger.Write(invalidColor, "invalid attack unit {0} cannot be Selected", p.SafeName());
return false;
}
// Ignore shit we can't attack
if (!p.Attackable)
{
if (showReason) Logger.Write(invalidColor, "invalid attack unit {0} cannot be Attacked", p.SafeName());
return false;
}
// Duh
if (p.IsDead)
{
if (showReason) Logger.Write(invalidColor, "invalid attack unit {0} is already Dead", p.SafeName());
return false;
}
// check for enemy players here as friendly only seems to work on npc's
if (p.IsPlayer)
{
WoWPlayer pp = p.ToPlayer();
if (pp.IsHorde == StyxWoW.Me.IsHorde && !pp.IsHostile)
{
if (showReason)
Logger.Write(invalidColor, "invalid attack player {0} not a hostile enemy", p.SafeName());
return false;
}
if (!pp.CanWeAttack())
{
if (showReason)
Logger.Write(invalidColor, "invalid attack player {0} cannot be Attacked currently", p.SafeName());
return false;
}
return true;
}
// Ignore evading NPCs
if (p.IsEvading())
{
if (showReason)
Logger.Write(invalidColor, "invalid unit, {0} game flagged as evading", p.SafeName());
return false;
}
// Ignore friendlies!
if (p.IsFriendly)
{
if (showReason) Logger.Write(invalidColor, "invalid attack unit {0} is Friendly", p.SafeName());
return false;
}
// Dummies/bosses are valid by default. Period.
if (p.IsTrainingDummy() || p.IsBoss())
return true;
// If it is a pet/minion/totem, lets find the root of ownership chain
WoWPlayer pOwner = GetPlayerParent(p);
// ignore if owner is player, alive, and not blacklisted then ignore (since killing owner kills it)
// .. following .IsMe check to prevent treating quest mob summoned by us that we need to kill as invalid
if (pOwner != null && pOwner.IsAlive && !pOwner.IsMe)
{
if (!ValidUnit(pOwner))
{
if (showReason)
Logger.Write(invalidColor, "invalid attack unit {0} - pets parent not an attackable Player", p.SafeName());
return false;
}
if (!StyxWoW.Me.IsPvPFlagged)
{
if (showReason)
Logger.Write(invalidColor, "valid attackable player {0} but I am not PvP Flagged", p.SafeName());
return false;
}
if (Blacklist.Contains(pOwner, BlacklistFlags.Combat))
{
if (showReason)
Logger.Write(invalidColor, "invalid attack unit {0} - Parent blacklisted for combat", p.SafeName());
return false;
}
return true;
}
//.........这里部分代码省略.........
示例12: Filter
/// <summary>
/// Filter for Healable Unit
/// </summary>
/// <param name="unit">the unit to check</param>
/// <returns>returns true if the unit meets the requirements to be a HealableUnit</returns>
public static bool Filter(WoWUnit unit)
{
try {
if (unit != null && unit.IsMe) return true; // im always valid..bazinga :P
return unit != null && (unit.IsValid &&
unit.ToPlayer().IsAlive &&
!unit.ToPlayer().IsGhost &&
unit.ToPlayer().IsPlayer &&
unit.ToPlayer() != null &&
!unit.ToPlayer().IsFlying &&
!unit.ToPlayer().OnTaxi &&
unit.Distance2DSqr < 40 * 40);
} catch (Exception ex) {
CLULogger.DiagnosticLog("Filter : {0}", ex);
}
return false;
}
示例13: CheckTarget
private void CheckTarget(WoWUnit unit, ref ulong prevGuid, string description)
{
// there are moments where CurrentTargetGuid != 0 but CurrentTarget == null. following
// .. tries to handle by only checking CurrentTarget reference and treating null as guid = 0
if (unit == null)
{
if (prevGuid != 0)
{
prevGuid = 0;
Logger.WriteDebug(description + ": changed to: (null)");
HandleTrainingDummy(unit);
}
}
else if (unit.Guid != prevGuid)
{
prevGuid = unit.Guid;
HandleTrainingDummy(unit);
string info = "";
if (Styx.CommonBot.POI.BotPoi.Current.Guid == Me.CurrentTargetGuid)
info += string.Format(", IsBotPoi={0}", Styx.CommonBot.POI.BotPoi.Current.Type);
if (Styx.CommonBot.Targeting.Instance.TargetList.Contains(Me.CurrentTarget))
info += string.Format(", TargetIndex={0}", Styx.CommonBot.Targeting.Instance.TargetList.IndexOf(Me.CurrentTarget) + 1);
string playerInfo = "N";
if (unit.IsPlayer)
{
WoWPlayer p = unit.ToPlayer();
playerInfo = string.Format("Y, Friend={0}, IsPvp={1}, CtstPvp={2}, FfaPvp={3}", Me.IsHorde == p.IsHorde, p.IsPvPFlagged, p.ContestedPvPFlagged, p.IsFFAPvPFlagged);
}
Logger.WriteDebug(description + ": changed to: {0} h={1:F1}%, maxh={2}, d={3:F1} yds, box={4:F1}, trivial={5}, player={6}, attackable={7}, neutral={8}, hostile={9}, entry={10}, faction={11}, loss={12}, facing={13}, blacklist={14}, combat={15}" + info,
unit.SafeName(),
unit.HealthPercent,
unit.MaxHealth,
unit.Distance,
unit.CombatReach,
unit.IsTrivial(),
playerInfo,
unit.Attackable.ToYN(),
unit.IsNeutral().ToYN(),
unit.IsHostile.ToYN(),
unit.Entry,
unit.FactionId,
unit.InLineOfSpellSight.ToYN(),
Me.IsSafelyFacing(unit).ToYN(),
Blacklist.Contains(unit.Guid, BlacklistFlags.Combat).ToYN(),
unit.Combat.ToYN()
);
}
}