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.
 
 
 

245 lines
5.9 KiB

  1. module.exports = {
  2. name: 'Event: Halloween',
  3. mapOffset: {
  4. x: 23,
  5. y: 86
  6. },
  7. extraScripts: [
  8. 'maps/fjolarok/events/halloween.js',
  9. 'mtx/summonPumpkinSkeleton.js',
  10. 'spells/spellScatterPumpkinPieces.js'
  11. ],
  12. mapFile: null,
  13. mapW: null,
  14. mapH: null,
  15. init: function () {
  16. this.mapFile = require('./maps/fjolarok/map');
  17. this.mapW = this.mapFile.width;
  18. this.mapH = this.mapFile.height;
  19. this.events.on('onBeforeGetFactions', this.onBeforeGetFactions.bind(this));
  20. this.events.on('onBeforeGetSkins', this.onBeforeGetSkins.bind(this));
  21. this.events.on('onBeforeGetEventList', this.onBeforeGetEventList.bind(this));
  22. //this.events.on('onBeforeGetQuests', this.onBeforeGetQuests.bind(this));
  23. //this.events.on('onBeforeGetDialogue', this.onBeforeGetDialogue.bind(this));
  24. this.events.on('onBeforeGetResourceList', this.onBeforeGetResourceList.bind(this));
  25. //this.events.on('onAfterGetZone', this.onAfterGetZone.bind(this));
  26. //this.events.on('onBeforeBuildLayerTile', this.onBeforeBuildLayerTile.bind(this));
  27. //this.events.on('onAfterGetLayerObjects', this.onAfterGetLayerObjects.bind(this));
  28. this.events.on('onBeforeGetMtxList', this.onBeforeGetMtxList.bind(this));
  29. this.events.on('onBeforeGetAnimations', this.onBeforeGetAnimations.bind(this));
  30. //this.events.on('onBeforeGetHerbConfig', this.onBeforeGetHerbConfig.bind(this));
  31. this.events.on('onBeforeGetSpellsInfo', this.beforeGetSpellsInfo.bind(this));
  32. this.events.on('onBeforeGetSpellsConfig', this.beforeGetSpellsConfig.bind(this));
  33. this.events.on('onBeforeGetSpellTemplate', this.beforeGetSpellTemplate.bind(this));
  34. },
  35. beforeGetSpellsInfo: function (spells) {
  36. spells.push({
  37. name: 'scatter pumpkin pieces',
  38. type: 'scatterPumpkinPieces',
  39. animation: 'melee',
  40. particles: {
  41. color: {
  42. start: ['ff4252', 'b34b3a'],
  43. end: ['b34b3a', 'ff4252']
  44. },
  45. scale: {
  46. start: {
  47. min: 2,
  48. max: 14
  49. },
  50. end: {
  51. min: 0,
  52. max: 8
  53. }
  54. },
  55. lifetime: {
  56. min: 1,
  57. max: 3
  58. },
  59. alpha: {
  60. start: 0.7,
  61. end: 0
  62. },
  63. randomScale: true,
  64. randomColor: true,
  65. chance: 0.6
  66. }
  67. });
  68. },
  69. beforeGetSpellsConfig: function (spells) {
  70. spells['scatter pumpkin pieces'] = {
  71. statType: ['str'],
  72. statMult: 0.1,
  73. auto: true,
  74. cdMax: 7,
  75. manaCost: 0,
  76. random: {
  77. }
  78. };
  79. },
  80. beforeGetSpellTemplate: function (spell) {
  81. if (spell.type === 'ScatterPumpkinPieces')
  82. spell.template = require('./spells/spellScatterPumpkinPieces.js');
  83. },
  84. onBeforeGetFactions: function (mappings) {
  85. extend(true, mappings, {
  86. pumpkinSailor: './factions/pumpkinSailor'
  87. });
  88. },
  89. onBeforeGetSkins: function (skins) {
  90. skins['3.0'] = {
  91. name: 'Pumpkin-Head Necromancer',
  92. sprite: [0, 0],
  93. spritesheet: `${this.folderName}/images/skins.png`
  94. };
  95. },
  96. onBeforeGetHerbConfig: function (herbs) {
  97. extend(true, herbs, {
  98. 'Tiny Pumpkin': {
  99. sheetName: 'objects',
  100. cell: 167,
  101. itemSprite: [3, 3],
  102. itemName: 'Candy Corn',
  103. itemSheet: `${this.folderName}/images/items.png`,
  104. itemAmount: [1, 1]
  105. },
  106. Pumpkin: {
  107. sheetName: 'objects',
  108. cell: 159,
  109. itemSprite: [3, 3],
  110. itemName: 'Candy Corn',
  111. itemSheet: `${this.folderName}/images/items.png`,
  112. itemAmount: [2, 3]
  113. },
  114. 'Giant Pumpkin': {
  115. sheetName: 'objects',
  116. cell: 158,
  117. itemSprite: [3, 3],
  118. itemName: 'Candy Corn',
  119. itemSheet: `${this.folderName}/images/items.png`,
  120. itemAmount: [2, 5]
  121. }
  122. });
  123. },
  124. onBeforeGetAnimations: function (animations) {
  125. //Skeleton animations
  126. let mobsheet = `${this.folderName}/images/mobs.png`;
  127. if (!animations.mobs[mobsheet])
  128. animations.mobs[mobsheet] = {};
  129. animations.mobs[mobsheet]['0'] = {
  130. melee: {
  131. spritesheet: mobsheet,
  132. row: 1,
  133. col: 0,
  134. frames: 2,
  135. frameDelay: 5
  136. },
  137. spawn: {
  138. spritesheet: mobsheet,
  139. row: 2,
  140. col: 0,
  141. frames: 3,
  142. frameDelay: 4,
  143. hideSprite: true,
  144. type: 'attackAnimation'
  145. },
  146. death: {
  147. spritesheet: mobsheet,
  148. row: 3,
  149. col: 0,
  150. frames: 4,
  151. frameDelay: 4,
  152. type: 'attackAnimation'
  153. }
  154. };
  155. },
  156. onBeforeGetResourceList: function (list) {
  157. list.push(`${this.folderName}/images/mobs.png`);
  158. list.push(`${this.folderName}/images/bosses.png`);
  159. list.push(`${this.folderName}/images/skins.png`);
  160. },
  161. onBeforeGetMtxList: function (list) {
  162. list.summonPumpkinSkeleton = this.relativeFolderName + '/mtx/summonPumpkinSkeleton';
  163. list.hauntedIceSpear = this.relativeFolderName + '/mtx/hauntedIceSpear';
  164. },
  165. onAfterGetLayerObjects: function (info) {
  166. if (info.map !== 'fjolarok')
  167. return;
  168. let layer = this.mapFile.layers.find(l => (l.name === info.layer));
  169. if (layer) {
  170. let offset = this.mapOffset;
  171. let mapScale = this.mapFile.tilesets[0].tileheight;
  172. layer.objects.forEach(function (l) {
  173. let newO = extend(true, {}, l);
  174. newO.x += (offset.x * mapScale);
  175. newO.y += (offset.y * mapScale);
  176. info.objects.push(newO);
  177. }, this);
  178. }
  179. },
  180. onBeforeBuildLayerTile: function (info) {
  181. if (info.map !== 'fjolarok')
  182. return;
  183. let offset = this.mapOffset;
  184. let x = info.x;
  185. let y = info.y;
  186. if ((x - offset.x < 0) || (y - offset.y < 0) || (x - offset.x >= this.mapW) || (y - offset.y >= this.mapH))
  187. return;
  188. let i = ((y - offset.y) * this.mapW) + (x - offset.x);
  189. let layer = this.mapFile.layers.find(l => (l.name === info.layer));
  190. if (layer)
  191. info.cell = layer.data[i];
  192. },
  193. onBeforeGetEventList: function (zone, list) {
  194. if (zone !== 'fjolarok')
  195. return;
  196. list.push(this.relativeFolderName + '/maps/fjolarok/events/halloween.js');
  197. list.push(this.relativeFolderName + '/maps/fjolarok/events/halloweenBoss.js');
  198. },
  199. onAfterGetZone: function (zone, config) {
  200. try {
  201. let modZone = require('./maps/' + zone + '/zone.js');
  202. extend(true, config, modZone);
  203. } catch (e) {
  204. }
  205. },
  206. onBeforeGetDialogue: function (zone, config) {
  207. try {
  208. let modDialogue = require('./maps/' + zone + '/dialogues.js');
  209. extend(true, config, modDialogue);
  210. } catch (e) {
  211. }
  212. }
  213. };