Difference between revisions of "Simple Companion Tutorial"

13,229 bytes added ,  10:44, 25 November 2011
m
no edit summary
imported>Rionukyo
m
imported>Vaelissa
m
 
(13 intermediate revisions by 7 users not shown)
Line 1: Line 1:
{{finished}}
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.


You Should create your quest script and ai packages before you edit
== Creating an NPC ==
your npc's appearance,add items,spells as follows.


Use note pad to remember:
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.
QuestName,Character id, variable name,ai package names,etc
if you cant remember what you named them
thy all have to be different names in the editor.


make new NPC: just give her an easy to remember id. Starting with the
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.
letter "A" is not a bad idea for the id so its at the top
of the list of names to show up in The editor.


check essential if you want them to be immortal.
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.


to make her go places that your guilds restrict click
factions in the npc's tab
leave the npc window open
then bring up the characters menu at the top
of the program window click faction locate PlayerFaction
highlight it then drag it to the factions box in your npcs window.


Now click the ai box,
[[Image:tutorial-00.jpg]]


Adjust the ai attributes to what you want. like setting the energy Lev to
100 means that the npc is less likely to stop,sit down,etc.


now right click the editorid box and make a new package
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.


this will be are staypackage name it accordingly.
leave packedge type as find
under target select player
now on conditions you will need to:


1.add GetIsID and under function parameters select your Npc.
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]]
it should be at a value of 1.0000


2.add GetQuestVariable and set the value to 0.0000
hit OK


we have a wait package with a value of 0.
[[Image:tutorial-01.jpg]]


make a new package its your follow package, name it accordingly.
this time set the type to follow.
and check always run,defencive combat,take falls,
continue if near pc,allow swimming
now do steps 1 again
and then step 2 but this time the value is 1.0000


now we have a follow package with a value of 1
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.


hit save.
press okay on the npc window we are done with that for now.


click character and select quest
[[Image:tutorial-02.jpg]]
Now make a new quest


On Quest conditions select new and GetIsPlayableRace this
should be at value 1.0000


Click the |...| box to
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.


Create a Script


in your quest data screen:
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.


ScriptName "Your Script Name"


Short "Variable name"
[[Image:tutorial-03.jpg]]


Save your Script. If you are confused follow example below.


|Example of script|
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.
ScriptName alexfollowscript


Short alexfollowme
|Example of script|


----------------------------------------------
Open up the quest window either by clicking on the '''Q''' or by going to the Character Menu and click on Quests...
Press okay on the quest window and reopen it, or your
Script will not show up yet so don't freak out.
reopen quest window select your quest.


to save time go back to your npc's ai window
now that we have are variable script
on conditions GetQuestVariable click function parameters
select are quest and the script


do this to both packages.
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.
done with that click the save button and OK on the npc window.


Back to quest window:
select your quest


go to topics
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.
right click in editor id box
add Greeting the one all in caps from the list
now topic text is what you see in game keep that in mind.
in the info box this is what the npcs says when u talk to him.
write something for him to say here to continue.


now on conditions put GetIsID click function parameters and select
your npc the value should be 1


now make a new topic for follow name it accordingly.
[[Image:tutorial-04.jpg]]
add the text you want him to say wen you ask him to follow.
now add the conditions
1.GetIsID select are npc value of 1.0000
2.GetQuestVariable select are variable script, value of 0.0000
3.Check goodbye.


now repeat previous steps with a wait topic name it accordingly.
1.GetIsID select are npc value of 1.0000
2.GetQuestVariable select are variable script,value of 1.0000
3.Check goodbye.


now to avoid bugs
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.
highlight the greeting topic in your quest window
in the result text box type
AddTopic yourfollowtopicname
AddTopic youwaittopicname


hit compile if all is well your names are
correct if not check you spelling


|Example of script|
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'''.
AddTopic alexfollow
AddTopic alexstay
|Example of script|


now highlight your follow topic,
in result script type the following.


StopWaiting yourfollowpackagename
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'''.
Set yourquestname.variablename to 1
now compile to check for errors,wrong names.


|Example of script|
StopWaiting alexfollowme
Set aaalex.alexfollow to 1
|Example of script|


on to the wait topic result script type the following.
[[Image:tutorial-05.jpg]]


Wait yourfollowpackagename
Set yourquestname.variablename to 0
compile


|Example of script|
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.
Wait alexfollowme
Set aaalex.alexfollow to 0
|Example of script|


okay now that you have a Brain you can focus one beauty now make
you npc look great add items,spells and place were ever you like enjoy.


E.p.H . 08
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 '...'
please email me rionukyo@gmail.com
 
 
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:
 
<pre>ScriptName AAveroniascript
 
short veroniafollow</pre>
 
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.
 
 
[[Image: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.
 
 
[[Image: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.
 
 
[[Image: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.
 
 
[[Image: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.
 
 
[[Image: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.
 
 
[[Image: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.
 
 
[[Image: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.
 
 
[[Image: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.
 
 
[[Image: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.
 
 
[[Image: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:
 
[[Image:tutorial-17.jpg]]
 
 
And the conditions of your stay topic should look something like this:
 
[[Image: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:
 
<pre>StopWaiting AAveroniafollow
set AAveroniaquest.veroniafollow to 1</pre>
 
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.
 
 
[[Image: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.
 
 
[[Image:tutorial-20.jpg]]
 
 
Your companion should be ready to journey with you and fight along side like true heros.
 
 
[[Image: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 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%2C Horses%2C 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.
 
[[Category:Tutorials]]
[[Category:Actor_Tutorials]]
[[Category:Companion_Tutorials]]
Anonymous user