Skip to content

Commit

Permalink
Separate sit knee animations to prevent animstate changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
Neloreck committed Aug 24, 2023
1 parent e266ba4 commit c2542ed
Show file tree
Hide file tree
Showing 5 changed files with 194 additions and 42 deletions.
10 changes: 8 additions & 2 deletions src/engine/core/objects/animation/animations/animpoint.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ import { mockFromLuaTable } from "@/fixtures/lua";

describe("animpoint animations list", () => {
it("should list all needed animations", () => {
expect(animpointAnimations.length()).toBe(43);

assertArraysIntersecting(mockFromLuaTable(animpointAnimations).getKeysArray(), [
EStalkerState.ANIMPOINT_STAY_WALL,
EStalkerState.ANIMPOINT_STAY_TABLE,
Expand All @@ -29,6 +27,8 @@ describe("animpoint animations list", () => {
EStalkerState.ANIMPOINT_SIT_LOW_EAT_KOLBASA,
EStalkerState.ANIMPOINT_SIT_ASS_EAT_BREAD,
EStalkerState.ANIMPOINT_SIT_ASS_EAT_KOLBASA,
EStalkerState.ANIMPOINT_SIT_KNEE_EAT_BREAD,
EStalkerState.ANIMPOINT_SIT_KNEE_EAT_KOLBASA,
EStalkerState.ANIMPOINT_STAY_WALL_DRINK_VODKA,
EStalkerState.ANIMPOINT_STAY_WALL_DRINK_ENERGY,
EStalkerState.ANIMPOINT_STAY_TABLE_DRINK_VODKA,
Expand All @@ -41,19 +41,25 @@ describe("animpoint animations list", () => {
EStalkerState.ANIMPOINT_SIT_LOW_DRINK_ENERGY,
EStalkerState.ANIMPOINT_SIT_ASS_DRINK_VODKA,
EStalkerState.ANIMPOINT_SIT_ASS_DRINK_ENERGY,
EStalkerState.ANIMPOINT_SIT_KNEE_DRINK_VODKA,
EStalkerState.ANIMPOINT_SIT_KNEE_DRINK_ENERGY,
EStalkerState.ANIMPOINT_SIT_LOW_DRINK_ENERGY,
EStalkerState.ANIMPOINT_STAY_WALL_GUITAR,
EStalkerState.ANIMPOINT_STAY_TABLE_GUITAR,
EStalkerState.ANIMPOINT_SIT_HIGH_GUITAR,
EStalkerState.ANIMPOINT_SIT_NORMAL_GUITAR,
EStalkerState.ANIMPOINT_SIT_LOW_GUITAR,
EStalkerState.ANIMPOINT_SIT_ASS_GUITAR,
EStalkerState.ANIMPOINT_SIT_KNEE_GUITAR,
EStalkerState.ANIMPOINT_STAY_WALL_HARMONICA,
EStalkerState.ANIMPOINT_STAY_TABLE_HARMONICA,
EStalkerState.ANIMPOINT_SIT_HIGH_HARMONICA,
EStalkerState.ANIMPOINT_SIT_NORMAL_HARMONICA,
EStalkerState.ANIMPOINT_SIT_LOW_HARMONICA,
EStalkerState.ANIMPOINT_SIT_ASS_HARMONICA,
EStalkerState.ANIMPOINT_SIT_KNEE_HARMONICA,
]);

expect(animpointAnimations.length()).toBe(49);
});
});
146 changes: 145 additions & 1 deletion src/engine/core/objects/animation/animations/animpoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,42 @@ export const animpointAnimations: LuaTable<TName, IAnimationDescriptor> = $fromO
rnd: createSequence(["animpoint_sit_low_eat_idle_1"], ["animpoint_sit_low_eat_idle_1"]),
},
[EStalkerState.ANIMPOINT_SIT_ASS_EAT_BREAD]: {
prop: {
maxidle: 3,
sumidle: 3,
rnd: 80,
moving: null,
},
into: createSequence(
["item_2_draw_0", { a: food.bread }, "item_2_draw_1"],
["item_2_draw_0", { a: food.bread }, "item_2_draw_1"]
),
out: createSequence(
["item_2_holster_1", { d: food.bread }, "item_2_holster_0"],
["item_2_holster_1", { d: food.bread }, "item_2_holster_0"]
),
idle: createSequence("item_2_aim_0", "item_2_aim_0"),
rnd: createSequence(["item_2_prepare_0", "item_2_attack_0"], ["item_2_prepare_0", "item_2_attack_0"]),
},
[EStalkerState.ANIMPOINT_SIT_ASS_EAT_KOLBASA]: {
prop: {
maxidle: 3,
sumidle: 3,
rnd: 80,
moving: null,
},
into: createSequence(
["item_1_draw_0", { a: food.kolbasa }, "item_1_draw_1"],
["item_1_draw_0", { a: food.kolbasa }, "item_1_draw_1"]
),
out: createSequence(
["item_1_holster_0", { d: food.kolbasa }, "item_1_holster_1"],
["item_1_holster_0", { d: food.kolbasa }, "item_1_holster_1"]
),
idle: createSequence("item_1_idle_1", "item_1_idle_1"),
rnd: createSequence(["item_1_attack_0", "item_1_idle_0"], ["item_1_attack_0", "item_1_idle_0"]),
},
[EStalkerState.ANIMPOINT_SIT_KNEE_EAT_BREAD]: {
prop: {
maxidle: 3,
sumidle: 3,
Expand All @@ -365,7 +401,7 @@ export const animpointAnimations: LuaTable<TName, IAnimationDescriptor> = $fromO
idle: createSequence("item_2_aim_0", "item_2_aim_0"),
rnd: createSequence(["item_2_prepare_0", "item_2_attack_0"], ["item_2_prepare_0", "item_2_attack_0"]),
},
[EStalkerState.ANIMPOINT_SIT_ASS_EAT_KOLBASA]: {
[EStalkerState.ANIMPOINT_SIT_KNEE_EAT_KOLBASA]: {
prop: {
maxidle: 3,
sumidle: 3,
Expand Down Expand Up @@ -599,6 +635,42 @@ export const animpointAnimations: LuaTable<TName, IAnimationDescriptor> = $fromO
idle: createSequence("item_5_aim_0", "item_5_aim_0"),
rnd: createSequence(["item_5_prepare_0", "item_5_attack_0"], ["item_5_prepare_0", "item_5_attack_0"]),
},
[EStalkerState.ANIMPOINT_SIT_KNEE_DRINK_VODKA]: {
prop: {
maxidle: 3,
sumidle: 3,
rnd: 80,
moving: null,
},
into: createSequence(
["item_4_draw_0", { a: food.vodka }, "item_4_draw_1"],
["item_4_draw_0", { a: food.vodka }, "item_4_draw_1"]
),
out: createSequence(
["item_4_holster_0", { d: food.vodka }, "item_4_holster_1"],
["item_4_holster_0", { d: food.vodka }, "item_4_holster_1"]
),
idle: createSequence("item_4_aim_0", "item_4_aim_0"),
rnd: createSequence(["item_4_prepare_0", "item_4_attack_0"], ["item_4_prepare_0", "item_4_attack_0"]),
},
[EStalkerState.ANIMPOINT_SIT_KNEE_DRINK_ENERGY]: {
prop: {
maxidle: 3,
sumidle: 3,
rnd: 80,
moving: null,
},
into: createSequence(
["item_5_draw_0", { a: food.energy_drink }, "item_5_draw_1"],
["item_5_draw_0", { a: food.energy_drink }, "item_5_draw_1"]
),
out: createSequence(
["item_5_holster_0", { d: food.energy_drink }, "item_5_holster_1"],
["item_5_holster_0", { d: food.energy_drink }, "item_5_holster_1"]
),
idle: createSequence("item_5_aim_0", "item_5_aim_0"),
rnd: createSequence(["item_5_prepare_0", "item_5_attack_0"], ["item_5_prepare_0", "item_5_attack_0"]),
},
[EStalkerState.ANIMPOINT_STAY_WALL_GUITAR]: {
prop: {
maxidle: 5,
Expand Down Expand Up @@ -743,6 +815,42 @@ export const animpointAnimations: LuaTable<TName, IAnimationDescriptor> = $fromO
idle: createSequence("guitar_0", "guitar_0"),
rnd: null,
},
[EStalkerState.ANIMPOINT_SIT_KNEE_GUITAR]: {
prop: {
maxidle: 3,
sumidle: 3,
rnd: 80,
moving: null,
},
into: createSequence(
[
"sit_1_guitar_0_0",
{ a: misc.guitar_a },
{
f: (object: ClientObject) => {
startPlayingGuitar(object);
},
},
"sit_1_guitar_0_1",
],
[
"sit_1_guitar_0_0",
{ a: misc.guitar_a },
{
f: (object: ClientObject) => {
startPlayingGuitar(object);
},
},
"sit_1_guitar_0_1",
]
),
out: createSequence(
["guitar_0_sit_1_0", { d: misc.guitar_a }, "guitar_0_sit_1_1"],
["guitar_0_sit_1_0", { d: misc.guitar_a }, "guitar_0_sit_1_1"]
),
idle: createSequence("guitar_0", "guitar_0"),
rnd: null,
},
[EStalkerState.ANIMPOINT_STAY_WALL_HARMONICA]: {
prop: {
maxidle: 5,
Expand Down Expand Up @@ -887,4 +995,40 @@ export const animpointAnimations: LuaTable<TName, IAnimationDescriptor> = $fromO
idle: createSequence("harmonica_0", "harmonica_0"),
rnd: null,
},
[EStalkerState.ANIMPOINT_SIT_KNEE_HARMONICA]: {
prop: {
maxidle: 3,
sumidle: 3,
rnd: 80,
moving: null,
},
into: createSequence(
[
"sit_2_harmonica_1_0",
{ a: misc.harmonica_a },
{
f: (object: ClientObject) => {
startPlayingHarmonica(object);
},
},
"sit_2_harmonica_1_1",
],
[
"sit_2_harmonica_1_0",
{ a: misc.harmonica_a },
{
f: (object: ClientObject) => {
startPlayingHarmonica(object);
},
},
"sit_2_harmonica_1_1",
]
),
out: createSequence(
["harmonica_1_sit_2_0", { d: misc.harmonica_a }, "harmonica_1_sit_2_1"],
["harmonica_1_sit_2_0", { d: misc.harmonica_a }, "harmonica_1_sit_2_1"]
),
idle: createSequence("harmonica_0", "harmonica_0"),
rnd: null,
},
});
2 changes: 2 additions & 0 deletions src/engine/core/objects/animation/state_types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ import type {
*/
export enum EStateEvaluatorId {
END = 1,
// Whether state is locked and cannot be changed (weapon animation happening, turning body)
LOCKED = 2,
// Whether state is locked by alife/combat activity.
LOCKED_EXTERNAL = 3,

// -- WEAPON
Expand Down
24 changes: 12 additions & 12 deletions src/engine/core/objects/animation/states/animpoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,17 +184,17 @@ export const animpointStates: LuaTable<TName, IStateDescriptor> = $fromObject<TN
movement: move.stand,
mental: anim.free,
bodystate: move.standing,
animstate: EStalkerState.ANIMPOINT_SIT_ASS,
animation: EStalkerState.ANIMPOINT_SIT_ASS_EAT_BREAD,
animstate: EStalkerState.ANIMPOINT_SIT_KNEE,
animation: EStalkerState.ANIMPOINT_SIT_KNEE_EAT_BREAD,
direction: CSightParams.eSightTypeAnimationDirection,
},
[EStalkerState.ANIMPOINT_SIT_KNEE_EAT_KOLBASA]: {
weapon: EWeaponAnimation.STRAPPED,
movement: move.stand,
mental: anim.free,
bodystate: move.standing,
animstate: EStalkerState.ANIMPOINT_SIT_ASS,
animation: EStalkerState.ANIMPOINT_SIT_ASS_EAT_KOLBASA,
animstate: EStalkerState.ANIMPOINT_SIT_KNEE,
animation: EStalkerState.ANIMPOINT_SIT_KNEE_EAT_KOLBASA,
direction: CSightParams.eSightTypeAnimationDirection,
},
[EStalkerState.ANIMPOINT_STAY_WALL_DRINK_VODKA]: {
Expand Down Expand Up @@ -310,17 +310,17 @@ export const animpointStates: LuaTable<TName, IStateDescriptor> = $fromObject<TN
movement: move.stand,
mental: anim.free,
bodystate: move.standing,
animstate: EStalkerState.ANIMPOINT_SIT_ASS,
animation: EStalkerState.ANIMPOINT_SIT_ASS_DRINK_VODKA,
animstate: EStalkerState.ANIMPOINT_SIT_KNEE,
animation: EStalkerState.ANIMPOINT_SIT_KNEE_DRINK_VODKA,
direction: CSightParams.eSightTypeAnimationDirection,
},
[EStalkerState.ANIMPOINT_SIT_KNEE_DRINK_ENERGY]: {
weapon: EWeaponAnimation.STRAPPED,
movement: move.stand,
mental: anim.free,
bodystate: move.standing,
animstate: EStalkerState.ANIMPOINT_SIT_ASS,
animation: EStalkerState.ANIMPOINT_SIT_ASS_DRINK_ENERGY,
animstate: EStalkerState.ANIMPOINT_SIT_KNEE,
animation: EStalkerState.ANIMPOINT_SIT_KNEE_DRINK_ENERGY,
direction: CSightParams.eSightTypeAnimationDirection,
},
[EStalkerState.ANIMPOINT_STAY_WALL_GUITAR]: {
Expand Down Expand Up @@ -382,8 +382,8 @@ export const animpointStates: LuaTable<TName, IStateDescriptor> = $fromObject<TN
movement: move.stand,
mental: anim.free,
bodystate: move.standing,
animstate: EStalkerState.ANIMPOINT_SIT_ASS,
animation: EStalkerState.ANIMPOINT_SIT_ASS_GUITAR,
animstate: EStalkerState.ANIMPOINT_SIT_KNEE,
animation: EStalkerState.ANIMPOINT_SIT_KNEE_GUITAR,
direction: CSightParams.eSightTypeAnimationDirection,
},
[EStalkerState.ANIMPOINT_STAY_WALL_HARMONICA]: {
Expand Down Expand Up @@ -445,8 +445,8 @@ export const animpointStates: LuaTable<TName, IStateDescriptor> = $fromObject<TN
movement: move.stand,
mental: anim.free,
bodystate: move.standing,
animstate: EStalkerState.ANIMPOINT_SIT_ASS,
animation: EStalkerState.ANIMPOINT_SIT_ASS_HARMONICA,
animstate: EStalkerState.ANIMPOINT_SIT_KNEE,
animation: EStalkerState.ANIMPOINT_SIT_KNEE_HARMONICA,
direction: CSightParams.eSightTypeAnimationDirection,
},
[EStalkerState.ANIMPOINT_STAY_WALL_WEAPON]: {
Expand Down
54 changes: 27 additions & 27 deletions src/engine/core/objects/state/add_state_manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -590,34 +590,34 @@ function addBasicManagerGraph(stateManager: StalkerStateManager): void {
statePlanner.add_action(EStateActionId.BODYSTATE_STANDING_FREE, standingFreeAction);

// -- ANIMSTATES
const animationStateStartAction = new animationStateManagement.ActionAnimstateStart(stateManager);

animationStateStartAction.add_precondition(new world_property(EStateEvaluatorId.LOCKED, false));
animationStateStartAction.add_precondition(new world_property(EStateEvaluatorId.LOCKED_EXTERNAL, false));
animationStateStartAction.add_precondition(new world_property(EStateEvaluatorId.ANIMSTATE, false));
animationStateStartAction.add_precondition(new world_property(EStateEvaluatorId.SMARTCOVER, true));
animationStateStartAction.add_precondition(new world_property(EStateEvaluatorId.ANIMATION_NONE_NOW, true));
animationStateStartAction.add_precondition(new world_property(EStateEvaluatorId.DIRECTION, true));
animationStateStartAction.add_precondition(new world_property(EStateEvaluatorId.MENTAL, true));
animationStateStartAction.add_precondition(new world_property(EStateEvaluatorId.WEAPON, true));
animationStateStartAction.add_precondition(new world_property(EStateEvaluatorId.MOVEMENT, true));
animationStateStartAction.add_precondition(new world_property(EStateEvaluatorId.ANIMSTATE_PLAY_NOW, false));
animationStateStartAction.add_effect(new world_property(EStateEvaluatorId.ANIMSTATE, true));
statePlanner.add_action(EStateActionId.ANIMSTATE_START, animationStateStartAction);

const animationStateStopAction = new animationStateManagement.ActionAnimstateStop(stateManager);

animationStateStopAction.add_precondition(new world_property(EStateEvaluatorId.LOCKED, false));
animationStateStopAction.add_precondition(new world_property(EStateEvaluatorId.LOCKED_EXTERNAL, false));
animationStateStopAction.add_precondition(new world_property(EStateEvaluatorId.ANIMATION_LOCKED, false));
animationStateStopAction.add_precondition(new world_property(EStateEvaluatorId.ANIMSTATE_LOCKED, false));
const animstateStartAction = new animationStateManagement.ActionAnimstateStart(stateManager);

animstateStartAction.add_precondition(new world_property(EStateEvaluatorId.LOCKED, false));
animstateStartAction.add_precondition(new world_property(EStateEvaluatorId.LOCKED_EXTERNAL, false));
animstateStartAction.add_precondition(new world_property(EStateEvaluatorId.ANIMSTATE, false));
animstateStartAction.add_precondition(new world_property(EStateEvaluatorId.SMARTCOVER, true));
animstateStartAction.add_precondition(new world_property(EStateEvaluatorId.ANIMATION_NONE_NOW, true));
animstateStartAction.add_precondition(new world_property(EStateEvaluatorId.DIRECTION, true));
animstateStartAction.add_precondition(new world_property(EStateEvaluatorId.MENTAL, true));
animstateStartAction.add_precondition(new world_property(EStateEvaluatorId.WEAPON, true));
animstateStartAction.add_precondition(new world_property(EStateEvaluatorId.MOVEMENT, true));
animstateStartAction.add_precondition(new world_property(EStateEvaluatorId.ANIMSTATE_PLAY_NOW, false));
animstateStartAction.add_effect(new world_property(EStateEvaluatorId.ANIMSTATE, true));
statePlanner.add_action(EStateActionId.ANIMSTATE_START, animstateStartAction);

const animstateStopAction = new animationStateManagement.ActionAnimstateStop(stateManager);

animstateStopAction.add_precondition(new world_property(EStateEvaluatorId.LOCKED, false));
animstateStopAction.add_precondition(new world_property(EStateEvaluatorId.LOCKED_EXTERNAL, false));
animstateStopAction.add_precondition(new world_property(EStateEvaluatorId.ANIMATION_LOCKED, false));
animstateStopAction.add_precondition(new world_property(EStateEvaluatorId.ANIMSTATE_LOCKED, false));
// --action.add_precondition (new world_property(EStateManagerProperty.animstate, false))
animationStateStopAction.add_precondition(new world_property(EStateEvaluatorId.ANIMSTATE_IDLE_NOW, false));
animationStateStopAction.add_precondition(new world_property(EStateEvaluatorId.ANIMATION_PLAY_NOW, false));
animationStateStopAction.add_effect(new world_property(EStateEvaluatorId.ANIMSTATE, true));
animationStateStopAction.add_effect(new world_property(EStateEvaluatorId.ANIMSTATE_PLAY_NOW, false));
animationStateStopAction.add_effect(new world_property(EStateEvaluatorId.ANIMSTATE_IDLE_NOW, true));
statePlanner.add_action(EStateActionId.ANIMSTATE_STOP, animationStateStopAction);
animstateStopAction.add_precondition(new world_property(EStateEvaluatorId.ANIMSTATE_IDLE_NOW, false));
animstateStopAction.add_precondition(new world_property(EStateEvaluatorId.ANIMATION_PLAY_NOW, false));
animstateStopAction.add_effect(new world_property(EStateEvaluatorId.ANIMSTATE, true));
animstateStopAction.add_effect(new world_property(EStateEvaluatorId.ANIMSTATE_PLAY_NOW, false));
animstateStopAction.add_effect(new world_property(EStateEvaluatorId.ANIMSTATE_IDLE_NOW, true));
statePlanner.add_action(EStateActionId.ANIMSTATE_STOP, animstateStopAction);

// -- ANIMATION

Expand Down

0 comments on commit c2542ed

Please sign in to comment.