@@ -1,77 +1,13 @@ | |||||
define([ | define([ | ||||
'../system/globals' | |||||
], function ( | ], 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 { | return { | ||||
translate: function (stat) { | translate: function (stat) { | ||||
return stats[stat]; | |||||
return statTranslations[stat]; | |||||
} | } | ||||
}; | }; | ||||
}); | }); |
@@ -100,10 +100,25 @@ define([ | |||||
$('<div class="no-afford"></div>').appendTo(itemEl); | $('<div class="no-afford"></div>').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); | 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('<br />'); | |||||
item.worthText = '<br />' + item.worthText; | |||||
} | |||||
} | } | ||||
this.center(); | this.center(); | ||||
@@ -137,8 +137,16 @@ module.exports = { | |||||
markup = target.trade.markup.buy; | markup = target.trade.markup.buy; | ||||
} | } | ||||
const eventMsg = { | |||||
items: itemList, | |||||
markup, | |||||
action: msg.action | |||||
}; | |||||
events.emit('onBeforeGetTradeList', eventMsg); | |||||
this.obj.syncer.set(true, 'trade', 'buyList', { | this.obj.syncer.set(true, 'trade', 'buyList', { | ||||
markup: markup, | |||||
markup, | |||||
items: itemList, | items: itemList, | ||||
buyback: (msg.action === 'buyback') | buyback: (msg.action === 'buyback') | ||||
}); | }); | ||||
@@ -239,13 +247,27 @@ module.exports = { | |||||
sendMessage(this.obj, 'color-greenB', `Unlocked skin: ${item.name}.`); | 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); | 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) | //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) | if (oldQuantity) | ||||
item.quantity = oldQuantity; | item.quantity = oldQuantity; | ||||
const sellEventMsg = { | |||||
const eventMsg = { | |||||
item, | 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; | this.gold += worth; | ||||
syncer.set(true, 'trade', 'gold', this.gold); | 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); | 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 itemList = extend([], this.obj.inventory.items.filter(i => i.worth && !i.eq)); | ||||
const sellEventMsg = { | |||||
const eventMsg = { | |||||
items: itemList, | 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) { | startBuyback: function (msg) { | ||||
@@ -33,6 +33,62 @@ const config = { | |||||
player: [], | player: [], | ||||
npc: [] | 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 | tos | ||||
}; | }; | ||||
@@ -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: { | mobs: { | ||||
@@ -365,7 +365,7 @@ module.exports = { | |||||
ignore: false | ignore: false | ||||
}; | }; | ||||
events.emit('onBeforeBuildMapObject', buildObjectMsg); | events.emit('onBeforeBuildMapObject', buildObjectMsg); | ||||
if (buildObjectMsg.built) | |||||
if (buildObjectMsg.ignore) | |||||
return; | return; | ||||
//Fixes for newer versions of tiled | //Fixes for newer versions of tiled | ||||