mmft93 Posted October 16, 2016 Share Posted October 16, 2016 I'm in the process of making a mod that lets you play as the Forest Sprite race. They are a race of people that live in the forest and know a handful of useful nature magic. a link to the mod page http://www.nexusmods.com/skyrim/mods/79450/? However some spells that I have in mind I know are going to require me to write scripts. I've read so many tutorials and the wiki and watched youtube videos I'm still some what lost however, so I thought I'd turn to the forums for help or at least some guidance. For starters I cant get notepad to compile my scripts at all it keeps saying error path not found I copied the path on wiki exactly though. Spell Ideas: 1. A weather spell that changes the weather granting different buffs like increased health and magicka that sort of thing. In my research I've come up with this script Scriptname NatureWeatherSpell extends ActiveMagicEffectEvent OnEffectStart(Actor Target, Actor Caster)Weather spellWeather = Weather.FindWeather(0)spellWeather.ForceActive(true)endeventEvent OnEffectFinish(Actor akTarget, Actor akCaster) Debug.Trace("Magic effect fades from " + akTarget Weather.ReleaseOverride() endevent what do you guys think? 2. A spell that summons a tree the tree casts an area spell to calm all enemies and heal the player periodically. a permanent version and one that last say 30 seconds or so. I don't have any idea how to write this script as of yet. Link to comment Share on other sites More sharing options...
didiusdeddysalam Posted October 16, 2016 Share Posted October 16, 2016 maybe you should make two scripts....the object script & the spell script for the activator(make your tree as an activator so you can put script in it...) this thing I know from Oblivion scripting...I don't really familiar with Skyrim scripting....so I'm so sorry if I cannot be much help for you... Link to comment Share on other sites More sharing options...
mmft93 Posted October 16, 2016 Author Share Posted October 16, 2016 Ok I think I understand what your saying. The Object script would then place the tree (the activator) and then the activator script would than cast the spell I want right? Link to comment Share on other sites More sharing options...
mmft93 Posted October 16, 2016 Author Share Posted October 16, 2016 I managed to make the spell summon the activator aka the tree but i cant make the activator cast the spell here's the script I've written I'm not sure what I'm missing ScriptName SacredTreeSpellCast extends Activatorspell property myspell autoActivator property myActivator autoActivator property akactionref autoActivator property akSource autoActivator property akTarget autoFunction Cast(ObjectReference akSource, ObjectReference akTarget = None) nativeendfunctionEvent OnActivate(ObjectReference akActionRef) mySpell.cast(myActivator, myActivator)EndEvent Link to comment Share on other sites More sharing options...
IsharaMeradin Posted October 16, 2016 Share Posted October 16, 2016 (edited) Drop the whole Cast function definition. You do not need to redefine it. It is already defined on the Spell script. The proper use in pseudo code is as follows: My spell.Cast(The object to cast my spell, The object to be hit by my spell)Putting that into real code: mySpell.Cast(myActivator,myActivator)You also do not need to make property definitions for akSource, akTarget, or akActionref. These are variables that are filled with data by the game engine when the event is ran or passed into to function by calling it. Example:Cast - if you use myActivator as both the target and the source, then you are telling the Cast function that akSource = myActivator and akTarget = myActivator.When one object activates another the one that does the activating is passed into the akActionref variable. This is why you can prevent NPCs from activating custom objects by using If akActionref == Game.GetPlayer()The now modified script should be as follows: ScriptName SacredTreeSpellCast extends Activator spell property myspell auto Activator property myActivator auto Event OnActivate(ObjectReference akActionRef) mySpell.cast(myActivator, myActivator) EndEvent Make sure that you assign the correct data to the properties when you fill them. You highlight the script on the object it is attached to, press the properties button and use the new window that appears to assign the objects that you want. If you use the Editor ID name as the variable name on the script then you can use the auto-fill feature. EDIT: spelling/grammar Edited October 16, 2016 by IsharaMeradin Link to comment Share on other sites More sharing options...
mmft93 Posted October 16, 2016 Author Share Posted October 16, 2016 (edited) Thank you IsharaMeradin I'm going to give it a try now. It might be a little to much for me but i was wondering is there any way to make an activator activate on its on like say the npc and the pc only have to get near it for it to activate? ok i tried it here's my new script ScriptName SacredTreeSpellCast extends Activatorspell property myspell autoActivator property myActivator autoEvent OnActivate(ObjectReference akActionRef) If akActionref == Game.GetPlayer() endif mySpell.cast(myActivator, myActivator)EndEvent however when i try to compile it it says error type mismatch on parameter 1 (did you forget a cast)I'm not to sure what it means by this looking on the wiki its talking about useing a magic procedure but that looks like its for npc's not activators I'm really confused now :( Edited October 16, 2016 by mmft93 Link to comment Share on other sites More sharing options...
IsharaMeradin Posted October 16, 2016 Share Posted October 16, 2016 The compiler error is complaining about the parameters in the Cast function. You have assigned the base Activator object as the property and are trying to pass that in as an ObjectReference. If you are wanting to refer to the object holding the script and pass that object into another function you can take advantage of the Self variable that is available to every script. ScriptName SacredTreeSpellCast extends Activator ;can try extending ObjectReference if need be spell property myspell auto Event OnActivate(ObjectReference akActionRef) If akActionRef == Game.GetPlayer() ; only the player can activate this ObjectRefence SelfObj = Self ; if it complains about using self alone cast it by adding 'as ObjectReference' after Self mySpell.cast(SelfObj, SelfObj) EndIf EndEvent If you want something to happen when the player or an NPC gets near, you'll need to use a trigger volume box that surrounds the object and the distance away from it that you want it to take affect. Then you'd have a script on that trigger volume box which activates your object. However, you could simply use the trigger volume box's script to do all the work rather than having it trigger the object in the middle. But if you want it to be tied to something that appears when you cast a spell, you'll need to have at least one instance of the trigger volume box at the size that you want tucked away in custom inaccessible cell and use the MoveTo function to move it from the start location to the new location. But that can get tricky as you need to keep track of where it is in order to move it around each time the spell is used. Perhaps such an idea is best for your permanent variation. That way you can limit the player to using a certain number and each instance cast has its own trigger volume box pre-set in size. Usually, trigger boxes are used for fixed items so that properties or links between pre-placed references can be set up. Not saying that it is impossible to use it in a movable setting, just that it may require a lot of testing to get working and keep working. One thing I am a bit confused about. Why are you having the object cast the spell at itself? Is it that the spell already has an effect which radiates out and affects whatever it touches and so you want it to be centered at the object? Link to comment Share on other sites More sharing options...
mmft93 Posted October 16, 2016 Author Share Posted October 16, 2016 (edited) My idea for this script was to create a spell that would summon a Tree (my activator). The Tree would have magical properties though and would calm all npc's who came near it and also heal the player and the player's allies. So I was thinking having that activator cast the illusion spell pacify to calm everybody around it that's why i was having it target its self. The trigger box does seem complicated to set up what about if I made a spell that can activate the tree like a remote detonator. I just don't want the player to always have to walk up to the tree and detonate it. thank you for helping me by the way I did like you saidmy new script: ScriptName SacredTreeSpellCast extends ObjectReferencespell property myspell autoEvent OnActivate(ObjectReference akActionRef) If akActionRef == Game.GetPlayer() ; only the player can activate this ObjectReference SelfObj = Self as ObjectReference mySpell.cast(SelfObj, SelfObj) EndIfEndEvent And it worked! :) thanks a bunch now my summoned tree's are casting the calm spell to enemies when activated. only thing is I'm not sure I want to have to run to the tree's each time to cast it. Now the goal is to find a way to activate them remotely. I'm thinking a spell that when it hits an activator activates it. Edited October 17, 2016 by mmft93 Link to comment Share on other sites More sharing options...
IsharaMeradin Posted October 16, 2016 Share Posted October 16, 2016 Another possibility is to have a targeted spell that the player can cast at the tree. Idea being that the player has to recharge the tree in order for it to perform its magics. The script on the tree would use the OnHit event with a condition for the projectile hitting it to be the one from the spell that the player cast. When it matches, activate the tree's area of effect spell. Link to comment Share on other sites More sharing options...
mmft93 Posted October 17, 2016 Author Share Posted October 17, 2016 I tried creating the OnHit event like you suggested: ScriptName SacredTreeSpellCast2 extends ObjectReferencespell property myspell autoprojectile property spellprojectile autoEvent Onhit(ObjectReference akActionRef, Projectile akProjectile) If akProjectile == spellprojectile ObjectReference SelfObj = Self as ObjectReference mySpell.cast(SelfObj, SelfObj) EndIfEndEvent but now when I try to compile it says doesn't match the parent script ObjectReference so i changed the extends to Form and then I get the error can not cast on ObjectReference so than I tried putting both but it still said error ( not sure if that's even allowed having more than one extends) Link to comment Share on other sites More sharing options...
Recommended Posts