Item dynamic resupply: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
(→‎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|Item dynamic resupply}}
{{lang|title=item_dynamic_resupply}}
{{hl2 point|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

English (en)Translate (Translate)

Template:Entity

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.  [todo tested in ?]
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.
C++ In code, it is represented by theCItem_DynamicResupplyclass, defined in theitem_dynamic_resupply.cppfile.

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.


Outputs

See also