2019-06-05 20:20:45 -05:00
|
|
|
import {buildInvoke, buildTraversal} from '@avocado/behavior';
|
|
|
|
|
|
|
|
import {AFFINITY_NONE} from '../../common/combat/constants';
|
|
|
|
|
|
|
|
// Projectile rock.
|
|
|
|
export function rockProjectileJSON() {
|
|
|
|
// Set as not damaging to user.
|
|
|
|
const setDoesNotCollideWith = buildInvoke(
|
|
|
|
['entity', 'setDoesNotCollideWith'],
|
|
|
|
[
|
|
|
|
buildTraversal(['wielder']),
|
|
|
|
],
|
|
|
|
);
|
|
|
|
// Set visible.
|
|
|
|
const setVisible = buildTraversal(
|
|
|
|
['entity', 'isVisible'],
|
|
|
|
true,
|
|
|
|
);
|
|
|
|
// Set item to user position.
|
|
|
|
const setToUserPosition = buildInvoke(
|
|
|
|
['entity', 'setPosition'],
|
|
|
|
[
|
|
|
|
buildTraversal(['wielder', 'position']),
|
|
|
|
],
|
|
|
|
);
|
|
|
|
// Turn and move in direction user is facing for half a second.
|
|
|
|
const turn = buildTraversal(
|
|
|
|
['entity', 'direction'],
|
|
|
|
buildTraversal(['wielder', 'direction']),
|
|
|
|
);
|
2019-06-05 23:40:20 -05:00
|
|
|
const move = buildInvoke(
|
|
|
|
['entity', 'moveFor'],
|
|
|
|
[
|
|
|
|
buildInvoke(
|
2019-09-08 03:21:56 -05:00
|
|
|
['Math', 'Vector', 'fromDirection'],
|
2019-06-05 23:40:20 -05:00
|
|
|
[
|
|
|
|
buildTraversal(['entity', 'direction']),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
0.5,
|
|
|
|
],
|
|
|
|
);
|
2019-06-06 00:21:11 -05:00
|
|
|
const setIsNotColliding = buildTraversal(
|
|
|
|
['entity', 'isColliding'],
|
|
|
|
false,
|
|
|
|
);
|
2019-06-05 23:40:20 -05:00
|
|
|
const setIsNotDamaging = buildTraversal(
|
|
|
|
['entity', 'isDamaging'],
|
|
|
|
false,
|
|
|
|
);
|
2019-06-06 00:42:21 -05:00
|
|
|
const fadeOutAndSlowDown = buildInvoke(
|
2019-06-06 00:21:11 -05:00
|
|
|
['entity', 'transition'],
|
|
|
|
[
|
|
|
|
{
|
|
|
|
opacity: 0,
|
2019-06-06 00:42:21 -05:00
|
|
|
speed: 0,
|
2019-06-06 00:21:11 -05:00
|
|
|
},
|
|
|
|
0.2,
|
|
|
|
],
|
|
|
|
);
|
2019-06-05 23:40:20 -05:00
|
|
|
const reflect = buildInvoke(
|
|
|
|
['entity', 'moveFor'],
|
|
|
|
[
|
|
|
|
buildInvoke(
|
2019-09-08 03:21:56 -05:00
|
|
|
['Math', 'Vector', 'sub'],
|
2019-06-05 23:40:20 -05:00
|
|
|
[
|
|
|
|
buildTraversal(['entity', 'position']),
|
|
|
|
buildTraversal(['obstacle', 'position']),
|
|
|
|
],
|
|
|
|
),
|
2019-06-06 00:21:11 -05:00
|
|
|
0.2,
|
|
|
|
],
|
|
|
|
);
|
|
|
|
const afterImpact = buildInvoke(
|
2019-09-08 03:44:27 -05:00
|
|
|
['Flow', 'parallel'],
|
2019-06-06 00:21:11 -05:00
|
|
|
[
|
|
|
|
{
|
|
|
|
type: 'actions',
|
|
|
|
traversals: [
|
2019-06-06 00:42:21 -05:00
|
|
|
fadeOutAndSlowDown,
|
2019-06-06 00:21:11 -05:00
|
|
|
reflect,
|
|
|
|
],
|
|
|
|
},
|
2019-06-05 23:40:20 -05:00
|
|
|
],
|
|
|
|
);
|
2019-06-05 20:20:45 -05:00
|
|
|
// Destroy.
|
|
|
|
const destroy = buildInvoke(
|
|
|
|
['entity', 'destroy'],
|
|
|
|
);
|
|
|
|
return {
|
|
|
|
traits: {
|
|
|
|
behaved: {
|
|
|
|
params: {
|
|
|
|
routines: {
|
|
|
|
type: 'routines',
|
|
|
|
routines: {
|
|
|
|
initial: {
|
|
|
|
type: 'routine',
|
|
|
|
routine: {
|
|
|
|
type: 'actions',
|
|
|
|
traversals: [
|
|
|
|
setDoesNotCollideWith,
|
|
|
|
setToUserPosition,
|
|
|
|
setVisible,
|
|
|
|
turn,
|
|
|
|
move,
|
|
|
|
destroy,
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
2019-06-05 23:40:20 -05:00
|
|
|
reflect: {
|
2019-06-05 20:20:45 -05:00
|
|
|
type: 'routine',
|
|
|
|
routine: {
|
|
|
|
type: 'actions',
|
2019-06-05 23:40:20 -05:00
|
|
|
traversals: [
|
2019-06-06 00:21:11 -05:00
|
|
|
setIsNotColliding,
|
2019-06-05 23:40:20 -05:00
|
|
|
setIsNotDamaging,
|
2019-06-06 00:21:11 -05:00
|
|
|
afterImpact,
|
2019-06-05 23:40:20 -05:00
|
|
|
destroy,
|
|
|
|
],
|
2019-06-05 20:20:45 -05:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
state: {
|
|
|
|
isBehaving: false,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
collider: {
|
|
|
|
params: {
|
2019-10-02 00:38:09 -05:00
|
|
|
collisionGroup: 'projectile',
|
2019-06-05 23:40:20 -05:00
|
|
|
collisionStartActions: {
|
|
|
|
type: 'actions',
|
|
|
|
traversals: [
|
|
|
|
buildInvoke(
|
2019-09-08 06:26:09 -05:00
|
|
|
['entity', 'context', 'add'],
|
2019-06-05 23:40:20 -05:00
|
|
|
[
|
|
|
|
'obstacle',
|
|
|
|
buildTraversal(['other']),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
buildTraversal(
|
|
|
|
['entity', 'currentRoutine'],
|
|
|
|
'reflect',
|
|
|
|
),
|
|
|
|
],
|
|
|
|
},
|
2019-06-05 20:20:45 -05:00
|
|
|
isSensor: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
damaging: {
|
|
|
|
params: {
|
|
|
|
damageSpecs: [
|
|
|
|
{
|
|
|
|
affinity: AFFINITY_NONE,
|
|
|
|
knockback: 500,
|
2019-06-05 23:40:20 -05:00
|
|
|
lock: 1,
|
2019-06-05 20:20:45 -05:00
|
|
|
power: 50,
|
|
|
|
variance: 0.1,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
directional: {
|
|
|
|
params: {
|
|
|
|
directionCount: 4,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
existent: {
|
|
|
|
state: {
|
|
|
|
name: 'Rock (projectile)',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
layered: {},
|
|
|
|
listed: {},
|
|
|
|
mobile: {
|
|
|
|
state: {
|
|
|
|
speed: 200,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
physical: {},
|
|
|
|
pictured: {
|
|
|
|
params: {
|
|
|
|
images: {
|
|
|
|
initial: {
|
|
|
|
offset: [0, 0],
|
|
|
|
size: [12, 12], // Derive?
|
|
|
|
uri: '/rock.png',
|
|
|
|
},
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
positioned: {},
|
|
|
|
roomed: {},
|
|
|
|
shaped: {
|
|
|
|
params: {
|
|
|
|
shape: {
|
|
|
|
type: 'rectangle',
|
|
|
|
position: [0, 0],
|
|
|
|
size: [12, 12],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
visible: {
|
|
|
|
state: {
|
|
|
|
isVisible: false,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|