ProgMath2 Posted December 10, 2015 Author Share Posted December 10, 2015 (edited) Damn. I clone objects when I need new objects. It doesn't create more garbage than in-game enchanting.I cast the spell (a new special spell) on the item laying on the floor. If item isn't a cloned form (was initially given by master or plugin file, not a player-enchanted or already progmath-modified one), it gets disabled and DeleteReference -ed and on it's place appears the clone. The cloned form (either the initial one or just placed here by the spell) get it's properties modified.In the last post I was concerned if DeleteReference really deletes a reference. Now I tested it, and yes, it really does all of sudden. So no extra garbage is created. Edited December 10, 2015 by ProgMath2 Link to comment Share on other sites More sharing options...
Surilindur Posted December 10, 2015 Share Posted December 10, 2015 (edited) As far as I know, DeleteReference works indeed on references. And it means dynamically created references, not items placed in the CS, and not base objects, just dynamic references (form ID of FFXXXXXX). If CloneForm creates a new base object for the cloned form, and stores that base object in the savegame (where else?), how would you delete that base object from the savegame? If it really creates a new base object that does not get automatically erased. I have never used CloneForm myself, though, so I am not sure. Edited December 10, 2015 by PhilippePetain Link to comment Share on other sites More sharing options...
forli Posted December 10, 2015 Share Posted December 10, 2015 (edited) Exactly. You can destroy references, but there's no way for scripts to destroy a base object once created. They will be forever part of the savegame, even if you destroy all their references. Edited December 10, 2015 by forli Link to comment Share on other sites More sharing options...
ProgMath2 Posted December 13, 2015 Author Share Posted December 13, 2015 (edited) You both didn't listen to me. I have no need to delete cloned items. Edited December 13, 2015 by ProgMath2 Link to comment Share on other sites More sharing options...
forli Posted December 13, 2015 Share Posted December 13, 2015 (edited) Yes, I listen. Your spell create up to 1 clone for every target's base object, then reuse the existing clones. The spell delete the original reference, but still you clone the spell's target base object and create a reference for this clone. This means (in the worst case) the spell can double all inventory items of Oblivion+DLC+mods (well, on average, if you use this spell often, you can expect to clone about 30% of all inventory items). Since clones are not part of the esp/esm data, they are saved in the savegame, and putting even a smaller 15% of all inventory items may increase the savegame's size by several MB, with unacceptable loading times and general game instability. Edited December 13, 2015 by forli Link to comment Share on other sites More sharing options...
ProgMath2 Posted December 13, 2015 Author Share Posted December 13, 2015 (edited) If player's using enchanting, that means (in the worst case) player can double all wearable unenchanted inventory items of Oblivion+DLC+mods...Even a hedgehog can see that one shouldn't clone forms without a reason. It's a player decision, to make a new item, or not, don't you think? My script does not make more garbage then vanilla game, that's what I say. The other thing I say is that my way is the only way to tweak item's properties so they would persist after reload.Let's finish that pointless arguement already. Edited December 13, 2015 by ProgMath2 Link to comment Share on other sites More sharing options...
Surilindur Posted December 13, 2015 Share Posted December 13, 2015 (edited) No, it is not the only way. You can use an array to store all base objects you need to modify, sort of 'collect' all the base objects in it. Then just go through the array upon each save load or game restart, whichever is of interest, and modify the base objects accordingly. No bloating, just changing the properties of base objects. And in case player removes a mod with items, a check could be added to see if the base object is valid before trying to modify it, and remove if invalid. Edit: Or that is how I think it might be possible. The array would be stored in a quest script, together with the check upon reloading. Edited December 13, 2015 by PhilippePetain Link to comment Share on other sites More sharing options...
forli Posted December 13, 2015 Share Posted December 13, 2015 (edited) If player's using enchanting, that means (in the worst case) player can double all wearable unenchanted inventory items of Oblivion+DLC+mods...Even a hedgehog can see that one shouldn't clone forms without a reason. It's a player decision, to make a new item, or not, don't you think? My script does not make more garbage then vanilla game, that's what I say. The other thing I say is that my way is the only way to tweak item's properties so they would persist after reload.Let's finish that pointless arguement already.Right, I forgot Oblivion create new base objects when enchanting or crafting potions (2 base objects when enchanting: the new enchantment and the new object with this enchantment). So... yes, Oblivion already cause a big garbage by itself. My question is: how do you distinguish a clone created by your mod from clones created by other mods? As PhilippePetain suggest, you need to keep track of your clones, else you may end altering clones created by other mods (which may not like the change you make to their clones). Edited December 13, 2015 by forli Link to comment Share on other sites More sharing options...
ProgMath2 Posted December 14, 2015 Author Share Posted December 14, 2015 My question is: how do you distinguish a clone created by your mod from clones created by other mods? As PhilippePetain suggest, you need to keep track of your clones, else you may end altering clones created by other mods (which may not like the change you make to their clones). It's rather strange question. Explain, please, which mod you do mean, what changes that mod could dislike, and how that mod is going to object.The only kind of mods I know that is cloning equipment is enchanting expansions, and they certainly would not track the new item's properties. Link to comment Share on other sites More sharing options...
Surilindur Posted December 14, 2015 Share Posted December 14, 2015 (edited) I think I can distantly remember digging around the codes of Side's Backpacks, and I think it worked somehow by, upon 'initialising' a backpack, cloning that backpack and letting player change the name of the cloned form (base object, as there is no other way to rename single items than having separate base object for each one, which you know already). The mod then worked by setting and reading some values from the backpack, I think it was weight, for example. It excpected the weight of the item to be something specific at a specific situation related to the backpack's functionality in the code. Or something like weight anyway. But at least that mod used cloned forms and relied on backpack base object properties to be something specific at least unders some specific circumstances. So it might not be exactly the thing that was needed, as it did not look easy to break, but it was something that did indeed excpect some values, on cloned forms, to be something specific. And it was weight, not health, but still. Have you tried to see what happens if you use an array in a quest script to store all base objects you need to modify? Then modify them upon save load? Something like the following (incomplete and untested, needs type checks, form ID / validity checks and a lot more, but just an idea): ScriptName SomeQuestScript Array_var aBaseObjects ref rTemp int iTemp Begin GameMode If ( GetGameLoaded == 0 ) Return EndIf SetDebugMode 1 ; turns on debug messages let iTemp := ar_Size aBaseObjects If ( iTemp < 0 ) ; Intitialise if uninitialised let aBaseObjects := ar_Construct Array DebugPrint "SomeMod: Init base objects array" EndIf DebugPrint "SomeMod: Save loaded, checking array..." While ( iTemp > 0 ) let iTemp -= 1 let rTemp := aBaseObjects[iTemp] ; should work this way ; add checks here to see if the reference to a base object ; is valid and something that makes sense to modify rTemp.SetObjectHealth 10000 DebugPrint "SomeMod: Modified %q%n%q (%i)", rTemp rTemp Loop DebugPrint "SomeMod: Save loaded, check finished!" EndIt has been a few months since I did any scripting for Oblivion, so that might not be exactly correct. And then add things to the array via something else... ref rItem ref rContainer int iTemp ... ForEach rItem <- rContainer let rBase := rItem.GetBaseObject let iTemp := ar_Find rBase SomeQuest.aBaseObjects ; add checks here to see if the base object is one ; of interest to you, not all base objects need their ; health set to a high value, some do not even have 'health' If ( iTemp < 0 ) ar_Append SomeQuest.aBaseObjects rBase rBase.SetObjectHealth 10000 EndIf Loop Maybe that might be an idea? Also, forli knows a lot more about these things. So if he says something, he is likely correct, and not me, so listen to him more. I am still sort of learning, I think. Edit: Added initialisation to the array, that one is pretty necessary for anything to work. :tongue:Edit 2: Added a check to prevent adding a reference to the same base object multiple times. Edited December 14, 2015 by PhilippePetain Link to comment Share on other sites More sharing options...
Recommended Posts