Simple Companion Tutorial

From the Oblivion ConstructionSet Wiki
Jump to navigation Jump to search

This will show you how to make a companion in CS. You will get to create your own NPC and give them two simple commands: Follow and Wait. It will be up to you to expand on your companion and add extra features to them. Be prepared for a lot of reading, this is a lengthy tutorial.

Creating an NPC[edit | edit source]

Let's begin by creating an NPC. Go to the Object Window on the left and expand Actors and NPC. When you see the list of NPC’s in the middle right click and select New.

I will give my companion the ID wikiComVeronia (see ID Conventions) and in the name box I will put Veronia Lightbringer. You can use any name you like for yours.

Before moving on we wanna make sure our companion is always the same level as the player. We don’t want them too under or overpowering so check the PC Level Offset box. Also we don’t want our NPC dying for good so check the Essential box. This will make them faint when they run out of health and regain consciousness soon after.


File:Tutorial-00.jpg


Other features you can change to your liking, it doesn’t matter what class you give your companion but it will decide how they will fight. Since I am making mine a knight I will choose Blademaster so she will use sword combat more often.


Start customizing your companion like you would do any other NPC with stats, items, weapons, skills and facial features. If you do not know how to use all those features I suggest you see the Basic NPC Creation Tutorial


File:Tutorial-01.jpg


For mine I created a lovely Imperial Knight. You can create whatever you want but it would be a good idea to stick to playable races to avoid bugs. I started out trying to create a Dremora companion for this tutorial but he will not accept our custom dialog. It might be a good idea to add the PlayerFaction from the faction list to make sure your companion gets all the same accesses and treatments as you.


File:Tutorial-02.jpg


Now let's place our NPC somewhere in the game world for us to meet. This can vary depending on what story you make with your companion but for easy access let's place ours in the Imperial City Market District. Go to the Cell View window and expand the World Space list. Select ICMarketDistrict and double click on ICMarketDistrict01. Scroll in with the mouse wheel a bit and push it and drag it to move the camera around. Scroll in and find a good spot for your NPC.


Once you found one go back to the Object Window and drag your NPC from the list and drop it in the rendering window. While your NPC is selected press F to drop them down to the ground and hold the right mouse button to rotate him in the direction that you want.


File:Tutorial-03.jpg


Now we completed our companion but we're not done yet. Right now they just act like a regular NPC in the game, now we have to give them the controls to follow you and stay still when needed.


Open up the quest window either by clicking on the Q or by going to the Character Menu and click on Quests...


Right click on the list in the left and click on new. Let's give our quest the name AAveroniaquest or whatever you wanna name it, again it’s a matter of personal preference. Give your quest a name, since this won't go into your quest journal you can just give it the same name as the ID. For mine AAveroniaquest will do. Since we want no other quests interfering with our companion let's give this quest a high priority 85 or 90 or 100 will do, you may have to tweak it a bit if you encounter major problems wile testing your mod. This is so no other dialogs get mixed in with our companion or other quests taking over our companions functions.


There is also something you have to do with every quest and it is to give it this special condition or it may not work. Click on the New button, and under the condition function find GetIsPlayableRace and type 1 in the value box.


File:Tutorial-04.jpg


Now let's move on to the topics tab. First we must give our companion the same thing we must give all NPCs. Right click on the empty list under Editor ID and select Add Topic. Scroll down untill you find GREETING in capital letters, select it and hit OK. Now right click in the empty list at the top under the Info column and select new. Type whatever you want in the response text, for my companion I will use “My will is at your command.” And you may play around with the emotion settings if you like. You may even add voice overs if you got the equipment for it but be warned if you can't do good voice overs then you shouldn’t do any at all. After you finish the response hit OK at the bottom.


Now before we work on this further we want to create 2 more responses. Right click on the left list again and go to Add Topic, this time we want to create our own topic so right click in the topic list and select new. Let's call this one AAfollow, After creating it select it and hit OK. Create one more topic this time call it AAstay.


Now click on the GREETING topic again and near the middle on the right hand side right click in the Add Topics box and click on Add Topic. Click on AAfollow and hit OK. Do this again for AAstay.


File:Tutorial-05.jpg


Now our NPC has the follow and stay commands in their dialog but they still won't do anything. We need to add a few lines of code and set up the conditions.


First let's set up the variable we will use for our quest. Variables can be tricky to use but they add much more functionality to the game and are used in just about everything to bring great enhancements to everything in the game. Go back to the Quest Data tab. Where you see the line that says Script click on the box with the '...'


At the top left click on script and click on new. Where the script type box is, open the list and select Quest.


Now we got some heavy scripting ahead of us, are you prepared? This may be the hardest work you will ever have to do.


Take a breath and let's begin. For the first line type ScriptName yourscriptname, for mine I will call it ScriptName AAveroniascript. Now hit the enter key 2 times giving yourself an extra line of space. Type in short variablename, for mine I use short veroniafollow. Your script should now look something like this:

ScriptName AAveroniascript

short veroniafollow

We're done... there was that so bad? What this script does is declare a variable for us to use, in my case veroniafollow is the variable, it can be anything you want, just try not to use any numbers as it may screw things up.


Hit the save button and close the script. We will also have to close the quest window and reopen it. Hit the OK button and the bottom and open up the quest window again.


Make sure it is your quest that is selected. Now in the script line expand the list and find our newly created script. Select it and go back to the Topics tab.


File:Tutorial-06.jpg


Now we must set up our conditions. Whenever you make responses you must always make sure the NPC you want says it. First let's set up the conditions for our GREETING. Click on it then at the bottom hit new and find GetIsID in the list. The next box over will say invalid, click on it and select our NPC in the list. If you used the AA method like me they should be very close to the beginning of the list.


File:Tutorial-07.jpg


Now let's move on to our follow topic. At the top you may want to rename the topic text. This will show the choice you will get in the game. Change it to something reasonable like Follow Me. Now in the empty list at the top, right click and select new. Type in a response you want your companion to say when they follow you. For mine I will use “I will follow you to whatever end.” Yea I'm a Lord of the Rings Fanatic, you may want to make yours a little different. When you're done with your response hit OK at the bottom.


File:Tutorial-08.jpg


This time we want our character to exit the dialog after they say this line so check the goodbye box on the right.


File:Tutorial-09.jpg


Again we only want our NPC to have this option so add the GetIsID condition to the bottom.


Do the same for the stay topic, this time giving your NPC a response when you want them to stay, for mine I used “I will stand guard till death take me.” Check the goodbye box, edit the topic text and add the GetIsID condition.


We're done in the quest window for now but we will need to come back here to program the AI for the following and staying. Hit OK at the bottom for now to close the quest window.


You may wanna take a break, get a drink or something. I know I got a headache from writing this tutorial... Don’t worry we're almost done and soon you will be able to rejoice with your companion and fight side by side on all your adventures.




Let's go back to our NPC window. Find your companion in the object window in the list of NPCs and double click it. Now lets click on the AI button near the bottom.


File:Tutorial-10.jpg


Before we do anything here let's edit the Energy Level. We don’t want our companion to get tired wile we're running so set it to 100. The other 3 stats are a matter of personal preference.


File:Tutorial-11.jpg


Right click in the empty list at the bottom and select new. This will bring up an AI package window we will create. Give it a short name, for mine I will use AAveroniastay.


Near the bottom click on the Conditions tab. Again we only want our NPC doing this so add the GetIsID line. We will also like to use our variable here. We only want our NPC to stay when we want them to stay, so add a new condition. Select GetQuestVariable in the list. Where the box says INVALID, UKNOWN click on it and select our quest in the list. For mine it is AAveroniaquest. In the second box where it says variable name you should see the variable you declared in the earlier script. Select it and hit OK. Leave the value field 0. We will use 0 as the stay variable.


File:Tutorial-12.jpg


After that our first package is done. But it isn’t quite ready to work properly yet as we need to add more lines of code to our quest later. When you're done hit OK to close the current package.


Lets create our second package, this time give it the ID you want for following. For mine I used AAveroniafollow.


This time we will need to check some flags to ensure our companion will function properly. First check Continue if PC Near so they will keep following you even when they're close to you, without this the package gets canceled when they get close to you then they are stuck standing still forever.


Then check Always Run, you want them to run with you. Also check Allow Swimming, you want them to be able to swim through water with you and check Allow Falls so they are able to cross small ledges and cliffs with you. Lastly check Defensive Combat.


Now change the package type to Follow. Cause we want them following something, namely us.


File:Tutorial-14.jpg


In the conditions tab add the good old GetIsID line like before. And we will also add the GetQuestVariable line but this time set the value to 1. We will use 1 as our following variable.


File:Tutorial-15.jpg


Now let's move on to the target tab. Click on the any object bullet and under in the Object ID list find Player and select it.


File:Tutorial-16.jpg


After that hit OK at the bottom and our second package is done. Hit Save in the package window and hit OK in the NPC window.


Our AI is complete, but our companion still doesn’t know when to activate the right packages. For this we need to go back to the quest window. Select our quest and go to the Topics tab.


To make things easier we only want our choices to show up when we need them so select the follow topic, for mine its AAfollow and look down to the conditions box. We only want the Follow Me option to show when the NPC is NOT following so click new and select GetQuestVariable. Select our quest and variable from the INVALID box and leave the value at 0.

Do the same for the stay topic but this time make the Value 1. This will make sure the Stay Here command will only show when the NPC IS following us.


The conditions of your follow topic should look something like this:

File:Tutorial-17.jpg


And the conditions of your stay topic should look something like this:

File:Tutorial-18.jpg


But those are only the conditions, we still need to change that variable from 0 to 1 and 1 to 0 when we need to.


Go back to the follow topic and look at the Result Script box. Now we need to write more dreaded scripts.


In the Result Script box type: StopWaiting yourfollowpackagename for mine it is StopWaiting AAveroniafollow this will resume the follow package if it was previously stopped before, without this line your NPC will always stand still regardless of command. For the second line type: set yourquestname.yourvariable to 1 for mine it is set AAveroniaquest.veroniafollow to 1 this will change our variable to 1 which is to follow. Your commands in the Result Script box should look something like this, depending on what your names are:

StopWaiting AAveroniafollow
set AAveroniaquest.veroniafollow to 1

Hit the compile button to check for errors, if there are some then you may have gotten your names wrong. Check back to your quest ID and variable script to see the exact names you gave them. If you followed my names then you should be fine.


Now go to your stay topic. In the result script box type the same thing only this time change the first command to Wait and the value of your variable at the end to 0. This will tell the follow package to stop working so your NPC can stand still and sets the follow variable to 0 which is our stay variable. Check for errors again and fix them if needed. When you're done hit OK at the bottom.


File:Tutorial-19.jpg


Now your companion is complete. First make sure you check it in the data files of the Oblivion launcher then go in game to check it out. They should be where ever you placed them in the world and have the Follow Me command ready to go.


File:Tutorial-20.jpg


Your companion should be ready to journey with you and fight along side like true heros.


File:Tutorial-21.jpg


If you would like to download the mod from this tutorial you can get it here: http://www.tesnexus.com/downloads/file.php?id=16289

Feel free to open it up in CS and cross reference all your actions with my own.



Tweaking your Companion[edit | edit source]

-The most prevalent problem with companions is leaving them behind on the other side of shut down Oblivion gates. If you don’t wanna lose your companion FOREVER then simply tell them to wait outside the gate. Or you can bring them in to fight, just remember to leave them back outside the gate before you take the Sigil stone. If you're good enough with scripting you may add some advance features to do this automatically or you may want to create a summon spell where you can call your companion to you where ever you are.


-If you plan to create more than one companion or use your companion mod along side others keep in mind you can't have more then 3 companions following you at once. This is something that cannot be changed, it is built into Oblivion’s engine. If you need to go on those escort quests like taking Martin to Cloud Ruler Temple, you may want to tell your companions to wait at certain locations and come pick them back up later.


-The most requested feature for companions is of course to get access to their inventory and share items. For this you might want to download Easy Companion Share:http://www.tesnexus.com/downloads/file.php?id=2964 This mod adds the necessary code to any NPC, all you need to do is add the result script to your dialog choices. This is also good for when you want to buy your companion new and better armor. Or if you think you can take it on, code your own inventory sharing system.


-One thing your companion can't do is repair their items so eventually they will get weaker and be unable to fight. You can do one of three things to solve this problem. One is to use easy companion share and take their items and repair them yourself, or code a self repairing script for your companion, or make custom items with 9999999 health and make the npc have 1000 base armor to eliminate item degrading and ensure they will stay at 100% durability forever. If you give them 1000 armor then you may want to consider lowering other stats to balance them out.


-If you find your companion not able to keep up with you while traveling you may want to give them a very high speed stat. Also if you're more advanced in scripting you may also want to give them automatic catch up where they teleport a certain distance close to you when they get too far away. It may also be a good idea to script them to ride horses or sneak when you ride horses and sneak. For more on getting NPC’s to do the same actions with you check out this page: NPCs, Horses, and you...


-If your companion gets lost or you are unable to find them you may also want to create them as a quest marker so you can see them where ever they are in the world map. This means you will have to upgrade your companion quest to an actual quest in the quest journal.