Difference between revisions of "Simple Companion Tutorial"

1,144 bytes removed ,  10:44, 25 November 2011
m
no edit summary
imported>Mightylink
imported>Vaelissa
m
 
(18 intermediate revisions by 8 users not shown)
Line 1: Line 1:
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...
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 ==


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
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.


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.
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.
 
 
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.




Line 29: Line 16:




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
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]]




Line 41: Line 28:




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.
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. Wile 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.
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.




[[Image:tutorial-03.jpg]]
[[Image: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 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.
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.




Line 58: Line 43:




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 no other quests interfering with our companion 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. This is so no other dialogs get mixed in with our companion or other quests taking over our companions functions.
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.




Line 67: Line 52:




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 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. Lets call this one '''AAfollow''', After creating it select it and hit OK. Create one more topic this time call it '''AAstay'''.
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'''.




Line 79: Line 64:




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.
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 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 ...
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 '...'




Line 91: Line 76:




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:
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:


<pre>ScriptName AAveroniascript
<pre>ScriptName AAveroniascript
Line 97: Line 82:
short veroniafollow</pre>
short veroniafollow</pre>


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.
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.




Line 109: Line 94:




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.
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.




Line 115: Line 100:




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.
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.




Line 127: Line 112:




Again we only want our npc to have this option so add the '''GetIsID''' condition to the bottom.
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.
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.
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 were almost done and soon you will be able to rejoice with your companion and fight side by side on all your adventures.
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.




Line 142: Line 127:




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.
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.




Line 148: Line 133:




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.
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.




Line 157: Line 142:




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.
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.




Line 163: Line 148:




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.
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.




Line 169: Line 154:




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.
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.




Line 187: Line 172:




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.
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.




Line 193: Line 178:




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.
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.




Line 199: Line 184:




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.
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.
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.




Line 220: Line 205:




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:
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:


<pre>StopWaiting AAveroniafollow
<pre>StopWaiting AAveroniafollow
set AAveroniaquest.veroniafollow to 1</pre>
set AAveroniaquest.veroniafollow to 1</pre>


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.
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 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.
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.




Line 234: Line 219:




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.
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.




Line 240: Line 225:




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




Line 252: Line 237:


----
----


== Tweaking your Companion ==
== 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.
-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 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.
-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 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.
-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 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
-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 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%2C_Horses%2C_and_you...]]
-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%2C Horses%2C and you...]]




Anonymous user