Logic playerproxy: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
mNo edit summary
(Extra example of logic_playerproxy)
 
(48 intermediate revisions by 21 users not shown)
Line 1: Line 1:
{{base point ep1|logic_playerproxy}} It is used to relay inputs/outputs to the player and back to the world.
{{LanguageBar}}
{{CD|CLogicPlayerProxy|file1=logic_playerproxy.cpp}}
{{this is a|logical entity|name=logic_playerproxy|sprite=playerproxy_this_icon_from_black_mesa_game.png|game=Half-Life 2 series|game1=Portal series|game2=Alien Swarm|game3=Counter-Strike: Global Offensive|game4=Black Mesa}}
 
It is used to relay inputs/outputs to the player and back to the world.
 
{{note|Outputs will only fire on the first instance of this entity in the map.}}
 
{{note|This entity is primarily intended for use in singleplayer, but all of the games it is present in can be played in multiplayer as well, even if they were not designed with it in mind. Thus, the entity exhibits varying behavior in multiplayer depending on the game:
* In [[Orange Box]] games and Portal 2, outputs will fire correctly, with the player that triggered the output as the {{ent|!activator}}.
* In Orange Box games, inputs will affect the most recently connected player.
* In Portal 2, inputs will do nothing and produce the console message <code>Can't use logic player proxy in multiplayer!</code> (which is slightly erroneous, as outputs still work as mentioned previously).
* In Alien Swarm and CS:GO (which are multiplayer only), the entity does not function at all.
}}


== Keyvalues ==
== Keyvalues ==
{{KV Targetname}}
{{KV Targetname}}
{{KV DamageFilter}}
{{KV DamageFilter|Damage filter that also needs to be passed when player takes damage}}


== Inputs ==
== Inputs ==
{{IO|RequestPlayerHealth|Requests the current player's health from the proxy. This will fire the PlayerHealth output with the value.}}
{{IO|SetFlashlightSlowDrain|Puts the player's flashlight in slow-power-drain mode (for Episodic darkness)}}
{{IO|SetFlashlightNormalDrain|Puts the player's flashlight to default power drain}}
{{IO|SetPlayerHealth|Sets the player's health to this value.|param=integer}}
{{IO|RequestAmmoState|Request the ammo state of the player. It will fire PlayerHasAmmo or PlayerHasNoAmmo outputs.}}
{{IO|LowerWeapon|Lowers the players weapon.|since=EP2}}
{{IO|EnableCappedPhysicsDamage|Cause player to take less damage from physics objects, and never more than 30 points from any individual strike.|since=EP2}}
{{IO|DisableCappedPhysicsDamage|Undo effects of EnableCappedPhysicsDamage|since=EP2}}
{{IO|SetLocatorTargetEntity|Set the entity that the HUD locator should track. (Usually a vehicle)|param=string|since=EP2}}
{{IO|AddPotatosToPortalgun|Change portalgun bodygroup to show potatos.|since=P2}}
{{IO|RemovePotatosFromPortalgun|Change portalgun bodygroup to not show potatos.|since=P2}}
{{IO|SetDropEnabled|Set wether the player is allowed to drop a carried object.|param=bool|since=P2}}
{{IO|ForceVMGrabController|Force the player to use the view model grab controller for all objects that are picked up.|since=P2}}
{{IO|ForcePhysicsGrabController|Force the player to use the physics grab controller for all objects that are picked up.|since=P2}}
{{IO|ResetGrabControllerBehavior|Resets the grab controller used by the player to its default behavior.|since=P2}}
{{IO|SetMotionBlurAmount|Forces the motion blur effect on the player. Set to < 0 to disable this override.|param=float|since=P2}}
{{I Targetname}}
{{I DamageFilter}}
{{I DamageFilter}}
=== {{hl2}}{{portal}}{{bms}} Half-Life 2, HL2 Episodes, Portal and Black Mesa ===
{{I|RequestPlayerHealth|Requests the current player's health from the proxy. This will fire the PlayerHealth output with the value.}}
{{I|SetFlashlightSlowDrain|Puts the player's flashlight in slow-power-drain mode (for Episodic darkness)}}
{{I|SetFlashlightNormalDrain|Puts the player's flashlight to default power drain}}
{{I|SetPlayerHealth|Sets the player's health to this value.|param=integer}}
{{I|RequestAmmoState|Request the ammo state of the player. It will fire PlayerHasAmmo or PlayerHasNoAmmo outputs.}}
{{I|EnableCappedPhysicsDamage|Cause player to take less damage from physics objects, and never more than 30 points from any individual strike.}}
{{I|DisableCappedPhysicsDamage|Undo effects of EnableCappedPhysicsDamage}}
=== {{hl2}}{{portal}} Half-Life 2, HL2 Episodes and Portal ===
{{I|LowerWeapon|Lowers the players weapon.}}
{{I|SetLocatorTargetEntity|Set the entity that the HUD locator should track. (Usually a vehicle)|param=string|only={{ep2}}}}
:{{note|Also works in [[Episode One]] since [[Source 2007]], if the resources are ported.}}
{{I|SuppressCrosshair|Hides the crosshair.|nofgd=1|only={{portal}}}}
:{{note|Unlike the command <code>crosshair 0</code>, the crosshair is enabled again when a new game is started or a save made before firing the input is loaded.}}
:{{note|Added in the March 3rd, 2010 update. Seems to be a backported Portal 2 input that was removed from Portal 2 before release.}}
{{I|OnPlayerStartedGame|Indicates that the player started the game from the beginning and leaderboard stats should be tracked.|nofgd=1|only={{psa}}}}
{{I|OnPlayerBeatGame|Saves the current time, portal, and step scores to the leaderboard if OnPlayerStartedGame was fired previously.|nofgd=1|only={{psa}}}}
=== {{portal2}} Portal 2 ===
{{I|AddPotatosToPortalgun|Change portalgun bodygroup to show PotatOS.}}
{{I|RemovePotatosFromPortalgun|Change portalgun bodygroup to not show PotatOS.}}
{{I|SetDropEnabled|Set whether the player is allowed to drop a carried object.}}
{{I|ForceVMGrabController|Force the player to use the view model grab controller for all objects that are picked up.}}
{{I|ForcePhysicsGrabController|Force the player to use the physics grab controller for all objects that are picked up.}}
{{I|ResetGrabControllerBehavior|Resets the grab controller used by the player to its default behavior.}}
{{I|SetMotionBlurAmount|Forces the motion blur effect on the player. Set to <<nowiki>=</nowiki> 0 to disable this override.|param=float}}
{{I|PaintPlayerWithPortalPaint|Displays a Conversion Gel splashing effect on the player's screen.|nofgd=1}}
{{Expand|title={{P2CE|4}} only inputs|
{{I|SetFallDamageEnabled|Enables or disables fall damage on the player.|param=bool}}
{{I|GiveBoots|Gives long fall boots to the player.}}
{{I|RemoveBoots|Removes long fall boots to the player.}}
{{I|GivePaintGunFull|Gives the player a full paint gun.}}
{{I|GivePaintGunBasic|Gives the player a basic paint gun.}}
{{I|RemovePaintGun|Removes the player's paint gun.}}
{{I|RemovePortalGun|Removes the player's portal gun.}}
}}


== Outputs ==
== Outputs ==
{{IO|OnFlashlightOn|Fired when the player turns on his flashlight. This output has the value of how much energy the player had when this happened [0..1].|param=float}}
 
{{IO|OnFlashlightOff|Fired when the player turns off his flashlight. This output has the value of how much energy the player had when this happened [0..1].|param=float}}
=== {{hl2}}{{portal}}{{bms}} Half-Life 2, HL2 Episodes, Portal and Black Mesa ===
{{IO|PlayerHealth|The player's current health value.|param=integer}}
 
{{IO|PlayerHasAmmo|Fired by request if the player has any ammo.}}
<!--PlayerDied and PlayerHealth are technically in all games, but can only fire in Half-Life 2/Portal/Black Mesa-->
{{IO|PlayerHasNoAmmo|Fired by request if the player doesn't have any ammo.}}
{{O|PlayerDied|Fires when the player dies.}}
{{IO|PlayerMissedAR2AltFire|Player fired an AR2 combine ball that didn't kill any enemies.|since=EP2}}
{{O|PlayerHealth|Outputs the player's current health value.|param=integer}}
{{IO|PlayerDied|Fires when the player dies.|since=EP2}}
{{O|OnFlashlightOn|Fired when the player turns on their flashlight. This output has the value of how much energy the player had when this happened [0..1].|param=float}}
{{IO|OnStartSlowingTime|Fired when a Portal player initiates slow time.|since=AS}}
{{O|OnFlashlightOff|Fired when the player turns off their flashlight. This output has the value of how much energy the player had when this happened [0..1].|param=float}}
{{IO|OnStopSlowingTime|Fired when a Portal player stops slowing time.|since=AS}}
{{O|PlayerHasAmmo|Fired by request if the player has any ammo.}}
{{IO|OnPrimaryPortalPlaced|Fired when a Portal player successfully places the primary portal.|since=P2}}
{{O|PlayerHasNoAmmo|Fired by request if the player doesn't have any ammo.}}
{{IO|OnSecondaryPortalPlaced|Fired when a Portal player successfully places the secondary portal.|since=P2}}
{{O|PlayerMissedAR2AltFire|Player fired an AR2 combine ball that didn't kill any enemies.|not={{hl2}}}}
{{IO|OnDuck|Fired when a player starts to duck.|since=P2}}
 
{{IO|OnUnDuck|Fired when a player releases the duck button.|since=P2}}
=== {{portal2}}{{bms}}{{csgo}} Portal 2, Counter-Strike Global Offensive and Black Mesa ===
{{IO|OnJump|Fired when a player jumps.|since=P2}}
 
{{O Targetname}}
{{O|OnDuck|Fired when a player starts to duck.}}
{{O|OnUnDuck|Fired when a player releases the duck button.}}
{{O|OnJump|Fired when a player jumps.}}
:{{bug|These are technically in Counter-Strike: Global Offensive and Black Mesa, but don't work.|hidetested=1}}
 
=== {{portal2}} Portal 2 ===
 
{{O|OnPrimaryPortalPlaced|Fired when a Portal player successfully places the primary portal.}}
{{O|OnSecondaryPortalPlaced|Fired when a Portal player successfully places the secondary portal.}}
{{O|OnCoopPing|Fired in response to the unused <code>+coop_ping</code> command. Normal pings do not fire this output; use {{ent|info_player_ping_detector}} instead.|nofgd=1}}
<!--These are in regular Portal 2, but never fire because slowtime was removed-->
{{O|OnStartSlowingTime|Fired when a Portal player initiates slow time.|only={{P2CE}}}}
{{O|OnStopSlowingTime|Fired when a Portal player stops slowing time.|only={{P2CE}}}}
 
== External links ==
'''Map example .VMF (Checks player health) - By RabidMonkey'''
* https://twhl.info/index.php/vault/view/5362
 
'''Map example .VMF and .BSP (Checks if player died and dissolves ragdoll) - By Jora'''
* http://gtamike.tsgk.com/gtamike_TSGK/logic_playerproxy.rar
 
'''Map example .VMF and .BSP (Checks if player died and plays a random death sound) - By Jora and gtamike_TSGK'''
* http://gtamike.tsgk.com/gtamike_TSGK/logic_playerproxy_alt.rar
 
[[Category:IO System]]

Latest revision as of 11:26, 21 August 2025

English (en)中文 (zh)Translate (Translate)
C++ Class hierarchy
CLogicPlayerProxy
CLogicalEntity
CServerOnlyEntity
CBaseEntity
C++ hl2_player.cpp
Playerproxy this icon from black mesa game.png

logic_playerproxy is a logical entity available in Half-Life 2 series Half-Life 2 series, Portal series Portal series, Alien Swarm Alien Swarm, Counter-Strike: Global Offensive Counter-Strike: Global Offensive, and Black Mesa Black Mesa.

It is used to relay inputs/outputs to the player and back to the world.

Note.pngNote:Outputs will only fire on the first instance of this entity in the map.
Note.pngNote:This entity is primarily intended for use in singleplayer, but all of the games it is present in can be played in multiplayer as well, even if they were not designed with it in mind. Thus, the entity exhibits varying behavior in multiplayer depending on the game:
  • In Orange Box games and Portal 2, outputs will fire correctly, with the player that triggered the output as the !activator.
  • In Orange Box games, inputs will affect the most recently connected player.
  • In Portal 2, inputs will do nothing and produce the console message Can't use logic player proxy in multiplayer! (which is slightly erroneous, as outputs still work as mentioned previously).
  • In Alien Swarm and CS:GO (which are multiplayer only), the entity does not function at all.

Keyvalues

Name (targetname) <string>[ Edit ]
The name that other entities refer to this entity by, via Inputs/Outputs or other keyvalues (e.g. parentname or target).
Also displayed in Hammer's 2D views and Entity Report.
See also:  Generic Keyvalues, Inputs and Outputs available to all entities

DamageFilter:

Damage Filter (damagefilter) <targetname>
Damage filter that also needs to be passed when player takes damage


Inputs

DamageFilter:

SetDamageFilter <stringRedirectInput/string>
Sets the entity to use as damage filter. Pass in an empty string (no parameter) to clear the damage filter.

Half-Life 2PortalBlack Mesa Half-Life 2, HL2 Episodes, Portal and Black Mesa

RequestPlayerHealth
Requests the current player's health from the proxy. This will fire the PlayerHealth output with the value.
SetFlashlightSlowDrain
Puts the player's flashlight in slow-power-drain mode (for Episodic darkness)
SetFlashlightNormalDrain
Puts the player's flashlight to default power drain
SetPlayerHealth <integerRedirectInput/integer>
Sets the player's health to this value.
RequestAmmoState
Request the ammo state of the player. It will fire PlayerHasAmmo or PlayerHasNoAmmo outputs.
EnableCappedPhysicsDamage
Cause player to take less damage from physics objects, and never more than 30 points from any individual strike.
DisableCappedPhysicsDamage
Undo effects of EnableCappedPhysicsDamage

Half-Life 2Portal Half-Life 2, HL2 Episodes and Portal

LowerWeapon
Lowers the players weapon.
SetLocatorTargetEntity <stringRedirectInput/string> (only in Half-Life 2: Episode Two)
Set the entity that the HUD locator should track. (Usually a vehicle)
Note.pngNote:Also works in Episode One since Source 2007, if the resources are ported.
SuppressCrosshair  (only in Portal) !FGD
Hides the crosshair.
Note.pngNote:Unlike the command crosshair 0, the crosshair is enabled again when a new game is started or a save made before firing the input is loaded.
Note.pngNote:Added in the March 3rd, 2010 update. Seems to be a backported Portal 2 input that was removed from Portal 2 before release.
OnPlayerStartedGame  (only in Portal: Still Alive) !FGD
Indicates that the player started the game from the beginning and leaderboard stats should be tracked.
OnPlayerBeatGame  (only in Portal: Still Alive) !FGD
Saves the current time, portal, and step scores to the leaderboard if OnPlayerStartedGame was fired previously.

Portal 2 Portal 2

AddPotatosToPortalgun
Change portalgun bodygroup to show PotatOS.
RemovePotatosFromPortalgun
Change portalgun bodygroup to not show PotatOS.
SetDropEnabled
Set whether the player is allowed to drop a carried object.
ForceVMGrabController
Force the player to use the view model grab controller for all objects that are picked up.
ForcePhysicsGrabController
Force the player to use the physics grab controller for all objects that are picked up.
ResetGrabControllerBehavior
Resets the grab controller used by the player to its default behavior.
SetMotionBlurAmount <floatRedirectInput/float>
Forces the motion blur effect on the player. Set to <= 0 to disable this override.
PaintPlayerWithPortalPaint  !FGD
Displays a Conversion Gel splashing effect on the player's screen.
Portal 2: Community Edition Portal 2: Community Edition only inputs
SetFallDamageEnabled <booleanRedirectInput/boolean>
Enables or disables fall damage on the player.
GiveBoots
Gives long fall boots to the player.
RemoveBoots
Removes long fall boots to the player.
GivePaintGunFull
Gives the player a full paint gun.
GivePaintGunBasic
Gives the player a basic paint gun.
RemovePaintGun
Removes the player's paint gun.
RemovePortalGun
Removes the player's portal gun.

Outputs

Half-Life 2PortalBlack Mesa Half-Life 2, HL2 Episodes, Portal and Black Mesa

PlayerDied
Fires when the player dies.
PlayerHealth <integerRedirectOutput/integer>
Outputs the player's current health value.
OnFlashlightOn <floatRedirectOutput/float>
Fired when the player turns on their flashlight. This output has the value of how much energy the player had when this happened [0..1].
OnFlashlightOff <floatRedirectOutput/float>
Fired when the player turns off their flashlight. This output has the value of how much energy the player had when this happened [0..1].
PlayerHasAmmo
Fired by request if the player has any ammo.
PlayerHasNoAmmo
Fired by request if the player doesn't have any ammo.
PlayerMissedAR2AltFire  (not in Half-Life 2)
Player fired an AR2 combine ball that didn't kill any enemies.

Portal 2Black MesaCounter-Strike: Global Offensive Portal 2, Counter-Strike Global Offensive and Black Mesa

OnDuck
Fired when a player starts to duck.
OnUnDuck
Fired when a player releases the duck button.
OnJump
Fired when a player jumps.
Icon-Bug.pngBug:These are technically in Counter-Strike: Global Offensive and Black Mesa, but don't work.

Portal 2 Portal 2

OnPrimaryPortalPlaced
Fired when a Portal player successfully places the primary portal.
OnSecondaryPortalPlaced
Fired when a Portal player successfully places the secondary portal.
OnCoopPing  !FGD
Fired in response to the unused +coop_ping command. Normal pings do not fire this output; use info_player_ping_detector instead.
OnStartSlowingTime  (only in Portal 2: Community Edition)
Fired when a Portal player initiates slow time.
OnStopSlowingTime  (only in Portal 2: Community Edition)
Fired when a Portal player stops slowing time.

External links

Map example .VMF (Checks player health) - By RabidMonkey

Map example .VMF and .BSP (Checks if player died and dissolves ragdoll) - By Jora

Map example .VMF and .BSP (Checks if player died and plays a random death sound) - By Jora and gtamike_TSGK