Difference between revisions of "Simple Companion Tutorial"

m
spelling, grammar, punctuation
imported>Haama
(Reverting - see talk page)
imported>D4v3
m (spelling, grammar, punctuation)
{{Unfinished}}
 
This will show you how to make a companion in CS. You will get to create your own npcNPC 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 ==
 
 
Start customizing your companion like you would do any other npcNPC 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
 
 
 
 
Now letslet'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 letslet'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 npcNPC.
 
 
Once you found one go back to the Object Window and drag your npcNPC from the list and drop it in the rendering window. WileWhile your npcNPC 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.
 
 
 
 
Now we completed our companion but werewe're not done yet. Right now they just act like a regular npcNPC in the game, now we have to give them the controls to follow you and stay still when needed.
 
 
 
 
Right click on the list in the left and click on new. LetsLet'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 wontwon'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 letslet'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.
 
 
 
 
Now letslet's move on to the topics tab. First we must give our companion the same thing we must give all npc’sNPC’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 warmedwarned if you cantcan'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. LetsLet's call this one '''AAfollow''', After creating it select it and hit OK. Create one more topic this time call it '''AAstay'''.
 
 
 
 
Now our npcNPC has the follow and stay commands in theretheir dialog but they still wontwon't do anything. We need to add a few lines of code and set up the conditions.
 
 
First letslet'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 '...'
 
 
 
 
Take a breath and letslet'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
short veroniafollow</pre>
 
WereWe'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.
 
 
 
 
Now we must set up our conditions. Whenever you make responses you must always make sure the npcNPC you want says it. First letslet'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 npcNPC in the list. If you used the AA method like me they should be very close to the beginning of the list.
 
 
 
 
Now letslet'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 youryou're done with your response hit OK at the bottom.
 
 
 
 
Again we only want our npcNPC to have this option so add the '''GetIsID''' condition to the bottom.
 
 
Do the same for the stay topic, this time giving your npcNPC 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.
 
 
WereWe'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 werewe're almost done and soon you will be able to rejoice with your companion and fight side by side on all your adventures.
 
 
 
 
LetsLet's go back to our npcNPC window. Find your companion in the object window in the list of npcsNPC's and double click it. Now lets click on the AI button near the bottom.
 
 
 
 
Before we do anything here letslet's edit the Energy Level. We don’t want our companion to get tired wile werewe're running so set it to 100. The other 3 stats are a matter of personal preference.
 
 
 
 
Near the bottom click on the Conditions tab. Again we only want our npcNPC doing this so add the '''GetIsID''' line. We will also like to use our variable here. We only want our npcNPC 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.
 
 
 
 
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 youryou're done hit OK to close the current package.
 
 
 
 
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 therethey're close to you, without this the package gets canceled when they get close to you then they are stuck standing still forever.
 
 
 
 
Now letslet'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.
 
 
 
 
After that hit OK at the bottom and our second package is done. Hit Save in the package window and hit OK in the npcNPC window.
 
 
 
 
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 npcNPC 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 npcNPC IS following us.
 
 
 
 
In the Result Script box type: '''StopWaiting yourfollowpackagename''' for mine it is '''StopWaiting AAveroniafollow''' this will resume the followingfollow package if it was previously stopped before, without this line your npcNPC 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
set AAveroniaquest.veroniafollow to 1</pre>
 
Hit the compile button to check for errors, if there are some then you may ofhave 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 followingfollow package to stop working so your npcNPC can stand still and sets the followingfollow variable to 0 which is our stay variable. Check for errors again and fix them if needed. When youryou're done hit OK at the bottom.
 
 
 
 
Now your companion is complete. First make sure you check it in the data files of the oblivionOblivion 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.
 
 
 
 
Your companion should be ready to journey with you and fight along side like true hero'sheros.
 
 
== Tweaking your Companion ==
 
-The most prevalent problem with companions is leaving them behind on the other side of shut down oblivionOblivion 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 youryou'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 cantcan't have more then 3 companions following you at once. This is something that cannot be changed, it is built into oblivion’sOblivion’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 theretheir 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 npcNPC, 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 cantcan't do is repair theretheir 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 theretheir items and repair itthem 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 wilewhile traveling you may want to give them a very high speed stat. Also if youryou're more advanced toin 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’sNPC’s to do the same actions with you check out this page: [[NPCs%2C_Horses%2C_and_you...]]
 
 
Anonymous user