#W# Initial Commit: Avatars Conquest
This commit is contained in:
commit
8eae46895e
7512 changed files with 416187 additions and 0 deletions
43
Scripts/Mobiles/Base/AI/AIControlMobileTarget.cs
Normal file
43
Scripts/Mobiles/Base/AI/AIControlMobileTarget.cs
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Server;
|
||||
using Server.Mobiles;
|
||||
using Server.Targeting;
|
||||
|
||||
namespace Server.Targets
|
||||
{
|
||||
public class AIControlMobileTarget : Target
|
||||
{
|
||||
private List<BaseAI> m_List;
|
||||
private OrderType m_Order;
|
||||
|
||||
public OrderType Order {
|
||||
get {
|
||||
return m_Order;
|
||||
}
|
||||
}
|
||||
|
||||
public AIControlMobileTarget( BaseAI ai, OrderType order ) : base( -1, false, ( order == OrderType.Attack ? TargetFlags.Harmful : TargetFlags.None ) )
|
||||
{
|
||||
m_List = new List<BaseAI>();
|
||||
m_Order = order;
|
||||
|
||||
AddAI( ai );
|
||||
}
|
||||
|
||||
public void AddAI( BaseAI ai )
|
||||
{
|
||||
if ( !m_List.Contains( ai ) )
|
||||
m_List.Add( ai );
|
||||
}
|
||||
|
||||
protected override void OnTarget( Mobile from, object o )
|
||||
{
|
||||
if ( o is Mobile ) {
|
||||
Mobile m = (Mobile)o;
|
||||
for ( int i = 0; i < m_List.Count; ++i )
|
||||
m_List[i].EndPickTarget( from, m, m_Order );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
157
Scripts/Mobiles/Base/AI/AnimalAI.cs
Normal file
157
Scripts/Mobiles/Base/AI/AnimalAI.cs
Normal file
|
|
@ -0,0 +1,157 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using Server.Targeting;
|
||||
using Server.Network;
|
||||
|
||||
// Ideas
|
||||
// When you run on animals the panic
|
||||
// When if ( distance < 8 && Utility.RandomDouble() * Math.Sqrt( (8 - distance) / 6 ) >= incoming.Skills[SkillName.AnimalTaming].Value )
|
||||
// More your close, the more it can panic
|
||||
/*
|
||||
* AnimalHunterAI, AnimalHidingAI, AnimalDomesticAI...
|
||||
*
|
||||
*/
|
||||
|
||||
namespace Server.Mobiles
|
||||
{
|
||||
public class AnimalAI : BaseAI
|
||||
{
|
||||
public AnimalAI(BaseCreature m) : base (m)
|
||||
{
|
||||
}
|
||||
|
||||
public override bool DoActionWander()
|
||||
{
|
||||
// Old:
|
||||
#if false
|
||||
if (AcquireFocusMob(m_Mobile.RangePerception, m_Mobile.FightMode, true, false, true))
|
||||
{
|
||||
m_Mobile.DebugSay( "There is something near, I go away" );
|
||||
Action = ActionType.Backoff;
|
||||
}
|
||||
else if ( m_Mobile.IsHurt() || m_Mobile.Combatant != null )
|
||||
{
|
||||
m_Mobile.DebugSay( "I am hurt or being attacked, I flee" );
|
||||
Action = ActionType.Flee;
|
||||
}
|
||||
else
|
||||
{
|
||||
base.DoActionWander();
|
||||
}
|
||||
|
||||
return true;
|
||||
#endif
|
||||
|
||||
// New, only flee @ 10%
|
||||
|
||||
double hitPercent = (double)m_Mobile.Hits / m_Mobile.HitsMax;
|
||||
|
||||
if ( !m_Mobile.Summoned && !m_Mobile.Controlled && hitPercent < 0.1 ) // Less than 10% health
|
||||
{
|
||||
m_Mobile.DebugSay( "I am low on health!" );
|
||||
Action = ActionType.Flee;
|
||||
}
|
||||
else if ( AcquireFocusMob( m_Mobile.RangePerception, m_Mobile.FightMode, false, false, true ) )
|
||||
{
|
||||
if ( m_Mobile.Debug )
|
||||
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.." );
|
||||
|
||||
Action = ActionType.Wander;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if ( WalkMobileRange( combatant, 1, true, m_Mobile.RangeFight, m_Mobile.RangeFight ) )
|
||||
{
|
||||
m_Mobile.Direction = m_Mobile.GetDirectionTo( combatant );
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( m_Mobile.GetDistanceToSqrt( combatant ) > m_Mobile.RangePerception + 1 )
|
||||
{
|
||||
if ( m_Mobile.Debug )
|
||||
m_Mobile.DebugSay( "I cannot find {0}", combatant.Name );
|
||||
|
||||
Action = ActionType.Wander;
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( m_Mobile.Debug )
|
||||
m_Mobile.DebugSay( "I should be closer to {0}", combatant.Name );
|
||||
}
|
||||
}
|
||||
|
||||
if ( !m_Mobile.Controlled && !m_Mobile.Summoned )
|
||||
{
|
||||
double hitPercent = (double)m_Mobile.Hits / m_Mobile.HitsMax;
|
||||
|
||||
if ( hitPercent < 0.1 )
|
||||
{
|
||||
m_Mobile.DebugSay( "I am low on health!" );
|
||||
Action = ActionType.Flee;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool DoActionBackoff()
|
||||
{
|
||||
double hitPercent = (double)m_Mobile.Hits / m_Mobile.HitsMax;
|
||||
|
||||
if ( !m_Mobile.Summoned && !m_Mobile.Controlled && hitPercent < 0.1 ) // Less than 10% health
|
||||
{
|
||||
Action = ActionType.Flee;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (AcquireFocusMob(m_Mobile.RangePerception * 2, FightMode.Closest, true, false , true))
|
||||
{
|
||||
if ( WalkMobileRange(m_Mobile.FocusMob, 1, false, m_Mobile.RangePerception, m_Mobile.RangePerception * 2) )
|
||||
{
|
||||
m_Mobile.DebugSay( "Well, here I am safe" );
|
||||
Action = ActionType.Wander;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Mobile.DebugSay( "I have lost my focus, lets relax" );
|
||||
Action = ActionType.Wander;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool DoActionFlee()
|
||||
{
|
||||
AcquireFocusMob(m_Mobile.RangePerception * 2, m_Mobile.FightMode, true, false, true);
|
||||
|
||||
if ( m_Mobile.FocusMob == null )
|
||||
m_Mobile.FocusMob = m_Mobile.Combatant;
|
||||
|
||||
return base.DoActionFlee();
|
||||
}
|
||||
}
|
||||
}
|
||||
131
Scripts/Mobiles/Base/AI/ArcherAI.cs
Normal file
131
Scripts/Mobiles/Base/AI/ArcherAI.cs
Normal file
|
|
@ -0,0 +1,131 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using Server.Targeting;
|
||||
using Server.Network;
|
||||
using Server.Mobiles;
|
||||
using Server.Items;
|
||||
|
||||
namespace Server.Mobiles
|
||||
{
|
||||
public class ArcherAI : BaseAI
|
||||
{
|
||||
public ArcherAI(BaseCreature m) : base (m)
|
||||
{
|
||||
}
|
||||
|
||||
public override bool DoActionWander()
|
||||
{
|
||||
m_Mobile.DebugSay( "I have no combatant" );
|
||||
|
||||
if (AcquireFocusMob(m_Mobile.RangePerception, m_Mobile.FightMode, false, false, true))
|
||||
{
|
||||
if ( m_Mobile.Debug )
|
||||
m_Mobile.DebugSay( "I have detected {0} and I will attack", m_Mobile.FocusMob.Name );
|
||||
|
||||
m_Mobile.Combatant = m_Mobile.FocusMob;
|
||||
Action = ActionType.Combat;
|
||||
}
|
||||
else
|
||||
{
|
||||
return base.DoActionWander();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool DoActionCombat()
|
||||
{
|
||||
if ( m_Mobile.Combatant == null || m_Mobile.Combatant.Deleted || !m_Mobile.Combatant.Alive || m_Mobile.Combatant.IsDeadBondedPet )
|
||||
{
|
||||
m_Mobile.DebugSay("My combatant is deleted");
|
||||
Action = ActionType.Guard;
|
||||
return true;
|
||||
}
|
||||
|
||||
if ( (m_Mobile.LastMoveTime + TimeSpan.FromSeconds( 1.0 )) < DateTime.Now )
|
||||
{
|
||||
if (WalkMobileRange(m_Mobile.Combatant, 1, true, m_Mobile.RangeFight, m_Mobile.Weapon.MaxRange))
|
||||
{
|
||||
// Be sure to face the combatant
|
||||
m_Mobile.Direction = m_Mobile.GetDirectionTo(m_Mobile.Combatant.Location);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( m_Mobile.Combatant != null )
|
||||
{
|
||||
if ( m_Mobile.Debug )
|
||||
m_Mobile.DebugSay( "I am still not in range of {0}", m_Mobile.Combatant.Name);
|
||||
|
||||
if ( (int) m_Mobile.GetDistanceToSqrt( m_Mobile.Combatant ) > m_Mobile.RangePerception + 1 )
|
||||
{
|
||||
if ( m_Mobile.Debug )
|
||||
m_Mobile.DebugSay( "I have lost {0}", m_Mobile.Combatant.Name);
|
||||
|
||||
m_Mobile.Combatant = null;
|
||||
Action = ActionType.Guard;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// When we have no ammo, we flee
|
||||
Container pack = m_Mobile.Backpack;
|
||||
|
||||
if ( pack == null || pack.FindItemByType( typeof( Arrow ) ) == null )
|
||||
{
|
||||
Action = ActionType.Flee;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// At 20% we should check if we must leave
|
||||
if ( m_Mobile.Hits < m_Mobile.HitsMax*20/100 )
|
||||
{
|
||||
bool bFlee = false;
|
||||
// if my current hits are more than my opponent, i don't care
|
||||
if ( m_Mobile.Combatant != null && m_Mobile.Hits < m_Mobile.Combatant.Hits)
|
||||
{
|
||||
int iDiff = m_Mobile.Combatant.Hits - m_Mobile.Hits;
|
||||
|
||||
if ( Utility.Random(0, 100) > 10 + iDiff) // 10% to flee + the diff of hits
|
||||
{
|
||||
bFlee = true;
|
||||
}
|
||||
}
|
||||
else if ( m_Mobile.Combatant != null && m_Mobile.Hits >= m_Mobile.Combatant.Hits)
|
||||
{
|
||||
if ( Utility.Random(0, 100) > 10 ) // 10% to flee
|
||||
{
|
||||
bFlee = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (bFlee)
|
||||
{
|
||||
Action = ActionType.Flee;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool DoActionGuard()
|
||||
{
|
||||
if ( AcquireFocusMob(m_Mobile.RangePerception, m_Mobile.FightMode, false, false, true ) )
|
||||
{
|
||||
if ( m_Mobile.Debug )
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
2594
Scripts/Mobiles/Base/AI/BaseAI.cs
Normal file
2594
Scripts/Mobiles/Base/AI/BaseAI.cs
Normal file
File diff suppressed because it is too large
Load diff
87
Scripts/Mobiles/Base/AI/BerserkAI.cs
Normal file
87
Scripts/Mobiles/Base/AI/BerserkAI.cs
Normal file
|
|
@ -0,0 +1,87 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using Server.Targeting;
|
||||
using Server.Network;
|
||||
|
||||
namespace Server.Mobiles
|
||||
{
|
||||
public class BerserkAI : BaseAI
|
||||
{
|
||||
public BerserkAI(BaseCreature m) : base (m)
|
||||
{
|
||||
}
|
||||
|
||||
public override bool DoActionWander()
|
||||
{
|
||||
m_Mobile.DebugSay( "I have No Combatant" );
|
||||
|
||||
if( AcquireFocusMob( m_Mobile.RangePerception, FightMode.Closest, false, true, true) )
|
||||
{
|
||||
if ( m_Mobile.Debug )
|
||||
m_Mobile.DebugSay( "I have detected " + m_Mobile.FocusMob.Name + " and I will attack" );
|
||||
|
||||
m_Mobile.Combatant = m_Mobile.FocusMob;
|
||||
Action = ActionType.Combat;
|
||||
}
|
||||
else
|
||||
{
|
||||
base.DoActionWander();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool DoActionCombat()
|
||||
{
|
||||
if( m_Mobile.Combatant == null || m_Mobile.Combatant.Deleted )
|
||||
{
|
||||
m_Mobile.DebugSay("My combatant is deleted");
|
||||
Action = ActionType.Guard;
|
||||
return true;
|
||||
}
|
||||
|
||||
if( WalkMobileRange( m_Mobile.Combatant, 1, true, m_Mobile.RangeFight, m_Mobile.RangeFight ) )
|
||||
{
|
||||
// Be sure to face the combatant
|
||||
m_Mobile.Direction = m_Mobile.GetDirectionTo( m_Mobile.Combatant.Location );
|
||||
}
|
||||
else
|
||||
{
|
||||
if( m_Mobile.Combatant != null )
|
||||
{
|
||||
if ( m_Mobile.Debug )
|
||||
m_Mobile.DebugSay("I am still not in range of " + m_Mobile.Combatant.Name);
|
||||
|
||||
if( (int) m_Mobile.GetDistanceToSqrt( m_Mobile.Combatant ) > m_Mobile.RangePerception + 1 )
|
||||
{
|
||||
if ( m_Mobile.Debug )
|
||||
m_Mobile.DebugSay( "I have lost " + m_Mobile.Combatant.Name );
|
||||
|
||||
Action = ActionType.Guard;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool DoActionGuard()
|
||||
{
|
||||
if ( AcquireFocusMob(m_Mobile.RangePerception, m_Mobile.FightMode, false, true, true ) )
|
||||
{
|
||||
if ( m_Mobile.Debug )
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
34
Scripts/Mobiles/Base/AI/CitizenAI.cs
Normal file
34
Scripts/Mobiles/Base/AI/CitizenAI.cs
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using Server.Targeting;
|
||||
using Server.Network;
|
||||
|
||||
namespace Server.Mobiles
|
||||
{
|
||||
public class CitizenAI : BaseAI
|
||||
{
|
||||
public CitizenAI(BaseCreature m) : base (m)
|
||||
{
|
||||
}
|
||||
|
||||
public override bool DoActionWander()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public override bool DoActionCombat()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public override bool DoActionBackoff()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public override bool DoActionFlee()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
176
Scripts/Mobiles/Base/AI/HealerAI.cs
Normal file
176
Scripts/Mobiles/Base/AI/HealerAI.cs
Normal file
|
|
@ -0,0 +1,176 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using Server.Targeting;
|
||||
using Server.Network;
|
||||
using Server.Spells;
|
||||
using Server.Spells.First;
|
||||
using Server.Spells.Second;
|
||||
using Server.Spells.Fourth;
|
||||
|
||||
namespace Server.Mobiles
|
||||
{
|
||||
public class HealerAI : BaseAI
|
||||
{
|
||||
private static NeedDelegate m_Cure = new NeedDelegate( NeedCure );
|
||||
private static NeedDelegate m_GHeal = new NeedDelegate( NeedGHeal );
|
||||
private static NeedDelegate m_LHeal = new NeedDelegate( NeedLHeal );
|
||||
private static NeedDelegate[] m_ACure = new NeedDelegate[] { m_Cure };
|
||||
private static NeedDelegate[] m_AGHeal = new NeedDelegate[] { m_GHeal };
|
||||
private static NeedDelegate[] m_ALHeal = new NeedDelegate[] { m_LHeal };
|
||||
private static NeedDelegate[] m_All = new NeedDelegate[] { m_Cure, m_GHeal, m_LHeal };
|
||||
|
||||
public HealerAI( BaseCreature m ) : base( m )
|
||||
{
|
||||
}
|
||||
|
||||
public override bool Think()
|
||||
{
|
||||
if ( m_Mobile.Deleted )
|
||||
return false;
|
||||
|
||||
Target targ = m_Mobile.Target;
|
||||
|
||||
if ( targ != null )
|
||||
{
|
||||
if ( targ is CureSpell.InternalTarget )
|
||||
{
|
||||
ProcessTarget( targ, m_ACure );
|
||||
}
|
||||
else if ( targ is GreaterHealSpell.InternalTarget )
|
||||
{
|
||||
ProcessTarget( targ, m_AGHeal );
|
||||
}
|
||||
else if ( targ is HealSpell.InternalTarget )
|
||||
{
|
||||
ProcessTarget( targ, m_ALHeal );
|
||||
}
|
||||
else
|
||||
{
|
||||
targ.Cancel( m_Mobile, TargetCancelType.Canceled );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Mobile toHelp = Find( m_All );
|
||||
|
||||
if ( toHelp != null )
|
||||
{
|
||||
if ( NeedCure( toHelp ) )
|
||||
{
|
||||
if ( m_Mobile.Debug )
|
||||
m_Mobile.DebugSay( "{0} needs a cure", toHelp.Name );
|
||||
|
||||
if ( !(new CureSpell( m_Mobile, null )).Cast() )
|
||||
new CureSpell( m_Mobile, null ).Cast();
|
||||
}
|
||||
else if ( NeedGHeal( toHelp ) )
|
||||
{
|
||||
if ( m_Mobile.Debug )
|
||||
m_Mobile.DebugSay( "{0} needs a greater heal", toHelp.Name );
|
||||
|
||||
if ( !(new GreaterHealSpell( m_Mobile, null )).Cast() )
|
||||
new HealSpell( m_Mobile, null ).Cast();
|
||||
}
|
||||
else if ( NeedLHeal( toHelp ) )
|
||||
{
|
||||
if ( m_Mobile.Debug )
|
||||
m_Mobile.DebugSay( "{0} needs a lesser heal", toHelp.Name );
|
||||
|
||||
new HealSpell( m_Mobile, null ).Cast();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( AcquireFocusMob( m_Mobile.RangePerception, FightMode.Weakest, false, true, false ) )
|
||||
{
|
||||
WalkMobileRange( m_Mobile.FocusMob, 1, false, 4, 7 );
|
||||
}
|
||||
else
|
||||
{
|
||||
WalkRandomInHome( 3, 2, 1 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private delegate bool NeedDelegate( Mobile m );
|
||||
|
||||
private void ProcessTarget( Target targ, NeedDelegate[] func )
|
||||
{
|
||||
Mobile toHelp = Find( func );
|
||||
|
||||
if ( toHelp != null )
|
||||
{
|
||||
if ( targ.Range != -1 && !m_Mobile.InRange( toHelp, targ.Range ) )
|
||||
{
|
||||
DoMove( m_Mobile.GetDirectionTo( toHelp ) | Direction.Running );
|
||||
}
|
||||
else
|
||||
{
|
||||
targ.Invoke( m_Mobile, toHelp );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
targ.Cancel( m_Mobile, TargetCancelType.Canceled );
|
||||
}
|
||||
}
|
||||
|
||||
private Mobile Find( params NeedDelegate[] funcs )
|
||||
{
|
||||
if ( m_Mobile.Deleted )
|
||||
return null;
|
||||
|
||||
Map map = m_Mobile.Map;
|
||||
|
||||
if ( map != null )
|
||||
{
|
||||
double prio = 0.0;
|
||||
Mobile found = null;
|
||||
|
||||
foreach ( Mobile m in m_Mobile.GetMobilesInRange( m_Mobile.RangePerception ) )
|
||||
{
|
||||
if ( !m_Mobile.CanSee( m ) || !(m is BaseCreature) || ((BaseCreature)m).Team != m_Mobile.Team )
|
||||
continue;
|
||||
|
||||
for ( int i = 0; i < funcs.Length; ++i )
|
||||
{
|
||||
if ( funcs[i]( m ) )
|
||||
{
|
||||
double val = -m_Mobile.GetDistanceToSqrt( m );
|
||||
|
||||
if ( found == null || val > prio )
|
||||
{
|
||||
prio = val;
|
||||
found = m;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return found;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static bool NeedCure( Mobile m )
|
||||
{
|
||||
return m.Poisoned;
|
||||
}
|
||||
|
||||
private static bool NeedGHeal( Mobile m )
|
||||
{
|
||||
return m.Hits < m.HitsMax - 40;
|
||||
}
|
||||
|
||||
private static bool NeedLHeal( Mobile m )
|
||||
{
|
||||
return m.Hits < m.HitsMax - 10;
|
||||
}
|
||||
}
|
||||
}
|
||||
1020
Scripts/Mobiles/Base/AI/MageAI.cs
Normal file
1020
Scripts/Mobiles/Base/AI/MageAI.cs
Normal file
File diff suppressed because it is too large
Load diff
183
Scripts/Mobiles/Base/AI/MeleeAI.cs
Normal file
183
Scripts/Mobiles/Base/AI/MeleeAI.cs
Normal file
|
|
@ -0,0 +1,183 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using Server.Targeting;
|
||||
using Server.Network;
|
||||
|
||||
//
|
||||
// This is a first simple AI
|
||||
//
|
||||
//
|
||||
|
||||
namespace Server.Mobiles
|
||||
{
|
||||
public class MeleeAI : BaseAI
|
||||
{
|
||||
public MeleeAI(BaseCreature m) : base (m)
|
||||
{
|
||||
}
|
||||
|
||||
public override bool DoActionWander()
|
||||
{
|
||||
m_Mobile.DebugSay( "I have no combatant" );
|
||||
|
||||
if ( AcquireFocusMob( m_Mobile.RangePerception, m_Mobile.FightMode, false, false, true ) )
|
||||
{
|
||||
if ( m_Mobile.Debug )
|
||||
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 || !combatant.Alive || combatant.IsDeadBondedPet )
|
||||
{
|
||||
m_Mobile.DebugSay( "My combatant is gone, so my guard is up" );
|
||||
|
||||
Action = ActionType.Guard;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if ( !m_Mobile.InRange( combatant, m_Mobile.RangePerception ) )
|
||||
{
|
||||
// They are somewhat far away, can we find something else?
|
||||
|
||||
if ( AcquireFocusMob( m_Mobile.RangePerception, m_Mobile.FightMode, false, false, true ) )
|
||||
{
|
||||
m_Mobile.Combatant = m_Mobile.FocusMob;
|
||||
m_Mobile.FocusMob = null;
|
||||
}
|
||||
else if ( !m_Mobile.InRange( combatant, m_Mobile.RangePerception * 3 ) )
|
||||
{
|
||||
m_Mobile.Combatant = null;
|
||||
}
|
||||
|
||||
combatant = m_Mobile.Combatant;
|
||||
|
||||
if ( combatant == null )
|
||||
{
|
||||
m_Mobile.DebugSay( "My combatant has fled, so I am on guard" );
|
||||
Action = ActionType.Guard;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/*if ( !m_Mobile.InLOS( combatant ) )
|
||||
{
|
||||
if ( AcquireFocusMob( m_Mobile.RangePerception, m_Mobile.FightMode, false, false, true ) )
|
||||
{
|
||||
m_Mobile.Combatant = combatant = m_Mobile.FocusMob;
|
||||
m_Mobile.FocusMob = null;
|
||||
}
|
||||
}*/
|
||||
|
||||
if ( MoveTo( combatant, true, m_Mobile.RangeFight ) )
|
||||
{
|
||||
m_Mobile.Direction = m_Mobile.GetDirectionTo( combatant );
|
||||
}
|
||||
else if ( AcquireFocusMob( m_Mobile.RangePerception, m_Mobile.FightMode, false, false, true ) )
|
||||
{
|
||||
if ( m_Mobile.Debug )
|
||||
m_Mobile.DebugSay( "My move is blocked, so I am going to attack {0}", m_Mobile.FocusMob.Name );
|
||||
|
||||
m_Mobile.Combatant = m_Mobile.FocusMob;
|
||||
Action = ActionType.Combat;
|
||||
|
||||
return true;
|
||||
}
|
||||
else if ( m_Mobile.GetDistanceToSqrt( combatant ) > m_Mobile.RangePerception + 1 )
|
||||
{
|
||||
if ( m_Mobile.Debug )
|
||||
m_Mobile.DebugSay( "I cannot find {0}, so my guard is up", combatant.Name );
|
||||
|
||||
Action = ActionType.Guard;
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( m_Mobile.Debug )
|
||||
m_Mobile.DebugSay( "I should be closer to {0}", combatant.Name );
|
||||
}
|
||||
|
||||
if ( !m_Mobile.Controlled && !m_Mobile.Summoned )
|
||||
{
|
||||
if ( m_Mobile.Hits < m_Mobile.HitsMax * 20/100 )
|
||||
{
|
||||
// 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 )
|
||||
{
|
||||
if ( m_Mobile.Debug )
|
||||
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 ) )
|
||||
{
|
||||
if ( m_Mobile.Debug )
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
100
Scripts/Mobiles/Base/AI/PredatorAI.cs
Normal file
100
Scripts/Mobiles/Base/AI/PredatorAI.cs
Normal file
|
|
@ -0,0 +1,100 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using Server.Targeting;
|
||||
using Server.Network;
|
||||
|
||||
|
||||
/*
|
||||
* PredatorAI, its an animal that can attack
|
||||
* Dont flee but dont attack if not hurt or attacked
|
||||
*
|
||||
*/
|
||||
|
||||
namespace Server.Mobiles
|
||||
{
|
||||
public class PredatorAI : BaseAI
|
||||
{
|
||||
public PredatorAI(BaseCreature m) : base (m)
|
||||
{
|
||||
}
|
||||
|
||||
public override bool DoActionWander()
|
||||
{
|
||||
if ( m_Mobile.Combatant != null )
|
||||
{
|
||||
m_Mobile.DebugSay( "I am hurt or being attacked, I kill him" );
|
||||
Action = ActionType.Combat;
|
||||
}
|
||||
else if (AcquireFocusMob(m_Mobile.RangePerception, m_Mobile.FightMode, true, false, true))
|
||||
{
|
||||
m_Mobile.DebugSay( "There is something near, I go away" );
|
||||
Action = ActionType.Backoff;
|
||||
}
|
||||
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.Wander;
|
||||
return true;
|
||||
}
|
||||
|
||||
if ( WalkMobileRange( combatant, 1, true, m_Mobile.RangeFight, m_Mobile.RangeFight ) )
|
||||
{
|
||||
m_Mobile.Direction = m_Mobile.GetDirectionTo( combatant );
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( m_Mobile.GetDistanceToSqrt( combatant ) > m_Mobile.RangePerception + 1 )
|
||||
{
|
||||
m_Mobile.DebugSay( "I cannot find {0}", combatant.Name );
|
||||
|
||||
Action = ActionType.Wander;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Mobile.DebugSay( "I should be closer to {0}", combatant.Name );
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool DoActionBackoff()
|
||||
{
|
||||
if ( m_Mobile.IsHurt() || m_Mobile.Combatant != null )
|
||||
{
|
||||
Action = ActionType.Combat;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (AcquireFocusMob(m_Mobile.RangePerception * 2, FightMode.Closest, true, false , true))
|
||||
{
|
||||
if ( WalkMobileRange(m_Mobile.FocusMob, 1, false, m_Mobile.RangePerception, m_Mobile.RangePerception * 2) )
|
||||
{
|
||||
m_Mobile.DebugSay( "Well, here I am safe" );
|
||||
Action = ActionType.Wander;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Mobile.DebugSay( "I have lost my focus, lets relax" );
|
||||
Action = ActionType.Wander;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
458
Scripts/Mobiles/Base/AI/SpeedInfo.cs
Normal file
458
Scripts/Mobiles/Base/AI/SpeedInfo.cs
Normal file
|
|
@ -0,0 +1,458 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using Server;
|
||||
using Server.Mobiles;
|
||||
|
||||
namespace Server
|
||||
{
|
||||
public class SpeedInfo
|
||||
{
|
||||
// Should we use the new method of speeds?
|
||||
private static bool Enabled = true;
|
||||
|
||||
private double m_ActiveSpeed;
|
||||
private double m_PassiveSpeed;
|
||||
private Type[] m_Types;
|
||||
|
||||
public double ActiveSpeed
|
||||
{
|
||||
get{ return m_ActiveSpeed; }
|
||||
set{ m_ActiveSpeed = value; }
|
||||
}
|
||||
|
||||
public double PassiveSpeed
|
||||
{
|
||||
get{ return m_PassiveSpeed; }
|
||||
set{ m_PassiveSpeed = value; }
|
||||
}
|
||||
|
||||
public Type[] Types
|
||||
{
|
||||
get{ return m_Types; }
|
||||
set{ m_Types = value; }
|
||||
}
|
||||
|
||||
public SpeedInfo( double activeSpeed, double passiveSpeed, Type[] types )
|
||||
{
|
||||
m_ActiveSpeed = activeSpeed;
|
||||
m_PassiveSpeed = passiveSpeed;
|
||||
m_Types = types;
|
||||
}
|
||||
|
||||
public static bool Contains( object obj )
|
||||
{
|
||||
if ( !Enabled )
|
||||
return false;
|
||||
|
||||
if ( m_Table == null )
|
||||
LoadTable();
|
||||
|
||||
SpeedInfo sp = (SpeedInfo)m_Table[obj.GetType()];
|
||||
|
||||
return ( sp != null );
|
||||
}
|
||||
|
||||
public static bool GetSpeeds( object obj, ref double activeSpeed, ref double passiveSpeed )
|
||||
{
|
||||
if ( !Enabled )
|
||||
return false;
|
||||
|
||||
if ( m_Table == null )
|
||||
LoadTable();
|
||||
|
||||
SpeedInfo sp = (SpeedInfo)m_Table[obj.GetType()];
|
||||
|
||||
if ( sp == null )
|
||||
return false;
|
||||
|
||||
activeSpeed = sp.ActiveSpeed;
|
||||
passiveSpeed = sp.PassiveSpeed;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private static void LoadTable()
|
||||
{
|
||||
m_Table = new Hashtable();
|
||||
|
||||
for ( int i = 0; i < m_Speeds.Length; ++i )
|
||||
{
|
||||
SpeedInfo info = m_Speeds[i];
|
||||
Type[] types = info.Types;
|
||||
|
||||
for ( int j = 0; j < types.Length; ++j )
|
||||
m_Table[types[j]] = info;
|
||||
}
|
||||
}
|
||||
|
||||
private static Hashtable m_Table;
|
||||
|
||||
private static SpeedInfo[] m_Speeds = new SpeedInfo[]
|
||||
{
|
||||
/* Slow */
|
||||
new SpeedInfo( 0.3, 0.6, new Type[]
|
||||
{
|
||||
typeof( RottingDrake ),
|
||||
typeof( ZombieDragon ),
|
||||
typeof( CarcassWorm ),
|
||||
typeof( Meglasaur ),
|
||||
typeof( Gorceratops ),
|
||||
typeof( Stegosaurus ),
|
||||
typeof( Turtle ),
|
||||
typeof( Shambler ),
|
||||
typeof( ShamblingMound ),
|
||||
typeof( AntLion ),
|
||||
typeof( ArcticOgreLord ),
|
||||
typeof( BoneKnight ),
|
||||
typeof( EarthElemental ),
|
||||
typeof( MeteorElemental ),
|
||||
typeof( StoneGolem ),
|
||||
typeof( StoneStatue ),
|
||||
typeof( Goliath ),
|
||||
typeof( MudElemental ),
|
||||
typeof( MagmaElemental ),
|
||||
typeof( WoodElemental ),
|
||||
typeof( Ettin ),
|
||||
typeof( SnowEttin ),
|
||||
typeof( SwampThing ),
|
||||
typeof( FrostOoze ),
|
||||
typeof( FrostTroll ),
|
||||
typeof( Ghoul ),
|
||||
typeof( Wight ),
|
||||
typeof( Golem ),
|
||||
typeof( HeadlessOne ),
|
||||
typeof( Mummy ),
|
||||
typeof( Ogre ),
|
||||
typeof( Owlbear ),
|
||||
typeof( Sasquatch ),
|
||||
typeof( CorpseGolem ),
|
||||
typeof( FleshGolem ),
|
||||
typeof( FleshGoliath ),
|
||||
typeof( Caveman ),
|
||||
typeof( OgreLord ),
|
||||
typeof( ForestGiant ),
|
||||
typeof( HillGiant ),
|
||||
typeof( MountainGiant ),
|
||||
typeof( FrostGiant ),
|
||||
typeof( Xorn ),
|
||||
typeof( Rat ),
|
||||
typeof( RottingCorpse ),
|
||||
typeof( Skeleton ),
|
||||
typeof( Slime ),
|
||||
typeof( Sludge ),
|
||||
typeof( LargeSlime ),
|
||||
typeof( Zombie ),
|
||||
typeof( ZombieGargoyle ),
|
||||
typeof( GargoyleUndead ),
|
||||
typeof( Walrus )
|
||||
} ),
|
||||
/* Fast */
|
||||
new SpeedInfo( 0.2, 0.4, new Type[]
|
||||
{
|
||||
typeof( BoneClaw ),
|
||||
typeof( ShadowDemon ),
|
||||
typeof( Torax ),
|
||||
typeof( Teradactyl ),
|
||||
typeof( AirElemental ),
|
||||
typeof( Typhoon ),
|
||||
typeof( AncientWyrm ),
|
||||
typeof( Balron ),
|
||||
typeof( SeaDevil ),
|
||||
typeof( DemonClaw ),
|
||||
typeof( BladeSpirits ),
|
||||
typeof( DreadSpider ),
|
||||
typeof( Efreet ),
|
||||
typeof( Lich ),
|
||||
typeof( Vampire ),
|
||||
typeof( Nightmare ),
|
||||
typeof( Cerberus ),
|
||||
typeof( Serperus ),
|
||||
typeof( Haderus ),
|
||||
typeof( OphidianArchmage ),
|
||||
typeof( OphidianMage ),
|
||||
typeof( OphidianWarrior ),
|
||||
typeof( OphidianMatriarch ),
|
||||
typeof( OphidianKnight ),
|
||||
typeof( Naga ),
|
||||
typeof( NagaWarrior ),
|
||||
typeof( NagaQueen ),
|
||||
typeof( FireNaga ),
|
||||
typeof( Kobra ),
|
||||
typeof( Medusa ),
|
||||
typeof( PoisonElemental ),
|
||||
typeof( GasCloud ),
|
||||
typeof( StormCloud ),
|
||||
typeof( IceSalamander ),
|
||||
typeof( FireSalamander ),
|
||||
typeof( Raptor ),
|
||||
typeof( SandVortex ),
|
||||
typeof( SavageShaman ),
|
||||
typeof( SnowElemental ),
|
||||
typeof( SuccubusQueen ),
|
||||
typeof( WhiteWyrm ),
|
||||
typeof( Wisp ),
|
||||
typeof( WidowQueen ),
|
||||
typeof( Kith ),
|
||||
typeof( BloodSpider ),
|
||||
typeof( GiantBlackWidow )
|
||||
} ),
|
||||
/* Very Fast */
|
||||
new SpeedInfo( 0.175, 0.350, new Type[]
|
||||
{
|
||||
typeof( EnergyVortex ),
|
||||
typeof( Pixie ),
|
||||
typeof( Fairy ),
|
||||
typeof( Swarm ),
|
||||
typeof( SilverSerpent ),
|
||||
typeof( Leviathan ),
|
||||
} ),
|
||||
/* Medium */
|
||||
new SpeedInfo( 0.25, 0.5, new Type[]
|
||||
{
|
||||
typeof( Demoness ),
|
||||
typeof( Hydra ),
|
||||
typeof( SeaHydra ),
|
||||
typeof( Goblin ),
|
||||
typeof( GoblinArcher ),
|
||||
typeof( GoblinWarrior ),
|
||||
typeof( MummyLord ),
|
||||
typeof( GiantCrab ),
|
||||
typeof( Lobstran ),
|
||||
typeof( Lurker ),
|
||||
typeof( ForestStalker ),
|
||||
typeof( CaveDweller ),
|
||||
typeof( Minotaur ),
|
||||
typeof( MinotaurLord ),
|
||||
typeof( MinotaurChief ),
|
||||
typeof( Ent ),
|
||||
typeof( Fungal ),
|
||||
typeof( FungalMage ),
|
||||
typeof( Sphinx ),
|
||||
typeof( RoyalSphinx ),
|
||||
typeof( AncientSphinx ),
|
||||
typeof( AcidElemental ),
|
||||
typeof( Alligator ),
|
||||
typeof( AncientLich ),
|
||||
typeof( AncientVampire ),
|
||||
typeof( Bird ),
|
||||
typeof( BlackBear ),
|
||||
typeof( BloodElemental ),
|
||||
typeof( BloodElementalElder ),
|
||||
typeof( PoisonElementalElder ),
|
||||
typeof( WaterElementalElder ),
|
||||
typeof( Boar ),
|
||||
typeof( BoneMagi ),
|
||||
typeof( Brigand ),
|
||||
typeof( BlackKnight ),
|
||||
typeof( BrownBear ),
|
||||
typeof( Bull ),
|
||||
typeof( BullFrog ),
|
||||
typeof( Cat ),
|
||||
typeof( Centaur ),
|
||||
typeof( Chicken ),
|
||||
typeof( Cougar ),
|
||||
typeof( Cow ),
|
||||
typeof( Cyclops ),
|
||||
typeof( CyclopsChief ),
|
||||
typeof( CyclopsLord ),
|
||||
typeof( Daemon ),
|
||||
typeof( Ktulu ),
|
||||
typeof( Deviless ),
|
||||
typeof( HornedDevil ),
|
||||
typeof( IceDevil ),
|
||||
typeof( DeepSeaSerpent ),
|
||||
typeof( GiantEel ),
|
||||
typeof( GiantSquid ),
|
||||
typeof( DemonicSpirit ),
|
||||
typeof( DireWolf ),
|
||||
typeof( Dog ),
|
||||
typeof( Dolphin ),
|
||||
typeof( GreatWhite ),
|
||||
typeof( Lochasaur ),
|
||||
typeof( Megalodon ),
|
||||
typeof( Shark ),
|
||||
typeof( Seahorse ),
|
||||
typeof( Tyranasaur ),
|
||||
typeof( SeaDragon ),
|
||||
typeof( Dragon ),
|
||||
typeof( Drakkhen ),
|
||||
typeof( DragonTurtle ),
|
||||
typeof( Drake ),
|
||||
typeof( LavaDrake ),
|
||||
typeof( SeaDrake ),
|
||||
typeof( SwampDragon ),
|
||||
typeof( Dwarf ),
|
||||
typeof( DwarfWarrior ),
|
||||
typeof( DwarfKnight ),
|
||||
typeof( Eagle ),
|
||||
typeof( ElderGazer ),
|
||||
typeof( AncientGazer ),
|
||||
typeof( EvilMage ),
|
||||
typeof( EvilMageLord ),
|
||||
typeof( MindFlayer ),
|
||||
typeof( Executioner ),
|
||||
typeof( Savage ),
|
||||
typeof( SavageLeader ),
|
||||
typeof( FireElemental ),
|
||||
typeof( LightningElemental ),
|
||||
typeof( FireGargoyle ),
|
||||
typeof( FrostSpider ),
|
||||
typeof( Shaclaw ),
|
||||
typeof( Gargoyle ),
|
||||
typeof( GargoyleMage ),
|
||||
typeof( GargoyleKnight ),
|
||||
typeof( GargoyleIce ),
|
||||
typeof( GargoyleStone ),
|
||||
typeof( GargoyleWizard ),
|
||||
typeof( GargoyleCrimson ),
|
||||
typeof( Gazer ),
|
||||
typeof( IceSerpent ),
|
||||
typeof( GiantRat ),
|
||||
typeof( GiantSerpent ),
|
||||
typeof( Viper ),
|
||||
typeof( Cobra ),
|
||||
typeof( GiantSpider ),
|
||||
typeof( GiantToad ),
|
||||
typeof( IceToad ),
|
||||
typeof( FireToad ),
|
||||
typeof( Goat ),
|
||||
typeof( Gorilla ),
|
||||
typeof( Ape ),
|
||||
typeof( GreatDeer ),
|
||||
typeof( GreyWolf ),
|
||||
typeof( GrizzlyBear ),
|
||||
typeof( CaveBear ),
|
||||
typeof( KodiakBear ),
|
||||
typeof( Lion ),
|
||||
typeof( Tiger ),
|
||||
typeof( Manticore ),
|
||||
typeof( SnowBear ),
|
||||
typeof( PandaBear ),
|
||||
typeof( Harpy ),
|
||||
typeof( ElderHarpy ),
|
||||
typeof( GiantHawk ),
|
||||
typeof( GiantRaven ),
|
||||
typeof( Roc ),
|
||||
typeof( AxeBeak ),
|
||||
typeof( Griffon ),
|
||||
typeof( Hippogriff ),
|
||||
typeof( HellHound ),
|
||||
typeof( Deer ),
|
||||
typeof( Hobgoblin ),
|
||||
typeof( HobgoblinChief ),
|
||||
typeof( HobgoblinArcher ),
|
||||
typeof( HobgoblinShaman ),
|
||||
typeof( Horse ),
|
||||
typeof( IceElemental ),
|
||||
typeof( IceFiend ),
|
||||
typeof( Imp ),
|
||||
typeof( FireImp ),
|
||||
typeof( IceImp ),
|
||||
typeof( Kraken ),
|
||||
typeof( HellCat ),
|
||||
typeof( LavaLizard ),
|
||||
typeof( GiantLizard ),
|
||||
typeof( LavaSerpent ),
|
||||
typeof( Lizardman ),
|
||||
typeof( Drasolisk ),
|
||||
typeof( Silisk ),
|
||||
typeof( Sakkhra ),
|
||||
typeof( SakkhraShaman ),
|
||||
typeof( Sahuagin ),
|
||||
typeof( SahuaginMage ),
|
||||
typeof( Llama ),
|
||||
typeof( Mongbat ),
|
||||
typeof( MountainGoat ),
|
||||
typeof( Dagon ),
|
||||
typeof( Krakoa ),
|
||||
typeof( OgreMagi ),
|
||||
typeof( Minion ),
|
||||
typeof( MinionWizard ),
|
||||
typeof( MinionWarrior ),
|
||||
typeof( Orc ),
|
||||
typeof( OrcCaptain ),
|
||||
typeof( OrcishLord ),
|
||||
typeof( OrcishMage ),
|
||||
typeof( PackHorse ),
|
||||
typeof( PackLlama ),
|
||||
typeof( Pirate ),
|
||||
typeof( Panther ),
|
||||
typeof( Pig ),
|
||||
typeof( PolarBear ),
|
||||
typeof( Rabbit ),
|
||||
typeof( Raccoon ),
|
||||
typeof( Squirrel ),
|
||||
typeof( Ratman ),
|
||||
typeof( RatmanArcher ),
|
||||
typeof( RatmanMage ),
|
||||
typeof( Satyr ),
|
||||
typeof( FlameCrawler ),
|
||||
typeof( Scorpion ),
|
||||
typeof( Mantis ),
|
||||
typeof( SandScorpion ),
|
||||
typeof( DeadlyScorpion ),
|
||||
typeof( SeaSerpent ),
|
||||
typeof( Shade ),
|
||||
typeof( ShadowWyrm ),
|
||||
typeof( Sheep ),
|
||||
typeof( BoneDrake ),
|
||||
typeof( SkeletalDragon ),
|
||||
typeof( VampiricDragon ),
|
||||
typeof( VampiricDrake ),
|
||||
typeof( SkeletalMage ),
|
||||
typeof( SkeletonArcher ),
|
||||
typeof( Snake ),
|
||||
typeof( SnowLeopard ),
|
||||
typeof( Spectre ),
|
||||
typeof( StoneGargoyle ),
|
||||
typeof( StoneHarpy ),
|
||||
typeof( StormGiant ),
|
||||
typeof( ShadowTitan ),
|
||||
typeof( SandGiant ),
|
||||
typeof( JungleGiant ),
|
||||
typeof( Succubus ),
|
||||
typeof( SwampTentacle ),
|
||||
typeof( AntaurWorker ),
|
||||
typeof( AntaurSoldier ),
|
||||
typeof( AntaurLord ),
|
||||
typeof( AntaurQueen ),
|
||||
typeof( TerathanAvenger ),
|
||||
typeof( TerathanDrone ),
|
||||
typeof( TerathanMatriarch ),
|
||||
typeof( TerathanWarrior ),
|
||||
typeof( TimberWolf ),
|
||||
typeof( Titan ),
|
||||
typeof( Troll ),
|
||||
typeof( Yeti ),
|
||||
typeof( Bugbear ),
|
||||
typeof( Unicorn ),
|
||||
typeof( DreadHorn ),
|
||||
typeof( WaterElemental ),
|
||||
typeof( DeepSeaElemental ),
|
||||
typeof( WhippingVine ),
|
||||
typeof( WhiteWolf ),
|
||||
typeof( Wraith ),
|
||||
typeof( AncientWyvern ),
|
||||
typeof( Wyvern ),
|
||||
typeof( Pharaoh ),
|
||||
typeof( LichLord ),
|
||||
typeof( Nazghoul ),
|
||||
typeof( Demilich ),
|
||||
typeof( VampireLord ),
|
||||
typeof( SkeletalKnight ),
|
||||
typeof( Bat ),
|
||||
typeof( VampireBat ),
|
||||
typeof( CaveBat ),
|
||||
typeof( Stirge ),
|
||||
typeof( ArcaneScarab ),
|
||||
typeof( Werewolf ),
|
||||
typeof( Scarab ),
|
||||
typeof( GoraxHorned ),
|
||||
typeof( GoraxSlicer ),
|
||||
typeof( GiantScarab ),
|
||||
typeof( IronBeetle ),
|
||||
typeof( Beetle )
|
||||
} )
|
||||
};
|
||||
}
|
||||
}
|
||||
194
Scripts/Mobiles/Base/AI/ThiefAI.cs
Normal file
194
Scripts/Mobiles/Base/AI/ThiefAI.cs
Normal file
|
|
@ -0,0 +1,194 @@
|
|||
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.HandToHand].Value >= 80.0 && m_Mobile.Skills[SkillName.Tactics].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_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 )
|
||||
{
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
121
Scripts/Mobiles/Base/AI/TimidAI.cs
Normal file
121
Scripts/Mobiles/Base/AI/TimidAI.cs
Normal file
|
|
@ -0,0 +1,121 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using Server.Targeting;
|
||||
using Server.Network;
|
||||
|
||||
namespace Server.Mobiles
|
||||
{
|
||||
public class TimidAI : BaseAI
|
||||
{
|
||||
public TimidAI(BaseCreature m) : base (m)
|
||||
{
|
||||
}
|
||||
|
||||
public override bool DoActionWander()
|
||||
{
|
||||
if (AcquireFocusMob(m_Mobile.RangePerception, m_Mobile.FightMode, true, false, true))
|
||||
{
|
||||
m_Mobile.DebugSay( "There is something near, I go away" );
|
||||
Action = ActionType.Backoff;
|
||||
}
|
||||
else if ( m_Mobile.IsHurt() || m_Mobile.Combatant != null )
|
||||
{
|
||||
m_Mobile.DebugSay( "I am hurt or being attacked, I flee" );
|
||||
Action = ActionType.Flee;
|
||||
}
|
||||
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.." );
|
||||
|
||||
Action = ActionType.Wander;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if ( WalkMobileRange( combatant, 1, true, m_Mobile.RangeFight, m_Mobile.RangeFight ) )
|
||||
{
|
||||
m_Mobile.Direction = m_Mobile.GetDirectionTo( combatant );
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( m_Mobile.GetDistanceToSqrt( combatant ) > m_Mobile.RangePerception + 1 )
|
||||
{
|
||||
if ( m_Mobile.Debug )
|
||||
m_Mobile.DebugSay( "I cannot find {0}", combatant.Name );
|
||||
|
||||
Action = ActionType.Wander;
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( m_Mobile.Debug )
|
||||
m_Mobile.DebugSay( "I should be closer to {0}", combatant.Name );
|
||||
}
|
||||
}
|
||||
|
||||
if ( !m_Mobile.Controlled && !m_Mobile.Summoned )
|
||||
{
|
||||
double hitPercent = (double)m_Mobile.Hits / m_Mobile.HitsMax;
|
||||
|
||||
if ( hitPercent < 0.1 )
|
||||
{
|
||||
m_Mobile.DebugSay( "I am low on health!" );
|
||||
Action = ActionType.Flee;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool DoActionBackoff()
|
||||
{
|
||||
double hitPercent = (double)m_Mobile.Hits / m_Mobile.HitsMax;
|
||||
|
||||
if ( !m_Mobile.Summoned && !m_Mobile.Controlled && hitPercent < 0.1 ) // Less than 10% health
|
||||
{
|
||||
Action = ActionType.Flee;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (AcquireFocusMob(m_Mobile.RangePerception * 2, FightMode.Closest, true, false , true))
|
||||
{
|
||||
if ( WalkMobileRange(m_Mobile.FocusMob, 1, false, m_Mobile.RangePerception, m_Mobile.RangePerception * 2) )
|
||||
{
|
||||
m_Mobile.DebugSay( "Well, here I am safe" );
|
||||
Action = ActionType.Wander;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Mobile.DebugSay( "I have lost my focus, lets relax" );
|
||||
Action = ActionType.Wander;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool DoActionFlee()
|
||||
{
|
||||
AcquireFocusMob(m_Mobile.RangePerception * 2, m_Mobile.FightMode, true, false, true);
|
||||
|
||||
if ( m_Mobile.FocusMob == null )
|
||||
m_Mobile.FocusMob = m_Mobile.Combatant;
|
||||
|
||||
return base.DoActionFlee();
|
||||
}
|
||||
}
|
||||
}
|
||||
149
Scripts/Mobiles/Base/AI/VendorAI.cs
Normal file
149
Scripts/Mobiles/Base/AI/VendorAI.cs
Normal file
|
|
@ -0,0 +1,149 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using Server.Targeting;
|
||||
using Server.Network;
|
||||
|
||||
//
|
||||
// This is a first simple AI
|
||||
//
|
||||
//
|
||||
|
||||
namespace Server.Mobiles
|
||||
{
|
||||
public class VendorAI : BaseAI
|
||||
{
|
||||
public VendorAI(BaseCreature m) : base (m)
|
||||
{
|
||||
}
|
||||
|
||||
public override bool DoActionWander()
|
||||
{
|
||||
m_Mobile.DebugSay( "I'm fine" );
|
||||
|
||||
if ( m_Mobile.Combatant != null )
|
||||
{
|
||||
if ( m_Mobile.Debug )
|
||||
m_Mobile.DebugSay( "{0} is attacking me", m_Mobile.Combatant.Name );
|
||||
|
||||
m_Mobile.Say( Utility.RandomList( 1005305, 501603 ) );
|
||||
|
||||
Action = ActionType.Flee;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( m_Mobile.FocusMob != null )
|
||||
{
|
||||
if ( m_Mobile.Debug )
|
||||
m_Mobile.DebugSay( "{0} has talked to me", m_Mobile.FocusMob.Name );
|
||||
|
||||
Action = ActionType.Interact;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Mobile.Warmode = false;
|
||||
|
||||
base.DoActionWander();
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool DoActionInteract()
|
||||
{
|
||||
Mobile customer = m_Mobile.FocusMob;
|
||||
|
||||
if ( m_Mobile.Combatant != null )
|
||||
{
|
||||
if ( m_Mobile.Debug )
|
||||
m_Mobile.DebugSay( "{0} is attacking me", m_Mobile.Combatant.Name );
|
||||
|
||||
m_Mobile.Say( Utility.RandomList( 1005305, 501603 ) );
|
||||
|
||||
Action = ActionType.Flee;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if ( customer == null || customer.Deleted || customer.Map != m_Mobile.Map )
|
||||
{
|
||||
m_Mobile.DebugSay( "My customer have disapeared" );
|
||||
m_Mobile.FocusMob = null;
|
||||
|
||||
Action = ActionType.Wander;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( customer.InRange( m_Mobile, m_Mobile.RangeFight ) )
|
||||
{
|
||||
if ( m_Mobile.Debug )
|
||||
m_Mobile.DebugSay( "I am with {0}", customer.Name );
|
||||
|
||||
m_Mobile.Direction = m_Mobile.GetDirectionTo( customer );
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( m_Mobile.Debug )
|
||||
m_Mobile.DebugSay( "{0} is gone", customer.Name );
|
||||
|
||||
m_Mobile.FocusMob = null;
|
||||
|
||||
Action = ActionType.Wander;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool DoActionGuard()
|
||||
{
|
||||
m_Mobile.FocusMob = m_Mobile.Combatant;
|
||||
return base.DoActionGuard();
|
||||
}
|
||||
|
||||
public override bool HandlesOnSpeech( Mobile from )
|
||||
{
|
||||
if ( from.InRange( m_Mobile, 4 ) )
|
||||
return true;
|
||||
|
||||
return base.HandlesOnSpeech( from );
|
||||
}
|
||||
|
||||
// Temporary
|
||||
public override void OnSpeech( SpeechEventArgs e )
|
||||
{
|
||||
base.OnSpeech( e );
|
||||
|
||||
Mobile from = e.Mobile;
|
||||
|
||||
if ( m_Mobile is BaseVendor && from.InRange( m_Mobile, Core.AOS ? 1 : 4 ) && !e.Handled )
|
||||
{
|
||||
if ( e.HasKeyword( 0x14D ) ) // *vendor sell*
|
||||
{
|
||||
e.Handled = true;
|
||||
|
||||
((BaseVendor)m_Mobile).VendorSell( from );
|
||||
m_Mobile.FocusMob = from;
|
||||
}
|
||||
else if ( e.HasKeyword( 0x3C ) )
|
||||
{
|
||||
e.Handled = true;
|
||||
|
||||
((BaseVendor)m_Mobile).VendorBuy( from );
|
||||
m_Mobile.FocusMob = from;
|
||||
}
|
||||
else if ( WasNamed( e.Speech ) )
|
||||
{
|
||||
e.Handled = true;
|
||||
|
||||
if ( e.HasKeyword( 0x177 ) ) // *sell*
|
||||
((BaseVendor)m_Mobile).VendorSell( from );
|
||||
else if ( e.HasKeyword( 0x171 ) ) // *buy*
|
||||
((BaseVendor)m_Mobile).VendorBuy( from );
|
||||
|
||||
m_Mobile.FocusMob = from;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
28
Scripts/Mobiles/Base/AnimalBuy.cs
Normal file
28
Scripts/Mobiles/Base/AnimalBuy.cs
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using Server.Items;
|
||||
|
||||
namespace Server.Mobiles
|
||||
{
|
||||
public class AnimalBuyInfo : GenericBuyInfo
|
||||
{
|
||||
private int m_ControlSlots;
|
||||
|
||||
public AnimalBuyInfo( int controlSlots, Type type, int price, int amount, int itemID, int hue ) : this( controlSlots, null, type, price, amount, itemID, hue )
|
||||
{
|
||||
}
|
||||
|
||||
public AnimalBuyInfo( int controlSlots, string name, Type type, int price, int amount, int itemID, int hue ) : base( name, type, price, amount, itemID, hue )
|
||||
{
|
||||
m_ControlSlots = controlSlots;
|
||||
}
|
||||
|
||||
public override int ControlSlots
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_ControlSlots;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
4127
Scripts/Mobiles/Base/BaseCreature.cs
Normal file
4127
Scripts/Mobiles/Base/BaseCreature.cs
Normal file
File diff suppressed because it is too large
Load diff
233
Scripts/Mobiles/Base/BaseGuildmaster.cs
Normal file
233
Scripts/Mobiles/Base/BaseGuildmaster.cs
Normal file
|
|
@ -0,0 +1,233 @@
|
|||
using System;
|
||||
using Server;
|
||||
using Server.Misc;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections;
|
||||
using Server.Network;
|
||||
using Server.Mobiles;
|
||||
using Server.Items;
|
||||
using Server.ContextMenus;
|
||||
|
||||
namespace Server.Mobiles
|
||||
{
|
||||
public abstract class BaseGuildmaster : BaseVendor
|
||||
{
|
||||
private List<SBInfo> m_SBInfos = new List<SBInfo>();
|
||||
protected override List<SBInfo> SBInfos{ get { return m_SBInfos; } }
|
||||
|
||||
public override bool IsActiveVendor{ get{ return true; } }
|
||||
|
||||
public override bool ClickTitle{ get{ return false; } }
|
||||
|
||||
public virtual int JoinCost{ get{ return 1000; } }
|
||||
|
||||
public override void InitSBInfo()
|
||||
{
|
||||
}
|
||||
|
||||
public virtual void SayGuildTo( Mobile m )
|
||||
{
|
||||
SayTo( m, 1008055 + (int)NpcGuild );
|
||||
}
|
||||
|
||||
public virtual void SayWelcomeTo( Mobile m )
|
||||
{
|
||||
SayTo( m, "Welcome to the guild! Thou shalt find it beneficial to your future endeavors." );
|
||||
}
|
||||
|
||||
public virtual void SayPriceTo( Mobile m )
|
||||
{
|
||||
m.Send( new MessageLocalizedAffix( Serial, Body, MessageType.Regular, SpeechHue, 3, 1008052, Name, AffixType.Append, JoinCost.ToString(), "" ) );
|
||||
}
|
||||
|
||||
public virtual bool WasNamed( string speech )
|
||||
{
|
||||
string name = this.Name;
|
||||
|
||||
return ( name != null && Insensitive.StartsWith( speech, name ) );
|
||||
}
|
||||
|
||||
public override bool HandlesOnSpeech( Mobile from )
|
||||
{
|
||||
if ( from.InRange( this.Location, 2 ) )
|
||||
return true;
|
||||
|
||||
return base.HandlesOnSpeech( from );
|
||||
}
|
||||
|
||||
public override void GetContextMenuEntries( Mobile from, List<ContextMenuEntry> list )
|
||||
{
|
||||
PlayerMobile pm = (PlayerMobile)from;
|
||||
base.GetContextMenuEntries( from, list );
|
||||
if ( pm.NpcGuild != this.NpcGuild ){ list.Add( new JoinEntry( from, this ) ); }
|
||||
else if ( pm.NpcGuild == this.NpcGuild ){ list.Add( new ResignEntry( from, this ) ); }
|
||||
}
|
||||
|
||||
public class JoinEntry : ContextMenuEntry
|
||||
{
|
||||
private Mobile m_Mobile;
|
||||
private Mobile m_Guildmaster;
|
||||
|
||||
public JoinEntry( Mobile from, Mobile guildmaster ) : base( 6116, 3 )
|
||||
{
|
||||
m_Mobile = from;
|
||||
m_Guildmaster = guildmaster;
|
||||
}
|
||||
|
||||
public override void OnClick()
|
||||
{
|
||||
if( !( m_Mobile is PlayerMobile ) )
|
||||
return;
|
||||
|
||||
JoinGuild( m_Mobile, (BaseGuildmaster)m_Guildmaster );
|
||||
}
|
||||
}
|
||||
|
||||
public class ResignEntry : ContextMenuEntry
|
||||
{
|
||||
private Mobile m_Mobile;
|
||||
private Mobile m_Guildmaster;
|
||||
|
||||
public ResignEntry( Mobile from, Mobile guildmaster ) : base( 6115, 3 )
|
||||
{
|
||||
m_Mobile = from;
|
||||
m_Guildmaster = guildmaster;
|
||||
}
|
||||
|
||||
public override void OnClick()
|
||||
{
|
||||
if( !( m_Mobile is PlayerMobile ) )
|
||||
return;
|
||||
|
||||
ResignGuild( m_Mobile, (BaseGuildmaster)m_Guildmaster );
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnSpeech( SpeechEventArgs e )
|
||||
{
|
||||
Mobile from = e.Mobile;
|
||||
|
||||
if ( !e.Handled && from is PlayerMobile && from.InRange( this.Location, 2 ) && WasNamed( e.Speech ) )
|
||||
{
|
||||
PlayerMobile pm = (PlayerMobile)from;
|
||||
|
||||
if ( e.HasKeyword( 0x0004 ) ) // *join* | *member*
|
||||
{
|
||||
if ( pm.NpcGuild == this.NpcGuild )
|
||||
SayTo( from, 501047 ); // Thou art already a member of our guild.
|
||||
else if ( pm.NpcGuild != NpcGuild.None )
|
||||
SayTo( from, 501046 ); // Thou must resign from thy other guild first.
|
||||
else
|
||||
SayPriceTo( from );
|
||||
|
||||
e.Handled = true;
|
||||
}
|
||||
else if ( e.HasKeyword( 0x0005 ) ) // *resign* | *quit*
|
||||
{
|
||||
if ( pm.NpcGuild != this.NpcGuild )
|
||||
{
|
||||
SayTo( from, 501052 ); // Thou dost not belong to my guild!
|
||||
}
|
||||
else
|
||||
{
|
||||
SayTo( from, 501054 ); // I accept thy resignation.
|
||||
pm.NpcGuild = NpcGuild.None;
|
||||
pm.InvalidateProperties();
|
||||
}
|
||||
|
||||
e.Handled = true;
|
||||
}
|
||||
}
|
||||
|
||||
base.OnSpeech( e );
|
||||
}
|
||||
|
||||
public static void JoinGuild( Mobile player, BaseGuildmaster guildmaster )
|
||||
{
|
||||
PlayerMobile pm = (PlayerMobile)player;
|
||||
|
||||
if ( pm.NpcGuild == ((BaseVendor)guildmaster).NpcGuild )
|
||||
guildmaster.SayTo( player, 501047 ); // Thou art already a member of our guild.
|
||||
else if ( pm.NpcGuild != NpcGuild.None )
|
||||
guildmaster.SayTo( player, 501046 ); // Thou must resign from thy other guild first.
|
||||
else
|
||||
guildmaster.SayPriceTo( player );
|
||||
}
|
||||
|
||||
public static void ResignGuild( Mobile player, BaseGuildmaster guildmaster )
|
||||
{
|
||||
PlayerMobile pm = (PlayerMobile)player;
|
||||
|
||||
if ( pm.NpcGuild != ((BaseVendor)guildmaster).NpcGuild )
|
||||
{
|
||||
guildmaster.SayTo( player, 501052 ); // Thou dost not belong to my guild!
|
||||
}
|
||||
else
|
||||
{
|
||||
guildmaster.SayTo( player, 501054 ); // I accept thy resignation.
|
||||
pm.NpcGuild = NpcGuild.None;
|
||||
pm.InvalidateProperties();
|
||||
}
|
||||
}
|
||||
|
||||
public override bool OnGoldGiven( Mobile from, Gold dropped )
|
||||
{
|
||||
if ( from is PlayerMobile && dropped.Amount == JoinCost )
|
||||
{
|
||||
PlayerMobile pm = (PlayerMobile)from;
|
||||
|
||||
if ( pm.NpcGuild == this.NpcGuild )
|
||||
{
|
||||
SayTo( from, 501047 ); // Thou art already a member of our guild.
|
||||
}
|
||||
else if ( pm.NpcGuild != NpcGuild.None )
|
||||
{
|
||||
SayTo( from, 501046 ); // Thou must resign from thy other guild first.
|
||||
}
|
||||
else if ( pm.Kills > 4 && this.NpcGuild != NpcGuild.AssassinsGuild && this.NpcGuild != NpcGuild.ThievesGuild )
|
||||
{
|
||||
SayTo( from, 501522 ); // I shall not deal with scum like thee!
|
||||
}
|
||||
else
|
||||
{
|
||||
SayWelcomeTo( from );
|
||||
|
||||
pm.NpcGuild = this.NpcGuild;
|
||||
pm.NpcGuildJoinTime = DateTime.Now;
|
||||
pm.NpcGuildGameTime = pm.GameTime;
|
||||
pm.InvalidateProperties();
|
||||
|
||||
dropped.Delete();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return base.OnGoldGiven( from, dropped );
|
||||
}
|
||||
|
||||
public BaseGuildmaster( string title ) : base( title )
|
||||
{
|
||||
Title = String.Format( "the {0} {1}", title, Female ? "guildmistress" : "guildmaster" );
|
||||
}
|
||||
|
||||
public BaseGuildmaster( Serial serial ) : base( serial )
|
||||
{
|
||||
}
|
||||
|
||||
public override void Serialize( GenericWriter writer )
|
||||
{
|
||||
base.Serialize( writer );
|
||||
|
||||
writer.Write( (int) 0 ); // version
|
||||
}
|
||||
|
||||
public override void Deserialize( GenericReader reader )
|
||||
{
|
||||
base.Deserialize( reader );
|
||||
|
||||
int version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
107
Scripts/Mobiles/Base/BaseHealer.cs
Normal file
107
Scripts/Mobiles/Base/BaseHealer.cs
Normal file
|
|
@ -0,0 +1,107 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Server;
|
||||
using Server.Misc;
|
||||
using Server.Items;
|
||||
using Server.Gumps;
|
||||
|
||||
namespace Server.Mobiles
|
||||
{
|
||||
public abstract class BaseHealer : BaseVendor
|
||||
{
|
||||
private List<SBInfo> m_SBInfos = new List<SBInfo>();
|
||||
protected override List<SBInfo> SBInfos{ get { return m_SBInfos; } }
|
||||
|
||||
public override bool IsActiveVendor{ get{ return false; } }
|
||||
|
||||
public override void InitSBInfo()
|
||||
{
|
||||
}
|
||||
|
||||
public BaseHealer() : base( null )
|
||||
{
|
||||
Invulnerable = true;
|
||||
|
||||
SetStr( 304, 400 );
|
||||
SetDex( 102, 150 );
|
||||
SetInt( 204, 300 );
|
||||
|
||||
SetDamage( 10, 23 );
|
||||
|
||||
SetSkill( SkillName.Concentration, 82.0, 100.0 );
|
||||
SetSkill( SkillName.Healing, 75.0, 97.5 );
|
||||
SetSkill( SkillName.Magery, 82.0, 100.0 );
|
||||
SetSkill( SkillName.MagicResist, 82.0, 100.0 );
|
||||
SetSkill( SkillName.Tactics, 82.0, 100.0 );
|
||||
}
|
||||
|
||||
public virtual bool CheckResurrect( Mobile m )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
private DateTime m_NextResurrect;
|
||||
private static TimeSpan ResurrectDelay = TimeSpan.FromSeconds( 2.0 );
|
||||
|
||||
public virtual void OfferResurrection( Mobile m )
|
||||
{
|
||||
Direction = GetDirectionTo( m );
|
||||
|
||||
m.PlaySound(0x1F2);
|
||||
m.FixedEffect( 0x376A, 10, 16 );
|
||||
|
||||
m.CloseGump( typeof( ResurrectGump ) );
|
||||
m.SendGump( new ResurrectGump( m, ResurrectMessage.Healer ) );
|
||||
}
|
||||
|
||||
public virtual void OfferHeal( PlayerMobile m )
|
||||
{
|
||||
Direction = GetDirectionTo( m );
|
||||
|
||||
Say( 501228 ); // I can do no more for you at this time.
|
||||
}
|
||||
|
||||
public override void OnMovement( Mobile m, Point3D oldLocation )
|
||||
{
|
||||
if ( !m.Frozen && DateTime.Now >= m_NextResurrect && InRange( m, 4 ) && !InRange( oldLocation, 4 ) && InLOS( m ) )
|
||||
{
|
||||
if ( !m.Alive )
|
||||
{
|
||||
m_NextResurrect = DateTime.Now + ResurrectDelay;
|
||||
|
||||
if ( m.Map == null || !m.Map.CanFit( m.Location, 16, false, false ) )
|
||||
{
|
||||
m.SendLocalizedMessage( 502391 ); // Thou can not be resurrected there!
|
||||
}
|
||||
else if ( CheckResurrect( m ) )
|
||||
{
|
||||
OfferResurrection( m );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public BaseHealer( Serial serial ) : base( serial )
|
||||
{
|
||||
}
|
||||
|
||||
public override void Serialize( GenericWriter writer )
|
||||
{
|
||||
base.Serialize( writer );
|
||||
}
|
||||
|
||||
public override void Deserialize( GenericReader reader )
|
||||
{
|
||||
base.Deserialize( reader );
|
||||
|
||||
if ( !Invulnerable )
|
||||
{
|
||||
AI = AIType.AI_Mage;
|
||||
ActiveSpeed = 0.2;
|
||||
PassiveSpeed = 0.8;
|
||||
RangePerception = BaseCreature.DefaultRangePerception;
|
||||
FightMode = FightMode.Aggressor;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
1375
Scripts/Mobiles/Base/BaseVendor.cs
Normal file
1375
Scripts/Mobiles/Base/BaseVendor.cs
Normal file
File diff suppressed because it is too large
Load diff
34
Scripts/Mobiles/Base/BeverageBuy.cs
Normal file
34
Scripts/Mobiles/Base/BeverageBuy.cs
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using Server.Items;
|
||||
|
||||
namespace Server.Mobiles
|
||||
{
|
||||
public class BeverageBuyInfo : GenericBuyInfo
|
||||
{
|
||||
private BeverageType m_Content;
|
||||
|
||||
public override bool CanCacheDisplay{ get{ return false; } }
|
||||
|
||||
public BeverageBuyInfo( Type type, BeverageType content, int price, int amount, int itemID, int hue ) : this( null, type, content, price, amount, itemID, hue )
|
||||
{
|
||||
}
|
||||
|
||||
public BeverageBuyInfo( string name, Type type, BeverageType content, int price, int amount, int itemID, int hue ) : base( name, type, price, amount, itemID, hue )
|
||||
{
|
||||
m_Content = content;
|
||||
|
||||
if ( type == typeof( Pitcher ) )
|
||||
Name = (1048128 + (int)content).ToString();
|
||||
else if ( type == typeof( BeverageBottle ) )
|
||||
Name = (1042959 + (int)content).ToString();
|
||||
else if ( type == typeof( Jug ) )
|
||||
Name = (1042965 + (int)content).ToString();
|
||||
}
|
||||
|
||||
public override IEntity GetEntity()
|
||||
{
|
||||
return (IEntity)Activator.CreateInstance( Type, new object[]{ m_Content } );
|
||||
}
|
||||
}
|
||||
}
|
||||
347
Scripts/Mobiles/Base/GenericBuy.cs
Normal file
347
Scripts/Mobiles/Base/GenericBuy.cs
Normal file
|
|
@ -0,0 +1,347 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Server;
|
||||
using Server.Items;
|
||||
using Server.Network;
|
||||
|
||||
namespace Server.Mobiles
|
||||
{
|
||||
public class GenericBuyInfo : IBuyItemInfo
|
||||
{
|
||||
private class DisplayCache : Container
|
||||
{
|
||||
private static DisplayCache m_Cache;
|
||||
|
||||
public static DisplayCache Cache {
|
||||
get {
|
||||
if ( m_Cache == null || m_Cache.Deleted )
|
||||
m_Cache = new DisplayCache();
|
||||
|
||||
return m_Cache;
|
||||
}
|
||||
}
|
||||
|
||||
private Dictionary<Type, IEntity> m_Table;
|
||||
private List<Mobile> m_Mobiles;
|
||||
|
||||
public DisplayCache() : base( 0 )
|
||||
{
|
||||
m_Table = new Dictionary<Type, IEntity>();
|
||||
m_Mobiles = new List<Mobile>();
|
||||
}
|
||||
|
||||
public IEntity Lookup( Type key )
|
||||
{
|
||||
IEntity e = null;
|
||||
m_Table.TryGetValue( key, out e );
|
||||
return e;
|
||||
}
|
||||
|
||||
public void Store( Type key, IEntity obj, bool cache )
|
||||
{
|
||||
if ( cache )
|
||||
m_Table[key] = obj;
|
||||
|
||||
if ( obj is Item )
|
||||
{
|
||||
Item sell = (Item)obj;
|
||||
|
||||
if ( sell is BaseJewel )
|
||||
((BaseJewel)sell).GemType = GemType.None;
|
||||
|
||||
AddItem( (Item)obj );
|
||||
}
|
||||
else if ( obj is Mobile )
|
||||
m_Mobiles.Add( (Mobile)obj );
|
||||
}
|
||||
|
||||
public DisplayCache( Serial serial ) : base( serial )
|
||||
{
|
||||
}
|
||||
|
||||
public override void OnAfterDelete()
|
||||
{
|
||||
base.OnAfterDelete();
|
||||
|
||||
for ( int i = 0; i < m_Mobiles.Count; ++i )
|
||||
m_Mobiles[i].Delete();
|
||||
|
||||
m_Mobiles.Clear();
|
||||
|
||||
for ( int i = Items.Count - 1; i >= 0; --i )
|
||||
if ( i < Items.Count )
|
||||
Items[i].Delete();
|
||||
|
||||
if ( m_Cache == this )
|
||||
m_Cache = null;
|
||||
}
|
||||
|
||||
public override void Serialize( GenericWriter writer )
|
||||
{
|
||||
base.Serialize( writer );
|
||||
|
||||
writer.Write( (int) 0 ); // version
|
||||
|
||||
writer.Write( m_Mobiles );
|
||||
}
|
||||
|
||||
public override void Deserialize( GenericReader reader )
|
||||
{
|
||||
base.Deserialize( reader );
|
||||
|
||||
int version = reader.ReadInt();
|
||||
|
||||
m_Mobiles = reader.ReadStrongMobileList();
|
||||
|
||||
for ( int i = 0; i < m_Mobiles.Count; ++i )
|
||||
m_Mobiles[i].Delete();
|
||||
|
||||
m_Mobiles.Clear();
|
||||
|
||||
for ( int i = Items.Count - 1; i >= 0; --i )
|
||||
if ( i < Items.Count )
|
||||
Items[i].Delete();
|
||||
|
||||
if ( m_Cache == null )
|
||||
m_Cache = this;
|
||||
else
|
||||
Delete();
|
||||
|
||||
m_Table = new Dictionary<Type, IEntity>();
|
||||
}
|
||||
}
|
||||
|
||||
private Type m_Type;
|
||||
private string m_Name;
|
||||
private int m_Price;
|
||||
private int m_MaxAmount, m_Amount;
|
||||
private int m_ItemID;
|
||||
private int m_Hue;
|
||||
private object[] m_Args;
|
||||
private IEntity m_DisplayEntity;
|
||||
|
||||
public virtual int ControlSlots{ get{ return 0; } }
|
||||
|
||||
public virtual bool CanCacheDisplay{ get{ return false; } } //return ( m_Args == null || m_Args.Length == 0 ); }
|
||||
|
||||
private bool IsDeleted( IEntity obj )
|
||||
{
|
||||
if ( obj is Item )
|
||||
return ((Item)obj).Deleted;
|
||||
else if ( obj is Mobile )
|
||||
return ((Mobile)obj).Deleted;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void DeleteDisplayEntity()
|
||||
{
|
||||
if ( m_DisplayEntity == null )
|
||||
return;
|
||||
|
||||
m_DisplayEntity.Delete();
|
||||
m_DisplayEntity = null;
|
||||
}
|
||||
|
||||
public IEntity GetDisplayEntity()
|
||||
{
|
||||
if ( m_DisplayEntity != null && !IsDeleted( m_DisplayEntity ) )
|
||||
return m_DisplayEntity;
|
||||
|
||||
bool canCache = this.CanCacheDisplay;
|
||||
|
||||
if ( canCache )
|
||||
m_DisplayEntity = DisplayCache.Cache.Lookup( m_Type );
|
||||
|
||||
if ( m_DisplayEntity == null || IsDeleted( m_DisplayEntity ) )
|
||||
m_DisplayEntity = GetEntity();
|
||||
|
||||
DisplayCache.Cache.Store( m_Type, m_DisplayEntity, canCache );
|
||||
|
||||
return m_DisplayEntity;
|
||||
}
|
||||
|
||||
public Type Type
|
||||
{
|
||||
get{ return m_Type; }
|
||||
set{ m_Type = value; }
|
||||
}
|
||||
|
||||
public string Name
|
||||
{
|
||||
get{ return m_Name; }
|
||||
set{ m_Name = value; }
|
||||
}
|
||||
|
||||
public int DefaultPrice{ get{ return m_PriceScalar; } }
|
||||
|
||||
private int m_PriceScalar;
|
||||
|
||||
public int PriceScalar
|
||||
{
|
||||
get{ return m_PriceScalar; }
|
||||
set{ m_PriceScalar = value; }
|
||||
}
|
||||
|
||||
public int Price
|
||||
{
|
||||
get
|
||||
{
|
||||
if ( m_PriceScalar != 0 )
|
||||
{
|
||||
if ( m_Price > 5000000 )
|
||||
{
|
||||
long price = m_Price;
|
||||
|
||||
price *= m_PriceScalar;
|
||||
price += 50;
|
||||
price /= 100;
|
||||
|
||||
if ( price > int.MaxValue )
|
||||
price = int.MaxValue;
|
||||
|
||||
return (int)price;
|
||||
}
|
||||
|
||||
return ( ((m_Price * m_PriceScalar) + 50) / 100 );
|
||||
}
|
||||
|
||||
return m_Price;
|
||||
}
|
||||
set{ m_Price = value; }
|
||||
}
|
||||
|
||||
public int ItemID
|
||||
{
|
||||
get{ return m_ItemID; }
|
||||
set{ m_ItemID = value; }
|
||||
}
|
||||
|
||||
public int Hue
|
||||
{
|
||||
get{ return m_Hue; }
|
||||
set{ m_Hue = value; }
|
||||
}
|
||||
|
||||
public int Amount
|
||||
{
|
||||
get{ return m_Amount; }
|
||||
set{ if ( value < 0 ) value = 0; m_Amount = value; }
|
||||
}
|
||||
|
||||
public int MaxAmount
|
||||
{
|
||||
get{ return m_MaxAmount; }
|
||||
set{ m_MaxAmount = value; }
|
||||
}
|
||||
|
||||
public object[] Args
|
||||
{
|
||||
get{ return m_Args; }
|
||||
set{ m_Args = value; }
|
||||
}
|
||||
|
||||
public GenericBuyInfo( Type type, int price, int amount, int itemID, int hue ) : this( null, type, price, amount, itemID, hue, null )
|
||||
{
|
||||
}
|
||||
|
||||
public GenericBuyInfo( string name, Type type, int price, int amount, int itemID, int hue ) : this( name, type, price, amount, itemID, hue, null )
|
||||
{
|
||||
}
|
||||
|
||||
public GenericBuyInfo( Type type, int price, int amount, int itemID, int hue, object[] args ) : this( null, type, price, amount, itemID, hue, args )
|
||||
{
|
||||
}
|
||||
|
||||
public GenericBuyInfo( string name, Type type, int price, int amount, int itemID, int hue, object[] args )
|
||||
{
|
||||
if ( amount > 10 )
|
||||
amount = Utility.RandomMinMax( (amount-5), (amount+10) );
|
||||
|
||||
m_Type = type;
|
||||
m_Price = price;
|
||||
m_MaxAmount = m_Amount = amount;
|
||||
m_ItemID = itemID;
|
||||
m_Hue = hue;
|
||||
m_Args = args;
|
||||
|
||||
if ( name == null )
|
||||
m_Name = itemID < 0x4000 ? (1020000 + itemID).ToString() : (1078872 + itemID).ToString();
|
||||
else
|
||||
m_Name = name;
|
||||
}
|
||||
|
||||
//get a new instance of an object (we just bought it)
|
||||
public virtual IEntity GetEntity()
|
||||
{
|
||||
if ( m_Args == null || m_Args.Length == 0 )
|
||||
return (IEntity)Activator.CreateInstance( m_Type );
|
||||
|
||||
return (IEntity)Activator.CreateInstance( m_Type, m_Args );
|
||||
//return (Item)Activator.CreateInstance( m_Type );
|
||||
}
|
||||
|
||||
//Attempt to restock with item, (return true if restock sucessful)
|
||||
public bool Restock( Item item, int amount )
|
||||
{
|
||||
return false;
|
||||
/*if ( item.GetType() == m_Type )
|
||||
{
|
||||
if ( item is BaseWeapon )
|
||||
{
|
||||
BaseWeapon weapon = (BaseWeapon)item;
|
||||
|
||||
if ( weapon.Quality == WeaponQuality.Low || weapon.Quality == WeaponQuality.Exceptional || (int)weapon.DurabilityLevel > 0 || (int)weapon.DamageLevel > 0 || (int)weapon.AccuracyLevel > 0 )
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( item is BaseArmor )
|
||||
{
|
||||
BaseArmor armor = (BaseArmor)item;
|
||||
|
||||
if ( armor.Quality == ArmorQuality.Low || armor.Quality == ArmorQuality.Exceptional || (int)armor.Durability > 0 || (int)armor.ProtectionLevel > 0 )
|
||||
return false;
|
||||
}
|
||||
|
||||
m_Amount += amount;
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}*/
|
||||
}
|
||||
|
||||
public void OnRestock()
|
||||
{
|
||||
if ( m_Amount <= 0 )
|
||||
{
|
||||
m_MaxAmount *= 2;
|
||||
|
||||
if ( m_MaxAmount >= 999 )
|
||||
m_MaxAmount = 999;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* NOTE: According to UO.com, the quantity is halved if the item does not reach 0
|
||||
* Here we implement differently: the quantity is halved only if less than half
|
||||
* of the maximum quantity was bought. That is, if more than half is sold, then
|
||||
* there's clearly a demand and we should not cut down on the stock.
|
||||
*/
|
||||
|
||||
int halfQuantity = m_MaxAmount;
|
||||
|
||||
if ( halfQuantity >= 999 )
|
||||
halfQuantity = 640;
|
||||
else if ( halfQuantity > 20 )
|
||||
halfQuantity /= 2;
|
||||
|
||||
if ( m_Amount >= halfQuantity )
|
||||
m_MaxAmount = halfQuantity;
|
||||
}
|
||||
|
||||
m_Amount = m_MaxAmount;
|
||||
}
|
||||
}
|
||||
}
|
||||
148
Scripts/Mobiles/Base/GenericSell.cs
Normal file
148
Scripts/Mobiles/Base/GenericSell.cs
Normal file
|
|
@ -0,0 +1,148 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Server.Items;
|
||||
|
||||
namespace Server.Mobiles
|
||||
{
|
||||
public class GenericSellInfo : IShopSellInfo
|
||||
{
|
||||
private Dictionary<Type, int> m_Table = new Dictionary<Type, int>();
|
||||
private Type[] m_Types;
|
||||
|
||||
public GenericSellInfo()
|
||||
{
|
||||
}
|
||||
|
||||
public void Add( Type type, int price )
|
||||
{
|
||||
m_Table[type] = price;
|
||||
m_Types = null;
|
||||
}
|
||||
|
||||
public int GetSellPriceFor( Item item )
|
||||
{
|
||||
int price = 0;
|
||||
m_Table.TryGetValue( item.GetType(), out price );
|
||||
|
||||
if ( item is BaseArmor ) {
|
||||
BaseArmor armor = (BaseArmor)item;
|
||||
|
||||
if ( armor.Quality == ArmorQuality.Low )
|
||||
price = (int)( price * 0.60 );
|
||||
else if ( armor.Quality == ArmorQuality.Exceptional )
|
||||
price = (int)( price * 1.25 );
|
||||
|
||||
price += 100 * (int)armor.Durability;
|
||||
|
||||
price += 100 * (int)armor.ProtectionLevel;
|
||||
|
||||
if ( price < 1 )
|
||||
price = 1;
|
||||
}
|
||||
else if ( item is BaseWeapon ) {
|
||||
BaseWeapon weapon = (BaseWeapon)item;
|
||||
|
||||
if ( weapon.Quality == WeaponQuality.Low )
|
||||
price = (int)( price * 0.60 );
|
||||
else if ( weapon.Quality == WeaponQuality.Exceptional )
|
||||
price = (int)( price * 1.25 );
|
||||
|
||||
price += 100 * (int)weapon.DurabilityLevel;
|
||||
|
||||
price += 100 * (int)weapon.DamageLevel;
|
||||
|
||||
if ( price < 1 )
|
||||
price = 1;
|
||||
}
|
||||
else if ( item is BaseJewel ) {
|
||||
BaseJewel jewel = (BaseJewel)item;
|
||||
|
||||
if ( jewel.GemType == GemType.StarSapphire )
|
||||
price += 62;
|
||||
else if ( jewel.GemType == GemType.Emerald )
|
||||
price += 50;
|
||||
else if ( jewel.GemType == GemType.Sapphire )
|
||||
price += 50;
|
||||
else if ( jewel.GemType == GemType.Ruby )
|
||||
price += 37;
|
||||
else if ( jewel.GemType == GemType.Citrine )
|
||||
price += 25;
|
||||
else if ( jewel.GemType == GemType.Amethyst )
|
||||
price += 50;
|
||||
else if ( jewel.GemType == GemType.Tourmaline )
|
||||
price += 47;
|
||||
else if ( jewel.GemType == GemType.Amber )
|
||||
price += 25;
|
||||
else if ( jewel.GemType == GemType.Diamond )
|
||||
price += 100;
|
||||
}
|
||||
else if ( item is BaseBeverage ) {
|
||||
int price1 = price, price2 = price;
|
||||
|
||||
if ( item is Pitcher )
|
||||
{ price1 = 3; price2 = 5; }
|
||||
else if ( item is BeverageBottle )
|
||||
{ price1 = 3; price2 = 3; }
|
||||
else if ( item is Jug )
|
||||
{ price1 = 6; price2 = 6; }
|
||||
|
||||
BaseBeverage bev = (BaseBeverage)item;
|
||||
|
||||
if ( bev.IsEmpty || bev.Content == BeverageType.Milk )
|
||||
price = price1;
|
||||
else
|
||||
price = price2;
|
||||
}
|
||||
|
||||
return price;
|
||||
}
|
||||
|
||||
public int GetBuyPriceFor( Item item )
|
||||
{
|
||||
return (int)( 1.90 * GetSellPriceFor( item ) );
|
||||
}
|
||||
|
||||
public Type[] Types
|
||||
{
|
||||
get
|
||||
{
|
||||
if ( m_Types == null )
|
||||
{
|
||||
m_Types = new Type[m_Table.Keys.Count];
|
||||
m_Table.Keys.CopyTo( m_Types, 0 );
|
||||
}
|
||||
|
||||
return m_Types;
|
||||
}
|
||||
}
|
||||
|
||||
public string GetNameFor( Item item )
|
||||
{
|
||||
if ( item.Name != null )
|
||||
return item.Name;
|
||||
else
|
||||
return item.LabelNumber.ToString();
|
||||
}
|
||||
|
||||
public bool IsSellable( Item item )
|
||||
{
|
||||
//if ( item.Hue != 0 )
|
||||
//return false;
|
||||
|
||||
return IsInList( item.GetType() );
|
||||
}
|
||||
|
||||
public bool IsResellable( Item item )
|
||||
{
|
||||
//if ( item.Hue != 0 )
|
||||
//return false;
|
||||
|
||||
return IsInList( item.GetType() );
|
||||
}
|
||||
|
||||
public bool IsInList( Type type )
|
||||
{
|
||||
return m_Table.ContainsKey( type );
|
||||
}
|
||||
}
|
||||
}
|
||||
1064
Scripts/Mobiles/Base/PlayerBarkeeper.cs
Normal file
1064
Scripts/Mobiles/Base/PlayerBarkeeper.cs
Normal file
File diff suppressed because it is too large
Load diff
2173
Scripts/Mobiles/Base/PlayerMobile.cs
Normal file
2173
Scripts/Mobiles/Base/PlayerMobile.cs
Normal file
File diff suppressed because it is too large
Load diff
1687
Scripts/Mobiles/Base/PlayerVendor.cs
Normal file
1687
Scripts/Mobiles/Base/PlayerVendor.cs
Normal file
File diff suppressed because it is too large
Load diff
23
Scripts/Mobiles/Base/PresetMapBuy.cs
Normal file
23
Scripts/Mobiles/Base/PresetMapBuy.cs
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using Server.Items;
|
||||
|
||||
namespace Server.Mobiles
|
||||
{
|
||||
public class PresetMapBuyInfo : GenericBuyInfo
|
||||
{
|
||||
private PresetMapEntry m_Entry;
|
||||
|
||||
public override bool CanCacheDisplay{ get{ return false; } }
|
||||
|
||||
public PresetMapBuyInfo( PresetMapEntry entry, int price, int amount ) : base( entry.Name.ToString(), null, price, amount, 0x14EC, 0 )
|
||||
{
|
||||
m_Entry = entry;
|
||||
}
|
||||
|
||||
public override IEntity GetEntity()
|
||||
{
|
||||
return new PresetMap( m_Entry );
|
||||
}
|
||||
}
|
||||
}
|
||||
426
Scripts/Mobiles/Base/RentedVendor.cs
Normal file
426
Scripts/Mobiles/Base/RentedVendor.cs
Normal file
|
|
@ -0,0 +1,426 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Server;
|
||||
using Server.Gumps;
|
||||
using Server.Multis;
|
||||
using Server.ContextMenus;
|
||||
using Server.Prompts;
|
||||
|
||||
namespace Server.Mobiles
|
||||
{
|
||||
public class VendorRentalDuration
|
||||
{
|
||||
public static readonly VendorRentalDuration[] Instances = new VendorRentalDuration[]
|
||||
{
|
||||
new VendorRentalDuration( TimeSpan.FromDays( 7.0 ), 1062361 ), // 1 Week
|
||||
new VendorRentalDuration( TimeSpan.FromDays( 14.0 ), 1062362 ), // 2 Weeks
|
||||
new VendorRentalDuration( TimeSpan.FromDays( 21.0 ), 1062363 ), // 3 Weeks
|
||||
new VendorRentalDuration( TimeSpan.FromDays( 28.0 ), 1062364 ) // 1 Month
|
||||
};
|
||||
|
||||
private TimeSpan m_Duration;
|
||||
private int m_Name;
|
||||
|
||||
public TimeSpan Duration{ get{ return m_Duration; } }
|
||||
public int Name{ get{ return m_Name; } }
|
||||
|
||||
public int ID
|
||||
{
|
||||
get
|
||||
{
|
||||
for ( int i = 0; i < Instances.Length; i++ )
|
||||
{
|
||||
if ( Instances[i] == this )
|
||||
return i;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
private VendorRentalDuration( TimeSpan duration, int name )
|
||||
{
|
||||
m_Duration = duration;
|
||||
m_Name = name;
|
||||
}
|
||||
}
|
||||
|
||||
public class RentedVendor : PlayerVendor
|
||||
{
|
||||
private VendorRentalDuration m_RentalDuration;
|
||||
private int m_RentalPrice;
|
||||
private bool m_LandlordRenew;
|
||||
private bool m_RenterRenew;
|
||||
private int m_RenewalPrice;
|
||||
|
||||
private int m_RentalGold;
|
||||
|
||||
private DateTime m_RentalExpireTime;
|
||||
private Timer m_RentalExpireTimer;
|
||||
|
||||
public RentedVendor( Mobile owner, BaseHouse house, VendorRentalDuration duration, int rentalPrice, bool landlordRenew, int rentalGold ) : base( owner, house )
|
||||
{
|
||||
m_RentalDuration = duration;
|
||||
m_RentalPrice = m_RenewalPrice = rentalPrice;
|
||||
m_LandlordRenew = landlordRenew;
|
||||
m_RenterRenew = false;
|
||||
|
||||
m_RentalGold = rentalGold;
|
||||
|
||||
m_RentalExpireTime = DateTime.Now + duration.Duration;
|
||||
m_RentalExpireTimer = new RentalExpireTimer( this, duration.Duration );
|
||||
m_RentalExpireTimer.Start();
|
||||
}
|
||||
|
||||
public RentedVendor( Serial serial ) : base( serial )
|
||||
{
|
||||
}
|
||||
|
||||
public VendorRentalDuration RentalDuration
|
||||
{
|
||||
get{ return m_RentalDuration; }
|
||||
}
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster )]
|
||||
public int RentalPrice
|
||||
{
|
||||
get{ return m_RentalPrice; }
|
||||
set{ m_RentalPrice = value; }
|
||||
}
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster )]
|
||||
public bool LandlordRenew
|
||||
{
|
||||
get{ return m_LandlordRenew; }
|
||||
set{ m_LandlordRenew = value; }
|
||||
}
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster )]
|
||||
public bool RenterRenew
|
||||
{
|
||||
get{ return m_RenterRenew; }
|
||||
set{ m_RenterRenew = value; }
|
||||
}
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster )]
|
||||
public bool Renew
|
||||
{
|
||||
get{ return LandlordRenew && RenterRenew && House != null && House.DecayType != DecayType.Condemned; }
|
||||
}
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster )]
|
||||
public int RenewalPrice
|
||||
{
|
||||
get{ return m_RenewalPrice; }
|
||||
set{ m_RenewalPrice = value; }
|
||||
}
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster )]
|
||||
public int RentalGold
|
||||
{
|
||||
get{ return m_RentalGold; }
|
||||
set{ m_RentalGold = value; }
|
||||
}
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster )]
|
||||
public DateTime RentalExpireTime
|
||||
{
|
||||
get{ return m_RentalExpireTime; }
|
||||
}
|
||||
|
||||
public override bool IsOwner( Mobile m )
|
||||
{
|
||||
return m == Owner || m.AccessLevel >= AccessLevel.GameMaster;
|
||||
}
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster )]
|
||||
public Mobile Landlord
|
||||
{
|
||||
get
|
||||
{
|
||||
if ( House != null )
|
||||
return House.Owner;
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsLandlord( Mobile m )
|
||||
{
|
||||
return House != null && House.IsOwner( m );
|
||||
}
|
||||
|
||||
public void ComputeRentalExpireDelay( out int days, out int hours )
|
||||
{
|
||||
TimeSpan delay = RentalExpireTime - DateTime.Now;
|
||||
|
||||
if ( delay <= TimeSpan.Zero )
|
||||
{
|
||||
days = 0;
|
||||
hours = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
days = delay.Days;
|
||||
hours = delay.Hours;
|
||||
}
|
||||
}
|
||||
|
||||
public void SendRentalExpireMessage( Mobile to )
|
||||
{
|
||||
int days, hours;
|
||||
ComputeRentalExpireDelay( out days, out hours );
|
||||
|
||||
to.SendLocalizedMessage( 1062464, days.ToString() + "\t" + hours.ToString() ); // The rental contract on this vendor will expire in ~1_DAY~ day(s) and ~2_HOUR~ hour(s).
|
||||
}
|
||||
|
||||
public override void OnAfterDelete()
|
||||
{
|
||||
base.OnAfterDelete();
|
||||
|
||||
m_RentalExpireTimer.Stop();
|
||||
}
|
||||
|
||||
public override void Destroy( bool toBackpack )
|
||||
{
|
||||
if ( RentalGold > 0 && House != null && House.IsAosRules )
|
||||
{
|
||||
if ( House.MovingCrate == null )
|
||||
House.MovingCrate = new MovingCrate( House );
|
||||
|
||||
Innkeeper.Deposit( House.MovingCrate, RentalGold );
|
||||
RentalGold = 0;
|
||||
}
|
||||
|
||||
base.Destroy( toBackpack );
|
||||
}
|
||||
|
||||
public override void GetContextMenuEntries( Mobile from, List<ContextMenuEntry> list )
|
||||
{
|
||||
if ( from.Alive )
|
||||
{
|
||||
if ( IsOwner( from ) )
|
||||
{
|
||||
list.Add( new ContractOptionsEntry( this ) );
|
||||
}
|
||||
else if ( IsLandlord( from ) )
|
||||
{
|
||||
if ( RentalGold > 0 )
|
||||
list.Add( new CollectRentEntry( this ) );
|
||||
|
||||
list.Add( new TerminateContractEntry( this ) );
|
||||
list.Add( new ContractOptionsEntry( this ) );
|
||||
}
|
||||
}
|
||||
|
||||
base.GetContextMenuEntries( from, list );
|
||||
}
|
||||
|
||||
private class ContractOptionsEntry : ContextMenuEntry
|
||||
{
|
||||
private RentedVendor m_Vendor;
|
||||
|
||||
public ContractOptionsEntry( RentedVendor vendor ) : base( 6209 )
|
||||
{
|
||||
m_Vendor = vendor;
|
||||
}
|
||||
|
||||
public override void OnClick()
|
||||
{
|
||||
Mobile from = Owner.From;
|
||||
|
||||
if ( m_Vendor.Deleted || !from.CheckAlive() )
|
||||
return;
|
||||
|
||||
if ( m_Vendor.IsOwner( from ) )
|
||||
{
|
||||
from.CloseGump( typeof( RenterVendorRentalGump ) );
|
||||
from.SendGump( new RenterVendorRentalGump( m_Vendor ) );
|
||||
|
||||
m_Vendor.SendRentalExpireMessage( from );
|
||||
}
|
||||
else if ( m_Vendor.IsLandlord( from ) )
|
||||
{
|
||||
from.CloseGump( typeof( LandlordVendorRentalGump ) );
|
||||
from.SendGump( new LandlordVendorRentalGump( m_Vendor ) );
|
||||
|
||||
m_Vendor.SendRentalExpireMessage( from );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class CollectRentEntry : ContextMenuEntry
|
||||
{
|
||||
private RentedVendor m_Vendor;
|
||||
|
||||
public CollectRentEntry( RentedVendor vendor ) : base( 6212 )
|
||||
{
|
||||
m_Vendor = vendor;
|
||||
}
|
||||
|
||||
public override void OnClick()
|
||||
{
|
||||
Mobile from = Owner.From;
|
||||
|
||||
if ( m_Vendor.Deleted || !from.CheckAlive() || !m_Vendor.IsLandlord( from ) )
|
||||
return;
|
||||
|
||||
if ( m_Vendor.RentalGold > 0 )
|
||||
{
|
||||
int depositedGold = Innkeeper.DepositUpTo( from, m_Vendor.RentalGold );
|
||||
m_Vendor.RentalGold -= depositedGold;
|
||||
|
||||
if ( depositedGold > 0 )
|
||||
from.SendLocalizedMessage( 1060397, depositedGold.ToString() ); // ~1_AMOUNT~ gold has been deposited into your inn chest.
|
||||
|
||||
if ( m_Vendor.RentalGold > 0 )
|
||||
from.SendLocalizedMessage( 500390 ); // Your inn chest is full.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class TerminateContractEntry : ContextMenuEntry
|
||||
{
|
||||
private RentedVendor m_Vendor;
|
||||
|
||||
public TerminateContractEntry( RentedVendor vendor ) : base( 6218 )
|
||||
{
|
||||
m_Vendor = vendor;
|
||||
}
|
||||
|
||||
public override void OnClick()
|
||||
{
|
||||
Mobile from = Owner.From;
|
||||
|
||||
if ( m_Vendor.Deleted || !from.CheckAlive() || !m_Vendor.IsLandlord( from ) )
|
||||
return;
|
||||
|
||||
from.SendLocalizedMessage( 1062503 ); // Enter the amount of gold you wish to offer the renter in exchange for immediate termination of this contract?
|
||||
from.Prompt = new RefundOfferPrompt( m_Vendor );
|
||||
}
|
||||
}
|
||||
|
||||
private class RefundOfferPrompt : Prompt
|
||||
{
|
||||
private RentedVendor m_Vendor;
|
||||
|
||||
public RefundOfferPrompt( RentedVendor vendor )
|
||||
{
|
||||
m_Vendor = vendor;
|
||||
}
|
||||
|
||||
public override void OnResponse( Mobile from, string text )
|
||||
{
|
||||
if ( !m_Vendor.CanInteractWith( from, false ) || !m_Vendor.IsLandlord( from ) )
|
||||
return;
|
||||
|
||||
text = text.Trim();
|
||||
|
||||
int amount;
|
||||
|
||||
if ( !int.TryParse( text, out amount ) )
|
||||
amount = -1;
|
||||
|
||||
Mobile owner = m_Vendor.Owner;
|
||||
if ( owner == null )
|
||||
return;
|
||||
|
||||
if ( amount < 0 )
|
||||
{
|
||||
from.SendLocalizedMessage( 1062506 ); // You did not enter a valid amount. Offer canceled.
|
||||
}
|
||||
else if ( Innkeeper.GetBalance( from ) < amount )
|
||||
{
|
||||
from.SendLocalizedMessage( 1062507 ); // You do not have that much money in your inn chest.
|
||||
}
|
||||
else if ( owner.Map != m_Vendor.Map || !owner.InRange( m_Vendor, 5 ) )
|
||||
{
|
||||
from.SendLocalizedMessage( 1062505 ); // The renter must be closer to the vendor in order for you to make this offer.
|
||||
}
|
||||
else
|
||||
{
|
||||
from.SendLocalizedMessage( 1062504 ); // Please wait while the renter considers your offer.
|
||||
|
||||
owner.CloseGump( typeof( VendorRentalRefundGump ) );
|
||||
owner.SendGump( new VendorRentalRefundGump( m_Vendor, from, amount ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void Serialize( GenericWriter writer )
|
||||
{
|
||||
base.Serialize( writer );
|
||||
|
||||
writer.WriteEncodedInt( 0 ); // version
|
||||
|
||||
writer.WriteEncodedInt( m_RentalDuration.ID );
|
||||
|
||||
writer.Write( (int) m_RentalPrice );
|
||||
writer.Write( (bool) m_LandlordRenew );
|
||||
writer.Write( (bool) m_RenterRenew );
|
||||
writer.Write( (int) m_RenewalPrice );
|
||||
|
||||
writer.Write( (int) m_RentalGold );
|
||||
|
||||
writer.WriteDeltaTime( (DateTime) m_RentalExpireTime );
|
||||
}
|
||||
|
||||
public override void Deserialize( GenericReader reader )
|
||||
{
|
||||
base.Deserialize( reader );
|
||||
|
||||
int version = reader.ReadEncodedInt();
|
||||
|
||||
int durationID = reader.ReadEncodedInt();
|
||||
if ( durationID < VendorRentalDuration.Instances.Length )
|
||||
m_RentalDuration = VendorRentalDuration.Instances[durationID];
|
||||
else
|
||||
m_RentalDuration = VendorRentalDuration.Instances[0];
|
||||
|
||||
m_RentalPrice = reader.ReadInt();
|
||||
m_LandlordRenew = reader.ReadBool();
|
||||
m_RenterRenew = reader.ReadBool();
|
||||
m_RenewalPrice = reader.ReadInt();
|
||||
|
||||
m_RentalGold = reader.ReadInt();
|
||||
|
||||
m_RentalExpireTime = reader.ReadDeltaTime();
|
||||
|
||||
TimeSpan delay = m_RentalExpireTime - DateTime.Now;
|
||||
m_RentalExpireTimer = new RentalExpireTimer( this, delay > TimeSpan.Zero ? delay : TimeSpan.Zero );
|
||||
m_RentalExpireTimer.Start();
|
||||
}
|
||||
|
||||
private class RentalExpireTimer : Timer
|
||||
{
|
||||
private RentedVendor m_Vendor;
|
||||
|
||||
public RentalExpireTimer( RentedVendor vendor, TimeSpan delay ) : base( delay, vendor.RentalDuration.Duration )
|
||||
{
|
||||
m_Vendor = vendor;
|
||||
|
||||
Priority = TimerPriority.OneMinute;
|
||||
}
|
||||
|
||||
protected override void OnTick()
|
||||
{
|
||||
int renewalPrice = m_Vendor.RenewalPrice;
|
||||
|
||||
if ( m_Vendor.Renew && m_Vendor.HoldGold >= renewalPrice )
|
||||
{
|
||||
m_Vendor.HoldGold -= renewalPrice;
|
||||
m_Vendor.RentalGold += renewalPrice;
|
||||
|
||||
m_Vendor.RentalPrice = renewalPrice;
|
||||
|
||||
m_Vendor.m_RentalExpireTime = DateTime.Now + m_Vendor.RentalDuration.Duration;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Vendor.Destroy( false );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
179
Scripts/Mobiles/Base/VendorInventory.cs
Normal file
179
Scripts/Mobiles/Base/VendorInventory.cs
Normal file
|
|
@ -0,0 +1,179 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Server;
|
||||
using Server.Multis;
|
||||
|
||||
namespace Server.Mobiles
|
||||
{
|
||||
public class VendorInventory
|
||||
{
|
||||
public static readonly TimeSpan GracePeriod = TimeSpan.FromDays( 7.0 );
|
||||
|
||||
private BaseHouse m_House;
|
||||
private string m_VendorName;
|
||||
private string m_ShopName;
|
||||
private Mobile m_Owner;
|
||||
|
||||
private List<Item> m_Items;
|
||||
private int m_Gold;
|
||||
|
||||
private DateTime m_ExpireTime;
|
||||
private Timer m_ExpireTimer;
|
||||
|
||||
public VendorInventory( BaseHouse house, Mobile owner, string vendorName, string shopName )
|
||||
{
|
||||
m_House = house;
|
||||
m_Owner = owner;
|
||||
m_VendorName = vendorName;
|
||||
m_ShopName = shopName;
|
||||
|
||||
m_Items = new List<Item>();
|
||||
|
||||
m_ExpireTime = DateTime.Now + GracePeriod;
|
||||
m_ExpireTimer = new ExpireTimer( this, GracePeriod );
|
||||
m_ExpireTimer.Start();
|
||||
}
|
||||
|
||||
public BaseHouse House
|
||||
{
|
||||
get{ return m_House; }
|
||||
set{ m_House = value; }
|
||||
}
|
||||
|
||||
public string VendorName
|
||||
{
|
||||
get{ return m_VendorName; }
|
||||
set{ m_VendorName = value; }
|
||||
}
|
||||
|
||||
public string ShopName
|
||||
{
|
||||
get{ return m_ShopName; }
|
||||
set{ m_ShopName = value; }
|
||||
}
|
||||
|
||||
public Mobile Owner
|
||||
{
|
||||
get{ return m_Owner; }
|
||||
set{ m_Owner = value; }
|
||||
}
|
||||
|
||||
public List<Item> Items
|
||||
{
|
||||
get{ return m_Items; }
|
||||
}
|
||||
|
||||
public int Gold
|
||||
{
|
||||
get{ return m_Gold; }
|
||||
set{ m_Gold = value; }
|
||||
}
|
||||
|
||||
public DateTime ExpireTime
|
||||
{
|
||||
get{ return m_ExpireTime; }
|
||||
}
|
||||
|
||||
public void AddItem( Item item )
|
||||
{
|
||||
item.Internalize();
|
||||
m_Items.Add( item );
|
||||
}
|
||||
|
||||
public void Delete()
|
||||
{
|
||||
foreach ( Item item in Items )
|
||||
{
|
||||
item.Delete();
|
||||
}
|
||||
|
||||
Items.Clear();
|
||||
Gold = 0;
|
||||
|
||||
if ( House != null )
|
||||
House.VendorInventories.Remove( this );
|
||||
|
||||
m_ExpireTimer.Stop();
|
||||
}
|
||||
|
||||
public void Serialize( GenericWriter writer )
|
||||
{
|
||||
writer.WriteEncodedInt( 0 ); // version
|
||||
|
||||
writer.Write( (Mobile) m_Owner );
|
||||
writer.Write( (string) m_VendorName );
|
||||
writer.Write( (string) m_ShopName );
|
||||
|
||||
writer.Write( m_Items, true );
|
||||
writer.Write( (int) m_Gold );
|
||||
|
||||
writer.WriteDeltaTime( m_ExpireTime );
|
||||
}
|
||||
|
||||
public VendorInventory( BaseHouse house, GenericReader reader )
|
||||
{
|
||||
m_House = house;
|
||||
|
||||
int version = reader.ReadEncodedInt();
|
||||
|
||||
m_Owner = reader.ReadMobile();
|
||||
m_VendorName = reader.ReadString();
|
||||
m_ShopName = reader.ReadString();
|
||||
|
||||
m_Items = reader.ReadStrongItemList();
|
||||
m_Gold = reader.ReadInt();
|
||||
|
||||
m_ExpireTime = reader.ReadDeltaTime();
|
||||
|
||||
if ( m_Items.Count == 0 && m_Gold == 0 )
|
||||
{
|
||||
Timer.DelayCall( TimeSpan.Zero, new TimerCallback( Delete ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
TimeSpan delay = m_ExpireTime - DateTime.Now;
|
||||
m_ExpireTimer = new ExpireTimer( this, delay > TimeSpan.Zero ? delay : TimeSpan.Zero );
|
||||
m_ExpireTimer.Start();
|
||||
}
|
||||
}
|
||||
|
||||
private class ExpireTimer : Timer
|
||||
{
|
||||
private VendorInventory m_Inventory;
|
||||
|
||||
public ExpireTimer( VendorInventory inventory, TimeSpan delay ) : base( delay )
|
||||
{
|
||||
m_Inventory = inventory;
|
||||
|
||||
Priority = TimerPriority.OneMinute;
|
||||
}
|
||||
|
||||
protected override void OnTick()
|
||||
{
|
||||
BaseHouse house = m_Inventory.House;
|
||||
|
||||
if ( house != null )
|
||||
{
|
||||
if ( m_Inventory.Gold > 0 )
|
||||
{
|
||||
if ( house.MovingCrate == null )
|
||||
house.MovingCrate = new MovingCrate( house );
|
||||
|
||||
Innkeeper.Deposit( house.MovingCrate, m_Inventory.Gold );
|
||||
}
|
||||
|
||||
foreach ( Item item in m_Inventory.Items )
|
||||
{
|
||||
if ( !item.Deleted )
|
||||
house.DropToMovingCrate( item );
|
||||
}
|
||||
|
||||
m_Inventory.Gold = 0;
|
||||
m_Inventory.Items.Clear();
|
||||
}
|
||||
|
||||
m_Inventory.Delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue