Difference between revisions of "Scripting Tutorial: Summoned Creatures"

From the Oblivion ConstructionSet Wiki
Jump to navigation Jump to search
imported>Gdarknight
imported>Vaelissa
 
(13 intermediate revisions by 8 users not shown)
Line 1: Line 1:
==CUSTOM SUMMONED CREATURES==
[[Category: Tutorials]]
[[Category: Scripting Tutorials]]
{{Tools|req0=[[The Elder Scrolls Construction Set|Construction Set]]}}
__TOC__


This tutorial will help you set up a custom Summon Creature spell using the Script Effect system. This is a complete tutorial starting at the basics.
This tutorial will help you set up a custom Summon Creature spell using the Script Effect system. This is a complete tutorial starting at the basics.


This will not change any game play settings or magic effects.
This will not change any game play settings or magic effects.
===What you will do===
 
==What you will do==
This tutorial will show you how to:
This tutorial will show you how to:
* Create a simple holding cell
* Create a simple holding cell
Line 13: Line 17:
* Create a new spell with the scripted "summon" effect
* Create a new spell with the scripted "summon" effect


===Step 1: Create a holding cell for your creatures.===
==Step 1: Create a holding cell for your creatures==
<hr>
* Open the [[:Category:Cells|World-> Cells]] menu and make sure the drop-down menu is set on [[Interior cells|Interiors]].
<p>
* Right-click on a cell name and select '''New'''. Make sure your ID is something unique you can remember.
* Open the '''World-> Cells''' menu and make sure the drop-down menu is set on Interiors.  
* Right-click on a cell name and select '''New'''. Make sure your id is something unique you can remember.
* Click Ok when done, and Ok again to close the menu.
* Click Ok when done, and Ok again to close the menu.
* Double-click on your Interior under the '''Cell View''' listing. You will now drag in an anchor reference to move the creature back to the cell.
* Double-click on your Interior under the '''Cell View''' listing. You will now drag in an anchor reference to move the creature back to the cell.
* In the '''Object Window,''' expand''' World Objects -> Static, '''and click on Architecture.
* In the [[Object Window]], expand World Objects -> Static''', and click on Architecture.
* Drag an interior such as “'''''AnvilHouseMCInterior01'''''” into the render view.
* Drag an interior such as “'''''AnvilHouseMCInterior01'''''” into the [[Render Window]].
* Right-click on the architecture object in the '''Cell View''' listing, and select '''Edit.'''
* Right-click on the architecture object in the [[Cell View Window]] listing, and select '''Edit'''.
* Enter a name for the reference such as “'''''CreatureCageREF'''''”, select “'''Persistent Reference'''” and click '''Ok'''.
* Enter a name for the reference such as “'''''CreatureCageREF'''''”,Set the Location to (0,0,10), select “'''Persistent Reference'''” and click '''Ok'''.


===Step 2: Choose an AI follow package.===
==Step 2: Choose an AI follow package==
</p><p>
There is a default “'''''FollowPlayer'''''” [[Glossary#A|AI package]], but it does not allow for swimming, falls, etc. You can use the steps below to create a custom package, or skip to Step 3.
<hr>
There is a default “'''''FollowPlayer'''''” package, but it does not allow for swimming, falls, etc. You can use the steps below to create a custom package, or skip to Step 3.


* Open the '''Characters->Packages''' menu.
* Open the [[AI Package|Characters->Packages]] menu.
* Right-click on a space and select '''New'''.
* Right-click on a space and select '''New'''.
<div class="thumbinner" style="width:"100%" align="center">
 
''[[Image:Packages01.jpg|624px|Packages01.jpg]]''
[[Image:Packages01.jpg|624px|Packages01.jpg]]
</div>
 
* Enter a unique name for you package that you can remember.
* Enter a unique name for you package that you can remember.
* Select “'''Must Complete'''” and “'''Defensive Combat'''” at a minimum; “'''Allow Swimming'''” and “'''Allow Falls'''” are optional. The other options are more for NPC’s than creatures.
* Select “'''Must Complete'''” and “'''Defensive Combat'''” at a minimum; “'''Allow Swimming'''” and “'''Allow Falls'''” are optional. The other options are more for [[Glossary#N|NPCs]] than creatures.
* Change the '''Package Type '''drop-down to “Follow”.
* Change the '''Package Type''' drop-down to “Follow”.
* Click on the '''Target''' tab and select “Specific Reference”.
* Click on the '''Target''' tab and select “Specific Reference”.
* Choose the Cell “'''''AbandonedMine02'''''” and the Ref “'''''Player PlayerRef'''''”.
* Choose the Cell “'''''AbandonedMine02'''''” and the Ref “'''''Player PlayerRef'''''”.
* Set the distance the creature can be from you: recommend 128.
* Set the distance the creature can be from you: recommend 128.
<div class="thumbinner" style="width:"100%" align="center">
 
''[[Image:Packages02.jpg|624px|Packages02.jpg]]''
[[Image:Packages02.jpg|624px|Packages02.jpg]]
</div>
 
* Click '''OK''' when done.
* Click '''OK''' when done.


===Step 3: The Critter!===
==Step 3: The Critter!==
</p><p>
<hr>
You will now change a normal creature into your summon version. I recommend editing an existing creature to ensure proper animation and models. For this example, I picked a Rat.
You will now change a normal creature into your summon version. I recommend editing an existing creature to ensure proper animation and models. For this example, I picked a Rat.


* In the '''Object Window''', expand '''Actors->Creatures->Creatures'''. Scroll down to '''''CreatureRat''''' and double-click to open.
* In the '''Object Window''', expand '''Actors->Creatures->Creatures'''. Scroll down to '''''CreatureRat''''' and double-click to open the properties window.
* Change the ID to “RatSummon01”, and the Name to “Summoned Rat”.
* Change the ID to “RatSummon01”, and the Name to “Summoned Rat”.
* Uncheck the “'''Respawn'''” box so we can control the resurrection from script.
* Uncheck the “'''Respawn'''” box so we can control the resurrection from script.
* Click on the AI button to open the menu.
* Click on the AI button to open the [[AI_Button|AI Object Dialog]].
<div class="thumbinner" style="width:"100%" align="center">
 
''[[Image:AIMenu01.jpg|568px|AIMenu01.jpg]]''
[[Image:AIMenu01.jpg|568px|AIMenu01.jpg]]
</div>
 
* Set the “'''Aggression'''” to zero and delete any existing packages
* Set the “'''Aggression'''” to five(so if a friend of the creature or the creature itself is attacked, it will attack the posing threat) and delete any existing packages by selecting them in the list and pressing delete.
* Open the '''Character->Packages''' menu and drag either the “'''''FollowPlayer'''''” package, or a custom one made in step 2 into the AI menu.
* Open the '''Character->Packages''' menu and drag either the “'''''FollowPlayer'''''” package, or a custom one made in step 2 into the AI menu.
* Click '''Save''' to close the menu. You can also close the '''Packages''' menu.
* Click '''Save''' to close the menu. You can also close the '''Packages''' menu.
* Select the “'''Factions'''” tab and delete any existing factions. Open the '''Character->Factions''' menu and drag over the “'''''PlayerFaction'''''”.
* Select the “'''Factions'''” tab and delete any existing factions(Not Required If NPC is Special). Open the '''Character->Factions''' menu and drag over the “'''''PlayerFaction'''''”.
* Click '''Ok''' and answer “'''Yes'''” to create a new form.
* Click '''Ok''' and answer “'''Yes'''” to create a new form.
* Drag your new creature into the Interior you created. Edit the creature reference just like the architecture piece and enter the name “'''''SummonRat1RE'''''F”.
* Drag your new creature into the Interior you created. Set the Location to (0,0,10). Edit the creature reference just like the architecture piece and enter the reference editor ID “'''''SummonRat1REF'''''.
* Select “'''Persistent Referenc'''e” and “'''Initially Disabled'''”. This ensures our creature is always available, but not moving around or running AI yet.
* Select “'''Persistent Reference'''and “'''Initially Disabled'''”. This ensures our creature is always available, but not moving around or running AI yet.
* Click '''Ok''' when done.
* Click '''Ok''' when done.


===Step 4: Creating the script effect.===
==Step 4: Creating the script effect==
</p>
<hr>
<p>
This script uses the [[MoveTo]] command to perform the actual summoning of the creature to the player. The remaining code is for visual effects and placement of the creature back in the holding cell when done, or dead.
This script uses the [[MoveTo]] command to perform the actual summoning of the creature to the player. The remaining code is for visual effects and placement of the creature back in the holding cell when done, or dead.
* Open the '''Gameplay->Edit Scripts''' menu and click '''Scripts->New'''.
* Open the [[Edit Scripts|Gameplay->Edit Scripts]] menu and click '''Scripts->New'''.
* Copy the script and paste into the editor window. Be sure to change the reference names if different from the tutorial (lines 13, 27, and 58).
* Copy the script and paste into the editor window. Be sure to change the reference names if different from the tutorial (lines 14, 33, and 74). These lines contain 3 numbers (0,0,10) which is the location of the reference, you can switch the reference location, but you must also switch the script location reference.
 
<pre>
<pre>
ScriptName SummonRatSCR
ScriptName SummonRatSCR


;This script can be used as a template for custom summoned creatures/NPC's
;This script can be used as a template for custom summoned creatures/NPCs


float timer
float timer
Line 104: Line 100:
Begin ScriptEffectUpdate
Begin ScriptEffectUpdate


     if timer > 30     ;Creature is dead and fade timer passed
     if ( timer > 30 )    ;Creature is dead and fade timer passed
         ;Move our creature back to it's holding cell
         ;Move our creature back to its holding cell
        SUMN.kill
         SUMN.moveto CreatureCageREF 0 0 10  
         SUMN.moveto CreatureCageREF 0 0 10  
         ;Reset our creature if dead
         ;Reset our creature if dead
Line 114: Line 111:


     ;Adjust timer state for early fade/disable upon death
     ;Adjust timer state for early fade/disable upon death
     if SUMN.getdead && timer < 28                 
     if ( SUMN.getdead == 1 ) && ( timer < 28 )                
         set timer to 28
         set timer to 28
     endif
     endif


     if timer > 0.1 && playonce == 0
     if ( timer > 0.1 ) && ( playonce == 0 )
         ;Play effect for creature entrance
         ;Play effect for creature entrance
         SUMN.pms effectSummonMythicDawn 1             
         SUMN.pms effectSummonMythicDawn 1             
Line 124: Line 121:
     endif
     endif


   
     ;Increment timer
     ;Increment timer
     set timer to timer + ScriptEffectElapsedSeconds        
     set timer to timer + GetSecondsPassed        


     if timer > 28 && playonce == 1
 
     if ( timer > 28 ) && ( playonce == 1 )
         ;Play effect for creature exit/death
         ;Play effect for creature exit/death
         SUMN.pms effectSummonMythicDawn 2            
         SUMN.kill            
         set playonce to 2
         set playonce to 2
     endif
     endif


     if playonce == 2     
     if ( playonce == 2 )    
         ;Fade creature for exit/death                                             
         ;Fade creature for exit/death                                             
         set fade to fade - 0.03
         set fade to fade - 0.03
Line 144: Line 143:
Begin ScriptEffectFinish
Begin ScriptEffectFinish


     ;Move our creature back to it's holding cell
     ;Move our creature back to its holding cell
     SUMN.moveto CreatureCageREF 0 0 10     
     SUMN.moveto CreatureCageREF 0 0 10     
     ;Reset our creature if dead                         
     ;Reset our creature if dead                         
Line 153: Line 152:
End
End
</pre>
</pre>
* Change the script type to “Magic Effect” in the drop-down and change the name if desired.
* Change the script type to “Magic Effect” in the drop-down and change the name if desired.
* Click the “'''Disk'''” icon (Save) when done, and exit the Script Editor.
* Click the “'''Disk'''” icon (Save) when done, and exit the Script Editor.


===Step 5: The Spell!===
==Step 5: The Spell!==
</p><p>
<hr>
Now we put it all together. The script will simulate the summon effect, while the “Follow” package will make the new creature follow and fight for you.
Now we put it all together. The script will simulate the summon effect, while the “Follow” package will make the new creature follow and fight for you.


* In the '''Object Window''', expand '''Magic->Spells'''. Right-click on a spell name and select '''New'''.
* In the '''Object Window''', expand '''Magic->Spells'''. Right-click on a spell name and select '''New'''.
* Give your spell a unique id like “'''''SummonRatCast'''''”. Name the spell as desired, and select the type of spell (Spell, Lesser Power, or Power).
* Give your spell a unique ID like “'''''SummonRatCast'''''”. Name the spell as desired, and select the type of spell (Spell, Lesser Power, or Power).("spell" is Recommended)
* Click on “'''Script Effect Always Applies'''” and deselect “'''Auto-Calculate'''”.
* Click on “'''Script Effect Always Applies'''” and deselect “'''Auto-Calculate'''”.
* Choose the minimum skill and set the cost if a Spell or LP.
* Choose the minimum skill and set the cost to 0 and the charge to 0 if a Spell or LP.
* Right-click under “'''Effect Name'''” and select '''New'''.
* Right-click under “'''Effect Name'''” and select '''New'''.
* Select “'''Script Effect'''” under the Effect drop-down, and set the spell length to 30. (see the script notes on adjusting the spell length)
* Select “'''Script Effect'''” under the Effect drop-down, and set the effect's duration to 30 (see the script notes on adjusting the spell length).
* Select your script from the script menu, and give the effect a name like “'''Summon Creature'''”.
* Select your script from the script menu, and give the effect a name like “'''Summon Creature'''”.
* Finally, set the school to “'''Conjuration'''” and choose one of the default Summon spells for the Visual Effect.
* Finally, set the school to “'''Conjuration'''” and choose one of the default Summon spells for the Visual Effect.
* Click '''Ok''' twice when done to exit the spell editor.
* Click '''Ok''' twice when done to exit the spell editor.


===Step 6: Getting your spell into the world.===
==Step 6: Getting your spell into the game==
</p><p>
<hr>
Adapted from [[Scripting Tutorial: My First Spell]].
Adapted from [[Scripting Tutorial: My First Spell]].
====Find the Form ID====
Go to the top of the spell list and find the "Count" column. Directly to the left of this column, you should see a double column line instead of the usual single line. Click and drag the right line of these double lines to the right to expand the "[[FormID]]" column. Now, scroll down and find the spell you just added. Write down the number in the Form Id column. It should look something like "01000ED9". (but may not be exactly that)
====Save====
This is important!


Choose File->Save from the menubar. If you were editing a new plugin, you will be prompted for a filename. Choose something memorable like "'''''Summon Rat Spell'''''".
===Setting Spell For Sale===
====Testing====
Go to the object window. Maximize Actors, NPC, and Breton. Select male. click on a name listed and type (ed) quickly. Right click on EdgarVautrine, click Edit. Select the tab called spelllist. Do Not Close, go to object window maximize spells. Look for the spell you created. Move it to the EdgarVautrine spelllist. Click ok.
Go ahead and start Oblivion up. When the launcher comes up, click on the "Data Files" button. Make sure that "Oblivion.esm" and the filename you chose earlier are the only entries checked. Click "OK"


Click "Play"
===Find the Form ID (Not Necessary)===
Go to the top of the spell list and find the "Count" column. Directly to the left of this column, you should see a double column line instead of the usual single line. Click and drag the right line of these double lines to the right to expand the "[[FormID]]" column. Now, scroll down and find the spell you just added. Write down the number in the Form Id column. It should look something like "01000ED9" (but may not be exactly that).


Start a new game or load up a save file.
===Save===
This is important!


Once you are actually playing, bring up the console by hitting the ~ key, and type the following:
Choose File->Save from the menubar. If you were editing a new plugin, you will be prompted for a filename. Choose something memorable like "'''''Summon Rat Spell'''''".
 
<pre>player.addspell <formId></pre>


where <formId> is the formId for the spell. (You did write it down, right?)
===Testing===
Go ahead and start Oblivion up. When the launcher comes up, click on the "Data Files" button. Make sure that "Oblivion.esm" and the filename you chose earlier are both checked. Click "OK"


It should look something like:
Teleport to The Imperial City Market District. Go to Edgar's Discount Spells. Buy The Spell From Edgar. If you followed the tutorial the cost of Buying the spell from Edgar should be $0.
<pre>player.addspell 01000ED9</pre>


If all goes well, a message will appear notifying you that "(your spell name)" was added. Choose this spell from your spellbook and cast it.
Choose this spell from your spellbook and cast it.


You should now have a Rat following you!
You should now have a Rat following you!

Latest revision as of 01:07, 24 November 2011


Tools used in this tutorial

Required


This tutorial will help you set up a custom Summon Creature spell using the Script Effect system. This is a complete tutorial starting at the basics.

This will not change any game play settings or magic effects.

What you will do[edit | edit source]

This tutorial will show you how to:

  • Create a simple holding cell
  • Create persistent references: one for a MoveTo marker and one for your creature
  • Create a Follow AI Package
  • Configure a creature to be "summoned"
  • Add a script to perform the "summon" effect
  • Create a new spell with the scripted "summon" effect

Step 1: Create a holding cell for your creatures[edit | edit source]

  • Open the World-> Cells menu and make sure the drop-down menu is set on Interiors.
  • Right-click on a cell name and select New. Make sure your ID is something unique you can remember.
  • Click Ok when done, and Ok again to close the menu.
  • Double-click on your Interior under the Cell View listing. You will now drag in an anchor reference to move the creature back to the cell.
  • In the Object Window, expand World Objects -> Static, and click on Architecture.
  • Drag an interior such as “AnvilHouseMCInterior01” into the Render Window.
  • Right-click on the architecture object in the Cell View Window listing, and select Edit.
  • Enter a name for the reference such as “CreatureCageREF”,Set the Location to (0,0,10), select “Persistent Reference” and click Ok.

Step 2: Choose an AI follow package[edit | edit source]

There is a default “FollowPlayerAI package, but it does not allow for swimming, falls, etc. You can use the steps below to create a custom package, or skip to Step 3.

Packages01.jpg

  • Enter a unique name for you package that you can remember.
  • Select “Must Complete” and “Defensive Combat” at a minimum; “Allow Swimming” and “Allow Falls” are optional. The other options are more for NPCs than creatures.
  • Change the Package Type drop-down to “Follow”.
  • Click on the Target tab and select “Specific Reference”.
  • Choose the Cell “AbandonedMine02” and the Ref “Player PlayerRef”.
  • Set the distance the creature can be from you: recommend 128.

Packages02.jpg

  • Click OK when done.

Step 3: The Critter![edit | edit source]

You will now change a normal creature into your summon version. I recommend editing an existing creature to ensure proper animation and models. For this example, I picked a Rat.

  • In the Object Window, expand Actors->Creatures->Creatures. Scroll down to CreatureRat and double-click to open the properties window.
  • Change the ID to “RatSummon01”, and the Name to “Summoned Rat”.
  • Uncheck the “Respawn” box so we can control the resurrection from script.
  • Click on the AI button to open the AI Object Dialog.

AIMenu01.jpg

  • Set the “Aggression” to five(so if a friend of the creature or the creature itself is attacked, it will attack the posing threat) and delete any existing packages by selecting them in the list and pressing delete.
  • Open the Character->Packages menu and drag either the “FollowPlayer” package, or a custom one made in step 2 into the AI menu.
  • Click Save to close the menu. You can also close the Packages menu.
  • Select the “Factions” tab and delete any existing factions(Not Required If NPC is Special). Open the Character->Factions menu and drag over the “PlayerFaction”.
  • Click Ok and answer “Yes” to create a new form.
  • Drag your new creature into the Interior you created. Set the Location to (0,0,10). Edit the creature reference just like the architecture piece and enter the reference editor ID “SummonRat1REF”.
  • Select “Persistent Reference” and “Initially Disabled”. This ensures our creature is always available, but not moving around or running AI yet.
  • Click Ok when done.

Step 4: Creating the script effect[edit | edit source]

This script uses the MoveTo command to perform the actual summoning of the creature to the player. The remaining code is for visual effects and placement of the creature back in the holding cell when done, or dead.

  • Open the Gameplay->Edit Scripts menu and click Scripts->New.
  • Copy the script and paste into the editor window. Be sure to change the reference names if different from the tutorial (lines 14, 33, and 74). These lines contain 3 numbers (0,0,10) which is the location of the reference, you can switch the reference location, but you must also switch the script location reference.
ScriptName SummonRatSCR

;This script can be used as a template for custom summoned creatures/NPCs

float timer
float fade
short playonce
ref SUMN

Begin ScriptEffectStart

;Set temp reference for scripting. 
;Allows faster transition of script as template. Also allows for leveled summon.
    set SUMN to SummonRat1REF
    ;Reset our creature if re-summoned before time runs out on spell                                            
    SUMN.disable        

    ;Now we move our creature to the Player
    ;Move the creature reference to the worldspace of the Player
    SUMN.moveto Player 30 30 10    
    ;Make our creature visible and active    
    SUMN.enable                        

    set fade to 1    ;Resets the alpha fade variable to 1

End

Begin ScriptEffectUpdate

    if ( timer > 30 )    ;Creature is dead and fade timer passed
        ;Move our creature back to its holding cell
        SUMN.kill
        SUMN.moveto CreatureCageREF 0 0 10 
        ;Reset our creature if dead
        SUMN.resurrect    
        ;Set our creature to an unprocessed state                            
        SUMN.disable                                    
    endif

    ;Adjust timer state for early fade/disable upon death
    if ( SUMN.getdead == 1 ) && ( timer < 28 )                
        set timer to 28
    endif

    if ( timer > 0.1 ) && ( playonce == 0 )
        ;Play effect for creature entrance
        SUMN.pms effectSummonMythicDawn 1            
        set playonce to 1
    endif

    
    ;Increment timer
    set timer to timer + GetSecondsPassed        


    if ( timer > 28 ) && ( playonce == 1 )
        ;Play effect for creature exit/death
        SUMN.kill            
        set playonce to 2
    endif

    if ( playonce == 2 )    
        ;Fade creature for exit/death                                            
        set fade to fade - 0.03
        SUMN.saa fade
    endif
        

End

Begin ScriptEffectFinish

    ;Move our creature back to its holding cell
    SUMN.moveto CreatureCageREF 0 0 10    
    ;Reset our creature if dead                        
    SUMN.resurrect        
    ;Set our creature to an unprocessed state                                        
    SUMN.disable                                                    

End
  • Change the script type to “Magic Effect” in the drop-down and change the name if desired.
  • Click the “Disk” icon (Save) when done, and exit the Script Editor.

Step 5: The Spell![edit | edit source]

Now we put it all together. The script will simulate the summon effect, while the “Follow” package will make the new creature follow and fight for you.

  • In the Object Window, expand Magic->Spells. Right-click on a spell name and select New.
  • Give your spell a unique ID like “SummonRatCast”. Name the spell as desired, and select the type of spell (Spell, Lesser Power, or Power).("spell" is Recommended)
  • Click on “Script Effect Always Applies” and deselect “Auto-Calculate”.
  • Choose the minimum skill and set the cost to 0 and the charge to 0 if a Spell or LP.
  • Right-click under “Effect Name” and select New.
  • Select “Script Effect” under the Effect drop-down, and set the effect's duration to 30 (see the script notes on adjusting the spell length).
  • Select your script from the script menu, and give the effect a name like “Summon Creature”.
  • Finally, set the school to “Conjuration” and choose one of the default Summon spells for the Visual Effect.
  • Click Ok twice when done to exit the spell editor.

Step 6: Getting your spell into the game[edit | edit source]

Adapted from Scripting Tutorial: My First Spell.

Setting Spell For Sale[edit | edit source]

Go to the object window. Maximize Actors, NPC, and Breton. Select male. click on a name listed and type (ed) quickly. Right click on EdgarVautrine, click Edit. Select the tab called spelllist. Do Not Close, go to object window maximize spells. Look for the spell you created. Move it to the EdgarVautrine spelllist. Click ok.

Find the Form ID (Not Necessary)[edit | edit source]

Go to the top of the spell list and find the "Count" column. Directly to the left of this column, you should see a double column line instead of the usual single line. Click and drag the right line of these double lines to the right to expand the "FormID" column. Now, scroll down and find the spell you just added. Write down the number in the Form Id column. It should look something like "01000ED9" (but may not be exactly that).

Save[edit | edit source]

This is important!

Choose File->Save from the menubar. If you were editing a new plugin, you will be prompted for a filename. Choose something memorable like "Summon Rat Spell".

Testing[edit | edit source]

Go ahead and start Oblivion up. When the launcher comes up, click on the "Data Files" button. Make sure that "Oblivion.esm" and the filename you chose earlier are both checked. Click "OK"

Teleport to The Imperial City Market District. Go to Edgar's Discount Spells. Buy The Spell From Edgar. If you followed the tutorial the cost of Buying the spell from Edgar should be $0.

Choose this spell from your spellbook and cast it.

You should now have a Rat following you!