Explorar el Código

finally got map hotswapping working

tags/v0.1.7^2
Big Bad Waffle hace 6 años
padre
commit
a2f4c23323
Se han modificado 5 ficheros con 2449 adiciones y 22 borrados
  1. +43
    -4
      src/server/mods/event-halloween/index.js
  2. +19
    -13
      src/server/mods/event-halloween/maps/tutorial/dialogues.js
  3. +2
    -2
      src/server/mods/event-halloween/maps/tutorial/zone.js
  4. +2372
    -0
      src/server/package-lock.json
  5. +13
    -3
      src/server/world/map.js

+ 43
- 4
src/server/mods/event-halloween/index.js Ver fichero

@@ -8,7 +8,7 @@ define([

mapOffset: {
x: 10,
y: 10
y: 82
},

extraScripts: [
@@ -16,18 +16,57 @@ define([
],

mapFile: null,
mapW: null,
mapH: null,

init: function() {
this.mapFile = require('../' + this.relativeFolderName + '/maps/tutorial/map');
this.mapFile = require.nodeRequire('../../../mods/event-halloween/maps/tutorial/map');
this.mapW = this.mapFile.width;
this.mapH = this.mapFile.height;

this.events.on('onBeforeGetEventList', this.onBeforeGetEventList.bind(this));
this.events.on('onBeforeGetQuests', this.onBeforeGetQuests.bind(this));
this.events.on('onBeforeGetDialogue', this.onBeforeGetDialogue.bind(this));
this.events.on('onAfterGetZone', this.onAfterGetZone.bind(this));
this.events.on('onBeforeBuildLayerTile', this.onBeforeBuildLayerTile.bind(this));
this.events.on('onAfterGetLayerObjects', this.onAfterGetLayerObjects.bind(this));
},

getLayerTile: function(info) {
info.cell = 3;
onAfterGetLayerObjects: function(info) {
if (info.map != 'tutorial')
return;

var layer = this.mapFile.layers.find(l => (l.name == info.layer));
if (layer) {
var offset = this.mapOffset;
var mapScale = this.mapFile.tilesets[0].tileheight;

layer.objects.forEach(function(l) {
var newO = extend(true, {}, l);
newO.x += (offset.x * mapScale);
newO.y += (offset.y * mapScale);

info.objects.push(newO);
}, this);
}
},

onBeforeBuildLayerTile: function(info) {
if (info.map != 'tutorial')
return;

var offset = this.mapOffset;

var x = info.x;
var y = info.y;

if ((x - offset.x < 0) || (y - offset.y < 0) || (x - offset.x >= this.mapW) || (y - offset.y >= this.mapH))
return;

var i = ((y - offset.y) * this.mapW) + (x - offset.x);
var layer = this.mapFile.layers.find(l => (l.name == info.layer));
if (layer)
info.cell = layer.data[i];
},

onBeforeGetEventList: function(zone, list) {


+ 19
- 13
src/server/mods/event-halloween/maps/tutorial/dialogues.js Ver fichero

@@ -1,16 +1,22 @@
module.exports = {
hermit: {
'1': {
msg: [{
msg: `What? Oh...what are you doing here?`,
options: [1.1]
}],
options: {
'1.1': {
msg: `Me? What are YOU doing in the middle of the wilderness?`,
goto: 2
define([

], function(

) {
return {
hermit: {
'1': {
msg: [{
msg: `What? Oh...what are you doing here?`,
options: [1.1]
}],
options: {
'1.1': {
msg: `Me? What are YOU doing in the middle of the wilderness?`,
goto: 2
}
}
}
}
}
};
};
});

+ 2
- 2
src/server/mods/event-halloween/maps/tutorial/zone.js Ver fichero

@@ -1,7 +1,7 @@
define([
], function(
) {
return {
resources: {


+ 2372
- 0
src/server/package-lock.json
La diferencia del archivo ha sido suprimido porque es demasiado grande
Ver fichero


+ 13
- 3
src/server/world/map.js Ver fichero

@@ -222,6 +222,15 @@ define([
continue;

var data = layer.data || layer.objects;
var firstItem = data[0];
if ((firstItem) && ((firstItem.id) || (firstItem.gid))) {
var info = {
map: this.name,
layer: layerName,
objects: data
};
events.emit('onAfterGetLayerObjects', info);
}

var len = data.length;
for (var j = 0; j < len; j++) {
@@ -230,16 +239,17 @@ define([
if ((cell.gid) || (cell.id))
builders.object(layerName, cell, j);
else {
var y = ~~(i / this.size.w);
var x = i - (y * this.size.w);
var y = ~~(j / this.size.w);
var x = j - (y * this.size.w);

var info = {
map: this.name,
layer: layerName,
cell: cell,
x: x,
y: y
};
events.emit('getLayerTile', info);
events.emit('onBeforeBuildLayerTile', info);
builders.tile(layerName, info.cell, j);
}
}


Cargando…
Cancelar
Guardar