Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.
 
 
 

113 Zeilen
2.9 KiB

  1. define([
  2. 'config/spells',
  3. 'config/spellsConfig'
  4. ], function (
  5. spells,
  6. spellsConfig
  7. ) {
  8. var maxQuality = 5;
  9. return {
  10. generate: function (item, blueprint) {
  11. blueprint = blueprint || {};
  12. var spellQuality = blueprint ? blueprint.spellQuality : '';
  13. var spellName = blueprint.spellName;
  14. if (!spellName) {
  15. var spellList = Object.keys(spellsConfig.spells).filter(s => ((!spellsConfig.spells[s].auto) && (!s.noDrop)));
  16. spellName = spellList[~~(Math.random() * spellList.length)];
  17. }
  18. var spell = spellsConfig.spells[spellName];
  19. var spellAesthetic = spells.spells.find(s => s.name.toLowerCase() == spellName) || {};
  20. if (!item.slot) {
  21. var sprite = [10, 0];
  22. var statType = spell.statType;
  23. if (statType == 'dex')
  24. sprite = [10, 1];
  25. else if (statType == 'str')
  26. sprite = [10, 2];
  27. else if (statType instanceof Array) {
  28. if ((statType.indexOf('dex') > -1) && (statType.indexOf('int') > -1))
  29. sprite = [10, 3];
  30. else if ((statType.indexOf('str') > -1) && (statType.indexOf('int') > -1))
  31. sprite = [10, 4];
  32. }
  33. item.name = 'Rune of ' + spellAesthetic.name;
  34. item.ability = true;
  35. item.sprite = sprite;
  36. } else if (spellQuality == 'basic')
  37. item.stats = {};
  38. if (blueprint.spellConfig)
  39. spellAesthetic = extend(true, {}, spellAesthetic, blueprint.spellConfig);
  40. item.spell = {
  41. name: spellAesthetic.name || 'Weapon Damage',
  42. type: spellAesthetic.type || spellName,
  43. rolls: {},
  44. values: {}
  45. };
  46. if (blueprint.spellConfig) {
  47. extend(true, item.spell, blueprint.spellConfig);
  48. }
  49. var propertyPerfection = [];
  50. var randomProperties = spell.random || {};
  51. var negativeStats = spell.negativeStats || [];
  52. for (var r in randomProperties) {
  53. var negativeStat = (negativeStats.indexOf(r) > -1);
  54. var range = randomProperties[r];
  55. var max = Math.min(20, item.level) / 20;
  56. var roll = random.expNorm(0, max);
  57. if (spellQuality == 'basic')
  58. roll = 0;
  59. else if (spellQuality == 'mid')
  60. roll = 0.5;
  61. item.spell.rolls[r] = roll;
  62. var int = r.indexOf('i_') == 0;
  63. var val = range[0] + ((range[1] - range[0]) * roll);
  64. if (int) {
  65. val = ~~val;
  66. r = r.replace('i_', '');
  67. } else
  68. val = ~~(val * 10) / 10;
  69. item.spell.values[r] = val;
  70. if (negativeStat)
  71. propertyPerfection.push(1 - roll);
  72. else
  73. propertyPerfection.push(roll)
  74. }
  75. if (blueprint.spellProperties) {
  76. item.spell.properties = {};
  77. for (var p in blueprint.spellProperties) {
  78. item.spell.properties[p] = blueprint.spellProperties[p];
  79. }
  80. }
  81. if (item.range) {
  82. item.spell.properties = item.spell.properties || {};
  83. item.spell.properties.range = item.range;
  84. }
  85. var per = propertyPerfection.reduce((p, n) => p + n, 0);
  86. var perfection = ~~((per / propertyPerfection.length) * 4);
  87. if (!item.slot)
  88. item.quality = perfection;
  89. else
  90. item.spell.quality = perfection
  91. }
  92. };
  93. });