This article relates to the game "Half-Life: Alyx". Click here for more information.
This article relates to the workshop tools for "Half-Life: Alyx". Click here for more information.
This article's documentation is for Source 2. Click here for more information.

Ammo Balancing in Half-Life : Alyx

From Valve Developer Community
Jump to: navigation, search


English (en)
... Icon-Important.png

Half-Life: Alyx Ammo Types

Ammo balancing creates part of the core tension in Half-Life: Alyx by dynamically adjusting the player's available resources. This creates a feeling that ammo and resources are constantly running low and that the player needs to consider every decision when engaging enemies. This effect is achieved by using several dynamic systems that try to remove outliers, and keep players at the desired level of danger. The two dynamic ammo balancing systems used in Half-Life: Alyx are Ammo Removal and Ammo Drain. Both systems rely on values set in the Skill.cfg file located in the Half-Life Alyx\game\hlvr\cfg directory.


Ammo Removal

Ammo Removal is a dynamic system that will remove resources (ammo, grenades, and health syringes) from the world if the player has too much of any individual resource. It can be enabled by setting that removal is allowed for ammo balancing on most items.

Remove ammo setting.png

Much like how most games have a maximum carriable amount of ammunition for each weapon, Half-Life: Alyx's Ammo Removal system strives to keep the player's inventory within certain thresholds. These thresholds for default ammo removal can be found in the Skill.cfg file. Below are the default values used for the normal difficulty level:

hlvr_player_ammobal_removeat_pistol		"60"

hlvr_player_ammobal_removeat_shotgun		"12"

hlvr_player_ammobal_removeat_rapidfire		"150"
Due to the "all or nothing" system, supplies are often given one at a time

The game checks the player's inventory (including ammo in each weapon) against these values when an item is loaded. Items are loaded in two ways:


  1. When the player enters the Potential Visibility Set of the item.
  2. When a point_template is triggered to spawn an item.


When either of these occur and the player has more of a resource type than the threshold for ammo removal, the spawned item is removed. Keep in mind, this includes items in the player inventory including grenades. If the player has grenades in their inventory, a new one will not be spawned.


Unlike grenades, health syringes have specific criteria which determine if they should be removed, including the following scenarios:


  1. If the player does not have a syringe in their inventory AND has full health, there is a random chance the syringe will be removed.
  2. If the player does not have a syringe in their inventory AND has less than full health, the syringe will always be spawned.
  3. If the player has a syringe in their inventory, the item will not spawn.


Lastly, there are additional nuances to the Ammo Removal system to prevent player frustration from having too many items removed as a result of the player having high resource levels. As such, the Ammo Removal system uses a counter to track how many resources have been removed. After seven items have been removed, the eighth one will not be. After the eighth item is not removed, the counter starts again.


Note.pngNote:PVS in HLA is finicky and not easily defined by the designer. As such, Valve typically uses point_templates to spawn resources for players throughout the game since they are more easily controllable.
Warning.pngWarning:THIS SYSTEM IS NOT AWARE OF NEARBY ITEMS THE PLAYER HAS NOT PICKED UP! Exercise caution when spawning ammo to ensure the player has adequate time to loot an area before spawning additional resources.

Ammo Drain

The Ammo Drain system is designed around long-term ammo balancing across several levels or even chapters. This system revolves around randomly decreasing player damage to create uncertainty in the time-to-kill of each enemy. Over time, the fluctuations in player damage are adjusted as the player exceeds certain ammo values. The main goal of the Ammo Drain system is to force the player into expending marginally more resources to eliminate enemies, usually in the form of requiring the player to shoot enemies a couple additional times.


The thresholds for ammo drain can be found in the Skill.cfg file. Below are the default values used for the normal difficulty level:

hlvr_player_ammobal_min_pistol				"20"
hlvr_player_ammobal_max_pistol				"60"

hlvr_player_ammobal_min_shotgun				"8"
hlvr_player_ammobal_max_shotgun				"12"

hlvr_player_ammobal_min_rapidfire			"90"
hlvr_player_ammobal_max_rapidfire			"150"

At the hlvr_player_ammobal_min value, or when the player is low on ammo, the system does not affect the player's damage. The probability that the player's damage is decreased raises as the player approaches hlvr_player_ammobal_max, or when the player has sufficient ammo. After the hlvr_player_ammobal_max value is reached, the system will continue to increase the probability that the player's damage will be decreased. If a shot fired is randomly decided to have it's damage adjusted, the damage will be capped to specified values for each weapon.


The drained damage values for each weapon can be found in the Skill.cfg file. Below are the default values used for the normal difficulty level:

hlvr_player_ammobal_drain_pistol			"4"

hlvr_player_ammobal_drain_shotgun			"6"

hlvr_player_ammobal_drain_rapidfire			"4"

This system does not substantially affect certain weapons, like the shotgun, due to the number of pellets fired per shot, and its high default damage.


For comparison, below are the default damage values for each weapon on the normal difficulty level:

vr_energygun_dmg						"8"

vr_energygun_handcannon_dmg					"6"

vr_rapidfire_dmg						"4"

However, there are upper limits to these adjustments, and they do not apply to all enemy types. Valve included a failsafe to ensure enemies die within a reasonable number of shots. The system sets maximum values for the number of shots that certain enemies can take to be defeated regardless of random damage decreases.


The maximum additional shots required to kill enemies can be found in the Skill.cfg file. Below are the default values used for the normal difficulty level:

sk_zombie_max_additional_ammo_shots		"18"
sk_headcrab_max_additional_ammo_shots		"4"
sk_barnacle_max_additional_ammo_shots		"8"
sk_combine_max_additional_ammo_shots		"16"

An enemy cannot take more shots to kill than these values. However, due to differences in enemy health, weapon damage, and difficultly level, in certain circumstances, these values cannot be reached.


Overall, this system is reminiscent of ammo balancing systems seen in other survival-action games and helps create uncertainty, prevents players from "counting their shots", and controls ammo from "snow-balling," but due to its randomness, has little short-term effects.

Best Practices

These ammo balancing systems are not meant to prevent the player's inventory from "snowballing" just slow it down.

It encourages the player's inventory to stay in a certain area, but it does not prevent it from exceeding that. Thorough players can still find an advantage.

These won't solve poor designer choices.

With that in mind, below are some tips and tricks to take advantage of these systems, while also encouraging good design for Half-Life: Alyx's gameplay.

Ammo Pacing

The Combine Locker prefab is often used to efficiently spawn ammo

Since the Ammo Removal system checks the player's current ammo state, it is often best to "trickle" items. Placing them farther apart will give the system time to adapt to the player's ammo situation.

This works best in linear layouts, but through use of objects such as Combine Lockers, the designer can check the player's ammo state at the exact time the ammo is discovered.

Below is an example of firing an output right when the locker is opened:

My Output Target Entity Target Input Parameter Delay
Ouput_OnHackSuccess [locker_template] ForceSpawn 0.00

Though, this can be used outside of Combine Lockers. Pad-Locked supply closets, closed containers, or even some drawers, can have the items spawn right when they are opened.

This gives designers more flexibility in less linear environments. However, having every box opened be empty can hurt exploration, so it's advised to not have all items be removable.

Pacing scavenging can help reduce fatigue



Pacing items like this has additional benefits.

"Scavenging fatigue" is real, and can be quite annoying if not accounted for. Picking up 20 items in 20 seconds WILL get annoying. Especially considering the extra interactivity required of VR, making sure a player isn't constantly opening every drawer, and shoving stuff in their backpack, can help keep them engaged.

Paced ammo also helps prevent player mishap. Large stockpiles, spread out, increase the risk of the player miss-using their ammo and running out. Depending on the time between stockpiles, a player may blame the designer, and not some mistake they made 5 rooms ago. In Half-Life: Alyx, running out of ammo is considered a "fail state", so players should understand why they have essentially "lost".


Ammo Variety

Keeping supplies varied ensures the player always has options

Both the Ammo Removal and the Ammo Drain systems do their calculations on a per weapon basis. This means keeping caches of supplies varied will help prevent the system from removing everything.

For example, a player may not need pistol ammo, so it all gets removed, but they do need shotgun ammo, so that still spawns.

Keeping the ammunition the player has varied also helps prevent the player from completely running out, while still giving them the feeling that they could.

If a player manages their ammunition poorly, they are more likely to "run dry" on a specific weapon. This can lead to dynamic tactics changes--often to sub-optimal ones. It is not optimal (or feel good) to kill an antlion with only a shotgun, but if that's all a player has left, that is what they must do. Playing past mistakes like this can often feel better and more immersive then simply running out of ammo and "losing", requiring a re-load.

See also