Browse Source

modding #1933: Allow beforeGatherResourceComplete to modify the gather chance of fishing nodes

tags/v0.11.0
Shaun 2 years ago
parent
commit
185fac6f19
2 changed files with 16 additions and 9 deletions
  1. +1
    -1
      src/server/components/gatherer.js
  2. +15
    -8
      src/server/world/resourceSpawner.js

+ 1
- 1
src/server/components/gatherer.js View File

@@ -116,7 +116,7 @@ module.exports = {
this.obj.syncer.set(false, 'gatherer', 'progress', 100); this.obj.syncer.set(false, 'gatherer', 'progress', 100);


if (isFish) { if (isFish) {
let catchChance = 40 + this.obj.stats.values.catchChance;
const catchChance = gatherResult.blueprint.gatherChance + this.obj.stats.values.catchChance;
if (~~(Math.random() * 100) >= catchChance) { if (~~(Math.random() * 100) >= catchChance) {
this.sendAnnouncement('The fish got away'); this.sendAnnouncement('The fish got away');
this.gathering = null; this.gathering = null;


+ 15
- 8
src/server/world/resourceSpawner.js View File

@@ -1,5 +1,10 @@
let herbs = require('../config/herbs'); let herbs = require('../config/herbs');


const defaultGatherChance = {
herb: 100,
fish: 40
};

module.exports = { module.exports = {
nodes: [], nodes: [],


@@ -22,7 +27,7 @@ module.exports = {
}, },


register: function (name, blueprint) { register: function (name, blueprint) {
let exists = this.nodes.find(n => (n.blueprint.name === name));
const exists = this.nodes.find(n => (n.blueprint.name === name));
if (exists) { if (exists) {
if (!exists.blueprint.positions) { if (!exists.blueprint.positions) {
exists.blueprint.positions = [{ exists.blueprint.positions = [{
@@ -47,21 +52,23 @@ module.exports = {
name: name name: name
}); });


let max = blueprint.max;
const max = blueprint.max;
delete blueprint.max; delete blueprint.max;


let chance = blueprint.chance;
const chance = blueprint.chance;
delete blueprint.chance; delete blueprint.chance;


let cdMax = blueprint.cdMax;
const cdMax = blueprint.cdMax;
delete blueprint.cdMax; delete blueprint.cdMax;


blueprint.gatherChance = blueprint.gatherChance ?? defaultGatherChance[blueprint.type];

this.nodes.push({ this.nodes.push({
cd: 0, cd: 0,
max: max,
chance: chance,
cdMax: cdMax,
blueprint: blueprint,
max,
chance,
cdMax,
blueprint,
spawns: [] spawns: []
}); });
}, },


Loading…
Cancel
Save