Getting references of items in your inventory.

Post » Thu Apr 08, 2010 4:19 am

I'm trying to figure out how to get references of a bunch of soulgems in your inventory automatically, to detect their soul levels and replace them with predefined filled soulgems. Do you have any ideas how to accomplish this?
User avatar
Ymani Hood
 
Posts: 3514
Joined: Fri Oct 26, 2007 3:22 am

Post » Thu Apr 08, 2010 4:38 pm

I'm trying to figure out how to get references of a bunch of soulgems in your inventory automatically, to detect their soul levels and replace them with predefined filled soulgems. Do you have any ideas how to accomplish this?

You cannot :(

Seriously, this is impossible without a new plugin to OBSE, as not even OBSE has the needed functionality. OBSE can give you references to the soulgems in your inventory, but it can only give you references to the base objects, thus you will not have a way of checking whether a soulgem is filled or not - furthermore, to replace it you would have to remove the old, and there is no way to control which of the individual items of the same base type to remove with removeItem, so you would be just as likely to remove an empty as a filled one.

I have thought about adding this functionality to Enhanced Economy, but to do it I would have to expand upon what the Refstuff OBSE plugin already does.
User avatar
Nicole Kraus
 
Posts: 3432
Joined: Sat Apr 14, 2007 11:34 pm

Post » Thu Apr 08, 2010 5:27 pm

I wonder if you could do a stupid pet trick with it.

Drop any non-pre-filled soul gems into the world, one at a time, scan them in the world, replace them with pre-filled equivalents, drop them back in the inventory again.
User avatar
Cash n Class
 
Posts: 3430
Joined: Wed Jun 28, 2006 10:01 am

Post » Thu Apr 08, 2010 2:36 pm

I wonder if you could do a stupid pet trick with it.

Drop any non-pre-filled soul gems into the world, one at a time, scan them in the world, replace them with pre-filled equivalents, drop them back in the inventory again.


I can do that even in the inventory, by just briefly going over them with the mouse in the inventory and using the Getactivemenuselection, to get it's reference. Not as automatic as I hoped but the next best thing I suppose. If they are stacked they will be converted one by one.
User avatar
Crystal Clear
 
Posts: 3552
Joined: Wed Aug 09, 2006 4:42 am

Post » Thu Apr 08, 2010 7:32 am

I think you could automate the "stupid pet trick" version, though. It would happen so fast the player probably wouldn't even notice it.
User avatar
Lauren Dale
 
Posts: 3491
Joined: Tue Jul 04, 2006 8:57 am

Post » Thu Apr 08, 2010 4:06 am

Well I'm certainly trying to. Any suggestions on how to do that? Hmm...I'm having another stupid idea. Now I know putting scripts on vanilla items is frowned upon but what if I put an object script on the empty soulgems so they check their soul levels if they are in a container, get the reference of the container they are in(if there is such a function) and if it is not empty it will put the corresponding full soulgem into the container while removing itself. The script probably gets removed on soul update I think.

Here's an example of what this might look like.
scn pettysoulgemscript1ref meref containershort doonceBegin Gamemode || menumodeif getcontainerset me to getselfIf getsoullevel me == 1 && doonce == 0set container to getcontainercontainer.additem soulgem1petty1pettysoul 1set doonce to 1removemeendifendifend

User avatar
Da Missz
 
Posts: 3438
Joined: Fri Mar 30, 2007 4:42 pm

Post » Thu Apr 08, 2010 3:44 am

[Oops, pressed reply instead of modify] But the script didn't work. Don't know why.
User avatar
C.L.U.T.C.H
 
Posts: 3385
Joined: Tue Aug 14, 2007 6:23 pm

Post » Thu Apr 08, 2010 2:18 pm

Getcontainer returns a specific reference to the container, not a check on whether it is in a container, doesn't it?

Maybe "If Getcontainer == Player"?

I was thinking of something a little more complicated. A script that identifies when a soul has been captured somehow (detect the soul trap sound or the message or something). Then it walks through all the soul gem references in the players inventory, finds the ones that are have empty base objects, drops the first such one it finds, then walks the references to soul gems in the worldspace, finds the one that was dropped, checks if it is empty, replaces it if it is not empty, has a remote NPC pick it up, then continues to the next soul gem in the inventory and finalizes by dumping the remote NPCs inventory back to the player.

Add a check of "isofflimits" or whatever it is to make sure the remote NPC doesn't pick up soul gems the player doesn't own and you'd take care of most of the major issues, I think.
User avatar
Miranda Taylor
 
Posts: 3406
Joined: Sat Feb 24, 2007 3:39 pm

Post » Thu Apr 08, 2010 6:34 pm

Getcontainer returns a specific reference to the container, not a check on whether it is in a container, doesn't it?

Maybe "If Getcontainer == Player"?

I was thinking of something a little more complicated. A script that identifies when a soul has been captured somehow (detect the soul trap sound or the message or something). Then it walks through all the soul gem references in the players inventory, finds the ones that are have empty base objects, drops the first such one it finds, then walks the references to soul gems in the worldspace, finds the one that was dropped, checks if it is empty, replaces it if it is not empty, has a remote NPC pick it up, then continues to the next soul gem in the inventory and finalizes by dumping the remote NPCs inventory back to the player.

Add a check of "isofflimits" or whatever it is to make sure the remote NPC doesn't pick up soul gems the player doesn't own and you'd take care of most of the major issues, I think.


Are you sure all that is necessary? :P I thought of implementing a simple quest script so if you just go over an object in the inventory and it detects it's a kind of empty soulgem, it goes on to detect it's soul level and replaces it quickly. It's not that taxing on gameplay :D
User avatar
Josh Lozier
 
Posts: 3490
Joined: Tue Nov 27, 2007 5:20 pm

Post » Thu Apr 08, 2010 7:41 am

That's the simpler solution, yes. And probably the better one.

I kinda got stuck on the "stupid pet trick" and trying to find a way to do it automatically and invisibly to the user. More thought exercise than good idea, really.
User avatar
Marquis deVille
 
Posts: 3409
Joined: Thu Jul 26, 2007 8:24 am

Post » Thu Apr 08, 2010 2:30 pm

The soul level currently in a soulgem is an attribute of the soulgem reference (like the health of a weapon).

Items in inventories or containers cannot be accessed by reference. Maybe Getactivemenuselection is a workaround (I've never used it).

Therefore, to check if a soulgem is empty, it needs to be in the world.

So, showler's suggestion is a good one. I have used something along this line in the past for some tests of mine and it works.

But, being kind of a heavy solution, you would have to worry about how often you need to run it.

Not sure about RefStuff but, from what TheNiceOne says, RefStuff would not solve it.
User avatar
Symone Velez
 
Posts: 3434
Joined: Thu Sep 07, 2006 12:39 am

Post » Thu Apr 08, 2010 1:28 pm

Kind of a bugger problem isn't it? :) Well I get debugging messages when I use getactivemenuselection and the referenced items are removed correctly if told to without getsoullevel. Is there a difference if I use Getsoullevel or getcurrentsoullevel on soulgems? I'm trying to avoid refstuff, more requirements on the mod when perhaps there is a workaround.

Edit: I've tried Getsoullevel soulgemref == 1, soulgemref.getsoullevel == 1, getsoullevel soulgemref 1, getcurrentsoullevel in objects scripts on soulgems themselves...I dunno maybe I should try that pet trick.
User avatar
Amy Melissa
 
Posts: 3390
Joined: Fri Jun 23, 2006 2:35 pm

Post » Thu Apr 08, 2010 4:04 am

Kind of a bugger problem isn't it? :) Well I get debugging messages when I use getactivemenuselection and the referenced items are removed correctly if told to without getsoullevel.
I am 99.9% sure that getactivemenuselection gives you a reference to the base object, not to the actual item. And therefore, Get(Current)SoulLevel will only give you the level of the base item, which is empty in case of fillable base objects.

...which leads back to showler's complicated solution again.

...but of course, I would love to be proven wrong ;)
User avatar
Mandi Norton
 
Posts: 3451
Joined: Tue Jan 30, 2007 2:43 pm

Post » Thu Apr 08, 2010 10:46 am

Sorry to dissapoint you, You are absolutely right, Niceone :D The getactivemenu selection only gets the reference of the base object. So what do I do? I didn't understand that trick very much.
User avatar
Sophh
 
Posts: 3381
Joined: Tue Aug 08, 2006 11:58 pm

Post » Thu Apr 08, 2010 4:25 pm

I am 99.9% sure that getactivemenuselection gives you a reference to the base object, not to the actual item. And therefore, Get(Current)SoulLevel will only give you the level of the base item, which is empty in case of fillable base objects.
Make that a 100.
User avatar
tannis
 
Posts: 3446
Joined: Sat Dec 09, 2006 11:21 pm

Post » Thu Apr 08, 2010 12:07 pm

Make that a 100.


Pretty much. Is it possible to detect the soul levels if they are moved to a remote container out of the player inventory, scanned, replaced and moved back? I don't understand the dropping part very much.
User avatar
Scott Clemmons
 
Posts: 3333
Joined: Sun Sep 16, 2007 5:35 pm

Post » Thu Apr 08, 2010 2:03 pm

Pretty much. Is it possible to detect the soul levels if they are moved to a remote container out of the player inventory, scanned, replaced and moved back?
Nope. You cannot get anything but base objects from any containers. The player is just another container.

I don't understand the dropping part very much.
If you're not very set on doing it yourself, you can give me some time and I'll test it out. I have already planned to add this feature to Enhanced Economy (that's why I knew this and had looked at RefStuff), but think I should be able to pull off showler's idea.
User avatar
Ricky Rayner
 
Posts: 3339
Joined: Fri Jul 13, 2007 2:13 am

Post » Thu Apr 08, 2010 1:20 pm

Nope. You cannot get anything but base objects from any containers. The player is just another container.

If you're not very set on doing it yourself, you can give me some time and I'll test it out. I have already planned to add this feature to Enhanced Economy (that's why I knew this and had looked at RefStuff), but think I should be able to pull off showler's idea.


I'm pretty keen on trying it myself too, i'm just being a doofus at understanding it. But could scripts added directly to soulgems actually work if they don't include any containers?
User avatar
Darian Ennels
 
Posts: 3406
Joined: Mon Aug 20, 2007 2:00 pm

Post » Thu Apr 08, 2010 9:29 am

Bad news.
I found my test esp with the scripts to do what showler's suggested and adapted a couple of scripts to test with soulgems.

Everything works as expected, except that when a soulgem is dropped by script functions (Drop and DropMe), its soul resets, or, in technical terms, a fresh soulgem is created. Therefore a SoulGemEmpty1Petty will be an empty petty soulgem, a SoulGem4Greater3CommonSoul will be a Greater soulgemwith a Common soul, etc., regardless of what soul level it had before the drop.
This does not happen when the player drops it himself.

This behavior is consistent with other dropping scenarios (dropped scripted items has its variables reset)

Since it will be reset to the Base Object specs, there is no point in dropping, checking and collecting them. You have the Base Object specs from GetItems anyway.

Under these circumstances, I cant figure out how to determine the actual soul level of the soulgems in inventory.

Unless, of course, somebody has the necessary experience to emulate all the keystrokes to open, browse and shift-click all the soulgems in the inventory.
User avatar
sally R
 
Posts: 3503
Joined: Mon Sep 25, 2006 10:34 pm

Post » Thu Apr 08, 2010 10:16 am

*Sigh*, I guess it's going to be a round of dropping your soulgems and getting crosshairref's or some other form of ref to detect their soul levels and if it fits the bill, a preset soulgem will be added to your inventory. Thanks for all your experienced input, you're great! :foodndrink:

Or Maybe something completely different like this(I know, still an object script):

scn pettysoulgemscriptref meref pickBegin OnActivateset pick to getactionrefset me to getselfIf getsoullevel me == 1pick.additem soulgem1petty1pettysoul 1me.disableme.deletereferenceendifend ;Now I know this next part won't work because it probably will fail to get the references correctly in inventories, otherwise ;I'd only use this. But atleast even if the ref's change the script should still be valid, even if the getrefs don't return specific ;values.Begin Onaddset pick to getactionrefset me to getselfIf getsoullevel me == 1pick.additem soulgem1petty1pettysoul 1removemeendifend

User avatar
Music Show
 
Posts: 3512
Joined: Sun Sep 09, 2007 10:53 am

Post » Thu Apr 08, 2010 3:11 pm

Okay, since I'm throwing out stupid, un-thought-through ideas anyway:

What if you replaced the Soul Trap spell with a scripted effect that checks if the target dies within it's span, checks if the player has an appropriate level soul gem (required size or larger) and then removes said soul gem from their inventory and adds a matching pre-filled replacement?

You'd have to not have any soul gems filled with a real Soul Trap spell in your inventory to begin with, or they would be vulnerable to being replaced, but after this change is made you shouldn't be making any more such gems anyway.
User avatar
Petr Jordy Zugar
 
Posts: 3497
Joined: Tue Jul 03, 2007 10:10 pm

Post » Thu Apr 08, 2010 3:23 pm

Completely replacing a spell effect? Is that even reasonably possible without conflicting with a tonload of mods? The idea is good but wouldn't really work out in practice I think.
User avatar
Adam Baumgartner
 
Posts: 3344
Joined: Wed May 30, 2007 12:12 pm

Post » Thu Apr 08, 2010 10:21 am

"un-thought-through"

However, if OBSE can dynamically replace the spell effects, then it might be viable.

I'm often surprised when the good coders on here can make my insane ideas into a workable concepts.
User avatar
u gone see
 
Posts: 3388
Joined: Tue Oct 02, 2007 2:53 pm

Post » Thu Apr 08, 2010 7:53 am

I know I know, but it did have some value. On another note, why do you think it causes a runtime error when I use cloneform and setnameex on it a frame later?
User avatar
Johanna Van Drunick
 
Posts: 3437
Joined: Tue Jun 20, 2006 11:40 am

Post » Thu Apr 08, 2010 7:28 am

You're not trying to run the setnameex on the reference to the cloneform, are you?
User avatar
Katey Meyer
 
Posts: 3464
Joined: Sat Dec 30, 2006 10:14 pm

Next

Return to IV - Oblivion