Simple Companion Tutorial

Revision as of 08:53, 30 March 2008 by imported>Mightylink

Simple Companion Tutorial

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. I said you will get to make a simple companion, not read a simple tutorial...


If you never used oblivion construction set then stop reading now. I suggest you read these tutorials first to build up some basic knowledge of how to make things. http://cs.elderscrolls.com/constwiki/index.php/Category:Getting_Started


Lets start with a fresh copy of good old Oblivion Construction Set. Open up the program, check oblivion.esm and press OK and wait for it to load.


Lets 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. Lets give it an ID that will be easy to find so AAmycompanion or whatever you wanna call it will do.


I always do all my custom items with AA so they appear at or very near the beginning of the list and is easy to find.


(Try not to use 0 or any other numbers in your names. These can throw off scripts and variables in oblivion and may cause problems or fail to work all together.)


I will give my companion the ID AAveronia 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: http://cs.elderscrolls.com/constwiki/index.php/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 lets 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 lets 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. Wile your npc is selected press F to drop him down to the ground and hold the right mouse button to rotate him in the direction that you want.


File:Tutorial-03.jpg

(Excuse my screenshot my video card does not support pixel shader 2.0, I have been using “oldblivion” to play all this time.)


Now we completed our companion but were 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. Lets 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 wont go into your quest journal you can just give it the same name as the ID. For mine AAveroniaquest will do. Since we want our companion to be with us throughout the game lets 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. 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 lets move on to the topics tab. First we must give our companion the same thing we must give all npc’s. 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 warmed if you cant 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. Lets 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 there dialog but they still wont do anything. We need to add a few lines of code and set up the conditions.


First lets 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 lets 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

Were 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 lets 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 lets 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 your done with your response hit OK at the bottom.


File:Tutorial-08.jpg


This time we want our character to exit the dialog after he says 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.


Were 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 were almost done and soon you will be able to rejoice with your companion and fight side by side on all your adventures.




Lets go back to our npc window. Find your companion in the object window in the list of npcs and double click it. Not lets click on the AI button near the bottom.


File:Tutorial-10.jpg


Before we do anything here lets edit the Energy Level. We don’t want our companion to get tired wile were 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 your 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 there 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 lets 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 following 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 of 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 following package to stop working so your npc can stand still and sets the following variable to 0 which is our stay variable. Check for errors again and fix them if needed. When your 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 hero's.


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

-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 your 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 then one companion or use your companion mod along side others keep in mind you cant 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 there 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 cant do is repair there 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 there items and repair it 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. You can also see the talk about undegradable items here: http://cs.elderscrolls.com/constwiki/index.php/How_do_I_create_armor_or_weapons_that_cannot_be_destroyed


-If you find your companion not able to keep up with you wile traveling you may want to give them a very high speed stat. Also if your more advanced to 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.




Credits

I would like to thank the wowwiki community for showing me the basics of CS. I am still very new to it but since I could not find a companion tutorial and it is highly requested, I decided to post my own. I fought for over three days trying to figure this out so no bad comments would be appreciated. Feel free to change anything if you think it is wrong. I would also like to thank haama and mmmpld from the Bethsoft forums for showing me the basics on variables and how to use them in quest scripts.

Tutorial written by: Mightylink