 |
Zombies are attacking Red Rocket Truck Stop! Can you find them in this screenshot? |
Settlement Attacks vs Sleep Interruption
Zombie Walkers has had the Zombie Attacks mode for awhile but it was buggy and didn't always work. Also, this mode only worked by interrupting your sleep for an attack. It didn't trigger settlement attacks when characters were awake (usually daytime).
I re-organized the holotape settings to better describe the mode by calling it Sleep Interruption and added a new one called Settlement Attacks. Both modes can spawn attacks at different times and can be configured with different percentage chances (per hour).
Triggering Settlement Attacks
To cut right to the chase, to trigger a settlement attack using the built-in mechanism you must get a reference to the appropriate WorkshopScript and then call the CheckForAttack method with an argument of true for forced.
I found looking at the games built-in settlement scripts like WorkshopParent to be helpful For example, to get a collection of workshops in the game you add the following property to your script:
In my script, I chose to only trigger attacks when you are present at a settlement. There's nothing worse in Fallout 4 than being notified of attacks on the other side of the map. Also, with how I modified my attack it will begin immediately so you wouldn't get there to help anyhow.
There's a timer that runs to check for an attack every 30 minutes in game. The percentage chance is based on your holotape configuration setting (halved since the holotape setting is per hour).
Sleep Interrupted With No Attack?
The Sleep Interruption mode didn't always trigger an attack when CheckForAttack was called. To debug the issue, I eventually realized you can enable Story Manager debugging with the following ini setting:
bEnableStoryManagerLogging=1
I then saw the following line in StoryManager.0.log:
----Quest 'WorkshopZombieAttack' failed to fill aliases
Eventually I realized that I wasn't giving the game world enough time to load before trying to trigger the attack. Quest alias, like the workshop itself, won't fill if the objects are not yet loaded.
To "wake up" the Player I copied the approach used in the game's built-in survival script which is to call
playerRef.MoveTo(playerRef). Moving the player to their current location causes the screen to fade out and back in and the game world to reload, I guess to simulate waking up? To fix, I added a short wait after waking up the player but before triggering the attack with
Utility.Wait.
Only Zombie Attacks
The other thing I wanted to do was make sure that when settlement attacks are triggered only zombie attacks would result. To do this I updated the settlement attack quest properties in Character -> SM Event Node -> Script Event. I added a property to each settlement attack quest that basically says only allow this if Settlement Attacks mode is disabled. For my custom zombie attack quest if says only allow this if Settlement Attacks mode is enabled.
 |
Add property to WorkshopAttack quest scripts to disable all but zombie attacks. |
Zombie Attack Quest Tweaks
One final thing I did was modify the Zombie Attack Quest itself to add notifications when the attack is beginning and over at the appropriate Quest Stages (see the screenshot at the beginning of this post). The game has similar notifications already, but only for settlement attacks that you are not already present for. Since these attacks are limited to when you are at a settlement, I had to add my own.
The built-in settlement quests also delay the start and end of these quests. The start delay is to accommodate the player making their way to the settlement and the end for them to chat with settlers about helping them. I removed both of these delays by updating the appropriate Quest Stages so that the attack starts right away and the quest is completed once the 'all attackers dead' stage triggers. This allows another attack to immediately happen at any time without delay.
Update 1/23/2017
The settlement attack implementation has been updated to move away from the game's built-in quests. Please see
Better Settlement Attacks for details.
0 comments: