item_dynamic_resupply

From Valve Developer Community
Jump to: navigation, search

item_dynamic_resupply

is a point entity available in the Half-Life 2 series.

English (en)
Edit

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.


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) <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.

Base:
Name (targetname) <string>
The name that other entities use to refer to this entity.
Parent (parentname) <targetname>
Maintain the same initial offset to this entity. An attachment point can also be used if separated by a comma at the end. (parentname [targetname],[attachment])
Tip.pngTip:Entities transition to the next map with their parents
Tip.pngTip:phys_constraint can be used as a workaround if parenting fails.
Origin (X Y Z) (origin) <coordinates>
The position of this entity's center in the world. Rotating entities typically rotate around their origin.
Note.pngNote:Hammer does not move the entities accordingly only in the editor.
Pitch Yaw Roll (X Y Z) (angles) <angle>
This entity's orientation in the world. Pitch is rotation around the Y axis, yaw is the rotation around the Z axis, roll is the rotation around the X axis.
Note.pngNote:This works on brush entities, although Hammer doesn't show the new angles.
Classname (classname) <string> !FGD
Determines the characteristics of the entity before it spawns.
Tip.pngTip:Changing this on runtime still has use, like making matching an entry in S_PreserveEnts will persist the entity on new rounds!
Flags (spawnflags) <flags> !FGD
Toggles exclusive features of an entity, its specific number is determined by the combination of flags added.
Effects (effects) <flags> !FGD
Combination of effect flags to use.

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.

Base:
AddContext <string>
Adds to the entity's list of response contexts. See Context.
AddOutput <string>
Assigns a new keyvalue/output on this entity. For keyvalues, some rely on extra necessary code to be ran and won't work if its simply just changed through this input. There is a strict format that must be followed:
// Format of changing KeyValues: "AddOutput [key] [value]"
//// Raw text:
"OnUser1" "!self,AddOutput,targetname new_name"

// Format of adding an Output: "AddOutput {targetname}:{inputname}:{parameter}:{delay}:{max times to fire, -1 means infinite}"
//// Raw text:
"OnUser1" "!self,AddOutput,OnUser1:SetParent:!activator:0.0:-1"
// Arguments can be left blank, but the empty blank should still be contained.
//// Raw text:
"OnUser1" "!self,AddOutput,OnUser1:ClearParent::0.0:-1"
ClearContext
Removes all contexts from this entity's list.
ClearParent
Removes this entity from the the movement hierarchy, leaving it free to move independently.
FireUser1 to FireUser4
Fires the respectiveOnUseroutputs; see User Inputs and Outputs.
Kill
Removes this entity and any entities parented to it from the world.
KillHierarchy
Functions the same as Kill, although this entity and any entities parented to it are killed on the same frame, being marginally faster thanKillinput.
RemoveContext <string>
Remove a context from this entity's list. The name should match the key of an existing context.
SetParent <string>
Move with this entity. See Entity Hierarchy (parenting).
SetParentAttachment <string>
Change this entity to attach to a specific attachment point on its parent. The entity will teleport so that the position of its root bone matches that of the attachment. Entities must be parented before being sent this input.
SetParentAttachmentMaintainOffset <string>
As above, but without teleporting. The entity retains its position relative to the attachment at the time of the input being received.
Use  !FGD
Same as a player invoking +use; no effect in most cases.
DispatchResponse <string> !FGD
Dispatches a response to the entity. See Response and Concept.
DispatchEffect <string> (removed since Left 4 Dead) !FGD
Dispatches a special effect from the entity's origin; See also List of Client Effects. Replaced by the particle system since Left 4 Dead.

Outputs

Base:

OnUser1 to OnUser4
These outputs each fire in response to the firing of the like-numbered FireUser1 to FireUser4 Input; see User Inputs and Outputs.

See also