Difference between revisions of "Casting Spells From An Activator"

Updated to use MoveTo instead of PlaceAtMe
imported>Ukgazzer
imported>Haama
(Updated to use MoveTo instead of PlaceAtMe)
Line 17: Line 17:
The first thing we need to do is create the activator object. This object will be used to cast spells.
The first thing we need to do is create the activator object. This object will be used to cast spells.


In the [[Object_Window|Object Window]], Expand the WorldObjects item and select Activator. Right-click in the object list to the right and select "New" from the context menu that pops up.
In the [[Object_Window|Object Window]], Expand the WorldObjects item and select Activator. Rename the activator with the Editor ID "ActivatorFlameNode0" to "SourceID" by slowly double-clicking on it, changing the name, and selecting "Yes" when the menu comes up.


Set these fields:
We also need to create a reference of the new activator. In the [[Cell View Window]], select "Interior" from the pull-down menu. Then select the Editor ID "TestQuest01" in the box on the left. Right-click it and select "Duplicate Cell". Rename the cell to something you'll remember and double-click it to open it in the [[Render Window]]. Now, drag your new [[Activator]] "SourceID" to the [[Render Window]]. Double-click on the activator to open the "Reference" window. Name it "Source" in the "Reference Editor ID" box. Mark it as a "Persistent Reference" and "Initially Disabled".
*<b>ID:</b> Set this to "ActivatorSource"
*<b>NIF:</b> Set this to "magiceffects\null.nif" (This makes the activator invisible)
 
Leave the rest of the fields alone and click "OK".


==Create the Spells==
==Create the Spells==
Line 53: Line 49:


===The Self Spell Script===
===The Self Spell Script===
This script uses [[PlaceAtMe]] to create an activator and then uses that activator to [[Cast]] the AOE spell.
This script uses [[MoveTo]] to move your activator to the caster and then uses that activator to [[Cast]] the AOE spell.


Set the <b>Script Type</b> to <b>Magic Effect</b>
Set the <b>Script Type</b> to <b>Magic Effect</b>
Line 67: Line 63:
;get a reference to the caster
;get a reference to the caster
set me to GetSelf
set me to GetSelf
;place an instance of the source activator that we created earlier
set source to me.PlaceAtMe ActivatorSource, 1, 0, 0


;add 200 to the height so it is above the actor
;add 200 to the height so it is above the actor
float height
source.MoveTo me 0, 0, 200
set height to me.GetPos z
set height to height + 200
source.SetPos z, height


;have the activator cast the AOE spell now
;have the activator cast the AOE spell now
source.Cast TutCallLightningAoeSpell me
source.Cast TutCallLightningAoeSpell me
;disable the activator so we don't have a bunch laying around
source.Disable
End</pre>
End</pre>


===The Area of Effect Spell Script===
===The Area of Effect Spell Script===
This script will be run on every actor that is hit by the TutCallLightningAoeSpell. This script will then create an activator using PlaceAtMe and use it to cast a lightning bolt at the affected actor. (Remember: This happens for each actor hit!)
This script will be run on every actor that is hit by the TutCallLightningAoeSpell. This script will then move the activator using [[MoveTo]] and use it to cast a lightning bolt at the affected actor. (Remember: This happens for each actor hit!)


Set the <b>Script Type</b> to <b>Magic Effect</b>
Set the <b>Script Type</b> to <b>Magic Effect</b>
Line 100: Line 87:
set me to GetSelf
set me to GetSelf


;place an instance of the source activator that we created earlier
;add 1000 to the height to simulate lightning coming from the sky
set source to me.PlaceAtMe ActivatorSource, 1, 0, 0
source.MoveTo me 0, 0, 1000
 
;add 1000 to the height so it looks like the lightning is coming from the sky
float height
set height to me.GetPos z
set height to height + 1000
source.SetPos z, height


;have the activator cast the lightning spell at the affected actor
;have the activator cast the lightning spell at the affected actor
source.Cast StandardShockDamageTarget1Novice me
source.Cast StandardShockDamageTarget1Novice me
;disable the activator so we don't have a bunch laying around
source.Disable
End</pre>
End</pre>
Instead of using the lines
<pre> 
        set source to me.PlaceAtMe ActivatorSource, 1, 0, 0
        float height
set height to me.GetPos z
set height to height + 1000
source.SetPos z, height
</pre>
an alternative is to place an example of the activator on the map,give it a unique name (eg 'source' in this case) and check the persistent reference box- This creates a single copy  of ActivatorSource in the game instead of creating new ones every time the spell is used with the placeatme command.Then replace these lines with
<pre>
        source.moveto me,0,0,1000
</pre>


==Attach the Scripts to the Spells==
==Attach the Scripts to the Spells==
Anonymous user