ModernUO/Scripts/Mobiles/AI/ThiefAI.cs
eos a0e13d5007 - Future ML craftables added to the special repair list until the craft system is updated.
- Items can now be repaired while wearing them.
- Items can now be fortified while wearing them.
- Fixed repair deed messages not sending.
- Sound effect added to powder of fortifying.
- Map issue for fishing and SOSs fixed, where it would not allow fishing in empty resource banks when not on the target SOS map.
- Added proximity spawner.
- Improved spawner mouseover menu, now also shows types set on the spawner which are not yet spawned.
- Fixed spawners only deleting half of their spawned objects when deleted.
- Added the ability to set TextDefinition objects in the props gump.
- WaitTeleporters now round delays to nearest in the remaining time messages.
- Updated TextDefinition to be more usable; made it parsable from string and added safe serialization/deserialization methods.
- Improved checking whether a mobile can flee.
- Monsters that give ML minor artifacts will no longer flee when low on hits (like paragons).
- Monsters that give ML minor artifacts will no longer spawn as paragon.
- Fixed issue with pets not eating certain foods.
- AI and targeting fixes for Red Death, Pyre and Swoop.
- Fame and karma added to Rend.
- Swoop corrected to have 0 karma.
- Stat and skill tweaks for Putrefier.
- Changelings will no longer show their fame title when morphed.
- Added travel restrictions for ML dungeons.
- Fixed issue of travel restriction message displaying twice.
- Monster teleporting is no longer affected by region travel restrictions.
2012-03-07 18:59:52 +00:00

194 lines
No EOL
5.4 KiB
C#

using System;
using System.Collections;
using Server.Targeting;
using Server.Network;
using Server.Items;
//
// This is a first simple AI
//
//
namespace Server.Mobiles
{
public class ThiefAI : BaseAI
{
public ThiefAI(BaseCreature m) : base (m)
{
}
private Item m_toDisarm;
public override bool DoActionWander()
{
m_Mobile.DebugSay( "I have no combatant" );
if ( AcquireFocusMob( m_Mobile.RangePerception, m_Mobile.FightMode, false, false, true ) )
{
m_Mobile.DebugSay( "I have detected {0}, attacking", m_Mobile.FocusMob.Name );
m_Mobile.Combatant = m_Mobile.FocusMob;
Action = ActionType.Combat;
}
else
{
base.DoActionWander();
}
return true;
}
public override bool DoActionCombat()
{
Mobile combatant = m_Mobile.Combatant;
if ( combatant == null || combatant.Deleted || combatant.Map != m_Mobile.Map )
{
m_Mobile.DebugSay( "My combatant is gone, so my guard is up" );
Action = ActionType.Guard;
return true;
}
if ( WalkMobileRange( combatant, 1, true, m_Mobile.RangeFight, m_Mobile.RangeFight ) )
{
m_Mobile.Direction = m_Mobile.GetDirectionTo( combatant );
if ( m_toDisarm == null )
m_toDisarm = combatant.FindItemOnLayer( Layer.OneHanded );
if ( m_toDisarm == null )
m_toDisarm = combatant.FindItemOnLayer( Layer.TwoHanded );
if ( m_toDisarm != null && m_toDisarm.IsChildOf( m_Mobile.Backpack ) )
{
m_toDisarm = combatant.FindItemOnLayer( Layer.OneHanded );
if ( m_toDisarm == null )
m_toDisarm = combatant.FindItemOnLayer( Layer.TwoHanded );
}
if ( !m_Mobile.DisarmReady && m_Mobile.Skills[SkillName.Wrestling].Value >= 80.0 && m_Mobile.Skills[SkillName.ArmsLore].Value >= 80.0 && m_toDisarm != null )
EventSink.InvokeDisarmRequest( new DisarmRequestEventArgs( m_Mobile ) );
if ( m_toDisarm != null && m_toDisarm.IsChildOf( combatant.Backpack ) && m_Mobile.NextSkillTime <= DateTime.Now && (m_toDisarm.LootType != LootType.Blessed && m_toDisarm.LootType != LootType.Newbied) )
{
m_Mobile.DebugSay( "Trying to steal from combatant." );
m_Mobile.UseSkill( SkillName.Stealing );
if ( m_Mobile.Target != null )
m_Mobile.Target.Invoke( m_Mobile, m_toDisarm );
}
else if ( m_toDisarm == null && m_Mobile.NextSkillTime <= DateTime.Now )
{
Container cpack = combatant.Backpack;
if ( cpack != null )
{
Item steala = cpack.FindItemByType( typeof ( Bandage ) );
if ( steala != null )
{
m_Mobile.DebugSay( "Trying to steal from combatant." );
m_Mobile.UseSkill( SkillName.Stealing );
if ( m_Mobile.Target != null )
m_Mobile.Target.Invoke( m_Mobile, steala );
}
Item stealb = cpack.FindItemByType( typeof ( Nightshade ) );
if ( stealb != null )
{
m_Mobile.DebugSay( "Trying to steal from combatant." );
m_Mobile.UseSkill( SkillName.Stealing );
if ( m_Mobile.Target != null )
m_Mobile.Target.Invoke( m_Mobile, stealb );
}
Item stealc = cpack.FindItemByType( typeof ( BlackPearl ) );
if ( stealc != null )
{
m_Mobile.DebugSay( "Trying to steal from combatant." );
m_Mobile.UseSkill( SkillName.Stealing );
if ( m_Mobile.Target != null )
m_Mobile.Target.Invoke( m_Mobile, stealc );
}
Item steald = cpack.FindItemByType( typeof ( MandrakeRoot ) );
if ( steald != null )
{
m_Mobile.DebugSay( "Trying to steal from combatant." );
m_Mobile.UseSkill( SkillName.Stealing );
if ( m_Mobile.Target != null )
m_Mobile.Target.Invoke( m_Mobile, steald );
}
else if ( steala == null && stealb == null && stealc == null && steald == null )
{
m_Mobile.DebugSay( "I am going to flee from {0}", combatant.Name );
Action = ActionType.Flee;
}
}
}
}
else
{
m_Mobile.DebugSay( "I should be closer to {0}", combatant.Name );
}
if ( m_Mobile.Hits < m_Mobile.HitsMax * 20/100 && m_Mobile.CanFlee )
{
// We are low on health, should we flee?
bool flee = false;
if ( m_Mobile.Hits < combatant.Hits )
{
// We are more hurt than them
int diff = combatant.Hits - m_Mobile.Hits;
flee = ( Utility.Random( 0, 100 ) > (10 + diff) ); // (10 + diff)% chance to flee
}
else
{
flee = Utility.Random( 0, 100 ) > 10; // 10% chance to flee
}
if ( flee )
{
m_Mobile.DebugSay( "I am going to flee from {0}", combatant.Name );
Action = ActionType.Flee;
}
}
return true;
}
public override bool DoActionGuard()
{
if ( AcquireFocusMob(m_Mobile.RangePerception, m_Mobile.FightMode, false, false, true ) )
{
m_Mobile.DebugSay( "I have detected {0}, attacking", m_Mobile.FocusMob.Name );
m_Mobile.Combatant = m_Mobile.FocusMob;
Action = ActionType.Combat;
}
else
{
base.DoActionGuard();
}
return true;
}
public override bool DoActionFlee()
{
if ( m_Mobile.Hits > m_Mobile.HitsMax/2 )
{
m_Mobile.DebugSay( "I am stronger now, so I will continue fighting" );
Action = ActionType.Combat;
}
else
{
m_Mobile.FocusMob = m_Mobile.Combatant;
base.DoActionFlee();
}
return true;
}
}
}