Fixed #153 See merge request !97tags/v0.1.3^2
@@ -150,8 +150,12 @@ define([ | |||||
physics.removeObject(this.obj, this.obj.x, this.obj.y); | physics.removeObject(this.obj, this.obj.x, this.obj.y); | ||||
if (!permadeath) { | if (!permadeath) { | ||||
this.obj.x = this.obj.spawn.x; | |||||
this.obj.y = this.obj.spawn.y; | |||||
var level = this.obj.stats.values.level; | |||||
var spawns = this.obj.spawn; | |||||
var spawnPos = ((spawns.find(s => ((s.maxLevel) && (s.maxLevel >= level)))) || (spawns[0])); | |||||
this.obj.x = spawnPos.x; | |||||
this.obj.y = spawnPos.y; | |||||
var syncer = this.obj.syncer; | var syncer = this.obj.syncer; | ||||
syncer.o.x = this.obj.x; | syncer.o.x = this.obj.x; | ||||
@@ -1085,7 +1085,7 @@ | |||||
"name":"", | "name":"", | ||||
"properties": | "properties": | ||||
{ | { | ||||
"cpnNotice":"{\"maxLevel\": 2, \"msg\": \"The seagull's eyes are bloodshot and in its beak you see a glinting locket. It stole your family heirloom!<br \/><br \/>Click on it to target it then press <font class='color-green'>1<\/font> to toggle auto-attack. Remember to stand close if you are a warrior or thief.\"}" | |||||
"cpnNotice":"{\"maxLevel\": 1, \"msg\": \"The seagull's eyes are bloodshot and in its beak you see a glinting locket. It stole your family heirloom!<br \/><br \/>Click on it to target it then press <font class='color-green'>1<\/font> to toggle auto-attack. Remember to stand close if you are a warrior or thief.\"}" | |||||
}, | }, | ||||
"rotation":0, | "rotation":0, | ||||
"type":"", | "type":"", | ||||
@@ -1130,7 +1130,7 @@ | |||||
"name":"", | "name":"", | ||||
"properties": | "properties": | ||||
{ | { | ||||
"cpnNotice":"{\"maxLevel\": 2, \"msg\": \"You can loot items by standing on them then open your inventory with <font class='color-green'>i<\/font>.<br \/><br \/>To equip an item, simply right click the item in your inventory.\"}" | |||||
"cpnNotice":"{\"maxLevel\": 2, \"msg\": \"Far to the north, you see a small shack. Civilization!<br \/><br \/>You can read more help by pressing <font class='color-green'>h<\/font>.\"}" | |||||
}, | }, | ||||
"rotation":0, | "rotation":0, | ||||
"type":"", | "type":"", | ||||
@@ -1145,7 +1145,7 @@ | |||||
"name":"", | "name":"", | ||||
"properties": | "properties": | ||||
{ | { | ||||
"cpnNotice":"{\"maxLevel\": 2, \"msg\": \"The seagull's eyes are bloodshot and in its beak you see a glinting locket. It stole your family heirloom!<br \/><br \/>Click on it to target it then press <font class='color-green'>1<\/font> to toggle auto-attack. Remember to stand close if you are a warrior or thief.\"}" | |||||
"cpnNotice":"{\"maxLevel\": 1, \"msg\": \"The seagull's eyes are bloodshot and in its beak you see a glinting locket. It stole your family heirloom!<br \/><br \/>Click on it to target it then press <font class='color-green'>1<\/font> to toggle auto-attack. Remember to stand close if you are a warrior or thief.\"}" | |||||
}, | }, | ||||
"rotation":0, | "rotation":0, | ||||
"type":"", | "type":"", | ||||
@@ -1419,7 +1419,7 @@ | |||||
{ | { | ||||
"instanced":"0", | "instanced":"0", | ||||
"name":"Test Zone", | "name":"Test Zone", | ||||
"spawn":"{\"x\":60,\"y\":116}" | |||||
"spawn":"[{\"maxLevel\":1,\"x\":60,\"y\":116},{\"maxLevel\":2,\"x\":89,\"y\":48}]" | |||||
}, | }, | ||||
"renderorder":"right-down", | "renderorder":"right-down", | ||||
"tileheight":8, | "tileheight":8, | ||||
@@ -124,15 +124,14 @@ define([ | |||||
msg.keepPos = false; | msg.keepPos = false; | ||||
} | } | ||||
var spawnPos = map.getSpawnPos(obj); | |||||
if ((!msg.keepPos) || (obj.x == null)) { | if ((!msg.keepPos) || (obj.x == null)) { | ||||
obj.x = map.spawn.x; | |||||
obj.y = map.spawn.y; | |||||
obj.x = spawnPos.x; | |||||
obj.y = spawnPos.y; | |||||
} | } | ||||
obj.spawn = { | |||||
x: map.spawn.x, | |||||
y: map.spawn.y | |||||
}; | |||||
obj.spawn = map.spawn; | |||||
syncer.queue('onGetMap', map.clientMap, [obj.serverId]); | syncer.queue('onGetMap', map.clientMap, [obj.serverId]); | ||||
@@ -312,25 +311,23 @@ define([ | |||||
msg.keepPos = false; | msg.keepPos = false; | ||||
} | } | ||||
var spawnPos = map.getSpawnPos(obj); | |||||
if ((!msg.keepPos) || (obj.x == null)) { | if ((!msg.keepPos) || (obj.x == null)) { | ||||
obj.x = map.spawn.x; | |||||
obj.y = map.spawn.y; | |||||
obj.x = spawnPos.x; | |||||
obj.y = spawnPos.y; | |||||
} | } | ||||
obj.spawn = { | |||||
x: map.spawn.x, | |||||
y: map.spawn.y | |||||
}; | |||||
obj.spawn = map.spawn; | |||||
if (exists) { | if (exists) { | ||||
//Keep track of what the connection id is (sent from the server) | //Keep track of what the connection id is (sent from the server) | ||||
obj.serverId = obj.id; | obj.serverId = obj.id; | ||||
delete obj.id; | delete obj.id; | ||||
obj.spawn = { | |||||
x: exists.map.spawn.x, | |||||
y: exists.map.spawn.y | |||||
}; | |||||
var spawnPos = exists.map.getSpawnPos(obj); | |||||
obj.spawn = exists.map.spawn; | |||||
exists.syncer.queue('onGetMap', exists.map.clientMap, [obj.serverId]); | exists.syncer.queue('onGetMap', exists.map.clientMap, [obj.serverId]); | ||||
@@ -353,8 +350,10 @@ define([ | |||||
}, | }, | ||||
onAddObject: function(keepPos, obj) { | onAddObject: function(keepPos, obj) { | ||||
if (!keepPos) { | if (!keepPos) { | ||||
obj.x = obj.instance.map.spawn.x; | |||||
obj.y = obj.instance.map.spawn.y; | |||||
var spawnPos = obj.instance.map.getSpawnPos(obj); | |||||
obj.x = spawnPos.x; | |||||
obj.y = spawnPos.y; | |||||
} | } | ||||
obj.instance.spawners.scale(obj.stats.values.level); | obj.instance.spawners.scale(obj.stats.values.level); | ||||
@@ -458,7 +457,8 @@ define([ | |||||
questBuilder: extend(true, {}, questBuilder), | questBuilder: extend(true, {}, questBuilder), | ||||
map: { | map: { | ||||
spawn: extend(true, {}, map.spawn), | spawn: extend(true, {}, map.spawn), | ||||
clientMap: extend(true, {}, map.clientMap) | |||||
clientMap: extend(true, {}, map.clientMap), | |||||
getSpawnPos: map.getSpawnPos.bind(map) | |||||
} | } | ||||
}; | }; | ||||
@@ -496,8 +496,11 @@ define([ | |||||
obj = instance.objects.addObject(objToAdd, this.onAddObject.bind(this, false)); | obj = instance.objects.addObject(objToAdd, this.onAddObject.bind(this, false)); | ||||
else { | else { | ||||
obj = instance.objects.transferObject(objToAdd); | obj = instance.objects.transferObject(objToAdd); | ||||
obj.x = instance.map.spawn.x; | |||||
obj.y = instance.map.spawn.y; | |||||
var spawnPos = instance.map.getSpawnPos(obj); | |||||
obj.x = spawnPos.x; | |||||
obj.y = spawnPos.y; | |||||
instance.questBuilder.obtain(obj); | instance.questBuilder.obtain(obj); | ||||
obj.instance.spawners.scale(obj.stats.values.level); | obj.instance.spawners.scale(obj.stats.values.level); | ||||
@@ -95,8 +95,11 @@ define([ | |||||
if (this.instanced) | if (this.instanced) | ||||
this.instanced = (this.instanced == '1'); | this.instanced = (this.instanced == '1'); | ||||
if (mapFile.properties.spawn) | |||||
if (mapFile.properties.spawn) { | |||||
this.spawn = JSON.parse(mapFile.properties.spawn); | this.spawn = JSON.parse(mapFile.properties.spawn); | ||||
if (!this.spawn.push) | |||||
this.spawn = [ this.spawn ]; | |||||
} | |||||
}, | }, | ||||
create: function() { | create: function() { | ||||
this.getMapFile(); | this.getMapFile(); | ||||
@@ -361,6 +364,13 @@ define([ | |||||
this.objBlueprints.push(obj); | this.objBlueprints.push(obj); | ||||
} | } | ||||
} | } | ||||
}, | |||||
getSpawnPos: function(obj) { | |||||
var stats = obj.components.find(c => (c.type == 'stats')); | |||||
var level = stats.values.level; | |||||
return ((this.spawn.find(s => ((s.maxLevel) && (s.maxLevel >= level)))) || (this.spawn[0])); | |||||
} | } | ||||
} | } | ||||
@@ -200,8 +200,10 @@ define([ | |||||
clientMap.collisionMap = _.get2dArray(w, h); | clientMap.collisionMap = _.get2dArray(w, h); | ||||
var startTemplate = startRoom.template; | var startTemplate = startRoom.template; | ||||
map.spawn.x = startRoom.x + ~~(startTemplate.width / 2); | |||||
map.spawn.y = startRoom.y + ~~(startTemplate.height / 2); | |||||
map.spawn = [{ | |||||
x: startRoom.x + ~~(startTemplate.width / 2), | |||||
y: startRoom.y + ~~(startTemplate.height / 2) | |||||
}]; | |||||
this.drawRoom(instance, startRoom); | this.drawRoom(instance, startRoom); | ||||
@@ -46,7 +46,7 @@ define([ | |||||
var w = this.physics.width; | var w = this.physics.width; | ||||
var h = this.physics.height; | var h = this.physics.height; | ||||
var spawn = this.map.spawn; | |||||
var spawn = this.map.spawn[0]; | |||||
var x = null; | var x = null; | ||||
var y = null; | var y = null; | ||||