Jump to content

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


bbqwtvr

Recommended Posts

First time CK user. I was trying to follow these instructions and got confused about how to add Properties to a script. As a result I created a bunch of messed up properties.

 

I cant see how to delete them. I researched this and read that you can only delete properties from the code when you Edit Source on the script. But even doing that didn't get rid of them.

 

The script above is for the BoundBow and I'm worried that some of the messed up properties may be contributing to a bug where the arrows don't de-spawn, so i have an ever-increasing number of bound arrows.

 

Thanks in advance.

Link to comment
Share on other sites

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

 

 

Edited by ReDragon2013
Link to comment
Share on other sites

Thank you for this.

 

It's pretty much over my head. I did a little bit of coding decades ago so I have a vague idea of some of it (the idea of an IF or WHILE), but not really sure how I would implement and test. (Not asking you to spoonfeed that to me or anything, I'll just have to figure out how to test.)

 

This does look like it might solve my problem of the arrows not despawning, so that would be cool.

 

But my original question - how to delete properties that one made in error - is that just not important or are there ways to do it?

 

Thanks again.

Link to comment
Share on other sites

The easiest way would be to remove the script from the magiceffect. And after that add the same script again to this effect. Now fill the properties which should be automatic added by CreationKit.

The thing with a property, which has to be a pre-filled array, is a bit tricky but not really. The array does not need to be initialized. The length of array is depending on the entries you add into.

Take you time to fill the ammo in right order as you need. You have to add this one by one through selection menu.

Edited by ReDragon2013
Link to comment
Share on other sites

Steps to delete unwanted properties from a script:

 

Option 1: Within the CK <-- useful if you have a small number of properties or all properties can auto-fill

Remove script from the record in question

Exit record in question

Re-open record in question

Re-add script

Option 2: Within the CK: <-- useful if you have a lot of wanted generic properties already filled

Open the record in question

Right click on attached script and choose to edit the source

Remove the unwanted property lines

Save and compile the script

Exit the record in question

Re-open the record in question

Highlight the script in question

Click the properties button

Confirm that the unwanted properties are now gone.

 

Option 3: Partially outside the CK: <-- useful if your script is too large to be loaded completely by the built in editor

Use third party text editor to remove unwanted property lines

Save and compile the script

Open the Creation Kit

Locate the record in question

Highlight the attached script

Click the properties button

Confirm that the unwanted properties are now gone.

 

Option 4: Completely outside the CK <-- useful if you really have an aversion to using the CK

Use third party text editor to remove unwanted property lines

Save and compile the script

Open xEdit (i.e. TES5Edit, SSEEdit, FO4Edit, etc)
Load your plugin
Locate the record in question
Find the VMAD section
Locate the attached script
Remove the unwanted property entries
Save plugin and exit xEdit

 

Please note, it is not the deleting of the lines from the script that is enough. The properties must be removed from the record itself. Either manually through xEdit or automatically through the CK by opening the properties window for the record(s) in question.

  • Thanks 1
Link to comment
Share on other sites

Thank you for such a thorough and complete answer.

 

With my current level of knowledge I can understand only part of it, but I think I'm just going to delete the mod, reinstall, and now make the changes suggested here with my new knowledge about how to edit properties.

 

Do you agree with the earlier poster that there is an error in this script?

 

 

 

 
 
********************
; PROPERTIES
;********************
AMMO[] Property boundArrow Auto ; Need to add in this order within Properties (or Mystic variant): boundArrow, boundArrow25, boundArrow50, boundArrow75
INT ammoIndex
MAGICEFFECT Property BoundBowFFSelf Auto ; Fill in Properties the corresponding Magic Effect

;********************
; EVENTS
;********************
Event OnEffectStart(Actor Target, Actor Caster)
; debug.trace("Bound Bow - Effect Starting - add and equip bound arrows")
RemoveAmmo(Caster)
Utility.Wait(0.1)
AddAmmo(Caster)
EndEvent

Event OnLoad()
; debug.trace("Bound Bow caught Cell Attach")
If !(GetCasterActor().hasMagicEffect(BoundBowFFSelf))
; debug.trace("Bound Bow - Cell Attached, script active, but effect not found on "+getCasterActor())
dispel()
EndIf
EndEvent

Event OnEffectFinish(Actor Target, Actor Caster)
; debug.trace("Bound Bow - Effect Finishing, remove any bound arrows")
RemoveAmmo(Caster)
EndEvent

;********************
; FUNCTION
;********************
Function AddAmmo(ACTOR Target)
INT levels = 100 / boundArrow.length
INT skill = Target.GetActorValue("Conjuration") as Int
If(skill > 80)
ammoIndex = 4 as INT
Else
ammoIndex = skill / levels as INT
EndIf
Target.AddItem(boundArrow[ammoIndex] as FORM, 100, TRUE)
Target.EquipItem(boundArrow[ammoIndex] as FORM, TRUE, TRUE)
EndFunction

Function RemoveAmmo(ACTOR Target)
INT i = 0
While(i < boundArrow.length)
If(Target.GetItemCount(boundArrow) > 0)
Target.RemoveItem(boundArrow[i],Target.GetItemCount(boundArrow[i]),TRUE)
EndIf
i += 1
EndWhile
EndFunction
 

Link to comment
Share on other sites

ReDragon2013 is correct, there is an error and his fix will work. The problem is this line:

If(Target.GetItemCount(boundArrow) > 0)

It's comparing the entire array with GetItemCount rather than 1 entry in the array. To fix you could also just change this line to this:

If(Target.GetItemCount(boundArrow[i]) > 0)
Link to comment
Share on other sites

Thank you, I did make that change as ReDragon 2013 suggested and I appreciate your confirming.

 

I tried deleting the mod and resinstalling, but my messed up old properties are still in the properties of the script. And unlike the first few times I edited the source of the script, there are no visible lines at the bottom for the properties. (I deleted everything in the script at one point in my efforts to fix the non-despawning arrows).

 

 

Steps to delete unwanted properties from a script:

 

Option 1: Within the CK <-- useful if you have a small number of properties or all properties can auto-fill

Remove script from the record in question

Exit record in question

Re-open record in question

Re-add script

Option 2: Within the CK: <-- useful if you have a lot of wanted generic properties already filled

Open the record in question

Right click on attached script and choose to edit the source

Remove the unwanted property lines

Save and compile the script

Exit the record in question

Re-open the record in question

Highlight the script in question

Click the properties button

Confirm that the unwanted properties are now gone.

 

I tried IsharaMeradin's first two options without success. Although maybe I did them incorrectly.

I think my next goal is to figure out how to complete remove / wipe / delete the mod in a way that will delete the old script and properties, and then start over from scratch. Just using Remove in MO2 did not seem to accomplish that - the zombie undead properties came back and the bound arrows still don't despawn when I sheath the bound bow.

 

Thanks all again for all the guidance. Much appreciated.

Link to comment
Share on other sites

You are using MO2 and you are editing Scaling Bound Weapons to incorporate the posted fix with the above mentioned edit to the array reference in the GetItemCount...

 

Remove script completely:

In MO2 on the right hand side there should be a Data tab, click this and navigate to the Scripts folder, see if the PEX version of the script you worked on before is still present. Check the Scripts > Source folder for the PSC version of the script. If either one is present, delete it (right click the file, choose Reveal in Explorer, find the file and delete it). Be sure to click Refresh in MO2 before proceeding. Alternatively, use Explorer to do a name search and let it find both the PEX and PSC files and then delete them.

 

Restore mod to original status:

In MO2 find your Scaling Bound Weapons mod folder in the priority window (left side). Right click and choose to re-install. Replace when prompted. All files in that folder will be wiped out and the FOMOD re-ran. Select your desired choices.

 

At this point, you can follow those instructions to apply that fix. Don't forget to make that edit mentioned earlier in this thread.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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