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.
 
 
 

251 lines
6.3 KiB

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