@@ -13,7 +13,7 @@ define([ | |||
}, | |||
extend: function(msg) { | |||
events.emit('onShowProgress', 'Gathering...', msg.progress); | |||
events.emit('onShowProgress', (msg.action || 'Gathering') + '...', msg.progress); | |||
}, | |||
onKeyDown: function(key) { | |||
@@ -38,7 +38,15 @@ define([ | |||
'elementAllResist': 'all resistance', | |||
//This stat is used for gambling when you can't see the stats | |||
'stats': 'stats' | |||
'stats': 'stats', | |||
//Fishing | |||
'weight': 'lb', | |||
//Rods | |||
'catchChance': 'extra catch chance', | |||
'catchSpeed': 'faster catch speed' , | |||
'fishRarity': 'higher fish rarity', | |||
'fishWeight': 'increased fish weight' | |||
}; | |||
return { | |||
@@ -5,7 +5,7 @@ | |||
z-index: 2; | |||
border: 5px solid @blackB; | |||
text-align: center; | |||
width: 458px; | |||
width: 474px; | |||
height: 534px; | |||
> .heading { | |||
@@ -93,6 +93,7 @@ | |||
&[slot="feet"] .icon { background-position: -448px -448px; } | |||
&[slot="trinket"] .icon { background-position: -448px -384px; } | |||
&[slot="twoHanded"] .icon { background-position: -384px -384px; } | |||
&[slot="tool"] .icon { background-position: -256px -384px; } | |||
&[slot^="rune"] .icon { background-position: -320px -384px; } | |||
} | |||
@@ -156,7 +157,6 @@ | |||
.runes { | |||
width: 100%; | |||
height: 80px; | |||
padding-left: calc((100% - (80px * 2) - 8px) / 2); | |||
.slot { | |||
float: left; | |||
@@ -21,6 +21,7 @@ | |||
</div> | |||
<div class="runes"> | |||
<div class="slot" slot="rune-0"><div class="icon"></div></div> | |||
<div class="slot" slot="tool"><div class="icon"></div></div> | |||
<div class="slot" slot="rune-1"><div class="icon"></div></div> | |||
</div> | |||
</div> | |||
@@ -11,6 +11,18 @@ define([ | |||
tplTooltip, | |||
statTranslations | |||
) { | |||
var percentageStats = [ | |||
'addCritChance', | |||
'addCritMultiplier', | |||
'sprintChance', | |||
'dmgPercent', | |||
'xpIncrease', | |||
'catchChance', | |||
'catchSpeed', | |||
'fishRarity', | |||
'fishWeight' | |||
]; | |||
return { | |||
tpl: template, | |||
type: 'tooltipItem', | |||
@@ -20,7 +32,7 @@ define([ | |||
postRender: function() { | |||
this.tooltip = this.el.find('.tooltip'); | |||
this.onEvent('onShowItemTooltip', this.onShowItemTooltip.bind(this)); | |||
this.onEvent('onHideItemTooltip', this.onHideItemTooltip.bind(this)); | |||
}, | |||
@@ -47,8 +59,7 @@ define([ | |||
tempStats[s] = '+' + delta; | |||
else if (delta < 0) | |||
tempStats[s] = delta; | |||
} | |||
else | |||
} else | |||
tempStats[s] = '+' + tempStats[s]; | |||
} | |||
for (var s in compareStats) { | |||
@@ -64,7 +75,7 @@ define([ | |||
var statName = statTranslations.translate(s); | |||
var value = tempStats[s]; | |||
if (['addCritChance', 'addCritMultiplier', 'sprintChance', 'dmgPercent', 'xpIncrease'].indexOf(s) > -1) | |||
if (percentageStats.indexOf(s) > -1) | |||
value += '%'; | |||
else if ((s.indexOf('element') == 0) && (s.indexOf('Resist') == -1)) | |||
value += '%'; | |||
@@ -141,14 +152,12 @@ define([ | |||
this.tooltip.find('.material').show(); | |||
else if (item.quest) | |||
this.tooltip.find('.quest').show(); | |||
} | |||
else if (item.eq) | |||
} else if (item.eq) | |||
this.tooltip.find('.info').hide(); | |||
if (!item.ability) { | |||
this.tooltip.find('.damage').hide(); | |||
} | |||
else | |||
} else | |||
this.tooltip.find('.info').hide(); | |||
if (item.spell) { | |||
@@ -156,13 +165,12 @@ define([ | |||
.html('<br />' + item.spell.name) | |||
.addClass('q' + item.spell.quality) | |||
.show(); | |||
this.tooltip.find('.damage') | |||
this.tooltip.find('.damage') | |||
.show(); | |||
if (item.ability) | |||
this.tooltip.find('.spellName').hide(); | |||
} | |||
else | |||
this.tooltip.find('.spellName').hide(); | |||
} else | |||
this.tooltip.find('.spellName').hide(); | |||
this.tooltip.find('.worth').html(item.worth ? ('<br />value: ' + item.worth) : ''); | |||
@@ -178,8 +186,7 @@ define([ | |||
this.find('.effects') | |||
.html(htmlEffects) | |||
.show(); | |||
} | |||
else | |||
} else | |||
this.find('.effects').hide(); | |||
if (item.factions) { | |||
@@ -198,8 +205,7 @@ define([ | |||
this.find('.faction') | |||
.html(htmlFactions) | |||
.show(); | |||
} | |||
else | |||
} else | |||
this.find('.faction').hide(); | |||
if ((shiftDown) || (!compare)) | |||
@@ -1,7 +1,7 @@ | |||
define([ | |||
'items/generators/quality' | |||
], function( | |||
qualityGenerator | |||
) { | |||
return { | |||
type: 'gatherer', | |||
@@ -10,6 +10,7 @@ define([ | |||
gathering: null, | |||
gatheringTtl: 0, | |||
gatheringTtlMax: 7, | |||
defaultTtlMax: 7, | |||
gather: function() { | |||
if (this.gathering != null) | |||
@@ -19,7 +20,21 @@ define([ | |||
if (nodes.length == 0) | |||
return; | |||
this.gathering = nodes[0]; | |||
var firstNode = nodes[0]; | |||
this.gathering = firstNode; | |||
var ttlMax = firstNode.resourceNode.ttl || this.defaultTtlMax; | |||
if (firstNode.resourceNode.type == 'fish') { | |||
var rod = this.obj.equipment.eq.tool; | |||
rod = this.obj.inventory.findItem(rod); | |||
var statCatchSpeed = Math.min(150, rod.stats.catchSpeed || 0); | |||
ttlMax *= (1 - (statCatchSpeed / 200)); | |||
} | |||
this.gatheringTtlMax = ttlMax; | |||
this.gatheringTtl = this.gatheringTtlMax; | |||
}, | |||
@@ -34,10 +49,63 @@ define([ | |||
var progress = 100 - ~~((this.gatheringTtl / this.gatheringTtlMax) * 100); | |||
this.obj.syncer.set(true, 'gatherer', 'progress', progress); | |||
if (gathering.resourceNode.type == 'fish') | |||
this.obj.syncer.set(true, 'gatherer', 'action', 'Fishing'); | |||
return; | |||
} | |||
if (gathering.resourceNode.type == 'fish') { | |||
var rod = this.obj.equipment.eq.tool; | |||
rod = this.obj.inventory.findItem(rod); | |||
var catchChance = 30 + (rod.stats.catchChance || 0); | |||
if (~~(Math.random() * 100) >= catchChance) { | |||
process.send({ | |||
method: 'events', | |||
data: { | |||
'onGetAnnouncement': [{ | |||
obj: { | |||
msg: 'The fish got away' | |||
}, | |||
to: [this.obj.serverId] | |||
}] | |||
} | |||
}); | |||
this.gathering = null; | |||
return; | |||
} | |||
var blueprint = gathering.resourceNode.blueprint; | |||
gathering.inventory.items.forEach(function(g) { | |||
delete g.quantity; | |||
qualityGenerator.generate(g, { | |||
//100 x 2.86 = 2000 (chance for a common) | |||
bonusMagicFind: (rod.stats.fishRarity || 0) * 2.82 | |||
}); | |||
g.name = { | |||
'0': '', | |||
'1': 'Big ', | |||
'2': 'Giant ', | |||
'3': 'Trophy ', | |||
'4': 'Fabled ' | |||
}[g.quality] + g.name; | |||
var statFishWeight = 1 + ((rod.stats.fishWeight || 0) / 100); | |||
var weight = ~~((blueprint.baseWeight + g.quality + (Math.random() * statFishWeight)) * 100) / 100; | |||
g.stats = { | |||
weight: weight | |||
}; | |||
g.worth = ~~(weight * 10); | |||
}); | |||
} | |||
this.nodes.spliceWhere(n => n == gathering); | |||
gathering.inventory.giveItems(this.obj, true); | |||
@@ -51,18 +119,37 @@ define([ | |||
}, | |||
enter: function(node) { | |||
var nodeType = node.resourceNode.type; | |||
var msg = `Press G to $ (${node.name})`; | |||
msg = msg.replace('$', { | |||
herb: 'gather', | |||
fish: 'fish for' | |||
}[nodeType]); | |||
var success = true; | |||
if (nodeType == 'fish') { | |||
var rod = this.obj.equipment.eq.tool; | |||
if (rod == null) { | |||
success = false; | |||
msg = 'You need a fishing rod to fish' | |||
} | |||
} | |||
process.send({ | |||
method: 'events', | |||
data: { | |||
'onGetAnnouncement': [{ | |||
obj: { | |||
msg: 'Press G to gather (' + node.name + ')' | |||
msg: msg | |||
}, | |||
to: [this.obj.serverId] | |||
}] | |||
} | |||
}); | |||
if (!success) | |||
return; | |||
this.nodes.spliceWhere(n => n == node); | |||
this.nodes.push(node); | |||
}, | |||
@@ -402,7 +402,7 @@ define([ | |||
//Material? | |||
var exists = false; | |||
if ((item.material) || (item.quest)) { | |||
if (((item.material) || (item.quest)) && (item.stackable)) { | |||
var existItem = this.items.find(i => i.name == item.name); | |||
if (existItem) { | |||
exists = true; | |||
@@ -23,6 +23,20 @@ define([ | |||
init: function(blueprint) { | |||
this.gold = blueprint.gold; | |||
(blueprint.forceItems || []).forEach(function(f, i) { | |||
var item = extend(true, {}, f); | |||
var id = 0; | |||
this.items.forEach(function(checkItem) { | |||
if (checkItem.id >= id) | |||
id = checkItem.id + 1; | |||
}); | |||
item.id = id; | |||
this.items.push(item); | |||
}, this); | |||
if (!blueprint.items) | |||
return; | |||
@@ -159,7 +173,7 @@ define([ | |||
if (msg.action == 'buyback') | |||
targetTrade.removeBuyback(msg.itemId, this.obj.name); | |||
else if (item.type != 'skin') | |||
else if ((item.type != 'skin') && (!item.infinite)) | |||
targetTrade.removeItem(msg.itemId, this.obj.name); | |||
targetTrade.gold += worth; | |||
@@ -168,8 +182,13 @@ define([ | |||
this.obj.syncer.set(true, 'trade', 'gold', this.gold); | |||
if (item.type != 'skin') { | |||
this.obj.syncer.setArray(true, 'trade', 'removeItems', item.id); | |||
this.obj.inventory.getItem(item); | |||
if (!item.infinite) | |||
this.obj.syncer.setArray(true, 'trade', 'removeItems', item.id); | |||
var clonedItem = extend(true, {}, item); | |||
delete clonedItem.infinite; | |||
this.obj.inventory.getItem(clonedItem); | |||
} | |||
else { | |||
this.obj.auth.saveSkin(item.id); | |||
@@ -18,6 +18,12 @@ define([ | |||
sheetName: 'tiles', | |||
cell: 51, | |||
itemSprite: [1, 0] | |||
}, | |||
'Sun Carp': { | |||
sheetName: 'objects', | |||
cell: 45, | |||
itemSprite: [11, 2], | |||
baseWeight: 3 | |||
} | |||
}; | |||
}); |
@@ -12,6 +12,13 @@ module.exports = { | |||
Emberleaf: { | |||
type: 'herb', | |||
max: 1 | |||
}, | |||
'Sun Carp': { | |||
type: 'fish', | |||
ttl: 30, | |||
max: 1, | |||
x: 97, | |||
y: 33 | |||
} | |||
}, | |||
objects: { | |||
@@ -208,6 +215,17 @@ module.exports = { | |||
min: 3, | |||
max: 5 | |||
}, | |||
forceItems: [ | |||
{ | |||
name: 'Flimsy Fishing Rod', | |||
type: 'Fishing Rod', | |||
slot: 'tool', | |||
quality: 0, | |||
worth: 10, | |||
sprite: [11, 0], | |||
infinite: true | |||
} | |||
], | |||
level: { | |||
min: 1, | |||
max: 5 | |||
@@ -5,7 +5,7 @@ define([ | |||
) { | |||
return { | |||
accounts: { | |||
waffle: { | |||
asd: { | |||
level: 10, | |||
messageStyle: 'color-cyan', | |||
messagePrefix: '(dev) ', | |||
@@ -29,7 +29,7 @@ define([ | |||
feet: 10, | |||
trinket: 2, | |||
twoHanded: 6, | |||
tool: 1 | |||
tool: 0 | |||
}, | |||
armorMult: { | |||
@@ -43,8 +43,11 @@ define([ | |||
for (var i = 0; i < mLen; i++) { | |||
qualities[i] = Math.max(0, qualities[i] - magicFind[i]); | |||
if (qualities[i] > 0) { | |||
if (i == 0) | |||
if (i == 0) { | |||
qualities[i] -= (bonusMagicFind * this.magicFindMult); | |||
if (qualities[i] < 0) | |||
qualities[i] = 0; | |||
} | |||
break; | |||
} | |||
@@ -1,7 +1,7 @@ | |||
define([ | |||
'items/generators/statsFishingRod' | |||
], function( | |||
statsFishingRod | |||
) { | |||
return { | |||
generators: { | |||
@@ -195,6 +195,11 @@ define([ | |||
mainStatChance: 0.7, | |||
generate: function(item, blueprint, result) { | |||
if (item.slot == 'tool') { | |||
statsFishingRod.generate(item, blueprint); | |||
return; | |||
} | |||
if (!blueprint.statCount) | |||
item.stats = {}; | |||
@@ -0,0 +1,44 @@ | |||
define([ | |||
], function( | |||
) { | |||
return { | |||
generators: { | |||
catchChance: function(item, blueprint) { | |||
return random.expNorm(0, 70); | |||
}, | |||
catchSpeed: function(item, blueprint) { | |||
return random.expNorm(0, 150); | |||
}, | |||
fishRarity: function(item, blueprint) { | |||
return random.expNorm(0, 100); | |||
}, | |||
fishWeight: function(item, blueprint) { | |||
return random.expNorm(0, 75); | |||
} | |||
}, | |||
generate: function(item, blueprint) { | |||
var statCount = blueprint.statCount || (item.quality + 1); | |||
var stats = Object.keys(this.generators); | |||
if (!item.stats) | |||
item.stats = {}; | |||
for (var i = 0; i < statCount; i++) { | |||
var stat = stats[~~(Math.random() * stats.length)]; | |||
var value = Math.ceil(this.generators[stat].call(this, item, blueprint)); | |||
if (!item.stats[stat]) | |||
item.stats[stat] = 0; | |||
item.stats[stat] += value; | |||
} | |||
} | |||
}; | |||
}); |
@@ -27,10 +27,8 @@ define([ | |||
if ((typeBlueprint.material) && (blueprint.statMult.armor)) | |||
blueprint.statMult.armor *= armorMaterials[typeBlueprint.material].statMult.armor; | |||
if (item.slot == 'tool') { | |||
blueprint.noStats = true; | |||
if (item.slot == 'tool') | |||
blueprint.noName = true; | |||
} | |||
} | |||
} | |||
}); |
@@ -22,5 +22,17 @@ extend(true, random, { | |||
var result = (mid + (roll * range)); | |||
return result; | |||
}, | |||
expNorm: function(low, high) { | |||
var roll = random.norm(0, 100); | |||
if (roll > 50) | |||
roll = 100 - roll; | |||
roll = (50 - roll) / 50; | |||
roll = low + ((high - low) * roll); | |||
return roll; | |||
} | |||
}); |
@@ -12,7 +12,7 @@ define([ | |||
physics: null, | |||
map: null, | |||
cdMax: 200, | |||
cdMax: 10, | |||
init: function(instance) { | |||
this.objects = instance.objects; | |||
@@ -25,11 +25,10 @@ define([ | |||
register: function(name, blueprint) { | |||
blueprint = extend(true, {}, blueprint, herbs[name], { | |||
name: name | |||
}); | |||
}); | |||
var max = blueprint.max; | |||
delete blueprint.max; | |||
delete blueprint.type; | |||
this.nodes.push({ | |||
cd: 0, | |||
@@ -47,38 +46,30 @@ define([ | |||
var h = this.physics.height; | |||
var spawn = this.map.spawn[0]; | |||
var x = null; | |||
var y = null; | |||
var x = blueprint.x || ~~(Math.random() * w); | |||
var y = blueprint.y || ~~(Math.random() * h); | |||
while (true) { | |||
x = ~~(Math.random() * w); | |||
y = ~~(Math.random() * h); | |||
if (this.physics.isTileBlocking(x, y)) | |||
return false; | |||
if (this.physics.isTileBlocking(x, y)) | |||
continue; | |||
else { | |||
var path = this.physics.getPath(spawn, { | |||
x: x, | |||
y: y | |||
}); | |||
var path = this.physics.getPath(spawn, { | |||
x: x, | |||
y: y | |||
}); | |||
var endTile = path[path.length - 1]; | |||
if (!endTile) | |||
continue; | |||
else if ((endTile.x != x) || (endTile.y != y)) | |||
continue; | |||
else { | |||
//Don't spawn in rooms | |||
var cell = this.physics.getCell(x, y); | |||
if (cell.some(c => c.notice)) | |||
continue; | |||
else { | |||
blueprint.x = x; | |||
blueprint.y = y; | |||
break; | |||
} | |||
} | |||
var endTile = path[path.length - 1]; | |||
if (!endTile) | |||
return false; | |||
else if ((endTile.x != x) || (endTile.y != y)) | |||
return false; | |||
else { | |||
//Don't spawn in rooms | |||
var cell = this.physics.getCell(x, y); | |||
if (cell.some(c => c.notice)) | |||
return false; | |||
else { | |||
blueprint.x = x; | |||
blueprint.y = y; | |||
} | |||
} | |||
@@ -94,20 +85,33 @@ define([ | |||
}] | |||
}); | |||
obj.addComponent('resourceNode').xp = (this.map.zone.level * this.map.zone.level); | |||
obj.addComponent('resourceNode', { | |||
type: blueprint.type, | |||
ttl: blueprint.ttl, | |||
xp: this.map.zone.level * this.map.zone.level, | |||
blueprint: blueprint | |||
}); | |||
var inventory = obj.addComponent('inventory'); | |||
obj.layerName = 'objects'; | |||
node.spawns.push(obj); | |||
inventory.getItem({ | |||
var item = { | |||
material: true, | |||
type: 'herb', | |||
type: node.type, | |||
sprite: node.blueprint.itemSprite, | |||
name: node.blueprint.name, | |||
quantity: 1, | |||
quality: 0 | |||
}); | |||
}; | |||
if (blueprint.type == 'fish') | |||
item.stackable = false; | |||
inventory.getItem(item); | |||
return true; | |||
}, | |||
update: function() { | |||
@@ -134,9 +138,10 @@ define([ | |||
} | |||
if ((sLen < node.max) && (node.cd == 0)) { | |||
node.cd = this.cdMax; | |||
this.spawn(node); | |||
break; | |||
if (this.spawn(node)) { | |||
node.cd = this.cdMax; | |||
break; | |||
} | |||
} | |||
} | |||
} | |||