Complete Example Scripts: Difference between revisions

Jump to navigation Jump to search
m
→‎Script to make an item cast a spell: Condensed properties, optimized slightly via removal of unnecessary '&&'
imported>Sollar
imported>JustinOther
m (→‎Script to make an item cast a spell: Condensed properties, optimized slightly via removal of unnecessary '&&')
Line 583: Line 583:


= Script to make an item cast a spell =
= Script to make an item cast a spell =
 
<Source lang="Papyrus">Scriptname SpellZapScript extends ObjectReference   
<Source lang="Papyrus">
Scriptname SpellZapScript extends ObjectReference   


import Utility
import Utility
 
Float Property xOffset Auto ; Relative X position for the target
Float Property xOffset Auto
Float Property yOffset Auto ; Y Offset for Target
{Relative X position for the target}
Float Property zOffset Auto ; Z offset for Target
 
Float Property RandomOffsetX Auto ; Randomness applied to X Offset. Initializes at 0.
Float Property yOffset Auto
Float Property RandomOffsetY Auto ;Randomness applied to Y Offset. Initializes at 0.
{Y Offset for Target}
Float Property RandomOffsetZ Auto ; Randomness applied to Z Offset. Initializes at 0.
 
Float Property PulseRate = 1.0 Auto ; How often do we shoot?
Float Property zOffset Auto
Float Property RandomRate Auto ; Add random delay to pulse rate, capped at this value
{Z offset for Target}
Activator Property TargetType Auto ; What type of object are we zapping if we're spawning a node?
 
ObjectReference Property CurrentTarget Auto ; The actual target we're shooting at
Float Property RandomOffsetX = 0.0 Auto
Bool Property SpawnNode Auto ; Do we spawn a target? If not, zap the nearest valid target. Initializes 'False'
{Randomness applied to X Offset}
Spell Property Zap Auto ; What spell shall we use for the effect?
 
FormList Property TargetTypeList Auto ; List of potential targets
Float Property RandomOffsetY = 0.0 Auto
Float Property SeekRange = 1000.0 Auto ; The range it will "Lock into" a target if not making a node.
{Randomness applied to Y Offset}
 
Float Property RandomOffsetZ = 0.0 Auto
{Randomness applied to Z Offset}
 
Float Property PulseRate = 1.0 Auto
{How often do we shoot?}
 
Float Property RandomRate = 0.0 Auto
{Add random delay to pulse rate, capped at this value}
 
Activator Property TargetType Auto
{What type of object are we zapping if we're spawning a node?}
 
ObjectReference Property CurrentTarget Auto
{The actual target we're shooting at}
 
Bool Property SpawnNode = false  Auto
{Do we spawn a target? If not, zap the nearest valid target.}
 
Spell Property Zap Auto
{What spell shall we use for the effect?}
 
FormList Property TargetTypeList Auto
{List of potential targets}
 
Float Property SeekRange = 1000.0 Auto
{The range it will "Lock into" a target if not making a node.}


Event OnInit()
Event OnInit()
Line 635: Line 605:
     float newYOffset = YOffSet + RandomFloat(0.0, RandomOffsetY / 2)
     float newYOffset = YOffSet + RandomFloat(0.0, RandomOffsetY / 2)
     float newZOffset = ZOffSet + RandomFloat(0.0, RandomOffsetZ / 2)
     float newZOffset = ZOffSet + RandomFloat(0.0, RandomOffsetZ / 2)
     if SpawnNode && !CurrentTarget
     if CurrentTarget ;!= None
    elseIf SpawnNode
         CurrentTarget = PlaceAtme(TargetType)
         CurrentTarget = PlaceAtme(TargetType)
         CurrentTarget.MoveTo(Self, newXOffSet, newYOffSet, newZOffSet)
         CurrentTarget.MoveTo(Self, newXOffSet, newYOffSet, newZOffSet)
Anonymous user

Navigation menu