Jump to content

Help with spawning items in chest via scripts


Recommended Posts

Hey I was wondering if anyone might able to help me out with a mod I'm working on, I need to activate something, a menu to pop up, you select an option, then in a few days a chest is filled with the selected items. (and the activateable is disabled until the items are delivered)
I'm a scripting noob so any insight at all would be helpful.

Thanks for any help in advance!

Link to comment
Share on other sites

Hey, you can put a script like this on your activator:

 

Scriptname TM_ObjectRefScript extends ObjectReference 

Float Property Days Auto ;set how many days to wait in the Creation Kit

Message Property My_Message Auto ;message menu to show. Make in the creation kit under Miscellaneous / Messages.
ObjectReference Property My_Container Auto ;Container to put items in

MiscObject Property LockPick Auto 
Armor Property ArmorElvenBoots Auto

Bool IsWaiting 

Event OnActivate(ObjectReference akActionRef) 
    If akActionRef == Game.GetPlayer() ;did the player activate this object? 
        Int Button = My_Message.Show() ;Show message and save the button chosen in game. 
        
        If Button == 1 ;did the player choose button 1? 
            If IsWaiting == True 
                Debug.Notification("Delivery already in route")
            Else 
                IsWaiting = True ;disable option until delivery is made 
                If Days <= 0 
                    Days = 1.0 ;failsafe in case days isn't set. Can't registerForSingleUpdateGameTime(0) 
                Endif
                    
                My_Container.BlockActivation(True) ;prevent activating container
                Float TimeToWait = Days * 24 
                RegisterForSingleUpdateGameTime(TimeToWait) ;update in however many days set in the ck.
            Endif 
        Endif 
    Endif 
EndEvent

Event OnUpdateGameTime() 
    IsWaiting = False ;Enable delivery option again.
    My_Container.AddItem(LockPick, 5) ;Add 5 lockpicks 
    My_Container.AddItem(ArmorElvenBoots,  1)  
    My_Container.BlockActivation(False) ;enable activating container again.
EndEvent

Name the script something more unique.

Don't forget to fill properties in the creation kit after compiling and attaching the script.

 

For a beginner script tutorial you can go here: http://www.cipscis.com/skyrim/tutorials/beginners.aspx

For more info on properties you can go here: http://tesalliance.org/forums/index.php?/topic/5039-class-2-properties/

Link to comment
Share on other sites

  • 4 weeks later...

Hey, I've finally gotten around to trying to implement this function too.

So far it's working for the first option "Raid Village" I just need to add functionality to more menu options, "Raid Fort" and "Raid Mages" for example.
And then I'm curious if I could make it add specific item levelled lists (depending on the option chosen) to the chest instead of a set item of a set amount.
It'd be a lot better if, for instance, you raid a village twice in a row and one time you get a heap of potatoes, and misc items, the next time, it's a few misc items and a various amount of another crop.

I see the-
"If Button == 1 ;did the player choose button 1?"
part and understand that in this case it refers to my "Raid Village" option which is set to 'Index 1' in my message, so I'm trying to figure where to add something like-
"If Button == 2 ;did the player choose button 2?"
and to make it add different items.

Link to comment
Share on other sites

Getting somewhere, I'm looking at the function list on the CK site and it looks like it'd be "AddForm" rather than "AddLeveledItem" but compiling tells me "AddForm is not a function or does not exist" I assume it's because somewhere in this script it's labelled as an ObjectReference and not LeveledItem...something to do with extends? Trying really hard to grasp all this.

=EDIT=

I have it like this at the bottom-
My_Container.AddItem(LockPick, 5) ;Add 5 lockpicks
My_Container.AddItem(ArmorElvenBoots, 1)
My_Container.AddForm(WBGoblinRaidJunk01, 1)

Edited by ManKannon89
Link to comment
Share on other sites

AddForm is for adding items to a formlist or a leveled list. Instead use AddItem with a formlist or leveled list. i.e.

My_Container.AddItem(FormListOfStuff) ; will add 1 of each item in the list
My_Container.AddItem(LeveledListOfStuff) ; will add 1 of whatever the game engine determines should be added based on player level.
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...