示例#1
0
 public void ClearThreat(Creature threat)
 {
     if (ThreatTableByCreature.ContainsKey(threat.Guid))
     {
         ThreatTableByCreature[threat.Guid].Threat = 0;
     }
 }
示例#2
0
 public void DecreaseThreat(Creature threat, uint amount)
 {
     if (ThreatTableByCreature.ContainsKey(threat.Guid))
     {
         ThreatTableByCreature[threat.Guid].Threat -= amount;
     }
 }
示例#3
0
 public void IncreaseThreat(Creature threat, uint amount)
 {
     if (!ThreatTableByCreature.ContainsKey(threat.Guid))
     {
         AddNewThreat(threat, amount);
     }
     ThreatTableByCreature[threat.Guid].Threat += amount;
 }
示例#4
0
 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}");
 }
示例#5
0
    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);
    }
示例#6
0
    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);
    }
示例#7
0
 public bool ContainsAny(List <User> users) => users.Any(user => ThreatTableByCreature.ContainsKey(user.Guid));
示例#8
0
 public bool ContainsThreat(Creature threat) => ThreatTableByCreature.ContainsKey(threat.Guid);
示例#9
0
 public void RemoveAllThreats()
 {
     ThreatTableByCreature.Clear();
     ThreatTableByThreat.Clear();
 }