Item dynamic resupply: Difference between revisions
Sage J. Fox (talk | contribs) (→Entity description: Specified what "items in the vicinity" means based on code. Also, an item_dynamic_resupply outside of a crate can spawn multiple items, per testing.) |
mNo edit summary |
||
Line 1: | Line 1: | ||
{{lang| | {{lang|title=item_dynamic_resupply}} | ||
{{ | {{entity|item_dynamic_resupply|type=e0|series=Half-Life 2}} | ||
==Entity description== | ==Entity description== |
Revision as of 13:10, 1 February 2023


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.

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.


Kill
input, it will not tell an owner (if any) that it was Kill
ed.[Why?] Normal Kill
behavior can still be reached through KillHierarchy
.
CItem_DynamicResupply
class, defined in theitem_dynamic_resupply.cpp
file.
Flags
- 1: Use Master's values
- 2: Is Master
- 8: Fallback to Health Vial
- 16: Alternate Master
Keyvalues
- Desired Health Ratio (DesiredHealth) ([todo internal name (i)]) <float>
- Attempt to fill the player up to this percentage of their max health.
- Desired Armor Ratio (DesiredArmor) ([todo internal name (i)]) <float>
- Attempt to fill the player up to this percentage of their max armor.
- Desired Pistol Ammo Ratio (DesiredAmmoPistol) ([todo internal name (i)]) <float>
- Attempt to fill the player up to this percentage of their max ammo carrying capacity.
- Desired SMG1 Ammo Ratio (DesiredAmmoSMG1) ([todo internal name (i)]) <float>
- Attempt to fill the player up to this percentage of their max ammo carrying capacity.
- Desired SMG1 Grenade Ammo Ratio (DesiredAmmoSMG1_Grenade) ([todo internal name (i)]) <float>
- Attempt to fill the player up to this percentage of their max ammo carrying capacity.
- Desired AR2 Ammo Ratio (DesiredAmmoAR2) ([todo internal name (i)]) <float>
- Attempt to fill the player up to this percentage of their max ammo carrying capacity.
- Desired Shotgun Ammo Ratio (DesiredAmmoBuckshot) ([todo internal name (i)]) <float>
- Attempt to fill the player up to this percentage of their max ammo carrying capacity.
- Desired RPG Ammo Ratio (DesiredAmmoRPG_Round) ([todo internal name (i)]) <float>
- Attempt to fill the player up to this percentage of their max ammo carrying capacity.
- Desired Grenade Ammo Ratio (DesiredAmmoGrenade) ([todo internal name (i)]) <float>
- Attempt to fill the player up to this percentage of their max ammo carrying capacity.
- Desired 357 Ammo Ratio (DesiredAmmo357) ([todo internal name (i)]) <float>
- Attempt to fill the player up to this percentage of their max ammo carrying capacity.
- Desired Crossbow Ammo Ratio (DesiredAmmoCrossbow) ([todo internal name (i)]) <float>
- Attempt to fill the player up to this percentage of their max ammo carrying capacity.
- Desired AR2 Alt-fire Ammo Ratio (DesiredAmmoAR2_AltFire) ([todo internal name (i)]) <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.