I did a bit of GECK work today on randomly hiding skillbooks. I tied into the OnLoad event in a script, along with 2 global variables.
Global Variables:
RndSBBaseChance = 60
RndSBLuckScale = 3.00
The concept being that the % chance that a skill book will appear is (Base + (Luck * Scale)). So for a Luck of 8, there's an 84% chance that the book will appear. For an average Luck of 5, where there are 25 books seeded, they will see 18.75 books on average. A minimal Luck of 1 gets you 15-16 books, a maximum Luck of 10 gets you 22-23 books (out of a possible 25).
Naturally, as I add more manually placed skillbooks to the wastes, I plan on changing those values slightly so that an average luck gets you around 18-19 books, with a minimum down around 15-16 and a maximum around 23-24.
Debug message entity:
Randomized Skill Books - Book %.0f - OnLoad - Base %.0f - Luck Scale %.2f - ChanceMin %.0f - Rnd %.0f
I defined 12 global variables with values of 1-12 so that I can pass those to the debug line. That lets me spit out a debug message box every time the OnLoad event fires for a given skillbook. So the code ends up looking like:
scriptname RndSBBarter; Randomly controls whether a Barter skill book will appearshort DoOnceOnLoad ; make sure we only do things onceshort RandomChance ; 0-100 randomshort ChanceToAppear ; threshold; Gets run once when the scripted object's 3D environment loads.; For interior cells, this is upon first entrance. For exterior cells,; they get loaded in a 5x5 grid centered on the player. It will not; run if you are re-entering a cell that you just left. Executes; the first time that the player visits the cell where the skill book; is located.Begin OnLoad If ( DoOnceOnLoad == 0 ) ; Get number between 0 and 100 Set RandomChance to GetRandomPercent ; RandomChance has to be <= ChanceToAppear for book to appear Set ChanceToAppear to RndSBBaseChance + (Player.GetAV Luck * RndSBLuckScale) ; Display debug message ShowMessage RndSBDebugMsg RndSBIDBarter RndSBBaseChance RndSBLuckScale ChanceToAppear RandomChance If (RandomChance <= ChanceToAppear) ; Do nothing, leave the book alone Else ; Disable and remove this skill book Disable MarkForDelete EndIf ; Make sure we don't execute the contents of this loop more then once Set DoOnceOnLoad To 1 EndIfEnd
I'm going to play with it for a while, it seems stable because it's so simple - but I need to verify some corner cases where skillbooks are not placed in the world, but are inside containers or carried by NPCs. I also need to add a lot of hand-placed skillbooks across the wastes so that there's less of a chance that a particular location will have the skill book show up. Unlike your Unfound scripts where you created new IDs for everything, I chose to just use the regular ID rather then go through and do a massive change.
Individual variables for each book type might be useful, but I'll just make sure to add an equal number of each book type. It's at least a start on something that I've been wanting to do for 9+ months now.
That being said... when I got the Big Book of Science from Moira as a quest reward and then dropped it on the ground, OnLoad got called. So gotta think about this a bit more.
(Later) Well, that was easy enough... OnDrop gets called before OnLoad, so I just set the "flag" variable to 1 in OnDrop, which short-circuits the OnLoad event as written.