Browse Source

Initial Commit

tags/v0.1.5^2
Big Bad Waffle 7 years ago
parent
commit
12442323ec
3 changed files with 126 additions and 35 deletions
  1. +60
    -0
      src/server/config/maps/tutorial/events.js
  2. +48
    -0
      src/server/events/events.js
  3. +18
    -35
      src/server/world/instancer.js

+ 60
- 0
src/server/config/maps/tutorial/events.js View File

@@ -0,0 +1,60 @@
module.exports = [{
name: 'Rodriguez Heist',
description: `Rodriguez, the Hermit's only chicken companion, has been kidnapped by a band of imps. Who knows what they plan on doing with him.`,

phases: [{
type: 'spawnMob',
spawnRect: {
x: 69,
y: 39,
w: 7,
h: 6
},
mob: [{
amount: 5,
name: 'thieving imp',
level: 5,
id: 'impthief-$',
hpMult: 5,
dmgMult: 1,
drops: {
rolls: 0
}
}, {
name: 'imp kingpin',
level: 8,
hpMult: 10,
dmgMult: 2
}]
}, {
type: 'locateMob',
announce: 'Locate the thieves',
mobName: 'imp kingpin',
distance: 5
}, {
type: 'eventChain',
events: [{
type: 'mobTalk',
id: 'impthief-1',
text: `Boss! They're on to us!`,
delay: 10
}, {
type: 'mobTalk',
id: 'impthief-3',
text: `They'll take the chicken. We needs it!`,
delay: 10
}, {
type: 'mobTalk',
id: 'impkingpin',
text: `They'll never have her, she's ours now! Kill them!`,
delay: 15
}]
}, {
type: 'giveReward',
item: {
name: 'The Moonspoon',
sprite: [0, 0],
level: 1
}
}]
}];

+ 48
- 0
src/server/events/events.js View File

@@ -0,0 +1,48 @@
define([
], function(
) {
return {
configs: null,

init: function(instance) {
this.instance = instance;

var configs = null;
try {
configs = require('../config/maps/' + this.instance.map.name + '/events');
}
catch (e) {}

if (!configs)
return;

this.configs = extend(true, [], configs);
this.configs.forEach(c => (c.ttl = 10));
},

update: function() {
var configs = this.configs;
if (!configs)
return;

var cLen = configs.length;
for (var i = 0; i < cLen; i++) {
var c = configs[i];
if (c.event)
continue;
else if (c.ttl > 0) {
c.ttl--;
continue;
}

c.event = this.startEvent(c);
}
},

startEvent: function(config) {
return {};
}
};
});

+ 18
- 35
src/server/world/instancer.js View File

@@ -8,7 +8,8 @@ define([
'config/spells/spellCallbacks',
'config/quests/questBuilder',
'world/randomMap',
'world/customMap'
'world/customMap',
'events/events'
], function(
map,
syncer,
@@ -19,7 +20,8 @@ define([
spellCallbacks,
questBuilder,
randomMap,
customMap
customMap,
events
) {
return {
instances: [],
@@ -36,39 +38,23 @@ define([
map.init(args);

if (!map.instanced) {
spawners.init({
objects: objects,
syncer: syncer,
zone: map.zone
});

map.create();
map.clientMap.zoneId = this.zoneId;

resourceSpawner.init({
var fakeInstance = {
objects: objects,
syncer: syncer,
zone: map.zone,
physics: physics,
zoneId: this.zoneId,
spawners: spawners,
questBuilder: questBuilder,
zone: map.zone,
map: map
});
};

syncer.init({
objects: objects
});
spawners.init(fakeInstance);

objects.init({
objects: objects,
syncer: syncer,
physics: physics,
zoneId: this.zoneId,
spawners: spawners,
questBuilder: questBuilder
});
map.create();
map.clientMap.zoneId = this.zoneId;

questBuilder.init({
spawners: spawners
});
[resourceSpawner, syncer, objects, questBuilder, events].forEach(i => i.init(fakeInstance));

this.addObject = this.nonInstanced.addObject.bind(this);
this.onAddObject = this.nonInstanced.onAddObject.bind(this);
@@ -109,8 +95,8 @@ define([
objects.update();
spawners.update();
resourceSpawner.update();

syncer.update();
events.update();

setTimeout(this.tick.bind(this), this.speed);
},
@@ -460,18 +446,15 @@ define([
zone: map.zone,
closeTtl: null,
questBuilder: extend(true, {}, questBuilder),
events: extend(true, {}, events),
map: {
name: map.name,
spawn: extend(true, {}, map.spawn),
clientMap: extend(true, {}, map.clientMap)
}
};

instance.objects.init(instance);
instance.spawners.init(instance);
instance.syncer.init(instance);
instance.resourceSpawner.init(instance);

instance.questBuilder.init(instance);
['objects', 'spawners', 'syncer', 'resourceSpawner', 'questBuilder', 'events'].forEach(i => instance[i].init(instance));

this.instances.push(instance);



Loading…
Cancel
Save