You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

277 lines
6.8 KiB

  1. module.exports = {
  2. name: 'Merrywinter',
  3. description: 'The Winter Man has returned to the isles, bringing gifts, games and snow.',
  4. distance: -1,
  5. cron: '0 0 2-31 12 *',
  6. disabled: true,
  7. events: {
  8. },
  9. helpers: {
  10. },
  11. phases: [{
  12. type: 'spawnMob',
  13. mobs: {
  14. name: 'The Winter Man',
  15. attackable: false,
  16. level: 20,
  17. cell: 2,
  18. sheetName: 'server/mods/event-xmas/images/mobs.png',
  19. id: 'giftyBags',
  20. hpMult: 1,
  21. pos: {
  22. x: 106,
  23. y: 46
  24. },
  25. dialogue: {
  26. auto: true,
  27. config: {
  28. 1: {
  29. msg: [{
  30. msg: 'A visitor, welcome!',
  31. options: [1.1, 1.2, 1.3]
  32. }],
  33. options: {
  34. 1.1: {
  35. msg: 'Who are you?',
  36. goto: '2'
  37. },
  38. 1.2: {
  39. msg: 'I would like to give you some snowflakes.',
  40. goto: 'giveSnowflakes'
  41. },
  42. 1.3: {
  43. msg: 'Do you have anything for sale?',
  44. goto: 'tradeBuy'
  45. }
  46. }
  47. },
  48. 2: {
  49. msg: [{
  50. msg: 'I am the place where snow began, for I am the Winter Man.',
  51. options: [2.1]
  52. }],
  53. options: {
  54. 2.1: {
  55. msg: 'What are you doing here?',
  56. goto: '3'
  57. }
  58. }
  59. },
  60. 3: {
  61. msg: [{
  62. msg: 'I came in the night to bring the cold, have you not heard the story told?',
  63. options: [3.1]
  64. }],
  65. options: {
  66. 3.1: {
  67. msg: 'Could you tell it to me?',
  68. goto: '4'
  69. }
  70. }
  71. },
  72. 4: {
  73. msg: [{
  74. msg: 'On the shortest night each year, the Man of Winter lends an ear<br />To wishes mouthed in quiet ire; injustices or things required<br />He\'ll send them gifts in the strangest places; fishing lines or fireplaces<br />For the Winter Man has come to give, to the poor and lonely and those who grieve<br /><br />And when the snows have come to pass, the Winter Man only one thing asks<br />That should you sense someone desire, you\'ll assist as they require<br />Then when winter comes around again, keep an eye out for your icy friend<br />For he is the place where cold began at the start of time; the Winter Man',
  75. options: [1.2, 1.3]
  76. }]
  77. },
  78. giveSnowflakes: {
  79. msg: [{
  80. msg: 'Why, thank you!',
  81. options: [1.1]
  82. }],
  83. method: function (obj) {
  84. let inventory = obj.inventory;
  85. let snowflakes = inventory.items.find(i => (i.name === 'Snowflake'));
  86. if ((!snowflakes) || (snowflakes.quantity < 15))
  87. return 'Sorry, please come back when you have at least fifteen.';
  88. while (true) {
  89. snowflakes = inventory.items.find(i => (i.name === 'Snowflake'));
  90. if ((!snowflakes) || (snowflakes.quantity < 15))
  91. return;
  92. else if ((!inventory.hasSpace()) && (snowflakes.quantity !== 15))
  93. return 'Sorry, it seems you don\'t have enough space to accept my gifts.';
  94. obj.reputation.getReputation('theWinterMan', 100);
  95. let chances = {
  96. 'Bottomless Eggnog': 3,
  97. 'Sprig of Mistletoe': 50,
  98. 'Merrywinter Play Script': 20,
  99. 'Unique Snowflake': 27
  100. };
  101. let rewards = [{
  102. name: 'Bottomless Eggnog',
  103. type: 'toy',
  104. sprite: [1, 1],
  105. spritesheet: 'server/mods/event-xmas/images/items.png',
  106. description: 'Makes you merry, makes you shine.',
  107. worth: 0,
  108. cdMax: 1714,
  109. noSalvage: true,
  110. noAugment: true
  111. }, {
  112. name: 'Sprig of Mistletoe',
  113. type: 'consumable',
  114. sprite: [3, 1],
  115. spritesheet: 'server/mods/event-xmas/images/items.png',
  116. description: 'Blows a kiss to your one true love...or whoever\'s closest',
  117. worth: 0,
  118. noSalvage: true,
  119. noAugment: true,
  120. uses: 5
  121. }, {
  122. name: 'Merrywinter Play Script',
  123. type: 'consumable',
  124. sprite: [2, 1],
  125. spritesheet: 'server/mods/event-xmas/images/items.png',
  126. description: 'Recites a line from the Merrywinter play',
  127. quantity: 1,
  128. worth: 0,
  129. noSalvage: true,
  130. noAugment: true
  131. }, {
  132. name: 'Unique Snowflake',
  133. spritesheet: 'server/mods/event-xmas/images/items.png',
  134. material: true,
  135. sprite: [1, 2],
  136. quantity: 1
  137. }];
  138. let pool = [];
  139. Object.keys(chances).forEach(function (c) {
  140. for (let i = 0; i < chances[c]; i++)
  141. pool.push(c);
  142. });
  143. let pick = pool[~~(Math.random() * pool.length)];
  144. let blueprint = rewards.find(r => (r.name === pick));
  145. inventory.getItem(extend(true, {}, blueprint));
  146. inventory.destroyItem(snowflakes.id, 15);
  147. }
  148. }
  149. },
  150. tradeBuy: {
  151. cpn: 'trade',
  152. method: 'startBuy',
  153. args: [{
  154. targetName: 'the winter man'
  155. }]
  156. }
  157. }
  158. },
  159. trade: {
  160. items: {
  161. min: 0,
  162. max: 0
  163. },
  164. forceItems: [{
  165. type: 'skin',
  166. id: '3.1',
  167. infinite: true,
  168. worth: {
  169. currency: 'Unique Snowflake',
  170. amount: 15
  171. },
  172. factions: [{
  173. id: 'theWinterMan',
  174. tier: 4
  175. }]
  176. }, {
  177. name: 'Enchanted Wreath',
  178. spritesheet: 'server/mods/event-xmas/images/items.png',
  179. sprite: [0, 2],
  180. slot: 'neck',
  181. type: 'Necklace',
  182. level: 8,
  183. quality: 3,
  184. worth: {
  185. currency: 'Unique Snowflake',
  186. amount: 4
  187. },
  188. stats: {
  189. magicFind: 35,
  190. castSpeed: 25,
  191. attackSpeed: 25
  192. },
  193. factions: [{
  194. id: 'theWinterMan',
  195. tier: 4
  196. }],
  197. infinite: true,
  198. noAugment: true,
  199. noSalvage: true,
  200. noDrop: true,
  201. noDestroy: true
  202. }],
  203. faction: {
  204. id: 'theWinterMan'
  205. },
  206. level: {
  207. min: 1,
  208. max: 5
  209. },
  210. markup: {
  211. buy: 0.25,
  212. sell: 2.5
  213. }
  214. }
  215. }
  216. }, {
  217. type: 'hookEvents',
  218. events: {
  219. onCompleteQuest: function (quest) {
  220. quest.rewards.push({
  221. name: 'Snowflake',
  222. spritesheet: 'server/mods/event-xmas/images/items.png',
  223. material: true,
  224. sprite: [3, 0],
  225. quantity: 1
  226. });
  227. },
  228. onBeforeBuildMob: function (zone, mobName, blueprint) {
  229. try {
  230. let zoneFile = require('../../' + zone + '/zone.js');
  231. let override = _.getDeepProperty(zoneFile, ['mobs', mobName]);
  232. if (override)
  233. extend(true, blueprint, override);
  234. } catch (e) {}
  235. },
  236. beforeGatherResource: function (gatherResult, gatherer) {
  237. let itemName = gatherResult.blueprint.itemName;
  238. if ((!itemName) || (itemName.toLowerCase() !== 'snowflake'))
  239. return;
  240. gatherer.reputation.getReputation('theWinterMan', 40);
  241. if ((gatherResult.name !== 'Gilded Gift') || (Math.random() >= 0.05))
  242. return;
  243. gatherResult.items.push({
  244. name: 'Wizard\'s Vice',
  245. spritesheet: 'server/mods/event-xmas/images/items.png',
  246. type: 'Reward Card',
  247. description: 'Reward: Scented Beard Oil',
  248. noSalvage: true,
  249. sprite: [0, 1],
  250. quantity: 1,
  251. quality: 2,
  252. setSize: 5
  253. });
  254. }
  255. }
  256. }]
  257. };