diff --git a/server/fixtures/mama-kitty-spawner.entity.js b/server/fixtures/mama-kitty-spawner.entity.js index 8797c3c..ce4f7e2 100644 --- a/server/fixtures/mama-kitty-spawner.entity.js +++ b/server/fixtures/mama-kitty-spawner.entity.js @@ -14,32 +14,36 @@ export function mamaKittySpawnerJSON() { }, ); - function setAxeFromRoom(roomAxe, entityAxe) { - return buildTraversal( - ['context', 'json', 'traits', 'positioned', 'state', entityAxe], - buildInvoke(['global', 'multiply'], [ + function roomAxeValue(roomAxe) { + return buildInvoke( + ['global', 'randomNumber'], + [ + 100, buildInvoke( - ['global', 'randomNumber'], + ['global', 'sub'], [ + buildTraversal(['entity', 'room', roomAxe]), 100, - buildInvoke( - ['global', 'sub'], - [ - buildTraversal(['entity', 'room', roomAxe]), - 100, - ], - ) ], - ), - 4, - ]), + ) + ], ); } - const spawn = buildInvoke(['entity', 'spawn'], [ - 'mama', - buildTraversal(['context', 'json']), - ]); + const spawn = buildInvoke( + ['entity', 'spawnAt'], + [ + 'mama', + buildInvoke( + ['global', 'makeArray'], + [ + roomAxeValue('width'), + roomAxeValue('height'), + ], + ), + buildTraversal(['context', 'json']), + ], + ); return { traits: { @@ -53,9 +57,6 @@ export function mamaKittySpawnerJSON() { routine: { type: 'actions', traversals: [ - storeJSON, - setAxeFromRoom('width', 'x'), - setAxeFromRoom('height', 'y'), spawn, ], } diff --git a/server/fixtures/mama-kitty.entity.js b/server/fixtures/mama-kitty.entity.js index 5e94cc5..8b5fd38 100644 --- a/server/fixtures/mama-kitty.entity.js +++ b/server/fixtures/mama-kitty.entity.js @@ -5,36 +5,21 @@ import {kittyJSON} from './kitty.entity'; // A MAMA kitteh. export function mamaKittyJSON() { - const storeJSON = buildTraversal( - ['context', 'json'], - { - traits: { - positioned: { - state: {}, - }, - }, - }, + const spawn = buildInvoke( + ['entity', 'spawnAt'], + [ + 'kitteh', + buildInvoke( + ['global', 'makeArray'], + [ + buildTraversal(['entity', 'x']), + buildTraversal(['entity', 'y']), + ], + ), + buildTraversal(['context', 'json']), + ], ); - const setJSONX = buildTraversal( - ['context', 'json', 'traits', 'positioned', 'state', 'x'], - buildInvoke(['global', 'multiply'], [ - buildTraversal(['entity', 'x']), 4 - ]), - ); - - const setJSONY = buildTraversal( - ['context', 'json', 'traits', 'positioned', 'state', 'y'], - buildInvoke(['global', 'multiply'], [ - buildTraversal(['entity', 'y']), 4 - ]), - ); - - const spawn = buildInvoke(['entity', 'spawn'], [ - 'kitteh', - buildTraversal(['context', 'json']), - ]); - const playDeathSound = buildInvoke(['entity', 'playSound'], [ buildTraversal(['entity', 'deathSound']), ]); @@ -66,9 +51,6 @@ export function mamaKittyJSON() { }; traits.animated.params.animations.idle.offset = [0, -8]; traits.behaved.params.routines.routines.initial.routine.traversals.push(...[ - storeJSON, - setJSONX, - setJSONY, spawn, ]); traits.existent.state.name = 'Mama Kitty';