Activatable and consumed-on-activation item help

Post » Thu Aug 15, 2013 12:39 pm

I've been thinking about making this mod for a long time, but am always hung up at the first aspect: the concept of an activatable item being consumed, like a loaf of bread.

However, in this instance, the item isn't food; it's a soul gem.

What i'd like to be able to do is have a soul gem in my inventory (non-filled), press the action button in my inventory, and have it shatter into soul gem fragments.

However, I'm absolutely clueless as to where to start. I have the creation kit pulled up, and I've been to the soul gem pages for both of the item categories (soul gems and soul gem fragments), but nothing on the internet even remotely shows how to make an item activatable.

Also, would it even be possible to have a spell that consumes one of these soul gem fragments instead of mana? I imagine it would take scripting for that to happen, but I'm ok with that. I've tango-d a bit with Java and Lua in the past.

Anyway, thanks in advance for any advice. As said before, I have no idea where to start, so I hope you guys can point me in the right direction. :smile:

User avatar
Jessica White
 
Posts: 3419
Joined: Sun Aug 20, 2006 5:03 am

Post » Thu Aug 15, 2013 9:37 am

What we want to do is capture an OnObjectEquipped() Event. Capturing this event on the Player is a little indirect because we don't want to attach a script to the Player directly. Instead, it would be better to use a ReferenceAlias filled by the player.

The most straight-forward way to do this would be to:

1) Create a Quest. Give it an EditorID and exit the window. Re-open the quest. It should be set to "Start Game Enabled".
2) Create a ReferenceAlias on that Quest.
3) Set it to Specific Reference: PlayerRef. Check Allow Reserved.
4) Attach a script to the ReferenceAlias that looks something like this:

scriptname SierSoulGemAliasScript extends ReferenceAliasMiscObject property SoulGemWhatever autoMiscObject property FragmentWhatever autoActor property PlayerRef autoEvent OnObjectEquipped(Form akBaseObject, ObjectReference akReference)    if akBaseObject == SoulGemWhatever        PlayerRef.RemoveItem(SoulGemWhatever)        PlayerRef.AddItem(FragmentWhatever)    endifendEvent
5) Attach a script to the quest itself that looks something like this:

scriptname SierSoulGemQuestScript extends QuestReferenceAlias property myPlayerAliasOnTheQuest autoActor property PlayerRef autoEvent OnInit()    bool b = myPlayerAliasOnTheQuest.ForceRefIfEmpty(PlayerRef)endEvent
You will need to "fill" the properties in the CK after you compile the scripts and attach them to the Alias and Quest. This establishes a linkage between "script objects" and "Creation Engine objects". The properties are meaningless to the engine until they are filled in the CK.

You will need to, of course, change the property names in the scripts to meaningful things. I'm not in front of the CK right now so I don't know what the actual editor IDs for empty soul gems or soul gem fragments are.

To make this work on many different empty soul gems (instead of just one type), instead of making a property for a single type of soul gem on the Alias script, make a property for a FormList, create the FormList in the CK, and fill the form list with the empty soul gems you want to recognize. You will have to modify the If statement of the OnObjectEquipped() event to accommodate this change; I leave it to you to make that change.

Hope this helps.

By the way, you will get an error notification generated by the game whenever you attempt to "equip" an item in the Misc category; something like "this item cannot be equipped". This comes from a GameSetting in the CK. I blanked out the contents of this GameSetting long ago in Frostfall and no one has ever seemed to miss it. You will have to do the same.
User avatar
Dan Endacott
 
Posts: 3419
Joined: Fri Jul 06, 2007 9:12 am

Post » Thu Aug 15, 2013 1:37 pm

Well, I'd like to stop in to give a small status-report. This is what the code for the quest portion looks like:

Scriptname SoulGemQuestScript extends Quest   ReferenceAlias property myPlayerAliasOnTheQuest autoActor property PlayerRef auto Event OnInit()  bool b = myPlayerAliasOnTheQuest.ForceRefIfEmpty(PlayerRef)endEvent} ReferenceAlias Property myPlayerAliasOnTheQuest  Auto  

and this is what the code for the alias portion looks like:

scriptname SoulGemAliasScript extends ReferenceAlias    SoulGem property SoulGemPetty autoMiscObject property SoulGemPiece001 autoActor property PlayerRef auto Event OnObjectEquipped(Form akBaseObject, ObjectReference akReference)if akBaseObject == SoulGemPettyPlayerRef.RemoveItem(SoulGemPetty)PlayerRef.AddItem(SoulGemPiece001)endifendEvent}SoulGem Property SoulGemPetty  Auto   MiscObject Property SoulGemPiece001  Auto   Actor Property PlayerRef  Auto  

Other than the minor tweaks to the MiscObject for the PettySoulGem property, just about everything is the same. I couldn't find PettySoulGem in MiscObject's properties so I figured the change was necessary. If not, I may need more explanation.
Speaking of, are all of the properties done and in order? It's my first time dealing with something like that so I'm kind of new to the field in that regard.
Regardless, I appreciate all of the help that's been done already, and i'm off to a flying start that I never would have had without it. Still, there's a little more assembly required, so any further help would speed me along even more. :smile:
User avatar
Stephy Beck
 
Posts: 3492
Joined: Mon Apr 16, 2007 12:33 pm


Return to V - Skyrim