User:Pinsplash/BaseEntity: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
(Created page with "Basic functions for all entities: {{ExpandBox| <code> @BaseClass {{=}} CBaseEntity [ {{User:Pinsplash/FGDline|smart=Name|targetname|param=target_source|The name that other e...")
 
mNo edit summary
 
(7 intermediate revisions by 2 users not shown)
Line 1: Line 1:
Basic functions for all entities:
Basic functions for all entities. Recommended to paste at the top of base.fgd.
{{ExpandBox|
{{ExpandBox|1=
<code>
@BaseClass base(Targetname, Parentname, Angles, Origin, Global) {{=}} CBaseEntity
@BaseClass {{=}} CBaseEntity
[
 
        {{User:Pinsplash/FGDline|smart=Response Contexts|ResponseContext|param=string|Pre-defined response system contexts for this entity. Format is key:value,key:value,...}}        
[
        effects(choices) : "Effect Flags" : 0 : "For configuring visual effects. If you want to combine effects, simply type in the sum of the effect numbers, e.g., '72' for 64+8." =
 
        [
{{User:Pinsplash/FGDline|smart=Name|targetname|param=target_source|The name that other entities refer to this entity by.}}
        0: "0 - None"
 
        1: "1 - EF_BONEMERGE: Bonemerge always (very expensive!)"
{{User:Pinsplash/FGDline|smart=Global Entity Name|globalname|param=string|def=""|Name by which this entity is linked to another entity in a different map. When the player transitions to a new map, entities in the new map with globalnames matching entities in the previous map will have the previous map's state copied over their state.}}
        2: "2 - EF_BRIGHTLIGHT: Bright, dynamic light at entity origin"
 
        4: "4 - EF_DIMLIGHT: Dim, dynamic light at entity origin"
{{User:Pinsplash/FGDline|smart=Parent|parentname|param=target_destination|Specifies a movement parent. An entity will maintain its initial offset from its parent. An attachment point can be added to the end of the name, separated by a comma. Every entity can be parented, even point entities. Entities which are parented will be forced to transition to the next map, such as from a trigger_transition. Some entities which aren't intended to be parented may not function correctly. phys_constraint can be used as a workaround to parenting.}}
        8: "8 - EF_NOINTERP: No movement interpolation"
 
        16: "16 - EF_NOSHADOW: Don't cast shadows"
{{User:Pinsplash/FGDline|smart=Origin (X Y Z)|param=origin|coordinates|The position of this entity's center in the world. Rotating entities typically rotate around their origin.}}
        32: "32 - EF_NODRAW: Don't draw entity (entity is fully ignored by clients, NOT server; can cause collision problems)"
 
        64: "64 - EF_NORECEIVESHADOW: Don't receive dynamic shadows"
{{User:Pinsplash/FGDline|smart=Pitch Yaw Roll (X Y Z)|param=angles|angle|def="0 0 0"|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. This works on brush entities, although Hammer doesn't show the new angles.}}
        128: "128 - EF_BONEMERGE_FASTCULL: Bonemerge only in PVS, better performance but prone to disappearing. Use with Bonemerge."
 
        256: "256 - EF_ITEM_BLINK: Unsubtle blink"
{{User:Pinsplash/FGDline|smart=Flags|spawnflags|param=integer|The Flags tab as the true number it is. 99% of the time you don't need to touch it here.}}
        512: "512 - EF_PARENT_ANIMATES: Flag parent as always animating and realign each frame"
 
        ]
{{User:Pinsplash/FGDline|smart=Response Contexts|ResponseContext|param=string|Pre-defined response system contexts for this entity. Format is key:value,key:value,...}}
        {{User:Pinsplash/FGDline|smart=Local Time|ltime|param=float|The local time of the entity, independent of the global clock. Used mainly for physics calculations.}}
 
        {{User:Pinsplash/FGDline|smart=Next Think|nextthink|param=float|Amount of time before the entity thinks again.}}
{{User:Pinsplash/FGDline|smart=Effects|effects|param=integer|Combination of effect flags to use.}}
        {{User:Pinsplash/FGDline|smart=Hammer ID|hammerid|param=integer|The entity's Hammer ID. Mainly used by plugins and debugging commands, such as ent_keyvalue. Can be manually assigned. Entities spawned at run-time are not assigned any Hammer ID.}}
 
        {{User:Pinsplash/FGDline|smart=Minimum CPU Level|mincpulevel|param=integer|Minimum CPU Level allowed for this entity. 0 means all levels allowed.|since=L4D}}
{{User:Pinsplash/FGDline|smart=Local Time|ltime|param=float|The local time of the entity, independent of the global clock. Used mainly for physics calculations.}}
        {{User:Pinsplash/FGDline|smart=Maximum CPU Level|maxcpulevel|param=integer|Maximum CPU Level allowed for this entity. 0 means all levels allowed.|since=L4D}}
 
        {{User:Pinsplash/FGDline|smart=Minimum GPU Level|mingpulevel|param=integer|Minimum GPU Level allowed for this entity. 0 means all levels allowed.|since=L4D}}
{{User:Pinsplash/FGDline|smart=Next Think|nextthink|param=float|Amount of time before the entity thinks again.}}
        {{User:Pinsplash/FGDline|smart=Maximum GPU Level|maxgpulevel|param=integer|Maximum GPU Level allowed for this entity. 0 means all levels allowed.|since=L4D}}
 
        {{User:Pinsplash/FGDline|smart=Lag Compensation|LagCompensate|param=choices|def=0|Set to Yes to lag compensate this entity. Should be used very sparingly!|since=L4D2}} {{=}}  
{{User:Pinsplash/FGDline|smart=Hammer ID|hammerid|param=integer|The entity's Hammer ID. Mainly used by plugins and debugging commands, such as ent_keyvalue. Can be manually assigned. Entities spawned at run-time are not assigned any Hammer ID.}}
        [
 
                0: "No"
{{User:Pinsplash/FGDline|smart=Minimum CPU Level|mincpulevel|param=integer|Minimum CPU Level allowed for this entity. 0 means all levels allowed.|since=L4D}}
                1: "Yes"
 
        ]
{{User:Pinsplash/FGDline|smart=Maximum CPU Level|maxcpulevel|param=integer|Maximum CPU Level allowed for this entity. 0 means all levels allowed.|since=L4D}}
        {{User:Pinsplash/FGDline|smart=Is Automatic-Aim Target|is_autoaim_target|param=choices|def=0|If yes, automatic-aim assistance will target this entity.|since=CSGO}} {{=}}  
 
        [
{{User:Pinsplash/FGDline|smart=Minimum GPU Level|mingpulevel|param=integer|Minimum GPU Level allowed for this entity. 0 means all levels allowed.|since=L4D}}
                0: "No"
 
                1: "Yes"
{{User:Pinsplash/FGDline|smart=Maximum GPU Level|maxgpulevel|param=integer|Maximum GPU Level allowed for this entity. 0 means all levels allowed.|since=L4D}}
        ]
 
        ///////////////////////inputs
{{User:Pinsplash/FGDline|smart=Entity Scripts|vscripts|param=scriptlist|Space delimited list of VScript files (without file extension) that are executed after all entities have spawned. The scripts are all executed in the same script scope, later ones overwriting any identical variables and functions.|since=L4D2}}
        {{User:Pinsplash/FGDline|input=1|Use|Same as a player invoking +use; may not do anything. Can also be invoked by creating an output that does not specify an input.}}
 
        {{User:Pinsplash/FGDline|input=1|DispatchEffect|Dispatches a special effect from the entity's origin. Replaced by particles since Left 4 Dead.|param=string}}
{{User:Pinsplash/FGDline|smart=Script think function|thinkfunction|param=string|Name of a function in this entity's script which will be called automatically every 100 milliseconds (ten times a second) for the duration of the script. It can be used to create timers or to simulate autonomous behavior. The return value (if present) will set the time until the next call. Try to avoid expensive operations in this function, as it may cause performance problems.|since=L4D2}}
        {{User:Pinsplash/FGDline|input=1|DispatchResponse|Dispatches a response to the entity.|param=string}}
 
        {{User:Pinsplash/FGDline|input=1|AddContext|Adds to the entity's list of response contexts. Format is <key>:<value>.|param=string}}
{{User:Pinsplash/FGDline|smart=Lag Compensation|LagCompensate|param=choices|def=0|Set to Yes to lag compensate this entity. Should be used very sparingly!|since=L4D2}} {{=}}  
        {{User:Pinsplash/FGDline|input=1|RemoveContext|Remove a context from this entity's list. The name should match the key of an existing context.|param=string}}
 
        {{User:Pinsplash/FGDline|input=1|ClearContext|Removes all contexts from this entity's list.|param=string}}
[
        {{User:Pinsplash/FGDline|input=1|CallScriptFunction|Execute a VScript function in the scope of the receiving entity.|param=string|since=L4D2}}
 
        {{User:Pinsplash/FGDline|input=1|SetLocalOrigin|Set this entity's origin in the map. (dubious)|param=string|since=p2}}
0: "No"
        {{User:Pinsplash/FGDline|input=1|SetLocalAngles|Set this entity's angles in the map. (dubious)|param=string|since=p2}}
 
]
1: "Yes"
}}
 
]
 
{{User:Pinsplash/FGDline|smart=Is Automatic-Aim Target|is_autoaim_target|param=choices|If yes, automatic-aim assistance will target this entity.|since=CSGO}} {{=}}  
 
[
 
0: "No"
 
1: "Yes"
 
]
 
///////////////////////inputs
 
{{User:Pinsplash/FGDline|input=1|Kill|Removes this entity and any entities parented to it from the world.}}
 
{{User:Pinsplash/FGDline|input=1|KillHierarchy|Functions the same as Kill, although this entity and any entities parented to it are killed on the same frame.}}
 
{{User:Pinsplash/FGDline|input=1|SetParent|Move with this entity.|param=string}}
 
{{User:Pinsplash/FGDline|input=1|SetParentAttachment|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.|param=string}}
 
{{User:Pinsplash/FGDline|input=1|SetParentAttachmentMaintainOffset|Same as SetParentAttachment, but without teleporting. The entity retains its position relative to the attachment at the time of the input being received.|param=string}}
 
{{User:Pinsplash/FGDline|input=1|ClearParent|Removes this entity from the the movement hierarchy, leaving it free to move independently.}}
 
{{User:Pinsplash/FGDline|input=1|AddOutput|Evaluates a keyvalue or output on this entity. KEYVALUES: <key> <value> OUTPUTS: <code><output name> <targetname>:<inputname>:<parameter>:<delay>:<max times to fire, -1 means infinite>|param=string}}
 
{{User:Pinsplash/FGDline|input=1|FireUser1|Fire OnUser1.}}
 
{{User:Pinsplash/FGDline|input=1|FireUser2|Fire OnUser2.}}
 
{{User:Pinsplash/FGDline|input=1|FireUser3|Fire OnUser3.}}
 
{{User:Pinsplash/FGDline|input=1|FireUser4|Fire OnUser4.}}
 
{{User:Pinsplash/FGDline|input=1|Use|Same as a player invoking +use; may not do anything. Can also be invoked by creating an output that does not specify an input.}}
 
{{User:Pinsplash/FGDline|input=1|DispatchEffect|Dispatches a special effect from the entity's origin. Replaced by particles since Left 4 Dead.|param=string}}
 
{{User:Pinsplash/FGDline|input=1|DispatchResponse|Dispatches a response to the entity.|param=string}}
 
{{User:Pinsplash/FGDline|input=1|AddContext|Adds to the entity's list of response contexts. Format is <key>:<value>.|param=string}}
 
{{User:Pinsplash/FGDline|input=1|RemoveContext|Remove a context from this entity's list. The name should match the key of an existing context.|param=string}}
 
{{User:Pinsplash/FGDline|input=1|ClearContext|Removes all contexts from this entity's list.|param=string}}
 
{{User:Pinsplash/FGDline|input=1|RunScriptFile|Execute a VScript file from disk, without file extension. The script contents are merged with the script scope of the receiving entity.|param=script|since=L4D2}}
 
{{User:Pinsplash/FGDline|input=1|RunScriptCode|Execute a string of VScript source code in the scope of the entity receiving the input. String quotation may be needed when fired via console. In l4d2, the code is executed in the script scope of the entity that fires the output, not the one receiving the input. Never try to pass string parameters to a script function with this input. It will corrupt the VMF structure because of the nested quotation marks, which then must be removed manually with a text editor.|param=string|since=L4D2}}
 
{{User:Pinsplash/FGDline|input=1|CallScriptFunction|Execute a VScript function in the scope of the receiving entity.|param=string|since=L4D2}}
 
{{User:Pinsplash/FGDline|input=1|SetLocalOrigin|Set this entity's origin in the map. (dubious)|param=origin|since=p2}}
 
{{User:Pinsplash/FGDline|input=1|SetLocalAngles|Set this entity's angles in the map. (dubious)|param=angles|since=p2}}
 
////////////////////////outputs
 
{{User:Pinsplash/FGDline|output=1|OnUser1|Fires in response to the firing of FireUser1.}}
 
{{User:Pinsplash/FGDline|output=1|OnUser2|Fires in response to the firing of FireUser2.}}
 
{{User:Pinsplash/FGDline|output=1|OnUser3|Fires in response to the firing of FireUser3.}}
 
{{User:Pinsplash/FGDline|output=1|OnUser4|Fires in response to the firing of FireUser4.}}
 
{{User:Pinsplash/FGDline|output=1|OnKilled|Left 4 Dead only. This output fires when the entity is killed and removed from the game.}}
 
]
</code>}}

Latest revision as of 07:16, 17 September 2024

Basic functions for all entities. Recommended to paste at the top of base.fgd.


@BaseClass base(Targetname, Parentname, Angles, Origin, Global) = CBaseEntity
[
        ResponseContext(string) : "Response Contexts" :  : "Pre-defined response system contexts for this entity. Format is key:value,key:value,..."         
        effects(choices) : "Effect Flags" : 0 : "For configuring visual effects. If you want to combine effects, simply type in the sum of the effect numbers, e.g., '72' for 64+8." =
        [
	        0: "0 - None"
	        1: "1 - EF_BONEMERGE: Bonemerge always (very expensive!)"
	        2: "2 - EF_BRIGHTLIGHT: Bright, dynamic light at entity origin"
	        4: "4 - EF_DIMLIGHT: Dim, dynamic light at entity origin"
	        8: "8 - EF_NOINTERP: No movement interpolation"
	        16: "16 - EF_NOSHADOW: Don't cast shadows"
	        32: "32 - EF_NODRAW: Don't draw entity (entity is fully ignored by clients, NOT server; can cause collision problems)"
	        64: "64 - EF_NORECEIVESHADOW: Don't receive dynamic shadows"
	        128: "128 - EF_BONEMERGE_FASTCULL: Bonemerge only in PVS, better performance but prone to disappearing. Use with Bonemerge."
	        256: "256 - EF_ITEM_BLINK: Unsubtle blink"
	        512: "512 - EF_PARENT_ANIMATES: Flag parent as always animating and realign each frame"
        ]
        ltime(float) : "Local Time" :  : "The local time of the entity, independent of the global clock. Used mainly for physics calculations."
        nextthink(float) : "Next Think" :  : "Amount of time before the entity thinks again."
        hammerid(integer) : "Hammer ID" :  : "The entity's Hammer ID. Mainly used by plugins and debugging commands, such as ent_keyvalue. Can be manually assigned. Entities spawned at run-time are not assigned any Hammer ID."
        mincpulevel(integer) : "Minimum CPU Level (Since L4D)" :  : "Minimum CPU Level allowed for this entity. 0 means all levels allowed."
        maxcpulevel(integer) : "Maximum CPU Level (Since L4D)" :  : "Maximum CPU Level allowed for this entity. 0 means all levels allowed."
        mingpulevel(integer) : "Minimum GPU Level (Since L4D)" :  : "Minimum GPU Level allowed for this entity. 0 means all levels allowed."
        maxgpulevel(integer) : "Maximum GPU Level (Since L4D)" :  : "Maximum GPU Level allowed for this entity. 0 means all levels allowed."
        LagCompensate(choices) : "Lag Compensation (Since L4D2)" : 0 : "Set to Yes to lag compensate this entity. Should be used very sparingly!" = 
        [
                0: "No"
                1: "Yes"
        ]
        is_autoaim_target(choices) : "Is Automatic-Aim Target (Since CSGO)" : 0 : "If yes, automatic-aim assistance will target this entity." = 
        [
                0: "No"
                1: "Yes"
        ]
        ///////////////////////inputs
        input Use(void) : "Same as a player invoking +use; may not do anything. Can also be invoked by creating an output that does not specify an input."
        input DispatchEffect(string) : "Dispatches a special effect from the entity's origin. Replaced by particles since Left 4 Dead."
        input DispatchResponse(string) : "Dispatches a response to the entity."
        input AddContext(string) : "Adds to the entity's list of response contexts. Format is <key>:<value>."
        input RemoveContext(string) : "Remove a context from this entity's list. The name should match the key of an existing context."
        input ClearContext(string) : "Removes all contexts from this entity's list."
        input CallScriptFunction(string) : "Since L4D2. Execute a VScript function in the scope of the receiving entity."
        input SetLocalOrigin(string) : "Since p2. Set this entity's origin in the map. (dubious)"
        input SetLocalAngles(string) : "Since p2. Set this entity's angles in the map. (dubious)"
]