25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.
 
 
 

345 satır
10 KiB

  1. define([
  2. 'items/generator'
  3. ], function (
  4. itemGenerator
  5. ) {
  6. return {
  7. mapFile: null,
  8. mapW: null,
  9. mapH: null,
  10. mapOffset: {
  11. x: 79,
  12. y: 32
  13. },
  14. init: function () {
  15. this.mapFile = require.nodeRequire('../../../mods/event-xmas/maps/tutorial/map');
  16. this.mapW = this.mapFile.width;
  17. this.mapH = this.mapFile.height;
  18. //this.events.on('onBeforeGetDialogue', this.onBeforeGetDialogue.bind(this));
  19. this.events.on('onBeforeGetResourceList', this.onBeforeGetResourceList.bind(this));
  20. //this.events.on('onBeforeGetEventList', this.onBeforeGetEventList.bind(this));
  21. this.events.on('onBeforeGetCardReward', this.onBeforeGetCardReward.bind(this));
  22. this.events.on('onBeforeGetSkins', this.onBeforeGetSkins.bind(this));
  23. //this.events.on('onAfterGetZone', this.onAfterGetZone.bind(this));
  24. //this.events.on('onBeforeGetHerbConfig', this.onBeforeGetHerbConfig.bind(this));
  25. //this.events.on('onBeforeBuildLayerTile', this.onBeforeBuildLayerTile.bind(this));
  26. //this.events.on('onAfterGetLayerObjects', this.onAfterGetLayerObjects.bind(this));
  27. this.events.on('onBeforeGetFactions', this.onBeforeGetFactions.bind(this));
  28. this.events.on('onBeforeUseItem', this.onBeforeUseItem.bind(this));
  29. this.events.on('onBeforeGetEffect', this.onBeforeGetEffect.bind(this));
  30. this.events.on('onBeforeGetCardsConfig', this.onBeforeGetCardsConfig.bind(this));
  31. },
  32. onBeforeGetCardsConfig: function (config) {
  33. extend(true, config, {
  34. 'Cheer and Spear': {
  35. chance: 40,
  36. reward: 'Rare Festive Spear',
  37. setSize: 3,
  38. mobName: ['frost crab', 'rude holf'],
  39. spritesheet: `server/mods/event-xmas/images/items.png`,
  40. sprite: [0, 1],
  41. quality: 2
  42. },
  43. "Wizard's Vice": {
  44. reward: 'Scented Beard Oil'
  45. }
  46. });
  47. },
  48. onBeforeGetSkins: function (skins) {
  49. skins['bearded wizard'] = {
  50. name: 'Bearded Wizard',
  51. sprite: [0, 0],
  52. spritesheet: `${this.folderName}/images/skins.png`
  53. };
  54. },
  55. onBeforeGetEffect: function (result) {
  56. if (result.type.toLowerCase() == 'merry')
  57. result.url = `${this.relativeFolderName}/effects/effectMerry.js`
  58. },
  59. onBeforeUseItem: function (obj, item, result) {
  60. var handler = {
  61. 'Merrywinter Play Script': function (obj, item, result) {
  62. var lines = [
  63. `A catch, a catch, our lines are taut, somebody grab the wheel`,
  64. `And when the catch was on the ship, all three stood 'round in awe`,
  65. `And with each present handed, and each snowflake landed, when the winter morn began`,
  66. `As each man got the things to which he'd previously alluded`,
  67. `But it was still taut though it moved for naught, a truly curious sign`,
  68. `But then it passed, the mighty thrashing, their chance of food expired`,
  69. `Declared to all (or those who'd hear), what passed the night before`,
  70. `Each one then, with their gift in hand, thanked the Winter Man`,
  71. `For not a man could gaze on it and believe that which he saw`,
  72. `For they were out, the three of them, fishing off the shore`,
  73. `I need to get back home sometime, before the moon's alighted`,
  74. `Inscribed on each in jet black ink, the recipient's relations`,
  75. `It started on a morning pale, with winter hardly come`,
  76. `Later they would cheerfully relate what the contents had included`,
  77. `My boy needs clothes, and books for school, but money's hard to find`,
  78. `My hooks are busted and rust encrusted, I know not how we'll eat`,
  79. `My wife has lost her silver ring, a gift from my dad`,
  80. `Reel it in, let's see this thing that had us so excited`,
  81. `So there they sat: dejected, silent, their moods now foul and gray`,
  82. `The first announced before he pounced to grab hold of the reel`,
  83. `The first then nodded and down, he plodded; a picture of defeat`,
  84. `The second chimed: Oh friends it seems, Ill luck is all we've had`,
  85. `The third announced: My friends, my friends, I am in such a bind`,
  86. `The third looked on with a heartfelt sigh to see the broken line`,
  87. `Waterproof boxes wrapped in lints and colorful decorations`,
  88. `What happened there, are we to starve? The second then enquired`,
  89. `When fishermen beyond the vale, their bellies full of rum`,
  90. `When with a mighty shudder, and a trembling rudder, their boat shook on the bay`
  91. ];
  92. obj.syncer.set(false, 'chatter', 'color', 0x48edff);
  93. var pick = ~~(Math.random() * (lines.length - 1));
  94. obj.syncer.set(false, 'chatter', 'msg', lines[pick] + '\r\n' + lines[pick + 1]);
  95. },
  96. 'Sprig of Mistletoe': function (obj, item, result) {
  97. var ox = obj.x;
  98. var oy = obj.y;
  99. var objects = obj.instance.objects.objects.filter(o => (((o.mob) || (o.player)) && (o.name) && (o != obj)));
  100. var closestDistance = 999;
  101. var closest = null;
  102. var oLen = objects.length;
  103. for (var i = 0; i < oLen; i++) {
  104. var m = objects[i];
  105. var distance = Math.max(Math.abs(ox - m.x), Math.abs(oy - m.y));
  106. if (distance < closestDistance) {
  107. closestDistance = distance;
  108. closest = m;
  109. }
  110. }
  111. if (!closest)
  112. return;
  113. var prefix = (closest.mob) ? 'the' : '';
  114. obj.syncer.set(false, 'chatter', 'color', 0xfc66f7);
  115. obj.syncer.set(false, 'chatter', 'msg', `...Smooches ${prefix} ${closest.name}...`);
  116. obj.instance.objects.buildObjects([{
  117. x: obj.x,
  118. y: obj.y,
  119. ttl: 10,
  120. properties: {
  121. cpnParticles: {
  122. simplify: function () {
  123. return {
  124. type: 'particles',
  125. blueprint: {
  126. color: {
  127. start: ['ff4252', 'ffc66f7', 'de43ae', 'd43346'],
  128. end: ['ff4252', 'ffc66f7', 'de43ae', 'd43346']
  129. },
  130. scale: {
  131. start: {
  132. min: 4,
  133. max: 10
  134. },
  135. end: {
  136. min: 4,
  137. max: 6
  138. }
  139. },
  140. speed: {
  141. start: {
  142. min: 0,
  143. max: 12
  144. },
  145. end: {
  146. min: 0,
  147. max: 4
  148. }
  149. },
  150. lifetime: {
  151. min: 1,
  152. max: 4
  153. },
  154. alpha: {
  155. start: 1,
  156. end: 0
  157. },
  158. randomScale: true,
  159. randomSpeed: true,
  160. chance: 0.3,
  161. randomColor: true,
  162. blendMode: 'add',
  163. spawnType: 'ring',
  164. spawnCircle: {
  165. r: 24,
  166. minR: 22
  167. }
  168. }
  169. }
  170. }
  171. }
  172. }
  173. }]);
  174. },
  175. 'Bottomless Eggnog': function (obj, item, result) {
  176. obj.effects.addEffect({
  177. type: 'merry',
  178. ttl: 514
  179. });
  180. },
  181. 'Scented Beard Oil': function (obj, item, result) {
  182. obj.syncer.set(false, 'chatter', 'color', 0xfc66f7);
  183. obj.syncer.set(false, 'chatter', 'msg', `...Rubs his beard throughtfully...`);
  184. }
  185. }[item.name];
  186. if (!handler)
  187. return;
  188. handler(obj, item, result);
  189. },
  190. onBeforeGetFactions: function (mappings) {
  191. extend(true, mappings, {
  192. theWinterMan: `${this.relativeFolderName}/factions/theWinterMan`
  193. });
  194. },
  195. onAfterGetLayerObjects: function (info) {
  196. if (info.map != 'tutorial')
  197. return;
  198. var layer = this.mapFile.layers.find(l => (l.name == info.layer));
  199. if (layer) {
  200. var offset = this.mapOffset;
  201. var mapScale = this.mapFile.tilesets[0].tileheight;
  202. layer.objects.forEach(function (l) {
  203. var newO = extend(true, {}, l);
  204. newO.x += (offset.x * mapScale);
  205. newO.y += (offset.y * mapScale);
  206. info.objects.push(newO);
  207. }, this);
  208. }
  209. },
  210. onBeforeBuildLayerTile: function (info) {
  211. if (info.map != 'tutorial')
  212. return;
  213. var offset = this.mapOffset;
  214. var x = info.x;
  215. var y = info.y;
  216. if ((x - offset.x < 0) || (y - offset.y < 0) || (x - offset.x >= this.mapW) || (y - offset.y >= this.mapH))
  217. return;
  218. var i = ((y - offset.y) * this.mapW) + (x - offset.x);
  219. var layer = this.mapFile.layers.find(l => (l.name == info.layer));
  220. if (layer) {
  221. var cell = layer.data[i];
  222. if (cell)
  223. info.cell = layer.data[i];
  224. }
  225. },
  226. onAfterGetZone: function (zone, config) {
  227. try {
  228. var modZone = require(this.relativeFolderName + '/maps/' + zone + '/zone.js');
  229. extend(true, config, modZone);
  230. } catch (e) {
  231. }
  232. },
  233. onBeforeGetHerbConfig: function (herbs) {
  234. extend(true, herbs, {
  235. 'Festive Gift': {
  236. sheetName: 'objects',
  237. cell: 166,
  238. itemSprite: [3, 0],
  239. itemName: 'Snowflake',
  240. itemSheet: `${this.folderName}/images/items.png`,
  241. itemAmount: [1, 2]
  242. },
  243. 'Giant Gift': {
  244. sheetName: 'bigObjects',
  245. cell: 14,
  246. itemSprite: [3, 0],
  247. itemName: 'Snowflake',
  248. itemSheet: `${this.folderName}/images/items.png`,
  249. itemAmount: [3, 5]
  250. },
  251. 'Gilded Gift': {
  252. sheetName: 'bigObjects',
  253. cell: 22,
  254. itemSprite: [3, 0],
  255. itemName: 'Snowflake',
  256. itemSheet: `${this.folderName}/images/items.png`,
  257. itemAmount: [5, 8]
  258. }
  259. });
  260. },
  261. onBeforeGetCardReward: function (msg) {
  262. if (msg.reward == 'Rare Festive Spear') {
  263. msg.handler = function (card) {
  264. return itemGenerator.generate({
  265. name: 'Festive Spear',
  266. level: [5, 15],
  267. noSpell: true,
  268. slot: 'twoHanded',
  269. type: 'Spear',
  270. quality: 2,
  271. stats: ['attackSpeed|10'],
  272. spritesheet: `server/mods/event-xmas/images/items.png`,
  273. sprite: [0, 0]
  274. });
  275. };
  276. } else if (msg.reward == 'Scented Beard Oil') {
  277. msg.handler = function (card) {
  278. return {
  279. name: 'Scented Beard Oil',
  280. type: 'toy',
  281. sprite: [3, 2],
  282. spritesheet: `server/mods/event-xmas/images/items.png`,
  283. description: `For some extra 'ho' in your holy vengeance.`,
  284. worth: 0,
  285. cdMax: 300,
  286. noSalvage: true,
  287. noAugment: true
  288. };
  289. };
  290. }
  291. },
  292. onBeforeGetResourceList: function (list) {
  293. list.push(`${this.folderName}/images/mobs.png`);
  294. list.push(`${this.folderName}/images/skins.png`);
  295. },
  296. onBeforeGetEventList: function (zone, list) {
  297. if (zone != 'tutorial')
  298. return;
  299. list.push(this.relativeFolderName + '/maps/tutorial/events/xmas.js');
  300. },
  301. onBeforeGetDialogue: function (zone, config) {
  302. try {
  303. var modDialogue = require(this.relativeFolderName + '/maps/' + zone + '/dialogues.js');
  304. extend(true, config, modDialogue);
  305. } catch (e) {
  306. }
  307. }
  308. };
  309. });