Tuesday, September 29, 2009

RR Companions AI Overhaul

I do not come bearing pictures.

The sad truth is that the work I've been doing doesn't lend itself to screenshotting well.

What have I been doing?

Once I finished with that weapons drawing command in the companion script I sorta... got on a roll.

Between my last post, and Monday night when I uploaded the more or less finalized testing plugin, I had damn near completely changed every facet of the non-following behavior of the companion system.

Have a peek at the readme:

As of right now, the experimental features added are:

1) A new system that allows raiders to attack Vault 1, no sooner than once every game-world-cell reset. This is four days, at the default setting. Note: there are a great many mods that change this value, and I cannot control which of them you run, so the respawn rate may vary.

The attacks now default to OFF, and must be enabled via the terminal on the front desk in the Guard House.

Please bear in mind that it would be a good idea to run a guards plugin before turning the attacks on.

The attack will always consist of six raiders, whose levels vary according to that of the player. The six will be randomly chosen from a list that consists of one of each type available at that level. These include "gun", "rifle" and "melee" until level eight, when the type "special" is added to the list.

ONLY female raiders spawn (this is ME making the mod, after all).

Note also: the trigger is written so that it does NOT require the player to be activated. The attack spawn can be activated by the player, by companions, by Guards, even NPCs if they roam into the entryway for whatever reason. Essentially, anything that steps into the trigger sets it off and initiates the attack.

Raiders can, however, NOT open the door leading into the vault. I considered changing this, but found it a realistic problem for the raiders. They'll loiter around outside, throwing curses through the door until you open it.

Raiders will NOT respawn while you are in the vault. You have to leave the vault and re-enter for the cell to reset, and the raiders to attack again.

Added a set of containers in the guard house, for arming and maintaining your defensive forces. There is now an ammo can, a locker, and a med-kit on the back wall, near the monitors.

The locker contains a large list of weapons. It uses leveled lists to spawn weapons from not only the vanilla game, but also many weapon mods, if you use them. Weapon locker contents are random, and will change from game to game. They also vary based on your level, at the time the plugin is activated. Note: weapon mod-added weapons will have their ammunition spawn in the weapons locker, and not in the ammo can. I plan to rectify this in the future, at least for CALIBR compatible mods.

The ammo can will contain many, many rounds of various types of ammo. Vanilla only, at this point. Sometimes, a stealth boy or two will also spawn. I have no idea why it does this, but don't consider it enough of a problem to embark upon a bug hunt.

The ammo can, med-kit, and weapon locker DO NOT respawn, ever.

The med-kit contains stimpacks only, and is intended to be used to supply the guards/NPCs in the vault, so that they can heal themselves as they take damage.

All three containers are restockable by dialog option, outlined below.



2) What I call the "sit package". A little scripting and a package that causes any companions using the Vault1companionscript to sit down when the player does -provided they are in your party at the time.

A small thing, but it adds a touch of character and realism, I think.

Conditions for sitting: You should note, the companions can be a bit flighty about sitting their pretty little butts down. It's almost random - some will sit in certain rooms, but not others. Some will sit next to you, or a seat down, or even on another piece of furniture altogether. Others don't seem to want to sit at all, sometimes.

The ones who opt not to sit, however, will still relax and pop open a Nuka Cola; unless they're wearing a full-face helmet. Covered mouth = no drink.


3) Draw! That's right, the companions now pull their weapons when you do, ensuring they are ready to throw down at a moment's notice. They relax and put the weapon(s) away when you do, provided they are not in combat.


4) Mail order your supplies. Okay, not really. The USPS may not exist in the Capital Wasteland, but that doesn't mean you have to actually venture outside to get ammo, meds, or some basic weapons. Speak to any one of your companions, the guards, or Sunny (the bartender) to make use of their "gray area" trader contacts. You can order loads of ammunition, stimpaks, miscellaneous meds, or weapons.

Packages only appear for sale if you have enough caps in your inventory to pay for it. Caps are automatically removed from your inventory when you make the purchase.

Ammo is spawned randomly from leveled lists. More and rarer ammunition are spawned as you buy more expensive packages. Ammunition is buyable in packages from one hundred to one thousand caps.

Stimpak orders always spawn stimpaks. The wholesale rate offered by the gray area contact generally amounts to ten caps per stim, varying a bit depending on how many stims spawn. Paks are ordered in packs costing from one hundred to five hundred caps.

Miscellaneous meds are orderable from the stimpak menu. Packages include a random assortment of medicine that is usually only used by the player - things like MedX, RadX, Rad-away, purified water, and the like. Packages of miscellaneous medicine cost a hundred caps each.

Weapons are mostly useful only as spare parts, or stopgap arms for early game companions and guards. Weapons spawn from leveled lists, and are consequently in generally poor condition. Packages are spawned from lists that include mod weapons, if you run such a package, so it's a good way to get a slew of mod weapons without having to traipse all over the wasteland looting raiders. Weapons come in packages of two hundred and five hundred caps each.

Each sale menu has an "I've changed my mind" option, so that you're never forced to buy if you don't want to.

Once purchased, contents of packages are added to the appropriate container in the Vault 1 entryway guard house instantly. This is a minor point of unrealism, but I didn't want to bog down the system with a timer. COnsider it ultra-super-futuristic-rush-delivery.


5) Companion wardrobe. All companions now have their own outfits, selectable by dialog. Outfits include Pre-War Casualwear, Regulator Duster, Merc Charmer Outfit, and Leather Armor. There is also a fifth option, "I'll give you an outfit to wear." which removes all companion outfits, and auto-opens the share window. If you select an outfit after putting a new set of armor into the companion's inventory, it will override the inventory item until the next time the companion assesses its equipment, when it will automatically equip the clothing/armor with the best DR rating.

The remove option will only affect the special companion-only clothing, and will NEVER remove items added to the companion's inventory normally.


6) Companion armory. All companions now have a set of their own weapons, selectable by dialog. Weapons include the 10mm Pistol, 10mm SMG, Sawed-Off Shotgun, and Sniper Rifle. All weapons have infinite ammunition, but are otherwise standard in rate of fire and damage. As with the armor, there is a fifth option, that removes all companion-only weaponry and opens the share window. Again, as with the armor, selecting a companion weapon via dialog will override any weapons in the companion's inventory, until the next time they assess their equipment, when the weapon with the highest damage (that they have ammunition for) will automatically be equipped.

The remove option will only affect the special companion-only weapons, and will NEVER remove items added to the companion's inventory normally.


7) Go to sleep. Selected by choosing "Why don't you lie down and get some sleep, while we have some time?" in the dialog menu. A for some reason often requested function, this option tells the companion to go to a nearby suitable bed, and go to sleep. The companion will sleep until awoken by the player. Note: this option does not remove the companion from your party.

The sleep system has already received a major overhaul. You may now order the companion to sleep in a specific bed, inside Vault 1. Choices include the player's bed, and all thirty of the NPC bedrooms.

The sleep packages have been overhauled for optimization as well, as I learned more about how they work.

Also note: with a "sleep anywhere" order, the companion will not sleep in a bed unless they're allowed to by the ownership. Example: companions can not sleep in the Megaton Common House, the Rivet City Common Room, or most NPC owned houses. A good rule of thumb is if you can't sleep in a bed, neither can they - with the notable exception of the naval cots in the Vault 1 entryway.

The sleep packages can be a bit wonky. Sometimes they terminate properly, and sometimes they don't.

Because of some lazy coding on Bethesda's part, the sleep packages don't "end" the way a travel package does. This has resulted in it being rather... problematic, to get the package removed and keep them from reverting to it the next time they're told to "stay here". Unfortunately, the packages also do not run like a normal package, and thus the conditional countermand I wrote never shows up in dialog choices.

As a (hopefully temporary) solution, I have added a trigger in the cave tunnel leading into Vault 1 that will forcibly strip any of the sleep packages from any NPC companion that is flagged as having been recruited when they walk through it. If a companion is having problems trying to return to bed whenever you tell them to stay, simply tell them to follow and walk them to the front door leading out into the wasteland, and back into the entryway. You don't have to actually change cells. You should then be able to tell them to stay with the correct sandbox package in place.


8) Relax here. Selected by choosing "Why don't you take a load off and relax here?" in the dialog menu, this is another function that I cannot see the immediate import of, but is a common request. This sets the companion to use a special sandbox package, intended to allow them to "live" in any cell outside vault 1 you care to leave them in. This option should not be used outdoors, in the wasteland, as the companion will likely wander off, and be difficult to find again without the aid of the tracking system.

This option only appears if you are in a cell other than Vault 1.

This function has its own special countermand, the dialog choice "Feel like coming with me again?", which will only appear if the companion is still running the special sandbox package. You should always use this order to cancel a relax command, rather than the generic follow command. When available, it will appear at the top of your list of dialog options.

While not its intended function, this command will also allow you to set up a "companion home" in any interior cell you care for. As long as the idle markers are there, the companions will use them.


9) Go Home. Not as often requested, but something I've wanted myself, this option - selected by choosing "Go back to the Vault and relax." from the dialog menu - will send the companion back to Vault 1, and then engage a sandbox package for them to live normally until needed again.

Note: once recruited, Vault 1 is the companions' home. This marker is not movable via dialog, and I have no plans to add a player-placeable home marker. If you want to force your companions to live in that shack in Megaton, you have to take them there yourself, and tell them to relax in that cell.

This command can be selected anywhere outside Vault 1, however the companion will move to the Vault normally, and will not teleport. Thus, it may take a day or more for them to get home, depending on where in the wasteland you are when you give the order.


10) Dialog reorder. I re-ordered some of the dialog options, in an attempt to make things friendlier, and less frustrating. Group orders and Breakup were moved down near the bottom of the list. I can't speak for anyone else, but I got tired of having breakup accidentally selected every time the damned menu lagged. Now a click during a lagging menu will most often select the resupply menu, or follow.


11) Dialog command adjustments. This one will likely be invisible to you, the end user, but it was important for those of us who create companions. The default follow command simply removed the top package from the companion's stack, as did the "stay here" command. These commands now call and remove the follow player and sandbox packages by name, so as not to screw up your package list, if you set one up on your custom companion so that they'd do more than sandbox in the vault.


12) Standard companion adjustments. Jill and Joan have had their inventories reset to use the new companion-only armor and weapons, without any "standard" items cluttering up their inventory. If you wish to change their weapon or outfit, just talk to them.


Note also: there are no group commands for sleep, relax here, or go home. This is not a bug, nor an oversight, and I have no intention of changing it.



As you can see, I did a whole mess of work. I've got to admit, I'm fairly proud of it. Provided it all works, these companions will not only be some of the most fully-featured available, but custom companions will also be easily created by the end user, oftentimes in less than twenty minutes apiece.

One of the big things about this whole mess of new features is that they all work with every companion created using the RR system, seamlessly and with no extra work on the end-user's part.

Not only is this huge for the users of Vault 1, but it's huge for me as well.

This batch of upgrades will finally bring the companion system and my own skills to the point that they needed to be to realize my full vision for my companions mod.

I can finally begin work in earnest, giving the girls the personalities, traits, equipment, and dialog that I've wanted since the beginning.

I've got no illusions that I'll finish the project in a week, but at least now I can finally start in on it and make real progress.

Once the new features are integrated into the master file, I'll bring the "base" version of my companions up to speed with the new stuff, and then start in on the in-depth version that will add personalities, quests, dialog, and so forth.

I have to say, I'm stunned, myself. Somewhere in the last three months I've become a competent modder. I wrote the script for stripping the sleeping packages from the companions free hand, without even checking the database for function references. Ditto for the clothing and weapon settings.

Never thought I'd be this guy. The one releasing big, well-featured mods that people like... always kinda figured I'd be relegated to retextures and occasionally changing a few values in someone else's work.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.