Welcome Guest [Log In] [Register]

Quote of the Moment


Viewing Single Post From: Oblivion: Creature Companion Tutorial
Maigrets
Member Avatar

CREATURE COMPANION TUTORIAL BASED ON MY SHER JA - MOUNTAIN LION COMPANION MOD.

***This tutorial assumes the user knows very little about using the Construction Set so I've tried to be as detailed as possible.***

Click the thumbnails for a better view so you can see what I'm referring to.

CREDITS:

The scripts used here for the companion are adapted from the Fenrir the Wolf Companion mod by delphinus with his permission. They were created with OBSE by Jumonji, but have been changed so they no longer require OBSE which mainly dealt with fast healing after battle. This is now dealt with by adding a Healing Ability and making the creature Essential. Jumonji helped me to do this when I created my Sher Ja Mountain Lion Companion.

The Add Summon Spell script is by WillieSea. I found it on the Official CS forums where I also find a lot of other helpful information.

Thank You.

Fenrir the Wolf by delphinus and Jumonji
http://www.tesnexus.com/downloads/file.php?id=14192

Sher Ja - Mountain Lion Companion by Maigrets
http://www.tesnexus.com/downloads/file.php?id=18063
Posted Image


STARTING OUT:

This will create a simple creature companion that can be activated to stay and follow. It will fight anything that is your enemy or that attacks you in Follow mode. For example, if you resist arrest for a crime, it will attack guards. It will NOT be aggressive to friends or yourself and is player owned. I make my companions Essential so they don't die, but become unconscious for a short time. That's up to you. I prefer not to have to reload or deactivate and reactivate the mod if it dies, especially when using overhaul mods like I do, where a non essential companion death is almost guaranteed.

In Stay mode it will wander the area where you left it and will defend itself if necessary.

There will be a Summon Spell to call your companion if you've left them somewhere, if they get stuck (rare), or to remove them from battle. If they do happen to get lost, for example, falling from a great height, they will teleport to you or return on entering a new cell. Or, of course, you can summon them back.
This spell can be added to an object and you can create a quest to find it if you like, or you can place the object near the creature. Make sure to mention it in your readme if you plan to release the mod.

I am including the option of adding the spell to an object to this tutorial. When the object is taken the spell is automatically added to your spellbook. The item doesn't need to be in your inventory afterwards, so you can throw it away or keep it depending on the item used.

The spell can also be added via a quest script which will add it as soon as you load your save, but will not be included in this tutorial. I prefer not to add the Summon Spell by a quest because I like to put my creatures somewhere to find, rather than an easier location like the Waterfront District.

Quest related options will be included in another tutorial which will outline a simple quest to find a companion or object with a small story attached to a note or book. This is added to your inventory when you load your game with the mod active. It will also include how to add spells via a quest and other options like sounds and messages which can be added to the scripts.

At the bottom of this tutorial is a list of all the Construction Set Commands.

Sher Ja - Mountain Lion Companion was my first mod and I made it a habit to take screen shots of all my open windows in the Construction Set. For example: scripts, spells, stats etc. I can see at a glance what I've done for future reference, without loading the mod. But that's just me. I sometimes still do it for new mods depending on what I add to them.


FIRST STEPS:

This tutorial will create a lion companion, but can be used for any creature.

It's a good idea to name all References and ID's with a prefix. For example - JJMyLion. It's preferable to not use numerals and have no spaces in the ID field. Using the JJ, or any other prefix makes it easier to find your entries. You can use AA or aa, or your initials as long as it's always the same for consistency.

Load the Construction Set and go to File/Save and create a new esp with the name of your choice. This will automatically make it active.
Click OK and Oblivion ESM will load automatically because you are loading a mod that requires it. Otherwise you can select Oblivion ESM only to load and choose to save your esp when you've started work on your mod.

Go to the Object Window on the left and expand the Actors\Creature\creature tree. Select the CreatureMountain Lion and double click to open it's Stats Form.

Posted Image

In the ID field give it a NEW unique ID. If you don't give it a new ID every lion will be a clone of yours. Close the window by clicking OK, and you will prompted to make a new form because you've changed the ID. Click YES to create a new object. In the NAME field give it a name which will appear in game.

Open the lion's Stats Form again.
Here you can change the Essential status and whether he will Check Corpses (I leave that in)etc. Take the tick out of No Low Level processing and Respawns. Leave his Combat Style at Default for the mountain lion.
Tick PC Level Offset to have him level with you. Choose whether you want him to level above or below you by entering a number in the Offset box. For example, 1 to stay at your level or -1 to be one level below you.
In the Calc Min box type 1 and in the Calc Max box type 0. This will adjust his health, speed and fatigue modifiers on the right of the window.

Starting out it's probably best to leave his health and other stats as they are. You can adjust them later if you want. Although, I give my creatures an Intelligence of at least 30 so they can follow up stairs and through doors. They will even open gates. Always leave Personality at 20 or below as anything higher can make him passive, and enemies, depending on their Faction will ignore him when you want him to fight.


From now on I'm referring to the Lion as Leo to make things a bit easier. The abbreviation, CS, will refer to the Construction Set.


Go to the Factions Tab and right click to delete anything in there which is usually Creature Faction.
Go to the CS Menu at the top of the screen and select Character -- Factions. Scroll down the list until you find Playerfaction. With Leo's page still open drag it to the Factions Tab. You can make a custom Faction, but it's not necessary. Player Faction gives Leo all the rights and privileges as the Player.
Posted Image

Select the Inventory Tab. You can leave anything there or delete it. If you make him Essential he can't be looted anyway.

Select the Spell Tab. Depending on your choice of creature there may be a Disease listed. If so, delete it. The mountain lion has a Resist Frost ability which you can leave intact. Other creatures may have their own Abilities which can stay as well.

There's no need to do anything with the other Tabs except if you want to add new meshes and textures for your creature, but this tutorial deals with the default Mountain Lion..
You can preview him moving and attacking by selecting the Animations Tab and clicking each movement to see him in the preview window. Tick the Preview Full box to do this.

**Remember to save often. Make regular backups of the esp so you can revert to a previous file if you make a mistake and have saved it! **


NEXT:

AI Tab:

At the bottom of the stats Form is the AI Tab. Click to change the values at the top of the new window.
Posted Image

Aggression -- I've found 5 or 10 works well. Some companions use zero, but I found it causes the companion to be passive at the most inopportune times. Anything above can cause him to attack indiscriminately, including friends.
Confidence -- the higher the setting the less likely he is to run from a fight. 75 is a good number. If he's Essential and you want him to break off a fight if you decide to run or come back to fight another day, you could try a lower number.
Energy Level -- This determines how fast he moves when following and fighting. You can leave it at the default for your creature.
Responsibility -- leave this at zero otherwise you will be reported for crimes by Leo and he can also accrue a bounty which applies to you being the owner.

At the bottom is the AI Package List. Right click on any packages in the list and delete all of them.

**Click SAVE and OK at the Stats page. Save the esp.



THE PACKAGES THAT MAKE LEO FOLLOW AND WANDER:


1. You will need to create a new Global Value first. Go to the Gameplay menu at the top of the main CS window and choose Globals.
Right click on any one and choose New.
Call it "LionFollow". Click OK. If you're using another name or creature, it still must be **Follow.

2. Now you have to make two AI packages.....Follow and Wander.

FOLLOW PACKAGE:

Open your creature entry again and return to the AI Window:

Right click again in the AI Package List and select NEW.
Select at least, Allow Falls, Defensive Combat and Allow Swimming.

At the top right where it says Package type select "Follow".

In the ID tab give it a name for example (yourprefix)LeoFollow.

You'll then see four tabs:

SCHEDULE, CONDITIONS, LOCATION and TARGET.

- Go to the CONDITIONS Tab-

- At the very bottom click on the "NEW" button and select "GetGlobalValue" from the list.
- The next box "Function Parameters" will say Invalid....click it and select the Global Value you made before. ie LionFollow
- Leave the Comparison box as is and change the Value to 1.0000.
Posted Image

- Go to the TARGET Tab and select Specific Reference then select PlayerRef in the "ref" tab.
- At the bottom right where it says Distance enter a number. This is how far Leo will be behind you when he follows. The number I use is 170 which is the distance the mod I based Sher Ja on uses. I assume it's feet, but we're metric in Australia. Anyway, it's a good distance because the companion is not under your feet or bumping into you all the time. This is also good if you use horses, because he won't be pushing the horse from behind when you are stationary. You can make it smaller or larger if you like.
Posted Image

- Click OK . You can go onto the next Package or click SAVE and come back to it. Remember to save and backup your esp.


WANDER PACKAGE:

Do exactly the same again, but this time call the ID "LeoWander". Choose the Package Type as Wander.
Posted Image

- Do the same at the Conditions Tab, but leave the Value at 0.0000.
- Click the LOCATION Tab and select Near Current Location. Give it a distance. Again mine is 1800. This is how far he will wander around when you activate him to tell him to wait. Some mods use 1200 or less...it's up to you. When you have the summon spell you can call him to you anyway.
Posted Image

Make sure Defensive Combat, Allow Falls and Allow Swimming are selected here as well. Click OK and SAVE to close the window.


NOW ADD THE SCRIPT

This is the script I use:
Posted Image

It's a good idea to type or copy the script to a text editor like Notepad first. That way you can make alterations if necessary before adding it to the creature and
risking errors when you try to save it.

You'll see where it says LionFollow you must change it to the name of the Global Value you made for your creature.
The message as you see can be whatever you like, but should not go to another line.

Give the script a name. It should have SCRIPT at the end no matter what you call it.

The bottom part of this script also tells him not to attack you if you hit him, but is probably not necessary because making him Player Owned does the same thing.
However, I was advised to leave it in and it doesn't have any adverse effects.

THE SCRIPT
NOTE: "scn" means script name. You can also use the word ScriptName instead.

***The scripts are not formatted correctly in this tutorial. When I work out how to fix it I will amend the text.

scn MASherJaScript

ref rEnemy

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

begin OnActivate

if IsActionRef player
SetIgnoreFriendlyHits 1
if LionFollow == 1
set LionFollow to 0
Message "'Sher Ja, wait for me.'"
elseif LionFollow == 0
set LionFollow to 1
Message "'Sher Ja, come with me.'"
endif
EvaluatePackage
playGroup Idle 1
else
activate
endif
end

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

begin OnStartCombat

;make sure not to attack friends after accidental hits.

set rEnemy to getCombatTarget
if GetShouldAttack rEnemy == 0 && Player.GetShouldAttack rEnemy == 0
StopCombat
StopCombatAlarmOnActor
playGroup Idle 1
return
endif
end



In the creature's Stats Form click on the little box with "......" on it, next to the Script field, beneath the NAME field.
Select New from the Menu. Copy and paste the script into the box. Make sure it is an Object Script. Select this from the Script Type list at the top right of the script window.
Select Save from the Menu or use the disk Icon.

DO NOT EVER SELECT RECOMPILE ALL WHEN SAVING -- This will compile every script in the game and your plugin will be extremely large not to mention problematical.

You'll have to close the stats form and re-open it to select the script from the dropdown list in the Script Field below your creature's name.

Close the Stats Form, SAVE and backup again.


PLACE LEO IN THE WORLD:

All of the keys needed to manipulate objects in the CS are included at the bottom of this tutorial.

In the Cell View window where it says Worldspace and Interiors in the selection box, find and select Tamriel.
You can click on any name to select it then type the 1st letter of the area you want to load......For example I...then scroll down to the IC Waterfront01.

Double click to load the area in the Render Window on the right. It may take a few seconds to load depending on your system.

Zoom in to the location you want to place your creature. Try to get as close as possible to where you want to place him, then drag the creature (the text) from the Object Window to the world and press F to drop him. Don't drop him from way up high or you might have trouble finding him, especially in an exterior.

Press the A key to turn on the lights so you can see what you are doing.
Use a combination of Shift + Mouse Wheel (held) alternately to manipulate the screen to get as close as possible to the desired position. Scroll the mouse wheel to zoom in and out.
Click the creature so it is selected to move it around, and use the RMB to rotate it if necessary. Or use the Z, X and Y keys for other movement.

When he's in the world double click him and give him an Editor Reference ID. This can be the same as his stats form ID, but put REF at the end. No spaces. Select Persistent Reference so he won't disappear when the world respawns. You should also select the Ownership Tab and make him Player owned. This will ensure he doesn't attack friendlies and will even defend you from guards if you resist arrest.
Posted Image

Now it's a good idea to open his Stats Form and check Quest Item. Making him a quest item gives him loading priority, so he always gets loaded at game start. Otherwise he can also be forgotten by the game engine.
Don't do it before putting him in the world or the CS will prompt you about Quest items and possibly give an error message.

Save your plugin and test it. At this point we haven't added the Summon Spell, but you should make sure he is where you want him. He can be activated to Stay and Follow without the spell.


CREATE THE ITEM TO HOLD THE SUMMON SPELL

If everything is working correctly we can go ahead and create the object that contains the spell and the spell itself.

**If you have Shivering Isles installed be careful about using items from the expansion unless you plan to use a creature and object from SI. Items, objects and spells etc from SI are usually prefixed with SE.

From the OBJECT LIST choose an item from the ITEMS list which will hold the Summon Spell script. It can be virtually anything, for example a gemstone or a bone which I used for Sher Ja or a shoe which I used for a dog companion. As long as a script can be added, it will work.
***Be careful about using Quest Objects as you must be sure to remove the tick from Quest Item first otherwise it will interfere with the related quest.

Once you've decided what you will use, double click to open the item's Form. As described above for Leo, give the item a unique ID and a name that will be displayed in the game. When prompted to create a new item, click YES. Leave the item for now. We have to create the Summon Spell before we can add the script to it.
Posted Image

CREATE THE ACTUAL SUMMON SPELL

In the OBJECT Window got to Magic/Spell. I usually make a Summon Spell a Lesser Power because it's easier to find if you have a lot of spells like I do. Otherwise it can be a basic spell.

Right click on any spell and select NEW.

Give your spell a unique ID and a name which will appear in your spellbook. Select the type of spell eg Lesser power. Select Script Effect Always Applies.
Remove the tick from Auto Calculate. This negates the cost of casting the spell. Close the Spell Form and reopen it. This saves your changes.

Right Click in the text field on the right and select NEW. From the Effect List select Script Effect. The Range is on SELF because we are casting the spell on ourselves. There is no need for a duration for this spell.
Leave the Script and Effect names for now. Choose the school of magic, eg Conjuration and a visual effect if you want one. I usually choose Command Creature for my companions.
Remove the tick from Effect is Hostile. Again, close the Form and reopen it.

Now we add the script. In the text field it will say Script: NONE. Right click and select EDIT.
Click on the "..." next to the Script drop down box and a Script Editor window will open the same way as when we created the companion.
Select NEW from the menu and copy and paste this scipt into the blank box. Make sure to choose MAGIC from the drop down box on the right.

scn SummonSherJaScript
Begin ScriptEffectStart
AALionref.moveto player, 100, 0, 0
End
Begin ScriptEffectFinish
End

Give your script a unique name. It should have Script at the end as shown. Change AALionref to the Editor Reference you made when you placed your creature in the world.
Save your script and close the Script Editor. Click OK to close the Effect Item Box and OK again to close the Spell Form. This saves the information.

Once again open your spell and the Effect Item Box. Select the script you just made from the drop down list. Give the effect a name in the Effect Name field, eg Summon Creature.
Now the script will show in the text field of the Spell Form. You can click OK to close it now.
Posted Image

ADD THE SUMMON SPELL TO YOUR ITEM

Find your item in the ITEM list and open it's Form. Add this script to it the same way as we added the previous scripts. This one must be an OBJECT script.

scn AASummonSpellScript
short doOnce
begin OnActivate
if doOnce == 0
Message "Friendship will be your reward"
Player.addspell AASherJaSpell
set doOnce to 1
endif
activate
end


Once again give it a unique name and add it to your item the same way as the previous scripts. It must be an OBJECT script this time.
You can add a message as shown, which will show in game at the top left of the screen when you take the object. You will also receive a message to say the spell has been added to your spellbook. If you prefer not to have the message in the script you can delete that line, but make sure not to leave the line blank. Move the next line up.
Click OK to close and save the information.

Place the item in the world the same way as you placed your creature. Drag the name of the item into the Render Window and place it wherever you like.

***Save your esp and now test it to make sure everything works as intended.


EXTRA NOTES

Your companion will start to wander as soon as you enter the cell where you placed him. If he has wandered off, just pick up your item containing the Summon Spell to bring him to you.
Activate him to make him Follow and again to make him Stay. He will take care of the rest.

I usually create a Healing Ability Spell even though my companions are Essential. I use Oscuro's Oblivion Overhaul (OOO) and Martigen's Monster Mod (MMM) and even essential companions can very often become unconscious when you really don't want them to.

See the screen shot for the Healing Ability I added to Sher Ja. You can make it weaker if desired, but this keeps him going in most heavy battles.
Posted Image

Create a spell as described for the Summon Spell, but not a Script effect. Make it an Ability and drag the Spell to the companion's Spell Tab in his Stats form

If there are any problems or something seems unclear, please ask and I'll do my best to clarify.


CONSTRUCTION SET COMMANDS:

====================
Navigating the Construction Set
====================
Camera View:
Shift + Mouse movement = Spin or tilt camera view.
V + Mouse up/down OR mouse wheel = Zoom in and out.
T = Top view
C = Center view (from South looking North)

Objects:
Single Click object = Select one object
Double Click object = Bring up 'Reference' window on object.
Ctrl + Click object = Select and add/subtract objects to a Group of selected objects.
Click window and drag a box around objects = Select all objects contained fully in the box.

Selected Objects Manipulation:
Z + Left mouse + Mouse Up/Down = Raise or lower object
Z + Right mouse + Mouse Left/Right = Angle object East or West
X + Left Mouse + Mouse Up/Down = Move object on Y axis
X + Right Mouse + Mouse Up/Down = Angle object North or South
Right Mouse + Mouse Left/Right = Rotate object
Left Mouse + Mouse Movement = Move object in 3D world

B = Show/Hide cell Borders
M = Show/Hide Markers (Horse, door, map, x)
H = Enter/Exit landscape editing mode
L = Show/Hide Light radius wireframe
A = All light on/off
W = Wireframe on/off
V = Leaves on/off

F4 = Show/hide Collision geometry

Copy and Paste:

Ctrl V - Paste
Ctrl C - Copy
Edited by Maigrets, Apr 11 2009, 12:10 AM.
Offline Profile Quote Post
Oblivion: Creature Companion Tutorial · TSRL - Modding Forums - Guest View