item_dynamic_resupply

From Valve Developer Community
Jump to: navigation, search
English (en)
class hierarchy
CItem_DynamicResupply defined in item_dynamic_resupply.cpp
CPointEntity
CBaseEntity

item_dynamic_resupply is a point entity available in Half-Life 2 Half-Life 2, Half-Life 2: Episode One Half-Life 2: Episode One, Half-Life 2: Episode Two Half-Life 2: Episode Two, and Half-Life 2: Deathmatch Half-Life 2: Deathmatch.

Entity description

This entity spawns an item that the player currently needs most (health, armor or ammo) and then removes itself. It is typically used in conjunction with item_item_crate, but it can also be found in the newgame_spawn / newgame_spawn_citadel prefabs, where several are used to give the player an ideal starting loadout for a map.

Its "Desired" keyvalues represent how much of each item the player should have in an ideal scenario. They are a ratio from 0 to 1. For example, if the Desired Armor is set to 0.3, that means we want the player to have 30% armor.

Each entity can only spawn one item each of the appropriate type to achieve the desired player inventory values. Also, the entity will not spawn an item if the player is already at or above the desired values, or if other existing items in the vicinity (in this entity's PVS, within 1024 Hammer Units) can help the player achieve those values.

Note.pngNote:This entity does not recognize the large variants of ammo packs, ammo crates (including the scout car's), health vials, or health/suit chargers as items that can help achieve the player's desired ratios.

When the player enters the PVS of this entity, it will determine the item(s) most needed by the player, spawn those items, and remove itself. To determine which item(s) the player most needs, it calculates which of the Desired Health/Armor/Ammo ratios the player is farthest from.

If the player is above all the desired levels, then no item will be spawned, unless this item_dynamic_resupply was created by an item_item_crate. In that case, a random piece of ammo used by a weapon, that the player has, will be spawned. If the 'Fallback to Health Vial' spawnflag is set, a health vial will be spawned instead of the ammo.

By default, the item_dynamic_resupply uses the values inside the Master resupply, instead of using it's own values. This makes it easy to tweak the desired loadout of many resupplies. The BecomeMaster input allows you to switch Masters dynamically as the level progresses.

Icon-Bug.pngBug:Loading saved games causes dynamic resupply masters to revert to how they were when the map spawned.
Note.pngNote:When this entity is killed via the Kill input, it will not tell an owner (if any) that it was Killed.[Why?] Normal Kill behavior can still be reached through KillHierarchy.

Flags

  •  [1] : Use Master's values
  •  [2] : Is Master
  •  [8] : Fallback to Health Vial
  •  [16] : Alternate Master

Keyvalues

Name (targetname) <string>
The targetname that other entities refer to this entity by.
Desired Health Ratio (DesiredHealth) <float>
Attempt to fill the player up to this percentage of their max health.
Desired Armor Ratio (DesiredArmor) <float>
Attempt to fill the player up to this percentage of their max armor.
Desired Pistol Ammo Ratio (DesiredAmmoPistol) <float>
Attempt to fill the player up to this percentage of their max ammo carrying capacity.
Desired SMG1 Ammo Ratio (DesiredAmmoSMG1) <float>
Attempt to fill the player up to this percentage of their max ammo carrying capacity.
Desired SMG1 Grenade Ammo Ratio (DesiredAmmoSMG1_Grenade) <float>
Attempt to fill the player up to this percentage of their max ammo carrying capacity.
Desired AR2 Ammo Ratio (DesiredAmmoAR2) <float>
Attempt to fill the player up to this percentage of their max ammo carrying capacity.
Desired Shotgun Ammo Ratio (DesiredAmmoBuckshot) <float>
Attempt to fill the player up to this percentage of their max ammo carrying capacity.
Desired RPG Ammo Ratio (DesiredAmmoRPG_Round) <float>
Attempt to fill the player up to this percentage of their max ammo carrying capacity.
Desired Grenade Ammo Ratio (DesiredAmmoGrenade) <float>
Attempt to fill the player up to this percentage of their max ammo carrying capacity.
Desired 357 Ammo Ratio (DesiredAmmo357) <float>
Attempt to fill the player up to this percentage of their max ammo carrying capacity.
Desired Crossbow Ammo Ratio (DesiredAmmoCrossbow) <float>
Attempt to fill the player up to this percentage of their max ammo carrying capacity.
Desired AR2 Alt-fire Ammo Ratio (DesiredAmmoAR2_AltFire) <float>
Attempt to fill the player up to this percentage of their max ammo carrying capacity.

Inputs

CalculateType
Force the dynamic resupply to calculate which item it should spawn.
BecomeMaster
Make this resupply the master resupply. All other resupplies set to Use Master's values will now use this resupply's values.

See also