[Tutorial] [Basic Scripting] Architecture in Grim Dawn

Hi everyone,

This tutorial is for those who are new to scripting/modding, and is intended to explain the basic scripting architecture in Grim Dawn, so that you understand how scripts are connected together. You’ll need to understand this in order to create new quests and other type of events in Grim Dawn.

We’ll use the “Modding Tutorial” Mod, and you need to have setup your modding tools suite already (check https://forums.crateentertainment.com/t/script-basics-modding-beginners-guide-i/37525 if you haven’t done so already). In order to open/edit scripts, you can use many softwares but I’d recommend Notepad++, it’s simple/light and free.

Now that you’re set, let’s look at how Grim Dawn organizes scripts.

Open your asset manager, choose the modding tutorial mod.

Go the Sources tab, click Scripts, and you’ll see a main.lua script in the right window : the main script is the entry point of the architecture of scripts, this is where all begins and it is needed for any of your scripts to work.

Open the script, and you’ll notice that it has two lines that loads other scripts :

main

So now we see that our main script is loading the grimdawn.lua script. So let’s look at what it is.

Go to scripts\game\ and open grimdawn.lua

grimdawn

Here we see that the grimdawn.lua is loading a script too : quests.lua which is another script in the same folder. Open it.

Now we see that script is loading all the quests and quest related scripts. This is where the quest script’s adresses are, and every quest script that is here will be loaded to be used when needed.

Here we see that the mod will be loading the quests "killBossQuest"and “flavorEvent.lua”.

Questevents.lua and _MPQuestControl.lua are not quests per say, but they are needed as well for your quests to work properly (what these specifically do will be covered in a quest creation tutorial).

Now you can see that in scripts/game/, there is a folder named quests, which is where those two quest scripts are.

Click that folder in your Asset Manager and open killBossQuest.lua

Here you see the script that will be executed by this quest only.

So now, from the first main.lua script down to killBossQuest.lua, you can see how scripts are spread and connected together. That explains why If you create a quest and it’s script, you will then also need to update the quests.lua so that the quest script is loaded.

If you wish to learn how to create a quest from beginning to end, there is a tutorial here : https://forums.crateentertainment.com/t/tutorial-basic-scripting-how-to-create-a-quest/103239/3

2 Likes

Thanks for the information. One issue I found is that creatures will not attack the player if the level disparity is to high. I’m using static levels where the player may be intended to fight things far below their level. I saw some of this in quest coding, but couldn’t find it elsewhere. I am assuming this is a simple line of code designating the aggro cap.

That’s not really related to this tutorial per say, maybe post in the discord or dm me for more specific questions.

I have not ran into this issue since I use proxies or define the mob level depending on the charLevel (could be a solution for you if you want the mobs to keep being underleveled but not static).

There is also a variable called monsterLevelGapFixer in gameenegine.dbr I haven’t checked what it does, but maybe that’s related to your issue.

I believe the LevelGapFixer is in relation to controlling how much gap there is between the player and mobs. So you could spawn creatures 10 levels above you for example.

I don’t know, but I can spawn creatures with 50+ levels without touching this variable. So I’m not sure what it does, but it does not lock the level of the ennemies.

Also please keep your post’s subject in relation to the orginal post.If you want to discuss your issue, you can pm me, but this thread if for how scripts unfold in Grim Dawn, not to discuss some variables specifically.

I haven’t experienced issues yet because I’m only about level 26 in play testing. However, when I use test characters at level 1,000+ all the current mobs stop attacking. So I’m not sure exactly where the breaking point is.

I saw code in the tutorial that had a specific level and aggro range. I’ll see if I can dig up the exact code. It showed a level cap for each difficulty. I think the code I saw was only applicable to the quest spawn though.