Jump to content

[LE] How can I give the player a list of items with a random count every seven days


capngagi

Recommended Posts

Make a new formlist, put your stuff you want to give in it. Then make a new quest that's start game enabled, and put this script on it.

 

 

  Reveal hidden contents

The script will give the same amount of each item to the player. If you want different amounts for each item, change the function to this:
  Reveal hidden contents
Function GivePlayerItems()
    Int M = StuffToGive.GetSize()
    While M > 0
        M -= 1
        PlayerRef.AddItem(StuffToGive.GetAt(M), Utility.RandomInt(0, 10))
    EndWhile
EndFunction

Change the script name to something more unique
Edited by dylbill
Link to comment
Share on other sites

Keep in mind that update events do not run when the game is paused and many menus pause the game including the sleep / wait menu. So it is possible that should the update have triggered while sleeping or waiting the event will run later than intended after the menu closes.

Link to comment
Share on other sites

  On 10/10/2020 at 12:39 AM, IsharaMeradin said:

Keep in mind that update events do not run when the game is paused and many menus pause the game including the sleep / wait menu. So it is possible that should the update have triggered while sleeping or waiting the event will run later than intended after the menu closes.

 

The way around this is to track the gametime and use that to adjust when the next event is registered for. So it fires for the first time, notes the current gametime, and registers for an update in seven days; when that update fires, it checks the current gametime, and then if there's been any delay, removes that much from the time period for the next registration.

 

I personally would avoid using a script randomization loop for amounts. There's a built in tool for this in Leveled Lists; use those instead. They offer significantly more control.

Link to comment
Share on other sites

You mean doing something like this?

 

 

  Reveal hidden contents

I'm not really familiar with Leveled Lists as I haven't used them in my own mods.
Edited by dylbill
Link to comment
Share on other sites

  On 10/10/2020 at 3:21 AM, foamyesque said:

 

  On 10/10/2020 at 12:39 AM, IsharaMeradin said:

Keep in mind that update events do not run when the game is paused and many menus pause the game including the sleep / wait menu. So it is possible that should the update have triggered while sleeping or waiting the event will run later than intended after the menu closes.

 

The way around this is to track the gametime and use that to adjust when the next event is registered for. So it fires for the first time, notes the current gametime, and registers for an update in seven days; when that update fires, it checks the current gametime, and then if there's been any delay, removes that much from the time period for the next registration.

 

I personally would avoid using a script randomization loop for amounts. There's a built in tool for this in Leveled Lists; use those instead. They offer significantly more control.

 

How do I randomize leveled lists?

Link to comment
Share on other sites

maybe somethings like this.. I use the code from dylbill as base. Like any other papyrus script, give it a unique name.

 

capnGivePlayerQuestScript

  Reveal hidden contents

 

Edited by ReDragon2013
Link to comment
Share on other sites

  On 10/10/2020 at 7:11 AM, capngagi said:

 

  On 10/10/2020 at 3:21 AM, foamyesque said:

 

  On 10/10/2020 at 12:39 AM, IsharaMeradin said:

Keep in mind that update events do not run when the game is paused and many menus pause the game including the sleep / wait menu. So it is possible that should the update have triggered while sleeping or waiting the event will run later than intended after the menu closes.

 

The way around this is to track the gametime and use that to adjust when the next event is registered for. So it fires for the first time, notes the current gametime, and registers for an update in seven days; when that update fires, it checks the current gametime, and then if there's been any delay, removes that much from the time period for the next registration.

 

I personally would avoid using a script randomization loop for amounts. There's a built in tool for this in Leveled Lists; use those instead. They offer significantly more control.

 

How do I randomize leveled lists?

 

 

Game does it for you if you have the leveled list set up for it (i.e you do not have Use All ticked). It will randomly select 1 thing amongst all the items in the list (all of which can have independently set quantities, and which can include duplicates) at or below the player's level (there are some corner cases where it uses a different actor's level instead but they don't apply here). You can nest leveled lists inside leveled lists, as well. Between these behaviours you can basically make a leveled list generate pretty much any kind of inventory generation behaviour you want. And giving someone a random selection of items is the entire reason they were made in the first place; it drives nearly every chest and NPC inventory in the game.

 

 

  On 10/10/2020 at 6:26 AM, dylbill said:

 

You mean doing something like this?

 

 

You can use a LeveledItem object in the AddItem command directly and it will do everything for you, so there's no need to walk through the list and independently randomize the quantities.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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