githubEdit

Abusing workspots

Or how to play an animation on an entity through clever gimmicks in Redscript.

Credits

First of all, let's give credits to people out there:

How to ?

It started from a talk with @Eli and @donk7413 the authors of Cyberscriptarrow-up-right and Smoke Everywherearrow-up-right mods.

When asked details about how they managed to have V smokes a cigarette anywhere in-game, they mentioned having merged all .workspot files in a gigantic file for convenience (namely Cyberscript Core Animation Archivearrow-up-right), so that Cyberscript can play any animation in-game on V or any NPC.

At first it didn't ring a bell, but then @psiberx mentioned about modders "abusing" .workspot by spawning an invisible .ent to have the target being animated.

🤔 ...

The trick is actually to spawn an invisible device (.ent) right onto your entity, which then allows to trigger animation(s).

WolvenKit

So it happens that we need a .ent file whose components contains a workWorkspotResourceComponent which references a .workspot by name and DepotPath.

In turn, .workspot file contains a list of worksSequences containing workAnimClips which are the animations to play with idleName and animName.

Of course the .ent must be made invisible and contain a set of specific properties, and this is where all hard work was already made by Cyberscript people.

💡arrow-up-right Generally speaking if you need to play a ton of animations I would recommend you to use Cyberscript directly, since it already does everything for you and also comes up with a ton of useful more features to build a mod with ease.

On the other hand, if like me you only want to play 1 or 2 animations at most, then it's probably a lot of overhead and you can keep reading.

What I personally did was to reuse Cyberscript archive .ent stripped of components that I don't need, and .workspot with only the animations that I'm interested into.

Redscript

Once archive is ready, we need something able to spawn an entity in Redscript (once again if your preference goes to Lua, I'd recommend you to use Cyberscript directly).

This is exactly what Codewarearrow-up-right offers with DynamicEntitySystem: see "Entities" in its wikiarrow-up-right!

Here's a short example which will get us going:

Clearing misconceptions

Actually the ones I personally had before:

  • .ent can be anything, not just a "living entity". it can be a cigarette, the act of smoking.. it can really be "whatever".

    • it contains components with e.g. workspotMapper, entSlot, etc

    • it also contains obviously a workWorkspotResourceComponent with points out to the .workspot.

  • .workspot gets triggered throughout .ent: you don't spawn a workspot and play it on a target, you spawn an entity which references the workspot and plays the workspot through the entity (which in turn play the animation(s), and you can "jump" from one animation to another in the same workspot).

Last updated