Pellape Posted July 11, 2022 Author Share Posted July 11, 2022 (edited) Everythig is working fine at the chest now so it is completed and I show you the script later but now I also want a spell that allows the player to access the chest wherever they are. In Oblivion we have a checkbox to make a reference persistent and we must also give it a name, otherwise we cannot access it from other scripts so how do I get in contact with the chest from a spell? In Oblivion I would just make a spellscript wit a single line really: ContainerREF.Activate Player and that is what I wanna make. The things is I do not know how to make my chest reference persistent nor how to type it. I do know we have similar functions in some other Skyrim mods but I cannot read others scripts, not unless they did provide the source and we can read everything in Oblivion and I did learn a lot of Oblivion scripting, by reading others scripts. So I placed a container in the game and gave the reference this name : PekDropChestREF How can I access that reference from a spell or a button or whatever? I looked in every tab in the Reference window, and no where can I see anything refering to Persistent Reference In the script we made for the Chest, we do get the name from self, but it is really the Scriptname we get, not the reference as we do have a function called GetSelf() in OBSE and that will give the reference, not the script that reference has. This is so confusing :D PekDropChestREF is xx0012C8 Is this a way to get the reference? (Game.GetForm(0x14) as ObjectReference) , Which in this case is the player? Like Game.GetForm(0x12C8) ??Or do I have to do like this? Game.GetFormFromFile(0x000012C8, "PekAutoSellStuff.esp") ?Maybe it is so I think wrong? Well let me then plainly ask: How do I get access to my chest from a spell? :wink: Edited July 11, 2022 by Pellape Link to comment Share on other sites More sharing options...
dylbill Posted July 11, 2022 Share Posted July 11, 2022 You can just define it as a property: Â ObjectReference Property PekDropChestREF Auto Event OnEffectStart(Actor akTarget, Actor akCaster) if akCaster == Game.GetPlayer() PekDropChestREF.Activate(akCaster) Endif EndEvent Hit the auto fill all button in the properties tab when attaching the script to the magic effect in the Creation Kit and it should auto fill with your chest. Make sure the script extends ActiveMagicEffect. Â I'm pretty sure SKSE organized their folders that way cause that's how it is in LE, and not every environment for SE will use Data/Source/Scripts for source files. I think I mentrioned earlier I use SSEScript for scripting, which still uses Data/Scripts/Source by default for SE I believe. Link to comment Share on other sites More sharing options...
Pellape Posted July 11, 2022 Author Share Posted July 11, 2022 Ahh, yes, thanks again dylbill. It has been so much so I do remember half of it right now. I will try exacty as you did type here. I do guess I did use Oblivon structure again but honestly, when I peek at my chest script now, it does not look so different really from Oblivion, it is just the names that are different and some other small stuff though. Â This script works perfect now and I started to autosell stuff in game and all I need is that spell and I publish it as I am sure more players wants a function like this. We see... :) Maybe no one will DL it, who knows? ;)Â Well here is my working script that is on the chest at least. I did not delete the stuff you added, as I keep it for later, the call of the function, as I think it will be useful later on in case I get new ideas. I did remark the output of the return value 5 you added as an example though... ;) Scriptname PekSellChestSCR extends ObjectReference {The Script at the container} ObjectReference ChestForm ObjectReference PlayerREF Form ItemInChestForm ;Form [] AllIemsInChest String ItemName Int StackSize Int GoldPieces Int TotalGold Event OnActivate (ObjectReference akActionRef) ChestForm = Self Debug.Notification ("This is " + Self as String + ChestForm as String) ;MiscUtil.PrintConsole ("Chest is open") RegisterForMenu("ContainerMenu") EndEvent Event OnMenuClose(String menuName) If ( menuName == "ContainerMenu" ) PlayerREF = Game.GetPlayer() UnRegisterForMenu("ContainerMenu") Int ItemsIndex = ChestForm.GetNumItems() ;MiscUtil.PrintConsole ("Chest is Closed, ItemCount = " + ItemsIndex as string ) Int MyInt = MyCustomIntFunction() ;Debug.Notification(MyInt) Debug.Notification ("The stuff in your inventory will now get sold. Open the console for a complete list") While ( ItemsIndex > 0 ) ItemsIndex -= 1 ItemInChestForm = ChestForm .GetNthForm(ItemsIndex) ItemName = ItemInChestForm.GetName() GoldPieces = ItemInChestForm.GetGoldValue() StackSize = PlayerREF.GetItemCount(ItemInChestForm) GoldPieces = GoldPieces * StackSize If ( StackSize > 0 ) PlayerREF.RemoveItem ( ItemInChestForm , StackSize , True ) PlayerREF.AddItem ( Game.GetForm(0xF) , GoldPieces , True ) MiscUtil.PrintConsole (StackSize as String + " " + ItemName as String + " has been sold for " + GoldPieces as String + " Septims") TotalGold = TotalGold + GoldPieces EndIf EndWhile If ( TotalGold > 0 ) Debug.Notification( "You did manage to auto sell your items for " + TotalGold + " Septims") EndIf Endif EndEvent Int Function MyCustomIntFunction() return 5 EndFunction So lets fix that spell now. :) Link to comment Share on other sites More sharing options...
Pellape Posted July 12, 2022 Author Share Posted July 12, 2022 (edited) The Spell is made, I looked at a similar spell to get it right. The spell it self works but it cannot see the chest. The Script looks like this right now. Scriptname PekSellStuffSPLSCR extends ActiveMagicEffect ObjectReference Property PekDropChestREF Auto Event OnEffectStart(Actor akTarget, Actor akCaster) Debug.Notification ("Accessing the chest in Whiteun") if akCaster == Game.GetPlayer() PekDropChestREF.Activate(akCaster) Endif MiscUtil.PrintConsole ("Actor is " + akCaster as String + " and is Contacting " + PekDropChestREF as String ) EndEvent When I cast the spell, I get this result in the Console: Actor is (Actor<(00000014)> and is Contacting None I also saw that we can choose a reference from the Property Window but I cannot choose the chest as the Cross gets RED and in Oblivion that means the reference is NOT Persistent. When I Google Persitent References I get so weird debates about Persistence and many advice against it. I do not understand these debates really. In my world, this Refence MUST be Persistent. So the question is: Am I right? What is Missing I saw a Video briefly, and the narrator do stuff so damn fast. He is linking a Button to Light Objects and he links them and get a white cross, which in my world, mean that his targets is already Persistent. I can even link to the floor inside the Cell I am at and that is not right. Let me show you: WOOT? Now it did work, the cross got White this time. I better go in game and try the spell again. The Spel obviously see the chest if I make the right Conclusion from this. We do see in the Property window that it is this specific reference in this specific cell even. :D Something is working... It should not, not in my world where we must use Persistent refs. :D The spell it self, well I copied everything from a similar spell in Legacy of the Dragonborn, LOTD, to make it simple and to get it right. I be back.... :wink: Damn, it did work and I do not know why honestly. Odd. ;) Well I publish it now and we see if it is working for others as well... ;) Edited July 12, 2022 by Pellape Link to comment Share on other sites More sharing options...
Pellape Posted July 12, 2022 Author Share Posted July 12, 2022 So here is the mod finally. Do take a peek at the Credits... ;)Â https://www.nexusmods.com/skyrimspecialedition/mods/71234/Â Next step is really to make it more user friendly, but it works fine as it is. I think I will make a spell next that only sell the stuff, without open the chest every time but for now, I leave it as it is to pick up possible bugs from the players. Link to comment Share on other sites More sharing options...
Pellape Posted July 12, 2022 Author Share Posted July 12, 2022 (edited) We did debate this earlier. GetGoldValue(). Well it does not include enchants. We do have an OBSE function that gets the complete value in Oblivion. Maybe I could put a request to the SKSE team to add it? :wink: I did google the question, to see if anyone had solve this, but so far: Not what I could find. Well the Note clearly say so as well. I sent an request. I also try to seeif we get see which enhanteffect that is in place on an item, to figure out how to calculate the gold value from it, but it will require a lot of Math really. What I see in game, when I enchant is that every different effect costs different but the value seems static, no matter which item that gets the effect. Calculate an object with 2 effects will be harder I guess but I guess this is the approach we must choose if we want to implement this. This also mean I have to check every damn enchant in CS, to see its value. Hmmm... Sounds like to much hard work really. If the player wants full price from an enchanted item, well then they can sell it manually but the game knows the full value, so it is so stupid that we cannot get it from the script. Edited July 12, 2022 by Pellape Link to comment Share on other sites More sharing options...
Sphered Posted July 12, 2022 Share Posted July 12, 2022 Enchantments dont have a value. Glancing in the CK I am seeing the same value for base items as well as their enchanted variants. Not saying values dont change, but I suppose its never come up as a pertinent concern for me, since the convenience is what makes auto-selling appealing SKSE team doesnt strike me as the type that will ever respond to a regular person. What I might suggest, if you want enchanted items to sell for more, is a GetEnchantment() check, and if it has one, tack on a percentage, and make it more complicated from there if you wish, by checking types/charge/etc I see you arent interested in the GetContainerForms() route. Do you, but that could save you a lot of headaches Link to comment Share on other sites More sharing options...
Pellape Posted July 13, 2022 Author Share Posted July 13, 2022 (edited) Yes, well I was very temped to use it really. I was gonna use it if the GetNthForm() did not do as expected. :D I will keep that in mind, how easy it seems to get arrays to work. That function seems very optimized honestly. Maybe it will also make my script a bit faster too? :wink: They actually do the same thing. The difference is that your function grabs all forms immediate. My function gets them one by one so if I would grab them from the form [] Things, I would just call Thing [index], which should be more optimized, instead of checking the chest every Index. But that is micro optimizing... :wink:  Oki, lets peek at the community. Why do we act as we do? The reason that the SKSE team will not respond to player requests is 2 I guess.They do get a lot of mails, focusing at their agenda, fixing bugs or whateverThey may not be a social bunch as having a dialogue just we have now, require that you like to communicate.It is a shame really. Idle that code xOBSE is not very social but at least he do respond to me and he has a very nice girl helping him with the social bit, Kat something and she is a OBSE goddess and very helpful, like you are. :D You could help them with the support. :wink: I do report all bugs I find to him and he is doing his best to make xOBSE better than OBSE was. I admire he is still doing it really, supporting that old game. But it is a very nice game to mod honestly. We also have Wrye, that is a Genious and he is so helpful and he has a whole team supporting him at Discord. https://www.nexusmods.com/skyrimspecialedition/mods/6837 and he made the first and best mod manager ever. I want to mention how damn nice he is as one of my files from 2008 is missing at nexus and I want it in my game. He did endorse that file at UESP and I cannot find it now, well I was hoping he still has it, so I contacted him at Discord and chatted with him. So he looked through his old harddrives, could not find it but still, that was so nice done. he said he did use it and liked it. Well we are not all social and it is up to each and everyone what they want or like to do. I did learn a lot by making this mod as I start to see the big differens between Skyrim and Oblivion and now I think I know a lot more how Skyrim really works. I did whine some here about how slow the scanning process is in LOTD here: https://www.nexusmods.com/oblivion/mods/52047 and I should remove that whining really and I will explain why. Lets first peek in Oblivion what happens in a single frame. All scripts available in a cell will run ones, from top to bottom, if it has a GameMode Event, it will run every line. It will check every script at least one every FPS. If a Loop is run, it will run that loop immediately and if we forgot the end the loop, lets say we forgot to add Turn += 1 or Turn -= 1 that loop will run forever and will lock the computer and to get out, well then we have to logout or reboot. So therefor I use questscripts as much as I can, to avoid all my scripts to run every frame or be checked every frame, to keep up performance. Oblivion priorities scripts above anything else. My scans and my reports gets into the console immediately. In Skyrim, I did noticed that the game does not prioritize the script in the same way, at least not report in the console and not finish the loop within a frame. I see in the console in Real Time, when every item gets sold, which is cool, as it is much faster than the message spamming in the left top. Okay, Oblivion does takes time to spam the messages at the left up top as well but not in the console and we have to use Conscribe, that saves the console to the drive in case I want to see more than just 10-15 lines of reports there. I also saw that we can save logs. So I did whine over the time it takes for LOTD to scan. Searching for books in game takes up to 10 min even. Scanning in that way is not possible in Oblivion as we must do things more static, but that also means that it gets faster. I do not want to add any performance issues to the Oblivion player community that use my mods, as they are loaded with scripts, so I must consider if it is necessary for a script to run every frame or not. Almost every scripter runs their scripts in GameMode at the references and I did that too until I figured out, that it cause a lot of LAG really. :smile: In many cases, it is unavoidable of course but I weight every script and look at its function in game. So I ask myself. When is it needed for this script to actually run? If I made this in Oblivion, every item would have been sold within 1 FPS. I did a similar script in Oblivion, and I had to slow down the script to make it work at all. Refilling a Wine Rack from a container, so I use a similar function of GetNthForm() and drops the item at the players, feet, scan the surroundings for that specific item, move it into an array of coordinates as a Whine Rack is a form of 2D array really, well 3D as I use different Y positions, depending on where the bottle origin really is in space. Well just look at this video. I must add pauses between each bottle, otherwise, the script will not be able to find the bottle and use it. The script will run, ignoring the bottle. :D  We also get nice reports in the console from OBSE, as we set the script editor in Offset mode, to actually find that row that gave the error. So you saw all the errors when I tried to get the bottles back into the rack. Well here I fixed it. It took me 2 weeks to get this to work, but I did. Finding the balance between the fast script engine and the FPS, well it was not easy really. This is video 2, when I fixed the bugs  I spent so much time, optimizing, trying the find the balance between adding a lot of stuff and the performance. I am very very happy with this mod right now after 2 years development. I feel I am in control right now. My favorite modder right now is called Maskar and he made the best Overhaul we have available for Oblivion and he still develop it. He is testing my mod right now as I added plugins and addons that needs his stuff. It is cool we can make stuff together and I made him some 3D objects as well in Blender. Skyrim require so much of my computer at least. I have 8Gb RAM, 4Gb Graphic RAM, NVIDIA 730 or whatever, and slow old drives. It lags a lot in the open world and in many player homes, well all I should add. It do not lag so much in Dungeons. Oblivion, in the other hand, runs much better on my computer then Skyrim does. I did ask Maskar yesterday if he ever modded Skyrim but he said no and he will focus at TES VI instead he said and will stay in Oblivion until then, which is cool. Maybe he ran into the same problems I did? He is not the one asking for help, but he support his Overhaul every day, answer the players ones every day. His player Base is huge really. So what makes him and his mod special? https://www.nexusmods.com/oblivion/mods/42780 He adds everything in game from scripts. He do not change a single cell by dragging anything to it. This makes his mod the cleanest ever made :D It cannot conflict with anything. I try to do the same in my project and damn, it really took me time to get it working. What I really dislike in Skyrim is when I first used your script and I tested it, and the spell could not find the chest reference. I did not change the script really, I did get a red cross, trying to find the chest and I found the bloody floor, but the chest, no way. I went here typing, closed down CK, restarted it to get that screenshot and suddenly, the script at that Magic Effect could see the chest reference. Nothing in Skyrim is immediate it seems. Nothing. Well correct me if I am wrong but this is the conclusions I have made today. I must feel I know what happens in game, to be able to control it, finding the balance. Well I am happy now. Lets see if I make another mod for Skyrim? I do have another Oblivion WIP from a request, that I also want to use, a trading mod, so I most likely start making it next week. It will be an Oblivion version of this mod: https://www.nexusmods.com/skyrimspecialedition/mods/15814 So the new mod will have this auto sell function, but also allow the player to actually RP a merchant. I will give the option to the player to setup his daily trading as he wish. If he does not want the auto sell function, well then he can close it down. It will be a simple shop with more posibilities than the Skyrim version has. Lets see what I can make :D Immersion is what a player wants, as this mod is not immersive a all that I made for Skyrim and that is not the purpose as it is to make the game funnier, so we can focus at what is really fun to do in game. I dreamt about game like these around 1990, Dungeon Master felt so cool, going inside a mountain, exploring caves. What is behind the next door? Daggerfall was the first game I ever loved, as I played it 2 years straight. :D I forgot the quest timer, so I broke the MQ but I had fun anyway in it. MQ is not that important to complete. Everyone will hate the player char in the end anyway, well the Noble Houses... :wink: Everyone except one of the Nobles will try to get the player killed. What a political mess that area is. Intrigues, but that's the way things work. TES is not a fairy tale. I do miss the Fame system in Skyrim, but I installed a mod that fix that. I do want the commoners at least to know who that player char is as we are not unknown after we visited a town many times. I do want to feel as a part of the community and we really feel that way in my Oblivion mod and we sure feel that in LOTD, where the DragonBorn is in focus. Maybe it is so that, that is the whole purpose with that project? Making us feel like we actually are changing the world? No NPC will care about you in Daggerfall for sure :D Fine, so be it... :wink: Edited July 13, 2022 by Pellape Link to comment Share on other sites More sharing options...
Pellape Posted July 13, 2022 Author Share Posted July 13, 2022 (edited) When it come to communications, it all depends how big the inbox gets. I communicate a lot with some members in the band SAGA, and I bet they are a bit tired of me... :wink: I did send them this video and they did like it. But still how much do a pro musician really want to chat with a single fan? I will find out as I will meet them in person 29th October and we see how much tired they really are of communicating with me. :D They love to play music, not deal with crazy fans. I would most likely act the same way, but still, they did offer us to meet them after the show, talking and debating as they want to thank every member in person after 45 years playing, which is great honestly. I bet we all have a personal side and a pro side. Rush musicians do not act this way. Alex Lifeson can spend a whole day with a single fan if they approach him, but he is unique. I do like that Jim Gilmour answer me at all honestly. He does, if I ask the right questions that is :D He sure loved this one: Â I did get a request from a member at their Facebook, asking if I could make this one? Well that one is much harder I told him, as it is very hard to actually sing this one, Saga did not said a single word about it. Maybe it sounds to much like the original or if they did start to feel I am a pain in their rear. I do not know. I will ask them in October if they have seen it though... :wink: Musically, it is much harder to play. But I did it. ;) Edited July 13, 2022 by Pellape Link to comment Share on other sites More sharing options...
Pellape Posted July 13, 2022 Author Share Posted July 13, 2022 (edited) Lets get back on track. I get sidetracked so easy. :D I think I now really need a fomlist as the array do have the limit of 128 items. Backside now of open the chest is it really cause LAG. It is simple, it works, but still, I have many items in the chest now and the way all TES games works is that, the more items we have in inventory or at a container, the more LAG we will have when we try to access the junk. So what is a fomlist? Is it like a levellist? Do I need to create it as an object or is it just a virtual placeholder for forms? I also need to separate the spells into 2 spells. One spell that only sell the stuff One Spell that open the container as I still need the container for interaction. But there is really many different ways to add stuff into a form list really but I think this is the most easiest way honestly. And then sell stuff from both the container and the player to keep it clean. But we can also use the container to add stuff to the list and take them out again, well no, that requires to much inventory handling, and is wat I try to avoid in the first place. I am lazy, do not forget that. :D Lazy persons tend to invent things like this. Lazy persons do want everything served on a silver plate. :D I am so lazy, I could watch a video instead about form lists, instead of asking you. :D In one way or another, something needs to be done about the LAG. So if I get this right, the Formlist is virtual right? https://www.creationkit.com/index.php?title=FormList_Script No I am wrong. The formlist is an actual object, a form of container. like the Levellist: https://www.creationkit.com/index.php?title=Complete_Example_Scripts#Cycle_Through_a_List_of_Objects_and_Perform_an_Action_on_Each_Object.28FormLists.29 Well I sort this out. One way or Another: I did base my char of Debbie Harry when I think about it. :D It really looks like her. ;) The singer in Blondie Edited July 13, 2022 by Pellape Link to comment Share on other sites More sharing options...
Recommended Posts