public Player GetMaxAggroPlayerHate() { UInt64 TotalDamages = TotalDamageReceive(); AggroInfo Aggro = null; float MaxHate = -1; AggroInfo Info; foreach (KeyValuePair <ushort, AggroInfo> Kp in _Aggros) { Info = Kp.Value; if (!Info.IsPlayer) { continue; } float Hate = Info.GetHate(TotalDamages); if (Hate > MaxHate) { MaxHate = Hate; Aggro = Info; } } if (Aggro != null) { return(_Owner.Region.GetPlayer(Aggro.Oid)); } return(null); }
public void SquigForm(byte enable) { Creature c = Obj as Creature; c.Ranged = 15; ChangeModel(c, enable); ApplyStatChange(c); // Size increase if (enable == 1) { c.OSInterface.AddEffect(1); // State 1 Champ, State 7 Super Champ } else { c.OSInterface.RemoveEffect(1); // State 1 Champ, State 7 Super Champ } AggroInfo aggro = c.AiInterface.CurrentBrain.GetMaxAggroHate(); if (aggro != null) { foreach (Player player in c.PlayersInRange) { if (c.PlayersInRange.ToList().Count() == 1 || (player != null && aggro.Oid != player.Oid)) { c.MvtInterface.StopMove(); c.AiInterface.CurrentBrain.Chase(player, true); break; } } } }
public AggroInfo GetAggro(UInt16 Oid, bool Create = true) { AggroInfo Info = null; if (!_Aggros.TryGetValue(Oid, out Info) && Create) { Info = new AggroInfo(Oid); _Aggros.Add(Oid, Info); } return(Info); }
protected AggroInfo GetAggro(ushort oid) { AggroInfo info; if (Aggros.TryGetValue(oid, out info)) { return(info); } info = new AggroInfo(oid); Aggros.Add(oid, info); return(info); }
public Unit GetNextTarget() { Unit Me = GetUnit(); Unit Target = null; if (!Me.IsPlayer()) { AggroInfo Info = GetMaxAggroHate(true); if (Info == null) { Info = GetMaxAggroHate(false); } if (Info != null) { Target = _Owner.Region.GetObject(Info.Oid) as Unit; } } else { Target = GetTarget(GameData.TargetTypes.TARGETTYPES_TARGET_ENEMY); } if (Target == null) { return(null); } if (!Target.IsInWorld()) { return(null); } if (Target.IsDead) { if (AI.State == AiState.FIGHTING) { OnTargetDie(Target); } return(null); } return(Target); }
public AggroInfo GetMaxAggroHate() { AggroInfo maxAggro = null; float maxHate = -1; foreach (AggroInfo aggro in Aggros.Values) { float hate = aggro.GetHate(); if (hate > maxHate) { maxHate = hate; maxAggro = aggro; } } return(maxAggro); }
public virtual Unit GetNextTarget() { while (Aggros.Count > 0) { AggroInfo info = GetMaxAggroHate(); Unit target = _unit.Region.GetObject(info.Oid) as Unit; if (target == null || target.IsDead || !target.IsInWorld() || info.Hatred == 0) { Aggros.Remove(info.Oid); continue; } return(target); } return(null); }
public AggroInfo GetMaxAggroHate() { UInt64 TotalDamages = TotalDamageReceive(); AggroInfo Aggro = null; float MaxHate = -1; foreach (AggroInfo Info in _Aggros.Values.ToArray()) { float Hate = Info.GetHate(TotalDamages); if (Hate > MaxHate) { MaxHate = Hate; Aggro = Info; } } return(Aggro); }
public Unit GetNextTarget() { Unit Me = GetUnit(); Unit Target = null; if (!Me.IsPlayer()) { AggroInfo Info = GetMaxAggroHate(); if (Info != null) { Target = Obj.Region.GetObject(Info.Oid) as Unit; } } else { if (CurrentTarget.Type != GameData.TargetTypes.TARGETTYPES_TARGET_ALLY) { Target = CurrentTarget.Target; } } if (Target == null) { return(null); } if (!Target.IsInWorld()) { return(null); } if (Target.IsDead) { if (State == AiState.FIGHTING) { OnTargetDie(Target); } return(null); } return(Target); }
private void SetRandomTarget() { AggroInfo maxAggro = null; Player plr = null; var delayedAggroRemoval = new List <object>(); List <Player> plrsInRange = new List <Player>(); foreach (Player player in _unit.PlayersInRange) { if (player != null && !player.IsDead && !player.IsInvulnerable && player.StealthLevel != 2) { plrsInRange.Add(player); } } int rndmPlr = 0; if (plrsInRange.Count() > 0) { rndmPlr = random.Next(1, plrsInRange.Count() + 1); } if (rndmPlr != 0) { CurTarget = Combat.CurrentTarget; plr = plrsInRange.ElementAt(rndmPlr - 1); if (plr.Oid != CurTarget.Oid) { maxAggro = GetMaxAggroHate(); AddHatred(plr, true, (long)maxAggro.Hatred - (long)GetAggro(plr.Oid).Hatred + 5000); _unit.Say("Switching target to " + plr.Name); delayedAggroRemoval.Add(plr); } } // Delay if (maxAggro != null && plr != null && !plr.IsDead) { plr.EvtInterface.AddEvent(DelayedAggroRemoval, 1000, 1, delayedAggroRemoval); } }
public virtual void AddHatred(Unit fighter, bool isPlayer, long hatred) { AggroInfo info = GetAggro(fighter.Oid); long temporaryHatred = (long)info.Hatred; temporaryHatred += hatred; if (temporaryHatred < 0) { temporaryHatred = 0; } info.Hatred = (ulong)temporaryHatred; if (_unit is Pet) { return; } if (!fighter.IsDead && Combat.CurrentTarget != null && Combat.CurrentTarget.Oid != fighter.Oid && GetAggro(fighter.Oid).Hatred > GetAggro(Combat.CurrentTarget.Oid).Hatred) { //If no delayed ability cast - delayed abilities will handle this anyways! //if (CurTarget == null) //{ AI.Debugger?.SendClientMessage("[MR]: Switching target from " + Combat.CurrentTarget.Name + " to " + fighter.Name + "."); AI.Debugger?.SendClientMessage("[MR]: Fighter hate: " + GetAggro(fighter.Oid).Hatred); //This should take care of finding the proper target Unit nextTarget = GetNextTarget(); Combat.SetTarget(nextTarget, TargetTypes.TARGETTYPES_TARGET_ENEMY); if (nextTarget != null && _unit.IsKeepLord) { _unit.Say("Die " + nextTarget.Name + "!"); } Chase(Combat.GetTarget(TargetTypes.TARGETTYPES_TARGET_ENEMY), true); //} } }
public AggroInfo GetMaxAggroHate(bool Player) { UInt64 TotalDamages = TotalDamageReceive(); AggroInfo Aggro = null; float MaxHate = -1; AggroInfo Info; foreach (KeyValuePair <ushort, AggroInfo> Kp in _Aggros) { Info = Kp.Value; float Hate = Info.GetHate(TotalDamages); if (Hate > MaxHate && Info.IsPlayer == Player) { MaxHate = Hate; Aggro = Info; } } return(Aggro); }
public AggroInfo GetAggro(UInt16 Oid, bool Create=true) { AggroInfo Info = null; if (!_Aggros.TryGetValue(Oid, out Info) && Create) { Info = new AggroInfo(Oid); _Aggros.Add(Oid, Info); } return Info; }
public void AddDamageReceive(UInt16 Oid, UInt32 Damages) { AggroInfo Info = GetAggro(Oid); Info.DamagesDeal = Damages; }
public virtual void AddHealReceive(ushort oid, bool isPlayer, uint count) { AggroInfo info = GetAggro(oid); info.HealingReceived = count; }
public void AddDamageReceive(UInt16 Oid, bool IsPlayer, UInt32 Damages) { AggroInfo Info = GetAggro(Oid, IsPlayer); Info.DamagesDeal = Damages; }
public void AddHealReceive(UInt16 Oid, bool IsPlayer, UInt32 Count) { AggroInfo Info = GetAggro(Oid, IsPlayer); Info.HealsReceive = Count; }