Advertisement
Guest User

Untitled

a guest
Oct 11th, 2022
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.51 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using Stump.DofusProtocol.Types;
  4. using Stump.Server.WorldServer.Database.Quests;
  5. using Stump.Server.WorldServer.Game.Actors.RolePlay.Characters;
  6. using Stump.Server.WorldServer.Game.Interactives;
  7. using Stump.Server.WorldServer.Database.Interactives;
  8. using Stump.Server.WorldServer.Database.Items.Templates;
  9.  
  10. namespace Stump.Server.WorldServer.Game.Quests.Objectives
  11. {
  12. public class FreeFormObjective : QuestObjective
  13. {
  14. private int m_completion;
  15.  
  16. public FreeFormObjective(Character character, QuestObjectiveTemplate template, bool finished, int elementId, int amount) : base(character, template, finished)
  17. {
  18. Element = InteractiveManager.Instance.GetInteractive(elementId);
  19. Amount = amount;
  20. }
  21.  
  22. public FreeFormObjective(Character character, QuestObjectiveTemplate template, QuestObjectiveStatus finished, int elementId,int amount) : base(character, template, finished)
  23. {
  24. Element = InteractiveManager.Instance.GetInteractive(elementId);
  25. Amount = amount;
  26. }
  27.  
  28. public InteractiveSpawn Element
  29. {
  30. get;
  31. }
  32. public int Amount
  33. {
  34. get;
  35. }
  36. public int Completions
  37. {
  38. get { return ObjectiveRecord.Completion; }
  39. private set
  40. {
  41. m_completion = value;
  42. ObjectiveRecord.Completion = value;
  43. }
  44. }
  45.  
  46. public override bool CanSee()
  47. {
  48. return true;
  49. }
  50. public override void EnableObjective()
  51. {
  52. Character.InteractiveObject += OnInteractiveObject;
  53. }
  54. private void OnInteractiveObject(InteractiveSpawn ElementId, int amount)
  55. {
  56. if (ElementId.Id != ElementId.Id)
  57. return;
  58.  
  59. if (Completions + amount >= Amount)
  60. {
  61. Completions += amount;
  62. CompleteObjective();
  63. }
  64. else
  65. Completions += amount;
  66. }
  67. public override void DisableObjective()
  68. {
  69.  
  70. }
  71.  
  72. public override QuestObjectiveInformations GetQuestObjectiveInformations()
  73. {
  74. return new QuestObjectiveInformations((ushort)Template.Id, ObjectiveRecord.Status ? false : true, new string[0]);
  75. }
  76.  
  77. public override int Completion()
  78. {
  79. return Completions;
  80. }
  81. }
  82. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement