public override void OnTick() { if (From.AIState == AIStates.Attack && From.AttackTarget != null) { if (From.Distance(From.AttackTarget) > 30 * 30 * 2) { From.AIState = AIStates.Explore; From.AttackTarget = null; return; } } switch (AIState) { case AIStates.DoingNothing: // retour a l'ai par defaut AIState = AIStates.Explore; break; case AIStates.Explore: AIState = AIStates.Pause1; break; case AIStates.Pause1: break; } }
public override void OnTick() { if (From.DebugSniffer != null) { From.DebugSniffer.SendMessage("PredatorAI::OnTick"); } if (From.AIState == AIStates.Attack && From.AttackTarget != null) { if (From.Distance(From.AttackTarget) > 35 * 35 * 2) { From.AIState = AIStates.LookingForPrey; From.AttackTarget = null; return; } } switch (AIState) { case AIStates.DoingNothing: // retour a l'ai par defaut AIState = AIStates.LookingForPrey; From.Running = false; break; case AIStates.LookingForPrey: From.Running = false; break; } }
//=================================================================// public Mobile ChooseAttackTarget(float AttackDistance, float HateLimit) { HateUnit AttackTarget = new HateUnit(null, 0); foreach (HateUnit unit in this.From.HateList) { if (AttackTarget.HatedMobile != null) { if (From.Distance(unit.HatedMobile) < AttackDistance & !unit.HatedMobile.Dead) { if (this.From.Distance(unit.HatedMobile) < this.From.Distance(AttackTarget.HatedMobile) && unit.Hate > AttackTarget.Hate | this.From.Distance(unit.HatedMobile) == this.From.Distance(AttackTarget.HatedMobile) && unit.Hate > AttackTarget.Hate) { if (AttackTarget.Hate < unit.Hate && unit.Hate > this.HateLimit && unit.HatedMobile.Level + 8 > this.From.Level) { //if (( From.Reputation( From.attackTarget ) < 0.5f )) From.BeginCombatWith( From.attackTarget ); AttackTarget.HatedMobile = unit.HatedMobile; } } } } else { if (unit.Hate > this.HateLimit && unit.HatedMobile.Level + 8 > this.From.Level) { AttackTarget.HatedMobile = unit.HatedMobile; } } } return(AttackTarget.HatedMobile); }
public override void OnTick() { if (From.DebugSniffer != null) { From.DebugSniffer.SendMessage("PredatorAI::OnTick"); } if (From.AIState == AIStates.Attack && From.AttackTarget != null) { if (From.Distance(From.AttackTarget) > 35 * 35 * 2) { From.AIState = AIStates.LookingForPrey; From.AttackTarget = null; return; } } if (From.AttackTarget == null || From.AttackTarget.Dead) { ArrayList mobs = From.KnownObjects(); foreach (Object o in mobs) { if (o is Mobile) { Mobile mob = o as Mobile; if (From.Distance(mob) < MaxViewDistance && Utility.Random4() == 0 && From.IsHostile(mob) && From.CanSee(mob) && !mob.Dead) { OnBeginFight(mob); From.AIState = AIStates.BeingAttacked; From.AttackTarget = mob; return; } } } } switch (AIState) { case AIStates.DoingNothing: // retour a l'ai par defaut AIState = AIStates.LookingForPrey; From.Running = false; break; case AIStates.LookingForPrey: From.Running = false; break; case AIStates.Speaking: From.Running = false; TimeSpan ts = DateTime.Now.Subtract(From.SpeakingFrom); if (ts.TotalSeconds > 15) { AIState = AIStates.LookingForPrey; } break; } }
public float ArrivalTime(Obj_AI_Base target) { try { if (target is Obj_AI_Hero && target.IsMoving) { var predTarget = Prediction.GetPrediction( target, Delay + From.Distance(target.ServerPosition) / Speed + Game.Ping / 2000f + 0.1f); return(Delay + From.Distance(predTarget.UnitPosition) / Speed + Game.Ping / 2000f + 0.1f); } return(Delay + From.Distance(target.ServerPosition) / Speed + Game.Ping / 2000f + 0.1f); } catch (Exception ex) { Global.Logger.AddItem(new LogItem(ex)); } return(0); }
/// <summary> /// Casts the targetted spell on the unit. /// </summary> /// <param name="unit">The unit.</param> /// <param name="packetCast">if set to <c>true</c> [packet cast].</param> /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns> public bool CastOnUnit(Obj_AI_Base unit, bool packetCast = false) { if (!Slot.IsReady() || From.Distance(unit.ServerPosition, true) > RangeSqr || (CommonMenu.Config.Item("LimitCastingAttempts").GetValue <bool>() && Utils.TickCount - LastCastAttemptT < (70 + Math.Min(60, Game.Ping)))) { return(false); } LastCastAttemptT = Utils.TickCount; if (packetCast) { return(ObjectManager.Player.Spellbook.CastSpell(Slot, unit, false)); } else { return(ObjectManager.Player.Spellbook.CastSpell(Slot, unit)); } }
/// <summary> /// Casts the targetted spell on the unit. /// </summary> public void CastOnUnit(Obj_AI_Base unit, bool packetCast = false) { if (!Slot.IsReady() || From.Distance(unit.ServerPosition) > Range) { return; } LastCastAttemptT = Environment.TickCount; if (packetCast) { ObjectManager.Player.Spellbook.CastSpell(Slot, unit, false); } else { ObjectManager.Player.Spellbook.CastSpell(Slot, unit); } }
/// <summary> /// Casts the targetted spell on the unit. /// </summary> public void CastOnUnit(Obj_AI_Base unit, bool packetCast = false) { if (!IsReady() || From.Distance(unit.ServerPosition) > Range) { return; } LastCastAttemptT = Environment.TickCount; if (packetCast) { Packet.C2S.Cast.Encoded(new Packet.C2S.Cast.Struct(unit.NetworkId, Slot)).Send(); } else { ObjectManager.Player.Spellbook.CastSpell(Slot, unit); } }
/// <summary> /// Casts the targetted spell on the unit. /// </summary> public bool CastOnUnit(Obj_AI_Base unit, bool packetCast = false) { if (!Slot.IsReady() || From.Distance(unit.ServerPosition, true) > RangeSqr) { return(false); } LastCastAttemptT = Utils.TickCount; if (packetCast) { return(ObjectManager.Player.Spellbook.CastSpell(Slot, unit, false)); } else { return(ObjectManager.Player.Spellbook.CastSpell(Slot, unit)); } }
/// <summary> /// Returns the unit health when the spell hits the unit. /// </summary> /// <param name="unit">The unit.</param> /// <returns>System.Single.</returns> public float GetHealthPrediction(Obj_AI_Base unit) { var time = (int)(Delay * 1000 + From.Distance(unit.ServerPosition) / Speed - 100); return(HealthPrediction.GetHealthPrediction(unit, time)); }
public override string ToString() { return($"{nameof(Id)}: {Id}, {nameof(From)}: {From}, {nameof(To)}: {To}, {nameof(Start)}: {Start}, {nameof(Finish)}: {Finish}, Distance: {From.Distance(To)}"); }
public override void OnTick() { if (From.DebugSniffer != null) { From.DebugSniffer.SendMessage("PredatorAI::OnTick"); } if (From.AIState == AIStates.Attack && From.AttackTarget != null) { if (From.Distance(From.AttackTarget) > 30 * 30 * 2) { From.AIState = AIStates.LookingForPrey; From.AttackTarget = null; return; } } /* * if ( From.AttackTarget == null || From.AttackTarget.Dead ) * foreach( Character c in World.allConnectedChars ) * { * if ( From.CanSee( c ) && c.Visible && !c.Dead && From.Distance( c ) < 30 * 30 * 2 ) * { * From.AIState = AIStates.BeingAttacked; * From.AttackTarget = (Mobile)c; * if ( From.DebugSniffer != null ) * From.DebugSniffer.SendMessage( "PredatorAI::OnTick::SeePrey" ); * return; * } * }*/ if (From.AttackTarget == null || From.AttackTarget.Dead) { ArrayList mobs = From.KnownObjects(); foreach (Object o in mobs) { if (o is Mobile) { Mobile mob = o as Mobile; if (From.Distance(mob) < MaxViewDistance && Utility.Random4() == 0 && From.IsHostile(mob) && From.CanSee(mob) && !mob.Dead) { From.AIState = AIStates.BeingAttacked; From.AttackTarget = mob; return; } } } } switch (AIState) { case AIStates.DoingNothing: // retour a l'ai par defaut AIState = AIStates.LookingForPrey; From.Running = false; break; case AIStates.LookingForPrey: From.Running = false; if (Utility.Random16() < 1) { AIState = AIStates.Pause1; } break; case AIStates.Pause1: AIState = AIStates.Pause2; break; case AIStates.Pause2: AIState = AIStates.Pause3; break; case AIStates.Pause3: AIState = AIStates.LookingForPrey; break; } }
public override void OnTick() { if (From.DebugSniffer != null) { From.DebugSniffer.SendMessage("PredatorAI::OnTick"); } if (From.AIState == AIStates.Attack && From.AttackTarget != null) { if (From.Distance(From.AttackTarget) > 30 * 30 * 2) { From.AIState = AIStates.LookingForPrey; From.AttackTarget = null; return; } } if (From.AttackTarget == null || From.AttackTarget.Dead) { foreach (Character c in World.allConnectedChars) { if (From.Distance(c) < MaxViewDistance && Utility.Random4() == 0 && From.IsHostile(c) && From.CanSee(c) && !c.Dead) { OnBeginFight(c); From.AIState = AIStates.BeingAttacked; From.AttackTarget = (Mobile)c; if (From.DebugSniffer != null) { From.DebugSniffer.SendMessage("PredatorAI::OnTick::SeePrey"); } return; } } } switch (AIState) { case AIStates.DoingNothing: // retour a l'ai par defaut AIState = AIStates.LookingForPrey; From.Running = false; break; case AIStates.LookingForPrey: From.Running = false; if (Utility.Random16() < 1) { AIState = AIStates.Pause1; } break; case AIStates.Pause1: AIState = AIStates.Pause2; break; case AIStates.Pause2: AIState = AIStates.Pause3; break; case AIStates.Pause3: AIState = AIStates.LookingForPrey; break; } }
public override void OnTick() { if (From.AIState == AIStates.Attack && From.AttackTarget != null) { if (From.Distance(From.AttackTarget) > 30 * 30 * 2) { From.AIState = AIStates.Explore; From.AttackTarget = null; return; } } /* * if ( From.AIState == AIStates.BeingAttacked && ( From.AttackTarget == null || From.AttackTarget.Dead ) ) * { * ArrayList mobs = From.KnownObjects(); * foreach( Object o in mobs ) * { * if ( o is Mobile ) * { * Mobile mob = o as Mobile; * if ( From.IsHostile( mob ) && From.CanSee( mob ) && * !mob.Dead && From.Distance( mob ) < 30 * 30 * 2 ) * { * From.AIState = AIStates.BeingAttacked; * From.AttackTarget = mob; * return; * } * } * } * }*/ switch (AIState) { case AIStates.DoingNothing: // retour a l'ai par defaut AIState = AIStates.Explore; break; case AIStates.Explore: if (Utility.Random16() < 2) { AIState = AIStates.Pause1; } else if (Utility.Random16() < 4) { AIState = AIStates.Pause2; } break; case AIStates.Pause1: AIState = AIStates.Pause2; break; case AIStates.Pause2: AIState = AIStates.Pause3; break; case AIStates.Pause3: AIState = AIStates.Explore; break; } }
public override void OnTick() { if (From.DebugSniffer != null) { From.DebugSniffer.SendMessage("SummonedAI::OnTick"); } if (From.AIState == AIStates.Attack && From.AttackTarget != null) { if (From.Distance(From.AttackTarget) > 30 * 30 * 2) { From.AIState = AIStates.Follow; From.AttackTarget = null; return; } } if ((From.AttackTarget == null || From.AttackTarget.Dead) && From.AIStance != AIStances.Passive) { if (summonedFrom == null) { Console.WriteLine("Stage summonedFrom NULL"); return; } if ((summonedFrom as Character).Player == null) { From.X = -2000f; From.Y = -2000f; From.Z = 1000f; From.MapId = 2; return; } foreach (Object o in (summonedFrom as Character).Player.KnownObjects) { if (o is Mobile) { Mobile c = o as Mobile; if (c != summonedFrom && From.AIStance == AIStances.Agressive) { if ((summonedFrom as Mobile).Reputation(c) < 0.3f && From.CanSee(c) && !c.Dead && From.Distance(c) < MaxViewDistance) { OnBeginFight(c); From.AIState = AIStates.BeingAttacked; From.AttackTarget = (Mobile)c; if (From.DebugSniffer != null) { From.DebugSniffer.SendMessage("SummonedAI::OnTick::SeePrey"); } return; } } /*else * if ( From.Faction != c.Faction && From.CanSee( c ) && c.Visible && !c.Dead && From.Distance( c ) < 30 * 30 * 2 ) * { * From.AIState = AIStates.BeingAttacked; * From.AttackTarget = (Mobile)c; * if ( From.DebugSniffer != null ) * From.DebugSniffer.SendMessage( "SummonedAI::OnTick::SeePrey" ); * return; * }*/ } } } switch (AIState) { case AIStates.DoingNothing: From.AIState = AIStates.Follow; break; case AIStates.Pause1: break; case AIStates.Follow: float dist = summonedFrom.Distance(From); float ndist = (From.CombatReach + summonedFrom.CombatReach); if (dist > 5) { if (dist > ndist) { From.Running = true; } else { From.Running = false; } double angle = (float)Math.Atan2(summonedFrom.Y - From.Y, summonedFrom.X - From.X); angle += Math.PI; From.MoveTo((float)(summonedFrom.X + Math.Cos(angle) * ndist * 1.5), (float)(summonedFrom.Y + Math.Sin(angle) * ndist * 1.5), (float)(summonedFrom.Z)); } break; } }
public override void OnTick() { if (From.AIState == AIStates.Attack && From.AttackTarget != null) { if (From.Distance(From.AttackTarget) > 25 * 25) { From.AIState = AIStates.Explore; From.AttackTarget = null; return; } } if (From.AttackTarget == null || From.AttackTarget.Dead) { ArrayList mobs = From.KnownObjects(); int dist = 10 + 4 * (256 - Utility.Random16() * Utility.Random16()); foreach (Object o in mobs) { if (o is Mobile) { Mobile mob = o as Mobile; if (From.Distance(mob) < MaxViewDistance && Utility.Random4() == 0 && From.IsHostile(mob) && From.CanSee(mob) && !mob.Dead) { OnBeginFight(mob); From.AIState = AIStates.BeingAttacked; From.AttackTarget = mob; return; } } } } switch (AIState) { case AIStates.DoingNothing: // return to the default AI AIState = AIStates.Explore; break; case AIStates.Explore: if (Utility.Random16() < 2) { AIState = AIStates.Pause1; } else if (Utility.Random16() < 4) { AIState = AIStates.Pause4; } break; case AIStates.Pause1: // make a pause AIState = AIStates.Pause2; break; case AIStates.Pause2: // make a pause AIState = AIStates.Pause3; break; case AIStates.Pause3: // make a pause AIState = AIStates.Pause4; break; case AIStates.Pause4: // make a pause AIState = AIStates.Pause5; break; case AIStates.Pause5: // make a pause AIState = AIStates.Explore; break; } }