diff --git a/src/client/js/misc/statTranslations.js b/src/client/js/misc/statTranslations.js
index 90f4c1d0..0c0cd276 100644
--- a/src/client/js/misc/statTranslations.js
+++ b/src/client/js/misc/statTranslations.js
@@ -1,77 +1,13 @@
define([
-
+ '../system/globals'
], function (
-
+ globals
) {
- let stats = {
- vit: 'vitality',
- regenHp: 'health regeneration',
- manaMax: 'maximum mana',
- regenMana: 'mana regeneration',
- str: 'strength',
- int: 'intellect',
- dex: 'dexterity',
- armor: 'armor',
-
- blockAttackChance: 'chance to block attacks',
- blockSpellChance: 'chance to block spells',
-
- dodgeAttackChance: 'chance to dodge attacks',
- dodgeSpellChance: 'chance to dodge spells',
-
- addCritChance: 'global crit chance',
- addCritMultiplier: 'global crit multiplier',
- addAttackCritChance: 'attack crit chance',
- addAttackCritMultiplier: 'attack crit multiplier',
- addSpellCritChance: 'spell crit chance',
- addSpellCritMultiplier: 'spell crit multiplier',
- magicFind: 'increased item quality',
- itemQuantity: 'increased item quantity',
- sprintChance: 'sprint chance',
- allAttributes: 'to all attributes',
- xpIncrease: 'additional xp per kill',
- lvlRequire: 'level requirement reduction',
-
- elementArcanePercent: 'increased arcane damage',
- elementFrostPercent: 'increased frost damage',
- elementFirePercent: 'increased fire damage',
- elementHolyPercent: 'increased holy damage',
- elementPoisonPercent: 'increased poison damage',
- physicalPercent: 'increased physical damage',
-
- elementPercent: 'increased elemental damage',
- spellPercent: 'increased spell damage',
-
- elementAllResist: 'all resistance',
- elementArcaneResist: 'arcane resistance',
- elementFrostResist: 'frost resistance',
- elementFireResist: 'fire resistance',
- elementHolyResist: 'holy resistance',
- elementPoisonResist: 'poison resistance',
-
- attackSpeed: 'attack speed',
- castSpeed: 'cast speed',
-
- lifeOnHit: 'life gained on hit',
-
- auraReserveMultiplier: 'aura mana reservation multiplier',
-
- //This stat is used for gambling when you can't see the stats
- stats: 'stats',
-
- //Fishing
- weight: 'lb',
- //Rods
- catchChance: 'extra catch chance',
- catchSpeed: 'faster catch speed',
- fishRarity: 'higher fish rarity',
- fishWeight: 'increased fish weight',
- fishItems: 'extra chance to hook items'
- };
+ const { clientConfig: { statTranslations } } = globals;
return {
translate: function (stat) {
- return stats[stat];
+ return statTranslations[stat];
}
};
});
diff --git a/src/client/ui/templates/trade/trade.js b/src/client/ui/templates/trade/trade.js
index fae23e3a..ae2aeaa1 100644
--- a/src/client/ui/templates/trade/trade.js
+++ b/src/client/ui/templates/trade/trade.js
@@ -100,10 +100,25 @@ define([
$('
').appendTo(itemEl);
}
- if (item.worth.currency)
- item.worthText = item.worth.amount + 'x ' + item.worth.currency;
- else
+ let worth = item.worth;
+ if (typeof(worth) === 'number')
item.worthText = ~~(itemList.markup * item.worth);
+ else {
+ if (!worth.push)
+ worth = [worth];
+
+ item.worthText = worth
+ .map(w => {
+ const { currency, amount } = w;
+
+ const result = `${amount}x ${currency}`;
+
+ return result;
+ })
+ .join('
');
+
+ item.worthText = '
' + item.worthText;
+ }
}
this.center();
diff --git a/src/server/components/trade.js b/src/server/components/trade.js
index f9cc2ac8..d2b15dc1 100644
--- a/src/server/components/trade.js
+++ b/src/server/components/trade.js
@@ -137,8 +137,16 @@ module.exports = {
markup = target.trade.markup.buy;
}
+ const eventMsg = {
+ items: itemList,
+ markup,
+ action: msg.action
+ };
+
+ events.emit('onBeforeGetTradeList', eventMsg);
+
this.obj.syncer.set(true, 'trade', 'buyList', {
- markup: markup,
+ markup,
items: itemList,
buyback: (msg.action === 'buyback')
});
@@ -239,13 +247,27 @@ module.exports = {
sendMessage(this.obj, 'color-greenB', `Unlocked skin: ${item.name}.`);
}
- if (item.worth.currency) {
- let currencyItem = this.obj.inventory.items.find(i => (i.name === item.worth.currency));
- this.obj.inventory.destroyItem(currencyItem.id, item.worth.amount, true);
- } else {
- targetTrade.gold += ~~(item.worth * markup);
- this.gold -= ~~(item.worth * markup);
+ const eventMsg = {
+ item,
+ worth: ~~(item.worth * targetTrade.markup.buy),
+ action: msg.action
+ };
+ events.emit('onBeforeTradeItem', eventMsg);
+
+ let { worth } = eventMsg;
+
+ if (typeof(worth) === 'number') {
+ targetTrade.gold += ~~(worth * markup);
+ this.gold -= ~~(worth * markup);
this.obj.syncer.set(true, 'trade', 'gold', this.gold);
+ } else {
+ if (!worth.push)
+ worth = [worth];
+
+ worth.forEach(w => {
+ let currencyItem = this.obj.inventory.items.find(i => (i.name === w.name));
+ this.obj.inventory.destroyItem(currencyItem.id, w.quantity, true);
+ });
}
//Hack to always redraw the UI (to give items the red overlay if they can't be afforded)
@@ -278,19 +300,24 @@ module.exports = {
if (oldQuantity)
item.quantity = oldQuantity;
- const sellEventMsg = {
+ const eventMsg = {
item,
- worth: ~~(item.worth * targetTrade.markup.buy)
+ worth: ~~(item.worth * targetTrade.markup.buy),
+ action: 'sell'
};
- events.emit('onBeforeSellItem', sellEventMsg);
+ events.emit('onBeforeTradeItem', eventMsg);
- const { worth } = sellEventMsg;
+ let { worth } = eventMsg;
- if (typeof(worth) !== 'object') {
+ if (typeof(worth) === 'number') {
this.gold += worth;
syncer.set(true, 'trade', 'gold', this.gold);
- } else
- inventory.getItem(worth, false, false, false, true);
+ } else {
+ if (!worth.push)
+ worth = [worth];
+
+ worth.forEach(w => inventory.getItem(w, false, false, false, true));
+ }
syncer.setArray(true, 'trade', 'removeItems', item.id);
@@ -325,14 +352,15 @@ module.exports = {
const itemList = extend([], this.obj.inventory.items.filter(i => i.worth && !i.eq));
- const sellEventMsg = {
+ const eventMsg = {
items: itemList,
- markup: target.trade.markup.buy
+ markup: target.trade.markup.sell,
+ action: 'sell'
};
- events.emit('onBeforeGetSellList', sellEventMsg);
+ events.emit('onBeforeGetTradeList', eventMsg);
- this.obj.syncer.set(true, 'trade', 'sellList', sellEventMsg);
+ this.obj.syncer.set(true, 'trade', 'sellList', eventMsg);
},
startBuyback: function (msg) {
diff --git a/src/server/config/clientConfig.js b/src/server/config/clientConfig.js
index 1d944877..d648ba55 100644
--- a/src/server/config/clientConfig.js
+++ b/src/server/config/clientConfig.js
@@ -33,6 +33,62 @@ const config = {
player: [],
npc: []
},
+ statTranslations: {
+ vit: 'vitality',
+ regenHp: 'health regeneration',
+ manaMax: 'maximum mana',
+ regenMana: 'mana regeneration',
+ str: 'strength',
+ int: 'intellect',
+ dex: 'dexterity',
+ armor: 'armor',
+
+ blockAttackChance: 'chance to block attacks',
+ blockSpellChance: 'chance to block spells',
+
+ dodgeAttackChance: 'chance to dodge attacks',
+ dodgeSpellChance: 'chance to dodge spells',
+
+ addCritChance: 'global crit chance',
+ addCritMultiplier: 'global crit multiplier',
+ addAttackCritChance: 'attack crit chance',
+ addAttackCritMultiplier: 'attack crit multiplier',
+ addSpellCritChance: 'spell crit chance',
+ addSpellCritMultiplier: 'spell crit multiplier',
+ magicFind: 'increased item quality',
+ itemQuantity: 'increased item quantity',
+ sprintChance: 'sprint chance',
+ allAttributes: 'to all attributes',
+ xpIncrease: 'additional xp per kill',
+ lvlRequire: 'level requirement reduction',
+
+ elementArcanePercent: 'increased arcane damage',
+ elementFrostPercent: 'increased frost damage',
+ elementFirePercent: 'increased fire damage',
+ elementHolyPercent: 'increased holy damage',
+ elementPoisonPercent: 'increased poison damage',
+ physicalPercent: 'increased physical damage',
+
+ elementPercent: 'increased elemental damage',
+ spellPercent: 'increased spell damage',
+
+ elementAllResist: 'all resistance',
+ elementArcaneResist: 'arcane resistance',
+ elementFrostResist: 'frost resistance',
+ elementFireResist: 'fire resistance',
+ elementHolyResist: 'holy resistance',
+ elementPoisonResist: 'poison resistance',
+
+ attackSpeed: 'attack speed',
+ castSpeed: 'cast speed',
+
+ lifeOnHit: 'life gained on hit',
+
+ auraReserveMultiplier: 'aura mana reservation multiplier',
+
+ //This stat is used for gambling when you can't see the stats
+ stats: 'stats'
+ },
tos
};
diff --git a/src/server/config/maps/fjolarok/zone.js b/src/server/config/maps/fjolarok/zone.js
index 522b5245..85607c95 100644
--- a/src/server/config/maps/fjolarok/zone.js
+++ b/src/server/config/maps/fjolarok/zone.js
@@ -382,178 +382,6 @@ module.exports = {
}
}
}
- },
- 'alchemy workbench': {
- components: {
- cpnParticles: {
- simplify: function () {
- return {
- type: 'particles',
- blueprint: {
- color: {
- start: ['ff4252', 'ff4252'],
- end: ['a82841', 'a82841']
- },
- scale: {
- start: {
- min: 2,
- max: 10
- },
- end: {
- min: 0,
- max: 2
- }
- },
- speed: {
- start: {
- min: 4,
- max: 16
- },
- end: {
- min: 2,
- max: 8
- }
- },
- lifetime: {
- min: 1,
- max: 4
- },
- randomScale: true,
- randomSpeed: true,
- chance: 0.2,
- randomColor: true,
- spawnType: 'rect',
- spawnRect: {
- x: -15,
- y: -28,
- w: 30,
- h: 8
- }
- }
- };
- }
- },
- cpnWorkbench: {
- type: 'alchemy'
- }
- }
- },
- etchbench: {
- components: {
- cpnParticles: {
- simplify: function () {
- return {
- type: 'particles',
- blueprint: {
- color: {
- start: ['ff4252', 'ff4252'],
- end: ['a82841', 'a82841']
- },
- scale: {
- start: {
- min: 2,
- max: 10
- },
- end: {
- min: 0,
- max: 2
- }
- },
- speed: {
- start: {
- min: 4,
- max: 16
- },
- end: {
- min: 2,
- max: 8
- }
- },
- lifetime: {
- min: 1,
- max: 4
- },
- randomScale: true,
- randomSpeed: true,
- chance: 0.2,
- randomColor: true,
- spawnType: 'rect',
- spawnRect: {
- x: -15,
- y: -28,
- w: 30,
- h: 8
- }
- }
- };
- }
- },
- cpnWorkbench: {
- type: 'etching'
- }
- }
- },
- fireplace: {
- components: {
- cpnWorkbench: {
- type: 'cooking'
- }
- }
- },
- 'enchanting shrine': {
- components: {
- cpnParticles: {
- simplify: function () {
- return {
- type: 'particles',
- blueprint: {
- color: {
- start: ['48edff', 'fc66f7'],
- end: ['393268', '42548d']
- },
- scale: {
- start: {
- min: 2,
- max: 10
- },
- end: {
- min: 0,
- max: 2
- }
- },
- speed: {
- start: {
- min: 4,
- max: 16
- },
- end: {
- min: 2,
- max: 8
- }
- },
- lifetime: {
- min: 1,
- max: 4
- },
- randomScale: true,
- randomSpeed: true,
- chance: 0.2,
- randomColor: true,
- spawnType: 'rect',
- spawnRect: {
- x: -15,
- y: -28,
- w: 30,
- h: 8
- }
- }
- };
- }
- },
- cpnWorkbench: {
- type: 'enchanting'
- }
- }
}
},
mobs: {
diff --git a/src/server/world/map.js b/src/server/world/map.js
index 8ffddbeb..ce463367 100644
--- a/src/server/world/map.js
+++ b/src/server/world/map.js
@@ -365,7 +365,7 @@ module.exports = {
ignore: false
};
events.emit('onBeforeBuildMapObject', buildObjectMsg);
- if (buildObjectMsg.built)
+ if (buildObjectMsg.ignore)
return;
//Fixes for newer versions of tiled