How do I get a potions info via script?

Post » Wed Jun 20, 2012 8:47 am

I am working on a potion rack and have a working version that operates like the bookcase.

I would like to take it a step further and start placing potions in specific markers but at present all my code does is identify the item as a potion.

Below is a fragment of code where I identify the potion as a potion.

Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer)

if (akBaseItem as Potion)
; If the item being added is a Potion then check to see if there is room in on the shelf.

if ((aiItemCount + CurrentPotionAmount) <= MaxPotionsAllowed)
; There's room on the shelf, manage the Potion placement
AddPotions(akBaseItem, aiItemCount)
CurrentPotionAmount = CurrentPotionAmount + aiItemCount
else



After the akBaseItem is identified as a potion how do I find out its type and level?
User avatar
jaideep singh
 
Posts: 3357
Joined: Sun Jul 08, 2007 8:45 pm

Post » Wed Jun 20, 2012 5:20 am

You could make formlists of each type of potion you wish to categorize (e.g. all health potions) then use http://www.creationkit.com/HasForm_-_FormList to see if your particular potion is in that list.

(formlists are created in the CK - but you can also check/modify them with Papyrus)
User avatar
Horror- Puppe
 
Posts: 3376
Joined: Fri Apr 13, 2007 11:09 am

Post » Wed Jun 20, 2012 6:50 am

Please read the stickied thread "http://www.gamesas.com/topic/1347469-how-to-ask-for-scripting-help/". Some of us, like me, are using a theme with a white background, so your yellow text is even harder for me to read than the usual unindented script.

What exactly do you mean by "type" and "level"? There probably isn't a way to directly get the information you're looking for, which would make ScarabMonkey suggested method probably the most feasible.

Cipscis
User avatar
Jimmie Allen
 
Posts: 3358
Joined: Sun Oct 14, 2007 6:39 am

Post » Wed Jun 20, 2012 12:46 pm

Please read the stickied thread "http://www.gamesas.com/topic/1347469-how-to-ask-for-scripting-help/". Some of us, like me, are using a theme with a white background, so your yellow text is even harder for me to read than the usual unindented script.

What exactly do you mean by "type" and "level"? There probably isn't a way to directly get the information you're looking for, which would make ScarabMonkey suggested method probably the most feasible.

Cipscis

Sorry about the yellow text, I didnt think it would really matter as my snipet is only to point out where and what I am working on. The complete code does work to place potions on the shelf it just uses a "place in first available marker" method copied from the bookshelf and that has some issues with the different size bottles.

What I would actually like to be able to do is pull the potions name or ID from the akBaseItem so I can use that to sort and place each potion in a marker specifically laid out for that potions bottle size so I can avoid placing a large potion botttle in the middle of a shelf load of smaller ones and sending them flying everywhere.
User avatar
Strawberry
 
Posts: 3446
Joined: Thu Jul 05, 2007 11:08 am

Post » Wed Jun 20, 2012 10:56 am

Do you suppose GetHeight() or GetWidth() or GetLength() would work when called on the potions?
User avatar
Hope Greenhaw
 
Posts: 3368
Joined: Fri Aug 17, 2007 8:44 pm

Post » Wed Jun 20, 2012 12:43 pm

One thing that might be useful is keywords. You can create new keywords like PotionLevel1, PotionLevel2, etc. and attach the appropriate ones to the various potions. http://www.creationkit.com/HasKeyword_-_Form can then be used to see which keywords the potion has. The drawbacks are that you have to edit all of the potions, meaning possible compatibility issues, and I'm not sure whether player created potions would have any keywords. For potion value, potions also get all of the functions available to Form scripts, so you can use http://www.creationkit.com/GetGoldValue_-_Form.
User avatar
Theodore Walling
 
Posts: 3420
Joined: Sat Jun 02, 2007 12:48 pm

Post » Wed Jun 20, 2012 1:12 am

I still think ScarabMonkey's suggested method of using FormLists is probably the best. Like using Keywords to specify the size of a potion, you could use various FormLists, each for a different size/shape of potion. This approach also wouldn't require editing of any potions, which is a nice compatibility bonus, and you could treat potions that aren't in any of the lists differently somehow in order to account for generated potions and those added by mods.

Cipscis
User avatar
Rachel Tyson
 
Posts: 3434
Joined: Sat Oct 07, 2006 4:42 pm

Post » Wed Jun 20, 2012 2:00 am

I can see how FormLists would work on this, a different list for each size potion, check the list them place it in a sized marker.

As each type of potion has a unique editor ID, RestoreHealth01, RestoreHealth02, etc I was hoping I could just use that as I would like to have the different types grouped together on the shelves.

Doesnt akBaseItem have some property that holds its EditorID, something like akBaseItem.EditorID

I havent even considered generated potions, but now its been mentioned I will probably just stick them in a container instead of displaying them.
User avatar
tiffany Royal
 
Posts: 3340
Joined: Mon Dec 25, 2006 1:48 pm

Post » Tue Jun 19, 2012 9:40 pm

There's no way to get the editorID of such items in-game, no, although like I said there are other ways to identify them. If you were planning on identifying them via editorID, then you could use pretty much the exact same approach to just compare their base object with one specified in a property, but that would be much slower than using form lists.

You could potentially use two sets of form lists - one for type and one for size/shape.

Cipscis
User avatar
Big mike
 
Posts: 3423
Joined: Fri Sep 21, 2007 6:38 pm

Post » Wed Jun 20, 2012 12:14 am

OK. So its looking like FormLists are the way to go.

Now to go pull some hair out.

Thanks guys.
User avatar
Yvonne
 
Posts: 3577
Joined: Sat Sep 23, 2006 3:05 am

Post » Wed Jun 20, 2012 2:59 am

You might want to check out this script too, as it already does size based spawning http://skyrim.nexusmods.com/downloads/file.php?id=10891

Also I'm pretty sure formlists are quite forgiving of missing entries, so you could add the potions from your favourite potion mods and the lists would remain compatible with users who don't have said mod... (excepting name collisions).
User avatar
Joanne Crump
 
Posts: 3457
Joined: Sat Jul 22, 2006 9:44 am

Post » Wed Jun 20, 2012 12:48 pm

I have the sorting and placement working for healing potions, now just need to do it for the other potions.

By far the most tedius job is addding all the properties and so forth needed to handle all the different potions ans markers, but I will get there.
User avatar
Rob
 
Posts: 3448
Joined: Fri Jul 13, 2007 12:26 am


Return to V - Skyrim