Browse Source

closes #1447

tags/v0.6^2
Shaun 4 years ago
parent
commit
7fe6715bdd
10 changed files with 111 additions and 50 deletions
  1. +2
    -2
      src/server/components/inventory.js
  2. +8
    -8
      src/server/config/maps/fjolarok/zone.js
  3. +1
    -1
      src/server/config/zoneBase.js
  4. +1
    -1
      src/server/items/generator.js
  5. +71
    -33
      src/server/items/generators/spellbook.js
  6. +2
    -2
      src/server/mods/class-necromancer/index.js
  7. BIN
     
  8. BIN
     
  9. +2
    -2
      src/server/mods/feature-cards/recipes/craftActions/rune.js
  10. +24
    -1
      src/server/mods/feature-cards/recipes/recipes.js

+ 2
- 2
src/server/components/inventory.js View File

@@ -575,7 +575,7 @@ module.exports = {
let item = generator.generate({
type: classes.weapons[this.obj.class],
quality: 0,
spellQuality: 'basic'
spellQuality: 0
});
item.worth = 0;
item.eq = true;
@@ -594,7 +594,7 @@ module.exports = {
if (!hasSpell) {
let item = generator.generate({
spell: true,
spellQuality: 'basic',
spellQuality: 0,
spellName: spellName
});
item.worth = 0;


+ 8
- 8
src/server/config/maps/fjolarok/zone.js View File

@@ -852,56 +852,56 @@ module.exports = {
extra: [{
generate: true,
spell: true,
spellQuality: 'basic',
spellQuality: 0,
infinite: true,
spellName: 'magic missile',
worth: 3
}, {
generate: true,
spell: true,
spellQuality: 'basic',
spellQuality: 0,
infinite: true,
spellName: 'ice spear',
worth: 3
}, {
generate: true,
spell: true,
spellQuality: 'basic',
spellQuality: 0,
infinite: true,
spellName: 'smite',
worth: 3
}, {
generate: true,
spell: true,
spellQuality: 'basic',
spellQuality: 0,
infinite: true,
spellName: 'consecrate',
worth: 3
}, {
generate: true,
spell: true,
spellQuality: 'basic',
spellQuality: 0,
infinite: true,
spellName: 'slash',
worth: 3
}, {
generate: true,
spell: true,
spellQuality: 'basic',
spellQuality: 0,
infinite: true,
spellName: 'charge',
worth: 3
}, {
generate: true,
spell: true,
spellQuality: 'basic',
spellQuality: 0,
infinite: true,
spellName: 'flurry',
worth: 3
}, {
generate: true,
spell: true,
spellQuality: 'basic',
spellQuality: 0,
infinite: true,
spellName: 'smokebomb',
worth: 3


+ 1
- 1
src/server/config/zoneBase.js View File

@@ -26,7 +26,7 @@ module.exports = {

rare: {
count: 1,
chance: 0.4,
chance: 0.94,

hpMult: 3,
dmgMult: 1.5,


+ 1
- 1
src/server/items/generator.js View File

@@ -14,7 +14,7 @@ let g13 = require('./generators/recipeBook');

let generators = [g1, g2, g3, g4, g5, g6, g11, g12, g7];
let materialGenerators = [g6, g8];
let spellGenerators = [g1, g9, g7];
let spellGenerators = [g1, g2, g9, g7];
let currencyGenerators = [g10, g8];
let recipeGenerators = [g6, g13];



+ 71
- 33
src/server/items/generators/spellbook.js View File

@@ -2,6 +2,60 @@ let spells = require('../../config/spells');
let spellsConfig = require('../../config/spellsConfig');
let configTypes = require('../config/types');

const qualityGenerator = require('./quality');
const qualityCount = qualityGenerator.qualities.length;

const buildRolls = (item, blueprint, { random: spellProperties, negativeStats = [] }) => {
//If the item has a slot, we need to generate a new quality for the rune
let quality = item.quality;
if (item.slot) {
const tempItem = {};

const tempBlueprint = extend(blueprint);
delete tempBlueprint.quality;
tempBlueprint.quality = blueprint.spellQuality;

qualityGenerator.generate(tempItem, tempBlueprint);

quality = tempItem.quality;
}

//We randomise the order so a random property gets to 'pick first'
// otherwise it's easier for earlier properties to use more of the valuePool
const propEntries = Object
.entries(spellProperties)
.sort((a, b) => Math.random() - Math.random());

const propCount = propEntries.length;

const minSum = (quality / qualityCount) * propCount;
const maxSum = ((quality + 1) / qualityCount) * propCount;

let propRolls = null;
let sum = 0;

do {
sum = 0;
propRolls = propEntries.map((e, i) => {
let [ prop ] = e;
const isNegative = negativeStats.includes(prop);

let roll = Math.random();
sum += roll;
if (isNegative)
roll = 1 - roll;

return [prop, roll];
});
} while (sum < minSum || sum > maxSum);

const result = Object.fromEntries(propRolls);

return result;
};

module.exports = {
generate: function (item, blueprint) {
blueprint = blueprint || {};
@@ -55,40 +109,31 @@ module.exports = {
extend(spell, typeConfig.spellConfig);
}

let propertyPerfection = [];

let randomProperties = spell.random || {};
let negativeStats = spell.negativeStats || [];
for (let r in randomProperties) {
let negativeStat = (negativeStats.indexOf(r) > -1);
let range = randomProperties[r];

let max = Math.min(consts.maxLevel, item.level) / consts.maxLevel;
const rolls = buildRolls(item, blueprint, spell);
Object.entries(spell.random || {}).forEach(entry => {
const [ property, range ] = entry;
const roll = rolls[property];

let roll = random.expNorm(0, max);
if (spellQuality === 'basic')
roll = 0;
else if (spellQuality === 'mid')
roll = 0.5;
item.spell.rolls[property] = roll;

item.spell.rolls[r] = roll;
const isInt = property.indexOf('i_') === 0;
let useProperty = property;
const minRange = range[0];
const maxRange = range[1] * (item.level / consts.maxLevel);

let int = r.indexOf('i_') === 0;
let val = range[0] + ((range[1] - range[0]) * roll);
let val = minRange + ((maxRange - minRange) * roll);

if (int) {
val = ~~val;
r = r.replace('i_', '');
if (isInt) {
useProperty = property.substr(2);
val = Math.round(val);
} else
val = ~~(val * 100) / 100;

item.spell.values[r] = val;
val = Math.max(range[0], Math.min(range[1], val));

if (negativeStat)
propertyPerfection.push(1 - roll);
else
propertyPerfection.push(roll);
}
item.spell.values[useProperty] = val;
});

if (blueprint.spellProperties) {
item.spell.properties = {};
@@ -100,12 +145,5 @@ module.exports = {
item.spell.properties = item.spell.properties || {};
item.spell.properties.range = item.range;
}

let per = propertyPerfection.reduce((p, n) => p + n, 0);
let perfection = ~~((per / propertyPerfection.length) * 4);
if (!item.slot)
item.quality = perfection;
else
item.spell.quality = perfection;
}
};

+ 2
- 2
src/server/mods/class-necromancer/index.js View File

@@ -25,14 +25,14 @@ module.exports = {
let newRunes = [{
generate: true,
spell: true,
spellQuality: 'basic',
spellQuality: 0,
infinite: true,
spellName: 'harvest life',
worth: 3
}, {
generate: true,
spell: true,
spellQuality: 'basic',
spellQuality: 0,
infinite: true,
spellName: 'summon skeleton',
worth: 3


BIN
View File


BIN
View File


+ 2
- 2
src/server/mods/feature-cards/recipes/craftActions/rune.js View File

@@ -1,8 +1,8 @@
let itemGenerator = require('../../../../items/generator');

module.exports = ({ level }, crafter) => {
module.exports = (config, crafter) => {
const result = itemGenerator.generate({
level,
...config,
spell: true
});



+ 24
- 1
src/server/mods/feature-cards/recipes/recipes.js View File

@@ -10,8 +10,31 @@ module.exports = [{
name: 'Runecrafter\'s Toil',
quantity: 3
}],
craftAction: rune.bind(null, {
level: 10,
magicFind: 500
})
}, {
name: 'Level 15 Rune',
description: '',
materials: [{
name: 'Runecrafter\'s Toil',
quantity: 10
}],
craftAction: rune.bind(null, {
level: 15,
magicFind: 1000
})
}, {
name: 'Level 20 Rune',
description: '',
materials: [{
name: 'Runecrafter\'s Toil',
quantity: 30
}],
craftAction: rune.bind(null, {
level: 10
level: 20,
magicFind: 1500
})
}, {
name: 'Legendary Level 15 Weapon',


Loading…
Cancel
Save