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.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 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; } }