Mods / FSM lib

Category: #Library
Author: Maltiez
Side: Both
Created: Oct 8th 2023 at 9:35 AM
Last modified: 5 days ago
Downloads: 28336
Follow Unfollow 211

Latest file for v1.19.4:
fsmlib_0.4.5.zip 1-click install


Requires: Animation Manager

For other modders: would be nice to collaborate on combat related mod. Would be nice to have somebody to test features, to animate player and items, may be even to write some code, or just do research part. 

Description:

Finite State Machine (FSM) implemented as CollectibleBehavior and used for creating complex item behaviour that player can interact with by hotkeys, keyboard and mouse keys (environmental inptus are planned as well).

This library provides .json API and can be used for content mods (no C# coding required). But it can also be easily extended with C# code mods without need in any patches by using its C# API. Documentation for both APIs are not ready and will come soon.

You can ask question and leave you suggestion on VS discord server under the mod's post in mods channel.

Examples from tutorials (or for future tutorials): FSM example (no more)

Features:

A short list of what you can do with the library. All the functionality is added by behavior, so it is not depended on class.

Behavior can:

  • play specific sounds with configurable volume and range
  • play player animations like "bowaim"
  • play transformation animations, where item can be progressively smoothly rotated, moved or scaled
  • play variants animation, where a range of variants is used as frames like in stop motion animation
  • perform melee attack using item's stats and with configurable animation
  • perform range attack where projectile can be taken from players inventory
  • store items and block in item (using its attributes), and provide them to other systems (like shooting one)
  • use durability of items in players inventory or just checking if there are required items
  • change items variant group like this from torch: "variantgroups": [{"code": "state", "states": ["unlit", "lit", "extinct"]}]
  • prevent swaying animation and let player point items to where camera is pointing to
  • change player stats
  • spawn particle effects
  • damage item or restore durability
  • do basic aiming providing accuracy values for shooting system that depend on how long player is aiming
  • give player specified item or block

All this can be triggered by:

  • hotkey press
  • key press or release
  • mouse key press or release
  • player attempting to change slot or drop item
  • player being underwater

Currently all this applies only to items in:

  • active hotbar slot
  • offhand slot
  • hotbar and inventory slots

Additional:

  • generation of control hints
  • generation of description entries
  • unification of hotkeys
  • hotkeys for not hotkey key events

All this funtionality will be expanded over time. If you need anything specific you can suggest it here and it will be implemented (sooner than later, but there can be some irl stuff preventing me from implementing features fast, like in hours and days).

And also: all this is just a interaction part. The huge part of the library is actual fullfledged FSM, that can allow you to configure complicated behaviors.

Required for:

Version For Game version Downloads Release date Changelog Download 1-click mod install*
v0.4.5 723 5 days ago Show fsmlib_0.4.5.zip Install now
v0.4.4 1526 Apr 9th at 6:19 AM Show fsmlib_0.4.4.zip Install now
v0.4.3 186 Apr 8th at 7:54 PM Show fsmlib_0.4.3.zip Install now
v0.4.2 556 Apr 6th at 10:04 AM Show fsmlib_0.4.2.zip Install now
v0.4.1 1196 Apr 1st at 7:32 AM Show fsmlib_0.4.1.zip Install now
v0.4.0 448 Mar 30th at 5:55 PM Show fsmlib_0.4.0.zip Install now
v0.4.0-dev.1 854 Mar 24th at 10:09 AM Show fsmlib_0.4.0-dev.1.zip Install now
v0.3.1 907 Mar 18th at 6:00 AM Show fsmlib_0.3.1.zip Install now
v0.3.0 1409 Mar 6th at 8:22 AM Show fsmlib_0.3.0.zip Install now
v0.2.15 1574 Feb 27th at 6:27 AM Show fsmlib_0.2.15.zip Install now
v0.2.14 331 Feb 24th at 1:47 AM Show fsmlib_0.2.14.zip Install now
v0.2.13 51 Feb 23rd at 11:50 PM Show fsmlib_0.2.13.zip Install now
v0.2.12 597 Feb 23rd at 5:28 AM Show fsmlib_0.2.12.zip Install now
v0.2.11 378 Feb 19th at 11:55 AM Show fsmlib_0.2.11.zip Install now
v0.2.10 165 Feb 18th at 3:28 PM Show fsmlib_0.2.10.zip Install now
v0.2.9 1636 Feb 13th at 1:18 PM Show fsmlib_0.2.9.zip Install now
v0.2.8 665 Feb 10th at 7:45 PM Show fsmlib_0.2.8.zip Install now
v0.2.7 707 Feb 5th at 2:26 PM Show fsmlib_0.2.7.zip Install now
v0.2.6 74 Feb 5th at 8:52 AM Show fsmlib_0.2.6.zip Install now
v0.2.5 110 Feb 4th at 10:28 PM Show fsmlib_0.2.5.zip Install now
v0.2.3 244 Feb 4th at 12:26 PM Show fsmlib_0.2.3.zip Install now
v0.2.2-pre.5 203 Feb 4th at 9:00 AM Show fsmlib_0.2.2-pre.5.zip Install now
v0.2.2-pre.4 234 Feb 3rd at 7:24 AM Show fsmlib_0.2.2-pre.4.zip Install now
v0.2.2-pre.3 539 Jan 30th at 10:54 AM Show fsmlib_0.2.2-pre.3.zip Install now
v0.2.2-pre.2 343 Jan 28th at 12:37 PM Show fsmlib_0.2.2-pre.2.zip Install now
v0.2.2-pre.1 581 Jan 24th at 2:14 PM Show fsmlib_0.2.2-pre.1.zip Install now
v0.2.0 713 Jan 11th at 10:15 AM Show fsmlib_0.2.0.zip Install now
v0.1.13 2915 Dec 13th 2023 at 1:19 AM Show fsmlib_0.1.13.zip Install now
v0.1.12 91 Dec 13th 2023 at 1:03 AM Show fsmlib_0.1.12.zip Install now
v0.1.11 413 Dec 12th 2023 at 4:37 AM Show fsmlib_0.1.11.zip Install now
v0.1.10 3711 Nov 1st 2023 at 4:03 AM Show fsmlib_0.1.10.zip Install now
v0.1.9 510 Oct 29th 2023 at 4:53 AM Show fsmlib_0.1.9.zip Install now
v0.1.8 881 Oct 23rd 2023 at 9:29 PM Show fsmlib_0.1.8.zip Install now
v0.1.7 218 Oct 23rd 2023 at 4:51 AM Show fsmlib_0.1.7.zip Install now
v0.1.6 495 Oct 20th 2023 at 6:25 PM Show fsmlib_0.1.6.zip Install now
v0.1.5 382 Oct 18th 2023 at 7:39 AM Show fsmlib_0.1.5.zip Install now
v0.1.4 393 Oct 15th 2023 at 4:16 PM Show fsmlib_0.1.4.zip Install now
v0.1.3 462 Oct 12th 2023 at 8:10 PM Show fsmlib_0.1.3.zip Install now
v0.1.2 325 Oct 10th 2023 at 10:32 PM Show fsmlib_0.1.2.zip Install now
v0.1.1 146 Oct 10th 2023 at 4:44 PM Show fsmlib_0.1.1.zip Install now
v0.1.0 404 Oct 8th 2023 at 9:37 AM Show fsmlib_0.1.0.zip Install now

10 Comments (oldest first | newest first)

💬 MaltiezAuthor, Apr 2nd at 7:16 AM

LarekFlynn

Please send logs (client-main), better in official VS discord server

This error is caused by some other mod that modifies vanilla methods related to slots and does a bad job at it. For me to be able to fix it I need to know what mod causes it (you need to figure it out, by turning mods off and testing, or something), and also I need logs. Moddb is a bad place for all this stuff, so you will need to get to official VS discord server.

💬 LarekFlynn, Apr 2nd at 1:54 AM

Game kept going but my arms were stuck in crossbow animation even after switching to other items and it wouldnt fire or reload the empty looking crossbow.

1.4.2024 20:36:47.671 [VerboseDebug] [FSMlib] [Delayed] System 'ammo-bolt' crashed while processing in 'load' operation in 'maltiezcrossbows:crossbow-stirrup-plain' collectible.

Request:{
"code": "ammo-bolt",
"action": "take",
"requirement": "bolt"
}

Exception:
System.ArgumentException: Supplied slot is not part of this inventory (backpack-4LCXe0iZRXZimAMofvGIBNxg)!
at Vintagestory.API.Common.InventoryBase.DidModifyItemSlot(ItemSlot slot, ItemStack extractedStack) in C:\Users\Tyron\Documents\vintagestory\game\VintagestoryApi\Common\Inventory\InventoryBase.cs:line 480
at Vintagestory.API.Common.ItemSlot.OnItemSlotModified_Patch2(ItemSlot this, ItemStack sinkStack)
at Vintagestory.API.Common.ItemSlot.TryPutInto_Patch1(ItemSlot this, ItemSlot sinkSlot, ItemStackMoveOperation& op)
at Vintagestory.API.Common.ItemSlot.TryPutInto(IWorldAccessor world, ItemSlot sinkSlot, Int32 quantity) in C:\Users\Tyron\Documents\vintagestory\game\VintagestoryApi\Common\Inventory\ItemSlot.cs:line 176
at MaltiezFSM.Systems.AmmoSelector.Process(IPlayer player) in D:\Projects\VintageStory\fsmlib\fsmlib\source\Systems\Common\ToolMode.cs:line 114
at MaltiezFSM.Systems.Requirements.Take(ItemSlot slot, IPlayer player, List`1 requirements) in D:\Projects\VintageStory\fsmlib\fsmlib\source\Systems\Requirements.cs:line 309
at MaltiezFSM.Systems.Requirements.Process(ItemSlot slot, IPlayer player, JsonObject parameters) in D:\Projects\VintageStory\fsmlib\fsmlib\source\Systems\Requirements.cs:line 138
at MaltiezFSM.Operations.BaseOperation.Process(ItemSlot slot, IPlayer player, IEnumerable`1 systems) in D:\Projects\VintageStory\fsmlib\fsmlib\source\Operations\BaseOperation.cs:line 84

💬 MaltiezAuthor, Jan 16th at 2:20 PM

Yamato200

Check if you have installed versions of the mods for your version of the game, and there are no later versions installed

💬 MaltiezAuthor, Jan 16th at 2:19 PM
💬 Yamato200, Jan 16th at 9:45 AM

This and the required animation manager both don't work for me somehow. The Mod manager says "unable to resolve some mod dependencies. please check log files. I don't even know where these logs are.

💬 MaltiezAuthor, Dec 28th 2023 at 6:50 PM

EduardoPupucon

Because you play an unreleased version of the game meant for testing and many mods (including this one) is not updated to it.

💬 EduardoPupucon, Dec 28th 2023 at 6:35 PM

every time i press right mouse button to reload my arquebus i get a crash and this error:
i have all of the dependencies and firearms

[code]
28/12/2023 15:21:15: Critical error occurred in the following mod: fsmlib@0.1.13
Loaded Mods: butchering@1.1.0, Swordz@1.1.3, game@1.19.0-rc.4, animationmanagerlib@0.3.0, liquidcontainers@1.2.0, creative@1.19.0-rc.4, survival@1.19.0-rc.4, em@2.5.0-pre.1, fsmlib@0.1.13, maltiezfirearms@0.3.9, tailorsdelight@1.2.1
System.MissingFieldException: Field not found: 'Vintagestory.API.Common.Entities.Entity.AnimManager'.
at MaltiezFSM.Systems.NoSway.SetAimAnimationCrutch(Boolean interact)
at MaltiezFSM.Systems.ActionCallbackTimer.Start() in D:\Projects\Firearms\fsmlib\fsmlib\src\Systems\Other\NoSwaySystem.cs:line 74
at MaltiezFSM.Systems.NoSway.Process(ItemSlot slot, EntityAgent player, JsonObject parameters) in D:\Projects\Firearms\fsmlib\fsmlib\src\Systems\Other\NoSwaySystem.cs:line 31
at MaltiezFSM.Operations.Delayed.MaltiezFSM.API.IOperation.Perform(ItemSlot slot, EntityAgent player, IState state, IInput input) in D:\Projects\Firearms\fsmlib\fsmlib\src\Operations\DelayedOperation.cs:line 292
at MaltiezFSM.Framework.FiniteStateMachine.RunOperation(ItemSlot slot, EntityAgent player, IOperation operation, IInput input, State state) in D:\Projects\Firearms\fsmlib\fsmlib\src\Framework\FiniteStateMachine.cs:line 214
at MaltiezFSM.Framework.FiniteStateMachine.Process(ItemSlot slot, EntityAgent player, IInput input) in D:\Projects\Firearms\fsmlib\fsmlib\src\Framework\FiniteStateMachine.cs:line 155
[/code]

💬 beagan, Oct 22nd 2023 at 12:22 PM

thank you for the reply, sorry i should've noticed that haha

💬 MaltiezAuthor, Oct 22nd 2023 at 2:23 AM

beagan

this works for 1.18.8+, last update was a day ago, as you can see

💬 beagan, Oct 22nd 2023 at 2:18 AM

does this need to be updated or does it work in .15

(edit comment delete)