Advertisement
Guest User

Untitled

a guest
Oct 21st, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.53 KB | None | 0 0
  1. using System;
  2. using Server.Engines.XmlSpawner2;
  3. using Server.ContextMenus;
  4. using System.Collections.Generic;
  5. using Server.Items;
  6.  
  7. namespace Server.Mobiles
  8. {
  9. [CorpseName("a horse corpse")]
  10. [TypeAlias("Server.Mobiles.BrownHorse", "Server.Mobiles.DirtyHorse", "Server.Mobiles.GrayHorse", "Server.Mobiles.TanHorse")]
  11. public class ReqPrototypeHorse : BaseMount
  12. {
  13. private bool m_BardingExceptional;
  14. private Mobile m_BardingCrafter;
  15. private int m_BardingHP;
  16. private bool m_HasBarding;
  17. private CraftResource m_BardingResource;
  18. private static readonly int[] m_IDs = new int[]
  19. {
  20. 0xC8, 0x3E9F,
  21. 0xE2, 0x3EA0,
  22. 0xE4, 0x3EA1,
  23. 0xCC, 0x3EA2
  24. };
  25. [Constructable]
  26. public ReqPrototypeHorse()
  27. : this("a horse")
  28. {
  29. }
  30.  
  31. [Constructable]
  32. public ReqPrototypeHorse(string name)
  33. : base(name, 0xE2, 0x3EA0, AIType.AI_Animal, FightMode.Aggressor, 10, 1, 0.2, 0.4)
  34. {
  35. int random = Utility.Random(4);
  36.  
  37. this.Body = m_IDs[random * 2];
  38. this.ItemID = m_IDs[random * 2 + 1];
  39. this.BaseSoundID = 0xA8;
  40.  
  41. this.SetStr(22, 98);
  42. this.SetDex(56, 75);
  43. this.SetInt(6, 10);
  44.  
  45. this.SetHits(28, 45);
  46. this.SetMana(0);
  47.  
  48. this.SetDamage(3, 4);
  49.  
  50. this.SetDamageType(ResistanceType.Physical, 100);
  51.  
  52. this.SetResistance(ResistanceType.Physical, 15, 20);
  53.  
  54. this.SetSkill(SkillName.MagicResist, 25.1, 30.0);
  55. this.SetSkill(SkillName.Tactics, 29.3, 44.0);
  56. this.SetSkill(SkillName.Wrestling, 29.3, 44.0);
  57.  
  58. this.Fame = 300;
  59. this.Karma = 300;
  60.  
  61. this.Tamable = true;
  62. this.ControlSlots = 1;
  63. this.MinTameSkill = 29.1;
  64.  
  65. Container pack = this.Backpack;
  66.  
  67. if (pack != null)
  68. pack.Delete();
  69.  
  70. pack = new StrongBackpack();
  71. pack.Movable = false;
  72.  
  73. this.AddItem(pack);
  74. }
  75.  
  76. public ReqPrototypeHorse(Serial serial)
  77. : base(serial)
  78. {
  79. }
  80.  
  81. [CommandProperty(AccessLevel.GameMaster)]
  82. public Mobile BardingCrafter
  83. {
  84. get
  85. {
  86. return this.m_BardingCrafter;
  87. }
  88. set
  89. {
  90. this.m_BardingCrafter = value;
  91. this.InvalidateProperties();
  92. }
  93. }
  94. [CommandProperty(AccessLevel.GameMaster)]
  95. public bool BardingExceptional
  96. {
  97. get
  98. {
  99. return this.m_BardingExceptional;
  100. }
  101. set
  102. {
  103. this.m_BardingExceptional = value;
  104. this.InvalidateProperties();
  105. }
  106. }
  107. [CommandProperty(AccessLevel.GameMaster)]
  108. public int BardingHP
  109. {
  110. get
  111. {
  112. return this.m_BardingHP;
  113. }
  114. set
  115. {
  116. this.m_BardingHP = value;
  117. this.InvalidateProperties();
  118. }
  119. }
  120. [CommandProperty(AccessLevel.GameMaster)]
  121. public bool HasBarding
  122. {
  123. get
  124. {
  125. return this.m_HasBarding;
  126. }
  127. set
  128. {
  129. this.m_HasBarding = value;
  130.  
  131. if (this.m_HasBarding)
  132. {
  133. this.Hue = CraftResources.GetHue(this.m_BardingResource);
  134. this.BodyValue = 284;
  135. this.ItemID = 16018;
  136. }
  137. else
  138. {
  139. this.BodyValue = 200;
  140. this.ItemID = 16031;
  141. this.Hue = 0;
  142. }
  143.  
  144. this.InvalidateProperties();
  145. }
  146. }
  147. [CommandProperty(AccessLevel.GameMaster)]
  148. public CraftResource BardingResource
  149. {
  150. get
  151. {
  152. return this.m_BardingResource;
  153. }
  154. set
  155. {
  156. this.m_BardingResource = value;
  157.  
  158. if (this.m_HasBarding)
  159. this.Hue = CraftResources.GetHue(value);
  160.  
  161. this.InvalidateProperties();
  162. }
  163. }
  164. [CommandProperty(AccessLevel.GameMaster)]
  165. public int BardingMaxHP
  166. {
  167. get
  168. {
  169. return this.m_BardingExceptional ? 2500 : 1000;
  170. }
  171. }
  172.  
  173.  
  174.  
  175. public override int Meat
  176. {
  177. get
  178. {
  179. return 3;
  180. }
  181. }
  182. public override int Hides
  183. {
  184. get
  185. {
  186. return 10;
  187. }
  188. }
  189. public override FoodType FavoriteFood
  190. {
  191. get
  192. {
  193. return FoodType.FruitsAndVegies | FoodType.GrainsAndHay;
  194. }
  195. }
  196.  
  197. public override void OnDoubleClick(Mobile from)
  198. {
  199. XMLReqHorse horseatt = XmlAttach.FindAttachment(this, typeof(XMLReqHorse)) as XMLReqHorse;
  200. if (horseatt != null)
  201. {
  202. if (horseatt.HasSaddle == true)
  203. {
  204. base.OnDoubleClick(from);
  205. return;
  206. }
  207.  
  208. if (horseatt.HasBags == true)
  209. {
  210. PackAnimal.TryPackOpen(this, from);
  211. return;
  212. }
  213. else
  214. {
  215. from.SendMessage("You must place a saddle on this mount if you wish to ride it.");
  216. return;
  217. }
  218. }
  219. else
  220. {
  221. return;
  222. }
  223. }
  224.  
  225. public class PackAnimalBackpackEntry : ContextMenuEntry
  226. {
  227. private readonly BaseCreature m_Animal;
  228. private readonly Mobile m_From;
  229.  
  230. public PackAnimalBackpackEntry(BaseCreature animal, Mobile from)
  231. : base(6145, 3)
  232. {
  233. this.m_Animal = animal;
  234. this.m_From = from;
  235.  
  236. if (animal.IsDeadPet)
  237. this.Enabled = false;
  238. }
  239.  
  240. public override void OnClick()
  241. {
  242. PackAnimal.TryPackOpen(this.m_Animal, this.m_From);
  243. }
  244. }
  245.  
  246. public class RemoveSaddleOrBag : ContextMenuEntry
  247. {
  248. private readonly BaseCreature m_Animal;
  249. private readonly Mobile m_From;
  250.  
  251. public RemoveSaddleOrBag(BaseCreature animal, Mobile from)
  252. : base(6145, 3)
  253. {
  254.  
  255. this.m_Animal = animal;
  256. this.m_From = from;
  257.  
  258. XMLReqHorse horseatt = XmlAttach.FindAttachment(this, typeof(XMLReqHorse)) as XMLReqHorse;
  259.  
  260. if (horseatt.HasBags || horseatt.HasSaddle)
  261. this.Enabled = true;
  262. else
  263. this.Enabled = false;
  264. }
  265.  
  266. public override void OnClick()
  267. {
  268. XMLReqHorse horseatt = XmlAttach.FindAttachment(this, typeof(XMLReqHorse)) as XMLReqHorse;
  269. if (horseatt.HasSaddle == true)
  270. {
  271. horseatt.HasSaddle = false;
  272. }
  273. if (horseatt.HasBags == true)
  274. {
  275. horseatt.HasBags = false;
  276. }
  277. }
  278. }
  279.  
  280. public override bool OnBeforeDeath()
  281. {
  282. if (!base.OnBeforeDeath())
  283. return false;
  284.  
  285. PackAnimal.CombineBackpacks(this);
  286.  
  287. return true;
  288. }
  289.  
  290. public override DeathMoveResult GetInventoryMoveResultFor(Item item)
  291. {
  292. return DeathMoveResult.MoveToCorpse;
  293. }
  294.  
  295. public override bool IsSnoop(Mobile from)
  296. {
  297. if (PackAnimal.CheckAccess(this, from))
  298. return false;
  299.  
  300. return base.IsSnoop(from);
  301. }
  302.  
  303. public override bool OnDragDrop(Mobile from, Item item)
  304. {
  305. if (this.CheckFeed(from, item))
  306. return true;
  307.  
  308. if (PackAnimal.CheckAccess(this, from))
  309. {
  310. this.AddToBackpack(item);
  311. return true;
  312. }
  313.  
  314. return base.OnDragDrop(from, item);
  315. }
  316.  
  317. public override bool CheckNonlocalDrop(Mobile from, Item item, Item target)
  318. {
  319. return PackAnimal.CheckAccess(this, from);
  320. }
  321.  
  322. public override bool CheckNonlocalLift(Mobile from, Item item)
  323. {
  324. return PackAnimal.CheckAccess(this, from);
  325. }
  326.  
  327. public override void GetContextMenuEntries(Mobile from, List<ContextMenuEntry> list)
  328. {
  329. base.GetContextMenuEntries(from, list);
  330. list.Add(new RemoveSaddleOrBag(this, from));
  331.  
  332. XMLReqHorse horseatt = XmlAttach.FindAttachment(this, typeof(XMLReqHorse)) as XMLReqHorse;
  333.  
  334. if (horseatt.HasBags == true)
  335. {
  336. PackAnimal.GetContextMenuEntries(this, from, list);
  337. }
  338. }
  339.  
  340.  
  341. public override void GetProperties(ObjectPropertyList list)
  342. {
  343. base.GetProperties(list);
  344.  
  345. if (this.m_HasBarding && this.m_BardingExceptional && this.m_BardingCrafter != null)
  346. list.Add(1060853, this.m_BardingCrafter.Name); // armor exceptionally crafted by ~1_val~
  347. }
  348.  
  349. public override void Serialize(GenericWriter writer)
  350. {
  351. base.Serialize(writer);
  352.  
  353. writer.Write((int)0); // version
  354.  
  355. writer.Write((bool)this.m_BardingExceptional);
  356. writer.Write((Mobile)this.m_BardingCrafter);
  357. writer.Write((bool)this.m_HasBarding);
  358. writer.Write((int)this.m_BardingHP);
  359. writer.Write((int)this.m_BardingResource);
  360. }
  361.  
  362. public override void Deserialize(GenericReader reader)
  363. {
  364. base.Deserialize(reader);
  365.  
  366. int version = reader.ReadInt();
  367.  
  368. this.m_BardingExceptional = reader.ReadBool();
  369. this.m_BardingCrafter = reader.ReadMobile();
  370. this.m_HasBarding = reader.ReadBool();
  371. this.m_BardingHP = reader.ReadInt();
  372. this.m_BardingResource = (CraftResource)reader.ReadInt();
  373. }
  374. }
  375. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement