90 lines
1.8 KiB
JavaScript
90 lines
1.8 KiB
JavaScript
import {buildInvoke, buildTraversal} from '@avocado/behavior';
|
|
|
|
// Mama kitty spawner.
|
|
export function mamaKittySpawnerJSON() {
|
|
|
|
const storeJSON = buildTraversal(
|
|
['context', 'json'],
|
|
{
|
|
traits: {
|
|
positioned: {
|
|
state: {},
|
|
},
|
|
},
|
|
},
|
|
);
|
|
|
|
function setAxeFromRoom(roomAxe, entityAxe) {
|
|
return buildTraversal(
|
|
['context', 'json', 'traits', 'positioned', 'state', entityAxe],
|
|
buildInvoke(['global', 'multiply'], [
|
|
buildInvoke(
|
|
['global', 'randomNumber'],
|
|
[
|
|
100,
|
|
buildInvoke(
|
|
['global', 'sub'],
|
|
[
|
|
buildTraversal(['entity', 'room', roomAxe]),
|
|
100,
|
|
],
|
|
)
|
|
],
|
|
),
|
|
4,
|
|
]),
|
|
);
|
|
}
|
|
|
|
const spawn = buildInvoke(['entity', 'spawn'], [
|
|
'mama',
|
|
buildTraversal(['context', 'json']),
|
|
]);
|
|
|
|
return {
|
|
traits: {
|
|
behaved: {
|
|
params: {
|
|
routines: {
|
|
type: 'routines',
|
|
routines: {
|
|
initial: {
|
|
type: 'routine',
|
|
routine: {
|
|
type: 'actions',
|
|
traversals: [
|
|
storeJSON,
|
|
setAxeFromRoom('width', 'x'),
|
|
setAxeFromRoom('height', 'y'),
|
|
spawn,
|
|
],
|
|
}
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
existent: {
|
|
state: {
|
|
name: 'Mama spawner',
|
|
},
|
|
},
|
|
layered: {},
|
|
listed: {},
|
|
roomed: {},
|
|
spawner: {
|
|
params: {
|
|
spawns: {
|
|
mama: {
|
|
uri: '/mama-kitty.entity.json',
|
|
},
|
|
},
|
|
},
|
|
state: {
|
|
maxSpawns: 2,
|
|
},
|
|
},
|
|
},
|
|
};
|
|
}
|