Ok on osi if pet is tamed or bonded it shows total weight which i got that part fixed. But on osi even if pet is not been tamed yet and you see him wild it
should also show weight. So i'm missing the weight part as when those
packed pets are wild.
[CODE]using System;
using System.Collections;
using System.Collections.Generic;
using Server;
using Server.Regions;
using Server.Targeting;
using Server.Network;
using Server.Spells;
using Server.Misc;
using Server.Items;
using Server.Mobiles;
using Server.ContextMenus;
using Server.Engines.Quests;
using Server.Factions;
using Server.Spells.Bushido;
using Server.Spells.Spellweaving;
namespace Server.Mobiles
{
#region Enums
/// <summary>
/// Summary description for MobileAI.
/// </summary>
///
public enum FightMode
{
None, // Never focus on others
Aggressor, // Only attack aggressors
Strongest, // Attack the strongest
Weakest, // Attack the weakest
Closest, // Attack the closest
Evil // Only attack aggressor -or- negative karma
}
public enum OrderType
{
None, //When no order, let's roam
Come, //"(All/Name) come" Summons all or one pet to your location.
Drop, //"(Name) drop" Drops its loot to the ground (if it carries any).
Follow, //"(Name) follow" Follows targeted being.
//"(All/Name) follow me" Makes all or one pet follow you.
Friend, //"(Name) friend" Allows targeted player to confirm resurrection.
Unfriend, // Remove a friend
Guard, //"(Name) guard" Makes the specified pet guard you. Pets can only guard their owner.
//"(All/Name) guard me" Makes all or one pet guard you.
Attack, //"(All/Name) kill",
//"(All/Name) attack" All or the specified pet(s) currently under your control attack the target.
Patrol, //"(Name) patrol" Roves between two or more guarded targets.
Release, //"(Name) release" Releases pet back into the wild (removes "tame" status).
Stay, //"(All/Name) stay" All or the specified pet(s) will stop and stay in current spot.
Stop, //"(All/Name) stop Cancels any current orders to attack, guard or follow.
Transfer //"(Name) transfer" Transfers complete ownership to targeted player.
}
[Flags]
public enum FoodType
{
Meat = 0x0001,
FruitsAndVegies = 0x0002,
GrainsAndHay = 0x0004,
Fish = 0x0008,
Eggs = 0x0010,
Gold = 0x0020
}
[Flags]
public enum PackInstinct
{
None = 0x0000,
Canine = 0x0001,
Ostard = 0x0002,
Feline = 0x0004,
Arachnid = 0x0008,
Daemon = 0x0010,
Bear = 0x0020,
Equine = 0x0040,
Bull = 0x0080
}
public enum ScaleType
{
Red,
Yellow,
Black,
Green,
White,
Blue,
All
}
public enum MeatType
{
Ribs,
Bird,
LambLeg
}
public enum HideType
{
Regular,
Spined,
Horned,
Barbed
}
#endregion
public class DamageStore : IComparable
{
public Mobile m_Mobile;
public int m_Damage;
public bool m_HasRight;
public DamageStore( Mobile m, int damage )
{
m_Mobile = m;
m_Damage = damage;
}
public int CompareTo( object obj )
{
DamageStore ds = (DamageStore)obj;
return ds.m_Damage - m_Damage;
}
}
[AttributeUsage( AttributeTargets.Class )]
public class FriendlyNameAttribute : Attribute
{
//future use: Talisman 'Protection/Bonus vs. Specific Creature
private TextDefinition m_FriendlyName;
public TextDefinition FriendlyName
{
get
{
return m_FriendlyName;
}
}
public FriendlyNameAttribute( TextDefinition friendlyName )
{
m_FriendlyName = friendlyName;
}
public static TextDefinition GetFriendlyNameFor( Type t )
{
if( t.IsDefined( typeof( FriendlyNameAttribute ), false ) )
{
object[] objs = t.GetCustomAttributes( typeof( FriendlyNameAttribute ), false );
if( objs != null && objs.Length > 0 )
{
FriendlyNameAttribute friendly = objs[0] as FriendlyNameAttribute;
return friendly.FriendlyName;
}
}
return t.Name;
}
}
public class BaseCreature : Mobile, IHonorTarget
{
public const int MaxLoyalty = 100;
#region Var declarations
private BaseAI m_AI; // THE AI
private AIType m_CurrentAI; // The current AI
private AIType m_DefaultAI; // The default AI
private Mobile m_FocusMob; // Use focus mob instead of combatant, maybe we don't whan to fight
private FightMode m_FightMode; // The style the mob uses
private int m_iRangePerception; // The view area
private int m_iRangeFight; // The fight distance
private bool m_bDebugAI; // Show debug AI messages
private int m_iTeam; // Monster Team
private double m_dActiveSpeed; // Timer speed when active
private double m_dPassiveSpeed; // Timer speed when not active
private double m_dCurrentSpeed; // The current speed, lets say it could be changed by something;
private Point3D m_pHome; // The home position of the creature, used by some AI
private int m_iRangeHome = 10; // The home range of the creature
List<Type> m_arSpellAttack; // List of attack spell/power
List<Type> m_arSpellDefense; // List of defensive spell/power
private bool m_bControlled; // Is controlled
private Mobile m_ControlMaster; // My master
private Mobile m_ControlTarget; // My target mobile
private Point3D m_ControlDest; // My target destination (patrol)
private OrderType m_ControlOrder; // My order
private int m_Loyalty;
private double m_dMinTameSkill;
private bool m_bTamable;
private bool m_bSummoned = false;
private DateTime m_SummonEnd;
private int m_iControlSlots = 1;
private bool m_bBardProvoked = false;
private bool m_bBardPacified = false;
private Mobile m_bBardMaster = null;
private Mobile m_bBardTarget = null;
private DateTime m_timeBardEnd;
private WayPoint m_CurrentWayPoint = null;
private Point2D m_TargetLocation = Point2D.Zero;
private Mobile m_SummonMaster;
private int m_HitsMax = -1;
private int m_StamMax = -1;
private int m_ManaMax = -1;
private int m_DamageMin = -1;
private int m_DamageMax = -1;
private int m_PhysicalResistance, m_PhysicalDamage = 100;
private int m_FireResistance, m_FireDamage;
private int m_ColdResistance, m_ColdDamage;
private int m_PoisonResistance, m_PoisonDamage;
private int m_EnergyResistance, m_EnergyDamage;
private List<Mobile> m_Owners;
private List<Mobile> m_Friends;
private bool m_IsStabled;
private bool m_HasGeneratedLoot; // have we generated our loot yet?
private bool m_Paragon;
#endregion
public virtual InhumanSpeech SpeechType{ get{ return null; } }
public bool IsStabled
{
get{ return m_IsStabled; }
set{ m_IsStabled = value; }
}
protected DateTime SummonEnd
{
get { return m_SummonEnd; }
set { m_SummonEnd = value; }
}
public virtual Faction FactionAllegiance{ get{ return null; } }
public virtual int FactionSilverWorth{ get{ return 30; } }
#region Bonding
public const bool BondingEnabled = true;
public virtual bool IsBondable{ get{ return ( BondingEnabled && !Summoned ); } }
public virtual TimeSpan BondingDelay{ get{ return TimeSpan.FromDays( 7.0 ); } }
public virtual TimeSpan BondingAbandonDelay{ get{ return TimeSpan.FromDays( 1.0 ); } }
public override bool CanRegenHits{ get{ return !m_IsDeadPet && base.CanRegenHits; } }
public override bool CanRegenStam{ get{ return !m_IsDeadPet && base.CanRegenStam; } }
public override bool CanRegenMana{ get{ return !m_IsDeadPet && base.CanRegenMana; } }
public override bool IsDeadBondedPet{ get{ return m_IsDeadPet; } }
private bool m_IsBonded;
private bool m_IsDeadPet;
private DateTime m_BondingBegin;
private DateTime m_OwnerAbandonTime;
[CommandProperty( AccessLevel.GameMaster )]
public Mobile LastOwner
{
get
{
if ( m_Owners == null || m_Owners.Count == 0 )
return null;
return m_Owners[m_Owners.Count - 1];
}
}
[CommandProperty( AccessLevel.GameMaster )]
public bool IsBonded
{
get{ return m_IsBonded; }
set{ m_IsBonded = value; InvalidateProperties(); }
}
public bool IsDeadPet
{
get{ return m_IsDeadPet; }
set{ m_IsDeadPet = value; }
}
[CommandProperty( AccessLevel.GameMaster )]
public DateTime BondingBegin
{
get{ return m_BondingBegin; }
set{ m_BondingBegin = value; }
}
[CommandProperty( AccessLevel.GameMaster )]
public DateTime OwnerAbandonTime
{
get{ return m_OwnerAbandonTime; }
set{ m_OwnerAbandonTime = value; }
}
#endregion
public virtual double WeaponAbilityChance{ get{ return 0.4; } }
public virtual WeaponAbility GetWeaponAbility()
{
return null;
}
#region Elemental Resistance/Damage
public override int BasePhysicalResistance{ get{ return m_PhysicalResistance; } }
public override int BaseFireResistance{ get{ return m_FireResistance; } }
public override int BaseColdResistance{ get{ return m_ColdResistance; } }
public override int BasePoisonResistance{ get{ return m_PoisonResistance; } }
public override int BaseEnergyResistance{ get{ return m_EnergyResistance; } }
[CommandProperty( AccessLevel.GameMaster )]
public int PhysicalResistanceSeed{ get{ return m_PhysicalResistance; } set{ m_PhysicalResistance = value; UpdateResistances(); } }
[CommandProperty( AccessLevel.GameMaster )]
public int FireResistSeed{ get{ return m_FireResistance; } set{ m_FireResistance = value; UpdateResistances(); } }
[CommandProperty( AccessLevel.GameMaster )]
public int ColdResistSeed{ get{ return m_ColdResistance; } set{ m_ColdResistance = value; UpdateResistances(); } }
[CommandProperty( AccessLevel.GameMaster )]
public int PoisonResistSeed{ get{ return m_PoisonResistance; } set{ m_PoisonResistance = value; UpdateResistances(); } }
[CommandProperty( AccessLevel.GameMaster )]
public int EnergyResistSeed{ get{ return m_EnergyResistance; } set{ m_EnergyResistance = value; UpdateResistances(); } }
[CommandProperty( AccessLevel.GameMaster )]
public int PhysicalDamage{ get{ return m_PhysicalDamage; } set{ m_PhysicalDamage = value; } }
[CommandProperty( AccessLevel.GameMaster )]
public int FireDamage{ get{ return m_FireDamage; } set{ m_FireDamage = value; } }
[CommandProperty( AccessLevel.GameMaster )]
public int ColdDamage{ get{ return m_ColdDamage; } set{ m_ColdDamage = value; } }
[CommandProperty( AccessLevel.GameMaster )]
public int PoisonDamage{ get{ return m_PoisonDamage; } set{ m_PoisonDamage = value; } }
[CommandProperty( AccessLevel.GameMaster )]
public int EnergyDamage{ get{ return m_EnergyDamage; } set{ m_EnergyDamage = value; } }
#endregion
[CommandProperty( AccessLevel.GameMaster )]
public bool IsParagon
{
get{ return m_Paragon; }
set
{
if ( m_Paragon == value )
return;
else if ( value )
Paragon.Convert( this );
else
Paragon.UnConvert( this );
m_Paragon = value;
InvalidateProperties();
}
}
public virtual FoodType FavoriteFood{ get{ return FoodType.Meat; } }
public virtual PackInstinct PackInstinct{ get{ return PackInstinct.None; } }
public List<Mobile> Owners { get { return m_Owners; } }
public virtual bool AllowMaleTamer{ get{ return true; } }
public virtual bool AllowFemaleTamer{ get{ return true; } }
public virtual bool SubdueBeforeTame{ get{ return false; } }
public virtual bool StatLossAfterTame{ get{ return SubdueBeforeTame; } }
public virtual bool Commandable{ get{ return true; } }
public virtual Poison HitPoison{ get{ return null; } }
public virtual double HitPoisonChance{ get{ return 0.5; } }
public virtual Poison PoisonImmune{ get{ return null; } }
public virtual bool BardImmune{ get{ return false; } }
public virtual bool Unprovokable{ get{ return BardImmune || m_IsDeadPet; } }
public virtual bool Uncalmable{ get{ return BardImmune || m_IsDeadPet; } }
public virtual bool BleedImmune{ get{ return false; } }
public virtual double BonusPetDamageScalar{ get{ return 1.0; } }
public virtual bool DeathAdderCharmable{ get{ return false; } }
//TODO: Find the pub 31 tweaks to the DispelDifficulty and apply them of course.
public virtual double DispelDifficulty{ get{ return 0.0; } } // at this skill level we dispel 50% chance
public virtual double DispelFocus{ get{ return 20.0; } } // at difficulty - focus we have 0%, at difficulty + focus we have 100%
#region Breath ability, like dragon fire breath
private DateTime m_NextBreathTime;
// Must be overriden in subclass to enable
public virtual bool HasBreath{ get{ return false; } }
// Base damage given is: CurrentHitPoints * BreathDamageScalar
public virtual double BreathDamageScalar{ get{ return (Core.AOS ? 0.16 : 0.05); } }
// Min/max seconds until next breath
public virtual double BreathMinDelay{ get{ return 10.0; } }
public virtual double BreathMaxDelay{ get{ return 15.0; } }
// Creature stops moving for 1.0 seconds while breathing
public virtual double BreathStallTime{ get{ return 1.0; } }
// Effect is sent 1.3 seconds after BreathAngerSound and BreathAngerAnimation is played
public virtual double BreathEffectDelay{ get{ return 1.3; } }
// Damage is given 1.0 seconds after effect is sent
public virtual double BreathDamageDelay{ get{ return 1.0; } }
public virtual int BreathRange{ get{ return RangePerception; } }
// Damage types
public virtual int BreathPhysicalDamage{ get{ return 0; } }
public virtual int BreathFireDamage{ get{ return 100; } }
public virtual int BreathColdDamage{ get{ return 0; } }
public virtual int BreathPoisonDamage{ get{ return 0; } }
public virtual int BreathEnergyDamage{ get{ return 0; } }
// Effect details and sound
public virtual int BreathEffectItemID{ get{ return 0x36D4; } }
public virtual int BreathEffectSpeed{ get{ return 5; } }
public virtual int BreathEffectDuration{ get{ return 0; } }
public virtual bool BreathEffectExplodes{ get{ return false; } }
public virtual bool BreathEffectFixedDir{ get{ return false; } }
public virtual int BreathEffectHue{ get{ return 0; } }
public virtual int BreathEffectRenderMode{ get{ return 0; } }
public virtual int BreathEffectSound{ get{ return 0x227; } }
// Anger sound/animations
public virtual int BreathAngerSound{ get{ return GetAngerSound(); } }
public virtual int BreathAngerAnimation{ get{ return 12; } }
public virtual void BreathStart( Mobile target )
{
BreathStallMovement();
BreathPlayAngerSound();
BreathPlayAngerAnimation();
this.Direction = this.GetDirectionTo( target );
Timer.DelayCall( TimeSpan.FromSeconds( BreathEffectDelay ), new TimerStateCallback( BreathEffect_Callback ), target );
}
public virtual void BreathStallMovement()
{
if ( m_AI != null )
m_AI.NextMove = DateTime.Now + TimeSpan.FromSeconds( BreathStallTime );
}
public virtual void BreathPlayAngerSound()
{
PlaySound( BreathAngerSound );
}
public virtual void BreathPlayAngerAnimation()
{
Animate( BreathAngerAnimation, 5, 1, true, false, 0 );
}
public virtual void BreathEffect_Callback( object state )
{
Mobile target = (Mobile)state;
if ( !target.Alive || !CanBeHarmful( target ) )
return;
BreathPlayEffectSound();
BreathPlayEffect( target );
Timer.DelayCall( TimeSpan.FromSeconds( BreathDamageDelay ), new TimerStateCallback( BreathDamage_Callback ), target );
}
public virtual void BreathPlayEffectSound()
{
PlaySound( BreathEffectSound );
}
public virtual void BreathPlayEffect( Mobile target )
{
Effects.SendMovingEffect( this, target, BreathEffectItemID,
BreathEffectSpeed, BreathEffectDuration, BreathEffectFixedDir,
BreathEffectExplodes, BreathEffectHue, BreathEffectRenderMode );
}
public virtual void BreathDamage_Callback( object state )
{
Mobile target = (Mobile)state;
if ( CanBeHarmful( target ) )
{
DoHarmful( target );
BreathDealDamage( target );
}
}
public virtual void BreathDealDamage( Mobile target )
{
int physDamage = BreathPhysicalDamage;
int fireDamage = BreathFireDamage;
int coldDamage = BreathColdDamage;
int poisDamage = BreathPoisonDamage;
int nrgyDamage = BreathEnergyDamage;
if ( physDamage == 0 && fireDamage == 0 && coldDamage == 0 && poisDamage == 0 && nrgyDamage == 0 )
{ // Unresistable damage even in AOS
target.Damage( BreathComputeDamage(), this );
}
else
{
AOS.Damage( target, this, BreathComputeDamage(), physDamage, fireDamage, coldDamage, poisDamage, nrgyDamage );
}
}
public virtual int BreathComputeDamage()
{
int damage = (int)(Hits * BreathDamageScalar);
if ( IsParagon )
damage = (int)(damage / Paragon.HitsBuff);
return damage;
}
#endregion
#region Spill Acid
public void SpillAcid( TimeSpan duration, int minDamage, int maxDamage )
{
SpillAcid( duration, minDamage, maxDamage, null, 1, 1 );
}
public void SpillAcid( TimeSpan duration, int minDamage, int maxDamage, Mobile target )
{
SpillAcid( duration, minDamage, maxDamage, target, 1, 1 );
}
public void SpillAcid( TimeSpan duration, int minDamage, int maxDamage, int count )
{
SpillAcid( duration, minDamage, maxDamage, null, count, count );
}
public void SpillAcid( TimeSpan duration, int minDamage, int maxDamage, int minAmount, int maxAmount )
{
SpillAcid( duration, minDamage, maxDamage, null, minAmount, maxAmount );
}
public void SpillAcid( TimeSpan duration, int minDamage, int maxDamage, Mobile target, int count )
{
SpillAcid( duration, minDamage, maxDamage, target, count, count );
}
public void SpillAcid( TimeSpan duration, int minDamage, int maxDamage, Mobile target, int minAmount, int maxAmount )
{
if ( (target != null && target.Map == null) || this.Map == null )
return;
int pools = Utility.RandomMinMax( minAmount, maxAmount );
for ( int i = 0; i < pools; ++i )
{
PoolOfAcid acid = new PoolOfAcid( duration, minDamage, maxDamage );
if ( target != null && target.Map != null )
{
acid.MoveToWorld( target.Location, target.Map );
continue;
}
bool validLocation = false;
Point3D loc = this.Location;
Map map = this.Map;
for ( int j = 0; !validLocation && j < 10; ++j )
{
int x = X + Utility.Random( 3 ) - 1;
int y = Y + Utility.Random( 3 ) - 1;
int z = map.GetAverageZ( x, y );
if ( validLocation = map.CanFit( x, y, this.Z, 16, false, false ) )
loc = new Point3D( x, y, Z );
else if ( validLocation = map.CanFit( x, y, z, 16, false, false ) )
loc = new Point3D( x, y, z );
}
acid.MoveToWorld( loc, map );
}
}
#endregion
#region Flee!!!
private DateTime m_EndFlee;
public DateTime EndFleeTime
{
get{ return m_EndFlee; }
set{ m_EndFlee = value; }
}
public virtual void StopFlee()
{
m_EndFlee = DateTime.MinValue;
}
public virtual bool CheckFlee()
{
if ( m_EndFlee == DateTime.MinValue )
return false;
if ( DateTime.Now >= m_EndFlee )
{
StopFlee();
return false;
}
return true;
}
public virtual void BeginFlee( TimeSpan maxDuration )
{
m_EndFlee = DateTime.Now + maxDuration;
}
#endregion
public BaseAI AIObject{ get{ return m_AI; } }
public const int MaxOwners = 5;
public virtual OppositionGroup OppositionGroup
{
get{ return null; }
}
#region Friends
public List<Mobile> Friends { get { return m_Friends; } }
public virtual bool AllowNewPetFriend
{
get{ return ( m_Friends == null || m_Friends.Count < 5 ); }
}
public virtual bool IsPetFriend( Mobile m )
{
return ( m_Friends != null && m_Friends.Contains( m ) );
}
public virtual void AddPetFriend( Mobile m )
{
if ( m_Friends == null )
m_Friends = new List<Mobile>();
m_Friends.Add( m );
}
public virtual void RemovePetFriend( Mobile m )
{
if ( m_Friends != null )
m_Friends.Remove( m );
}
public virtual bool IsFriend( Mobile m )
{
OppositionGroup g = this.OppositionGroup;
if ( g != null && g.IsEnemy( this, m ) )
return false;
if ( !(m is BaseCreature) )
return false;
BaseCreature c = (BaseCreature)m;
return ( m_iTeam == c.m_iTeam && ( (m_bSummoned || m_bControlled) == (c.m_bSummoned || c.m_bControlled) )/* && c.Combatant != this */);
}
#endregion
#region Allegiance
public virtual Ethics.Ethic EthicAllegiance { get { return null; } }
public enum Allegiance
{
None,
Ally,
Enemy
}
public virtual Allegiance GetFactionAllegiance( Mobile mob )
{
if ( mob == null || mob.Map != Faction.Facet || FactionAllegiance == null )
return Allegiance.None;
Faction fac = Faction.Find( mob, true );
if ( fac == null )
return Allegiance.None;
return ( fac == FactionAllegiance ? Allegiance.Ally : Allegiance.Enemy );
}
public virtual Allegiance GetEthicAllegiance( Mobile mob )
{
if ( mob == null || mob.Map != Faction.Facet || EthicAllegiance == null )
return Allegiance.None;
Ethics.Ethic ethic = Ethics.Ethic.Find( mob, true );
if ( ethic == null )
return Allegiance.None;
return ( ethic == EthicAllegiance ? Allegiance.Ally : Allegiance.Enemy );
}
#endregion
public virtual bool IsEnemy( Mobile m )
{
OppositionGroup g = this.OppositionGroup;
if ( g != null && g.IsEnemy( this, m ) )
return true;
if ( m is BaseGuard )
return false;
if ( GetFactionAllegiance( m ) == Allegiance.Ally )
return false;
Ethics.Ethic ourEthic = EthicAllegiance;
Ethics.Player pl = Ethics.Player.Find( m, true );
if ( pl != null && pl.IsShielded && ( ourEthic == null || ourEthic == pl.Ethic ) )
return false;
if ( !(m is BaseCreature) || m is Server.Engines.Quests.Haven.MilitiaFighter )
return true;
if( TransformationSpellHelper.UnderTransformation( m, typeof( EtherealVoyageSpell ) ) )
return false;
BaseCreature c = (BaseCreature)m;
return ( m_iTeam != c.m_iTeam || ( (m_bSummoned || m_bControlled) != (c.m_bSummoned || c.m_bControlled) )/* || c.Combatant == this*/ );
}
public override string ApplyNameSuffix( string suffix )
{
if ( IsParagon )
{
if ( suffix.Length == 0 )
suffix = "(Paragon)";
else
suffix = String.Concat( suffix, " (Paragon)" );
}
return base.ApplyNameSuffix( suffix );
}
public virtual bool CheckControlChance( Mobile m )
{
if ( GetControlChance( m ) > Utility.RandomDouble() )
{
Loyalty += 1;
return true;
}
PlaySound( GetAngerSound() );
if ( Body.IsAnimal )
Animate( 10, 5, 1, true, false, 0 );
else if ( Body.IsMonster )
Animate( 18, 5, 1, true, false, 0 );
Loyalty -= 3;
return false;
}
public virtual bool CanBeControlledBy( Mobile m )
{
return ( GetControlChance( m ) > 0.0 );
}
public double GetControlChance( Mobile m )
{
return GetControlChance( m, false );
}
public virtual double GetControlChance( Mobile m, bool useBaseSkill )
{
if ( m_dMinTameSkill <= 29.1 || m_bSummoned || m.AccessLevel >= AccessLevel.GameMaster )
return 1.0;
double dMinTameSkill = m_dMinTameSkill;
if ( dMinTameSkill > -24.9 && Server.SkillHandlers.AnimalTaming.CheckMastery( m, this ) )
dMinTameSkill = -24.9;
int taming = (int)((useBaseSkill ? m.Skills[SkillName.AnimalTaming].Base : m.Skills[SkillName.AnimalTaming].Value ) * 10);
int lore = (int)((useBaseSkill ? m.Skills[SkillName.AnimalLore].Base : m.Skills[SkillName.AnimalLore].Value )* 10);
int difficulty = (int)(dMinTameSkill * 10);
int weighted = ((taming * 4) + lore) / 5;
int bonus = weighted - difficulty;
int chance;
if ( bonus <= 0 )
chance = 700 + (bonus * 14);
else
chance = 700 + (bonus * 6);
if ( chance >= 0 && chance < 200 )
chance = 200;
else if ( chance > 990 )
chance = 990;
chance -= (MaxLoyalty - m_Loyalty) * 10;
return ( (double)chance / 1000 );
}
private static Type[] m_AnimateDeadTypes = new Type[]
{
typeof( MoundOfMaggots ), typeof( HellSteed ), typeof( SkeletalMount ),
typeof( WailingBanshee ), typeof( Wraith ), typeof( SkeletalDragon ),
typeof( LichLord ), typeof( FleshGolem ), typeof( Lich ),
typeof( SkeletalKnight ), typeof( BoneKnight ), typeof( Mummy ),
typeof( SkeletalMage ), typeof( BoneMagi ), typeof( PatchworkSkeleton )
};
public virtual bool IsAnimatedDead
{
get
{
if ( !Summoned )
return false;
Type type = this.GetType();
bool contains = false;
for ( int i = 0; !contains && i < m_AnimateDeadTypes.Length; ++i )
contains = ( type == m_AnimateDeadTypes[i] );
return contains;
}
}
public override void Damage( int amount, Mobile from )
{
int oldHits = this.Hits;
if ( Core.AOS && !this.Summoned && this.Controlled && 0.2 > Utility.RandomDouble() )
amount = (int)(amount * BonusPetDamageScalar);
if ( Spells.Necromancy.EvilOmenSpell.CheckEffect( this ) )
amount = (int)(amount * 1.25);
Mobile oath = Spells.Necromancy.BloodOathSpell.GetBloodOath( from );
if ( oath == this )
{
amount = (int)(amount * 1.1);
from.Damage( amount, from );
}
#region Mondain's Legacy
if ( from != null && from.Talisman is BaseTalisman )
{
BaseTalisman talisman = (BaseTalisman) from.Talisman;
if ( talisman.Slayer != TalismanSlayerName.None && TalismanSlayer.Check( talisman.Slayer, this ) )
amount *= 2;
}
#endregion
base.Damage( amount, from );
if ( SubdueBeforeTame && !Controlled )
{
if ( (oldHits > (this.HitsMax / 10)) && (this.Hits <= (this.HitsMax / 10)) )
PublicOverheadMessage( MessageType.Regular, 0x3B2, false, "* The creature has been beaten into subjugation! *" );
}
}
public virtual bool DeleteCorpseOnDeath
{
get
{
return !Core.AOS && m_bSummoned;
}
}
public override void SetLocation( Point3D newLocation, bool isTeleport )
{
base.SetLocation( newLocation, isTeleport );
if ( isTeleport && m_AI != null )
m_AI.OnTeleported();
}
public override void OnBeforeSpawn( Point3D location, Map m )
{
if ( Paragon.CheckConvert( this, location, m ) )
IsParagon = true;
base.OnBeforeSpawn( location, m );
}
public override ApplyPoisonResult ApplyPoison( Mobile from, Poison poison )
{
if ( !Alive || IsDeadPet )
return ApplyPoisonResult.Immune;
if ( Spells.Necromancy.EvilOmenSpell.CheckEffect( this ) )
poison = PoisonImpl.IncreaseLevel( poison );
ApplyPoisonResult result = base.ApplyPoison( from, poison );
if ( from != null && result == ApplyPoisonResult.Poisoned && PoisonTimer is PoisonImpl.PoisonTimer )
(PoisonTimer as PoisonImpl.PoisonTimer).From = from;
return result;
}
public override bool CheckPoisonImmunity( Mobile from, Poison poison )
{
if ( base.CheckPoisonImmunity( from, poison ) )
return true;
Poison p = this.PoisonImmune;
return ( p != null && p.Level >= poison.Level );
}
[CommandProperty( AccessLevel.GameMaster )]
public int Loyalty
{
get
{
return m_Loyalty;
}
set
{
m_Loyalty = Math.Min( Math.Max( value, 0 ), MaxLoyalty );
}
}
[CommandProperty( AccessLevel.GameMaster )]
public WayPoint CurrentWayPoint
{
get
{
return m_CurrentWayPoint;
}
set
{
m_CurrentWayPoint = value;
}
}
[CommandProperty( AccessLevel.GameMaster )]
public Point2D TargetLocation
{
get
{
return m_TargetLocation;
}
set
{
m_TargetLocation = value;
}
}
public virtual Mobile ConstantFocus{ get{ return null; } }
public virtual bool DisallowAllMoves
{
get
{
return false;
}
}
public virtual bool InitialInnocent
{
get
{
return false;
}
}
public virtual bool AlwaysMurderer
{
get
{
return false;
}
}
public virtual bool AlwaysAttackable
{
get
{
return false;
}
}
[CommandProperty( AccessLevel.GameMaster )]
public virtual int DamageMin{ get{ return m_DamageMin; } set{ m_DamageMin = value; } }
[CommandProperty( AccessLevel.GameMaster )]
public virtual int DamageMax{ get{ return m_DamageMax; } set{ m_DamageMax = value; } }
[CommandProperty( AccessLevel.GameMaster )]
public override int HitsMax
{
get
{
if ( m_HitsMax >= 0 )
return m_HitsMax;
return Str;
}
}
[CommandProperty( AccessLevel.GameMaster )]
public int HitsMaxSeed
{
get{ return m_HitsMax; }
set{ m_HitsMax = value; }
}
[CommandProperty( AccessLevel.GameMaster )]
public override int StamMax
{
get
{
if ( m_StamMax >= 0 )
return m_StamMax;
return Dex;
}
}
[CommandProperty( AccessLevel.GameMaster )]
public int StamMaxSeed
{
get{ return m_StamMax; }
set{ m_StamMax = value; }
}
[CommandProperty( AccessLevel.GameMaster )]
public override int ManaMax
{
get
{
if ( m_ManaMax >= 0 )
return m_ManaMax;
return Int;
}
}
[CommandProperty( AccessLevel.GameMaster )]
public int ManaMaxSeed
{
get{ return m_ManaMax; }
set{ m_ManaMax = value; }
}
public virtual bool CanOpenDoors
{
get
{
return !this.Body.IsAnimal && !this.Body.IsSea;
}
}
public virtual bool CanMoveOverObstacles
{
get
{
return Core.AOS || this.Body.IsMonster;
}
}
public virtual bool CanDestroyObstacles
{
get
{
// to enable breaking of furniture, 'return CanMoveOverObstacles;'
return false;
}
}
public void Unpacify()
{
BardEndTime = DateTime.Now;
BardPacified = false;
}
private HonorContext m_ReceivedHonorContext;
public HonorContext ReceivedHonorContext{ get{ return m_ReceivedHonorContext; } set{ m_ReceivedHonorContext = value; } }
public override void OnDamage( int amount, Mobile from, bool willKill )
{
if ( BardPacified && (HitsMax - Hits) * 0.001 > Utility.RandomDouble() )
Unpacify();
int disruptThreshold;
//NPCs can use bandages too!
if( !Core.AOS )
disruptThreshold = 0;
else if( from != null && from.Player )
disruptThreshold = 18;
else
disruptThreshold = 25;
if( amount > disruptThreshold )
{
BandageContext c = BandageContext.GetContext( this );
if( c != null )
c.Slip();
}
if( Confidence.IsRegenerating( this ) )
Confidence.StopRegenerating( this );
WeightOverloading.FatigueOnDamage( this, amount );
InhumanSpeech speechType = this.SpeechType;
if ( speechType != null && !willKill )
speechType.OnDamage( this, amount );
if ( m_ReceivedHonorContext != null )
m_ReceivedHonorContext.OnTargetDamaged( from, amount );
base.OnDamage( amount, from, willKill );
}
public virtual void OnDamagedBySpell( Mobile from )
{
}
#region Alter[...]Damage From/To
public virtual void AlterDamageScalarFrom( Mobile caster, ref double scalar )
{
}
public virtual void AlterDamageScalarTo( Mobile target, ref double scalar )
{
}
public virtual void AlterSpellDamageFrom( Mobile from, ref int damage )
{
}
public virtual void AlterSpellDamageTo( Mobile to, ref int damage )
{
}
public virtual void AlterMeleeDamageFrom( Mobile from, ref int damage )
{
#region Mondain's Legacy
if ( from != null && from.Talisman is BaseTalisman )
{
BaseTalisman talisman = (BaseTalisman) from.Talisman;
if ( talisman.Killer != null && talisman.Killer.Type != null )
{
Type type = talisman.Killer.Type;
if ( type == GetType() )
damage = (int) ( damage * ( 1 + (double) talisman.Killer.Amount / 100 ) );
}
}
#endregion
}
public virtual void AlterMeleeDamageTo( Mobile to, ref int damage )
{
}
#endregion
public virtual void CheckReflect( Mobile caster, ref bool reflect )
{
}
public virtual void OnCarve( Mobile from, Corpse corpse )
{
int feathers = Feathers;
int wool = Wool;
int meat = Meat;
int hides = Hides;
int scales = Scales;
if ( (feathers == 0 && wool == 0 && meat == 0 && hides == 0 && scales == 0) || Summoned || IsBonded )
{
from.SendLocalizedMessage( 500485 ); // You see nothing useful to carve from the corpse.
}
else
{
if( Core.ML && from.Race == Race.Human )
{
hides = (int)Math.Ceiling( hides * 1.1 ); //10% Bonus Only applies to Hides, Ore & Logs
}
if ( corpse.Map == Map.Felucca )
{
feathers *= 2;
wool *= 2;
hides *= 2;
}
new Blood( 0x122D ).MoveToWorld( corpse.Location, corpse.Map );
if ( feathers != 0 )
{
corpse.DropItem( new Feather( feathers ) );
from.SendLocalizedMessage( 500479 ); // You pluck the bird. The feathers are now on the corpse.
}
if ( wool != 0 )
{
corpse.DropItem( new Wool( wool ) );
from.SendLocalizedMessage( 500483 ); // You shear it, and the wool is now on the corpse.
}
if ( meat != 0 )
{
if ( MeatType == MeatType.Ribs )
corpse.DropItem( new RawRibs( meat ) );
else if ( MeatType == MeatType.Bird )
corpse.DropItem( new RawBird( meat ) );
else if ( MeatType == MeatType.LambLeg )
corpse.DropItem( new RawLambLeg( meat ) );
from.SendLocalizedMessage( 500467 ); // You carve some meat, which remains on the corpse.
}
if ( hides != 0 )
{
if ( HideType == HideType.Regular )
corpse.DropItem( new Hides( hides ) );
else if ( HideType == HideType.Spined )
corpse.DropItem( new SpinedHides( hides ) );
else if ( HideType == HideType.Horned )
corpse.DropItem( new HornedHides( hides ) );
else if ( HideType == HideType.Barbed )
corpse.DropItem( new BarbedHides( hides ) );
from.SendLocalizedMessage( 500471 ); // You skin it, and the hides are now in the corpse.
}
if ( scales != 0 )
{
ScaleType sc = this.ScaleType;
switch ( sc )
{
case ScaleType.Red: corpse.DropItem( new RedScales( scales ) ); break;
case ScaleType.Yellow: corpse.DropItem( new YellowScales( scales ) ); break;
case ScaleType.Black: corpse.DropItem( new BlackScales( scales ) ); break;
case ScaleType.Green: corpse.DropItem( new GreenScales( scales ) ); break;
case ScaleType.White: corpse.DropItem( new WhiteScales( scales ) ); break;
case ScaleType.Blue: corpse.DropItem( new BlueScales( scales ) ); break;
case ScaleType.All:
{
corpse.DropItem( new RedScales( scales ) );
corpse.DropItem( new YellowScales( scales ) );
corpse.DropItem( new BlackScales( scales ) );
corpse.DropItem( new GreenScales( scales ) );
corpse.DropItem( new WhiteScales( scales ) );
corpse.DropItem( new BlueScales( scales ) );
break;
}
}
from.SendMessage( "You cut away some scales, but they remain on the corpse." );
}
corpse.Carved = true;
if ( corpse.IsCriminalAction( from ) )
from.CriminalAction( true );
}
}
public const int DefaultRangePerception = 16;
public const int OldRangePerception = 10;
public BaseCreature(AIType ai,
FightMode mode,
int iRangePerception,
int iRangeFight,
double dActiveSpeed,
double dPassiveSpeed)
{
if ( iRangePerception == OldRangePerception )
iRangePerception = DefaultRangePerception;
m_Loyalty = MaxLoyalty; // Wonderfully Happy
m_CurrentAI = ai;
m_DefaultAI = ai;
m_iRangePerception = iRangePerception;
m_iRangeFight = iRangeFight;
m_FightMode = mode;
m_iTeam = 0;
SpeedInfo.GetSpeeds( this, ref dActiveSpeed, ref dPassiveSpeed );
m_dActiveSpeed = dActiveSpeed;
m_dPassiveSpeed = dPassiveSpeed;
m_dCurrentSpeed = dPassiveSpeed;
m_bDebugAI = false;
m_arSpellAttack = new List<Type>();
m_arSpellDefense = new List<Type>();
m_bControlled = false;
m_ControlMaster = null;
m_ControlTarget = null;
m_ControlOrder = OrderType.None;
m_bTamable = false;
m_Owners = new List<Mobile>();
m_NextReacquireTime = DateTime.Now + ReacquireDelay;
ChangeAIType(AI);
InhumanSpeech speechType = this.SpeechType;
if ( speechType != null )
speechType.OnConstruct( this );
GenerateLoot( true );
}
public BaseCreature( Serial serial ) : base( serial )
{
m_arSpellAttack = new List<Type>();
m_arSpellDefense = new List<Type>();
m_bDebugAI = false;
}
public override void Serialize( GenericWriter writer )
{
base.Serialize( writer );
writer.Write( (int) 16 ); // version
writer.Write( (int)m_CurrentAI );
writer.Write( (int)m_DefaultAI );
writer.Write( (int)m_iRangePerception );
writer.Write( (int)m_iRangeFight );
writer.Write( (int)m_iTeam );
writer.Write( (double)m_dActiveSpeed );
writer.Write( (double)m_dPassiveSpeed );
writer.Write( (double)m_dCurrentSpeed );
writer.Write( (int) m_pHome.X );
writer.Write( (int) m_pHome.Y );
writer.Write( (int) m_pHome.Z );
// Version 1
writer.Write( (int) m_iRangeHome );
int i=0;
writer.Write( (int) m_arSpellAttack.Count );
for ( i=0; i< m_arSpellAttack.Count; i++ )
{
writer.Write( m_arSpellAttack[i].ToString() );
}
writer.Write( (int) m_arSpellDefense.Count );
for ( i=0; i< m_arSpellDefense.Count; i++ )
{
writer.Write( m_arSpellDefense[i].ToString() );
}
// Version 2
writer.Write( (int) m_FightMode );
writer.Write( (bool) m_bControlled );
writer.Write( (Mobile) m_ControlMaster );
writer.Write( (Mobile) m_ControlTarget );
writer.Write( (Point3D) m_ControlDest );
writer.Write( (int) m_ControlOrder );
writer.Write( (double) m_dMinTameSkill );
// Removed in version 9
//writer.Write( (double) m_dMaxTameSkill );
writer.Write( (bool) m_bTamable );
writer.Write( (bool) m_bSummoned );
if ( m_bSummoned )
writer.WriteDeltaTime( m_SummonEnd );
writer.Write( (int) m_iControlSlots );
// Version 3
writer.Write( (int)m_Loyalty );
// Version 4
writer.Write( m_CurrentWayPoint );
// Verison 5
writer.Write( m_SummonMaster );
// Version 6
writer.Write( (int) m_HitsMax );
writer.Write( (int) m_StamMax );
writer.Write( (int) m_ManaMax );
writer.Write( (int) m_DamageMin );
writer.Write( (int) m_DamageMax );
// Version 7
writer.Write( (int) m_PhysicalResistance );
writer.Write( (int) m_PhysicalDamage );
writer.Write( (int) m_FireResistance );
writer.Write( (int) m_FireDamage );
writer.Write( (int) m_ColdResistance );
writer.Write( (int) m_ColdDamage );
writer.Write( (int) m_PoisonResistance );
writer.Write( (int) m_PoisonDamage );
writer.Write( (int) m_EnergyResistance );
writer.Write( (int) m_EnergyDamage );
// Version 8
writer.Write( m_Owners, true );
// Version 10
writer.Write( (bool) m_IsDeadPet );
writer.Write( (bool) m_IsBonded );
writer.Write( (DateTime) m_BondingBegin );
writer.Write( (DateTime) m_OwnerAbandonTime );
// Version 11
writer.Write( (bool) m_HasGeneratedLoot );
// Version 12
writer.Write( (bool) m_Paragon );
// Version 13
writer.Write( (bool) ( m_Friends != null && m_Friends.Count > 0 ) );
if ( m_Friends != null && m_Friends.Count > 0 )
writer.Write( m_Friends, true );
// Version 14
writer.Write( (bool)m_RemoveIfUntamed );
writer.Write( (int)m_RemoveStep );
}
private static double[] m_StandardActiveSpeeds = new double[]
{
0.175, 0.1, 0.15, 0.2, 0.25, 0.3, 0.4, 0.5, 0.6, 0.8
};
private static double[] m_StandardPassiveSpeeds = new double[]
{
0.350, 0.2, 0.4, 0.5, 0.6, 0.8, 1.0, 1.2, 1.6, 2.0
};
public override void Deserialize( GenericReader reader )
{
base.Deserialize( reader );
int version = reader.ReadInt();
m_CurrentAI = (AIType)reader.ReadInt();
m_DefaultAI = (AIType)reader.ReadInt();
m_iRangePerception = reader.ReadInt();
m_iRangeFight = reader.ReadInt();
m_iTeam = reader.ReadInt();
m_dActiveSpeed = reader.ReadDouble();
m_dPassiveSpeed = reader.ReadDouble();
m_dCurrentSpeed = reader.ReadDouble();
if ( m_iRangePerception == OldRangePerception )
m_iRangePerception = DefaultRangePerception;
m_pHome.X = reader.ReadInt();
m_pHome.Y = reader.ReadInt();
m_pHome.Z = reader.ReadInt();
if ( version >= 1 )
{
m_iRangeHome = reader.ReadInt();
int i, iCount;
iCount = reader.ReadInt();
for ( i=0; i< iCount; i++ )
{
string str = reader.ReadString();
Type type = Type.GetType( str );
if ( type != null )
{
m_arSpellAttack.Add( type );
}
}
iCount = reader.ReadInt();
for ( i=0; i< iCount; i++ )
{
string str = reader.ReadString();
Type type = Type.GetType( str );
if ( type != null )
{
m_arSpellDefense.Add( type );
}
}
}
else
{
m_iRangeHome = 0;
}
if ( version >= 2 )
{
m_FightMode = ( FightMode )reader.ReadInt();
m_bControlled = reader.ReadBool();
m_ControlMaster = reader.ReadMobile();
m_ControlTarget = reader.ReadMobile();
m_ControlDest = reader.ReadPoint3D();
m_ControlOrder = (OrderType) reader.ReadInt();
m_dMinTameSkill = reader.ReadDouble();
if ( version < 9 )
reader.ReadDouble();
m_bTamable = reader.ReadBool();
m_bSummoned = reader.ReadBool();
if ( m_bSummoned )
{
m_SummonEnd = reader.ReadDeltaTime();
new UnsummonTimer( m_ControlMaster, this, m_SummonEnd - DateTime.Now ).Start();
}
m_iControlSlots = reader.ReadInt();
}
else
{
m_FightMode = FightMode.Closest;
m_bControlled = false;
m_ControlMaster = null;
m_ControlTarget = null;
m_ControlOrder = OrderType.None;
}
if ( version >= 3 )
m_Loyalty = reader.ReadInt();
else
m_Loyalty = MaxLoyalty; // Wonderfully Happy
if ( version >= 4 )
m_CurrentWayPoint = reader.ReadItem() as WayPoint;
if ( version >= 5 )
m_SummonMaster = reader.ReadMobile();
if ( version >= 6 )
{
m_HitsMax = reader.ReadInt();
m_StamMax = reader.ReadInt();
m_ManaMax = reader.ReadInt();
m_DamageMin = reader.ReadInt();
m_DamageMax = reader.ReadInt();
}
if ( version >= 7 )
{
m_PhysicalResistance = reader.ReadInt();
m_PhysicalDamage = reader.ReadInt();
m_FireResistance = reader.ReadInt();
m_FireDamage = reader.ReadInt();
m_ColdResistance = reader.ReadInt();
m_ColdDamage = reader.ReadInt();
m_PoisonResistance = reader.ReadInt();
m_PoisonDamage = reader.ReadInt();
m_EnergyResistance = reader.ReadInt();
m_EnergyDamage = reader.ReadInt();
}
if ( version >= 8 )
m_Owners = reader.ReadStrongMobileList();
else
m_Owners = new List<Mobile>();
if ( version >= 10 )
{
m_IsDeadPet = reader.ReadBool();
m_IsBonded = reader.ReadBool();
m_BondingBegin = reader.ReadDateTime();
m_OwnerAbandonTime = reader.ReadDateTime();
}
if ( version >= 11 )
m_HasGeneratedLoot = reader.ReadBool();
else
m_HasGeneratedLoot = true;
if ( version >= 12 )
m_Paragon = reader.ReadBool();
else
m_Paragon = false;
if ( version >= 13 && reader.ReadBool() )
m_Friends = reader.ReadStrongMobileList();
else if ( version < 13 && m_ControlOrder >= OrderType.Unfriend )
++m_ControlOrder;
if ( version < 16 )
Loyalty *= 10;
double activeSpeed = m_dActiveSpeed;
double passiveSpeed = m_dPassiveSpeed;
SpeedInfo.GetSpeeds( this, ref activeSpeed, ref passiveSpeed );
bool isStandardActive = false;
for ( int i = 0; !isStandardActive && i < m_StandardActiveSpeeds.Length; ++i )
isStandardActive = ( m_dActiveSpeed == m_StandardActiveSpeeds[i] );
bool isStandardPassive = false;
for ( int i = 0; !isStandardPassive && i < m_StandardPassiveSpeeds.Length; ++i )
isStandardPassive = ( m_dPassiveSpeed == m_StandardPassiveSpeeds[i] );
if ( isStandardActive && m_dCurrentSpeed == m_dActiveSpeed )
m_dCurrentSpeed = activeSpeed;
else if ( isStandardPassive && m_dCurrentSpeed == m_dPassiveSpeed )
m_dCurrentSpeed = passiveSpeed;
if ( isStandardActive && !m_Paragon )
m_dActiveSpeed = activeSpeed;
if ( isStandardPassive && !m_Paragon )
m_dPassiveSpeed = passiveSpeed;
if ( version >= 14 )
{
m_RemoveIfUntamed = reader.ReadBool();
m_RemoveStep = reader.ReadInt();
}
if( version <= 14 && m_Paragon && Hue == 0x31 )
{
Hue = Paragon.Hue; //Paragon hue fixed, should now be 0x501.
}
Chec
please delete this one its the other one thats why it shows 2 different post of same.