turielo Posted June 14, 2017 Share Posted June 14, 2017 Hi everyone!I'm working on a simple mod wich consist of a house with different options, including auto-sorting equipment and items. Yeah, classic stuff. Here's the deal: I'm pretty new to advance modding (meaning getting a headache on scripts), and I try to make an auto-sorting process which include almost everything ingame (I collect a lot and like it organized without loosing hours of manual sorting). I've already made chests and switches based on the scripts of Trystans sorter script, modified by Quartz, and all works pretty fine, except I didn't remember scripts have a limit of caption so I couldn't make a few switches to auto-sort items quickly. Instead, I have almost a dozen of different switches for weapons only. So my question is: what is the correct procedure to avoid having a wall full of tiny switches (I use the ARSwitch01 model)? I don't expect a full tutorial from you, just some advices or links I can use, don't worry! In theory I thought about 3 ideas, but I don't even know if that is possible to do:1-Having a general script linked to a switch, script which use other smaller but detailed scripts(for example: general script on switch01 (weapons) with links to detailed script of sorting weapons by type, one for swords, another for axes, etc...)2-Having a general switch which can be used ingame, with a script where if the player push the switch, it triggers other switches hidden (out of the room so invisible unless tlc) each one with a script that sort different category of items(f-e: there is the GeneralSwitch, and hidden there is a switch that sort only swords, another only axes and another only hammers. When the player activate the GeneralSwitch, it triggers the switches for sword, axes and hammers. Let's say there is another hidden switch auto-sorting leather armors, the GeneralSwitch being only about weapons will only trigger the sword/axe/hammer hidden switches but not the leather armor hidden switch.3-Basically is there a way to be able to add more to a script (without limitation of words), or a simplier way to code an autosorting script? In Skyrim I've used the keywords relative to items and the coding was much simplier, but here I had to make a statement for each object. Here's a quick overview of the code I use: Scriptname WeaponSorterbyTypeSCRIPT;based on Trystans sorter script, modified by Quartz short stateshort buttonlong tempCount Begin OnActivate if (state == 0 && IsActionRef player == 1) playgroup forward 1 MessageBox "Sort and store your weapons by type?", "Yes", "No" set state to 1 endifEnd Begin GameMode if (state == 0) return ; Early return, nothing to do in most cases this script runs endif set button to GetButtonPressed if (button == -1) return elseif (button == 1) ; No set state to 0 return endif ; Following button == 0, Yes if (Player.GetItemCount "WeapDaedricClaymore" >= 1) Set tempCount to Player.GetItemCount "WeapDaedricClaymore" Player.RemoveItem "WeapDaedricClaymore" tempCount AAACWSwords.AddItem "WeapDaedricClaymore" tempCount endif if (Player.GetItemCount "WeapDaedricDagger" >= 1) Set tempCount to Player.GetItemCount "WeapDaedricDagger" Player.RemoveItem "WeapDaedricDagger" tempCount AAACWSwords.AddItem "WeapDaedricDagger" tempCount endif...............................................................and so long...................................................................... if (Player.GetItemCount "WeapDaedricLongsword" >= 1) Set tempCount to Player.GetItemCount "WeapDaedricLongsword" Player.RemoveItem "WeapDaedricLongsword" tempCount AAACWSwords.AddItem "WeapDaedricLongsword" tempCount endif set state to 0 End ; GameModeProblem is, there is a lot of items to compile here, for exemple I had to make 3 different switches/codes for Enchanted Weapons, because the complete list didn't fit in one & only script. I think around ~650 caracters it just stop writting, so I had to split some of the lists. Thanks guys if you can help me!and sorry if I massacred english, I'm french and not ggod at it! Cheers! Link to comment Share on other sites More sharing options...
Surilindur Posted June 14, 2017 Share Posted June 14, 2017 OBSE offers commands to check object types. Would that help? For example something like (I have not tested this, mind you!) an OBSE user-created function, which is basically just an object script that does not look like one is not attached to anything (as in, do not attach it to anything!): scriptname AutoSortTestFunc ref Item ref TargetContainer array_var ContainerMap begin _Function { ContainerMap } foreach Item <- ( This ) ; the easy way, if it works, if not you can use GetSelf to store in a ref variable and use that variable if eval ( ( Item.IsQuestItem ) || !( Item.IsPlayable2 ) ) continue ; avoid quest items and non-playable/invisible stuff that is not intended to be moved endif let TargetContainer := ContainerMap[(Item.GetObjectType)] ; get the target container based on object type if ( TargetContainer ) ; if the container exists, then move items, calling RemoveMeIR without target container destroys the item I think... Item.RemoveMeIR TargetContainer endif loop let ContainerMap := ar_Null ; emptying it just to be sure endAssuming the "this" actually works in that context. I have used that map[(some_function_that_returns_key)] bit in a script before so that one should work. The "this" was taken from the Construction Set Wiki. Called like this, to sort items from the container reference it was called on, to the target container references: scriptname SomeActivatorTest begin _OnActivate PlayerRef PlayerRef.Call AutoSortTestFunc ( ar_Map 19::ApparatusContainer, 20::ArmourContainer, 21::BookContainer, 22::ClothingContainer, 25::IngredientContainer ) ; and more.... endWhere the map is a map of <type>::<container_ref> pairs, with the types being the ones defined in the OBSE Command Documentation, which means they are also the ones returned by the GetObjectType function! Easy, assuming it actually works. I am not sure about using integers as map keys like that, but the documentation says it should be possible... :huh: I also have another small thing related to NPC races that I need to test, but have not had the time, though I hope I have some time soon to test this one, too. But for now, it is untested. :P You would need to launch the Construction Set in a way that adds OBSE support for the scripting system, though. I use the Construction Set Extender myself, but the general idea is to run the editor with obse_loader.exe -editor -notimeoutand it should work. However the actual things to look for would be the GetObjectType, GetWeaponType, GetArmorType and such functions. You can find them all in the OBSE Command Documentation. Add to those commands a loop of sorts to go through all the inventory references and the code should be somewhat compact. Also, the actual inventory reference loops from OBSE would be handy, in that you can access each reference itself, and avoid having to add+remove items, because I think that resets their health and enchantment charge and stuff, because the original item vanishes! Just remember not to move quest items or items that are unplayble (items the IsPlayable2 functions says False on!) because those are probably not intended to be taken away from the player. If someone else has another idea, I would also love to hear it. Or something more simple. Also, does that ready-made sorting system you mentioned have every item hardcoded, or does it already use something built with OBSE? Link to comment Share on other sites More sharing options...
turielo Posted June 14, 2017 Author Share Posted June 14, 2017 I haven't thought about OBSE functions to be honest... As I said modding in Oblivion is quite new for me, so I stayed only using CS. I have to look into it, I'm not quite familiar with OBSE as a modding tool. Also, no I didn't put items that aren't suppose to be used, so it make space in the script but not enough. I don't really know if the base code I used were already construct with OBSE, I "study" it when I looked on the Glenvar castle mod to understand the bases of auto-sorting script (in taht case the autor just made it for ingredients only), so I don't know if OBSE was involved. I've tested it in my own mod, it worked, so I continued to expand it for weapons, armors, soulgems and clothing. Ingredients and SG are okay, as there is not a lot of items to list, but weapons & armors, that's a different story. Anyway, I think beginning to look more into OBSE possibility might be a good start, so thank you for the advice. Hell, I think I might have some more headaches! haha! (I'm not really a script person, more a "if it works it works but I don't know how" person!) However the actual things to look for would be the GetObjectType, GetWeaponType, GetArmorType and such functions. About that part, I assume this is a bit like using keywords in the Skyrim's CK? Like I might try to get their xType to sort them more easily without having to enter every single items in the script? It might be a very good way indeed! Now I first have to learn more on how to use it properly but I guess that would be a better way to handle multiple type of objects in one script... I will try all that and let you know if I achieve to understand it and use it correctly. Thank you! In the meantime of course I would, like you, remain open to other suggestions! Cheers! Link to comment Share on other sites More sharing options...
Wolfhound2 Posted July 19, 2017 Share Posted July 19, 2017 Hi Turielo I don't think it's practical to do an autosorter without OBSE, to be honest.This type of mod is mainly what I've worked on, and I long ago gave up on doing anything like that in standard Oblivion script - it's just far too inflexible and laborious, as you've discovered. One big issue with using the vanilla 'RemoveItem' and 'AddItem' functions is that the thing you add to the container is NOT the same thing that you remove from your inventory.For example, you have a damaged sword, an enchanted bow that's only half charged, and a stolen Silver Urn...You remove these from inventory, and add them to a container.The things you add are 'Base Objects' - so they are pristine, fully charged, and nobody owns them.Your container now has a perfect sword, a fully charged bow, and that Silver Urn has been 'laundered'.So, not the way to go... (Pardon the shameless self-promotion here, but it is relevant...) I have a mod that does basically what you want, but it uses OBSE extensively to avoid the problems you have, namely too many items to list in the code.So it uses the OBSE functions to check the item types (and other properties) and selectively move them, rather than laboriously having to check every individual item.Also, doing it this way means that it can handle anything added by other mods - if it's an enchanted two-hand sword, my mod recognises it as such, and shoves it in the container you set up for enchanted two-hand swords, or whatever. The mod is called "The Art of speedy depositing" - search for name contains "speedy deposit" here on The Nexus.You are more than welcome to look through that code, and steal anything you think could be useful.Bear in mind, you'll have to get the CS working with OBSE first.I'll happily answer any questions you have about the mod code and how it works. However - and this is a HUGE caveat - the code in that was written in a much earlier version of OBSE which lacked the inventory reference functions,so I had to use a major (and very clunky) workaround to get it to work at all.I would not recommend you do it exactly the same way, but it could at least give you some ideas.It should be worth having a look at it, to see how a flexible autosorter can work. Depending on the time-frame for your house, I might have far better news for you, though... pm me if you're interested.Hint: I'm working on a complete re-write, using the latest OBSE functions. It's not imminent, but it's not too far away either.Also, it will be done as a 'Master' so it will then be easy to add patches for house mods, which might be of interest to you... Cheers Link to comment Share on other sites More sharing options...
Recommended Posts