Difference between revisions of "Crime System"
(Created page with "<div class="noautonum">__TOC__</div> '''INTRODUCTION''' This guide explains how to use the Crime System of DOS2 in your mods. We will add several NPCs, a guard and a working...") |
m (BADCIVILIAN -> BADASSCIVILIAN) |
||
(One intermediate revision by one other user not shown) | |||
Line 21: | Line 21: | ||
Meet Otto, an ordinary trader who sells health potions (from small to giant). | Meet Otto, an ordinary trader who sells health potions (from small to giant). | ||
− | + | [[File:OrdinaryTrader.png|none|Prison]] | |
To add Otto: | To add Otto: | ||
*Add a new NPC. | *Add a new NPC. | ||
Line 40: | Line 40: | ||
*Add a new NPC. | *Add a new NPC. | ||
*Add a script to him : Crime_HumanReactions. | *Add a script to him : Crime_HumanReactions. | ||
− | *Add a tag to the NPC: | + | *Add a tag to the NPC: BADASSCIVILIAN. // This is the only difference with Otto. |
*Set Alignment to "Neutral NPC". | *Set Alignment to "Neutral NPC". | ||
Line 72: | Line 72: | ||
Gustav is quite happy with his new job. There is only one problem - since there is no prison, he is forced to kill every criminal. That's not how they were taught in Academy! So, Gustav decides to build a prison. | Gustav is quite happy with his new job. There is only one problem - since there is no prison, he is forced to kill every criminal. That's not how they were taught in Academy! So, Gustav decides to build a prison. | ||
− | + | [[File:Prison.png|none|Prison]] | |
To add prison: | To add prison: | ||
*Build a prison cell. | *Build a prison cell. |
Latest revision as of 20:19, 13 June 2018
INTRODUCTION
This guide explains how to use the Crime System of DOS2 in your mods. We will add several NPCs, a guard and a working prison.
If you are not familiar with Divinity Engine read this tutorial first: https://docs.larian.game/How_to_create_a_basic_adventure_with_quests,_dialog_and_scripts, because it explains important things like creating levels, adding NPCs etc.
INITIAL SETUP
- Create a new project. Let's call it "Crime System Test".
- Create a new level from the Basic template. Let's call it "Main".
- Add Crime Region Trigger and Crime Area Trigger to your level. They should encompass the whole level.
- Set "Owner ID" in Crime Region Trigger to "CST".
SCENARIOS
1. Ordinary NPCs
Scenario - we need an ordinary trader who will forgive the player's first two attempts to commit a crime (taking his stuff, assaulting him), but who will become hostile after the third attempt. Basically, most of the traders in DOS2 are acting this way.
Meet Otto, an ordinary trader who sells health potions (from small to giant).
To add Otto:
- Add a new NPC.
- Add a new tag to the NPC: CIVILIAN
- Add a new script to the NPC : Crime_HumanReactions. //the Crime System relies on this script.
- Set his "Alignment" to "Neutral NPC".
- Add several health potions and set Owner ID for each of them. Now the Owner will prevent you from picking up his stuff.*
Now you can test this setup. Otto will forgive your first two attempts to pick up one of his potions from the ground, but he will attack you after the third attempt. The same with stealing from his pockets or attacking him.
2. Agressive NPCs
Scenario - we need a badass trader who will attack the player after the very first attempt to commit a crime (taking his stuff, assaulting him). Let's add another trader, Bart. He just came to this area. He solds poison and all sorts of daggers. Shady person, agree. He placed some of his goods on the ground. He also have a free poison sample - a big bottle with poison. You can take it without any repercussions, but don't try to pick up anything else!
To add Bart:
- Add a new NPC.
- Add a script to him : Crime_HumanReactions.
- Add a tag to the NPC: BADASSCIVILIAN. // This is the only difference with Otto.
- Set Alignment to "Neutral NPC".
This time we will solve the ownership problem differently:
- Add several items (poison potions and daggers in our case).
- Add a new Box Trigger. It should contain all Bart's items. Let's name it "S_CST_Ownership_BadassTrader". We use this instead of setting "Owner ID" for each item individually.
- Add a new story - CST_TriggerRegistration. Copy this code into the story:
DB_ItemOwnerShipTriggers("Main",TRIGGERGUID_S_CST_Ownership_BadassTrader_45c206a6-713f-44c6-a60c-4b5dc2d93bef,CHARACTERGUID_S_CST_BadassTrader_fdeda12a-cbb8-4ca6-a53b-b7aeb82d700c); DB_ItemOwnerShipClearItem("Main",ITEMGUID_S_RE_PoisonPotion_Sample_821a5d30-78b1-48b9-b2dc-2810c3ef0236);
By using this code we set Bart as Owner for each item except the sample bottle. This is more convinient than setting Owner ID for each item separately.
3. Guards
Scenario - we want guards in our mod. Ordinary citizens shouldn't fight with the player. Instead, they should call for a guard and then run away. Let's return to Otto. Otto doesn't like Bart. Not only Bart himself is very suspicious, but most of his clients are also quite shady. This whole situation is quite stressful for Otto, so he decides to hire a guard, a fellow named Gustav.
To add Gustav:
- Add a new NPC.
- Add a script to him : Crime_HumanReactions. //Crime System won't work without this script.
- Add a tag to the NPC: GUARD. // Again, the only difference with Otto and Bart
- Set Alignment to "Neutral NPC".
Now you can attack Otto or steal from him and he will call Gustav instead of attacking you.
4. Prison
Scenario - we want to have a prison where guards can send players.
Gustav is quite happy with his new job. There is only one problem - since there is no prison, he is forced to kill every criminal. That's not how they were taught in Academy! So, Gustav decides to build a prison.
To add prison:
- Build a prison cell.
- Place BoxTrigger inside the cell. Let's call it S_CST_Prison_PlayerCell.
- Create a door - S_CST_Prison_PlayerCell_Door.
- Place a point trigger in front of the door - S_CST_Prison_PlayerCell_Door_Trigger.
- Add two chests and call them S_CST_Prison_PlayerEquipmentChest and S_CST_Prison_EvidenceChest.
- Add a new story - CST_CrimeAdjustments.
- Add this code in INIT section.
DB_RegionPrison("Main_CST",(TRIGGERGUID)TRIGGERGUID_S_CST_Prison_PlayerCell_c54dff13-9d9e-428b-983a-95f3def1aad4); DB_PlayerPrison((TRIGGERGUID)TRIGGERGUID_S_CST_Prison_PlayerCell_c54dff13-9d9e-428b-983a-95f3def1aad4,(TRIGGERGUID)TRIGGERGUID_S_CST_Prison_PlayerCell_Door_Trigger_300fbf9f-4ba1-48fb-b431-eaeb461bb06a,"EscapedCSTPrison",""); DB_PlayerPrison_Door((TRIGGERGUID)TRIGGERGUID_S_CST_Prison_PlayerCell_c54dff13-9d9e-428b-983a-95f3def1aad4,(ITEMGUID)ITEMGUID_S_CST_Prison_PlayerCell_Door_0cb944b9-7061-4fa2-8f7b-8a4cde9e9366,"CST_PrisonCells_Key"); DB_PrisonChest((TRIGGERGUID)TRIGGERGUID_S_CST_Prison_PlayerCell_c54dff13-9d9e-428b-983a-95f3def1aad4,(ITEMGUID)ITEMGUID_S_CST_Prison_PlayerEquipmentChest_2371acb1-dadb-4ff0-a5dc-2945ef0c5029); DB_PrisonEvidenceChest((TRIGGERGUID)TRIGGERGUID_S_CST_Prison_PlayerCell_c54dff13-9d9e-428b-983a-95f3def1aad4,(ITEMGUID)ITEMGUID_S_CST_Prison_EvidenceChest_44e1ebe1-b5d7-4ef8-bb75-5ef895bfae44);
We can now test it:
- steal something from Otto;
- wait near him;
- he starts a dialog - refuse to give his items back;
- he calls a guard and the guard stats a dialog with you;
- agree to go to prison;
- your character will be teleported into a prison cell and his stuff will be stored in a chest.
5. Choosing alignment
There is a little problem with default alignments. Neutral NPCs react to crimes, but run from Evil NPCs. Good NPCs attack Evil NPCs, but the Crime System doesn't work with them, they simply don't attack you (no matter what you do). So, if you want to have some traders that react to crimes and also can join the player in a fight against Evil NPCs (e.g. a bunch of wolves attack a farm market) you have two options:
- Open the Alignment Editor and add a new relation: Neutral NPC Hostile Evil NPCs.
- Open the Alignment Editor, add a new entity (e.g. NeutralAlly), add a new hostile realation (NeutralAlly Hostile EvilNPC), and then set your NPCs alignment to "NeutralAlly".
If you have any questions after reading this short guide you can also check this page: https://docs.larian.game/Generic_behaviour