Guest User

RunUO 2.0

a guest
Mar 8th, 2015
365
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 24.06 KB | None | 0 0
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using Server;
  5. using Server.ContextMenus;
  6. using Server.Engines.PartySystem;
  7. using Server.Engines.Quests;
  8. using Server.Engines.Quests.Doom;
  9. using Server.Engines.Quests.Haven;
  10. using Server.Guilds;
  11. using Server.Misc;
  12. using Server.Mobiles;
  13. using Server.Network;
  14.  
  15. namespace Server.Items
  16. {
  17. public class Corpse : Container, ICarvable
  18. {
  19. private Mobile m_Owner; // Whos corpse is this?
  20. private Mobile m_Killer; // Who killed the owner?
  21. private bool m_Carved; // Has this corpse been carved?
  22.  
  23. private List<Mobile> m_Looters; // Who's looted this corpse?
  24. private List<Item> m_EquipItems; // List of items equiped when the owner died. Ingame, these items display /on/ the corpse, not just inside
  25. private List<Mobile> m_Aggressors; // Anyone from this list will be able to loot this corpse; we attacked them, or they attacked us when we were freely attackable
  26.  
  27. private string m_CorpseName; // Value of the CorpseNameAttribute attached to the owner when he died -or- null if the owner had no CorpseNameAttribute; use "the remains of ~name~"
  28. private bool m_NoBones; // If true, this corpse will not turn into bones
  29.  
  30. private bool m_VisitedByTaxidermist; // Has this corpse yet been visited by a taxidermist?
  31. private bool m_Channeled; // Has this corpse yet been used to channel spiritual energy? (AOS Spirit Speak)
  32.  
  33. // For notoriety:
  34. private AccessLevel m_AccessLevel; // Which AccessLevel the owner had when he died
  35. private Guild m_Guild; // Which Guild the owner was in when he died
  36. private int m_Kills; // How many kills the owner had when he died
  37. private bool m_Criminal; // Was the owner criminal when he died?
  38.  
  39. private DateTime m_TimeOfDeath; // What time was this corpse created?
  40.  
  41. private HairInfo m_Hair; // This contains the hair of the owner
  42. private FacialHairInfo m_FacialHair; // This contains the facial hair of the owner
  43.  
  44. public static readonly TimeSpan MonsterLootRightSacrifice = TimeSpan.FromMinutes( 2.0 );
  45.  
  46. public static readonly TimeSpan InstancedCorpseTime = TimeSpan.FromMinutes( 3.0 );
  47.  
  48. [CommandProperty( AccessLevel.GameMaster )]
  49. public virtual bool InstancedCorpse
  50. {
  51. get
  52. {
  53. if ( !Core.SE )
  54. return false;
  55.  
  56. return ( DateTime.Now > m_TimeOfDeath + InstancedCorpseTime );
  57. }
  58. }
  59.  
  60. public override bool IsDecoContainer
  61. {
  62. get{ return false; }
  63. }
  64.  
  65. private Dictionary<Mobile, List<Item>> m_InstancedItems;
  66.  
  67. [CommandProperty( AccessLevel.GameMaster )]
  68. public DateTime TimeOfDeath
  69. {
  70. get{ return m_TimeOfDeath; }
  71. set{ m_TimeOfDeath = value; }
  72. }
  73.  
  74. public override bool DisplayWeight { get { return false; } }
  75.  
  76. public HairInfo Hair { get { return m_Hair; } }
  77. public FacialHairInfo FacialHair { get { return m_FacialHair; } }
  78.  
  79. [CommandProperty( AccessLevel.GameMaster )]
  80. public bool Carved
  81. {
  82. get{ return m_Carved; }
  83. set{ m_Carved = value; }
  84. }
  85.  
  86. [CommandProperty( AccessLevel.GameMaster )]
  87. public bool VisitedByTaxidermist
  88. {
  89. get{ return m_VisitedByTaxidermist; }
  90. set{ m_VisitedByTaxidermist = value; }
  91. }
  92.  
  93. [CommandProperty( AccessLevel.GameMaster )]
  94. public bool Channeled
  95. {
  96. get{ return m_Channeled; }
  97. set{ m_Channeled = value; }
  98. }
  99.  
  100. [CommandProperty( AccessLevel.GameMaster )]
  101. public AccessLevel AccessLevel
  102. {
  103. get{ return m_AccessLevel; }
  104. }
  105.  
  106. public List<Mobile> Aggressors
  107. {
  108. get{ return m_Aggressors; }
  109. }
  110.  
  111. public List<Mobile> Looters
  112. {
  113. get{ return m_Looters; }
  114. }
  115.  
  116. [CommandProperty( AccessLevel.GameMaster )]
  117. public Mobile Killer
  118. {
  119. get{ return m_Killer; }
  120. }
  121.  
  122. public List<Item> EquipItems
  123. {
  124. get{ return m_EquipItems; }
  125. }
  126.  
  127. public Guild Guild
  128. {
  129. get{ return m_Guild; }
  130. }
  131.  
  132. [CommandProperty( AccessLevel.GameMaster )]
  133. public int Kills
  134. {
  135. get{ return m_Kills; }
  136. set{ m_Kills = value; }
  137. }
  138.  
  139. [CommandProperty( AccessLevel.GameMaster )]
  140. public bool Criminal
  141. {
  142. get{ return m_Criminal; }
  143. set{ m_Criminal = value; }
  144. }
  145.  
  146. [CommandProperty( AccessLevel.GameMaster )]
  147. public Mobile Owner
  148. {
  149. get{ return m_Owner; }
  150. }
  151.  
  152. public void TurnToBones()
  153. {
  154. if ( Deleted )
  155. return;
  156.  
  157. ProcessDelta();
  158. SendRemovePacket();
  159. ItemID = Utility.Random( 0xECA, 9 ); // bone graphic
  160. Hue = 0;
  161. ProcessDelta();
  162.  
  163. m_NoBones = true;
  164. BeginDecay( m_BoneDecayTime );
  165. }
  166.  
  167. private static TimeSpan m_DefaultDecayTime = TimeSpan.FromMinutes( 7.0 );
  168. private static TimeSpan m_BoneDecayTime = TimeSpan.FromMinutes( 7.0 );
  169.  
  170. private Timer m_DecayTimer;
  171. private DateTime m_DecayTime;
  172.  
  173. public void BeginDecay( TimeSpan delay )
  174. {
  175. if ( m_DecayTimer != null )
  176. m_DecayTimer.Stop();
  177.  
  178. m_DecayTime = DateTime.Now + delay;
  179.  
  180. m_DecayTimer = new InternalTimer( this, delay );
  181. m_DecayTimer.Start();
  182. }
  183.  
  184. public override void OnAfterDelete()
  185. {
  186. if ( m_DecayTimer != null )
  187. m_DecayTimer.Stop();
  188.  
  189. m_DecayTimer = null;
  190. }
  191.  
  192. private class InternalTimer : Timer
  193. {
  194. private Corpse m_Corpse;
  195.  
  196. public InternalTimer( Corpse c, TimeSpan delay ) : base( delay )
  197. {
  198. m_Corpse = c;
  199. Priority = TimerPriority.FiveSeconds;
  200. }
  201.  
  202. protected override void OnTick()
  203. {
  204. if ( !m_Corpse.m_NoBones )
  205. m_Corpse.TurnToBones();
  206. else
  207. m_Corpse.Delete();
  208. }
  209. }
  210.  
  211. public static string GetCorpseName( Mobile m )
  212. {
  213. Type t = m.GetType();
  214.  
  215. object[] attrs = t.GetCustomAttributes( typeof( CorpseNameAttribute ), true );
  216.  
  217. if ( attrs != null && attrs.Length > 0 )
  218. {
  219. CorpseNameAttribute attr = attrs[0] as CorpseNameAttribute;
  220.  
  221. if ( attr != null )
  222. return attr.Name;
  223. }
  224.  
  225. return null;
  226. }
  227.  
  228. public static void Initialize()
  229. {
  230. Mobile.CreateCorpseHandler += new CreateCorpseHandler( Mobile_CreateCorpseHandler );
  231. }
  232.  
  233. public static Container Mobile_CreateCorpseHandler( Mobile owner, HairInfo hair, FacialHairInfo facialhair, List<Item> initialContent, List<Item> equipItems )
  234. {
  235. bool shouldFillCorpse = true;
  236.  
  237. //if ( owner is BaseCreature )
  238. // shouldFillCorpse = !((BaseCreature)owner).IsBonded;
  239.  
  240. Corpse c;
  241. if( owner is MilitiaFighter )
  242. c = new MilitiaFighterCorpse( owner, hair, facialhair, shouldFillCorpse ? equipItems : new List<Item>() );
  243. else
  244. c = new Corpse( owner, hair, facialhair, shouldFillCorpse ? equipItems : new List<Item>() );
  245.  
  246. owner.Corpse = c;
  247.  
  248. if ( shouldFillCorpse )
  249. {
  250. for ( int i = 0; i < initialContent.Count; ++i )
  251. {
  252. Item item = initialContent[i];
  253.  
  254. if ( Core.AOS && owner.Player && item.Parent == owner.Backpack )
  255. c.AddItem( item );
  256. else
  257. c.DropItem( item );
  258.  
  259. if ( owner.Player && Core.AOS )
  260. c.SetRestoreInfo( item, item.Location );
  261. }
  262. }
  263. else
  264. {
  265. c.Carved = true; // TODO: Is it needed?
  266. }
  267.  
  268. Point3D loc = owner.Location;
  269. Map map = owner.Map;
  270.  
  271. if ( map == null || map == Map.Internal )
  272. {
  273. loc = owner.LogoutLocation;
  274. map = owner.LogoutMap;
  275. }
  276.  
  277. c.MoveToWorld( loc, map );
  278.  
  279. return c;
  280. }
  281.  
  282. public override bool IsPublicContainer{ get{ return true; } }
  283.  
  284. public Corpse( Mobile owner, List<Item> equipItems ) : this( owner, null, null, equipItems )
  285. {
  286. }
  287.  
  288. public Corpse( Mobile owner, HairInfo hair, FacialHairInfo facialhair, List<Item> equipItems )
  289. : base( 0x2006 )
  290. {
  291. // To supress console warnings, stackable must be true
  292. Stackable = true;
  293. Amount = owner.Body; // protocol defines that for itemid 0x2006, amount=body
  294. Stackable = false;
  295.  
  296. Movable = false;
  297. Hue = owner.Hue;
  298. Direction = owner.Direction;
  299. Name = owner.Name;
  300.  
  301. m_Owner = owner;
  302.  
  303. m_CorpseName = GetCorpseName( owner );
  304.  
  305. m_TimeOfDeath = DateTime.Now;
  306.  
  307. m_AccessLevel = owner.AccessLevel;
  308. m_Guild = owner.Guild as Guild;
  309. m_Kills = owner.Kills;
  310. m_Criminal = owner.Criminal;
  311.  
  312. m_Hair = hair;
  313. m_FacialHair = facialhair;
  314.  
  315.  
  316. // This corpse does not turn to bones if: the owner is not a player
  317. m_NoBones = !owner.Player;
  318.  
  319. m_Looters = new List<Mobile>();
  320. m_EquipItems = equipItems;
  321.  
  322. m_Aggressors = new List<Mobile>( owner.Aggressors.Count + owner.Aggressed.Count );
  323. bool addToAggressors = !( owner is BaseCreature );
  324.  
  325. TimeSpan lastTime = TimeSpan.MaxValue;
  326.  
  327. for ( int i = 0; i < owner.Aggressors.Count; ++i )
  328. {
  329. AggressorInfo info = owner.Aggressors[i];
  330.  
  331. if ( (DateTime.Now - info.LastCombatTime) < lastTime )
  332. {
  333. m_Killer = info.Attacker;
  334. lastTime = (DateTime.Now - info.LastCombatTime);
  335. }
  336.  
  337. if ( addToAggressors && !info.CriminalAggression )
  338. m_Aggressors.Add( info.Attacker );
  339. }
  340.  
  341. for ( int i = 0; i < owner.Aggressed.Count; ++i )
  342. {
  343. AggressorInfo info = owner.Aggressed[i];
  344.  
  345. if ( (DateTime.Now - info.LastCombatTime) < lastTime )
  346. {
  347. m_Killer = info.Defender;
  348. lastTime = (DateTime.Now - info.LastCombatTime);
  349. }
  350.  
  351. if ( addToAggressors )
  352. m_Aggressors.Add( info.Defender );
  353. }
  354.  
  355. if ( !addToAggressors )
  356. {
  357. BaseCreature bc = (BaseCreature)owner;
  358.  
  359. Mobile master = bc.GetMaster();
  360. if( master != null )
  361. m_Aggressors.Add( master );
  362.  
  363. List<DamageStore> rights = BaseCreature.GetLootingRights( bc.DamageEntries, bc.HitsMax );
  364. for ( int i = 0; i < rights.Count; ++i )
  365. {
  366. DamageStore ds = rights[i];
  367.  
  368. if ( ds.m_HasRight )
  369. m_Aggressors.Add( ds.m_Mobile );
  370. }
  371. }
  372.  
  373. BeginDecay( m_DefaultDecayTime );
  374. }
  375.  
  376. private void AssignInstancedLoot()
  377. {
  378. if ( m_InstancedItems == null )
  379. }
  380. m_InstancedItems = new Dictionary<Mobile, List<Item>>();
  381.  
  382. public Corpse( Serial serial ) : base( serial )
  383. {
  384. }
  385.  
  386. public override void Serialize( GenericWriter writer )
  387. {
  388. base.Serialize( writer );
  389.  
  390. writer.Write( (int) 10 ); // version
  391.  
  392. writer.WriteDeltaTime( m_TimeOfDeath );
  393.  
  394. List<KeyValuePair<Item, Point3D>> list = ( m_RestoreTable == null ? null : new List<KeyValuePair<Item, Point3D>>( m_RestoreTable ) );
  395. int count = ( list == null ? 0 : list.Count );
  396.  
  397. writer.Write( count );
  398.  
  399. for ( int i = 0; i < count; ++i )
  400. {
  401. KeyValuePair<Item, Point3D> kvp = list[i];
  402. Item item = kvp.Key;
  403. Point3D loc = kvp.Value;
  404.  
  405. writer.Write( item );
  406.  
  407. if ( item.Location == loc )
  408. {
  409. writer.Write( false );
  410. }
  411. else
  412. {
  413. writer.Write( true );
  414. writer.Write( loc );
  415. }
  416. }
  417.  
  418. writer.Write( m_VisitedByTaxidermist );
  419.  
  420. writer.Write( m_DecayTimer != null );
  421.  
  422. if ( m_DecayTimer != null )
  423. writer.WriteDeltaTime( m_DecayTime );
  424.  
  425. writer.Write( m_Looters );
  426. writer.Write( m_Killer );
  427.  
  428. writer.Write( (bool) m_Carved );
  429.  
  430. writer.Write( m_Aggressors );
  431.  
  432. writer.Write( m_Owner );
  433.  
  434. writer.Write( m_NoBones );
  435.  
  436. writer.Write( (string) m_CorpseName );
  437.  
  438. writer.Write( (int) m_AccessLevel );
  439. writer.Write( (Guild) m_Guild );
  440. writer.Write( (int) m_Kills );
  441. writer.Write( (bool) m_Criminal );
  442.  
  443. writer.Write( m_EquipItems );
  444. }
  445.  
  446. public override void Deserialize( GenericReader reader )
  447. {
  448. base.Deserialize( reader );
  449.  
  450. int version = reader.ReadInt();
  451.  
  452. switch ( version )
  453. {
  454. case 10:
  455. {
  456. m_TimeOfDeath = reader.ReadDeltaTime();
  457.  
  458. goto case 9;
  459. }
  460. case 9:
  461. {
  462. int count = reader.ReadInt();
  463.  
  464. for ( int i = 0; i < count; ++i )
  465. {
  466. Item item = reader.ReadItem();
  467.  
  468. if ( reader.ReadBool() )
  469. SetRestoreInfo( item, reader.ReadPoint3D() );
  470. else if ( item != null )
  471. SetRestoreInfo( item, item.Location );
  472. }
  473.  
  474. goto case 8;
  475. }
  476. case 8:
  477. {
  478. m_VisitedByTaxidermist = reader.ReadBool();
  479.  
  480. goto case 7;
  481. }
  482. case 7:
  483. {
  484. if ( reader.ReadBool() )
  485. BeginDecay( reader.ReadDeltaTime() - DateTime.Now );
  486.  
  487. goto case 6;
  488. }
  489. case 6:
  490. {
  491. m_Looters = reader.ReadStrongMobileList();
  492. m_Killer = reader.ReadMobile();
  493.  
  494. goto case 5;
  495. }
  496. case 5:
  497. {
  498. m_Carved = reader.ReadBool();
  499.  
  500. goto case 4;
  501. }
  502. case 4:
  503. {
  504. m_Aggressors = reader.ReadStrongMobileList();
  505.  
  506. goto case 3;
  507. }
  508. case 3:
  509. {
  510. m_Owner = reader.ReadMobile();
  511.  
  512. goto case 2;
  513. }
  514. case 2:
  515. {
  516. m_NoBones = reader.ReadBool();
  517.  
  518. goto case 1;
  519. }
  520. case 1:
  521. {
  522. m_CorpseName = reader.ReadString();
  523.  
  524. goto case 0;
  525. }
  526. case 0:
  527. {
  528. if ( version < 10 )
  529. m_TimeOfDeath = DateTime.Now;
  530.  
  531. if ( version < 7 )
  532. BeginDecay( m_DefaultDecayTime );
  533.  
  534. if ( version < 6 )
  535. m_Looters = new List<Mobile>();
  536.  
  537. if ( version < 4 )
  538. m_Aggressors = new List<Mobile>();
  539.  
  540. m_AccessLevel = (AccessLevel)reader.ReadInt();
  541. reader.ReadInt(); // guild reserve
  542. m_Kills = reader.ReadInt();
  543. m_Criminal = reader.ReadBool();
  544.  
  545. m_EquipItems = reader.ReadStrongItemList();
  546.  
  547. break;
  548. }
  549. }
  550. }
  551.  
  552. public override void SendInfoTo( NetState state, bool sendOplPacket )
  553. {
  554. base.SendInfoTo( state, sendOplPacket );
  555.  
  556. if ( ItemID == 0x2006 )
  557. {
  558. state.Send( new CorpseContent( state.Mobile, this ) );
  559. state.Send( new CorpseEquip( state.Mobile, this ) );
  560. }
  561. }
  562.  
  563. public bool IsCriminalAction( Mobile from )
  564. {
  565. if ( from == m_Owner || from.AccessLevel >= AccessLevel.GameMaster )
  566. return false;
  567.  
  568. Party p = Party.Get( m_Owner );
  569.  
  570. if ( p != null && p.Contains( from ) )
  571. {
  572. PartyMemberInfo pmi = p[m_Owner];
  573.  
  574. if ( pmi != null && pmi.CanLoot )
  575. return false;
  576. }
  577.  
  578. return ( NotorietyHandlers.CorpseNotoriety( from, this ) == Notoriety.Innocent );
  579. }
  580.  
  581. public override bool CheckItemUse( Mobile from, Item item )
  582. {
  583. if ( !base.CheckItemUse( from, item ) )
  584. return false;
  585.  
  586. if ( item != this )
  587. return CanLoot( from, item );
  588.  
  589. return true;
  590. }
  591.  
  592. public override bool CheckLift( Mobile from, Item item, ref LRReason reject )
  593. {
  594. if ( !base.CheckLift( from, item, ref reject ) )
  595. return false;
  596.  
  597. return CanLoot( from,item );
  598. }
  599.  
  600. public override void OnItemUsed( Mobile from, Item item )
  601. {
  602. base.OnItemUsed( from, item );
  603.  
  604. if ( from != m_Owner )
  605. from.RevealingAction();
  606.  
  607. if ( item != this && IsCriminalAction( from ) )
  608. from.CriminalAction( true );
  609.  
  610. if ( !m_Looters.Contains( from ) )
  611. m_Looters.Add( from );
  612. }
  613.  
  614. public override void OnItemLifted( Mobile from, Item item )
  615. {
  616. base.OnItemLifted( from, item );
  617.  
  618. if ( item != this && from != m_Owner )
  619. from.RevealingAction();
  620.  
  621. if ( item != this && IsCriminalAction( from ) )
  622. from.CriminalAction( true );
  623.  
  624. if ( !m_Looters.Contains( from ) )
  625. m_Looters.Add( from );
  626. }
  627.  
  628. private class OpenCorpseEntry : ContextMenuEntry
  629. {
  630. public OpenCorpseEntry() : base( 6215, 2 )
  631. {
  632. }
  633.  
  634. public override void OnClick()
  635. {
  636. Corpse corpse = Owner.Target as Corpse;
  637.  
  638. if ( corpse != null && Owner.From.CheckAlive() )
  639. corpse.Open( Owner.From, false );
  640. }
  641. }
  642.  
  643. public override void GetContextMenuEntries( Mobile from, List<ContextMenuEntry> list )
  644. {
  645. base.GetContextMenuEntries( from, list );
  646.  
  647. if ( Core.AOS && m_Owner == from && from.Alive )
  648. list.Add( new OpenCorpseEntry() );
  649. }
  650.  
  651. private Dictionary<Item, Point3D> m_RestoreTable;
  652.  
  653. public bool GetRestoreInfo( Item item, ref Point3D loc )
  654. {
  655. if ( m_RestoreTable == null || item == null )
  656. return false;
  657.  
  658. return m_RestoreTable.TryGetValue( item, out loc );
  659. }
  660.  
  661. public void SetRestoreInfo( Item item, Point3D loc )
  662. {
  663. if ( item == null )
  664. return;
  665.  
  666. if ( m_RestoreTable == null )
  667. m_RestoreTable = new Dictionary<Item, Point3D>();
  668.  
  669. m_RestoreTable[item] = loc;
  670. }
  671.  
  672. public void ClearRestoreInfo( Item item )
  673. {
  674. if ( m_RestoreTable == null || item == null )
  675. return;
  676.  
  677. m_RestoreTable.Remove( item );
  678.  
  679. if ( m_RestoreTable.Count == 0 )
  680. m_RestoreTable = null;
  681. }
  682.  
  683. public bool CanLoot( Mobile from, Item item )
  684. {
  685. if ( !IsCriminalAction( from ) )
  686. return true;
  687.  
  688. Map map = this.Map;
  689.  
  690. if ( map == null || (map.Rules & MapRules.HarmfulRestrictions) != 0 )
  691. return false;
  692.  
  693. return true;
  694. }
  695.  
  696. public bool CheckLoot( Mobile from, Item item )
  697. {
  698. if ( !CanLoot( from, item ) )
  699. {
  700. if ( m_Owner == null || !m_Owner.Player )
  701. from.SendLocalizedMessage( 1005035 ); // You did not earn the right to loot this creature!
  702. else
  703. from.SendLocalizedMessage( 1010049 ); // You may not loot this corpse.
  704.  
  705. return false;
  706. }
  707. else if ( IsCriminalAction( from ) )
  708. {
  709. if ( m_Owner == null || !m_Owner.Player )
  710. from.SendLocalizedMessage( 1005036 ); // Looting this monster corpse will be a criminal act!
  711. else
  712. from.SendLocalizedMessage( 1005038 ); // Looting this corpse will be a criminal act!
  713. }
  714.  
  715. return true;
  716. }
  717.  
  718. public virtual void Open( Mobile from, bool checkSelfLoot )
  719. {
  720. if ( from.AccessLevel > AccessLevel.Player || from.InRange( this.GetWorldLocation(), 2 ) )
  721. {
  722.  
  723. #region Self Looting
  724. bool selfLoot = ( checkSelfLoot && ( from == m_Owner ) );
  725.  
  726. if ( selfLoot )
  727. {
  728. List<Item> items = new List<Item>( this.Items );
  729.  
  730. bool gathered = false;
  731. bool didntFit = false;
  732.  
  733. Container pack = from.Backpack;
  734.  
  735. bool checkRobe = true;
  736.  
  737. for ( int i = 0; !didntFit && i < items.Count; ++i )
  738. {
  739. Item item = items[i];
  740. Point3D loc = item.Location;
  741.  
  742. if ( (item.Layer == Layer.Hair || item.Layer == Layer.FacialHair) || !item.Movable || !GetRestoreInfo( item, ref loc ) )
  743. continue;
  744.  
  745. if ( checkRobe )
  746. {
  747. DeathRobe robe = from.FindItemOnLayer( Layer.OuterTorso ) as DeathRobe;
  748.  
  749. if ( robe != null )
  750. {
  751. if ( Core.SE )
  752. {
  753. robe.Delete();
  754. }
  755. else
  756. {
  757. Map map = from.Map;
  758.  
  759. if ( map != null && map != Map.Internal )
  760. robe.MoveToWorld( from.Location, map );
  761. }
  762. }
  763. }
  764.  
  765. if ( m_EquipItems.Contains( item ) && from.EquipItem( item ) )
  766. {
  767. gathered = true;
  768. }
  769. else if ( pack != null && pack.CheckHold( from, item, false, true ) )
  770. {
  771. item.Location = loc;
  772. pack.AddItem( item );
  773. gathered = true;
  774. }
  775. else
  776. {
  777. didntFit = true;
  778. }
  779. }
  780.  
  781. if ( gathered && !didntFit )
  782. {
  783. m_Carved = true;
  784.  
  785. if ( ItemID == 0x2006 )
  786. {
  787. ProcessDelta();
  788. SendRemovePacket();
  789. ItemID = Utility.Random( 0xECA, 9 ); // bone graphic
  790. Hue = 0;
  791. ProcessDelta();
  792. }
  793.  
  794. from.PlaySound( 0x3E3 );
  795. from.SendLocalizedMessage( 1062471 ); // You quickly gather all of your belongings.
  796. return;
  797. }
  798.  
  799. if ( gathered && didntFit )
  800. from.SendLocalizedMessage( 1062472 ); // You gather some of your belongings. The rest remain on the corpse.
  801. }
  802.  
  803. #endregion
  804.  
  805. if ( !CheckLoot( from, null ) )
  806. return;
  807.  
  808. #region Quests
  809. PlayerMobile player = from as PlayerMobile;
  810.  
  811. if ( player != null )
  812. {
  813. QuestSystem qs = player.Quest;
  814.  
  815. if ( qs is UzeraanTurmoilQuest )
  816. {
  817. GetDaemonBoneObjective obj = qs.FindObjective( typeof( GetDaemonBoneObjective ) ) as GetDaemonBoneObjective;
  818.  
  819. if ( obj != null && obj.CorpseWithBone == this && ( !obj.Completed || UzeraanTurmoilQuest.HasLostDaemonBone( player ) ) )
  820. {
  821. Item bone = new QuestDaemonBone();
  822.  
  823. if ( player.PlaceInBackpack( bone ) )
  824. {
  825. obj.CorpseWithBone = null;
  826. player.SendLocalizedMessage( 1049341, "", 0x22 ); // You rummage through the bones and find a Daemon Bone! You quickly place the item in your pack.
  827.  
  828. if ( !obj.Completed )
  829. obj.Complete();
  830. }
  831. else
  832. {
  833. bone.Delete();
  834. player.SendLocalizedMessage( 1049342, "", 0x22 ); // Rummaging through the bones you find a Daemon Bone, but can't pick it up because your pack is too full. Come back when you have more room in your pack.
  835. }
  836.  
  837. return;
  838. }
  839. }
  840. else if ( qs is TheSummoningQuest )
  841. {
  842. VanquishDaemonObjective obj = qs.FindObjective( typeof( VanquishDaemonObjective ) ) as VanquishDaemonObjective;
  843.  
  844. if ( obj != null && obj.Completed && obj.CorpseWithSkull == this )
  845. {
  846. GoldenSkull sk = new GoldenSkull();
  847.  
  848. if ( player.PlaceInBackpack( sk ) )
  849. {
  850. obj.CorpseWithSkull = null;
  851. player.SendLocalizedMessage( 1050022 ); // For your valor in combating the devourer, you have been awarded a golden skull.
  852. qs.Complete();
  853. }
  854. else
  855. {
  856. sk.Delete();
  857. player.SendLocalizedMessage( 1050023 ); // You find a golden skull, but your backpack is too full to carry it.
  858. }
  859. }
  860. }
  861. }
  862.  
  863. #endregion
  864.  
  865. base.OnDoubleClick( from );
  866.  
  867. if ( from != m_Owner )
  868. from.RevealingAction();
  869. }
  870. else
  871. {
  872. from.SendLocalizedMessage( 500446 ); // That is too far away.
  873. return;
  874. }
  875. }
  876.  
  877. public override void OnDoubleClick( Mobile from )
  878. {
  879. Open( from, Core.AOS );
  880. }
  881.  
  882. public override bool CheckContentDisplay( Mobile from )
  883. {
  884. return false;
  885. }
  886.  
  887. public override bool DisplaysContent{ get{ return false; } }
  888.  
  889. public override void AddNameProperty( ObjectPropertyList list )
  890. {
  891. if ( ItemID == 0x2006 ) // Corpse form
  892. {
  893. if ( m_CorpseName != null )
  894. list.Add( m_CorpseName );
  895. else
  896. list.Add( 1046414, this.Name ); // the remains of ~1_NAME~
  897. }
  898. else // Bone form
  899. {
  900. list.Add( 1046414, this.Name ); // the remains of ~1_NAME~
  901. }
  902. }
  903.  
  904. public override void OnAosSingleClick( Mobile from )
  905. {
  906. int hue = Notoriety.GetHue( NotorietyHandlers.CorpseNotoriety( from, this ) );
  907. ObjectPropertyList opl = this.PropertyList;
  908.  
  909. if ( opl.Header > 0 )
  910. from.Send( new MessageLocalized( Serial, ItemID, MessageType.Label, hue, 3, opl.Header, Name, opl.HeaderArgs ) );
  911. }
  912.  
  913. public override void OnSingleClick( Mobile from )
  914. {
  915. int hue = Notoriety.GetHue( NotorietyHandlers.CorpseNotoriety( from, this ) );
  916.  
  917. if ( ItemID == 0x2006 ) // Corpse form
  918. {
  919. if ( m_CorpseName != null )
  920. from.Send( new AsciiMessage( Serial, ItemID, MessageType.Label, hue, 3, "", m_CorpseName ) );
  921. else
  922. from.Send( new MessageLocalized( Serial, ItemID, MessageType.Label, hue, 3, 1046414, "", Name ) );
  923. }
  924. else // Bone form
  925. {
  926. from.Send( new MessageLocalized( Serial, ItemID, MessageType.Label, hue, 3, 1046414, "", Name ) );
  927. }
  928. }
  929.  
  930. public void Carve( Mobile from, Item item )
  931. {
  932. if ( IsCriminalAction( from ) && this.Map != null && (this.Map.Rules & MapRules.HarmfulRestrictions) != 0 )
  933. {
  934. if ( m_Owner == null || !m_Owner.Player )
  935. from.SendLocalizedMessage( 1005035 ); // You did not earn the right to loot this creature!
  936. else
  937. from.SendLocalizedMessage( 1010049 ); // You may not loot this corpse.
  938.  
  939. return;
  940. }
  941.  
  942. Mobile dead = m_Owner;
  943.  
  944. if ( m_Carved || dead == null )
  945. {
  946. from.SendLocalizedMessage( 500485 ); // You see nothing useful to carve from the corpse.
  947. }
  948. else if ( ((Body)Amount).IsHuman && ItemID == 0x2006 )
  949. {
  950. new Blood( 0x122D ).MoveToWorld( Location, Map );
  951.  
  952. new Torso().MoveToWorld( Location, Map );
  953. new LeftLeg().MoveToWorld( Location, Map );
  954. new LeftArm().MoveToWorld( Location, Map );
  955. new RightLeg().MoveToWorld( Location, Map );
  956. new RightArm().MoveToWorld( Location, Map );
  957. new Head( dead.Name ).MoveToWorld( Location, Map );
  958.  
  959. m_Carved = true;
  960.  
  961. ProcessDelta();
  962. SendRemovePacket();
  963. ItemID = Utility.Random( 0xECA, 9 ); // bone graphic
  964. Hue = 0;
  965. ProcessDelta();
  966.  
  967. if ( IsCriminalAction( from ) )
  968. from.CriminalAction( true );
  969. }
  970. else if ( dead is BaseCreature )
  971. {
  972. ((BaseCreature)dead).OnCarve( from, this );
  973. }
  974. else
  975. {
  976. from.SendLocalizedMessage( 500485 ); // You see nothing useful to carve from the corpse.
  977. }
  978. }
  979. }
  980. }
Advertisement
Add Comment
Please, Sign In to add comment