Jump to content

[LE] Changing a Weapon Enchantment shader Through Script


AslanKebab

Recommended Posts

suggestion: do not use both effectshaders inside the magicEffect, let them start and stop with object script below. It should not break the weapon enchantment.

 

xyzDualEffectWeaponScript

 

Scriptname xyzDualEffectWeaponScript extends ObjectReference
; https://forums.nexusmods.com/index.php?/topic/7184141-changing-a-weapon-enchantment-shader-through-script/
; AslanKebab wrote: "Enchantment shader that is visible on the weapon is the one that is tied to the first magic effect in the condition
;                    index list and does not change depending which hand is holding the weapon like applied weapons does."

  EffectShader PROPERTY effect1 auto    ; fill with CK
  EffectShader PROPERTY effect2 auto    ; fill with CK
  EffectShader myEffect                 ; hold the active effect for this weapon object

; *** Note: Would you like to have more than one of this weapon, no trouble if you attach this script to the weapon base object. ***


; -- EVENTs -- 4

EVENT OnInit()
    IF ( effect1 )
        effect1.Stop(self)
    ELSE
        Debug.Trace("Missing property for effect1!")
    ENDIF

    IF ( effect2 )
        effect2.Stop(self)
    ELSE
        Debug.Trace("Missing property for effect2!")
    ENDIF

    myEffect = None
ENDEVENT


EVENT OnMagicEffectApply(ObjectReference akCaster, MagicEffect akEffect)
; received when a magic affect is being applied to this object
    Debug.Trace(self+ " OnMagicEffectApply() has been reached.. with " +akEffect+ " from " +akCaster)    ; info only
ENDEVENT


EVENT OnEquipped(Actor akActor)
; received when this object is equipped by an actor

    IF (akActor.GetEquippedWeapon() == self.GetBaseObject() as Weapon)  ; rightHand, GetEquippedWeapon(False) by default
        myEffect = effect1
    ELSE                                                                ; leftHand, GetEquippedWeapon(TRUE)
        myEffect = effect2
    ENDIF

; https://www.creationkit.com/index.php?title=Play_-_EffectShader
    myEffect.Play(self as ObjectReference, -1)                          ; play effectshader without time limit
ENDEVENT


EVENT OnUnEquipped(Actor akActor)
; received when this object is unequipped by an actor

    IF ( myEffect )
        myEffect.Stop(self)
        myEffect = None
    ENDIF
ENDEVENT

 

 

Link to comment
Share on other sites

  • 2 weeks later...

Hello Redragon

 

I forgot about this thread for a while, sorry for the late response.

 

I tried your suggested solution by the first incorporating it to the main weapon script that updates the enchantment variables it compiles but does not work. that did not work.

not did copy-pasting your Script as is into a second script file.

 

I have checked it and it is running, I think there is an issue with myEffect.Play(self as ObjectReference) doesn´t seem to work. and effect.Play(self as Weapon) does not compile as it thinks I am casting to something else.

 

It seems it is not uncommon for effect shaders in general to break each other.

 

If you would like I could send you my Esp, Thank you for your time.

Edited by AslanKebab
Link to comment
Share on other sites

I wonder: Have you tried moving the condition to the MagicEffect instead of the Enchantment? Done that way, it will only get checked when the enchantment is first applied, so it's not great for something that might change while the enchantment's active, but I think you're okay because equipping the thing should reapply the enchantment.

 

The reason I suggest this is that if there are conditions on a magic effect *in the spell* (or enchantment/ability/shout), a few game systems will behave as if the magic effect is in fact there and active even if the conditions say otherwise. Could be worth a shot, though race conditions with your tracking variable or other issues might mean it doesn't work.

Edited by foamyesque
Link to comment
Share on other sites

Hello Foamyesque

 

I tried your suggestion and it did not break the script. it also solved a minor bug that I was going to get to later.

However, it did not change EffectsShader depending on which hand holding the weapon as I was hoping, it kept picking the effect with the highest index in the effect list of the enchantment.

 

Thanks for your suggestion, it helped me a little bit but not in the way I was hoping. :smile:

Edited by AslanKebab
Link to comment
Share on other sites

  • Recently Browsing   0 members

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