PageRenderTime 77ms CodeModel.GetById 26ms RepoModel.GetById 0ms app.codeStats 1ms

/Scripts/Engines/AI/Creature/BaseCreature.cs

https://bitbucket.org/Kel/crepuscule
C# | 4750 lines | 3594 code | 997 blank | 159 comment | 913 complexity | 1afd62a65d5182fc73a5cee6e9e74830 MD5 | raw file
  1. using System;
  2. using System.Collections;
  3. using Server;
  4. using Server.Regions;
  5. using Server.Targeting;
  6. using Server.Network;
  7. using Server.Spells;
  8. using Server.Misc;
  9. using Server.Items;
  10. using Server.Mobiles;
  11. using Server.ContextMenus;
  12. using Server.Engines.Quests;
  13. using Server.Engines;
  14. using System.Collections.Generic;
  15. namespace Server.Mobiles
  16. {
  17. /// <summary>
  18. /// Summary description for MobileAI.
  19. /// </summary>
  20. ///
  21. public enum FightMode
  22. {
  23. None, // Never focus on others
  24. Agressor, // Only attack agressors
  25. Strongest, // Attack the strongest
  26. Weakest, // Attack the weakest
  27. Closest, // Attack the closest
  28. Evil // Only attack aggressor -or- negative karma
  29. }
  30. public enum OrderType
  31. {
  32. None, //When no order, let's roam
  33. Come, //"(All/Name) come" Summons all or one pet to your location.
  34. Drop, //"(Name) drop" Drops its loot to the ground (if it carries any).
  35. Follow, //"(Name) follow" Follows targeted being.
  36. //"(All/Name) follow me" Makes all or one pet follow you.
  37. Friend, //"(Name) friend" Allows targeted player to confirm resurrection.
  38. Guard, //"(Name) guard" Makes the specified pet guard you. Pets can only guard their owner.
  39. //"(All/Name) guard me" Makes all or one pet guard you.
  40. Attack, //"(All/Name) kill",
  41. //"(All/Name) attack" All or the specified pet(s) currently under your control attack the target.
  42. Patrol, //"(Name) patrol" Roves between two or more guarded targets.
  43. Release, //"(Name) release" Releases pet back into the wild (removes "tame" status).
  44. Stay, //"(All/Name) stay" All or the specified pet(s) will stop and stay in current spot.
  45. Stop, //"(All/Name) stop Cancels any current orders to attack, guard or follow.
  46. Transfert //"(Name) transfer" Transfers complete ownership to targeted player.
  47. }
  48. [Flags]
  49. public enum FoodType
  50. {
  51. Meat = 0x0001,
  52. FruitsAndVegies = 0x0002,
  53. GrainsAndHay = 0x0004,
  54. Fish = 0x0008,
  55. Eggs = 0x0010,
  56. Gold = 0x0020
  57. }
  58. [Flags]
  59. public enum PackInstinct
  60. {
  61. None = 0x0000,
  62. Canine = 0x0001,
  63. Ostard = 0x0002,
  64. Feline = 0x0004,
  65. Arachnid = 0x0008,
  66. Daemon = 0x0010,
  67. Bear = 0x0020,
  68. Equine = 0x0040,
  69. Bull = 0x0080
  70. }
  71. public enum ScaleType
  72. {
  73. Red,
  74. Yellow,
  75. Black,
  76. Green,
  77. White,
  78. Blue,
  79. All
  80. }
  81. public enum MeatType
  82. {
  83. Ribs,
  84. Bird,
  85. LambLeg,
  86. Chicken
  87. }
  88. public enum HideType
  89. {
  90. Regular,
  91. Spined,
  92. Horned,
  93. Barbed
  94. }
  95. public enum PetLoyalty
  96. {
  97. None,
  98. Confused,
  99. ExtremelyUnhappy,
  100. RatherUnhappy,
  101. Unhappy,
  102. SomewhatContent,
  103. Content,
  104. Happy,
  105. RatherHappy,
  106. VeryHappy,
  107. ExtremelyHappy,
  108. WonderfullyHappy
  109. }
  110. public class DamageStore : IComparable
  111. {
  112. public Mobile m_Mobile;
  113. public int m_Damage;
  114. public bool m_HasRight;
  115. public DamageStore(Mobile m, int damage)
  116. {
  117. m_Mobile = m;
  118. m_Damage = damage;
  119. }
  120. public int CompareTo(object obj)
  121. {
  122. DamageStore ds = (DamageStore)obj;
  123. return ds.m_Damage - m_Damage;
  124. }
  125. }
  126. [Description("PNJ")]
  127. public class BaseCreature : Mobile
  128. {
  129. private BaseAI m_AI; // THE AI
  130. private AIType m_CurrentAI; // The current AI
  131. private AIType m_DefaultAI; // The default AI
  132. private Mobile m_FocusMob; // Use focus mob instead of combatant, maybe we don't whan to fight
  133. private FightMode m_FightMode; // The style the mob uses
  134. private LootPackLevel m_LootLevel; // The loot pack level of the mob
  135. private int m_iRangePerception; // The view area
  136. private int m_iRangeFight; // The fight distance
  137. private bool m_bDebugAI; // Show debug AI messages
  138. private int m_iTeam; // Monster Team
  139. private double m_dActiveSpeed; // Timer speed when active
  140. private double m_dPassiveSpeed; // Timer speed when not active
  141. private double m_dCurrentSpeed; // The current speed, lets say it could be changed by something;
  142. private Point3D m_pHome; // The home position of the creature, used by some AI
  143. private int m_iRangeHome = 10; // The home range of the creature
  144. ArrayList m_arSpellAttack; // List of attack spell/power
  145. ArrayList m_arSpellDefense; // Liste of defensive spell/power
  146. private bool m_bControled; // Is controled
  147. private Mobile m_ControlMaster; // My master
  148. private Mobile m_ControlTarget; // My target mobile
  149. private Point3D m_ControlDest; // My target destination (patrol)
  150. private OrderType m_ControlOrder; // My order
  151. private PetLoyalty m_Loyalty;
  152. private double m_dMinTameSkill;
  153. private bool m_bTamable;
  154. private bool m_bSummoned = false;
  155. private DateTime m_SummonEnd;
  156. private int m_iControlSlots = 1;
  157. private bool m_bBardProvoked = false;
  158. private bool m_bBardPacified = false;
  159. private Mobile m_bBardMaster = null;
  160. private Mobile m_bBardTarget = null;
  161. private DateTime m_timeBardEnd;
  162. private WayPoint m_CurrentWayPoint = null;
  163. private Point2D m_TargetLocation = Point2D.Zero;
  164. private Mobile m_SummonMaster;
  165. private int m_HitsMax = -1;
  166. private int m_StamMax = -1;
  167. private int m_ManaMax = -1;
  168. private int m_DamageMin = -1;
  169. private int m_DamageMax = -1;
  170. private int m_PhysicalResistance, m_PhysicalDamage = 100;
  171. private int m_FireResistance, m_FireDamage;
  172. private int m_ColdResistance, m_ColdDamage;
  173. private int m_PoisonResistance, m_PoisonDamage;
  174. private int m_EnergyResistance, m_EnergyDamage;
  175. private ArrayList m_Owners;
  176. private Hashtable m_FearLove;
  177. private Hashtable m_Hate;
  178. private bool m_IsSystemInitialized = false;
  179. protected TimeSpan m_SayingsDelay = TimeSpan.FromSeconds(30);
  180. protected DateTime m_NextSaying;
  181. protected bool m_SayingsEnabled = false;
  182. protected int m_SayingsSecondsDelay = 30;
  183. protected string m_Saying1 = "";
  184. protected string m_Saying2 = "";
  185. protected string m_Saying3 = "";
  186. protected string m_Saying4 = "";
  187. protected string m_Saying5 = "";
  188. private bool m_ShowNameTag = true;
  189. private bool m_IsStabled;
  190. private bool m_HasGeneratedLoot; // have we generated our loot yet?
  191. public virtual InhumanSpeech SpeechType { get { return null; } }
  192. public bool IsStabled
  193. {
  194. get { return m_IsStabled; }
  195. set { m_IsStabled = value; }
  196. }
  197. #region Bonding
  198. public const bool BondingEnabled = true;
  199. public virtual bool IsBondable { get { return (BondingEnabled && !Summoned); } }
  200. public virtual TimeSpan BondingDelay { get { return TimeSpan.FromDays(7.0); } }
  201. public virtual TimeSpan BondingAbandonDelay { get { return TimeSpan.FromDays(1.0); } }
  202. public override bool CanRegenHits { get { return !m_IsDeadPet && base.CanRegenHits; } }
  203. public override bool CanRegenStam { get { return !m_IsDeadPet && base.CanRegenStam; } }
  204. public override bool CanRegenMana { get { return !m_IsDeadPet && base.CanRegenMana; } }
  205. public override bool IsDeadBondedPet { get { return m_IsDeadPet; } }
  206. private bool m_IsBonded;
  207. private bool m_IsDeadPet;
  208. private DateTime m_BondingBegin;
  209. private DateTime m_OwnerAbandonTime;
  210. [CommandProperty(AccessLevel.GameMaster)]
  211. public bool IsBonded
  212. {
  213. get { return m_IsBonded; }
  214. set { m_IsBonded = value; InvalidateProperties(); }
  215. }
  216. public bool IsDeadPet
  217. {
  218. get { return m_IsDeadPet; }
  219. set { m_IsDeadPet = value; }
  220. }
  221. [CommandProperty(AccessLevel.GameMaster)]
  222. public DateTime BondingBegin
  223. {
  224. get { return m_BondingBegin; }
  225. set { m_BondingBegin = value; }
  226. }
  227. [CommandProperty(AccessLevel.GameMaster)]
  228. public DateTime OwnerAbandonTime
  229. {
  230. get { return m_OwnerAbandonTime; }
  231. set { m_OwnerAbandonTime = value; }
  232. }
  233. #endregion
  234. public virtual double WeaponAbilityChance { get { return 0.4; } }
  235. public virtual WeaponAbility GetWeaponAbility()
  236. {
  237. return null;
  238. }
  239. public override int BasePhysicalResistance { get { return m_PhysicalResistance; } }
  240. public override int BaseFireResistance { get { return m_FireResistance; } }
  241. public override int BaseColdResistance { get { return m_ColdResistance; } }
  242. public override int BasePoisonResistance { get { return m_PoisonResistance; } }
  243. public override int BaseEnergyResistance { get { return m_EnergyResistance; } }
  244. [CommandProperty(AccessLevel.GameMaster)]
  245. public bool ShowNameTag { get { return m_ShowNameTag; } set { m_ShowNameTag = value; } }
  246. [CommandProperty(AccessLevel.GameMaster)]
  247. public bool SayingsEnabled { get { return m_SayingsEnabled; } set { m_SayingsEnabled = value; } }
  248. [CommandProperty(AccessLevel.GameMaster)]
  249. public int SayingsSecondsDelay { get { return m_SayingsSecondsDelay; } set { m_SayingsSecondsDelay = value; m_SayingsDelay = TimeSpan.FromSeconds(value); } }
  250. [CommandProperty(AccessLevel.GameMaster)]
  251. public string Saying1 { get { return m_Saying1; } set { m_Saying1 = value; } }
  252. [CommandProperty(AccessLevel.GameMaster)]
  253. public string Saying2 { get { return m_Saying2; } set { m_Saying2 = value; } }
  254. [CommandProperty(AccessLevel.GameMaster)]
  255. public string Saying3 { get { return m_Saying3; } set { m_Saying3 = value; } }
  256. [CommandProperty(AccessLevel.GameMaster)]
  257. public string Saying4 { get { return m_Saying4; } set { m_Saying4 = value; } }
  258. [CommandProperty(AccessLevel.GameMaster)]
  259. public string Saying5 { get { return m_Saying5; } set { m_Saying5 = value; } }
  260. [CommandProperty(AccessLevel.GameMaster)]
  261. public int PhysicalResistanceSeed { get { return m_PhysicalResistance; } set { m_PhysicalResistance = value; UpdateResistances(); } }
  262. [CommandProperty(AccessLevel.GameMaster)]
  263. public int FireResistSeed { get { return m_FireResistance; } set { m_FireResistance = value; UpdateResistances(); } }
  264. [CommandProperty(AccessLevel.GameMaster)]
  265. public int ColdResistSeed { get { return m_ColdResistance; } set { m_ColdResistance = value; UpdateResistances(); } }
  266. [CommandProperty(AccessLevel.GameMaster)]
  267. public int PoisonResistSeed { get { return m_PoisonResistance; } set { m_PoisonResistance = value; UpdateResistances(); } }
  268. [CommandProperty(AccessLevel.GameMaster)]
  269. public int EnergyResistSeed { get { return m_EnergyResistance; } set { m_EnergyResistance = value; UpdateResistances(); } }
  270. [CommandProperty(AccessLevel.GameMaster)]
  271. public int PhysicalDamage { get { return m_PhysicalDamage; } set { m_PhysicalDamage = value; } }
  272. [CommandProperty(AccessLevel.GameMaster)]
  273. public int FireDamage { get { return m_FireDamage; } set { m_FireDamage = value; } }
  274. [CommandProperty(AccessLevel.GameMaster)]
  275. public int ColdDamage { get { return m_ColdDamage; } set { m_ColdDamage = value; } }
  276. [CommandProperty(AccessLevel.GameMaster)]
  277. public int PoisonDamage { get { return m_PoisonDamage; } set { m_PoisonDamage = value; } }
  278. [CommandProperty(AccessLevel.GameMaster)]
  279. public int EnergyDamage { get { return m_EnergyDamage; } set { m_EnergyDamage = value; } }
  280. [CommandProperty(AccessLevel.GameMaster)]
  281. public LootPackLevel LootLevel { get { return m_LootLevel; } set { m_LootLevel = value; } }
  282. public virtual FoodType FavoriteFood { get { return FoodType.Meat; } }
  283. public virtual PackInstinct PackInstinct { get { return PackInstinct.None; } }
  284. public ArrayList Owners { get { return m_Owners; } }
  285. public virtual bool AllowMaleTamer { get { return true; } }
  286. public virtual bool AllowFemaleTamer { get { return true; } }
  287. public virtual bool SubdueBeforeTame { get { return false; } }
  288. public virtual bool Commandable { get { return true; } }
  289. public virtual Poison HitPoison { get { return null; } }
  290. public virtual double HitPoisonChance { get { return 0.5; } }
  291. public virtual Poison PoisonImmune { get { return null; } }
  292. public virtual bool BardImmune { get { return false; } }
  293. public virtual bool Unprovokable { get { return BardImmune || m_IsDeadPet; } }
  294. public virtual bool Uncalmable { get { return BardImmune || m_IsDeadPet; } }
  295. public virtual double DispelDifficulty { get { return 0.0; } } // at this skill level we dispel 50% chance
  296. public virtual double DispelFocus { get { return 20.0; } } // at difficulty - focus we have 0%, at difficulty + focus we have 100%
  297. #region Breath ability, like dragon fire breath
  298. private DateTime m_NextBreathTime;
  299. // Must be overriden in subclass to enable
  300. public virtual bool HasBreath { get { return false; } }
  301. // Base damage given is: CurrentHitPoints * BreathDamageScalar
  302. public virtual double BreathDamageScalar { get { return (Core.AOS ? 0.16 : 0.05); } }
  303. // Min/max seconds until next breath
  304. public virtual double BreathMinDelay { get { return 10.0; } }
  305. public virtual double BreathMaxDelay { get { return 15.0; } }
  306. // Creature stops moving for 1.0 seconds while breathing
  307. public virtual double BreathStallTime { get { return 1.0; } }
  308. // Effect is sent 1.3 seconds after BreathAngerSound and BreathAngerAnimation is played
  309. public virtual double BreathEffectDelay { get { return 1.3; } }
  310. // Damage is given 1.0 seconds after effect is sent
  311. public virtual double BreathDamageDelay { get { return 1.0; } }
  312. public virtual int BreathRange { get { return RangePerception; } }
  313. // Damage types
  314. public virtual int BreathPhysicalDamage { get { return 0; } }
  315. public virtual int BreathFireDamage { get { return 100; } }
  316. public virtual int BreathColdDamage { get { return 0; } }
  317. public virtual int BreathPoisonDamage { get { return 0; } }
  318. public virtual int BreathEnergyDamage { get { return 0; } }
  319. // Effect details and sound
  320. public virtual int BreathEffectItemID { get { return 0x36D4; } }
  321. public virtual int BreathEffectSpeed { get { return 5; } }
  322. public virtual int BreathEffectDuration { get { return 0; } }
  323. public virtual bool BreathEffectExplodes { get { return false; } }
  324. public virtual bool BreathEffectFixedDir { get { return false; } }
  325. public virtual int BreathEffectHue { get { return 0; } }
  326. public virtual int BreathEffectRenderMode { get { return 0; } }
  327. public virtual int BreathEffectSound { get { return 0x227; } }
  328. // Anger sound/animations
  329. public virtual int BreathAngerSound { get { return GetAngerSound(); } }
  330. public virtual int BreathAngerAnimation { get { return 12; } }
  331. public virtual void BreathStart(Mobile target)
  332. {
  333. BreathStallMovement();
  334. BreathPlayAngerSound();
  335. BreathPlayAngerAnimation();
  336. this.Direction = this.GetDirectionTo(target);
  337. Timer.DelayCall(TimeSpan.FromSeconds(BreathEffectDelay), new TimerStateCallback(BreathEffect_Callback), target);
  338. }
  339. public virtual void BreathStallMovement()
  340. {
  341. if (m_AI != null)
  342. m_AI.NextMove = DateTime.Now + TimeSpan.FromSeconds(BreathStallTime);
  343. }
  344. public virtual void BreathPlayAngerSound()
  345. {
  346. PlaySound(BreathAngerSound);
  347. }
  348. public virtual void BreathPlayAngerAnimation()
  349. {
  350. Animate(BreathAngerAnimation, 5, 1, true, false, 0);
  351. }
  352. public virtual void BreathEffect_Callback(object state)
  353. {
  354. Mobile target = (Mobile)state;
  355. if (!target.Alive || !CanBeHarmful(target))
  356. return;
  357. BreathPlayEffectSound();
  358. BreathPlayEffect(target);
  359. Timer.DelayCall(TimeSpan.FromSeconds(BreathDamageDelay), new TimerStateCallback(BreathDamage_Callback), target);
  360. }
  361. public virtual void BreathPlayEffectSound()
  362. {
  363. PlaySound(BreathEffectSound);
  364. }
  365. public virtual void BreathPlayEffect(Mobile target)
  366. {
  367. Effects.SendMovingEffect(this, target, BreathEffectItemID,
  368. BreathEffectSpeed, BreathEffectDuration, BreathEffectFixedDir,
  369. BreathEffectExplodes, BreathEffectHue, BreathEffectRenderMode);
  370. }
  371. public virtual void BreathDamage_Callback(object state)
  372. {
  373. Mobile target = (Mobile)state;
  374. if (CanBeHarmful(target))
  375. {
  376. DoHarmful(target);
  377. BreathDealDamage(target);
  378. }
  379. }
  380. public virtual void BreathDealDamage(Mobile target)
  381. {
  382. int physDamage = BreathPhysicalDamage;
  383. int fireDamage = BreathFireDamage;
  384. int coldDamage = BreathColdDamage;
  385. int poisDamage = BreathPoisonDamage;
  386. int nrgyDamage = BreathEnergyDamage;
  387. if (physDamage == 0 && fireDamage == 0 && coldDamage == 0 && poisDamage == 0 && nrgyDamage == 0)
  388. { // Unresistable damage even in AOS
  389. target.Damage(BreathComputeDamage(), this);
  390. }
  391. else
  392. {
  393. AOS.Damage(target, this, BreathComputeDamage(), physDamage, fireDamage, coldDamage, poisDamage, nrgyDamage);
  394. }
  395. }
  396. public virtual int BreathComputeDamage()
  397. {
  398. return (int)(Hits * BreathDamageScalar);
  399. }
  400. #endregion
  401. private DateTime m_EndFlee;
  402. public DateTime EndFleeTime
  403. {
  404. get { return m_EndFlee; }
  405. set { m_EndFlee = value; }
  406. }
  407. public virtual void StopFlee()
  408. {
  409. m_EndFlee = DateTime.MinValue;
  410. }
  411. public virtual bool CheckFlee()
  412. {
  413. if (m_EndFlee == DateTime.MinValue)
  414. return false;
  415. if (DateTime.Now >= m_EndFlee)
  416. {
  417. StopFlee();
  418. return false;
  419. }
  420. return true;
  421. }
  422. public virtual void BeginFlee(TimeSpan maxDuration)
  423. {
  424. m_EndFlee = DateTime.Now + maxDuration;
  425. }
  426. public BaseAI AIObject { get { return m_AI; } }
  427. public const int MaxOwners = 5;
  428. public virtual OppositionGroup OppositionGroup
  429. {
  430. get { return null; }
  431. }
  432. public virtual bool IsFriend(Mobile m)
  433. {
  434. OppositionGroup g = this.OppositionGroup;
  435. if (g != null && g.IsEnemy(this, m))
  436. return false;
  437. if (!(m is BaseCreature))
  438. return false;
  439. BaseCreature c = (BaseCreature)m;
  440. return (m_iTeam == c.m_iTeam && ((m_bSummoned || m_bControled) == (c.m_bSummoned || c.m_bControled)));
  441. }
  442. public virtual bool IsEnemy(Mobile m)
  443. {
  444. OppositionGroup g = this.OppositionGroup;
  445. if (g != null && g.IsEnemy(this, m))
  446. return true;
  447. if (m is BaseGuard)
  448. return false;
  449. if (!(m is BaseCreature))
  450. return true;
  451. BaseCreature c = (BaseCreature)m;
  452. return (m_iTeam != c.m_iTeam || ((m_bSummoned || m_bControled) != (c.m_bSummoned || c.m_bControled)));
  453. }
  454. public virtual bool CheckControlChance(Mobile m)
  455. {
  456. return CheckControlChance(m, 0.0);
  457. }
  458. public virtual bool CheckControlChance(Mobile m, double offset)
  459. {
  460. double v = GetControlChance(m) + offset;
  461. if (v > Utility.RandomDouble())
  462. return true;
  463. PlaySound(GetAngerSound());
  464. if (Body.IsAnimal)
  465. Animate(10, 5, 1, true, false, 0);
  466. else if (Body.IsMonster)
  467. Animate(18, 5, 1, true, false, 0);
  468. return false;
  469. }
  470. public virtual bool CanBeControlledBy(Mobile m)
  471. {
  472. return (GetControlChance(m) > 0.0);
  473. }
  474. public virtual double GetControlChance(Mobile m)
  475. {
  476. return 100;
  477. }
  478. private static Type[] m_AnimateDeadTypes = new Type[]
  479. {
  480. typeof( MoundOfMaggots ), typeof( HellSteed ), typeof( SkeletalMount ),
  481. typeof( WailingBanshee ), typeof( Wraith ), typeof( SkeletalDragon ),
  482. typeof( LichLord ), typeof( FleshGolem ), typeof( Lich ),
  483. typeof( SkeletalKnight ), typeof( BoneKnight ), typeof( Mummy2 ),
  484. typeof( SkeletalMage ), typeof( BoneMagi ), typeof( PatchworkSkeleton )
  485. };
  486. public virtual bool IsAnimatedDead
  487. {
  488. get
  489. {
  490. if (!Summoned)
  491. return false;
  492. Type type = this.GetType();
  493. bool contains = false;
  494. for (int i = 0; !contains && i < m_AnimateDeadTypes.Length; ++i)
  495. contains = (type == m_AnimateDeadTypes[i]);
  496. return contains;
  497. }
  498. }
  499. public override void Damage(int amount, Mobile from)
  500. {
  501. int oldHits = this.Hits;
  502. if (Spells.Necromancy.EvilOmenSpell.CheckEffect(this))
  503. amount = (int)(amount * 1.25);
  504. Mobile oath = Spells.Necromancy.BloodOathSpell.GetBloodOath(from);
  505. if (oath == this)
  506. {
  507. amount = (int)(amount * 1.1);
  508. from.Damage(amount, from);
  509. }
  510. base.Damage(amount, from);
  511. if (SubdueBeforeTame && !Controled)
  512. {
  513. if ((oldHits > (this.HitsMax / 10)) && (this.Hits <= (this.HitsMax / 10)))
  514. PublicOverheadMessage(MessageType.Regular, 0x3B2, false, "* The creature has been beaten into subjugation! *");
  515. }
  516. }
  517. public virtual bool DeleteCorpseOnDeath
  518. {
  519. get
  520. {
  521. return !Core.AOS && m_bSummoned;
  522. }
  523. }
  524. public override void SetLocation(Point3D newLocation, bool isTeleport)
  525. {
  526. base.SetLocation(newLocation, isTeleport);
  527. if (isTeleport && m_AI != null)
  528. m_AI.OnTeleported();
  529. }
  530. public override ApplyPoisonResult ApplyPoison(Mobile from, Poison poison)
  531. {
  532. if (!Alive || IsDeadPet)
  533. return ApplyPoisonResult.Immune;
  534. if (Spells.Necromancy.EvilOmenSpell.CheckEffect(this))
  535. return base.ApplyPoison(from, PoisonImpl.IncreaseLevel(poison));
  536. return base.ApplyPoison(from, poison);
  537. }
  538. public override bool CheckPoisonImmunity(Mobile from, Poison poison)
  539. {
  540. if (base.CheckPoisonImmunity(from, poison))
  541. return true;
  542. Poison p = this.PoisonImmune;
  543. return (p != null && p.Level >= poison.Level);
  544. }
  545. [CommandProperty(AccessLevel.GameMaster)]
  546. public PetLoyalty Loyalty
  547. {
  548. get
  549. {
  550. return m_Loyalty;
  551. }
  552. set
  553. {
  554. m_Loyalty = value;
  555. }
  556. }
  557. [CommandProperty(AccessLevel.GameMaster)]
  558. public WayPoint CurrentWayPoint
  559. {
  560. get
  561. {
  562. return m_CurrentWayPoint;
  563. }
  564. set
  565. {
  566. m_CurrentWayPoint = value;
  567. }
  568. }
  569. [CommandProperty(AccessLevel.GameMaster)]
  570. public Point2D TargetLocation
  571. {
  572. get
  573. {
  574. return m_TargetLocation;
  575. }
  576. set
  577. {
  578. m_TargetLocation = value;
  579. }
  580. }
  581. public virtual Mobile ConstantFocus { get { return null; } }
  582. public virtual bool DisallowAllMoves
  583. {
  584. get
  585. {
  586. return false;
  587. }
  588. }
  589. public virtual bool InitialInnocent
  590. {
  591. get
  592. {
  593. return false;
  594. }
  595. }
  596. public virtual bool AlwaysMurderer
  597. {
  598. get
  599. {
  600. return false;
  601. }
  602. }
  603. public virtual bool AlwaysAttackable
  604. {
  605. get
  606. {
  607. return false;
  608. }
  609. }
  610. [CommandProperty(AccessLevel.GameMaster)]
  611. public virtual int DamageMin { get { return m_DamageMin; } set { m_DamageMin = value; } }
  612. [CommandProperty(AccessLevel.GameMaster)]
  613. public virtual int DamageMax { get { return m_DamageMax; } set { m_DamageMax = value; } }
  614. [CommandProperty(AccessLevel.GameMaster)]
  615. public override int HitsMax
  616. {
  617. get
  618. {
  619. if (m_HitsMax >= 0)
  620. return m_HitsMax;
  621. return Str;
  622. }
  623. }
  624. [CommandProperty(AccessLevel.GameMaster)]
  625. public int HitsMaxSeed
  626. {
  627. get { return m_HitsMax; }
  628. set { m_HitsMax = value; }
  629. }
  630. [CommandProperty(AccessLevel.GameMaster)]
  631. public override int StamMax
  632. {
  633. get
  634. {
  635. if (m_StamMax >= 0)
  636. return m_StamMax;
  637. return Dex;
  638. }
  639. }
  640. [CommandProperty(AccessLevel.GameMaster)]
  641. public int StamMaxSeed
  642. {
  643. get { return m_StamMax; }
  644. set { m_StamMax = value; }
  645. }
  646. [CommandProperty(AccessLevel.GameMaster)]
  647. public override int ManaMax
  648. {
  649. get
  650. {
  651. if (m_ManaMax >= 0)
  652. return m_ManaMax;
  653. return Int;
  654. }
  655. }
  656. [CommandProperty(AccessLevel.GameMaster)]
  657. public int ManaMaxSeed
  658. {
  659. get { return m_ManaMax; }
  660. set { m_ManaMax = value; }
  661. }
  662. public Hashtable FearLove
  663. {
  664. get { return m_FearLove; }
  665. }
  666. public Hashtable Hate
  667. {
  668. get { return m_Hate; }
  669. }
  670. public virtual bool CanOpenDoors
  671. {
  672. get
  673. {
  674. return !this.Body.IsAnimal && !this.Body.IsSea;
  675. }
  676. }
  677. public virtual bool CanMoveOverObstacles
  678. {
  679. get
  680. {
  681. return this.Body.IsMonster;
  682. }
  683. }
  684. public virtual bool CanDestroyObstacles
  685. {
  686. get
  687. {
  688. // to enable breaking of furniture, 'return CanMoveOverObstacles;'
  689. return false;
  690. }
  691. }
  692. public override void OnDamage(int amount, Mobile from, bool willKill)
  693. {
  694. WeightOverloading.FatigueOnDamage(this, amount);
  695. InhumanSpeech speechType = this.SpeechType;
  696. if (speechType != null && !willKill)
  697. speechType.OnDamage(this, amount);
  698. base.OnDamage(amount, from, willKill);
  699. }
  700. public virtual void OnDamagedBySpell(Mobile from)
  701. {
  702. }
  703. public virtual void AlterDamageScalarFrom(Mobile caster, ref double scalar)
  704. {
  705. }
  706. public virtual void AlterDamageScalarTo(Mobile target, ref double scalar)
  707. {
  708. }
  709. public virtual void AlterMeleeDamageFrom(Mobile from, ref int damage)
  710. {
  711. }
  712. public virtual void AlterMeleeDamageTo(Mobile to, ref int damage)
  713. {
  714. }
  715. public virtual void CheckReflect(Mobile caster, ref bool reflect)
  716. {
  717. }
  718. public virtual void OnCarve(Mobile from, Corpse corpse)
  719. {
  720. int feathers = Feathers;
  721. int wool = Wool;
  722. int meat = Meat;
  723. int hides = Hides;
  724. int scales = Scales;
  725. if ((feathers == 0 && wool == 0 && meat == 0 && hides == 0 && scales == 0) || Summoned || IsBonded)
  726. {
  727. from.SendLocalizedMessage(500485); // You see nothing useful to carve from the corpse.
  728. }
  729. else
  730. {
  731. if (corpse.Map == Map.Felucca)
  732. {
  733. feathers *= 2;
  734. wool *= 2;
  735. hides *= 2;
  736. }
  737. new Blood(0x122D).MoveToWorld(corpse.Location, corpse.Map);
  738. if (feathers != 0)
  739. {
  740. corpse.DropItem(new Feather(feathers));
  741. from.SendLocalizedMessage(500479); // You pluck the bird. The feathers are now on the corpse.
  742. }
  743. if (wool != 0)
  744. {
  745. corpse.DropItem(new Wool(wool));
  746. from.SendLocalizedMessage(500483); // You shear it, and the wool is now on the corpse.
  747. }
  748. if (meat != 0)
  749. {
  750. if (MeatType == MeatType.Ribs)
  751. corpse.DropItem(new RawRibs(meat));
  752. else if (MeatType == MeatType.Bird)
  753. corpse.DropItem(new RawBird(meat));
  754. else if (MeatType == MeatType.LambLeg)
  755. corpse.DropItem(new RawLambLeg(meat));
  756. else if (MeatType == MeatType.Chicken)
  757. corpse.DropItem(new RawChickenLeg(meat));
  758. from.SendLocalizedMessage(500467); // You carve some meat, which remains on the corpse.
  759. }
  760. if (hides != 0)
  761. {
  762. if (HideType == HideType.Regular)
  763. corpse.DropItem(new Hides(hides));
  764. else if (HideType == HideType.Spined)
  765. corpse.DropItem(new SpinedHides(hides));
  766. else if (HideType == HideType.Horned)
  767. corpse.DropItem(new HornedHides(hides));
  768. else if (HideType == HideType.Barbed)
  769. corpse.DropItem(new BarbedHides(hides));
  770. from.SendLocalizedMessage(500471); // You skin it, and the hides are now in the corpse.
  771. }
  772. if (scales != 0)
  773. {
  774. ScaleType sc = this.ScaleType;
  775. switch (sc)
  776. {
  777. case ScaleType.Red: corpse.DropItem(new RedScales(scales)); break;
  778. case ScaleType.Yellow: corpse.DropItem(new YellowScales(scales)); break;
  779. case ScaleType.Black: corpse.DropItem(new BlackScales(scales)); break;
  780. case ScaleType.Green: corpse.DropItem(new GreenScales(scales)); break;
  781. case ScaleType.White: corpse.DropItem(new WhiteScales(scales)); break;
  782. case ScaleType.Blue: corpse.DropItem(new BlueScales(scales)); break;
  783. case ScaleType.All:
  784. {
  785. corpse.DropItem(new RedScales(scales));
  786. corpse.DropItem(new YellowScales(scales));
  787. corpse.DropItem(new BlackScales(scales));
  788. corpse.DropItem(new GreenScales(scales));
  789. corpse.DropItem(new WhiteScales(scales));
  790. corpse.DropItem(new BlueScales(scales));
  791. break;
  792. }
  793. }
  794. from.SendMessage("You cut away some scales, but they remain on the corpse.");
  795. }
  796. corpse.Carved = true;
  797. if (corpse.IsCriminalAction(from))
  798. from.CriminalAction(true);
  799. }
  800. }
  801. public const int DefaultRangePerception = 16;
  802. public const int OldRangePerception = 10;
  803. public BaseCreature(AIType ai,
  804. FightMode mode,
  805. int iRangePerception,
  806. int iRangeFight,
  807. double dActiveSpeed,
  808. double dPassiveSpeed)
  809. {
  810. if (iRangePerception == OldRangePerception)
  811. iRangePerception = DefaultRangePerception;
  812. m_Loyalty = PetLoyalty.WonderfullyHappy;
  813. m_CurrentAI = ai;
  814. m_DefaultAI = ai;
  815. m_iRangePerception = iRangePerception;
  816. m_iRangeFight = iRangeFight;
  817. m_FightMode = mode;
  818. m_iTeam = 0;
  819. SpeedInfo.GetSpeeds(this, ref dActiveSpeed, ref dPassiveSpeed);
  820. m_dActiveSpeed = dActiveSpeed;
  821. m_dPassiveSpeed = dPassiveSpeed;
  822. m_dCurrentSpeed = dPassiveSpeed;
  823. m_bDebugAI = false;
  824. m_arSpellAttack = new ArrayList();
  825. m_arSpellDefense = new ArrayList();
  826. m_bControled = false;
  827. m_ControlMaster = null;
  828. m_ControlTarget = null;
  829. m_ControlOrder = OrderType.None;
  830. m_bTamable = false;
  831. m_Owners = new ArrayList();
  832. m_NextReaquireTime = DateTime.Now + ReaquireDelay;
  833. ChangeAIType(AI);
  834. InhumanSpeech speechType = this.SpeechType;
  835. if (speechType != null)
  836. speechType.OnConstruct(this);
  837. GenerateLoot(true);
  838. }
  839. public BaseCreature(Serial serial)
  840. : base(serial)
  841. {
  842. m_arSpellAttack = new ArrayList();
  843. m_arSpellDefense = new ArrayList();
  844. m_bDebugAI = false;
  845. }
  846. public override void Serialize(GenericWriter writer)
  847. {
  848. base.Serialize(writer);
  849. writer.Write((int)17); // version
  850. writer.Write((int)m_LootLevel);
  851. writer.Write(Frozen);
  852. writer.Write(m_IsSystemInitialized);
  853. writer.Write(m_ShowNameTag);
  854. writer.Write(m_SayingsEnabled);
  855. writer.Write(m_SayingsSecondsDelay);
  856. writer.Write(m_Saying1);
  857. writer.Write(m_Saying2);
  858. writer.Write(m_Saying3);
  859. writer.Write(m_Saying4);
  860. writer.Write(m_Saying5);
  861. writer.Write((int)m_CurrentAI);
  862. writer.Write((int)m_DefaultAI);
  863. writer.Write((int)m_iRangePerception);
  864. writer.Write((int)m_iRangeFight);
  865. writer.Write((int)m_iTeam);
  866. writer.Write((double)m_dActiveSpeed);
  867. writer.Write((double)m_dPassiveSpeed);
  868. writer.Write((double)m_dCurrentSpeed);
  869. writer.Write((int)m_pHome.X);
  870. writer.Write((int)m_pHome.Y);
  871. writer.Write((int)m_pHome.Z);
  872. // Version 1
  873. writer.Write((int)m_iRangeHome);
  874. int i = 0;
  875. writer.Write((int)m_arSpellAttack.Count);
  876. for (i = 0; i < m_arSpellAttack.Count; i++)
  877. {
  878. writer.Write(m_arSpellAttack[i].ToString());
  879. }
  880. writer.Write((int)m_arSpellDefense.Count);
  881. for (i = 0; i < m_arSpellDefense.Count; i++)
  882. {
  883. writer.Write(m_arSpellDefense[i].ToString());
  884. }
  885. // Version 2
  886. writer.Write((int)m_FightMode);
  887. writer.Write((bool)m_bControled);
  888. writer.Write((Mobile)m_ControlMaster);
  889. writer.Write((Mobile)m_ControlTarget);
  890. writer.Write((Point3D)m_ControlDest);
  891. writer.Write((int)m_ControlOrder);
  892. writer.Write((double)m_dMinTameSkill);
  893. // Removed in version 9
  894. //writer.Write( (double) m_dMaxTameSkill );
  895. writer.Write((bool)m_bTamable);
  896. writer.Write((bool)m_bSummoned);
  897. if (m_bSummoned)
  898. writer.WriteDeltaTime(m_SummonEnd);
  899. writer.Write((int)m_iControlSlots);
  900. // Version 3
  901. writer.Write((int)m_Loyalty);
  902. // Version 4
  903. writer.Write(m_CurrentWayPoint);
  904. // Verison 5
  905. writer.Write(m_SummonMaster);
  906. // Version 6
  907. writer.Write((int)m_HitsMax);
  908. writer.Write((int)m_StamMax);
  909. writer.Write((int)m_ManaMax);
  910. writer.Write((int)m_DamageMin);
  911. writer.Write((int)m_DamageMax);
  912. // Version 7
  913. writer.Write((int)m_PhysicalResistance);
  914. writer.Write((int)m_PhysicalDamage);
  915. writer.Write((int)m_FireResistance);
  916. writer.Write((int)m_FireDamage);
  917. writer.Write((int)m_ColdResistance);
  918. writer.Write((int)m_ColdDamage);
  919. writer.Write((int)m_PoisonResistance);
  920. writer.Write((int)m_PoisonDamage);
  921. writer.Write((int)m_EnergyResistance);
  922. writer.Write((int)m_EnergyDamage);
  923. // Version 8
  924. writer.WriteMobileList(m_Owners, true);
  925. // Version 10
  926. writer.Write((bool)m_IsDeadPet);
  927. writer.Write((bool)m_IsBonded);
  928. writer.Write((DateTime)m_BondingBegin);
  929. writer.Write((DateTime)m_OwnerAbandonTime);
  930. // Version 11
  931. writer.Write((bool)m_HasGeneratedLoot);
  932. // Version 12
  933. writer.Write((int)Erudition);
  934. //// Version 13
  935. //writer.Write((int)m_FearLove.Count);
  936. //foreach (Mobile mobile in m_FearLove.Keys)
  937. //{
  938. // writer.Write((Mobile)mobile);
  939. // writer.Write((double)m_FearLove[mobile]);
  940. //}
  941. //writer.Write((int)m_Hate.Count);
  942. //foreach (Mobile mobile in m_Hate.Keys)
  943. //{
  944. // writer.Write((Mobile)mobile);
  945. // writer.Write((double)m_Hate[mobile]);
  946. //}
  947. }
  948. private static double[] m_StandardActiveSpeeds = new double[]
  949. {
  950. 0.175, 0.1, 0.15, 0.2, 0.25, 0.3, 0.4, 0.5, 0.6, 0.8
  951. };
  952. private static double[] m_StandardPassiveSpeeds = new double[]
  953. {
  954. 0.350, 0.2, 0.4, 0.5, 0.6, 0.8, 1.0, 1.2, 1.6, 2.0
  955. };
  956. public override void Deserialize(GenericReader reader)
  957. {
  958. base.Deserialize(reader);
  959. int version = reader.ReadInt();
  960. if (version >= 17)
  961. {
  962. m_LootLevel = (LootPackLevel)reader.ReadInt();
  963. }
  964. if (version >= 16)
  965. {
  966. Frozen = reader.ReadBool();
  967. }
  968. if (version >= 15)
  969. {
  970. m_IsSystemInitialized = reader.ReadBool();
  971. }
  972. if (version >= 14)
  973. {
  974. m_ShowNameTag = reader.ReadBool();
  975. }
  976. if (version >= 13)
  977. {
  978. m_SayingsEnabled = reader.ReadBool();
  979. m_SayingsSecondsDelay = reader.ReadInt();
  980. m_Saying1 = reader.ReadString();
  981. m_Saying2 = reader.ReadString();
  982. m_Saying3 = reader.ReadString();
  983. m_Saying4 = reader.ReadString();
  984. m_Saying5 = reader.ReadString();
  985. m_SayingsDelay = TimeSpan.FromSeconds(m_SayingsSecondsDelay);
  986. }
  987. m_CurrentAI = (AIType)reader.ReadInt();
  988. m_DefaultAI = (AIType)reader.ReadInt();
  989. m_iRangePerception = reader.ReadInt();
  990. m_iRangeFight = reader.ReadInt();
  991. m_iTeam = reader.ReadInt();
  992. m_dActiveSpeed = reader.ReadDouble();
  993. m_dPassiveSpeed = reader.ReadDouble();
  994. m_dCurrentSpeed = reader.ReadDouble();
  995. double activeSpeed = m_dActiveSpeed;
  996. double passiveSpeed = m_dPassiveSpeed;
  997. SpeedInfo.GetSpeeds(this, ref activeSpeed, ref passiveSpeed);
  998. bool isStandardActive = false;
  999. for (int i = 0; !isStandardActive && i < m_StandardActiveSpeeds.Length; ++i)
  1000. isStandardActive = (m_dActiveSpeed == m_StandardActiveSpeeds[i]);
  1001. bool isStandardPassive = false;
  1002. for (int i = 0; !isStandardPassive && i < m_StandardPassiveSpeeds.Length; ++i)
  1003. isStandardPassive = (m_dPassiveSpeed == m_StandardPassiveSpeeds[i]);
  1004. if (isStandardActive && m_dCurrentSpeed == m_dActiveSpeed)
  1005. m_dCurrentSpeed = activeSpeed;
  1006. else if (isStandardPassive && m_dCurrentSpeed == m_dPassiveSpeed)
  1007. m_dCurrentSpeed = passiveSpeed;
  1008. if (isStandardActive)
  1009. m_dActiveSpeed = activeSpeed;
  1010. if (isStandardPassive)
  1011. m_dPassiveSpeed = passiveSpeed;
  1012. if (m_iRangePerception == OldRangePerception)
  1013. m_iRangePerception = DefaultRangePerception;
  1014. m_pHome.X = reader.ReadInt();
  1015. m_pHome.Y = reader.ReadInt();
  1016. m_pHome.Z = reader.ReadInt();
  1017. if (version >= 1)
  1018. {
  1019. m_iRangeHome = reader.ReadInt();
  1020. int i, iCount;
  1021. iCount = reader.ReadInt();
  1022. for (i = 0; i < iCount; i++)
  1023. {
  1024. string str = reader.ReadString();
  1025. Type type = Type.GetType(str);
  1026. if (type != null)
  1027. {
  1028. m_arSpellAttack.Add(type);
  1029. }
  1030. }
  1031. iCount = reader.ReadInt();
  1032. for (i = 0; i < iCount; i++)
  1033. {
  1034. string str = reader.ReadString();
  1035. Type type = Type.GetType(str);
  1036. if (type != null)
  1037. {
  1038. m_arSpellDefense.Add(type);
  1039. }
  1040. }
  1041. }
  1042. else
  1043. {
  1044. m_iRangeHome = 0;
  1045. }
  1046. if (version >= 2)
  1047. {
  1048. m_FightMode = (FightMode)reader.ReadInt();
  1049. m_bControled = reader.ReadBool();
  1050. m_ControlMaster = reader.ReadMobile();
  1051. m_ControlTarget = reader.ReadMobile();
  1052. m_ControlDest = reader.ReadPoint3D();
  1053. m_ControlOrder = (OrderType)reader.ReadInt();
  1054. m_dMinTameSkill = reader.ReadDouble();
  1055. if (version < 9)
  1056. reader.ReadDouble();
  1057. m_bTamable = reader.ReadBool();
  1058. m_bSummoned = reader.ReadBool();
  1059. if (m_bSummoned)
  1060. {
  1061. m_SummonEnd = reader.ReadDeltaTime();
  1062. new UnsummonTimer(m_ControlMaster, this, m_SummonEnd - DateTime.Now).Start();
  1063. }
  1064. m_iControlSlots = reader.ReadInt();
  1065. }
  1066. else
  1067. {
  1068. m_FightMode = FightMode.Closest;
  1069. m_bControled = false;
  1070. m_ControlMaster = null;
  1071. m_ControlTarget = null;
  1072. m_ControlOrder = OrderType.None;
  1073. }
  1074. if (version >= 3)
  1075. m_Loyalty = (PetLoyalty)reader.ReadInt();
  1076. else
  1077. m_Loyalty = PetLoyalty.WonderfullyHappy;
  1078. if (version >= 4)
  1079. m_CurrentWayPoint = reader.ReadItem() as WayPoint;
  1080. if (version >= 5)
  1081. m_SummonMaster = reader.ReadMobile();
  1082. if (version >= 6)
  1083. {
  1084. m_HitsMax = reader.ReadInt();
  1085. m_StamMax = reader.ReadInt();
  1086. m_ManaMax = reader.ReadInt();
  1087. m_DamageMin = reader.ReadInt();
  1088. m_DamageMax = reader.ReadInt();
  1089. }
  1090. if (version >= 7)
  1091. {
  1092. m_PhysicalResistance = reader.ReadInt();
  1093. m_PhysicalDamage = reader.ReadInt();
  1094. m_FireResistance = reader.ReadInt();
  1095. m_FireDamage = reader.ReadInt();
  1096. m_ColdResistance = reader.ReadInt();
  1097. m_ColdDamage = reader.ReadInt();
  1098. m_PoisonResistance = reader.ReadInt();
  1099. m_PoisonDamage = reader.ReadInt();
  1100. m_EnergyResistance = reader.ReadInt();
  1101. m_EnergyDamage = reader.ReadInt();
  1102. }
  1103. if (version >= 8)
  1104. m_Owners = reader.ReadMobileList();
  1105. else
  1106. m_Owners = new ArrayList();
  1107. if (version >= 10)
  1108. {
  1109. m_IsDeadPet = reader.ReadBool();
  1110. m_IsBonded = reader.ReadBool();
  1111. m_BondingBegin = reader.ReadDateTime();
  1112. m_OwnerAbandonTime = reader.ReadDateTime();
  1113. }
  1114. if (version >= 11)
  1115. m_HasGeneratedLoot = reader.ReadBool();
  1116. else
  1117. m_HasGeneratedLoot = true;
  1118. if (version >= 12)
  1119. Erudition = reader.ReadInt();
  1120. else
  1121. Erudition = 0;
  1122. CheckStatTimers();
  1123. ChangeAIType(m_CurrentAI);
  1124. AddFollowers();
  1125. if (IsAnimatedDead)
  1126. Spells.Necromancy.AnimateDeadSpell.Register(m_SummonMaster, this);
  1127. }
  1128. #region Fonction ObjectPropertyList
  1129. public override void AddNameProperties(ObjectPropertyList list)
  1130. {
  1131. base.AddNameProperties(list);
  1132. if (Controled && Commandable)
  1133. {
  1134. if (Summoned)
  1135. list.Add(1049646); // (summoned)
  1136. else if (IsBonded)
  1137. list.Add(1049608); // (bonded)
  1138. else
  1139. list.Add(502006); // (tame)
  1140. }
  1141. }
  1142. public override void GetProperties(ObjectPropertyList list)
  1143. {
  1144. base.GetProperties(list);
  1145. }
  1146. protected int m_Erudition = 0;
  1147. [CommandProperty(AccessLevel.GameMaster)]
  1148. public int Erudition
  1149. {
  1150. get { return m_Erudition; }
  1151. set { m_Erudition = value; }
  1152. }
  1153. public override void SendPropertiesTo(Mobile from)
  1154. {
  1155. ObjectPropertyList opl = new ObjectPropertyList(this);
  1156. string name = Name;
  1157. if (from is RacePlayerMobile && (!(this is BaseVendor)))
  1158. {
  1159. RacePlayerMobile pmf = (RacePlayerMobile)from;
  1160. if (pmf.AccessLevel > AccessLevel.Player)
  1161. {
  1162. // SI GM
  1163. if (pmf.Capacities[CapacityName.Lore].Value < Erudition)
  1164. {//pas érudit
  1165. opl.Add(1050045, "{0} \t{1}\t {2}", "", "Créature", ""); // ~1_PREFIX~~2_NAME~~3_SUFFIX~
  1166. }
  1167. else
  1168. {//Assez érudit
  1169. opl.Add(1050045, "{0} \t{1}\t {2}", "", name, ""); // ~1_PREFIX~~2_NAME~~3_SUFFIX~
  1170. }
  1171. }
  1172. else
  1173. {
  1174. // SI PJ
  1175. if (pmf.Capacities[CapacityName.Lore].Value < Erudition)
  1176. {//pas érudit
  1177. opl.Add(1050045, "{0} \t{1}\t {2}", "", "Créature", ""); // ~1_PREFIX~~2_NAME~~3_SUFFIX~
  1178. }
  1179. else
  1180. {//Assez érudit
  1181. opl.Add(1050045, "{0} \t{1}\t {2}", "", name, ""); // ~1_PREFIX~~2_NAME~~3_SUFFIX~
  1182. }
  1183. }
  1184. }
  1185. //from.Send(opl);
  1186. base.SendPropertiesTo(from);
  1187. }
  1188. private static ArrayList m_Hears;
  1189. private static ArrayList m_OnSpeech;
  1190. private static bool m_NoSpeechLOS1;
  1191. [CommandProperty(AccessLevel.GameMaster)]
  1192. public static bool NoSpeechLOS1 { get { return m_NoSpeechLOS1; } set { m_NoSpeechLOS1 = value; } }
  1193. public override bool CanSee(Mobile m)
  1194. {
  1195. //SendPropertiesTo(this);
  1196. //SendPropertiesTo(m);
  1197. return base.CanSee(m);
  1198. }
  1199. public override void DoSpeech(string text, int[] keywords, MessageType type, int hue)
  1200. {
  1201. // base.DoSpeech(text, keywords, type, hue);
  1202. if (Commands.Handle(this, text))
  1203. return;
  1204. int range = 12;
  1205. switch (type)
  1206. {
  1207. case MessageType.Regular: this.SpeechHue = hue; break;
  1208. case MessageType.Emote: this.EmoteHue = hue; break;
  1209. case MessageType.Whisper: this.WhisperHue = hue; range = 2; break;
  1210. case MessageType.Yell:
  1211. this.YellHue = hue; range = 18;
  1212. range = 18;
  1213. break;
  1214. default: type = MessageType.Regular; break;
  1215. }
  1216. SpeechEventArgs regArgs = new SpeechEventArgs(this, text, type, hue, keywords);
  1217. EventSink.InvokeSpeech(regArgs);
  1218. this.Region.OnSpeech(regArgs);
  1219. OnSaid(regArgs);
  1220. if (regArgs.Blocked)
  1221. return;
  1222. text = regArgs.Speech;
  1223. if (text == null || text.Length == 0)
  1224. return;
  1225. if (m_Hears == null)
  1226. m_Hears = new ArrayList();
  1227. else if (m_Hears.Count > 0)
  1228. m_Hears.Clear();
  1229. if (m_OnSpeech == null)
  1230. m_OnSpeech = new ArrayList();
  1231. else if (m_OnSpeech.Count > 0)
  1232. m_OnSpeech.Clear();
  1233. ArrayList hears = m_Hears;
  1234. ArrayList onSpeech = m_OnSpeech;
  1235. if (this.Map != null)
  1236. {
  1237. IPooledEnumerable eable = this.Map.GetObjectsInRange(this.Location, range);
  1238. foreach (object o in eable)
  1239. {
  1240. if (o is Mobile)
  1241. {
  1242. Mobile heard = (Mobile)o;
  1243. if (heard.CanSee(this) && (m_NoSpeechLOS1 || !heard.Player || heard.InLOS(this)))
  1244. {
  1245. if (heard.NetState != null)
  1246. hears.Add(heard);
  1247. if (heard.HandlesOnSpeech(this))
  1248. onSpeech.Add(heard);
  1249. for (int i = 0; i < heard.Items.Count; ++i)
  1250. {
  1251. Item item = (Item)heard.Items[i];
  1252. if (item.HandlesOnSpeech)
  1253. onSpeech.Add(item);
  1254. //if (item is Container)
  1255. // AddSpeechItemsFrom(onSpeech, (Container)item);
  1256. }
  1257. }
  1258. }
  1259. else if (o is Item)
  1260. {
  1261. if (((Item)o).HandlesOnSpeech)
  1262. onSpeech.Add(o);
  1263. //if (o is Container)
  1264. // AddSpeechItemsFrom(onSpeech, (Container)o);
  1265. }
  1266. }
  1267. //eable.Free();
  1268. object mutateContext = null;
  1269. string mutatedText = text;
  1270. SpeechEventArgs mutatedArgs = null;
  1271. if (MutateSpeech(hears, ref mutatedText, ref mutateContext))
  1272. mutatedArgs = new SpeechEventArgs(this, mutatedText, type, hue, new int[0]);
  1273. CheckSpeechManifest();
  1274. ProcessDelta();
  1275. Packet regp = null;
  1276. Packet mutp = null;
  1277. for (int i = 0; i < hears.Count; ++i)
  1278. {
  1279. Mobile heard = (Mobile)hears[i];
  1280. //SendPropertiesTo(heard);
  1281. if (mutatedArgs == null || !CheckHearsMutatedSpeech(heard, mutateContext))
  1282. {
  1283. heard.OnSpeech(regArgs);
  1284. NetState ns = heard.NetState;
  1285. if (ns != null)
  1286. {
  1287. string name = Name;
  1288. RacePlayerMobile pmf = (RacePlayerMobile)(ns.Mobile);
  1289. if (pmf.Capacities[CapacityName.Lore].Value < Erudition)
  1290. {//pas érudit
  1291. name = "Créature";
  1292. }
  1293. if (type == MessageType.Yell)
  1294. {
  1295. regp = new UnicodeMessage(this.Serial, Body, type, this.EmoteHue, 3, this.Language, name, "*crie*");
  1296. regp = new UnicodeMessage(this.Serial, Body, type, hue, 3, this.Language, name, text);
  1297. }
  1298. else if (type == MessageType.Whisper)
  1299. {
  1300. regp = new UnicodeMessage(this.Serial, Body, type, this.EmoteHue, 3, this.Language, name, "*murmure*");
  1301. regp = new UnicodeMessage(this.Serial, Body, type, hue, 3, this.Language, name, text);
  1302. }
  1303. else
  1304. regp = new UnicodeMessage(this.Serial, Body, type, hue, 3, this.Language, name, text);
  1305. if (regp == null)
  1306. {
  1307. // string name = Name;
  1308. // name = this.TrouverNom(heard.Serial.Value);
  1309. // if (name == "-1")
  1310. //{
  1311. // if (this.Female)
  1312. // name = "Inconnue";
  1313. // else
  1314. // name = "Inconnu";
  1315. // }
  1316. //regp = new UnicodeMessage(this.Serial, Body, type, hue, 3, this.Language, Convert.ToString(this.Serial.Value) + " à " + Convert.ToString(heard.Serial.Value), text);
  1317. }
  1318. ns.Send(regp);
  1319. }
  1320. }
  1321. else
  1322. {
  1323. heard.OnSpeech(mutatedArgs);
  1324. NetState ns = heard.NetState;
  1325. if (ns != null)
  1326. {
  1327. //if (mutp == null)
  1328. // {
  1329. string name = Name;
  1330. RacePlayerMobile pmf = (RacePlayerMobile)(ns.Mobile);
  1331. if (pmf.Capacities[CapacityName.Lore].Value < Erudition)
  1332. {//pas érudit
  1333. name = "Créature";
  1334. }
  1335. mutp = new UnicodeMessage(this.Serial, Body, type, hue, 3, this.Language, name, mutatedText);
  1336. // }
  1337. ns.Send(mutp);
  1338. }
  1339. }
  1340. }
  1341. //if (onSpeech.Count > 1)
  1342. // onSpeech.Sort(LocationComparer.GetInstance(this));
  1343. for (int i = 0; i < onSpeech.Count; ++i)
  1344. {
  1345. object obj = onSpeech[i];
  1346. if (obj is Mobile)
  1347. {
  1348. Mobile heard = (Mobile)obj;
  1349. if (mutatedArgs == null || !CheckHearsMutatedSpeech(heard, mutateContext))
  1350. heard.OnSpeech(regArgs);
  1351. else
  1352. heard.OnSpeech(mutatedArgs);
  1353. }
  1354. else
  1355. {
  1356. Item item = (Item)obj;
  1357. item.OnSpeech(regArgs);
  1358. }
  1359. }
  1360. }
  1361. }
  1362. #endregion
  1363. public virtual bool IsHumanInTown()
  1364. {
  1365. return (Body.IsHuman && Region is Regions.GuardedRegion);
  1366. }
  1367. public virtual bool CheckGold(Mobile from, Item dropped)
  1368. {
  1369. if (dropped is Gold)
  1370. return OnGoldGiven(from, (Gold)dropped);
  1371. return false;
  1372. }
  1373. public virtual bool OnGoldGiven(Mobile from, Gold dropped)
  1374. {
  1375. if (CheckTeachingMatch(from))
  1376. {
  1377. if (Teach(m_Teaching, from, dropped.Amount, true))
  1378. {
  1379. dropped.Delete();
  1380. return true;
  1381. }
  1382. }
  1383. else if (IsHumanInTown())
  1384. {
  1385. Direction = GetDirectionTo(from);
  1386. int oldSpeechHue = this.SpeechHue;
  1387. this.SpeechHue = 0x23F;
  1388. SayTo(from, "Vous me donnez ça?");
  1389. if (dropped.Amount >= 400)
  1390. SayTo(from, "Hoo, c't'un bon cadeau.");
  1391. else
  1392. SayTo(from, "L'écus sont toujours bienvenus.");
  1393. this.SpeechHue = 0x3B2;
  1394. SayTo(from, 501548); // I thank thee.
  1395. this.SpeechHue = oldSpeechHue;
  1396. dropped.Delete();
  1397. return true;
  1398. }
  1399. return false;
  1400. }
  1401. public override bool ShouldCheckStatTimers { get { return false; } }
  1402. private static Type[] m_Eggs = new Type[]
  1403. {
  1404. typeof( FriedEggs ), typeof( Eggs )
  1405. };
  1406. private static Type[] m_Fish = new Type[]
  1407. {
  1408. typeof( FishSteak ), typeof( RawFishSteak )
  1409. };
  1410. private static Type[] m_GrainsAndHay = new Type[]
  1411. {
  1412. typeof( BreadLoaf ), typeof( FrenchBread )
  1413. };
  1414. private static Type[] m_Meat = new Type[]
  1415. {
  1416. /* Cooked */
  1417. typeof( Bacon ), typeof( CookedBird ), typeof( Sausage ),
  1418. typeof( Ham ), typeof( Ribs ), typeof( LambLeg ),
  1419. typeof( ChickenLeg ),
  1420. /* Uncooked */
  1421. typeof( RawBird ), typeof( RawRibs ), typeof( RawLambLeg ),
  1422. typeof( RawChickenLeg ),
  1423. /* Body Parts */
  1424. typeof( Head ), typeof( LeftArm ), typeof( LeftLeg ),
  1425. typeof( Torso ), typeof( RightArm ), typeof( RightLeg )
  1426. };
  1427. private static Type[] m_FruitsAndVegies = new Type[]
  1428. {
  1429. typeof( HoneydewMelon ), typeof( YellowGourd ), typeof( GreenGourd ),
  1430. typeof( Banana ), typeof( Bananas ), typeof( Lemon ), typeof( Lime ),
  1431. typeof( Dates ), typeof( Grapes ), typeof( Peach ), typeof( Pear ),
  1432. typeof( Apple ), typeof( Watermelon ), typeof( Squash ),
  1433. typeof( Cantaloupe ), typeof( Carrot ), typeof( Cabbage ),
  1434. typeof( Onion ), typeof( Lettuce ), typeof( Pumpkin )
  1435. };
  1436. private static Type[] m_Gold = new Type[]
  1437. {
  1438. // white wyrms eat gold..
  1439. typeof( Gold )
  1440. };
  1441. public virtual bool CheckFoodPreference(Item f)
  1442. {
  1443. if (CheckFoodPreference(f, FoodType.Eggs, m_Eggs))
  1444. return true;
  1445. if (CheckFoodPreference(f, FoodType.Fish, m_Fish))
  1446. return true;
  1447. if (CheckFoodPreference(f, FoodType.GrainsAndHay, m_GrainsAndHay))
  1448. return true;
  1449. if (CheckFoodPreference(f, FoodType.Meat, m_Meat))
  1450. return true;
  1451. if (CheckFoodPreference(f, FoodType.FruitsAndVegies, m_FruitsAndVegies))
  1452. return true;
  1453. if (CheckFoodPreference(f, FoodType.Gold, m_Gold))
  1454. return true;
  1455. return false;
  1456. }
  1457. public virtual bool CheckFoodPreference(Item fed, FoodType type, Type[] types)
  1458. {
  1459. if ((FavoriteFood & type) == 0)
  1460. return false;
  1461. Type fedType = fed.GetType();
  1462. bool contains = false;
  1463. for (int i = 0; !contains && i < types.Length; ++i)
  1464. contains = (fedType == types[i]);
  1465. return contains;
  1466. }
  1467. public virtual bool CheckFeed(Mobile from, Item dropped)
  1468. {
  1469. if (!IsDeadPet && Controled && ControlMaster == from && (dropped is Food || dropped is Gold || dropped is CookableFood || dropped is Head || dropped is LeftArm || dropped is LeftLeg || dropped is Torso || dropped is RightArm || dropped is RightLeg))
  1470. {
  1471. Item f = dropped;
  1472. if (CheckFoodPreference(f))
  1473. {
  1474. int amount = f.Amount;
  1475. if (amount > 0)
  1476. {
  1477. bool happier = false;
  1478. int stamGain;
  1479. if (f is Gold)
  1480. stamGain = amount - 50;
  1481. else
  1482. stamGain = (amount * 15) - 50;
  1483. if (stamGain > 0)
  1484. Stam += stamGain;
  1485. for (int i = 0; i < amount; ++i)
  1486. {
  1487. if (m_Loyalty < PetLoyalty.WonderfullyHappy && 0.5 >= Utility.RandomDouble())
  1488. {
  1489. ++m_Loyalty;
  1490. happier = true;
  1491. }
  1492. }
  1493. if (happier)
  1494. SayTo(from, 502060); // Your pet looks happier.
  1495. if (Body.IsAnimal)
  1496. Animate(3, 5, 1, true, false, 0);
  1497. else if (Body.IsMonster)
  1498. Animate(17, 5, 1, true, false, 0);
  1499. if (IsBondable && !IsBonded)
  1500. {
  1501. Mobile master = m_ControlMaster;
  1502. if (master != null)
  1503. {
  1504. if (m_dMinTameSkill <= 29.1 || master.Skills[SkillName.AnimalTaming].Value >= m_dMinTameSkill || this is SwampDragon || this is Ridgeback || this is SavageRidgeback)
  1505. {
  1506. if (BondingBegin == DateTime.MinValue)
  1507. {
  1508. BondingBegin = DateTime.Now;
  1509. }
  1510. else if ((BondingBegin + BondingDelay) <= DateTime.Now)
  1511. {
  1512. IsBonded = true;
  1513. BondingBegin = DateTime.MinValue;
  1514. from.SendLocalizedMessage(1049666); // Your pet has bonded with you!
  1515. }
  1516. }
  1517. }
  1518. }
  1519. dropped.Delete();
  1520. return true;
  1521. }
  1522. }
  1523. }
  1524. return false;
  1525. }
  1526. public virtual void OnActionWander()
  1527. {
  1528. }
  1529. public virtual void OnActionCombat()
  1530. {
  1531. }
  1532. public virtual void OnActionGuard()
  1533. {
  1534. }
  1535. public virtual void OnActionFlee()
  1536. {
  1537. }
  1538. public virtual void OnActionInteract()
  1539. {
  1540. }
  1541. public virtual void OnActionBackoff()
  1542. {
  1543. }
  1544. public override bool OnDragDrop(Mobile from, Item dropped)
  1545. {
  1546. if (CheckFeed(from, dropped))
  1547. return true;
  1548. else if (CheckGold(from, dropped))
  1549. return true;
  1550. return base.OnDragDrop(from, dropped);
  1551. }
  1552. public virtual void ChangeAIType(AIType NewAI)
  1553. {
  1554. if (m_AI != null)
  1555. m_AI.m_Timer.Stop();
  1556. m_AI = null;
  1557. switch (NewAI)
  1558. {
  1559. case AIType.AI_Melee:
  1560. m_AI = new MeleeAI(this);
  1561. break;
  1562. case AIType.AI_CriminalsGuard:
  1563. m_AI = new CriminalsGuardAI(this);
  1564. break;
  1565. case AIType.AI_Animal:
  1566. m_AI = new AnimalAI(this);
  1567. break;
  1568. case AIType.AI_Berserk:
  1569. m_AI = new BerserkAI(this);
  1570. break;
  1571. case AIType.AI_Archer:
  1572. m_AI = new ArcherAI(this);
  1573. break;
  1574. case AIType.AI_Healer:
  1575. m_AI = new HealerAI(this);
  1576. break;
  1577. case AIType.AI_Vendor:
  1578. m_AI = new VendorAI(this);
  1579. break;
  1580. case AIType.AI_Mage:
  1581. m_AI = new MageAI(this);
  1582. break;
  1583. case AIType.AI_Predator:
  1584. //m_AI = new PredatorAI(this);
  1585. m_AI = new MeleeAI(this);
  1586. break;
  1587. case AIType.AI_Thief:
  1588. m_AI = new ThiefAI(this);
  1589. break;
  1590. }
  1591. }
  1592. public virtual void ChangeAIToDefault()
  1593. {
  1594. ChangeAIType(m_DefaultAI);
  1595. }
  1596. [CommandProperty(AccessLevel.GameMaster)]
  1597. public AIType AI
  1598. {
  1599. get
  1600. {
  1601. return m_CurrentAI;
  1602. }
  1603. set
  1604. {
  1605. m_CurrentAI = value;
  1606. if (m_CurrentAI == AIType.AI_Use_Default)
  1607. {
  1608. m_CurrentAI = m_DefaultAI;
  1609. }
  1610. ChangeAIType(m_CurrentAI);
  1611. }
  1612. }
  1613. [CommandProperty(AccessLevel.Administrator)]
  1614. public bool Debug
  1615. {
  1616. get
  1617. {
  1618. return m_bDebugAI;
  1619. }
  1620. set
  1621. {
  1622. m_bDebugAI = value;
  1623. }
  1624. }
  1625. [CommandProperty(AccessLevel.GameMaster)]
  1626. public int Team
  1627. {
  1628. get
  1629. {
  1630. return m_iTeam;
  1631. }
  1632. set
  1633. {
  1634. m_iTeam = value;
  1635. OnTeamChange();
  1636. }
  1637. }
  1638. public virtual void OnTeamChange()
  1639. {
  1640. }
  1641. [CommandProperty(AccessLevel.GameMaster)]
  1642. public Mobile FocusMob
  1643. {
  1644. get
  1645. {
  1646. return m_FocusMob;
  1647. }
  1648. set
  1649. {
  1650. m_FocusMob = value;
  1651. }
  1652. }
  1653. [CommandProperty(AccessLevel.GameMaster)]
  1654. public FightMode FightMode
  1655. {
  1656. get
  1657. {
  1658. return m_FightMode;
  1659. }
  1660. set
  1661. {
  1662. m_FightMode = value;
  1663. }
  1664. }
  1665. [CommandProperty(AccessLevel.GameMaster)]
  1666. public int RangePerception
  1667. {
  1668. get
  1669. {
  1670. return m_iRangePerception;
  1671. }
  1672. set
  1673. {
  1674. m_iRangePerception = value;
  1675. }
  1676. }
  1677. [CommandProperty(AccessLevel.GameMaster)]
  1678. public int RangeFight
  1679. {
  1680. get
  1681. {
  1682. return m_iRangeFight;
  1683. }
  1684. set
  1685. {
  1686. m_iRangeFight = value;
  1687. }
  1688. }
  1689. [CommandProperty(AccessLevel.GameMaster)]
  1690. public int RangeHome
  1691. {
  1692. get
  1693. {
  1694. return m_iRangeHome;
  1695. }
  1696. set
  1697. {
  1698. m_iRangeHome = value;
  1699. }
  1700. }
  1701. [CommandProperty(AccessLevel.GameMaster)]
  1702. public double ActiveSpeed
  1703. {
  1704. get
  1705. {
  1706. return m_dActiveSpeed;
  1707. }
  1708. set
  1709. {
  1710. m_dActiveSpeed = value;
  1711. }
  1712. }
  1713. [CommandProperty(AccessLevel.GameMaster)]
  1714. public double PassiveSpeed
  1715. {
  1716. get
  1717. {
  1718. return m_dPassiveSpeed;
  1719. }
  1720. set
  1721. {
  1722. m_dPassiveSpeed = value;
  1723. }
  1724. }
  1725. [CommandProperty(AccessLevel.GameMaster)]
  1726. public double CurrentSpeed
  1727. {
  1728. get
  1729. {
  1730. return m_dCurrentSpeed;
  1731. }
  1732. set
  1733. {
  1734. if (m_dCurrentSpeed != value)
  1735. {
  1736. m_dCurrentSpeed = value;
  1737. if (m_AI != null)
  1738. m_AI.OnCurrentSpeedChanged();
  1739. }
  1740. }
  1741. }
  1742. [CommandProperty(AccessLevel.GameMaster)]
  1743. public Point3D Home
  1744. {
  1745. get
  1746. {
  1747. return m_pHome;
  1748. }
  1749. set
  1750. {
  1751. m_pHome = value;
  1752. }
  1753. }
  1754. [CommandProperty(AccessLevel.GameMaster)]
  1755. public bool Controled
  1756. {
  1757. get
  1758. {
  1759. return m_bControled;
  1760. }
  1761. set
  1762. {
  1763. if (m_bControled == value)
  1764. return;
  1765. m_bControled = value;
  1766. Delta(MobileDelta.Noto);
  1767. InvalidateProperties();
  1768. }
  1769. }
  1770. public override void RevealingAction()
  1771. {
  1772. Spells.Sixth.InvisibilitySpell.RemoveTimer(this);
  1773. base.RevealingAction();
  1774. }
  1775. public void RemoveFollowers()
  1776. {
  1777. if (m_ControlMaster != null)
  1778. m_ControlMaster.Followers -= ControlSlots;
  1779. else if (m_SummonMaster != null)
  1780. m_SummonMaster.Followers -= ControlSlots;
  1781. if (m_ControlMaster != null && m_ControlMaster.Followers < 0)
  1782. m_ControlMaster.Followers = 0;
  1783. if (m_SummonMaster != null && m_SummonMaster.Followers < 0)
  1784. m_SummonMaster.Followers = 0;
  1785. }
  1786. public void AddFollowers()
  1787. {
  1788. if (m_ControlMaster != null)
  1789. m_ControlMaster.Followers += ControlSlots;
  1790. else if (m_SummonMaster != null)
  1791. m_SummonMaster.Followers += ControlSlots;
  1792. }
  1793. [CommandProperty(AccessLevel.GameMaster)]
  1794. public Mobile ControlMaster
  1795. {
  1796. get
  1797. {
  1798. return m_ControlMaster;
  1799. }
  1800. set
  1801. {
  1802. if (m_ControlMaster == value)
  1803. return;
  1804. RemoveFollowers();
  1805. m_ControlMaster = value;
  1806. AddFollowers();
  1807. Delta(MobileDelta.Noto);
  1808. }
  1809. }
  1810. [CommandProperty(AccessLevel.GameMaster)]
  1811. public Mobile SummonMaster
  1812. {
  1813. get
  1814. {
  1815. return m_SummonMaster;
  1816. }
  1817. set
  1818. {
  1819. if (m_SummonMaster == value)
  1820. return;
  1821. RemoveFollowers();
  1822. m_SummonMaster = value;
  1823. AddFollowers();
  1824. Delta(MobileDelta.Noto);
  1825. }
  1826. }
  1827. [CommandProperty(AccessLevel.GameMaster)]
  1828. public Mobile ControlTarget
  1829. {
  1830. get
  1831. {
  1832. return m_ControlTarget;
  1833. }
  1834. set
  1835. {
  1836. m_ControlTarget = value;
  1837. }
  1838. }
  1839. [CommandProperty(AccessLevel.GameMaster)]
  1840. public Point3D ControlDest
  1841. {
  1842. get
  1843. {
  1844. return m_ControlDest;
  1845. }
  1846. set
  1847. {
  1848. m_ControlDest = value;
  1849. }
  1850. }
  1851. [CommandProperty(AccessLevel.GameMaster)]
  1852. public OrderType ControlOrder
  1853. {
  1854. get
  1855. {
  1856. return m_ControlOrder;
  1857. }
  1858. set
  1859. {
  1860. m_ControlOrder = value;
  1861. if (m_AI != null)
  1862. m_AI.OnCurrentOrderChanged();
  1863. }
  1864. }
  1865. [CommandProperty(AccessLevel.GameMaster)]
  1866. public bool BardProvoked
  1867. {
  1868. get
  1869. {
  1870. return m_bBardProvoked;
  1871. }
  1872. set
  1873. {
  1874. m_bBardProvoked = value;
  1875. }
  1876. }
  1877. [CommandProperty(AccessLevel.GameMaster)]
  1878. public bool BardPacified
  1879. {
  1880. get
  1881. {
  1882. return m_bBardPacified;
  1883. }
  1884. set
  1885. {
  1886. m_bBardPacified = value;
  1887. }
  1888. }
  1889. [CommandProperty(AccessLevel.GameMaster)]
  1890. public Mobile BardMaster
  1891. {
  1892. get
  1893. {
  1894. return m_bBardMaster;
  1895. }
  1896. set
  1897. {
  1898. m_bBardMaster = value;
  1899. }
  1900. }
  1901. [CommandProperty(AccessLevel.GameMaster)]
  1902. public Mobile BardTarget
  1903. {
  1904. get
  1905. {
  1906. return m_bBardTarget;
  1907. }
  1908. set
  1909. {
  1910. m_bBardTarget = value;
  1911. }
  1912. }
  1913. [CommandProperty(AccessLevel.GameMaster)]
  1914. public DateTime BardEndTime
  1915. {
  1916. get
  1917. {
  1918. return m_timeBardEnd;
  1919. }
  1920. set
  1921. {
  1922. m_timeBardEnd = value;
  1923. }
  1924. }
  1925. [CommandProperty(AccessLevel.GameMaster)]
  1926. public double MinTameSkill
  1927. {
  1928. get
  1929. {
  1930. return m_dMinTameSkill;
  1931. }
  1932. set
  1933. {
  1934. m_dMinTameSkill = value;
  1935. }
  1936. }
  1937. [CommandProperty(AccessLevel.GameMaster)]
  1938. public bool Tamable
  1939. {
  1940. get
  1941. {
  1942. return m_bTamable;
  1943. }
  1944. set
  1945. {
  1946. m_bTamable = value;
  1947. }
  1948. }
  1949. [CommandProperty(AccessLevel.Administrator)]
  1950. public bool Summoned
  1951. {
  1952. get
  1953. {
  1954. return m_bSummoned;
  1955. }
  1956. set
  1957. {
  1958. if (m_bSummoned == value)
  1959. return;
  1960. m_NextReaquireTime = DateTime.Now;
  1961. m_bSummoned = value;
  1962. Delta(MobileDelta.Noto);
  1963. InvalidateProperties();
  1964. }
  1965. }
  1966. [CommandProperty(AccessLevel.Administrator)]
  1967. public int ControlSlots
  1968. {
  1969. get
  1970. {
  1971. return m_iControlSlots;
  1972. }
  1973. set
  1974. {
  1975. m_iControlSlots = value;
  1976. }
  1977. }
  1978. public virtual bool NoHouseRestrictions { get { return false; } }
  1979. public virtual bool IsHouseSummonable { get { return false; } }
  1980. public virtual int Feathers { get { return 0; } }
  1981. public virtual int Wool { get { return 0; } }
  1982. public virtual MeatType MeatType { get { return MeatType.Ribs; } }
  1983. public virtual int Meat { get { return 0; } }
  1984. public virtual int Hides { get { return 0; } }
  1985. public virtual HideType HideType { get { return HideType.Regular; } }
  1986. public virtual int Scales { get { return 0; } }
  1987. public virtual ScaleType ScaleType { get { return ScaleType.Red; } }
  1988. public virtual bool AutoDispel { get { return false; } }
  1989. public virtual bool IsScaryToPets { get { return false; } }
  1990. public virtual bool IsScaredOfScaryThings { get { return true; } }
  1991. public virtual bool CanRummageCorpses { get { return false; } }
  1992. public virtual void OnGotMeleeAttack(Mobile attacker)
  1993. {
  1994. if (AutoDispel && attacker is BaseCreature && ((BaseCreature)attacker).Summoned && !((BaseCreature)attacker).IsAnimatedDead)
  1995. Dispel(attacker);
  1996. }
  1997. public virtual void Dispel(Mobile m)
  1998. {
  1999. Effects.SendLocationParticles(EffectItem.Create(m.Location, m.Map, EffectItem.DefaultDuration), 0x3728, 8, 20, 5042);
  2000. Effects.PlaySound(m, m.Map, 0x201);
  2001. m.Delete();
  2002. }
  2003. public virtual bool DeleteOnRelease { get { return m_bSummoned; } }
  2004. public virtual void OnGaveMeleeAttack(Mobile defender)
  2005. {
  2006. Poison p = HitPoison;
  2007. if (p != null && HitPoisonChance >= Utility.RandomDouble())
  2008. defender.ApplyPoison(this, p);
  2009. if (AutoDispel && defender is BaseCreature && ((BaseCreature)defender).Summoned && !((BaseCreature)defender).IsAnimatedDead)
  2010. Dispel(defender);
  2011. }
  2012. public override void OnAfterDelete()
  2013. {
  2014. if (m_AI != null)
  2015. {
  2016. if (m_AI.m_Timer != null)
  2017. m_AI.m_Timer.Stop();
  2018. m_AI = null;
  2019. }
  2020. FocusMob = null;
  2021. if (IsAnimatedDead)
  2022. Spells.Necromancy.AnimateDeadSpell.Unregister(m_SummonMaster, this);
  2023. base.OnAfterDelete();
  2024. }
  2025. public void DebugSay(string text)
  2026. {
  2027. if (m_bDebugAI)
  2028. this.PublicOverheadMessage(MessageType.Regular, 41, false, text);
  2029. }
  2030. public void DebugSay(string format, params object[] args)
  2031. {
  2032. if (m_bDebugAI)
  2033. this.PublicOverheadMessage(MessageType.Regular, 41, false, String.Format(format, args));
  2034. }
  2035. /*
  2036. * Will need to be givent a better name
  2037. *
  2038. * This function can be overriden.. so a "Strongest" mobile, can have a different definition depending
  2039. * on who check for value
  2040. * -Could add a FightMode.Prefered
  2041. *
  2042. */
  2043. public virtual double GetValueFrom(Mobile m, FightMode acqType, bool bPlayerOnly)
  2044. {
  2045. if ((bPlayerOnly && m.Player) || !bPlayerOnly)
  2046. {
  2047. switch (acqType)
  2048. {
  2049. case FightMode.Strongest:
  2050. return (m.Skills[SkillName.Tactics].Value + m.Str); //returns strongest mobile
  2051. case FightMode.Weakest:
  2052. return -m.Hits; // returns weakest mobile
  2053. default:
  2054. return -GetDistanceToSqrt(m); // returns closest mobile
  2055. }
  2056. }
  2057. else
  2058. {
  2059. return double.MinValue;
  2060. }
  2061. }
  2062. // Turn, - for let, + for right
  2063. // Basic for now, need works
  2064. public virtual void Turn(int iTurnSteps)
  2065. {
  2066. int v = (int)Direction;
  2067. Direction = (Direction)((((v & 0x7) + iTurnSteps) & 0x7) | (v & 0x80));
  2068. }
  2069. public virtual void TurnInternal(int iTurnSteps)
  2070. {
  2071. int v = (int)Direction;
  2072. SetDirection((Direction)((((v & 0x7) + iTurnSteps) & 0x7) | (v & 0x80)));
  2073. }
  2074. public bool IsHurt()
  2075. {
  2076. return (Hits != HitsMax);
  2077. }
  2078. public double GetHomeDistance()
  2079. {
  2080. return GetDistanceToSqrt(m_pHome);
  2081. }
  2082. public virtual int GetTeamSize(int iRange)
  2083. {
  2084. int iCount = 0;
  2085. foreach (Mobile m in this.GetMobilesInRange(iRange))
  2086. {
  2087. if (m is BaseCreature)
  2088. {
  2089. if (((BaseCreature)m).Team == Team)
  2090. {
  2091. if (!m.Deleted)
  2092. {
  2093. if (m != this)
  2094. {
  2095. if (CanSee(m))
  2096. {
  2097. iCount++;
  2098. }
  2099. }
  2100. }
  2101. }
  2102. }
  2103. }
  2104. return iCount;
  2105. }
  2106. // Do my combatant is attaking me??
  2107. public bool IsCombatantAnAgressor()
  2108. {
  2109. if (Combatant != null)
  2110. {
  2111. if (Combatant.Combatant == this)
  2112. {
  2113. return true;
  2114. }
  2115. }
  2116. return false;
  2117. }
  2118. private class TameEntry : ContextMenuEntry
  2119. {
  2120. private BaseCreature m_Mobile;
  2121. public TameEntry(Mobile from, BaseCreature creature)
  2122. : base(6130, 6)
  2123. {
  2124. m_Mobile = creature;
  2125. Enabled = Enabled && (from.Female ? creature.AllowFemaleTamer : creature.AllowMaleTamer);
  2126. }
  2127. public override void OnClick()
  2128. {
  2129. if (!Owner.From.CheckAlive())
  2130. return;
  2131. Owner.From.TargetLocked = true;
  2132. SkillHandlers.AnimalTaming.DisableMessage = true;
  2133. if (Owner.From.UseSkill(SkillName.AnimalTaming))
  2134. Owner.From.Target.Invoke(Owner.From, m_Mobile);
  2135. SkillHandlers.AnimalTaming.DisableMessage = false;
  2136. Owner.From.TargetLocked = false;
  2137. }
  2138. }
  2139. public virtual bool CanTeach { get { return false; } }
  2140. public virtual bool CheckTeach(SkillName skill, Mobile from)
  2141. {
  2142. if (!CanTeach)
  2143. return false;
  2144. if (skill == SkillName.Stealth && from.Skills[SkillName.Hiding].Base < 80.0)
  2145. return false;
  2146. if (skill == SkillName.RemoveTrap && (from.Skills[SkillName.Lockpicking].Base < 50.0 || from.Skills[SkillName.DetectHidden].Base < 50.0))
  2147. return false;
  2148. if (!Core.AOS && (skill == SkillName.Focus || skill == SkillName.Chivalry || skill == SkillName.Necromancy))
  2149. return false;
  2150. return true;
  2151. }
  2152. public enum TeachResult
  2153. {
  2154. Success,
  2155. Failure,
  2156. KnowsMoreThanMe,
  2157. KnowsWhatIKnow,
  2158. SkillNotRaisable,
  2159. NotEnoughFreePoints
  2160. }
  2161. public virtual TeachResult CheckTeachSkills(SkillName skill, Mobile m, int maxPointsToLearn, ref int pointsToLearn, bool doTeach)
  2162. {
  2163. if (!CheckTeach(skill, m) || !m.CheckAlive())
  2164. return TeachResult.Failure;
  2165. Skill ourSkill = Skills[skill];
  2166. Skill theirSkill = m.Skills[skill];
  2167. if (ourSkill == null || theirSkill == null)
  2168. return TeachResult.Failure;
  2169. int baseToSet = ourSkill.BaseFixedPoint / 3;
  2170. if (baseToSet > 420)
  2171. baseToSet = 420;
  2172. else if (baseToSet < 200)
  2173. return TeachResult.Failure;
  2174. if (baseToSet > theirSkill.CapFixedPoint)
  2175. baseToSet = theirSkill.CapFixedPoint;
  2176. pointsToLearn = baseToSet - theirSkill.BaseFixedPoint;
  2177. if (maxPointsToLearn > 0 && pointsToLearn > maxPointsToLearn)
  2178. {
  2179. pointsToLearn = maxPointsToLearn;
  2180. baseToSet = theirSkill.BaseFixedPoint + pointsToLearn;
  2181. }
  2182. if (pointsToLearn < 0)
  2183. return TeachResult.KnowsMoreThanMe;
  2184. if (pointsToLearn == 0)
  2185. return TeachResult.KnowsWhatIKnow;
  2186. if (theirSkill.Lock != SkillLock.Up)
  2187. return TeachResult.SkillNotRaisable;
  2188. int freePoints = m.Skills.Cap - m.Skills.Total;
  2189. int freeablePoints = 0;
  2190. if (freePoints < 0)
  2191. freePoints = 0;
  2192. for (int i = 0; (freePoints + freeablePoints) < pointsToLearn && i < m.Skills.Length; ++i)
  2193. {
  2194. Skill sk = m.Skills[i];
  2195. if (sk == theirSkill || sk.Lock != SkillLock.Down)
  2196. continue;
  2197. freeablePoints += sk.BaseFixedPoint;
  2198. }
  2199. if ((freePoints + freeablePoints) == 0)
  2200. return TeachResult.NotEnoughFreePoints;
  2201. if ((freePoints + freeablePoints) < pointsToLearn)
  2202. {
  2203. pointsToLearn = freePoints + freeablePoints;
  2204. baseToSet = theirSkill.BaseFixedPoint + pointsToLearn;
  2205. }
  2206. if (doTeach)
  2207. {
  2208. int need = pointsToLearn - freePoints;
  2209. for (int i = 0; need > 0 && i < m.Skills.Length; ++i)
  2210. {
  2211. Skill sk = m.Skills[i];
  2212. if (sk == theirSkill || sk.Lock != SkillLock.Down)
  2213. continue;
  2214. if (sk.BaseFixedPoint < need)
  2215. {
  2216. need -= sk.BaseFixedPoint;
  2217. sk.BaseFixedPoint = 0;
  2218. }
  2219. else
  2220. {
  2221. sk.BaseFixedPoint -= need;
  2222. need = 0;
  2223. }
  2224. }
  2225. /* Sanity check */
  2226. if (baseToSet > theirSkill.CapFixedPoint || (m.Skills.Total - theirSkill.BaseFixedPoint + baseToSet) > m.Skills.Cap)
  2227. return TeachResult.NotEnoughFreePoints;
  2228. theirSkill.BaseFixedPoint = baseToSet;
  2229. }
  2230. return TeachResult.Success;
  2231. }
  2232. public virtual bool CheckTeachingMatch(Mobile m)
  2233. {
  2234. if (m_Teaching == (SkillName)(-1))
  2235. return false;
  2236. if (m is PlayerMobile)
  2237. return (((PlayerMobile)m).Learning == m_Teaching);
  2238. return true;
  2239. }
  2240. private SkillName m_Teaching = (SkillName)(-1);
  2241. public virtual bool Teach(SkillName skill, Mobile m, int maxPointsToLearn, bool doTeach)
  2242. {
  2243. int pointsToLearn = 0;
  2244. TeachResult res = CheckTeachSkills(skill, m, maxPointsToLearn, ref pointsToLearn, doTeach);
  2245. switch (res)
  2246. {
  2247. case TeachResult.KnowsMoreThanMe:
  2248. {
  2249. Say(501508); // I cannot teach thee, for thou knowest more than I!
  2250. break;
  2251. }
  2252. case TeachResult.KnowsWhatIKnow:
  2253. {
  2254. Say(501509); // I cannot teach thee, for thou knowest all I can teach!
  2255. break;
  2256. }
  2257. case TeachResult.NotEnoughFreePoints:
  2258. case TeachResult.SkillNotRaisable:
  2259. {
  2260. // Make sure this skill is marked to raise. If you are near the skill cap (700 points) you may need to lose some points in another skill first.
  2261. m.SendLocalizedMessage(501510, "", 0x22);
  2262. break;
  2263. }
  2264. case TeachResult.Success:
  2265. {
  2266. if (doTeach)
  2267. {
  2268. Say(501539); // Let me show thee something of how this is done.
  2269. m.SendLocalizedMessage(501540); // Your skill level increases.
  2270. m_Teaching = (SkillName)(-1);
  2271. if (m is PlayerMobile)
  2272. ((PlayerMobile)m).Learning = (SkillName)(-1);
  2273. }
  2274. else
  2275. {
  2276. // I will teach thee all I know, if paid the amount in full. The price is:
  2277. Say(1019077, AffixType.Append, String.Format(" {0}", pointsToLearn), "");
  2278. Say(1043108); // For less I shall teach thee less.
  2279. m_Teaching = skill;
  2280. if (m is PlayerMobile)
  2281. ((PlayerMobile)m).Learning = skill;
  2282. }
  2283. return true;
  2284. }
  2285. }
  2286. return false;
  2287. }
  2288. public override void AggressiveAction(Mobile aggressor, bool criminal)
  2289. {
  2290. base.AggressiveAction(aggressor, criminal);
  2291. StopFlee();
  2292. ForceReaquire();
  2293. OrderType ct = m_ControlOrder;
  2294. if (aggressor.ChangingCombatant && (m_bControled || m_bSummoned) && (ct == OrderType.Come || ct == OrderType.Stay || ct == OrderType.Stop || ct == OrderType.None || ct == OrderType.Follow))
  2295. {
  2296. ControlTarget = aggressor;
  2297. ControlOrder = OrderType.Attack;
  2298. }
  2299. }
  2300. public virtual void AddCustomContextEntries(Mobile from, List<ContextMenuEntry> list)
  2301. {
  2302. }
  2303. public override void GetContextMenuEntries(Mobile from, List<ContextMenuEntry> list)
  2304. {
  2305. base.GetContextMenuEntries(from, list);
  2306. if (m_AI != null && Commandable)
  2307. m_AI.GetContextMenuEntries(from, list);
  2308. if (m_bTamable && !m_bControled && from.Alive)
  2309. list.Add(new TameEntry(from, this));
  2310. AddCustomContextEntries(from, list);
  2311. if (CanTeach && from.Alive)
  2312. {
  2313. Skills ourSkills = this.Skills;
  2314. Skills theirSkills = from.Skills;
  2315. for (int i = 0; i < ourSkills.Length && i < theirSkills.Length; ++i)
  2316. {
  2317. Skill skill = ourSkills[i];
  2318. Skill theirSkill = theirSkills[i];
  2319. if (skill != null && theirSkill != null && skill.Base >= 60.0 && CheckTeach(skill.SkillName, from))
  2320. {
  2321. double toTeach = skill.Base / 3.0;
  2322. if (toTeach > 42.0)
  2323. toTeach = 42.0;
  2324. list.Add(new TeachEntry((SkillName)i, this, from, (toTeach > theirSkill.Base)));
  2325. }
  2326. }
  2327. }
  2328. }
  2329. /// <summary>
  2330. /// Ensures that a template is assigned for the creature
  2331. /// </summary>
  2332. public void EnsureTemplateAssigned()
  2333. {
  2334. if (!m_IsSystemInitialized)
  2335. {
  2336. m_IsSystemInitialized = true;
  2337. ManagerConfig.InitializeCreature(this);
  2338. }
  2339. }
  2340. public override bool HandlesOnSpeech(Mobile from)
  2341. {
  2342. InhumanSpeech speechType = this.SpeechType;
  2343. if (speechType != null && (speechType.Flags & IHSFlags.OnSpeech) != 0 && from.InRange(this, 3))
  2344. return true;
  2345. return (m_AI != null && m_AI.HandlesOnSpeech(from) && from.InRange(this, m_iRangePerception));
  2346. }
  2347. public override void OnSpeech(SpeechEventArgs e)
  2348. {
  2349. InhumanSpeech speechType = this.SpeechType;
  2350. if (speechType != null && speechType.OnSpeech(this, e.Mobile, e.Speech))
  2351. e.Handled = true;
  2352. else if (!e.Handled && m_AI != null && e.Mobile.InRange(this, m_iRangePerception))
  2353. m_AI.OnSpeech(e);
  2354. }
  2355. public override bool IsHarmfulCriminal(Mobile target)
  2356. {
  2357. if ((Controled && target == m_ControlMaster) || (Summoned && target == m_SummonMaster))
  2358. return false;
  2359. if (target is BaseCreature && ((BaseCreature)target).InitialInnocent)
  2360. return false;
  2361. if (target is PlayerMobile && ((PlayerMobile)target).PermaFlags.Count > 0)
  2362. return false;
  2363. return base.IsHarmfulCriminal(target);
  2364. }
  2365. public override void CriminalAction(bool message)
  2366. {
  2367. base.CriminalAction(message);
  2368. if ((Controled || Summoned))
  2369. {
  2370. if (m_ControlMaster != null && m_ControlMaster.Player)
  2371. m_ControlMaster.CriminalAction(false);
  2372. else if (m_SummonMaster != null && m_SummonMaster.Player)
  2373. m_SummonMaster.CriminalAction(false);
  2374. }
  2375. }
  2376. public override void DoHarmful(Mobile target, bool indirect)
  2377. {
  2378. base.DoHarmful(target, indirect);
  2379. if (target == this || target == m_ControlMaster || target == m_SummonMaster || (!Controled && !Summoned))
  2380. return;
  2381. ArrayList list = this.Aggressors;
  2382. for (int i = 0; i < list.Count; ++i)
  2383. {
  2384. AggressorInfo ai = (AggressorInfo)list[i];
  2385. if (ai.Attacker == target)
  2386. return;
  2387. }
  2388. list = this.Aggressed;
  2389. for (int i = 0; i < list.Count; ++i)
  2390. {
  2391. AggressorInfo ai = (AggressorInfo)list[i];
  2392. if (ai.Defender == target)
  2393. {
  2394. if (m_ControlMaster != null && m_ControlMaster.Player && m_ControlMaster.CanBeHarmful(target, false))
  2395. m_ControlMaster.DoHarmful(target, true);
  2396. else if (m_SummonMaster != null && m_SummonMaster.Player && m_SummonMaster.CanBeHarmful(target, false))
  2397. m_SummonMaster.DoHarmful(target, true);
  2398. return;
  2399. }
  2400. }
  2401. }
  2402. private static Mobile m_NoDupeGuards;
  2403. public void ReleaseGuardDupeLock()
  2404. {
  2405. m_NoDupeGuards = null;
  2406. }
  2407. public void ReleaseGuardLock()
  2408. {
  2409. EndAction(typeof(GuardedRegion));
  2410. }
  2411. private DateTime m_IdleReleaseTime;
  2412. public virtual bool CheckIdle()
  2413. {
  2414. // Initialize on idling
  2415. EnsureTemplateAssigned();
  2416. if (Combatant != null)
  2417. return false; // in combat.. not idling
  2418. if (m_IdleReleaseTime > DateTime.MinValue)
  2419. {
  2420. // idling...
  2421. if (DateTime.Now >= m_IdleReleaseTime)
  2422. {
  2423. m_IdleReleaseTime = DateTime.MinValue;
  2424. return false; // idle is over
  2425. }
  2426. return true; // still idling
  2427. }
  2428. if (95 > Utility.Random(100))
  2429. return false; // not idling, but don't want to enter idle state
  2430. m_IdleReleaseTime = DateTime.Now + TimeSpan.FromSeconds(Utility.RandomMinMax(15, 25));
  2431. if (Body.IsHuman)
  2432. {
  2433. switch (Utility.Random(2))
  2434. {
  2435. case 0: Animate(5, 5, 1, true, true, 1); break;
  2436. case 1: Animate(6, 5, 1, true, false, 1); break;
  2437. }
  2438. }
  2439. else if (Body.IsAnimal)
  2440. {
  2441. switch (Utility.Random(3))
  2442. {
  2443. case 0: Animate(3, 3, 1, true, false, 1); break;
  2444. case 1: Animate(9, 5, 1, true, false, 1); break;
  2445. case 2: Animate(10, 5, 1, true, false, 1); break;
  2446. }
  2447. }
  2448. else if (Body.IsMonster)
  2449. {
  2450. switch (Utility.Random(2))
  2451. {
  2452. case 0: Animate(17, 5, 1, true, false, 1); break;
  2453. case 1: Animate(18, 5, 1, true, false, 1); break;
  2454. }
  2455. }
  2456. PlaySound(GetIdleSound());
  2457. return true; // entered idle state
  2458. }
  2459. public override void OnMovement(Mobile m, Point3D oldLocation)
  2460. {
  2461. base.OnMovement(m, oldLocation);
  2462. // Initialize on movement
  2463. EnsureTemplateAssigned();
  2464. if (m is RacePlayerMobile && m_SayingsEnabled && DateTime.Now >= m_NextSaying && !m.Hidden) // check if its time to talk
  2465. {
  2466. var rpm = m as RacePlayerMobile;
  2467. if (rpm.AccessLevel == AccessLevel.Player && InRange(m, 2) && !InRange(oldLocation, 2) && InLOS(m)) // check if player in range.
  2468. {
  2469. m_NextSaying = DateTime.Now + m_SayingsDelay; // set next talk time
  2470. if (Utility.Random(3) > 0)
  2471. {
  2472. switch (Utility.Random(5)) // 5 speech options
  2473. {
  2474. case 0: Say(m_Saying1); break;
  2475. case 1: Say(m_Saying2); break;
  2476. case 2: Say(m_Saying3); break;
  2477. case 3: Say(m_Saying4); break;
  2478. case 4: Say(m_Saying5); break;
  2479. };
  2480. }
  2481. }
  2482. }
  2483. if (ReaquireOnMovement)
  2484. ForceReaquire();
  2485. InhumanSpeech speechType = this.SpeechType;
  2486. if (speechType != null)
  2487. speechType.OnMovement(this, m, oldLocation);
  2488. /* Begin notice sound */
  2489. if (m.Player && m_FightMode != FightMode.Agressor && m_FightMode != FightMode.None && Combatant == null && !Controled && !Summoned)
  2490. {
  2491. // If this creature defends itself but doesn't actively attack (animal) or
  2492. // doesn't fight at all (vendor) then no notice sounds are played..
  2493. // So, players are only notified of agressive monsters
  2494. // Monsters that are currently fighting are ignored
  2495. // Controled or summoned creatures are ignored
  2496. if (InRange(m.Location, 18) && !InRange(oldLocation, 18))
  2497. {
  2498. if (Body.IsMonster)
  2499. Animate(11, 5, 1, true, false, 1);
  2500. PlaySound(GetAngerSound());
  2501. }
  2502. }
  2503. /* End notice sound */
  2504. if (m_NoDupeGuards == m)
  2505. return;
  2506. if (!Body.IsHuman || Kills >= 5 || AlwaysMurderer || AlwaysAttackable || m.Kills < 5 || !m.InRange(Location, 12) || !m.Alive)
  2507. return;
  2508. Region reg = this.Region;
  2509. if (reg is GuardedRegion)
  2510. {
  2511. GuardedRegion guardedRegion = (GuardedRegion)reg;
  2512. if (!guardedRegion.IsDisabled() && guardedRegion.IsGuardCandidate(m) && BeginAction(typeof(GuardedRegion)))
  2513. {
  2514. Say(1013037 + Utility.Random(16));
  2515. guardedRegion.CallGuards(this.Location);
  2516. Timer.DelayCall(TimeSpan.FromSeconds(5.0), new TimerCallback(ReleaseGuardLock));
  2517. m_NoDupeGuards = m;
  2518. Timer.DelayCall(TimeSpan.Zero, new TimerCallback(ReleaseGuardDupeLock));
  2519. }
  2520. }
  2521. }
  2522. public void AddSpellAttack(Type type)
  2523. {
  2524. m_arSpellAttack.Add(type);
  2525. }
  2526. public void AddSpellDefense(Type type)
  2527. {
  2528. m_arSpellDefense.Add(type);
  2529. }
  2530. public Spell GetAttackSpellRandom()
  2531. {
  2532. if (m_arSpellAttack.Count > 0)
  2533. {
  2534. Type type = (Type)m_arSpellAttack[Utility.Random(m_arSpellAttack.Count)];
  2535. object[] args = { this, null };
  2536. return Activator.CreateInstance(type, args) as Spell;
  2537. }
  2538. else
  2539. {
  2540. return null;
  2541. }
  2542. }
  2543. public Spell GetDefenseSpellRandom()
  2544. {
  2545. if (m_arSpellDefense.Count > 0)
  2546. {
  2547. Type type = (Type)m_arSpellDefense[Utility.Random(m_arSpellDefense.Count)];
  2548. object[] args = { this, null };
  2549. return Activator.CreateInstance(type, args) as Spell;
  2550. }
  2551. else
  2552. {
  2553. return null;
  2554. }
  2555. }
  2556. public Spell GetSpellSpecific(Type type)
  2557. {
  2558. int i;
  2559. for (i = 0; i < m_arSpellAttack.Count; i++)
  2560. {
  2561. if (m_arSpellAttack[i] == type)
  2562. {
  2563. object[] args = { this, null };
  2564. return Activator.CreateInstance(type, args) as Spell;
  2565. }
  2566. }
  2567. for (i = 0; i < m_arSpellDefense.Count; i++)
  2568. {
  2569. if (m_arSpellDefense[i] == type)
  2570. {
  2571. object[] args = { this, null };
  2572. return Activator.CreateInstance(type, args) as Spell;
  2573. }
  2574. }
  2575. return null;
  2576. }
  2577. public void SetDamage(int val)
  2578. {
  2579. m_DamageMin = val;
  2580. m_DamageMax = val;
  2581. }
  2582. public void SetDamage(int min, int max)
  2583. {
  2584. m_DamageMin = min;
  2585. m_DamageMax = max;
  2586. }
  2587. public void SetHits(int val)
  2588. {
  2589. if (val < 1000 && !Core.AOS)
  2590. val = (val * 100) / 60;
  2591. m_HitsMax = val;
  2592. Hits = HitsMax;
  2593. }
  2594. public void SetHits(int min, int max)
  2595. {
  2596. if (min < 1000 && !Core.AOS)
  2597. {
  2598. min = (min * 100) / 60;
  2599. max = (max * 100) / 60;
  2600. }
  2601. m_HitsMax = Utility.RandomMinMax(min, max);
  2602. Hits = HitsMax;
  2603. }
  2604. public void SetStam(int val)
  2605. {
  2606. m_StamMax = val;
  2607. Stam = StamMax;
  2608. }
  2609. public void SetStam(int min, int max)
  2610. {
  2611. m_StamMax = Utility.RandomMinMax(min, max);
  2612. Stam = StamMax;
  2613. }
  2614. public void SetMana(int val)
  2615. {
  2616. m_ManaMax = val;
  2617. Mana = ManaMax;
  2618. }
  2619. public void SetMana(int min, int max)
  2620. {
  2621. m_ManaMax = Utility.RandomMinMax(min, max);
  2622. Mana = ManaMax;
  2623. }
  2624. public void SetStr(int val)
  2625. {
  2626. RawStr = val;
  2627. Hits = HitsMax;
  2628. }
  2629. public void SetStr(int min, int max)
  2630. {
  2631. RawStr = Utility.RandomMinMax(min, max);
  2632. Hits = HitsMax;
  2633. }
  2634. public void SetDex(int val)
  2635. {
  2636. RawDex = val;
  2637. Stam = StamMax;
  2638. }
  2639. public void SetDex(int min, int max)
  2640. {
  2641. RawDex = Utility.RandomMinMax(min, max);
  2642. Stam = StamMax;
  2643. }
  2644. public void SetInt(int val)
  2645. {
  2646. RawInt = val;
  2647. Mana = ManaMax;
  2648. }
  2649. public void SetInt(int min, int max)
  2650. {
  2651. RawInt = Utility.RandomMinMax(min, max);
  2652. Mana = ManaMax;
  2653. }
  2654. public void SetDamageType(ResistanceType type, int min, int max)
  2655. {
  2656. SetDamageType(type, Utility.RandomMinMax(min, max));
  2657. }
  2658. public void SetDamageType(ResistanceType type, int val)
  2659. {
  2660. switch (type)
  2661. {
  2662. case ResistanceType.Physical: m_PhysicalDamage = val; break;
  2663. case ResistanceType.Fire: m_FireDamage = val; break;
  2664. case ResistanceType.Cold: m_ColdDamage = val; break;
  2665. case ResistanceType.Poison: m_PoisonDamage = val; break;
  2666. case ResistanceType.Energy: m_EnergyDamage = val; break;
  2667. }
  2668. }
  2669. public void SetResistance(ResistanceType type, int min, int max)
  2670. {
  2671. SetResistance(type, Utility.RandomMinMax(min, max));
  2672. }
  2673. public void SetResistance(ResistanceType type, int val)
  2674. {
  2675. switch (type)
  2676. {
  2677. case ResistanceType.Physical: m_PhysicalResistance = val; break;
  2678. case ResistanceType.Fire: m_FireResistance = val; break;
  2679. case ResistanceType.Cold: m_ColdResistance = val; break;
  2680. case ResistanceType.Poison: m_PoisonResistance = val; break;
  2681. case ResistanceType.Energy: m_EnergyResistance = val; break;
  2682. }
  2683. UpdateResistances();
  2684. }
  2685. public void SetSkill(SkillName name, double val)
  2686. {
  2687. Skills[name].BaseFixedPoint = (int)(val * 10);
  2688. }
  2689. public void SetSkill(SkillName name, double min, double max)
  2690. {
  2691. int minFixed = (int)(min * 10);
  2692. int maxFixed = (int)(max * 10);
  2693. Skills[name].BaseFixedPoint = Utility.RandomMinMax(minFixed, maxFixed);
  2694. }
  2695. public void SetFameLevel(int level)
  2696. {
  2697. switch (level)
  2698. {
  2699. case 1: Fame = Utility.RandomMinMax(0, 1249); break;
  2700. case 2: Fame = Utility.RandomMinMax(1250, 2499); break;
  2701. case 3: Fame = Utility.RandomMinMax(2500, 4999); break;
  2702. case 4: Fame = Utility.RandomMinMax(5000, 9999); break;
  2703. case 5: Fame = Utility.RandomMinMax(10000, 10000); break;
  2704. }
  2705. }
  2706. public void SetKarmaLevel(int level)
  2707. {
  2708. switch (level)
  2709. {
  2710. case 0: Karma = -Utility.RandomMinMax(0, 624); break;
  2711. case 1: Karma = -Utility.RandomMinMax(625, 1249); break;
  2712. case 2: Karma = -Utility.RandomMinMax(1250, 2499); break;
  2713. case 3: Karma = -Utility.RandomMinMax(2500, 4999); break;
  2714. case 4: Karma = -Utility.RandomMinMax(5000, 9999); break;
  2715. case 5: Karma = -Utility.RandomMinMax(10000, 10000); break;
  2716. }
  2717. }
  2718. public static void Cap(ref int val, int min, int max)
  2719. {
  2720. if (val < min)
  2721. val = min;
  2722. else if (val > max)
  2723. val = max;
  2724. }
  2725. public void PackPotion()
  2726. {
  2727. PackMagicJewel();
  2728. PackItem(Loot.RandomPotion());
  2729. }
  2730. public void PackScroll(int minCircle, int maxCircle)
  2731. {
  2732. PackScroll(Utility.RandomMinMax(minCircle, maxCircle));
  2733. }
  2734. public void PackScroll(int circle)
  2735. {
  2736. PackMagicJewel();
  2737. int min = (circle - 1) * 8;
  2738. PackItem(Loot.RandomScroll());
  2739. }
  2740. public void PackMagicItems(int minLevel, int maxLevel)
  2741. {
  2742. PackMagicItems(minLevel, maxLevel, 0.30, 0.15);
  2743. }
  2744. public void PackMagicItems(int minLevel, int maxLevel, double armorChance, double weaponChance)
  2745. {
  2746. if (!PackArmor(minLevel, maxLevel, armorChance))
  2747. PackWeapon(minLevel, maxLevel, weaponChance);
  2748. }
  2749. protected bool m_Spawning;
  2750. protected int m_KillersLuck;
  2751. public void GenerateLoot(bool spawning)
  2752. {
  2753. m_Spawning = spawning;
  2754. if (!spawning)
  2755. m_KillersLuck = 0;
  2756. GenerateLoot();
  2757. var type = CreatureType.FindType(this);
  2758. if (!spawning && type != null)
  2759. {
  2760. Container backpack = Backpack;
  2761. if (backpack == null)
  2762. {
  2763. backpack = new Backpack();
  2764. backpack.Movable = false;
  2765. AddItem(backpack);
  2766. }
  2767. type.Loot.Generate(this, backpack, LootLevel);
  2768. }
  2769. m_Spawning = false;
  2770. m_KillersLuck = 0;
  2771. }
  2772. public virtual void GenerateLoot()
  2773. {
  2774. }
  2775. public bool PackArmor(int minLevel, int maxLevel)
  2776. {
  2777. return PackArmor(minLevel, maxLevel, 1.0);
  2778. }
  2779. public bool PackArmor(int minLevel, int maxLevel, double chance)
  2780. {
  2781. if (chance <= Utility.RandomDouble())
  2782. return false;
  2783. Cap(ref minLevel, 0, 5);
  2784. Cap(ref maxLevel, 0, 5);
  2785. if (Core.AOS)
  2786. {
  2787. Item item = Loot.RandomArmorOrShieldOrJewelry();
  2788. if (item == null)
  2789. return false;
  2790. int attributeCount, min, max;
  2791. GetRandomAOSStats(minLevel, maxLevel, out attributeCount, out min, out max);
  2792. if (item is BaseArmor)
  2793. BaseRunicTool.ApplyAttributesTo((BaseArmor)item, attributeCount, min, max);
  2794. else if (item is BaseJewel)
  2795. BaseRunicTool.ApplyAttributesTo((BaseJewel)item, attributeCount, min, max);
  2796. PackItem(item);
  2797. }
  2798. else
  2799. {
  2800. BaseArmor armor = Loot.RandomArmorOrShield();
  2801. if (armor == null)
  2802. return false;
  2803. armor.ProtectionLevel = (ArmorProtectionLevel)RandomMinMaxScaled(minLevel, maxLevel);
  2804. armor.Durability = (ArmorDurabilityLevel)RandomMinMaxScaled(minLevel, maxLevel);
  2805. PackItem(armor);
  2806. }
  2807. return true;
  2808. }
  2809. public static void GetRandomAOSStats(int minLevel, int maxLevel, out int attributeCount, out int min, out int max)
  2810. {
  2811. int v = RandomMinMaxScaled(minLevel, maxLevel);
  2812. if (v >= 5)
  2813. {
  2814. attributeCount = Utility.RandomMinMax(2, 6);
  2815. min = 20; max = 70;
  2816. }
  2817. else if (v == 4)
  2818. {
  2819. attributeCount = Utility.RandomMinMax(2, 4);
  2820. min = 20; max = 50;
  2821. }
  2822. else if (v == 3)
  2823. {
  2824. attributeCount = Utility.RandomMinMax(2, 3);
  2825. min = 20; max = 40;
  2826. }
  2827. else if (v == 2)
  2828. {
  2829. attributeCount = Utility.RandomMinMax(1, 2);
  2830. min = 10; max = 30;
  2831. }
  2832. else
  2833. {
  2834. attributeCount = 1;
  2835. min = 10; max = 20;
  2836. }
  2837. }
  2838. public static int RandomMinMaxScaled(int min, int max)
  2839. {
  2840. if (min == max)
  2841. return min;
  2842. if (min > max)
  2843. {
  2844. int hold = min;
  2845. min = max;
  2846. max = hold;
  2847. }
  2848. /* Example:
  2849. * min: 1
  2850. * max: 5
  2851. * count: 5
  2852. *
  2853. * total = (5*5) + (4*4) + (3*3) + (2*2) + (1*1) = 25 + 16 + 9 + 4 + 1 = 55
  2854. *
  2855. * chance for min+0 : 25/55 : 45.45%
  2856. * chance for min+1 : 16/55 : 29.09%
  2857. * chance for min+2 : 9/55 : 16.36%
  2858. * chance for min+3 : 4/55 : 7.27%
  2859. * chance for min+4 : 1/55 : 1.81%
  2860. */
  2861. int count = max - min + 1;
  2862. int total = 0, toAdd = count;
  2863. for (int i = 0; i < count; ++i, --toAdd)
  2864. total += toAdd * toAdd;
  2865. int rand = Utility.Random(total);
  2866. toAdd = count;
  2867. int val = min;
  2868. for (int i = 0; i < count; ++i, --toAdd, ++val)
  2869. {
  2870. rand -= toAdd * toAdd;
  2871. if (rand < 0)
  2872. break;
  2873. }
  2874. return val;
  2875. }
  2876. public bool PackSlayer()
  2877. {
  2878. return PackSlayer(0.05);
  2879. }
  2880. public bool PackSlayer(double chance)
  2881. {
  2882. if (chance <= Utility.RandomDouble())
  2883. return false;
  2884. if (Utility.RandomBool())
  2885. {
  2886. BaseInstrument instrument = Loot.RandomInstrument();
  2887. if (instrument != null)
  2888. {
  2889. instrument.Slayer = SlayerGroup.GetLootSlayerType(GetType());
  2890. PackItem(instrument);
  2891. }
  2892. }
  2893. return true;
  2894. }
  2895. public bool PackWeapon(int minLevel, int maxLevel)
  2896. {
  2897. return PackWeapon(minLevel, maxLevel, 1.0);
  2898. }
  2899. public bool PackWeapon(int minLevel, int maxLevel, double chance)
  2900. {
  2901. if (chance <= Utility.RandomDouble())
  2902. return false;
  2903. Cap(ref minLevel, 0, 5);
  2904. Cap(ref maxLevel, 0, 5);
  2905. Item item = Loot.RandomWeaponOrJewelry();
  2906. if (item == null)
  2907. return false;
  2908. int attributeCount, min, max;
  2909. GetRandomAOSStats(minLevel, maxLevel, out attributeCount, out min, out max);
  2910. if (item is BaseWeapon)
  2911. BaseRunicTool.ApplyAttributesTo((BaseWeapon)item, attributeCount, min, max);
  2912. else if (item is BaseJewel)
  2913. BaseRunicTool.ApplyAttributesTo((BaseJewel)item, attributeCount, min, max);
  2914. PackItem(item);
  2915. return true;
  2916. }
  2917. public void PackGold(int amount)
  2918. {
  2919. PackMagicJewel();
  2920. //if ( amount > 0 )
  2921. // PackItem( new Gold( amount ) );
  2922. return;
  2923. }
  2924. public void PackGold(int min, int max)
  2925. {
  2926. PackMagicJewel();
  2927. //PackGold( Utility.RandomMinMax( min, max ) );
  2928. return;
  2929. }
  2930. public void PackStatue(int min, int max)
  2931. {
  2932. PackStatue(Utility.RandomMinMax(min, max));
  2933. }
  2934. public void PackStatue(int amount)
  2935. {
  2936. for (int i = 0; i < amount; ++i)
  2937. PackStatue();
  2938. }
  2939. public void PackStatue()
  2940. {
  2941. PackItem(Loot.RandomStatue());
  2942. }
  2943. public void PackGem()
  2944. {
  2945. PackGem(1);
  2946. PackMagicJewel();
  2947. }
  2948. public void PackLesserDaemonBone()
  2949. {
  2950. if (Utility.Random(0, 100) <= 15)
  2951. {
  2952. PackItem(new DaemonBone(Utility.Random(1, 5)));
  2953. }
  2954. }
  2955. public void PackDaemonBone()
  2956. {
  2957. if (Utility.Random(0, 100) <= 25)
  2958. {
  2959. PackItem(new DaemonBone(Utility.Random(1, 10)));
  2960. }
  2961. }
  2962. public void PackMagicJewel()
  2963. {
  2964. if (Utility.Random(0, 1000) <= 10)
  2965. {
  2966. PackItem(new MagicJewel());
  2967. }
  2968. }
  2969. public void PackGem(int min, int max)
  2970. {
  2971. PackGem(Utility.RandomMinMax(min, max));
  2972. }
  2973. public void PackGem(int amount)
  2974. {
  2975. if (amount <= 0)
  2976. return;
  2977. Item gem = Loot.RandomGem();
  2978. gem.Amount = amount;
  2979. PackItem(gem);
  2980. }
  2981. public void PackItem(Item item)
  2982. {
  2983. if (Summoned || item == null)
  2984. {
  2985. if (item != null)
  2986. item.Delete();
  2987. return;
  2988. }
  2989. Container pack = Backpack;
  2990. if (pack == null)
  2991. {
  2992. pack = new Backpack();
  2993. pack.Movable = false;
  2994. AddItem(pack);
  2995. }
  2996. if (!item.Stackable || !pack.TryDropItem(this, item, false)) // try stack
  2997. pack.DropItem(item); // failed, drop it anyway
  2998. }
  2999. public override void OnDoubleClick(Mobile from)
  3000. {
  3001. if (from.AccessLevel >= AccessLevel.GameMaster && !Body.IsHuman)
  3002. {
  3003. Container pack = this.Backpack;
  3004. if (pack != null)
  3005. pack.DisplayTo(from);
  3006. }
  3007. base.OnDoubleClick(from);
  3008. }
  3009. #region Disable Local Names
  3010. public sealed override void OnAosSingleClick(Mobile from)
  3011. {
  3012. if (!m_ShowNameTag || this is BaseGuildMobile)
  3013. return;
  3014. if (from is RacePlayerMobile)
  3015. {
  3016. var rpm = (RacePlayerMobile)from;
  3017. if (this is BaseVendor)
  3018. {
  3019. if (!rpm.GuildInfo.IsYoung)
  3020. return;
  3021. }
  3022. else
  3023. {
  3024. if (!rpm.GuildInfo.ShowMonsters)
  3025. return;
  3026. }
  3027. }
  3028. ObjectPropertyList opl = this.PropertyList;
  3029. if (opl.Header > 0)
  3030. {
  3031. int hue;
  3032. string name = Name;
  3033. if (this.NameHue != -1)
  3034. hue = this.NameHue;
  3035. else if (this.AccessLevel > AccessLevel.Player)
  3036. hue = 11;
  3037. else
  3038. hue = Notoriety.GetHue(Notoriety.Compute(from, this));
  3039. if (from is RacePlayerMobile)
  3040. {
  3041. RacePlayerMobile rpm = (RacePlayerMobile)from;
  3042. if (rpm.Capacities[CapacityName.Lore].Value < Erudition)
  3043. name = "Créature";
  3044. }
  3045. from.Send(new MessageLocalized(this.Serial, Body, MessageType.Label, hue, 3, opl.Header, name, opl.HeaderArgs));
  3046. }
  3047. //SendPropertiesTo(from);
  3048. }
  3049. public sealed override void OnSingleClick(Mobile from)
  3050. {
  3051. if (!m_ShowNameTag || this is BaseGuildMobile)
  3052. return;
  3053. if (from is RacePlayerMobile)
  3054. {
  3055. var rpm = (RacePlayerMobile)from;
  3056. if (this is BaseVendor)
  3057. {
  3058. if (!rpm.GuildInfo.IsYoung)
  3059. return;
  3060. }
  3061. else
  3062. {
  3063. if (!rpm.GuildInfo.ShowMonsters)
  3064. return;
  3065. }
  3066. }
  3067. if (Controled && Commandable)
  3068. {
  3069. int number;
  3070. if (Summoned)
  3071. number = 1049646; // (summoned)
  3072. else if (IsBonded)
  3073. number = 1049608; // (bonded)
  3074. else
  3075. number = 502006; // (tame)
  3076. PrivateOverheadMessage(MessageType.Regular, 0x3B2, number, from.NetState);
  3077. }
  3078. if (this.Deleted)
  3079. return;
  3080. else if (AccessLevel == AccessLevel.Player && DisableHiddenSelfClick && Hidden && from == this)
  3081. return;
  3082. int hue;
  3083. if (this.NameHue != -1)
  3084. hue = this.NameHue;
  3085. else if (AccessLevel > AccessLevel.Player)
  3086. hue = 11;
  3087. else
  3088. hue = Notoriety.GetHue(Notoriety.Compute(from, this));
  3089. string name = Name;
  3090. if (name == null)
  3091. name = String.Empty;
  3092. string prefix = "";
  3093. if (ShowFameTitle && (this.Player || this.Body.IsHuman) && this.Fame >= 10000)
  3094. prefix = (this.Female ? "Lady" : "Lord");
  3095. string suffix = "";
  3096. if (ClickTitle && Title != null && Title.Length > 0)
  3097. suffix = Title;
  3098. //suffix = ApplyNameSuffix(suffix);
  3099. string val;
  3100. if (prefix.Length > 0 && suffix.Length > 0)
  3101. val = String.Concat(prefix, " ", name, " ", suffix);
  3102. else if (prefix.Length > 0)
  3103. val = String.Concat(prefix, " ", name);
  3104. else if (suffix.Length > 0)
  3105. val = String.Concat(name, " ", suffix);
  3106. else
  3107. val = name;
  3108. if (from.NetState.Mobile is RacePlayerMobile)
  3109. {
  3110. RacePlayerMobile rpm = (RacePlayerMobile)(from.NetState.Mobile);
  3111. if (rpm.Capacities[CapacityName.Lore].Value < Erudition)
  3112. val = "Créature";
  3113. }
  3114. PrivateOverheadMessage(MessageType.Label, hue, true, val, from.NetState);
  3115. //base.OnSingleClick( from );
  3116. //SendPropertiesTo(from);
  3117. }
  3118. #endregion
  3119. public virtual int TreasureMapLevel { get { return 0; } }
  3120. public override bool OnBeforeDeath()
  3121. {
  3122. int treasureLevel = TreasureMapLevel;
  3123. if (!Summoned && !NoKillAwards && !IsBonded && treasureLevel > 0 && (Map == Map.Felucca || Map == Map.Trammel) && TreasureMap.LootChance >= Utility.RandomDouble())
  3124. PackItem(new TreasureMap(treasureLevel, Map));
  3125. if (!Summoned && !NoKillAwards && !m_HasGeneratedLoot)
  3126. {
  3127. m_HasGeneratedLoot = true;
  3128. GenerateLoot(false);
  3129. }
  3130. if (IsAnimatedDead)
  3131. Effects.SendLocationEffect(Location, Map, 0x3728, 13, 1, 0x461, 4);
  3132. InhumanSpeech speechType = this.SpeechType;
  3133. if (speechType != null)
  3134. speechType.OnDeath(this);
  3135. return base.OnBeforeDeath();
  3136. }
  3137. private bool m_NoKillAwards;
  3138. public bool NoKillAwards
  3139. {
  3140. get { return m_NoKillAwards; }
  3141. set { m_NoKillAwards = value; }
  3142. }
  3143. public int ComputeBonusDamage(ArrayList list, Mobile m)
  3144. {
  3145. int bonus = 0;
  3146. for (int i = list.Count - 1; i >= 0; --i)
  3147. {
  3148. DamageEntry de = (DamageEntry)list[i];
  3149. if (de.Damager == m || !(de.Damager is BaseCreature))
  3150. continue;
  3151. BaseCreature bc = (BaseCreature)de.Damager;
  3152. Mobile master = null;
  3153. if (bc.Controled && bc.ControlMaster != null)
  3154. master = bc.ControlMaster;
  3155. else if (bc.Summoned && bc.SummonMaster != null)
  3156. master = bc.SummonMaster;
  3157. if (master == m)
  3158. bonus += de.DamageGiven;
  3159. }
  3160. return bonus;
  3161. }
  3162. private class FKEntry
  3163. {
  3164. public Mobile m_Mobile;
  3165. public int m_Damage;
  3166. public FKEntry(Mobile m, int damage)
  3167. {
  3168. m_Mobile = m;
  3169. m_Damage = damage;
  3170. }
  3171. }
  3172. public static ArrayList GetLootingRights(ArrayList damageEntries)
  3173. {
  3174. ArrayList rights = new ArrayList();
  3175. for (int i = damageEntries.Count - 1; i >= 0; --i)
  3176. {
  3177. if (i >= damageEntries.Count)
  3178. continue;
  3179. DamageEntry de = (DamageEntry)damageEntries[i];
  3180. if (de.HasExpired)
  3181. {
  3182. damageEntries.RemoveAt(i);
  3183. continue;
  3184. }
  3185. int damage = de.DamageGiven;
  3186. ArrayList respList = de.Responsible;
  3187. if (respList != null)
  3188. {
  3189. for (int j = 0; j < respList.Count; ++j)
  3190. {
  3191. DamageEntry subEntry = (DamageEntry)respList[j];
  3192. Mobile master = subEntry.Damager;
  3193. if (master == null || master.Deleted || !master.Player)
  3194. continue;
  3195. bool needNewSubEntry = true;
  3196. for (int k = 0; needNewSubEntry && k < rights.Count; ++k)
  3197. {
  3198. DamageStore ds = (DamageStore)rights[k];
  3199. if (ds.m_Mobile == master)
  3200. {
  3201. ds.m_Damage += subEntry.DamageGiven;
  3202. needNewSubEntry = false;
  3203. }
  3204. }
  3205. if (needNewSubEntry)
  3206. rights.Add(new DamageStore(master, subEntry.DamageGiven));
  3207. damage -= subEntry.DamageGiven;
  3208. }
  3209. }
  3210. Mobile m = de.Damager;
  3211. if (m is BaseCreature)
  3212. {
  3213. BaseCreature bc = (BaseCreature)m;
  3214. if (bc.Controled && bc.ControlMaster != null)
  3215. m = bc.ControlMaster;
  3216. else if (bc.Summoned && bc.SummonMaster != null)
  3217. m = bc.SummonMaster;
  3218. }
  3219. if (m == null || m.Deleted || !m.Player)
  3220. continue;
  3221. if (damage <= 0)
  3222. continue;
  3223. bool needNewEntry = true;
  3224. for (int j = 0; needNewEntry && j < rights.Count; ++j)
  3225. {
  3226. DamageStore ds = (DamageStore)rights[j];
  3227. if (ds.m_Mobile == m)
  3228. {
  3229. ds.m_Damage += damage;
  3230. needNewEntry = false;
  3231. }
  3232. }
  3233. if (needNewEntry)
  3234. rights.Add(new DamageStore(m, damage));
  3235. }
  3236. if (rights.Count > 0)
  3237. {
  3238. if (rights.Count > 1)
  3239. rights.Sort();
  3240. int topDamage = ((DamageStore)rights[0]).m_Damage;
  3241. int minDamage = (topDamage * 70) / 100;
  3242. for (int i = 0; i < rights.Count; ++i)
  3243. {
  3244. DamageStore ds = (DamageStore)rights[i];
  3245. ds.m_HasRight = (ds.m_Damage >= minDamage);
  3246. }
  3247. }
  3248. return rights;
  3249. }
  3250. public override void OnDeath(Container c)
  3251. {
  3252. if (IsBonded)
  3253. {
  3254. int sound = this.GetDeathSound();
  3255. if (sound >= 0)
  3256. Effects.PlaySound(this, this.Map, sound);
  3257. Warmode = false;
  3258. Poison = null;
  3259. Combatant = null;
  3260. Hits = 0;
  3261. Stam = 0;
  3262. Mana = 0;
  3263. IsDeadPet = true;
  3264. ControlTarget = ControlMaster;
  3265. ControlOrder = OrderType.Follow;
  3266. ProcessDeltaQueue();
  3267. SendIncomingPacket();
  3268. SendIncomingPacket();
  3269. ArrayList aggressors = this.Aggressors;
  3270. for (int i = 0; i < aggressors.Count; ++i)
  3271. {
  3272. AggressorInfo info = (AggressorInfo)aggressors[i];
  3273. if (info.Attacker.Combatant == this)
  3274. info.Attacker.Combatant = null;
  3275. }
  3276. ArrayList aggressed = this.Aggressed;
  3277. for (int i = 0; i < aggressed.Count; ++i)
  3278. {
  3279. AggressorInfo info = (AggressorInfo)aggressed[i];
  3280. if (info.Defender.Combatant == this)
  3281. info.Defender.Combatant = null;
  3282. }
  3283. Mobile owner = this.ControlMaster;
  3284. if (owner == null || owner.Deleted || owner.Map != this.Map || !owner.InRange(this, 12) || !this.CanSee(owner) || !this.InLOS(owner))
  3285. {
  3286. if (this.OwnerAbandonTime == DateTime.MinValue)
  3287. this.OwnerAbandonTime = DateTime.Now;
  3288. }
  3289. else
  3290. {
  3291. this.OwnerAbandonTime = DateTime.MinValue;
  3292. }
  3293. }
  3294. else
  3295. {
  3296. if (!Summoned && !m_NoKillAwards)
  3297. {
  3298. int totalFame = Fame / 100;
  3299. int totalKarma = -Karma / 100;
  3300. ArrayList list = GetLootingRights(this.DamageEntries);
  3301. bool givenQuestKill = false;
  3302. for (int i = 0; i < list.Count; ++i)
  3303. {
  3304. DamageStore ds = (DamageStore)list[i];
  3305. if (!ds.m_HasRight)
  3306. continue;
  3307. Titles.AwardFame(ds.m_Mobile, totalFame, true);
  3308. Titles.AwardKarma(ds.m_Mobile, totalKarma, true);
  3309. // ----------------------------------------------------------------------------
  3310. /*
  3311. if (ds.m_Mobile is RacePlayerMobile && m_CurrentAI != AIType.AI_Animal)
  3312. {
  3313. RacePlayerMobile player = (RacePlayerMobile)ds.m_Mobile;
  3314. var Evo = player.EvolutionInfo;
  3315. int PreviousLevel = Evo.Level;
  3316. if (PreviousLevel < 25 && Utility.RandomMinMax(0,99) < 1)
  3317. {
  3318. Evo.Experience += 1;
  3319. player.SendMessage("Vous vous sentez plus expérimenté après ce combat.");
  3320. if (PreviousLevel < Evo.Level)
  3321. {
  3322. player.SendMessage("Félicitations! Vous avez atteint le niveau " + Evo.Level);
  3323. player.SkillsCap += 1400;
  3324. }
  3325. }
  3326. }
  3327. */
  3328. // ----------------------------------------------------------------------------
  3329. if (givenQuestKill)
  3330. continue;
  3331. }
  3332. }
  3333. base.OnDeath(c);
  3334. if (DeleteCorpseOnDeath)
  3335. c.Delete();
  3336. }
  3337. }
  3338. /* To save on cpu usage, RunUO creatures only reaquire creatures under the following circumstances:
  3339. * - 10 seconds have elapsed since the last time it tried
  3340. * - The creature was attacked
  3341. * - Some creatures, like dragons, will reaquire when they see someone move
  3342. *
  3343. * This functionality appears to be implemented on OSI as well
  3344. */
  3345. private DateTime m_NextReaquireTime;
  3346. public DateTime NextReaquireTime { get { return m_NextReaquireTime; } set { m_NextReaquireTime = value; } }
  3347. public virtual TimeSpan ReaquireDelay { get { return TimeSpan.FromSeconds(10.0); } }
  3348. public virtual bool ReaquireOnMovement { get { return false; } }
  3349. public void ForceReaquire()
  3350. {
  3351. m_NextReaquireTime = DateTime.MinValue;
  3352. }
  3353. public override void OnDelete()
  3354. {
  3355. SetControlMaster(null);
  3356. SummonMaster = null;
  3357. base.OnDelete();
  3358. }
  3359. public override bool CanBeHarmful(Mobile target, bool message, bool ignoreOurBlessedness)
  3360. {
  3361. if ((target is BaseVendor && ((BaseVendor)target).IsInvulnerable) || target is PlayerVendor || target is TownCrier)
  3362. {
  3363. if (message)
  3364. {
  3365. if (target.Title == null)
  3366. SendMessage("{0} the vendor cannot be harmed.", target.Name);
  3367. else
  3368. SendMessage("{0} {1} cannot be harmed.", target.Name, target.Title);
  3369. }
  3370. return false;
  3371. }
  3372. return base.CanBeHarmful(target, message, ignoreOurBlessedness);
  3373. }
  3374. public override bool CanBeRenamedBy(Mobile from)
  3375. {
  3376. bool ret = base.CanBeRenamedBy(from);
  3377. if (Controled && from == ControlMaster)
  3378. ret = true;
  3379. return ret;
  3380. }
  3381. public bool SetControlMaster(Mobile m)
  3382. {
  3383. if (m == null)
  3384. {
  3385. ControlMaster = null;
  3386. Controled = false;
  3387. ControlTarget = null;
  3388. ControlOrder = OrderType.None;
  3389. Guild = null;
  3390. Delta(MobileDelta.Noto);
  3391. }
  3392. else
  3393. {
  3394. if (m.Followers + ControlSlots > m.FollowersMax)
  3395. {
  3396. m.SendLocalizedMessage(1049607); // You have too many followers to control that creature.
  3397. return false;
  3398. }
  3399. CurrentWayPoint = null;//so tamed animals don't try to go back
  3400. ControlMaster = m;
  3401. Controled = true;
  3402. ControlTarget = null;
  3403. ControlOrder = OrderType.Come;
  3404. Guild = null;
  3405. Delta(MobileDelta.Noto);
  3406. }
  3407. return true;
  3408. }
  3409. private static bool m_Summoning;
  3410. public static bool Summoning
  3411. {
  3412. get { return m_Summoning; }
  3413. set { m_Summoning = value; }
  3414. }
  3415. public static bool Summon(BaseCreature creature, Mobile caster, Point3D p, int sound, TimeSpan duration)
  3416. {
  3417. return Summon(creature, true, caster, p, sound, duration);
  3418. }
  3419. public static bool Summon(BaseCreature creature, bool controled, Mobile caster, Point3D p, int sound, TimeSpan duration)
  3420. {
  3421. if (caster.Followers + creature.ControlSlots > caster.FollowersMax)
  3422. {
  3423. caster.SendLocalizedMessage(1049645); // You have too many followers to summon that creature.
  3424. creature.Delete();
  3425. return false;
  3426. }
  3427. creature.EnsureTemplateAssigned();
  3428. m_Summoning = true;
  3429. if (controled)
  3430. creature.SetControlMaster(caster);
  3431. creature.RangeHome = 10;
  3432. creature.Summoned = true;
  3433. creature.SummonMaster = caster;
  3434. Container pack = creature.Backpack;
  3435. if (pack != null)
  3436. {
  3437. for (int i = pack.Items.Count - 1; i >= 0; --i)
  3438. {
  3439. if (i >= pack.Items.Count)
  3440. continue;
  3441. ((Item)pack.Items[i]).Delete();
  3442. }
  3443. }
  3444. new UnsummonTimer(caster, creature, duration).Start();
  3445. creature.m_SummonEnd = DateTime.Now + duration;
  3446. creature.MoveToWorld(p, caster.Map);
  3447. Effects.PlaySound(p, creature.Map, sound);
  3448. m_Summoning = false;
  3449. return true;
  3450. }
  3451. private static bool EnableRummaging = true;
  3452. private const double ChanceToRummage = 0.5; // 50%
  3453. private const double MinutesToNextRummageMin = 1.0;
  3454. private const double MinutesToNextRummageMax = 4.0;
  3455. private const double MinutesToNextChanceMin = 0.25;
  3456. private const double MinutesToNextChanceMax = 0.75;
  3457. private DateTime m_NextRummageTime;
  3458. public virtual void OnThink()
  3459. {
  3460. if (EnableRummaging && CanRummageCorpses && !Summoned && !Controled && DateTime.Now >= m_NextRummageTime)
  3461. {
  3462. double min, max;
  3463. if (ChanceToRummage > Utility.RandomDouble() && Rummage())
  3464. {
  3465. min = MinutesToNextRummageMin;
  3466. max = MinutesToNextRummageMax;
  3467. }
  3468. else
  3469. {
  3470. min = MinutesToNextChanceMin;
  3471. max = MinutesToNextChanceMax;
  3472. }
  3473. double delay = min + (Utility.RandomDouble() * (max - min));
  3474. m_NextRummageTime = DateTime.Now + TimeSpan.FromMinutes(delay);
  3475. }
  3476. if (HasBreath && !Summoned && DateTime.Now >= m_NextBreathTime) // tested: controled dragons do breath fire, what about summoned skeletal dragons?
  3477. {
  3478. Mobile target = this.Combatant;
  3479. if (target != null && target.Alive && !target.IsDeadBondedPet && CanBeHarmful(target) && target.Map == this.Map && !IsDeadBondedPet && target.InRange(this, BreathRange) && InLOS(target) && !BardPacified)
  3480. BreathStart(target);
  3481. m_NextBreathTime = DateTime.Now + TimeSpan.FromSeconds(BreathMinDelay + (Utility.RandomDouble() * BreathMaxDelay));
  3482. }
  3483. }
  3484. public virtual bool Rummage()
  3485. {
  3486. Corpse toRummage = null;
  3487. foreach (Item item in this.GetItemsInRange(2))
  3488. {
  3489. if (item is Corpse && item.Items.Count > 0)
  3490. {
  3491. toRummage = (Corpse)item;
  3492. break;
  3493. }
  3494. }
  3495. if (toRummage == null)
  3496. return false;
  3497. Container pack = this.Backpack;
  3498. if (pack == null)
  3499. return false;
  3500. var items = toRummage.Items;
  3501. bool rejected;
  3502. LRReason reason;
  3503. for (int i = 0; i < items.Count; ++i)
  3504. {
  3505. Item item = (Item)items[Utility.Random(items.Count)];
  3506. Lift(item, item.Amount, out rejected, out reason);
  3507. if (!rejected && Drop(this, new Point3D(-1, -1, 0)))
  3508. {
  3509. // *rummages through a corpse and takes an item*
  3510. PublicOverheadMessage(MessageType.Emote, 0x3B2, 1008086);
  3511. return true;
  3512. }
  3513. }
  3514. return false;
  3515. }
  3516. public void Pacify(Mobile master, DateTime endtime)
  3517. {
  3518. BardPacified = true;
  3519. BardEndTime = endtime;
  3520. }
  3521. public override Mobile GetDamageMaster(Mobile damagee)
  3522. {
  3523. if (m_bBardProvoked && damagee == m_bBardTarget)
  3524. return m_bBardMaster;
  3525. return base.GetDamageMaster(damagee);
  3526. }
  3527. public void Provoke(Mobile master, Mobile target, bool bSuccess)
  3528. {
  3529. BardProvoked = true;
  3530. this.PublicOverheadMessage(MessageType.Emote, EmoteHue, false, "*looks furious*");
  3531. if (bSuccess)
  3532. {
  3533. PlaySound(GetIdleSound());
  3534. BardMaster = master;
  3535. BardTarget = target;
  3536. Combatant = target;
  3537. BardEndTime = DateTime.Now + TimeSpan.FromSeconds(30.0);
  3538. if (target is BaseCreature)
  3539. {
  3540. BaseCreature t = (BaseCreature)target;
  3541. t.BardProvoked = true;
  3542. t.BardMaster = master;
  3543. t.BardTarget = this;
  3544. t.Combatant = this;
  3545. t.BardEndTime = DateTime.Now + TimeSpan.FromSeconds(30.0);
  3546. }
  3547. }
  3548. else
  3549. {
  3550. PlaySound(GetAngerSound());
  3551. BardMaster = master;
  3552. BardTarget = target;
  3553. }
  3554. }
  3555. public bool FindMyName(string str, bool bWithAll)
  3556. {
  3557. int i, j;
  3558. string name = this.Name;
  3559. if (name == null || str.Length < name.Length)
  3560. return false;
  3561. string[] wordsString = str.Split(' ');
  3562. string[] wordsName = name.Split(' ');
  3563. for (j = 0; j < wordsName.Length; j++)
  3564. {
  3565. string wordName = wordsName[j];
  3566. bool bFound = false;
  3567. for (i = 0; i < wordsString.Length; i++)
  3568. {
  3569. string word = wordsString[i];
  3570. if (Insensitive.Equals(word, wordName))
  3571. bFound = true;
  3572. if (bWithAll && Insensitive.Equals(word, "all"))
  3573. return true;
  3574. }
  3575. if (!bFound)
  3576. return false;
  3577. }
  3578. return true;
  3579. }
  3580. public static void TeleportPets(Mobile master, Point3D loc, Map map)
  3581. {
  3582. TeleportPets(master, loc, map, false);
  3583. }
  3584. public static void TeleportPets(Mobile master, Point3D loc, Map map, bool onlyBonded)
  3585. {
  3586. ArrayList move = new ArrayList();
  3587. foreach (Mobile m in master.GetMobilesInRange(3))
  3588. {
  3589. if (m is BaseCreature)
  3590. {
  3591. BaseCreature pet = (BaseCreature)m;
  3592. if (pet.Controled && pet.ControlMaster == master)
  3593. {
  3594. if (!onlyBonded || pet.IsBonded)
  3595. {
  3596. if (pet.ControlOrder == OrderType.Guard || pet.ControlOrder == OrderType.Follow || pet.ControlOrder == OrderType.Come)
  3597. move.Add(pet);
  3598. }
  3599. }
  3600. }
  3601. }
  3602. foreach (Mobile m in move)
  3603. m.MoveToWorld(loc, map);
  3604. }
  3605. public virtual void ResurrectPet()
  3606. {
  3607. if (!IsDeadPet)
  3608. return;
  3609. OnBeforeResurrect();
  3610. Poison = null;
  3611. Warmode = false;
  3612. Hits = 10;
  3613. Stam = StamMax;
  3614. Mana = 0;
  3615. ProcessDeltaQueue();
  3616. IsDeadPet = false;
  3617. Effects.SendPacket(Location, Map, new BondedStatus(0, this.Serial, 0));
  3618. this.SendIncomingPacket();
  3619. this.SendIncomingPacket();
  3620. OnAfterResurrect();
  3621. //Bonded Status only last once and has to be reaquired.
  3622. IsBonded = false;
  3623. BondingBegin = DateTime.MinValue;
  3624. Mobile owner = this.ControlMaster;
  3625. if (owner == null || owner.Deleted || owner.Map != this.Map || !owner.InRange(this, 12) || !this.CanSee(owner) || !this.InLOS(owner))
  3626. {
  3627. if (this.OwnerAbandonTime == DateTime.MinValue)
  3628. this.OwnerAbandonTime = DateTime.Now;
  3629. }
  3630. else
  3631. {
  3632. this.OwnerAbandonTime = DateTime.MinValue;
  3633. }
  3634. }
  3635. public override bool CanBeDamaged()
  3636. {
  3637. if (IsDeadPet)
  3638. return false;
  3639. return base.CanBeDamaged();
  3640. }
  3641. public virtual bool PlayerRangeSensitive { get { return true; } }
  3642. public override void OnSectorDeactivate()
  3643. {
  3644. if (PlayerRangeSensitive && m_AI != null)
  3645. m_AI.Deactivate();
  3646. base.OnSectorDeactivate();
  3647. }
  3648. public override void OnSectorActivate()
  3649. {
  3650. if (PlayerRangeSensitive && m_AI != null)
  3651. m_AI.Activate();
  3652. base.OnSectorActivate();
  3653. }
  3654. // used for deleting creatures in houses
  3655. private int m_RemoveStep;
  3656. [CommandProperty(AccessLevel.GameMaster)]
  3657. public int RemoveStep { get { return m_RemoveStep; } set { m_RemoveStep = value; } }
  3658. }
  3659. public class LoyaltyTimer : Timer
  3660. {
  3661. private static TimeSpan InternalDelay = TimeSpan.FromMinutes(5.0);
  3662. public static void Initialize()
  3663. {
  3664. new LoyaltyTimer().Start();
  3665. }
  3666. public LoyaltyTimer()
  3667. : base(InternalDelay, InternalDelay)
  3668. {
  3669. m_NextHourlyCheck = DateTime.Now + TimeSpan.FromHours(5.0);
  3670. Priority = TimerPriority.FiveSeconds;
  3671. }
  3672. private DateTime m_NextHourlyCheck;
  3673. protected override void OnTick()
  3674. {
  3675. bool hasHourElapsed = (DateTime.Now >= m_NextHourlyCheck);
  3676. if (hasHourElapsed)
  3677. m_NextHourlyCheck = DateTime.Now + TimeSpan.FromHours(5.0);
  3678. ArrayList toRelease = new ArrayList();
  3679. // added array for wild creatures in house regions to be removed
  3680. ArrayList toRemove = new ArrayList();
  3681. foreach (Mobile m in World.Mobiles.Values)
  3682. {
  3683. if (m is BaseMount && ((BaseMount)m).Rider != null)
  3684. continue;
  3685. if (m is BaseCreature)
  3686. {
  3687. BaseCreature c = (BaseCreature)m;
  3688. if (c.IsDeadPet)
  3689. {
  3690. Mobile owner = c.ControlMaster;
  3691. if (owner == null || owner.Deleted || owner.Map != c.Map || !owner.InRange(c, 12) || !c.CanSee(owner) || !c.InLOS(owner))
  3692. {
  3693. if (c.OwnerAbandonTime == DateTime.MinValue)
  3694. c.OwnerAbandonTime = DateTime.Now;
  3695. else if ((c.OwnerAbandonTime + c.BondingAbandonDelay) <= DateTime.Now)
  3696. toRemove.Add(c);
  3697. }
  3698. else
  3699. {
  3700. c.OwnerAbandonTime = DateTime.MinValue;
  3701. }
  3702. }
  3703. else if (c.Controled && c.Commandable && c.Loyalty > PetLoyalty.None && c.Map != Map.Internal)
  3704. {
  3705. Mobile owner = c.ControlMaster;
  3706. // changed loyalty decrement
  3707. if (hasHourElapsed)
  3708. {
  3709. --c.Loyalty;
  3710. if (c.Loyalty == PetLoyalty.Confused)
  3711. {
  3712. c.Say(1043270, "Créature"); // * ~1_NAME~ looks around desperately *
  3713. c.PlaySound(c.GetIdleSound());
  3714. }
  3715. }
  3716. c.OwnerAbandonTime = DateTime.MinValue;
  3717. if (c.Loyalty == PetLoyalty.None)
  3718. toRelease.Add(c);
  3719. }
  3720. // added lines to check if a wild creature in a house region has to be removed or not
  3721. if (!c.Controled && c.Region is HouseRegion && c.CanBeDamaged())
  3722. {
  3723. c.RemoveStep++;
  3724. if (c.RemoveStep >= 20)
  3725. toRemove.Add(c);
  3726. }
  3727. else
  3728. {
  3729. c.RemoveStep = 0;
  3730. }
  3731. }
  3732. }
  3733. foreach (BaseCreature c in toRelease)
  3734. {
  3735. c.Say(1043255, "Créature"); // ~1_NAME~ appears to have decided that is better off without a master!
  3736. c.Loyalty = PetLoyalty.WonderfullyHappy;
  3737. c.IsBonded = false;
  3738. c.BondingBegin = DateTime.MinValue;
  3739. c.OwnerAbandonTime = DateTime.MinValue;
  3740. c.ControlTarget = null;
  3741. //c.ControlOrder = OrderType.Release;
  3742. c.AIObject.DoOrderRelease(); // this will prevent no release of creatures left alone with AI disabled (and consequent bug of Followers)
  3743. }
  3744. // added code to handle removing of wild creatures in house regions
  3745. foreach (BaseCreature c in toRemove)
  3746. {
  3747. c.Delete();
  3748. }
  3749. }
  3750. }
  3751. }