@@ -18,6 +18,11 @@ define([ | |||||
postRender: function() { | postRender: function() { | ||||
this.onEvent('onGetTalk', this.onGetTalk.bind(this)); | this.onEvent('onGetTalk', this.onGetTalk.bind(this)); | ||||
this.onEvent('onRezone', this.onRezone.bind(this)); | |||||
}, | |||||
onRezone: function() { | |||||
this.hide(); | |||||
}, | }, | ||||
onGetTalk: function(dialogue) { | onGetTalk: function(dialogue) { | ||||
@@ -95,8 +95,18 @@ define([ | |||||
if (stateConfig.cpn) { | if (stateConfig.cpn) { | ||||
var cpn = sourceObj[stateConfig.cpn]; | var cpn = sourceObj[stateConfig.cpn]; | ||||
cpn[stateConfig.method].apply(cpn, stateConfig.args); | |||||
return; | |||||
var newArgs = extend(true, [], stateConfig.args); | |||||
newArgs.push(this.obj); | |||||
var result = cpn[stateConfig.method].apply(cpn, newArgs); | |||||
if (stateConfig.goto) { | |||||
if (result) | |||||
return this.getState(sourceObj, stateConfig.goto.success); | |||||
else | |||||
return this.getState(sourceObj, stateConfig.goto.failure); | |||||
} | |||||
else | |||||
return null; | |||||
} | } | ||||
var result = { | var result = { | ||||
@@ -158,6 +168,26 @@ define([ | |||||
return { | return { | ||||
type: 'dialogue' | type: 'dialogue' | ||||
}; | }; | ||||
}, | |||||
//These don't belong here, but I can't figure out where to put them right now | |||||
//They are actions that can be performed while chatting with someone | |||||
teleport: function(msg) { | |||||
this.obj.syncer.set(true, 'dialogue', 'state', null); | |||||
var portal = extend(true, {}, require('./components/portal'), msg); | |||||
portal.collisionEnter(this.obj); | |||||
}, | |||||
getItem: function(msg, source) { | |||||
var inventory = this.obj.inventory; | |||||
var exists = inventory.items.find(i => (i.name == msg.item.name)); | |||||
if (!exists) { | |||||
inventory.getItem(msg.item); | |||||
return true; | |||||
} | |||||
else | |||||
return false; | |||||
} | } | ||||
}; | }; | ||||
}); | }); |
@@ -3,7 +3,7 @@ module.exports = { | |||||
'1': { | '1': { | ||||
msg: [{ | msg: [{ | ||||
msg: `What? Oh...what are you doing here?`, | msg: `What? Oh...what are you doing here?`, | ||||
options: [1.1, 1.2, 1.3, 1.4, 1.5] | |||||
options: [1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7] | |||||
}], | }], | ||||
options: { | options: { | ||||
'1.1': { | '1.1': { | ||||
@@ -25,6 +25,14 @@ module.exports = { | |||||
'1.5': { | '1.5': { | ||||
msg: `I changed my mind, I want to buy something back.`, | msg: `I changed my mind, I want to buy something back.`, | ||||
goto: 'tradeBuyback' | goto: 'tradeBuyback' | ||||
}, | |||||
'1.6': { | |||||
msg: `Send me to the big city.`, | |||||
goto: 'portalCity' | |||||
}, | |||||
'1.7': { | |||||
msg: `Gimme`, | |||||
goto: 'getItem' | |||||
} | } | ||||
} | } | ||||
}, | }, | ||||
@@ -85,6 +93,18 @@ module.exports = { | |||||
} | } | ||||
} | } | ||||
}, | }, | ||||
'4': { | |||||
msg: `There you go!`, | |||||
options: { | |||||
} | |||||
}, | |||||
'5': { | |||||
msg: `You already have that!`, | |||||
options: { | |||||
} | |||||
}, | |||||
tradeBuy: { | tradeBuy: { | ||||
cpn: 'trade', | cpn: 'trade', | ||||
method: 'startBuy', | method: 'startBuy', | ||||
@@ -105,6 +125,32 @@ module.exports = { | |||||
args: [{ | args: [{ | ||||
targetName: 'hermit' | targetName: 'hermit' | ||||
}] | }] | ||||
}, | |||||
portalCity: { | |||||
cpn: 'dialogue', | |||||
method: 'teleport', | |||||
args: [{ | |||||
toZone: 'city', | |||||
toPos: { | |||||
x: 136, | |||||
y: 216 | |||||
} | |||||
}] | |||||
}, | |||||
getItem: { | |||||
cpn: 'dialogue', | |||||
method: 'getItem', | |||||
args: [{ | |||||
item: { | |||||
name: 'fancy feather', | |||||
quest: true, | |||||
sprite: [0, 0] | |||||
} | |||||
}], | |||||
goto: { | |||||
success: 4, | |||||
failure: 5 | |||||
} | |||||
} | } | ||||
} | } | ||||
}; | }; |