Jump to content

[LE] Scripting candlelight cast


Recommended Posts

Tried going after this a few times, i want my custom follower to cast candlelight when the light level reaches a certain darkness, and keep casting it after the spell runs out. SKSE code is available for use. SCRIPTING IS HARD OKAY?

Link to comment
Share on other sites

What I would do, is make a new global variable and a new spell ability with the conditions GetLightLevel < SomeAmount AND GetGlobalValue MyGlobalCheck == 0. Also duplicate the CandleLight spell and magic effect.

 

Put this script on the ability's magic effect:

 

 

 

Scriptname MyModCastLightScript extends ActiveMagicEffect 

Spell Property MyCandlelightCopySpell Auto 

Event OnEffectStart(Actor akTarget, Actor akCaster) 
    MyCandlelightCopySpell.Cast(akTarget)
EndEvent 

Put this script on your duplicate candlelight spell's magic effect:

Scriptname MyModCandleLightScript extends ActiveMagicEffect 

GlobalVariable Property MyGlobalCheck Auto

Event OnEffectStart(Actor akTarget, Actor akCaster)
    MyGlobalCheck.SetValue(1) 
EndEvent 

Event OnEffectFinish(Actor akTarget, Actor akCaster) 
    MyGlobalCheck.SetValue(0)
EndEvent  

As always, name the scripts and other properties something more unique to your mod.
Edited by dylbill
Link to comment
Share on other sites

Basically, you make a spell ability and put it on your follower. The spell has the condition GetLightLevel < SomeAmount. If that were the only condition, the magic effect would start as soon as the light level was below the certain amount. So the sequence would be, you go to a low light area, your follower would cast the candlelight spell from the script. If however, you went to a higher light area, and back to the low light area, the follower would cast the spell again, even if the candlelight spell was still active. Also, if you were still in a low light area, and the candlelight spell ends, the follower wouldn't cast it again until you went to a high light area, and again to a low light area. This is why the global variable is necessary.

 

With the second script I posted, it sets the MyGlobalCheck global variable to 1 when the candlelight effect starts, and 0 when it ends. So if you also have the condition GetGlobalValue MyGlobalCheck == 0 on the ability, and you are still in a low light area, the ability effect will start again, causing the follower to cast the candlelight spell again. Also he won't cast it again until the candlelight effect ends.

Link to comment
Share on other sites

I noticed you only have 1 candlelight script. For it to work, you need 2 scripts.

 

step by step instructions
1. In the CK under miscellaneous / Global make a new global variable and name it KoahniCandleLightCheckGV. Keep it on 'short' and set it to 0.
2. duplicate the magic effect LightFFSelf. Name it something unique. Compile and attach this script to it:

Scriptname KoahniCandlelightScript extends ActiveMagicEffect 

GlobalVariable Property KoahniCandleLightCheckGV Auto

Event OnEffectStart(Actor akTarget, Actor akCaster)
    KoahniCandleLightCheckGV.SetValue(1) 
EndEvent 

Event OnEffectFinish(Actor akTarget, Actor akCaster) 
    KoahniCandleLightCheckGV.SetValue(0)
EndEvent 

After attaching, click on Properties and then Auto Fill All.
3. Duplicate the vanilla CandleLight Spell. Name it KoahniCandlelightSpell. Delete the magic effect LightFFSelf from it, and put the duplicate magic effect you just made on it. Magnitue 5, duration 1m , which is the same as the vanilla spell.
4. make a new magic effect
Archetype: Script
Type: Constant Effect
Delivery: Self
With the No Hit Event, Painless and Hide in UI boxes checked.
Attach this script to it:

Scriptname KoahniCandlelightAbilityScript extends ActiveMagicEffect 

Spell Property KoahniCandlelightSpell Auto 

Event OnEffectStart(Actor akTarget, Actor akCaster) 
    KoahniCandlelightSpell.Cast(akTarget)
EndEvent 

Again after attaching click on Properties and then Auto Fill All.
Make a new spell - KoahniCandlelightAbility.
Type: Ability
Casting: Constant Effect
Delivery: Self.
Put the magic effect you just made above on it, with the condition GetLightLevel < SomeAmount, have it run on the player, and the condition GetGlobalValue KoahniCandleLightCheckGV == 0.
Give the KoahniCandlelightAbility to your follower by adding it to their spells list.
Link to comment
Share on other sites

If you want to have the animation play, I think you need to use an Ai Package with UseMagic: https://www.creationkit.com/index.php?title=Procedure_UseMagic

You would use that instead of the ability. Put the same conditions on the Ai Package: GetLightLevel < SomeAmount and GetGlobalValue KoahniCandleLightCheckGV == 0

 

For making the candlelight warming, I'm not sure how, but others have made mods that do this. You can look at how they did it and incorporate it into your mod.

https://www.nexusmods.com/skyrim/mods/4419

Edited by dylbill
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...