Fallout 3

File information

Last updated

Original upload

Created by

Imp of the Perverse

Uploaded by

Imp of the Perverse

Virus scan

Safe to use

About this mod

This is a resource that can be shared by multiple mods, used to add script tokens to the inventories of every actor in the wasteland.

Permissions and credits
Inventory Access
R1.0

by Imp of the Perverse




_____________

Description:
_____________

This resource gives modders an easy way to place an item into the inventory of every actor in the capital wasteland. It's intended to be used with tokens running object scripts.


________________

Ideas/Requests:
________________

A mod that monitors the air temperature calculated by Ambient Temperature, and uses it to determine what gear wasteland NPC equip.

A mod that monitors NPCs with grenades, and creates an explosion if they were killed before having the chance to throw the grenade they just pulled the pin from.

A mod that adjusts the heights of all wasteland NPCs using setscale, based on their SPECIAL stats (my mod SPECIAL Based Player Height will perform that function for the player). The one drawback here is that I don't think SPECIAL varies that much throughout the wastes.


________________________

Directions for Players:
________________________

If you're using a mod that requires this resource, add this .esm to your load order with the rest of your .esms, higher in your load order than any mods that require it.


________________________

Directions for Modders:
________________________

Create a quest in your mod marked as "Begin Enabled". The quest's script should consist of the following lines:

scn YourQuestQuestScript

begin gamemode
AddFormToFormList IAPiggyBackList YourItem
stopquest YourQuest
end

Where YourQuest is the name of your quest, and YourItem is a script token that you've created - a piece of armor with the "playable" flag left unchecked to prevent it from being seen if the player kills the actor whose inventory it was in. Due to some complications that can arise if a mod that uses this resource is later removed, the above code should always be used (using the FOSE command ListGetFormIndex will crash the script).

The object script you place on that token can then be used to do any number of things. I'm using one to cause power armor wearers to explode if you hit them in the MicroFusion Pack, and to add a number of power armor upgrades to their inventories. I decided to create this resource when I thought up another use - adjusting NPC's equipped armor to suit the weather.

In general, you'll want to set a reference variable using the line:

set myRef to getcontainer

myRef will then point to the actor whose inventory your script is running in. You can use myRef in conditional statements to find out what kind of actor myRef is (NPC, molerat, behemoth...), what weapon they're using, what they're wearing, what faction they're in, etc., and react accordingly.

Don't bother removing your token if it's not in the right inventory - Inventory Access will just add it in again. I'd suggest just wrapping all of your code in a conditional that checks if a variable is 0 or 1 - if the actor is one your code applies to, leave the variable 0 to let the code continue to execute. If the actor is something else, set the variable to 1 to stop execution.


IMPORTANT:

If you want to use your script to change the actor's equipped gear, there is an AI bug that will occur if the equipitem statement is executed during gamemode - the actor's AI will freeze up and they'll just stand there rather than attacking, talking, or otherwise going about their business.

To fix this, first create a dummy armor object - right click in the GECK object browser's armor section, select "Create New", give the armor a FORMID, but otherwise leave all entries at their defaults (blank in most cases). In your object script, do the following:

1. Add 1 of your dummy armor objects to the actor's inventory
2. Equip the dummy armor object with the EquipItem command
3. Add and equip the gear you wanted to equip (the dummy armor has no biped slots selected, so it will not interfere with any equipment you want to equip)
4. Delay a frame or two (use a counter)
5. Remove the dummy armor WITHOUT first unequipping it. It helps if you attempt to remove 2 copies of it (removeItem dummyarmor 2)

Removing the equipped dummy armor will somehow kickstart the AI again after it hangs up.

Also, keep it in mind that other modders will likely be using this same method to change the actor's gear. If you both use code like this:

IF actor.getequipped myArmor == 0
actor.additem myArmor 1
actor.equipitem myArmor
ENDif

The actor's equipped armor will bounce back and fourth between your two mods (not a good thing). It would be better to do this, and otherwise leave things up to chance:

IF sDoOnce == 0
actor.additem myArmor 1
actor.equipitem myArmor
set sDoOnce to 1
ENDif

Even better, run a check a few frames later and remove your armor or weapon if it's no longer equipped (unless you're feeling generous).




________________

Implementation:
________________

This mod uses FOSE's ref walk commands to step through all of the actors in the player's current cell, and the surrounding eight cells, every time the player enters a new cell. Each actor's inventory is checked to see if it contains a PiggyBackToken, and if it does not, the token is placed there. A script running on that token then steps through each entry in the PiggyBackList formlist, checking to see if that entry is in the actor's inventory. If it's not, the script adds one. The process is repeated each time a new entry is added to the PiggyBackList - each time the player adds a new mod that uses this resource.

There's nothing stopping you from performing your own ref walk, but if a dozen mods in a player's load order are all performing one at about the same time, there's the potential for performance and stability issues. There are also some strange quirks associated with ref walks (conditionals will occasionally fail during the course of the walk, etc.) and this resource has been written with them in mind. Hopefully it should provide an easy, stable way for everyone to use this powerful tool.




______

Mods:
______

Powered Power Armor R1.4 gold (soon to be released)