Kingdom Come: Deliverance – Scripting Tutorial 1: First Script

Kingdom Come: Deliverance – Scripting Tutorial 1: First Script


Hello and welcome to the scripting
tutorial for Kingdom Come: Deliverance. This tutorial requires that you have
already properly setup your local database and that you have installed all
the necessary tools. For the first exercise you will only need the CryEngine
sandbox editor, but later you will also need Skald, Storm and Swift. The Sandbox editor executable is found under Steam, KingdomComeDeliverance>bin>win64releasedll. You also have to create this user.cfg file and fill it with these parameters, with proper values of course. Now let’s launch the editor. The editor
will take about 20 to maybe 60 seconds to launch depending on the power of your
computer. We sped this process up for obvious reasons. Now this is the Welcome window for the
sandbox editor. Ideally you should use a 2 or even 3 monitor setup but in this
video I can only use one screen. If you do however possess multiple monitors, I
will show you how to take advantage of it. Normally you would maximize the main window and then you could use the other tools,
like these two, combine them and move them to the
other screen. I will try to squeeze as much
information into this one screen as possible. For this purpose I will also set this
specific cvar to value 1 and I will also copy this value into the user CFG
file, so that for every subsequent start up I don’t have to set it up again. What this cvar does is very simple. When
you move the tools window just a bit, it will force the refresh and they will
start behaving like a normal window. They will not overlap with the main
window and you can minimize them, maximize them at your will. Let’s start
the actual exercise. We want to create a new level – let’s give it a name. This level will be stored under the
levels folder; you can find it under data>levels. We certainly want to use the
terrain and we want the level to be small. Now, as you can see, a new folder with the name of the level was created under the levels folder. The level creation takes
several seconds and now we will be asked about the quality of the terrain. We
don’t need anything fancy. An error window might appear but you can close it. You can look around when you are holding down the right mouse button.
You can also use the wsad keys and scrolling to control the camera. Move up a bit and you will see the flat
terrain. Now using Ctrl+G should start the game-mode. However this doesn’t work in a newly created level – to get rid of this
error, you only need to save the level and
reload it again. And now when I press Ctrl+G, I’m in the
game. When I press Shift+Esc, the game-mode
ends. So the goal of this exercise is to have
an NPC, create a new brain for it and make it play a simple animation. So first we need the NPC – you can find it
under RollupBar>Entity>AI>NPC. The NPC is a male NPC – the other option is NPC_Female. They are different because they have different skeletons. Just drag and
drop it. As you can see, it is now snapping to a sort of a grid. You can
change the setting here and now we have very fine control over the entity’s
placement. One more detail – if we happen to have an
object somewhere in the air and want to place it back to the ground, we can do
this by holding down Ctrl+Shift and clicking left mouse button. Next we want to create a new sublayer
called ’npc’. Now we want to save the level. Move the
NPC to its new sublayer and save the level again. You may have noticed in this process
that there are these asterisks appearing and disappearing. They indicate any
unsaved change. Now I want to rename the NPC entity. As per the instructions, his
name should be test_ST_npc1. Now as you can see, the
asterisk reappeared. You can also see it here, so maybe we should save the level again. Now we have the entity named and we have
to give it a soul so under View>Open View Pane, you have all these tools and
what you need is Warhorse (WH) NPC Editor. there you go to the Properties tab and
you must have the NPC selected. Here, as you can see, you can connect the man to
an existing soul which will make him behave and appear as any predefined male NPC. But we want to create a new soul. Soul data is stored in the database but
pressing this button will not save the data immediately – it will only prepare
the operation. This is indicated by missing shared soul name here. So to
actually commit the data to the database, you have to either save the level or any
layer of the level. Let’s do just that. Now, if I reselect the
NPC, you can see the soul name finally appeared here, which confirms that the
data was finally saved into the database. So this soul is now using the npc_test_base brain, which is just a default brain which does nothing basically, but
we don’t want to change the definition of this brain, as it would affect any
newly created NPC. We want to create a new brain. For this we need another tool.
It’s called WH XGEN NPC Editor. It’s the other window I already had
opened here. Let me just adjust the sizes of these various sub windows. Now we want to create a new brain, so
go to the brain tab and click “Create new” button and give the brain a name. Let’s give it
the same name as of the NPC entity. Now the brain is created. Now a brain doesn’t actually do anything –
it’s just a data structure, a handle of sorts.
What can hold any actual executable script is subbrain, so let’s give our
brain a new subbrain. Just click this “New” button here and let’s fill in all
these properties. For the name of the subbrain we will use the same and just add
“_main” suffix. NPC brains need type BehaviorTree and we want to
specify an XML file which will hold the actual implementation of the subbrain
tree. We want to create a new subfolder “_test” and then specify the
name of the XML file and let’s give it the same name. This subfolder will be created in the
AI root folder, which can be found here. For the operation we are doing right now
to work, you also need to pay attention to this default .xml file. You can find it
under Data_reference folder in the modding package. You need to have
it copied here in the AI root folder. The BehaviorTree type only supports onUpdate tree, so let’s have it checked, and we also want it to be “Always active”
as opposed to activated on demand . “Always active” will just run all the time. Now
that we have the brain and its subbrain defined, let’s click the Save
brain here, which will save it to the database and it will also create the XML
file we specified. As you can see here the new subfolder
and the XML five we specified have been successfully created. When I reselect
the NPC, you can notice that he still has the old brain and subbrain. That’s
because we haven’t changed the brain that is to be used by the soul so we
need to give him the new brain. We have to re-save the level to update the soul settings. Now we have to reload the AI script and when I reselect the NPC again
we should finally see the new subbrain. Now we can finally start scripting this
guy’s behavior. When you are in the Tree Editor, you can press spacebar, which will
start this search function. You can write in any filter tokens and the search
function will give you a list of nodes that fit the filter criteria. You can
navigate through the list with arrows. We want a node called PlayAnimation. It is the first search result, so let’s
just press ENTER and then connect the node here. The NPC can now play an
animation but it doesn’t know which one specifically. Let’s find the animation in
the Mannequin Editor. To see all the male skeleton animations,
you have to load the malepreview file. There are a lot of animations, so loading
will take its time. You may also see some errors but you can ignore them. Now we
may not know exactly which animation we are looking for, so let’s do some
searching. We want the NPC to wave his hand, so let’s use the word wave and
let’s try it in the fragmentID filter. Well, we failed, we got no results. Let’s try the same for the tag filter. Now we’re
getting something. Now we can see that the animation
fragment is actually called GreetingsUpperBody and that the full tag name is waveSmall. You can preview the animation by
clicking it twice and pressing this play button. The fragmentID name goes into the
animation property and that tag name goes into the tags
property. The editor might crash when you try to
enter the game-mode with the Mannequin tool open, so let’s close it. Let’s now jump
in the game and see what he does. And here we see the first problem – the
animation is being played over and over again, because as the PlayAnimation node succeeds, the whole tree restarts itself, which is its inherent property. We want
the animation to be played just once, so let’s exit the game-mode with Shift+Esc and see what we can do. So we want the PlayAnimation to be followed by
a Wait node with time set to -1, which means infinity. In order to execute these
nodes one after another, we need a sequence node. A sequence node simply executes its child trees – or child nodes in this case –
in sequential manner. So let’s resave the tree using either
this save function or, when you are in the Tree Editor, you can simply use
Ctrl+S. Let’s jump back in the game-mode and see what happens. And he does
exactly what we needed him to do. Congratulations, you’ve just finished
Exercise 1! See you next time!

69 thoughts on “Kingdom Come: Deliverance – Scripting Tutorial 1: First Script

  1. I READY TO MAKE EVIL DEAD CASTLE FROM MOVIE EVIL DEAD 3, AND UNIQUE MEDIEVILS WEAPONS AND STAFF! 🙂 AND FOR SHURE HUGE SECRETS AND MONSTERS AND QUESTS!

  2. I really love when developers support mods openly. it's explains they are really serious about their game instead of badshit greed….. Warhorse and CDPR are my all time favorite developers

  3. So with this amount of support I might try to learn how to mod.

    However I would try only to enrich the original. Some new quests and people. Make Samopesh matter. It would be nice if I can set it before the Skalitz raid. Would be interesting (and challenging) to make chain of quests leading to rebuild Skalitz though…

    I would probably make the smaller merchants a travelling ones (so you could meet them on roads). Some more hunting, gambling, drinking with Sir Capon, etc…

  4. It's almost like Bethesda when it comes to the original Skyrim or Fallout 3/New Vegas.
    Finally a company that puts in work, shows how good they are as a studio and rounds it off by helping their community and they want to see it thrive.

    Thank you!

  5. This style looks familiar like a similar system to what I learned in instrumentation for engineering or kinda like the lego mindstorm but far more complex though more accessible. Thomas the train engine incoming. Hope you make one about setting up combat situations, stores/merchants and conversation/questing please

  6. Has anyone figured out how to load existing brains/sub-brains to examine/edit them? I can open "player" and "DefaultBrain" but no others.

  7. This is fantastic. Seeing how serious you guys are about modding makes me want to try to learn how to do it myself. Hopefully there are a bunch of these videos, because I'd love to learn.

  8. good day warhors studio, I finished voting games there is a little way to tamp and I had a crazy love for cuman, and I intended to reproduce a replica not identical, but inspired by your model and I wanted to know if you could tell me about their caftan pieces more than complicated to esailler to reproduce on everything for the model of the silk sainture and the reasons to be directly on the caftan, thank you for your patience to read this comment if it is read and sorry for spelling errors but I practice the English of then 1 year thank you to a Belgian proud of your work thank you😊👌👍

  9. Add FUCKING CHEAT CODES FOR FUCKING CONSOLES BECAUSE WERE DONT GET ANYTHING WE CANT GET MODS ITS SIMPLE AND IF YOU DO DO IT ADD MONEY AND INVINCIBILITY BECAUSE ITS UNFAIR FOR PEOPLE WHO CANT AFFORD A GOOD COMPUTER TO RUN THIS GAME DON'T BE LIKE BETHESDA

  10. I think, what they are trying to achieve with mods, apart from making game last longer for their community, is to find some fun and interesting features that mods might throw into their game, which WHS can implement with their own adaptation and they will see popularity of these mods amongst players.

  11. I want a retinue system. There's nearly no chance I'll ever have the motivation to make it, but it would be dope to be able to recruit, equip, and train a few followers. Buy them mounts, run down enemies in a cavalry wedge with your spears… oh, the dream.

Leave a Reply

Your email address will not be published. Required fields are marked *