@@ -14,6 +14,7 @@ | |||
@red: #d43346; | |||
@blue: #3fa7dd; | |||
@green: #80f643; | |||
@greenA: #80f643; | |||
@greenB: #4ac441; | |||
@greenC: #386646; | |||
@@ -2,7 +2,7 @@ define([ | |||
'js/input', | |||
'js/system/client', | |||
'js/misc/physics' | |||
], function( | |||
], function ( | |||
input, | |||
client, | |||
physics | |||
@@ -17,7 +17,10 @@ define([ | |||
y: 0 | |||
}, | |||
update: function() { | |||
update: function () { | |||
if (this.obj.dead) | |||
return; | |||
if (this.obj.moveAnimation) | |||
this.obj.pather.clearPath(); | |||
@@ -40,17 +43,17 @@ define([ | |||
this.keyMove(); | |||
}, | |||
bump: function(dx, dy) { | |||
bump: function (dx, dy) { | |||
if (this.obj.pather.path.length > 0) | |||
return; | |||
this.obj.addComponent('bumpAnimation', { | |||
deltaX: dx, | |||
deltaY: dy | |||
}); | |||
}, | |||
keyMove: function() { | |||
keyMove: function () { | |||
var delta = { | |||
x: input.getAxis('horizontal'), | |||
y: input.getAxis('vertical') | |||
@@ -74,7 +77,7 @@ define([ | |||
this.addQueue(newX, newY); | |||
}, | |||
addQueue: function(x, y) { | |||
addQueue: function (x, y) { | |||
if (this.obj.moveAnimation) | |||
return; | |||
@@ -95,4 +98,4 @@ define([ | |||
}); | |||
} | |||
}; | |||
}); | |||
}); |
@@ -1,7 +1,7 @@ | |||
define([ | |||
'js/system/events', | |||
'js/rendering/renderer' | |||
], function( | |||
], function ( | |||
events, | |||
renderer | |||
) { | |||
@@ -15,7 +15,7 @@ define([ | |||
hpSprite: null, | |||
hpSpriteInner: null, | |||
init: function(blueprint) { | |||
init: function (blueprint) { | |||
if (this.obj.self) | |||
events.emit('onGetStats', this.values); | |||
@@ -50,7 +50,10 @@ define([ | |||
this.updateHpSprite(); | |||
}, | |||
updateHpSprite: function() { | |||
updateHpSprite: function () { | |||
if (this.obj.dead) | |||
return; | |||
var obj = this.obj; | |||
var yOffset = -12; | |||
@@ -80,7 +83,7 @@ define([ | |||
this.hpSpriteInner.visible = this.hpSprite.visible; | |||
}, | |||
extend: function(blueprint) { | |||
extend: function (blueprint) { | |||
var bValues = blueprint.values || {}; | |||
var values = this.values; | |||
@@ -99,7 +102,7 @@ define([ | |||
this.updateHpSprite(); | |||
}, | |||
destroy: function() { | |||
destroy: function () { | |||
renderer.destroyObject({ | |||
sprite: this.hpSprite, | |||
layerName: 'effects' | |||
@@ -111,4 +114,4 @@ define([ | |||
}); | |||
} | |||
}; | |||
}); | |||
}); |
@@ -146,8 +146,15 @@ define([ | |||
if (obj.sheetName) { | |||
obj.sprite = renderer.buildObject(obj); | |||
if (template.hidden) | |||
if (template.hidden) { | |||
obj.sprite.visible = false; | |||
if (obj.nameSprite) | |||
obj.nameSprite.visible = false; | |||
if ((obj.stats) && (obj.stats.hpSprite)) { | |||
obj.stats.hpSprite.visible = false; | |||
obj.stats.hpSpriteInner.visible = false; | |||
} | |||
} | |||
} | |||
components.forEach(function (c) { | |||
@@ -254,6 +261,12 @@ define([ | |||
if (sprite) { | |||
if (template.hidden != null) { | |||
sprite.visible = !template.hidden; | |||
if (obj.nameSprite) | |||
obj.nameSprite.visible = this.nameSprite; | |||
if ((obj.stats) && (obj.stats.hpSprite)) { | |||
obj.stats.hpSprite.visible = !template.hidden; | |||
obj.stats.hpSpriteInner.visible = !template.hidden; | |||
} | |||
} | |||
} | |||
@@ -310,8 +323,9 @@ define([ | |||
var objects = this.objects; | |||
var oLen = objects.length; | |||
for (var i = 0; i < oLen; i++) { | |||
var ns = objects[i].nameSprite; | |||
if (!ns) | |||
var obj = objects[i]; | |||
var ns = obj.nameSprite; | |||
if ((!ns) || (obj.dead)) | |||
continue; | |||
ns.visible = showNames; | |||
@@ -76,7 +76,6 @@ define([ | |||
PIXI.SCALE_MODES.DEFAULT = PIXI.SCALE_MODES.NEAREST; | |||
events.on('onGetMap', this.onGetMap.bind(this)); | |||
events.on('onDeath', this.onDeath.bind(this)); | |||
events.on('onToggleFullscreen', this.toggleScreen.bind(this)); | |||
this.width = $('body').width(); | |||
@@ -240,13 +239,6 @@ define([ | |||
} | |||
}, | |||
onDeath: function (pos) { | |||
this.setPosition({ | |||
x: (pos.x - (this.width / (scale * 2))) * scale, | |||
y: (pos.y - (this.height / (scale * 2))) * scale | |||
}, true); | |||
}, | |||
onResize: function () { | |||
var zoom = window.devicePixelRatio; | |||
@@ -3,7 +3,7 @@ define([ | |||
'js/system/client', | |||
'html!ui/templates/death/template', | |||
'css!ui/templates/death/styles' | |||
], function( | |||
], function ( | |||
events, | |||
client, | |||
template, | |||
@@ -15,7 +15,7 @@ define([ | |||
modal: true, | |||
centered: true, | |||
postRender: function() { | |||
postRender: function () { | |||
this.onEvent('onDeath', this.onDeath.bind(this)); | |||
this.onEvent('onPermadeath', this.onPermadeath.bind(this)); | |||
@@ -23,30 +23,49 @@ define([ | |||
this.find('.btn-respawn').on('click', this.onRespawn.bind(this)); | |||
}, | |||
onLogout: function() { | |||
onLogout: function () { | |||
$('.uiOptions').data('ui').charSelect(); | |||
}, | |||
onRespawn: function() { | |||
onRespawn: function () { | |||
events.emit('onHideOverlay', this.el); | |||
this.hide(); | |||
client.request({ | |||
cpn: 'player', | |||
method: 'performAction', | |||
data: { | |||
cpn: 'stats', | |||
method: 'respawn' | |||
} | |||
}); | |||
}, | |||
doShow: function() { | |||
doShow: function () { | |||
this.show(); | |||
events.emit('onShowOverlay', this.el); | |||
}, | |||
onDeath: function(event) { | |||
this.find('.msg').html('you were killed by [ <div class="inner">' + event.source + '</div> ]'); | |||
onDeath: function (event) { | |||
if (!event.source) { | |||
this.find('.msg').html('you are dead'); | |||
} else | |||
this.find('.msg').html('you were killed by [ <div class="inner">' + event.source + '</div> ]'); | |||
this.find('.penalty') | |||
.html('you lost ' + event.xpLoss + ' experience') | |||
.show(); | |||
if (!event.xpLoss) | |||
this.find('.penalty').hide(); | |||
this.el.removeClass('permadeath'); | |||
this.doShow(); | |||
}, | |||
onPermadeath: function(event) { | |||
onPermadeath: function (event) { | |||
this.find('.msg').html('you were killed by [ <div class="inner">' + event.source + '</div> ]'); | |||
this.el.addClass('permadeath'); | |||
this.doShow(); | |||
} | |||
}; | |||
}); | |||
}); |
@@ -18,6 +18,11 @@ | |||
} | |||
} | |||
.penalty { | |||
color: @yellowB; | |||
margin-top: 15px; | |||
} | |||
.btn { | |||
color: @white; | |||
width: 100%; | |||
@@ -50,4 +55,4 @@ | |||
display: none; | |||
} | |||
} | |||
} | |||
} |
@@ -1,7 +1,8 @@ | |||
<div class="uiDeath"> | |||
<div class="msg"></div> | |||
<div class="penalty"></div> | |||
<div class="buttons"> | |||
<div class="btn btn-respawn">respawn</div> | |||
<div class="btn btn-logout">log out</div> | |||
</div> | |||
</div> | |||
</div> |
@@ -49,6 +49,9 @@ define([ | |||
}, | |||
move: function () { | |||
if (this.obj.dead) | |||
return; | |||
var result = { | |||
success: true | |||
}; | |||
@@ -93,7 +96,7 @@ define([ | |||
//find mobs in range | |||
var range = this.range; | |||
var faction = this.faction; | |||
var inRange = this.physics.getArea(x - range, y - range, x + range, y + range, (c => (((!c.player) || (!obj.player)) && (c.aggro) && (c.aggro.willAutoAttack(obj))))); | |||
var inRange = this.physics.getArea(x - range, y - range, x + range, y + range, (c => (((!c.player) || (!obj.player)) && (!obj.dead) && (c.aggro) && (c.aggro.willAutoAttack(obj))))); | |||
if (inRange.length == 0) | |||
return; | |||
@@ -235,13 +238,16 @@ define([ | |||
for (var i = 0; i < lLen; i++) { | |||
var l = list[i]; | |||
if (!l) { | |||
console.log('aggro obj empty???'); | |||
lLen--; | |||
continue; | |||
} | |||
//Maybe the aggro component was removed? | |||
var targetAggro = l.obj.aggro; | |||
if (targetAggro) | |||
if (targetAggro) { | |||
targetAggro.unAggro(this.obj); | |||
i--; | |||
lLen--; | |||
} | |||
} | |||
this.list = []; | |||
@@ -26,6 +26,9 @@ define([ | |||
spawn: function (character, cb) { | |||
var obj = this.obj; | |||
if (character.dead) | |||
obj.dead = true; | |||
extend(true, obj, { | |||
layerName: 'mobs', | |||
cell: character.cell, | |||
@@ -36,6 +39,7 @@ define([ | |||
zoneName: character.zoneName || 'fjolarok', | |||
x: character.x, | |||
y: character.y, | |||
hidden: character.dead, | |||
account: character.account, | |||
instanceId: character.instanceId | |||
}); | |||
@@ -162,6 +166,9 @@ define([ | |||
var physics = this.obj.instance.physics; | |||
physics.removeObject(this.obj, this.obj.x, this.obj.y); | |||
this.obj.dead = true; | |||
this.obj.aggro.die(); | |||
if (!permadeath) { | |||
var level = this.obj.stats.values.level; | |||
@@ -180,20 +187,21 @@ define([ | |||
this.obj.x = spawnPos.x; | |||
this.obj.y = spawnPos.y; | |||
var syncer = this.obj.syncer; | |||
syncer.o.x = this.obj.x; | |||
syncer.o.y = this.obj.y; | |||
physics.addObject(this.obj, this.obj.x, this.obj.y); | |||
this.obj.stats.die(source); | |||
} else { | |||
this.obj.stats.dead = true; | |||
process.send({ | |||
method: 'object', | |||
serverId: this.obj.serverId, | |||
obj: { | |||
dead: true | |||
} | |||
}); | |||
} else { | |||
process.send({ | |||
method: 'object', | |||
serverId: this.obj.serverId, | |||
obj: { | |||
dead: true, | |||
permadead: true | |||
} | |||
}); | |||
@@ -201,11 +209,18 @@ define([ | |||
this.obj.fireEvent('onAfterDeath', source); | |||
this.obj.aggro.die(); | |||
this.obj.spellbook.die(); | |||
this.obj.effects.die(); | |||
}, | |||
respawn: function () { | |||
var syncer = this.obj.syncer; | |||
syncer.o.x = this.obj.x; | |||
syncer.o.y = this.obj.y; | |||
this.obj.aggro.move(); | |||
this.obj.instance.physics.addObject(this.obj, this.obj.x, this.obj.y); | |||
}, | |||
move: function (msg) { | |||
@@ -111,7 +111,7 @@ define([ | |||
}, | |||
update: function () { | |||
if (((this.obj.mob) && (!this.obj.follower)) || (this.dead)) | |||
if (((this.obj.mob) && (!this.obj.follower)) || (this.obj.dead)) | |||
return; | |||
var values = this.values; | |||
@@ -367,24 +367,87 @@ define([ | |||
}, | |||
die: function (source) { | |||
this.values.hp = this.values.hpMax; | |||
this.values.mana = this.values.manaMax; | |||
this.obj.syncer.setObject(false, 'stats', 'values', 'hp', this.values.hp); | |||
this.obj.syncer.setObject(false, 'stats', 'values', 'mana', this.values.mana); | |||
var obj = this.obj; | |||
var values = this.values; | |||
this.syncer.queue('onGetDamage', { | |||
id: this.obj.id, | |||
id: obj.id, | |||
event: true, | |||
text: 'death' | |||
}); | |||
obj.syncer.set(true, null, 'dead', true); | |||
var obj = obj; | |||
var syncO = obj.syncer.o; | |||
obj.hidden = true; | |||
obj.nonSelectable = true; | |||
syncO.hidden = true; | |||
syncO.nonSelectable = true; | |||
var xpLoss = ~~Math.min(values.xp, values.xpMax / 10); | |||
values.xp -= xpLoss; | |||
obj.syncer.setObject(true, 'stats', 'values', 'xp', values.xp); | |||
this.syncer.queue('onDeath', { | |||
x: this.obj.x, | |||
y: this.obj.y, | |||
source: source.name | |||
}, [this.obj.serverId]); | |||
source: source.name, | |||
xpLoss: xpLoss | |||
}, [obj.serverId]); | |||
obj.instance.syncer.queue('onGetObject', { | |||
x: obj.x, | |||
y: obj.y, | |||
components: [{ | |||
type: 'attackAnimation', | |||
row: 0, | |||
col: 4 | |||
}] | |||
}); | |||
}, | |||
respawn: function () { | |||
this.obj.syncer.set(true, null, 'dead', false); | |||
var obj = this.obj; | |||
var syncO = obj.syncer.o; | |||
this.obj.dead = false; | |||
var values = this.values; | |||
values.hp = values.hpMax; | |||
values.mana = values.manaMax; | |||
obj.syncer.setObject(false, 'stats', 'values', 'hp', values.hp); | |||
obj.syncer.setObject(false, 'stats', 'values', 'mana', values.mana); | |||
obj.hidden = false; | |||
obj.nonSelectable = false; | |||
syncO.hidden = false; | |||
syncO.nonSelectable = false; | |||
process.send({ | |||
method: 'object', | |||
serverId: this.obj.serverId, | |||
obj: { | |||
dead: false | |||
} | |||
}); | |||
obj.instance.syncer.queue('onGetObject', { | |||
x: obj.x, | |||
y: obj.y, | |||
components: [{ | |||
type: 'attackAnimation', | |||
row: 0, | |||
col: 4 | |||
}] | |||
}); | |||
this.obj.player.respawn(); | |||
}, | |||
takeDamage: function (damage, threatMult, source) { | |||
source.fireEvent('beforeDealDamage', damage, this.obj); | |||
this.obj.fireEvent('beforeTakeDamage', damage, source); | |||
@@ -132,9 +132,9 @@ define([ | |||
cpn.init(); | |||
} | |||
if (this.physics) { | |||
if ((this.physics) && (!obj.dead)) { | |||
if (!obj.width) | |||
this.physics.addObject(obj, obj.x, obj.y); | |||
this.physics.addObject(obj, obj.x, obj.y); | |||
else | |||
this.physics.addRegion(obj); | |||
} | |||
@@ -206,7 +206,8 @@ define([ | |||
} | |||
this.objects.push(newO); | |||
this.physics.addObject(newO, newO.x, newO.y); | |||
if (!newO.dead) | |||
this.physics.addObject(newO, newO.x, newO.y); | |||
callback(newO); | |||
@@ -63,7 +63,19 @@ define([ | |||
} else | |||
player = this.players.find(p => p.socket.id == socket.id); | |||
if ((!player) || ((player.permadead) && (['getCharacterList', 'getCharacter', 'deleteCharacter'].indexOf(msg.method) === -1))) | |||
if ( | |||
(!player) || | |||
( | |||
(player.permadead) && | |||
(['getCharacterList', 'getCharacter', 'deleteCharacter'].indexOf(msg.method) === -1) | |||
) || | |||
( | |||
(player.dead) && | |||
(msg.method != 'performAction') && | |||
(msg.data.cpn != 'stats') && | |||
(msg.data.method != 'respawn') | |||
) | |||
) | |||
return; | |||
var cpn = player[msg.cpn]; | |||
@@ -27,7 +27,8 @@ define([ | |||
stash: ['withdraw'], | |||
trade: ['buySell'], | |||
door: ['lock', 'unlock'], | |||
wardrobe: ['open', 'apply'] | |||
wardrobe: ['open', 'apply'], | |||
stats: ['respawn'] | |||
}; | |||
return ((secondaryAllowed[msg.data.cpn]) && (secondaryAllowed[msg.data.cpn].indexOf(msg.data.method) > -1)); | |||
@@ -158,6 +158,13 @@ define([ | |||
questBuilder.obtain(obj); | |||
obj.fireEvent('afterMove'); | |||
if (obj.dead) { | |||
obj.instance.syncer.queue('onDeath', { | |||
x: obj.x, | |||
y: obj.y | |||
}, [obj.serverId]); | |||
} | |||
}, | |||
updateObject: function (msg) { | |||
var obj = objects.find(o => o.serverId == msg.id); | |||
@@ -384,6 +391,13 @@ define([ | |||
obj.stats.rescale(maxLevel); | |||
obj.fireEvent('afterMove'); | |||
if (obj.dead) { | |||
obj.instance.syncer.queue('onDeath', { | |||
x: obj.x, | |||
y: obj.y | |||
}, [obj.serverId]); | |||
} | |||
}, | |||
updateObject: function (msg) { | |||
var id = msg.id; | |||
@@ -551,6 +565,13 @@ define([ | |||
} | |||
}); | |||
if (obj.dead) { | |||
obj.instance.syncer.queue('onDeath', { | |||
x: obj.x, | |||
y: obj.y | |||
}, [obj.serverId]); | |||
} | |||
return obj; | |||
} | |||
}, | |||