Jump to content

Adding a random amount of gold to a chest(container)?


ThePearl

Recommended Posts

Hey there!

 

I am working on my first scripted mod and I could use some help.

 

I read the tutorials on the cs.elderscrolls wiki as well as doing some search, but I can't find a tutorial on adding a random amount of gold to a container every day or week. I copied the OrumGangHollowRock and addded my own script, I haven't gotten far at all. But I have gotten this far!:

 

begin OnLoad

end

 

Yeah, real far huh? I could really use some help :), it'd be much appreciated

Link to comment
Share on other sites

ScriptName YourScript

Short CalcVar
Short InitVar
Short LastOpened

Begin OnActivate
 If InitVar == 0; if this is the first time opening, just place a random amount
ContainerRef.AddItem F GetRandomPercent
Set InitVar to 1
 Else
If GameDaysPassed > LastOpened; only add amount once per day
  Set CalcVar = (GameDaysPassed - LastOpened) * GetRandomPercent
  ContainerRef.AddItem F CalcVar
Endif
 Endif

 Set LastOpened to GameDaysPassed

 Activate
End

 

"ChestRef" is the name you have given to your container; it needs to be a persistant reference Before applying this script.

 

GetRandomPercent returns a number between 0 and 99. If you want to increase or decrease the amount, then you would need to adjust accordingly, such as (GetRandomPercent * 2) or (GetRandomPercent/2).

 

As written, the amount is added every time the chest is opened. To have it start over again, add the line ChestRef.RemoveAllItems before the lines that have "AddItem" in them.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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