dfac364 Posted April 6, 2012 Share Posted April 6, 2012 So ive been trying to script an activator to (when activated) fire a spell at an "xmarker" unfortuantly i cant for the life of me get it right, I was able to find a template on the creation kit page page but i cant even get it to compile, if anyone can help me with this i would be ever greatfull. *Example Script to make an item cast a spell Scriptname SpellZapScript extends ObjectReference import Utility 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 = 0.0 Auto{Randomness applied to X Offset} Float Property RandomOffsetY = 0.0 Auto{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 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() if SpawnNode && !CurrentTarget CurrentTarget = PlaceAtme(TargetType,1) CurrentTarget.MoveTo(Self,XOffSet,YOffSet,ZOffSet) endif RegisterForSingleUpdate(PulseRate)EndEvent Event OnUpdate() if !SpawnNode CurrentTarget = Game.FindClosestReferenceOfAnyTypeInListfromRef(TargetTypeList,Self,SeekRange) ; find something nearby to shoot at if we're not making our own target. if !TargetTypeList && GetDistance(Player) < SeekRange ; No list given, Default to the player. CurrentTarget = Game.GetPlayer() endif else CurrentTarget.MoveTo(Self, XOffSet+(RandomFloat(0.0,RandomOffsetX)-RandomOffsetX/2 ), \ YOffSet+(RandomFloat(0.0,RandomOffsetY)-RandomOffsetY/2), \ ZOffSet+(RandomFloat(0.0,RandomOffsetZ)-RandomOffsetZ/2)) endif Zap.Cast(Self,CurrentTarget) RegisterForSingleUpdate(PulseRate+RandomFloat(0.0,RandomRate))EndEvent How to make this script work: Put it on the object you want the spells to originate from, and set the properties to define it's 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. Link to comment Share on other sites More sharing options...
fg109 Posted April 6, 2012 Share Posted April 6, 2012 Change this line: if !TargetTypeList && GetDistance(Player) < SeekRange ; No list given, Default to the player. to this: if !TargetTypeList && GetDistance(Game.GetPlayer()) < SeekRange ; No list given, Default to the player. I will edit the wiki to fix it. Link to comment Share on other sites More sharing options...
dfac364 Posted April 6, 2012 Author Share Posted April 6, 2012 Change this line: if !TargetTypeList && GetDistance(Player) < SeekRange ; No list given, Default to the player. to this: if !TargetTypeList && GetDistance(Game.GetPlayer()) < SeekRange ; No list given, Default to the player. I will edit the wiki to fix it. i really appreciate your help but its still not working presumably because of my ineptitude with scripting, im just trying to get an activator to fire a conjure spell at an xmarker and this is what im trying to use if you could help me out that would be awesome, it keeps telling me (5,27): no viable alternative at input '(' Scriptname fff extends ObjectReference import Utility Float Property PulseRate = (1.0) {How often do we shoot?} Activator Property TargetType (xmarker) {What type of object are we zapping if we're spawning a node?} ObjectReference Property CurrentTarget (LinkedRef) {The actual target we're shooting at} Bool Property SpawnNode == TRUE Spell Property Zap (ConjureDremoraLord){What spell shall we use for the effect?} Event OnInit() if SpawnNode && !CurrentTarget CurrentTarget = PlaceAtme(xmarker,1) endif RegisterForSingleUpdate(PulseRate)EndEvent Event OnUpdate() if !SpawnNode CurrentTarget = Game.FindClosestReferenceOfAnyTypeInListfromRef(TargetTypeList,Self,SeekRange) ; find something nearby to shoot at if we're not making our own target. if !TargetTypeList && GetDistance(Game.GetPlayer()) < SeekRange ; No list given, Default to the player. CurrentTarget = Game.GetPlayer() endif Zap.Cast(Self,CurrentTarget) RegisterForSingleUpdate(PulseRate+RandomFloat(0.0,RandomRate)) endifEndEvent Link to comment Share on other sites More sharing options...
fg109 Posted April 6, 2012 Share Posted April 6, 2012 (edited) You left out all the auto's this time. You're supposed to be setting the properties outside of the script. http://www.creationkit.com/Bethesda_Tutorial_Papyrus_Introduction_to_Properties#Hooking_up_the_message_boxes_to_the_properties_in_the_script Edited April 6, 2012 by fg109 Link to comment Share on other sites More sharing options...
dfac364 Posted April 6, 2012 Author Share Posted April 6, 2012 You left out all the auto's this time. You're supposed to be setting the properties outside of the script. http://www.creationkit.com/Bethesda_Tutorial_Papyrus_Introduction_to_Properties#Hooking_up_the_message_boxes_to_the_properties_in_the_script so i leave the lines before the EVENT as they where and than edit them as properties? sorry if im not getting this most of what i know about scripts i got from looking at existing ones and tweaking them Link to comment Share on other sites More sharing options...
fg109 Posted April 6, 2012 Share Posted April 6, 2012 Editing the properties in the script itself would set those values as the default values, but they will be overridden by the values you set outside of the script. Also, you can only set default values for bool, int, and float variables. Scripts are external from a mod itself. So if you want to reference anything from the esm or esp (eg X marker, ConjureDremoraLord) you will need to use properties and set the values of the properties from outside of the script. Link to comment Share on other sites More sharing options...
dfac364 Posted April 6, 2012 Author Share Posted April 6, 2012 Editing the properties in the script itself would set those values as the default values, but they will be overridden by the values you set outside of the script. Also, you can only set default values for bool, int, and float variables. Scripts are external from a mod itself. So if you want to reference anything from the esm or esp (eg X marker, ConjureDremoraLord) you will need to use properties and set the values of the properties from outside of the script. okay thank you very much i think i understand now, did everything else look alright though? as far as the event script Link to comment Share on other sites More sharing options...
fg109 Posted April 6, 2012 Share Posted April 6, 2012 If you copied exactly what was on the wiki, then yes. The only problem was that one line where 'Player' was used instead of 'Game.GetPlayer()'. Link to comment Share on other sites More sharing options...
dfac364 Posted April 6, 2012 Author Share Posted April 6, 2012 If you copied exactly what was on the wiki, then yes. The only problem was that one line where 'Player' was used instead of 'Game.GetPlayer()'. thank you very much Link to comment Share on other sites More sharing options...
dfac364 Posted April 6, 2012 Author Share Posted April 6, 2012 (edited) its going off rapid fire instead of just once and its firing on itself, i changed the pulse rate around and tried using random cooridnates and different types of activators it didnt make a difference any ideas? Edited April 6, 2012 by dfac364 Link to comment Share on other sites More sharing options...
Recommended Posts