xsol
Member
- Joined
- Nov 7, 2011
- Messages
- 503
I would like add this code to Helpers:
The code returns a count of hostiles at a location and optional will determine the count based on if a buff/debuff is in place. This is simply code I find myself using a lot and the other functions enable more complex checks.
I want to evolve this to help check for targets that are "blinded" and switch to a new target that is not "blinded" as well as further locking down frag. grenade from breaking cc... so eventually there would be a methos that returns the first target not under n effect(s) at vector v...
If one of you wants to make something better...
MeleeTargets - and it's overloads return a count of targets in melee range of a location.
an example use case for me is:
Also I think we are going to need a master list/array of effects that we don't want to dps...
The code returns a count of hostiles at a location and optional will determine the count based on if a buff/debuff is in place. This is simply code I find myself using a lot and the other functions enable more complex checks.
I want to evolve this to help check for targets that are "blinded" and switch to a new target that is not "blinded" as well as further locking down frag. grenade from breaking cc... so eventually there would be a methos that returns the first target not under n effect(s) at vector v...
If one of you wants to make something better...
MeleeTargets - and it's overloads return a count of targets in melee range of a location.
an example use case for me is:
- nbt - not blind targets
- bt - blind targets
- ((nbt >= 2) && bt <= 2) -> AoE
Also I think we are going to need a master list/array of effects that we don't want to dps...
PHP:
public enum BuffCheckType
{
HasNone,
HasAny,
HasAll
}
public enum EffectType
{
Buff,
DeBuff
}
//xsol - 11.5.2012
public static bool HasAnyBuff(TorCharacter unit, string[] buffs)
{
foreach (string s in buffs)
{
if (unit.HasBuff(s))
return true;
}
return false;
}
//xsol - 11.5.2012
public static bool HasAllBuffs(TorCharacter unit, string[] buffs)
{
foreach (string s in buffs)
{
if (!unit.HasBuff(s))
return false;
}
return true;
}
//xsol - 11.5.2012
public static bool HasAnyDebuff(TorCharacter unit, string[] debuffs)
{
foreach (string s in debuffs)
{
if (unit.HasDebuff(s))
return true;
}
return false;
}
//xsol - 11.5.2012
public static bool HasAllDebuffs(TorCharacter unit, string[] debuffs)
{
foreach (string s in debuffs)
{
if (!unit.HasDebuff(s))
return false;
}
return true;
}
//xsol - 11.5.2012 - Determines the number of hostile targets at your location.
public static int MeleeTargets()
{
return MeleeTargets(BuddyTor.Me.CurrentTarget.Position);
}
//xsol - 11.5.2012 - etermines the number of hostile targets at a location.
public static int MeleeTargets(Vector3 position)
{
return ObjectManager.GetObjects<Buddy.Swtor.Objects.TorNpc>().Count(
o =>
Buddy.Common.Math.Vector3.Distance(position, o.Position) <= Global.meleeDist &&
o.IsHostile);
}
//xsol - 11.5.2012 -Determines the number of hostile target at your location.
public static int MeleeTargets(Vector3 position, string[] effects, BuffCheckType check, EffectType checkFor)
{
if (checkFor == EffectType.Buff)
{
switch (check)
{
case BuffCheckType.HasAll:
return ObjectManager.GetObjects<Buddy.Swtor.Objects.TorNpc>().Count(
o =>
Buddy.Common.Math.Vector3.Distance(position, o.Position) <= Global.meleeDist &&
o.IsHostile &&
HasAllBuffs(o, effects));
case BuffCheckType.HasAny:
return ObjectManager.GetObjects<Buddy.Swtor.Objects.TorNpc>().Count(
o =>
Buddy.Common.Math.Vector3.Distance(position, o.Position) <= Global.meleeDist &&
o.IsHostile &&
HasAnyBuff(o, effects));
case BuffCheckType.HasNone:
return ObjectManager.GetObjects<Buddy.Swtor.Objects.TorNpc>().Count(
o =>
Buddy.Common.Math.Vector3.Distance(position, o.Position) <= Global.meleeDist &&
o.IsHostile &&
!HasAnyBuff(o, effects));
default:
return ObjectManager.GetObjects<Buddy.Swtor.Objects.TorNpc>().Count(
o =>
Buddy.Common.Math.Vector3.Distance(position, o.Position) <= Global.meleeDist &&
o.IsHostile &&
HasAllBuffs(o, effects));
}
}
else
{
switch (check)
{
case BuffCheckType.HasAll:
return ObjectManager.GetObjects<Buddy.Swtor.Objects.TorNpc>().Count(
o =>
Buddy.Common.Math.Vector3.Distance(position, o.Position) <= Global.meleeDist &&
o.IsHostile &&
HasAllDebuffs(o, effects));
case BuffCheckType.HasAny:
return ObjectManager.GetObjects<Buddy.Swtor.Objects.TorNpc>().Count(
o =>
Buddy.Common.Math.Vector3.Distance(position, o.Position) <= Global.meleeDist &&
o.IsHostile &&
HasAnyDebuff(o, effects));
case BuffCheckType.HasNone:
return ObjectManager.GetObjects<Buddy.Swtor.Objects.TorNpc>().Count(
o =>
Buddy.Common.Math.Vector3.Distance(position, o.Position) <= Global.meleeDist &&
o.IsHostile &&
!HasAnyDebuff(o, effects));
default:
return ObjectManager.GetObjects<Buddy.Swtor.Objects.TorNpc>().Count(
o =>
Buddy.Common.Math.Vector3.Distance(position, o.Position) <= Global.meleeDist &&
o.IsHostile &&
HasAllDebuffs(o, effects));
}
}
}
//xsol - 11.5.2012
public static int MeleeTargets(string[] effects, BuffCheckType check, EffectType checkFor)
{
return MeleeTargets(BuddyTor.Me.CurrentTarget.Position, effects, check, checkFor);
}