Hosting and domain costs until October 2024 have been generously sponsored by dumptruck_ds. Thank you!
Editing QuakeC Fields
From Quake Wiki
Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.
The edit can be undone.
Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 1: | Line 1: | ||
− | Quake's fields are broken down into two main types: system fields and entity fields. When a field is declared, every entity in the game has their own version of that field. Valid field data types include <code>string</code>, <code>vector</code>, <code>float</code>, and <code>entity</code>. | + | Quake's fields are broken down into two main types: system fields and entity fields. When a field is declared, every entity in the game has their own version of that field. Valid field data types include <code>string</code>, <code>vector</code>, <code>float</code>, and <code>entity</code>. They are declared via |
.datatype variableName; | .datatype variableName; | ||
− | + | Note the <code>.</code> as declaring a variable without this will make it global instead of entity-specific. | |
− | Note the <code>.</code> as declaring a variable without this will make it global instead of entity-specific | ||
System fields are fields defined within the engine itself and must be present for the game to work. These are always defined after the system global fields. The end of them is denoted by the <code>void end_sys_fields;</code> declaration. System fields must always be declared in the order defined within the vanilla QuakeC files as they are linked by memory offsets internally. Changing the order will break logic. | System fields are fields defined within the engine itself and must be present for the game to work. These are always defined after the system global fields. The end of them is denoted by the <code>void end_sys_fields;</code> declaration. System fields must always be declared in the order defined within the vanilla QuakeC files as they are linked by memory offsets internally. Changing the order will break logic. | ||
Line 11: | Line 10: | ||
The following fields should be defined in the exact order of this list, otherwise memory offset errors can occur. | The following fields should be defined in the exact order of this list, otherwise memory offset errors can occur. | ||
− | *''float'' '''modelindex''' | + | *''float'' '''modelindex''' - The index for the entity's current model within the cache. Setting this to 0 will remove the entity's model. Otherwise this is best set via <code>setmodel()</code>. |
− | + | *''vector'' '''absmin''' - The world coordinate of the bottom left corner of the entity's axis-aligned bounding box. Both <code>setorigin()</code> and <code>setsize()</code> will set this. For BSP entities, <code>setmodel()</code> will also set this. | |
− | *''vector'' '''absmin''' | + | *''vector'' '''absmax''' - The world coordinate of the top right corner of the entity's axis-aligned bounding box. Both <code>setorigin()</code> and <code>setsize()</code> will set this. For BSP entities, <code>setmodel()</code> will also set this. |
− | + | *''float'' '''ltime''' - The local time for the entity. This is used in place of the global '''time''' variable if the entity has the move type <code>MOVETYPE_PUSH</code> since BSP entities that get blocked will pause their timer. | |
− | *''vector'' '''absmax''' | + | *''float'' '''[[Fields:Movetype|movetype]]''' - The type of movement the entity has. There are special rules for what entities should have what move type. |
− | + | *''float'' '''[[Fields:Solid|solid]]''' - The type of collision the entity has. There are special rules for BSP entities regarding their '''movetype'''. | |
− | *''float'' '''ltime''' | + | *''vector'' '''origin''' - The current world coordinate of the entity. Should be set by <code>setorigin()</code> since it involves relinking the entity to the world. |
− | + | *''vector'' '''oldorigin''' - Only used with <code>MOVETYPE_WALK</code> to determine if the entity is stuck when moving. | |
− | *''float'' '''[[Fields:Movetype|movetype]]''' | + | *''vector'' '''velocity''' - The movement direction and speed of the entity measured in map units/second. |
− | + | *''vector'' '''angles''' - The current direction as (pitch, yaw, roll) the entity's model is facing. Players use '''v_angle''' for their camera direction. Note that positive pitch values point up and negative pitch values down within this field. If you wish to pass it directly to <code>makevectors()</code>, you should negate the pitch before doing so. BSP entities should not use this field as their bounding box will not be aligned to their orientation. | |
− | *''float'' '''[[Fields:Solid|solid]]''' | + | *''vector'' '''avelocity''' - The angular velocity as (pitch, yaw, roll) of the entity measured in degrees/second. BSP entities should not use this field as their bounding box will not be aligned to their orientation. |
− | + | *''vector'' '''punchangle''' - The view angle offset as (pitch, yaw, roll) to apply to the player's camera e.g. weapon recoil. | |
− | *''vector'' '''origin''' | + | *''string'' '''classname''' - The type the entity is. Quake uses this to determine what spawn function to call for a given entity when it's first created while loading (the class name will match its spawn function's name). |
− | + | *''string'' '''model''' - The name of the entity's current model. Setting this to empty will remove the entity's model. Otherwise this is best set via <code>setmodel()</code>. For BSP entities, this field is automatically populated with the name of their internal BSP model on spawn. | |
− | *''vector'' '''oldorigin''' | + | *''float'' '''frame''' - The current frame index for the entity's model. |
− | + | *''float'' '''skin''' - The current skin index for the entity's model. | |
− | + | *''float'' '''[[Fields:Effects|effects]]''' - Flags that store which effects to apply to an entity e.g. muzzle flash. | |
− | + | *''vector'' '''mins''' - The size of the entity pointing towards its bottom left. These should be negative values. Should be set by <code>setsize()</code> since it involves relinking the entity to the world. For BSP entities this is set by <code>setmodel()</code>. | |
− | *''vector'' '''angles''' | + | *''vector'' '''maxs''' - The size of the entity pointing towards its top right. These should be positive values. Should be set by <code>setsize()</code> since it involves relinking the entity to the world. For BSP entities this is set by <code>setmodel()</code>. |
− | + | *''vector'' '''size''' - The total size of the entity on all 3 axes. Should be set by <code>setsize()</code> since it involves relinking the entity to the world. For BSP entities this is set by <code>setmodel()</code>. | |
− | *''vector'' '''avelocity''' | + | *''void()'' '''touch''' - The function to run (if any) when a collision occurs with another entity, both on the collider and collidee respectively. Only runs if the entity is considered a form of solid. If an entity is a trigger only its <code>touch()</code> will be called. |
− | + | *''void()'' '''use''' - Unused. | |
− | *''vector'' '''punchangle''' | + | *''void()'' '''think''' - The next function to perform on the entity. Only gets called if '''nextthink''' is a positive value. |
− | + | *''void()'' '''blocked''' - Function called by BSP entities when they are unable to push an entity out of the way. | |
− | *''string'' '''classname''' | + | *''float'' '''nextthink''' - The time stamp for when to perform the next <code>think()</code> action. If a non-positive number, does nothing. After an entity thinks this is automatically set back to 0. For standard entities '''time''' should be used to set the time stamp while for BSP entities the '''ltime''' field should be used instead. |
− | + | *''entity'' '''groundentity''' - The entity currently being stood on top of, if any. Often used to denote standing on top of a BSP entity. | |
− | *''string'' '''model''' | + | *''float'' '''health''' - The current health of the entity. This should use rounded numbers as imprecisions can cause bugs at low health values. |
− | + | *''float'' '''frags''' - The number of kills the player currently has in PvP modes. | |
− | *''float'' '''frame''' | + | *''float'' '''weapon''' - The item bit for the player's currently selected weapon. |
− | + | *''string'' '''weaponmodel''' - The name of the model to use for the player's HUD weapon. | |
− | *''float'' '''skin''' | + | *''float'' '''weaponframe''' - The current frame index for the player's HUD weapon. |
− | + | *''float'' '''currentammo''' - The amount of ammo to display in the HUD for the player's currently selected weapon. | |
− | *''float'' '''[[Fields:Effects|effects]]''' | + | *''float'' '''ammo_shells''' - The amount of shells the entity currently has. |
− | + | *''float'' '''ammo_nails''' - The amount of nails the entity currently has. | |
− | *''vector'' '''mins''' | + | *''float'' '''ammo_rockets''' - The amount of rockets the entity currently has. |
− | + | *''float'' '''ammo_cells''' - The amount of cells the entity currently has. | |
− | *''vector'' '''maxs''' | + | *''float'' '''[[Fields:Items|items]]''' - Tracks the items an entity currently has. Usage can vary depending on type of entity, but common usage is for players, backpacks, and locked doors. Note: For players, this has special interactions with the HUD. |
− | + | *''float'' '''takedamage''' - The type of damage the entity is capable of taking. Can be the following: | |
− | *''vector'' '''size''' | + | *:<code>DAMAGE_NO</code> |
− | + | *:<code>DAMAGE_YES</code> | |
− | *''void()'' '''touch''' | + | *:<code>DAMAGE_AIM</code> (signifies that the entity can be autoaimed at) |
− | + | *''entity'' '''chain''' - Used with <code>findradius()</code> to create a linked list of entities that were found. This should not be used outside this purpose or modified manually. Nested <code>findradius()</code> calls can break this functionality without special precautions. | |
− | *''void()'' '''use''' | + | *''float'' '''deadflag''' - Used with players to denote their current respawn state. Can be the following: |
− | |||
− | *''void()'' '''think''' | ||
− | |||
− | *''void()'' '''blocked''' | ||
− | |||
− | *''float'' '''nextthink''' | ||
− | |||
− | *''entity'' '''groundentity''' | ||
− | |||
− | *''float'' '''health''' | ||
− | |||
− | *''float'' '''frags''' | ||
− | |||
− | *''float'' '''weapon''' | ||
− | |||
− | *''string'' '''weaponmodel''' | ||
− | |||
− | *''float'' '''weaponframe''' | ||
− | |||
− | *''float'' '''currentammo''' | ||
− | |||
− | *''float'' '''ammo_shells''' | ||
− | |||
− | *''float'' '''ammo_nails''' | ||
− | |||
− | *''float'' '''ammo_rockets''' | ||
− | |||
− | *''float'' '''ammo_cells''' | ||
− | |||
− | *''float'' '''[[Fields:Items|items]]''' | ||
− | |||
− | *''float'' '''takedamage''' | ||
− | |||
− | : | ||
− | : | ||
− | : | ||
− | *''entity'' '''chain''' | ||
− | |||
− | *''float'' '''deadflag''' | ||
− | |||
:*<code>DEAD_NO</code> | :*<code>DEAD_NO</code> | ||
:*<code>DEAD_DYING</code> | :*<code>DEAD_DYING</code> | ||
:*<code>DEAD_DEAD</code> | :*<code>DEAD_DEAD</code> | ||
:*<code>DEAD_RESPAWNABLE</code> | :*<code>DEAD_RESPAWNABLE</code> | ||
− | *''vector'' '''view_ofs''' | + | *''vector'' '''view_ofs''' - The amount to shift from the origin of the entity to get its eye point. |
− | + | *''float'' '''button0''' - Boolean that determines if the fire button is pressed. | |
− | *''float'' '''button0''' | + | *''float'' '''button1''' - Unused. |
− | + | *''float'' '''button2''' - Boolean that determines if the jump button is pressed. | |
− | *''float'' '''button1''' | + | *''float'' '''impulse''' - The command a client is sending to the server. This is used for changing weapons and certain cheats. Only one impulse can be sent at a time. |
− | + | *''float'' '''fixangle''' - If set to <code>TRUE</code>, the player's camera angle is updated instantly based off their '''angles''' field. This is automatically cleared. | |
− | *''float'' '''button2''' | + | *''vector'' '''v_angle''' - The direction the player's camera is facing as (pitch, yaw, roll). Negative pitch values point up while positive pitch values point down. |
− | + | *''float'' '''idealpitch''' - If walking on a slope, the calculated pitch to align the player's camera with it. This is disabled if mouse input is active. | |
− | *''float'' '''impulse''' | + | *''string'' '''netname''' - The name of the entity, be it the player's name or a printable name for messages. |
− | + | *''entity'' '''enemy''' - For monsters, the entity it's currently chasing after. This is also the entity floating and swimming monsters will always try to align their height to. | |
− | *''float'' '''fixangle''' | + | *''float'' '''[[Fields:Flags|flags]]''' - The flags for the entity. |
− | + | *''float'' '''colormap''' - The current color map index for the player's model. | |
− | *''vector'' '''v_angle''' | + | *''float'' '''team''' - What team the player is on in team-based PvP modes. |
− | + | *''float'' '''max_health''' - The maximum amount a player can heal from standard health pickups. | |
− | *''float'' '''idealpitch''' | + | *''float'' '''teleport_time''' - If greater than '''time''', ignore movement inputs from the player. This is set immediately after teleporting to make sure the player can't run off into the abyss. |
− | + | *''float'' '''armortype''' - The fraction of damage to absorb. This only stores up to two decimal places by default. | |
− | *''string'' '''netname''' | + | *''float'' '''armorvalue''' - How much armor the entity currently has. |
− | + | *''float'' '''waterlevel''' - The current liquid level of the entity. For players: | |
− | *''entity'' '''enemy''' | + | :0 - Out of liquid |
− | + | :1 - Below waist | |
− | *''float'' '''[[Fields:Flags|flags]]''' | + | :2 - Above waist |
− | + | :3 - Above camera view height | |
− | *''float'' '''colormap''' | + | :For other entities, this is only 0 (out of liquid) or 1 (in liquid). |
− | + | *''float'' '''watertype''' - The <code>CONTENT_*</code> type of the liquid the entity is standing in. | |
− | *''float'' '''team''' | + | *''float'' '''ideal_yaw''' - For monsters, this is the yaw they want to turn towards. |
− | + | *''float'' '''yaw_speed''' - How quickly the monster should turn towards '''ideal_yaw'''. Measured in degrees per 0.1 seconds by default. | |
− | *''float'' '''max_health''' | + | *''entity'' '''aiment''' - Unused. |
− | + | *''entity'' '''goalentity''' - The entity monsters are trying to move towards, usually while patrolling. For floating and swimming monsters, they won't try to put themselves at level with it. | |
− | *''float'' '''teleport_time''' | + | *''float'' '''spawnflags''' - The flags set for the entity within the map editor itself. What spawn flags are available differs from entity type to entity type. |
− | + | *''string'' '''target''' - The '''targetname''' id that an entity will try and activate when it gets used. Different entity types have different use conditions. | |
− | *''float'' '''armortype''' | + | *''string'' '''targetname''' - The id of the entity for use in being activated. |
− | + | *''float'' '''dmg_take''' - How much modified damage the player took on a given frame. | |
− | *''float'' '''armorvalue''' | + | *''float'' '''dmg_save''' - How much damage was mitigated by the player's armor on a given frame. |
− | + | *''entity'' '''dmg_inflictor''' - The last entity to deal damage to the player on a given frame. | |
− | *''float'' '''waterlevel''' | + | *''entity'' '''owner''' - Which entity is considered the owner of this entity. Entities will automatically pass through their '''owner''' instead of colliding with them. |
− | + | *''vector'' '''movedir''' - Used by various entity types to determine which way to move e.g. doors. | |
− | : | + | *''string'' '''message''' - What message to display when certain entity types are activated. |
− | : | + | *''float'' '''sounds''' - What type of sounds an entity uses. Often used for setting sound types on BSP entities from the map editor. |
− | : | ||
− | : | ||
− | :For other entities, this is only | ||
− | *''float'' '''watertype''' | ||
− | |||
− | *''float'' '''ideal_yaw''' | ||
− | |||
− | *''float'' '''yaw_speed''' | ||
− | |||
− | *''entity'' '''aiment''' | ||
− | |||
− | *''entity'' '''goalentity''' | ||
− | |||
− | *''float'' '''spawnflags''' | ||
− | |||
− | *''string'' '''target''' | ||
− | |||
− | *''string'' '''targetname''' | ||
− | |||
− | *''float'' '''dmg_take''' | ||
− | |||
− | *''float'' '''dmg_save''' | ||
− | |||
− | *''entity'' '''dmg_inflictor''' | ||
− | |||
− | *''entity'' '''owner''' | ||
− | |||
− | *''vector'' '''movedir''' | ||
− | |||
− | *''string'' '''message''' | ||
− | |||
− | *''float'' '''sounds''' | ||
− | |||
*''string'' '''noise''' | *''string'' '''noise''' | ||
*''string'' '''noise1''' | *''string'' '''noise1''' | ||
*''string'' '''noise2''' | *''string'' '''noise2''' | ||
*''string'' '''noise3''' | *''string'' '''noise3''' | ||
− | : | + | :- Sound names that various BSP entities use to play audio during certain interactions. |
== Entity Fields == | == Entity Fields == | ||
These can be defined anywhere in any order. Removing or changing them isn't advised since maps use field names to determine what values to set, and any field can be arbitrarily set from the map editor. Modifying these could cause vanilla maps to break due to incorrect initializing. | These can be defined anywhere in any order. Removing or changing them isn't advised since maps use field names to determine what values to set, and any field can be arbitrarily set from the map editor. Modifying these could cause vanilla maps to break due to incorrect initializing. | ||
− | + | *''string'' '''wad''' - | |
− | + | *''string'' '''map''' - The current name of the level. This is the actual file name and not the presentable one. | |
− | *'' | + | *''float'' '''worldtype''' - Used across various entity types to determine what type of level it is and what assets should be used e.g. keys. |
− | + | *''string'' '''killtarget''' - The '''targetname''' id of the entities to remove from the world when activated. Contrary to its name, this will delete them and not kill them. This takes precedence over '''target''' by default. | |
− | *'' | + | *''float'' '''light_lev''' - |
− | + | *''float'' '''style''' - | |
− | + | *''void()'' '''th_stand''' - | |
− | + | *''void()'' '''th_walk''' - | |
− | + | *''void()'' '''th_run''' - | |
− | + | *''void()'' '''th_missile''' - | |
− | *'' | + | *''void()'' '''th_melee''' - |
− | + | *''void(entity attacker, float damage)'' '''th_pain''' - | |
− | *''float'' '''light_lev''' | + | *''void()'' '''th_die''' - |
− | + | *''entity'' '''oldenemy''' - | |
− | + | *''float'' '''speed''' - | |
− | + | *''float'' '''lefty''' - | |
− | *'' | + | *''float'' '''search_time''' - |
− | + | *''float'' '''attack_state''' - | |
− | + | *''float'' '''walkframe''' - | |
− | + | *''float'' '''attack_finished''' - | |
− | *'' | + | *''float'' '''pain_finished''' - |
− | + | *''float'' '''invincible_finished''' - | |
− | *'' | + | *''float'' '''invisible_finished''' - |
− | + | *''float'' '''super_damage_finished''' - | |
− | + | *''float'' '''radsuit_finished''' - | |
− | + | *''float'' '''invincible_time''' - | |
− | + | *''float'' '''invincible_sound''' - | |
− | + | *''float'' '''invisible_time''' - | |
− | + | *''float'' '''invisible_sound''' - | |
− | + | *''float'' '''super_time''' - | |
− | + | *''float'' '''super_sound''' - | |
− | *'' | + | *''float'' '''rad_time''' - |
− | + | *''float'' '''fly_sound''' - | |
− | *'' | + | *''float'' '''axhitme''' - |
− | + | *''float'' '''show_hostile''' - | |
− | *'' | + | *''float'' '''jump_flag''' - |
− | + | *''float'' '''swim_flag''' - | |
− | *''float'' ''' | + | *''float'' '''air_finished''' - |
− | + | *''float'' '''bubble_count''' - | |
− | *'' | + | *''string'' '''deathtype''' - |
− | + | *''string'' '''mdl''' - | |
− | *'' | + | *''vector'' '''mangle''' - |
− | + | *''vector'' '''oldorigin''' - | |
− | *''float'' ''' | + | *''float'' '''t_length''' - |
− | + | *''float'' '''t_width''' - | |
− | + | *''vector'' '''dest''' - | |
− | + | *''vector'' '''dest1''' - | |
− | *'' | + | *''vector'' '''dest2''' - |
− | + | *''float'' '''wait''' - | |
− | *''float'' ''' | + | *''float'' '''delay''' - |
− | + | *''entity'' '''trigger_field''' - | |
− | *'' | + | *''string'' '''noise4''' - |
− | + | *''float'' '''pausetime''' - | |
− | + | *''entity'' '''movetarget''' - | |
− | + | *''float'' '''aflag''' - | |
− | *'' | + | *''float'' '''dmg''' - |
− | + | *''float'' '''cnt''' - | |
− | *''float'' ''' | + | *''void()'' '''think1''' - |
− | + | *''vector'' '''finaldest''' - | |
− | *''float'' ''' | + | *''vector'' '''finalangle''' - |
− | + | *''float'' '''count''' - | |
− | *''float'' ''' | + | *''float'' '''lip''' - |
− | + | *''float'' '''state''' - | |
− | + | *''vector'' '''pos1''' - | |
− | + | *''vector'' '''pos2''' - | |
− | + | *''float'' '''waitmin''' - | |
− | + | *''float'' '''waitmax''' - | |
− | + | *''float'' '''distance''' - | |
− | + | *''float'' '''volume''' - | |
− | *'' | + | *''float'' '''dmgtime''' - |
− | + | *''float'' '''healamount''' - | |
− | + | *''float'' '''healtype''' - | |
− | + | *''float'' '''hit_z''' - | |
− | + | *''float'' '''inpain''' - | |
− | |||
− | *''float'' ''' | ||
− | |||
− | |||
− | |||
− | *'' | ||
− | |||
− | |||
− | |||
− | *'' | ||
− | |||
− | *'' | ||
− | |||
− | *''float'' ''' | ||
− | |||
− | *''float'' ''' | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | *'' | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | *'' | ||
− | |||
− | |||
− | *'' | ||
− | |||
− | *''entity'' ''' | ||
− | |||
− | *''float'' ''' | ||
− | |||
− | *''float'' ''' | ||
− | |||
− | *''float'' ''' | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | *'' | ||
− | |||
− | *''float'' ''' | ||
− | |||
− | *''float'' ''' | ||
− | |||
− | |||
− | |||
− | |||
− | *'' | ||
− | |||
− | |||
− | |||
− | *''float'' ''' | ||
− | |||
− | *''float'' ''' | ||
− | |||
− | *''float'' ''' | ||
− | |||
− | |||
− | |||
− | *''float'' ''' | ||
− | |||
− | *''float'' ''' | ||
− | |||
− | *''float'' ''' | ||
− | |||
− | *''float'' ''' | ||
− | |||
− | *''float'' ''' | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− |