Advertisement
Guest User

Untitled

a guest
Jun 22nd, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.04 KB | None | 0 0
  1. using System;
  2. using System.Collections;
  3. using DOL.Database;
  4. using DOL.GS.PacketHandler;
  5.  
  6. namespace DOL.GS
  7. {
  8. public class ExtensionNPC : GameNPC
  9. {
  10. private const string ITEM_WEAK = "extension_npc.item";
  11. private const int COST = 50;
  12.  
  13. /// <summary>
  14. /// Adds messages to ArrayList which are sent when object is targeted
  15. /// </summary>
  16. /// <param name="player">GamePlayer that is examining this object</param>
  17. /// <returns>list with string messages</returns>
  18. public override IList GetExamineMessages(GamePlayer player)
  19. {
  20. /*
  21. * You examine Elvar Ironhand. He is friendly and is a smith.
  22. * [Give him an object to be repaired]
  23. */
  24. IList list = new ArrayList();
  25. list.Add("You target [" + GetName(0, false) + "]");
  26. list.Add("You examine " + GetName(0, false) + " " + GetPronoun(0, true) + " is " + GetAggroLevelString(player, false) + " and is an advanced smith.");
  27. list.Add("[Give him an object to be upgraded]");
  28. return list;
  29. }
  30.  
  31. public override bool Interact(GamePlayer player)
  32. {
  33. if (!base.Interact(player))
  34. return false;
  35.  
  36. SayTo(player, "Hello " + player.Name + ", just hand me an vest, glove or boot to have an extension added to it for Bounty Points.");
  37.  
  38. return true;
  39. }
  40.  
  41. public override bool ReceiveItem(GameLiving source, InventoryItem item)
  42. {
  43. if (source == null || item == null)
  44. return false;
  45.  
  46. GamePlayer player = source as GamePlayer;
  47. if (player == null)
  48. return false;
  49.  
  50. switch ((eInventorySlot)item.Item_Type)
  51. {
  52. case eInventorySlot.TorsoArmor:
  53. case eInventorySlot.HandsArmor:
  54. case eInventorySlot.FeetArmor: break;
  55. default:
  56. {
  57. SayTo(player, "I can only add an extension onto a vest, glove or boot!");
  58. return false;
  59. }
  60. }
  61.  
  62. if (item.Extension == 5)
  63. {
  64. SayTo(player, "Your item already has been upgraded!");
  65. return false;
  66. }
  67.  
  68. player.TempProperties.setProperty(ITEM_WEAK, new WeakRef(item));
  69. player.Out.SendMessage("It will cost " + COST + " Bounty Points to upgrade the " + item.Name, eChatType.CT_System, eChatLoc.CL_SystemWindow);
  70. player.Client.Out.SendCustomDialog("Do you accept to upgrade the " + item.Name, new CustomDialogResponse(DialogResponse));
  71.  
  72. return true;
  73. }
  74.  
  75. protected void DialogResponse(GamePlayer player, byte response)
  76. {
  77. WeakReference itemWeak = (WeakReference)player.TempProperties.getProperty(ITEM_WEAK, new WeakRef(null));
  78. player.TempProperties.removeProperty(ITEM_WEAK);
  79.  
  80. if (response != 0x01)
  81. return;
  82.  
  83. InventoryItem item = (InventoryItem)itemWeak.Target;
  84.  
  85. if (item == null || item.SlotPosition == (int)eInventorySlot.Ground
  86. || item.OwnerID == null || item.OwnerID != player.InternalID)
  87. {
  88. player.Out.SendMessage("Invalid item.", eChatType.CT_System, eChatLoc.CL_SystemWindow);
  89. return;
  90. }
  91.  
  92. if (!player.RemoveBountyPoints(COST))
  93. {
  94. player.Out.SendMessage("You don't have enough bounty points, you need " + COST + ".", eChatType.CT_System, eChatLoc.CL_SystemWindow);
  95. return;
  96. }
  97.  
  98. player.Out.SendMessage("You pay " + GetName(0, false) + " " + COST + " bounty points.", eChatType.CT_System, eChatLoc.CL_SystemWindow);
  99.  
  100. item.Extension = 5;
  101. GameServer.Database.SaveObject(item);
  102.  
  103. SayTo(player, "It's done. Your " + item.Name + " has been upgraded!");
  104. return;
  105. }
  106. }
  107. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement