Jump to content

[LE] How do you get rid of messed up properties you made?


bbqwtvr

Recommended Posts

the script on mod page (you linked) has an error

 

 

Function RemoveAmmo(ACTOR Target)
INT i = 0
While(i < boundArrow.length)
;;    If(Target.GetItemCount(boundArrow) > 0)        ; error: you cannot use the whole array here, but a formlist would be working
      If(Target.GetItemCount(boundArrow[i]) > 0)     ; or this line instead above
        Target.RemoveItem(boundArrow[i],Target.GetItemCount(boundArrow[i]),TRUE)
    EndIf
    i += 1
EndWhile
EndFunction

 

 

 

SC_BW_BoundBowScript

 

Scriptname SC_BW_BoundBowScript extends ActiveMagicEffect
; https://forums.nexusmods.com/index.php?/topic/9789353-how-do-you-get-rid-of-messed-up-properties-you-made/

  MagicEffect PROPERTY BoundBowFFSelf auto
  ; use auto-fill here, to fill this with the corresponding MGEF

  Ammo[] PROPERTY boundArrow auto
  ; required to add next ammo in order within this array property (or the Mystic variant of ammo):
      ; boundArrow        ; [0]  no idea is this existent
      ; boundArrow25      ; [1]
      ; boundArrow50      ; [2]
      ; boundArrow75      ; [3]
      ; boundArrow100     ; [4]


; -- EVENTs -- 3

EVENT OnEffectStart(Actor akTarget, Actor akCaster)
;;    debug.trace("Bound Bow - Effect Starting - add and equip bound arrows")

    RemoveAmmo(akCaster)
    Utility.Wait(0.1)
    AddAmmo(akCaster)
ENDEVENT


EVENT OnLoad()
;;  debug.trace("Bound Bow caught Cell Attach")

    actor aRef = self.GetCasterActor()

    IF (aRef) && !aRef.HasMagicEffect(BoundBowFFSelf)
;;      debug.trace("Bound Bow - Cell Attached, script active, but effect not found on "+getCasterActor())
        self.Dispel()                                    ; remove effect from caster immediately
    ENDIF
ENDEVENT


EVENT OnEffectFinish(Actor akTarget, Actor akCaster)
;;  debug.trace("Bound Bow - Effect Finishing, remove any bound arrows")
    RemoveAmmo(akCaster)
ENDEVENT


; -- FUNCTIONs -- 2

;---------------------------
FUNCTION AddAmmo(Actor aRef)
;---------------------------
    int i = aRef.GetActorValue("Conjuration") as Int        ; i = skill level

; adjust the next condition, if required

    IF     (i < 25)
                    i = 0        ; boundArrow
    ELSEIF (i < 50)
                    i = 1        ; boundArrow25
    ELSEIF (i < 75)
                    i = 2        ; boundArrow50
    ELSEIF (i < 95)
                    i = 3        ; boundArrow75
    ELSE
                    i = 4        ; boundArrow100
    ENDIF

    form fm = boundArrow[i] as Form

    aRef.AddItem(fm, 100, TRUE)               ; add 100 of ammo
    aRef.EquipItem(fm, TRUE, TRUE)            ; equip this ammo to caster
ENDFUNCTION


;------------------------------
FUNCTION RemoveAmmo(Actor aRef)
;------------------------------
; https://www.nexusmods.com/skyrimspecialedition/mods/11940?tab=posts&BH=0

    int i = 0
    WHILE (i < boundArrow.Length)
        form fm = boundArrow[i] as Form
    
        IF ( fm )
            int n = aRef.GetItemCount(fm)
            IF (n > 0)                                        ; fixed error here
                aRef.RemoveItem(fm, n, TRUE)
            ENDIF
        ENDIF

        i = i + 1
    ENDWHILE
ENDFUNCTION

 

 

 

or this script variant

SC_BW_BoundBowScript

 

Scriptname SC_BW_BoundBowScript extends ActiveMagicEffect
; https://forums.nexusmods.com/index.php?/topic/9789353-how-do-you-get-rid-of-messed-up-properties-you-made/

  MagicEffect PROPERTY BoundBowFFSelf auto
  ; use auto-fill here, to fill this with the corresponding MGEF

  Ammo[] PROPERTY boundArrow auto
  ; required to add next ammo in order within this array property (or the Mystic variant of ammo):
      ; boundArrow        ; [0]  no idea is this existent
      ; boundArrow25      ; [1]
      ; boundArrow50      ; [2]
      ; boundArrow75      ; [3]
      ; boundArrow100     ; [4]

  Actor myTarget            ; to make the caster persistent for a while


; -- EVENTs -- 3

EVENT OnEffectStart(Actor akTarget, Actor akCaster)
;;    debug.trace("Bound Bow - Effect Starting - add and equip bound arrows")

    myTarget = akCaster

    RemoveAmmo(myTarget)
    Utility.Wait(0.1)
    AddAmmo(myTarget)
ENDEVENT


EVENT OnLoad()
;;  debug.trace("Bound Bow caught Cell Attach")

    IF (myTarget) && !myTarget.HasMagicEffect(BoundBowFFSelf)
;;      debug.trace("Bound Bow - Cell Attached, script active, but effect not found on "+getCasterActor())
        self.Dispel()                                    ; remove effect from caster immediately
    ENDIF
ENDEVENT


EVENT OnEffectFinish(Actor akTarget, Actor akCaster)
;;  debug.trace("Bound Bow - Effect Finishing, remove any bound arrows")

    IF ( myTarget )
        RemoveAmmo(myTarget)
        myTarget = None
    ENDIF
ENDEVENT


; -- FUNCTIONs -- 2

;---------------------------
FUNCTION AddAmmo(Actor aRef)
;---------------------------
    int i = aRef.GetActorValue("Conjuration") as Int        ; i = skill level

; adjust the next condition, if required

    IF     (i < 25)
                    i = 0        ; boundArrow
    ELSEIF (i < 50)
                    i = 1        ; boundArrow25
    ELSEIF (i < 75)
                    i = 2        ; boundArrow50
    ELSEIF (i < 95)
                    i = 3        ; boundArrow75
    ELSE
                    i = 4        ; boundArrow100
    ENDIF

    form fm = boundArrow[i] as Form

    aRef.AddItem(fm, 100, TRUE)               ; add 100 of ammo
    aRef.EquipItem(fm, TRUE, TRUE)            ; equip this ammo to caster
ENDFUNCTION


;------------------------------
FUNCTION RemoveAmmo(Actor aRef)
;------------------------------
; https://www.nexusmods.com/skyrimspecialedition/mods/11940?tab=posts&BH=0

    int i = 0
    WHILE (i < boundArrow.Length)
        form fm = boundArrow[i] as Form
    
        IF ( fm )
            int n = aRef.GetItemCount(fm)
            IF (n > 0)                                        ; fixed error here
                aRef.RemoveItem(fm, n, TRUE)
            ENDIF
        ENDIF

        i = i + 1
    ENDWHILE
ENDFUNCTION

 

 

I didn't even review the code. I compiled it, tested it and it worked and just said "hey!" Good catch thank you

Link to comment
Share on other sites

Thank you very much!

 

This was super helpful. I learned that I have some horrible directory structures left over from Vortex, now MO2, also SKSE...so many places for a little script to hide.

 

Anyway ty, this worked. And I did correct the error in the array thingy.

 

Appreciate all the help.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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