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
5.6 KiB

  1. /* eslint-disable max-lines-per-function */
  2. const itemTypes = require('../items/config/types');
  3. const spellGenerator = require('../items/generators/spellbook');
  4. module.exports = {
  5. fixDb: async function () {
  6. await io.deleteAsync({
  7. key: 'list',
  8. table: 'leaderboard'
  9. });
  10. },
  11. fixCharacter: function (player) {
  12. let inv = player.components.find(c => (c.type === 'inventory'));
  13. if ((inv) && (inv.items))
  14. this.fixItems(inv.items);
  15. },
  16. fixCustomChannels: function (customChannels) {
  17. return customChannels
  18. .filter(c => {
  19. return (
  20. c.length <= 15 &&
  21. c.match(/^[0-9a-zA-Z]+$/)
  22. );
  23. });
  24. },
  25. fixStash: function (stash) {
  26. this.fixItems(stash);
  27. },
  28. fixItems: function (items) {
  29. //There are some bugged mounts with cdMax: 0. Set that to 86 as 86 is the new CD (down from 171)
  30. items
  31. .filter(i => i.type === 'mount')
  32. .forEach(i => {
  33. i.cdMax = 86;
  34. });
  35. items
  36. .filter(i => i.name === 'Candy Corn')
  37. .forEach(i => {
  38. i.noDrop = true;
  39. });
  40. items
  41. .filter(i => i.name === 'Enchanted Wreath')
  42. .forEach(i => {
  43. delete i.noDrop;
  44. delete i.noDestroy;
  45. });
  46. items
  47. .filter(i => (i.name === 'Elixir of Infatuation'))
  48. .forEach(function (i) {
  49. i.cdMax = 342;
  50. i.sprite = [1, 0];
  51. });
  52. items
  53. .filter(i => i.name === 'Squashling Vine')
  54. .forEach(i => {
  55. i.petSheet = 'server/mods/iwd-souls-moor/images/skins.png';
  56. i.petCell = 16;
  57. });
  58. items
  59. .filter(i => ((i.name === 'Cowl of Obscurity') && (!i.factions)))
  60. .forEach(function (i) {
  61. i.factions = [{
  62. id: 'gaekatla',
  63. tier: 7
  64. }];
  65. });
  66. items
  67. .filter(i => i.stats && i.stats.magicFind > 135)
  68. .forEach(i => {
  69. let value = '' + i.stats.magicFind;
  70. i.stats.magicFind = ~~(value.substr(value.length - 2));
  71. });
  72. items
  73. .filter(i => (
  74. i.enchantedStats &&
  75. i.slot !== 'tool' &&
  76. Object.keys(i.enchantedStats).some(e => e.indexOf('catch') === 0 || e.indexOf('fish') === 0)
  77. ))
  78. .forEach(function (i) {
  79. let enchanted = i.enchantedStats;
  80. let stats = i.stats;
  81. Object.keys(enchanted).forEach(e => {
  82. if (e.indexOf('catch') === 0 || e.indexOf('fish') === 0) {
  83. delete stats[e];
  84. delete enchanted[e];
  85. }
  86. });
  87. if (!Object.keys(enchanted).length)
  88. delete i.enchantedStats;
  89. });
  90. items
  91. .filter(i => i.factions && i.factions.indexOf && i.factions.some(f => f.id === 'pumpkinSailor') && i.slot === 'finger')
  92. .forEach(i => {
  93. i.noDestroy = false;
  94. });
  95. items
  96. .filter(i => (i.name === 'Steelclaw\'s Bite'))
  97. .forEach(function (i) {
  98. let effect = i.effects[0];
  99. if (!effect.properties) {
  100. effect.properties = {
  101. element: 'poison'
  102. };
  103. } else if (!effect.properties.element)
  104. effect.properties.element = 'poison';
  105. });
  106. items
  107. .filter(i => i.name === 'Gourdhowl')
  108. .forEach(i => {
  109. const effect = i.effects[0];
  110. if (!effect.rolls.castSpell) {
  111. effect.rolls = {
  112. castSpell: {
  113. type: 'whirlwind',
  114. damage: effect.rolls.damage,
  115. range: 1,
  116. statType: 'str',
  117. statMult: 1,
  118. isAttack: true
  119. },
  120. castTarget: 'none',
  121. chance: effect.rolls.chance,
  122. textTemplate: 'Grants you a ((chance))% chance to cast a ((castSpell.damage)) damage whirlwind on hit',
  123. combatEvent: {
  124. name: 'afterDealDamage',
  125. afterDealDamage: {
  126. spellName: 'melee'
  127. }
  128. }
  129. };
  130. }
  131. });
  132. items
  133. .filter(i => i.name === 'Putrid Shank')
  134. .forEach(i => {
  135. const effect = i.effects[0];
  136. if (!effect.rolls.castSpell) {
  137. effect.rolls = {
  138. chance: effect.rolls.chance,
  139. textTemplate: 'Grants you a ((chance))% chance to cast a ((castSpell.damage)) damage smokebomb on hit',
  140. combatEvent: {
  141. name: 'afterDealDamage',
  142. afterDealDamage: {
  143. spellName: 'melee'
  144. }
  145. },
  146. castTarget: 'none',
  147. castSpell: {
  148. type: 'smokeBomb',
  149. damage: 1,
  150. range: 1,
  151. element: 'poison',
  152. statType: 'dex',
  153. statMult: 1,
  154. duration: 5,
  155. isAttack: true
  156. }
  157. };
  158. }
  159. if (effect.rolls.castSpell.type === 'smokebomb')
  160. effect.rolls.castSpell.type = 'smokeBomb';
  161. });
  162. items
  163. .filter(i =>
  164. i.name === 'Princess Morgawsa\'s Trident' &&
  165. (
  166. i.type !== 'Trident' ||
  167. i.spell.type !== 'projectile'
  168. )
  169. )
  170. .forEach(i => {
  171. i.type = 'Trident';
  172. i.requires[0].stat = 'int';
  173. delete i.implicitStats;
  174. const typeConfig = itemTypes.types[i.slot][i.type];
  175. spellGenerator.generate(i, {
  176. ...typeConfig,
  177. spellQuality: i.spell.quality
  178. });
  179. });
  180. items
  181. .filter(i =>
  182. i.name === 'Steelclaw\'s Bite' &&
  183. (
  184. i.type !== 'Curved Dagger' ||
  185. i.spell.type !== 'melee'
  186. )
  187. )
  188. .forEach(i => {
  189. i.type = 'Curved Dagger';
  190. i.requires[0].stat = 'dex';
  191. delete i.implicitStats;
  192. const typeConfig = itemTypes.types[i.slot][i.type];
  193. spellGenerator.generate(i, {
  194. ...typeConfig,
  195. spellQuality: i.spell.quality
  196. });
  197. });
  198. items
  199. .filter(f => f.effects?.[0]?.factionId === 'akarei' && !f.effects[0].properties)
  200. .forEach(function (i) {
  201. let effect = i.effects[0];
  202. let chance = parseFloat(effect.text.split(' ')[0].replace('%', ''));
  203. effect.properties = {
  204. chance: chance
  205. };
  206. });
  207. items
  208. .filter(f => ((f.stats) && (f.stats.dmgPercent)))
  209. .forEach(function (i) {
  210. i.stats.physicalPercent = i.stats.dmgPercent;
  211. delete i.stats.dmgPercent;
  212. if ((i.enchantedStats) && (i.enchantedStats.dmgPercent)) {
  213. i.enchantedStats.physicalPercent = i.enchantedStats.dmgPercent;
  214. delete i.enchantedStats.dmgPercent;
  215. }
  216. });
  217. }
  218. };