public void ClearThreat(Creature threat) { if (ThreatTableByCreature.ContainsKey(threat.Guid)) { ThreatTableByCreature[threat.Guid].Threat = 0; } }
public void DecreaseThreat(Creature threat, uint amount) { if (ThreatTableByCreature.ContainsKey(threat.Guid)) { ThreatTableByCreature[threat.Guid].Threat -= amount; } }
public void IncreaseThreat(Creature threat, uint amount) { if (!ThreatTableByCreature.ContainsKey(threat.Guid)) { AddNewThreat(threat, amount); } ThreatTableByCreature[threat.Guid].Threat += amount; }
public void RemoveThreat(Creature threat) { if (!ThreatTableByCreature.TryGetValue(threat.Guid, out ThreatEntry entry)) { return; } ThreatTableByCreature.Remove(threat.Guid); ThreatTableByThreat.Remove(entry); GameLog.Error($"{OwnerObject.Id}: Removed threat {threat.Id}"); }
public void AddNewThreat(Creature newThreat, uint amount = 0) { var entry = new ThreatEntry(newThreat.Guid) { Threat = amount }; ThreatTableByCreature.Add(newThreat.Guid, entry); ThreatTableByThreat.Add(entry, newThreat.Guid); }
public List <Creature> GetTargets(CreatureTargetPriority priority) { var ret = new List <Creature>(); ThreatEntry entry; switch (priority) { case CreatureTargetPriority.HighThreat: ret.Add(Game.World.WorldData.GetWorldObject <Creature>(ThreatTableByThreat.First().Value)); break; case CreatureTargetPriority.LowThreat: ret.Add(Game.World.WorldData.GetWorldObject <Creature>(ThreatTableByThreat.First().Value)); break; case CreatureTargetPriority.Attacker: entry = ThreatTableByThreat.Keys.OrderByDescending(x => x.SecondsSinceLastMelee) .FirstOrDefault(); if (entry != null) { ret.Add(entry.TargetObject); } break; case CreatureTargetPriority.AttackingCaster: entry = ThreatTableByThreat.Keys.Where(x => x.IsCaster).OrderByDescending(x => x.SecondsSinceLastNonHealCast) .FirstOrDefault(); if (entry != null) { ret.Add(entry.TargetObject); } break; case CreatureTargetPriority.AttackingGroup: entry = ThreatTableByThreat.Keys.OrderByDescending(x => x.SecondsSinceLastMelee) .FirstOrDefault(); if (entry != null) { ret.Add(entry.TargetObject); } break; case CreatureTargetPriority.AttackingHealer: entry = ThreatTableByThreat.Keys.Where(x => x.IsHealer).OrderByDescending(x => x.SecondsSinceLastHeal) .FirstOrDefault(); if (entry != null) { ret.Add(entry.TargetObject); } break; case CreatureTargetPriority.AllAllies: ret.AddRange(OwnerObject.Map.EntityTree.GetObjects(OwnerObject.GetViewport()).OfType <Monster>().Select(x => x as Creature).ToList()); break; case CreatureTargetPriority.RandomAlly: ret.Add(OwnerObject.Map.EntityTree.GetObjects(OwnerObject.GetViewport()).OfType <Monster>().Select(x => x as Creature).PickRandom()); break; case CreatureTargetPriority.RandomAttacker: ret.Add(Game.World.WorldData.GetWorldObject <Creature>(ThreatTableByCreature.PickRandom().Key)); break; case CreatureTargetPriority.Self: ret.Add(OwnerObject); break; default: break; } return(ret); }
public bool ContainsAny(List <User> users) => users.Any(user => ThreatTableByCreature.ContainsKey(user.Guid));
public bool ContainsThreat(Creature threat) => ThreatTableByCreature.ContainsKey(threat.Guid);
public void RemoveAllThreats() { ThreatTableByCreature.Clear(); ThreatTableByThreat.Clear(); }