Animators and coilhead animations
This commit is contained in:
@@ -0,0 +1,302 @@
|
||||
{
|
||||
"format_version": "1.8.0",
|
||||
"animations": {
|
||||
"animation.CoilHead.idle": {
|
||||
"loop": true,
|
||||
"animation_length": 1,
|
||||
"bones": {
|
||||
"coilhead": {
|
||||
"rotation": {
|
||||
"vector": [0, 0, 0]
|
||||
},
|
||||
"position": {
|
||||
"vector": [0, 0, 0]
|
||||
},
|
||||
"scale": {
|
||||
"vector": [1, 1, 1]
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"animation.CoilHead.stop": {
|
||||
"animation_length": 0.75,
|
||||
"bones": {
|
||||
"spring": {
|
||||
"rotation": {
|
||||
"0.0": {
|
||||
"vector": [0, 0, 0]
|
||||
},
|
||||
"0.25": {
|
||||
"vector": [-22.5, 0, 0]
|
||||
},
|
||||
"0.5417": {
|
||||
"vector": [12.5, 0, 0]
|
||||
},
|
||||
"0.75": {
|
||||
"vector": [0, 0, 0]
|
||||
}
|
||||
},
|
||||
"position": {
|
||||
"0.0": {
|
||||
"vector": [0, 0, 0]
|
||||
},
|
||||
"0.25": {
|
||||
"vector": [0, 0, 0]
|
||||
},
|
||||
"0.5417": {
|
||||
"vector": [0, 0, 0]
|
||||
},
|
||||
"0.75": {
|
||||
"vector": [0, 0, 0]
|
||||
}
|
||||
},
|
||||
"scale": {
|
||||
"0.0": {
|
||||
"vector": [1, 1, 1]
|
||||
},
|
||||
"0.25": {
|
||||
"vector": [1, 1, 1]
|
||||
},
|
||||
"0.5417": {
|
||||
"vector": [1, 1, 1]
|
||||
},
|
||||
"0.75": {
|
||||
"vector": [1, 1, 1]
|
||||
}
|
||||
}
|
||||
},
|
||||
"head": {
|
||||
"rotation": {
|
||||
"0.0": {
|
||||
"vector": [0, 0, 0]
|
||||
},
|
||||
"0.25": {
|
||||
"vector": [-17.5, 0, 0]
|
||||
},
|
||||
"0.5417": {
|
||||
"vector": [32.5, 0, 0]
|
||||
},
|
||||
"0.75": {
|
||||
"vector": [0, 0, 0]
|
||||
}
|
||||
},
|
||||
"position": {
|
||||
"0.0": {
|
||||
"vector": [0, 0, 0]
|
||||
},
|
||||
"0.25": {
|
||||
"vector": [0, 0, 0]
|
||||
},
|
||||
"0.5417": {
|
||||
"vector": [0, 0, 0]
|
||||
},
|
||||
"0.75": {
|
||||
"vector": [0, 0, 0]
|
||||
}
|
||||
},
|
||||
"scale": {
|
||||
"0.0": {
|
||||
"vector": [1, 1, 1]
|
||||
},
|
||||
"0.25": {
|
||||
"vector": [1, 1, 1]
|
||||
},
|
||||
"0.5417": {
|
||||
"vector": [1, 1, 1]
|
||||
},
|
||||
"0.75": {
|
||||
"vector": [1, 1, 1]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"animation.CoilHead.walk": {
|
||||
"loop": true,
|
||||
"animation_length": 0.5,
|
||||
"bones": {
|
||||
"coilhead": {
|
||||
"rotation": {
|
||||
"0.0": {
|
||||
"vector": [0, 0, 0]
|
||||
},
|
||||
"0.125": {
|
||||
"vector": [0, 0, 0]
|
||||
},
|
||||
"0.25": {
|
||||
"vector": [0, 0, 0]
|
||||
},
|
||||
"0.375": {
|
||||
"vector": [0, 0, 0]
|
||||
},
|
||||
"0.5": {
|
||||
"vector": [0, 0, 0]
|
||||
}
|
||||
},
|
||||
"position": {
|
||||
"0.0": {
|
||||
"vector": [0, 0, 0]
|
||||
},
|
||||
"0.125": {
|
||||
"vector": [0, -1.3, 0]
|
||||
},
|
||||
"0.25": {
|
||||
"vector": [0, 0, 0]
|
||||
},
|
||||
"0.375": {
|
||||
"vector": [0, -1.3, 0]
|
||||
},
|
||||
"0.5": {
|
||||
"vector": [0, 0, 0]
|
||||
}
|
||||
},
|
||||
"scale": {
|
||||
"0.0": {
|
||||
"vector": [1, 1, 1]
|
||||
},
|
||||
"0.125": {
|
||||
"vector": [1, 1, 1]
|
||||
},
|
||||
"0.25": {
|
||||
"vector": [1, 1, 1]
|
||||
},
|
||||
"0.375": {
|
||||
"vector": [1, 1, 1]
|
||||
},
|
||||
"0.5": {
|
||||
"vector": [1, 1, 1]
|
||||
}
|
||||
}
|
||||
},
|
||||
"left_leg": {
|
||||
"rotation": {
|
||||
"0.0": {
|
||||
"vector": [0, 0, 0]
|
||||
},
|
||||
"0.125": {
|
||||
"vector": [-20, 0, 0]
|
||||
},
|
||||
"0.25": {
|
||||
"vector": [0, 0, 0]
|
||||
},
|
||||
"0.375": {
|
||||
"vector": [25, 0, 0]
|
||||
},
|
||||
"0.5": {
|
||||
"vector": [0, 0, 0]
|
||||
}
|
||||
},
|
||||
"position": {
|
||||
"0.0": {
|
||||
"vector": [0, 0, 0]
|
||||
},
|
||||
"0.125": {
|
||||
"vector": [0, 0, 0]
|
||||
},
|
||||
"0.25": {
|
||||
"vector": [0, 0, 0]
|
||||
},
|
||||
"0.375": {
|
||||
"vector": [0, 0, 0]
|
||||
},
|
||||
"0.5": {
|
||||
"vector": [0, 0, 0]
|
||||
}
|
||||
},
|
||||
"scale": {
|
||||
"0.0": {
|
||||
"vector": [1, 1, 1]
|
||||
},
|
||||
"0.125": {
|
||||
"vector": [1, 1, 1]
|
||||
},
|
||||
"0.25": {
|
||||
"vector": [1, 1, 1]
|
||||
},
|
||||
"0.375": {
|
||||
"vector": [1, 1, 1]
|
||||
},
|
||||
"0.5": {
|
||||
"vector": [1, 1, 1]
|
||||
}
|
||||
}
|
||||
},
|
||||
"right_leg": {
|
||||
"rotation": {
|
||||
"0.0": {
|
||||
"vector": [0, 0, 0]
|
||||
},
|
||||
"0.125": {
|
||||
"vector": [25, 0, 0]
|
||||
},
|
||||
"0.25": {
|
||||
"vector": [0, 0, 0]
|
||||
},
|
||||
"0.375": {
|
||||
"vector": [-12.5, 0, 0]
|
||||
},
|
||||
"0.5": {
|
||||
"vector": [0, 0, 0]
|
||||
}
|
||||
},
|
||||
"position": {
|
||||
"0.0": {
|
||||
"vector": [0, 0, 0]
|
||||
},
|
||||
"0.125": {
|
||||
"vector": [0, 0, 0]
|
||||
},
|
||||
"0.25": {
|
||||
"vector": [0, 0, 0]
|
||||
},
|
||||
"0.375": {
|
||||
"vector": [0, 0, 0]
|
||||
},
|
||||
"0.5": {
|
||||
"vector": [0, 0, 0]
|
||||
}
|
||||
},
|
||||
"scale": {
|
||||
"0.0": {
|
||||
"vector": [1, 1, 1]
|
||||
},
|
||||
"0.125": {
|
||||
"vector": [1, 1, 1]
|
||||
},
|
||||
"0.25": {
|
||||
"vector": [1, 1, 1]
|
||||
},
|
||||
"0.375": {
|
||||
"vector": [1, 1, 1]
|
||||
},
|
||||
"0.5": {
|
||||
"vector": [1, 1, 1]
|
||||
}
|
||||
}
|
||||
},
|
||||
"spring": {
|
||||
"rotation": {
|
||||
"vector": [-22.5, 0, 0]
|
||||
},
|
||||
"position": {
|
||||
"vector": [0, 0, 0]
|
||||
},
|
||||
"scale": {
|
||||
"vector": [1, 1, 1]
|
||||
}
|
||||
},
|
||||
"head": {
|
||||
"rotation": {
|
||||
"vector": [-17.5, 0, 0]
|
||||
},
|
||||
"position": {
|
||||
"vector": [0, 0, 0]
|
||||
},
|
||||
"scale": {
|
||||
"vector": [1, 1, 1]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
// the coilhead: it goes after players like any monster, but can't move while one of them is looking at it
|
||||
import type { MobRef, Player, Position, ScriptGoal, ServerContext } from "cubi/server";
|
||||
import { AnimationState, type ClientContext } from "cubi/client";
|
||||
import { DOOR, type DoorParams, set_door_open } from "./shared.ts";
|
||||
|
||||
// how far away a player still freezes it
|
||||
@@ -21,11 +22,16 @@ export function register_coilhead(ctx: ServerContext) {
|
||||
const nearest_player = builtin.nearest_attackable_player();
|
||||
|
||||
ctx.entities.register_behavior("dangerous_business:coilhead", (mob, goals) => {
|
||||
// takes every control from the goals after it, so it doesn't walk, turn, jump or hit while seen
|
||||
// takes every control from the goals after it, so it doesn't walk, turn, jump or hit while seen. clients see it
|
||||
// frozen, for its animator
|
||||
goals.add(0, {
|
||||
flags: ["move", "look", "jump"],
|
||||
can_use: () => ctx.players.all().some((player) => sees(ctx, player, mob)),
|
||||
start: () => mob.stop(),
|
||||
start: () => {
|
||||
mob.stop();
|
||||
mob.set_client_data("frozen", true);
|
||||
},
|
||||
stop: () => mob.set_client_data("frozen", undefined),
|
||||
});
|
||||
goals.add(1, chase);
|
||||
goals.add(2, stroll);
|
||||
@@ -36,6 +42,31 @@ export function register_coilhead(ctx: ServerContext) {
|
||||
});
|
||||
}
|
||||
|
||||
// bobs as it walks and stands still otherwise. when it freezes its head springs back and forth once, and it looks
|
||||
// where it's looking
|
||||
export function register_coilhead_animator(ctx: ClientContext) {
|
||||
const idle = ctx.render.clip("dangerous_business:coilhead/idle");
|
||||
const walk = ctx.render.clip("dangerous_business:coilhead/walk");
|
||||
const stop = ctx.render.clip("dangerous_business:coilhead/stop");
|
||||
ctx.render.register_entity_animator("dangerous_business:coilhead", (coilhead) => {
|
||||
const frozen = new AnimationState();
|
||||
return {
|
||||
on_data(field, time) {
|
||||
if (field === "frozen") frozen.animate_when(coilhead.get_client_data("frozen") === true, time);
|
||||
},
|
||||
pose(pose, time) {
|
||||
if (frozen.started && !frozen.finished(stop, time)) {
|
||||
pose.play_state(stop, frozen, time);
|
||||
} else {
|
||||
pose.play(idle, time / 20);
|
||||
pose.play_walk(walk, coilhead, time);
|
||||
}
|
||||
pose.look("head");
|
||||
},
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
// opens a door on the mob's way after it's stood at it for ticks. without flags, so the goal going after its target
|
||||
// keeps its way and the mob stays at the door. the door's in the mobs_path_through tag, so its way goes through it
|
||||
export function opens_doors(ctx: ServerContext, mob: MobRef, ticks: number): ScriptGoal {
|
||||
|
||||
@@ -2,7 +2,7 @@ import type { ClientContext, Color } from "cubi/client";
|
||||
import type { ServerContext } from "cubi/server";
|
||||
import { DOOR, FACILITY_DOOR } from "./shared.ts";
|
||||
import { Alea } from "@paulaboks/rng";
|
||||
import { register_coilhead } from "./coilhead.ts";
|
||||
import { register_coilhead, register_coilhead_animator } from "./coilhead.ts";
|
||||
import { DOORWAY, MAIN_TILE, type Marker, type PlacedTile, plan_interior, tile_type, TILES } from "./interior.ts";
|
||||
|
||||
export { shared } from "./shared.ts";
|
||||
@@ -19,6 +19,7 @@ export function server(ctx: ServerContext) {
|
||||
|
||||
export function client(ctx: ClientContext) {
|
||||
register_hud(ctx);
|
||||
register_coilhead_animator(ctx);
|
||||
}
|
||||
|
||||
// a small 5x5 ring in the middle of the screen to aim with, its corners and middle left empty, in gui pixels
|
||||
|
||||
Reference in New Issue
Block a user