Editing
Complete Example Scripts
(section)
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
= Script to make an item cast a spell = <syntaxhighlight lang="Papyrus">Scriptname SpellZapScript extends ObjectReference import Utility Actor Property PlayerREF Auto Float Property xOffset Auto ; Relative X position for the target Float Property yOffset Auto ; Y Offset for Target Float Property zOffset Auto ; Z offset for Target Float Property RandomOffsetX Auto ; Randomness applied to X Offset. Initializes at 0. Float Property RandomOffsetY Auto ;Randomness applied to Y Offset. Initializes at 0. 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 RandomRate 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 Auto ; Do we spawn a target? If not, zap the nearest valid target. Initializes 'False' 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() if CurrentTarget ;!= None elseIf SpawnNode float newXOffset = XOffSet + RandomFloat(-RandomOffsetX, RandomOffsetX) float newYOffset = YOffSet + RandomFloat(-RandomOffsetY, RandomOffsetY) float newZOffset = ZOffSet + RandomFloat(-RandomOffsetZ, RandomOffsetZ) CurrentTarget = PlaceAtme(TargetType) CurrentTarget.MoveTo(Self, newXOffSet, newYOffSet, newZOffSet) endif RegisterForSingleUpdate(PulseRate) EndEvent Event OnUpdate() ; find something nearby to shoot at if we're not making our own target. if !SpawnNode && !TargetTypeList && GetDistance(PlayerREF) < SeekRange ; No list given, Default to the player if he is in range. CurrentTarget = PlayerREF elseif TargetTypeList CurrentTarget = Game.FindClosestReferenceOfAnyTypeInListfromRef(TargetTypeList, Self, SeekRange) endif if CurrentTarget ; it's possible that there is no target Zap.Cast(Self,CurrentTarget) endif RegisterForSingleUpdate(PulseRate + RandomFloat(0.0, RandomRate)) EndEvent </syntaxhighlight> How to make this script work: *Put it on the object you want the spells to originate from, and set the properties to define its exact desired behavior. *Pick any spell you want for the property Zap (needs to be of the Aimed spell type) *If you want it to just shoot at a specific spot, define the Spawn Node Type as an xmarker, set SpawnNode to "True", and enter the relative coordinates you want the spell to be aimed at. *If you want it to look for targets nearby, set SpawnNode to false and put a formlist of the valid targets in the TargetTypeList. If no Formlist is given, it will default to trying to shoot the player.
Summary:
Please note that all contributions to the CreationKit Wiki are considered to be released under the Creative Commons Attribution-ShareAlike (see
CreationKit:Copyrights
for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource.
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Navigation menu
Personal tools
Not logged in
Talk
Contributions
Create account
Log in
Namespaces
Page
Discussion
English
Views
Read
Edit
Edit source
View history
More
Search
Navigation
Landing page
Tutorials
Game Systems
Editor Reference
Scripting Reference
Recent changes
Help
Tools
What links here
Related changes
Special pages
Page information
Page values