2. Entities¶
For a more in-depth descriptions of specific entities, refer to
2.1. Basic properties¶
2.2. Camera¶
Not all entities can see, but for those that do, the eyes are the windows to the soul. In the Half-Life universe, an entity is called the camera or the view. The camera is located at a fixed position relative to the entity’s origin, at least at server side. At client side, the player’s camera position is slightly complicated by view bobbing if enabled.
2.3. Movement¶
All entities in Half-Life has an associated movement type, or movetype. These are all the possible movetypes in Half-Life:
MOVETYPE_NONEThe entity never moves and not subjected to gravity. Examples of entities using this movetype are triggers, RPG laser spots,
env_explosion, etc. In the engine code,SV_Physics_Nonehandles the physics of this movetype. This function simply calls theThinkfunction associated with the entity and returns.MOVETYPE_WALKThis movetype is only used by the player and gives rise to the familiar air and ground movement physics of the player (see Player movement basics).
MOVETYPE_STEPThis is the primary movetype used by monsters, analogous to
MOVETYPE_WALKfor the player.SV_Physics_Stephandles this movetype, and it computes water buoyancy physics, gravity by Euler’s method (see Gravity), friction, position update, and also runs the entity’sThinkfunction.MOVETYPE_FLYThis movetype is used by entities that do not experience gravity, but has collision. For example, the Nihilanth (Nihilanth) uses this movetype, so does the tripmine (Tripmine), crossbow bolt, and many others. Notably, this movetype is also used by the player on a ladder (Ladders). The
SV_Physics_Tossis responsible of this movetype. It runs theThinkfunction, perform other checks, and compute position update and collisions.MOVETYPE_TOSSThis movetype is used by gibs, dead monsters, and certain pickup items such as the battery and suit. Similar to
MOVETYPE_FLY, theSV_Physics_Tossfunction handles this movetype, though with gravity.MOVETYPE_PUSHThis movetype is used by entities that can push and crush other entities, but does not clip to worldspawn. These are buttons, doors, func_breakable (func_breakable, but not func_pushable), func_rotating, func_wall, func_pendulum, etc.
SV_Physics_Pusherruns the physics for this movetype, which calls eitherSV_PushRotateorSV_PushMoveat some point, and calls theThinkfunction of the entity.MOVETYPE_NOCLIPEntities with this movetype does not experience gravity, and does not clip with any other entity.
SV_Physics_Noclipis responsible of the physics, which consists of running theThinkfunction, computing position and angle update, andSV_LinkEdict.MOVETYPE_FLYMISSILEThis movetype is not found to be used by any entity in vanilla Half-Life. The
SV_Physics_Tossfunction is responsible of its physics.MOVETYPE_BOUNCEThis movetype is used by entities that can bounce off other entities. A prominent example is the hand grenade (Hand grenade), but satchel charges (Satchel charge), MP5 grenades, and others use this movetype as well. Similar to
MOVETYPE_TOSS,SV_Physics_Tossis called for this movetype, but with the bounce coefficient (see Player collision) computed by .𝑏 = 2 − 𝑘 𝑒 MOVETYPE_BOUNCEMISSILEJust like
MOVETYPE_FLYMISSILE, this movetype does not seem to be used by any entity in the unmodded Half-Life.SV_Physics_Tossis also called for this movetype, and the bounce coefficient (see Player collision) is set to be , independent of entity gravity.𝑏 = 2 MOVETYPE_FOLLOWEntities of this movetype tracks the movement of the entity given by
pev->aiment. For example, theCBasePlayerItemclass, inherited by all player weapons, follows the player and is set to this movetype. Entities of this movetype does not experience gravity or collision.SV_Physics_Followruns its physics code, and consists of callingThinkand copying theaimentorigin and angles, along withSV_LinkEdict.MOVETYPE_PUSHSTEPThis entity seems to only be used by func_pushable. The physics of this movetype is very similar to that of
MOVETYPE_PUSH, except thatMOVETYPE_PUSHSTEPuses a slightly different way to collide with other entities.TODO
MOVETYPE_COMPOUNDThis movetype does not seem to be used.
2.4. Gravity¶
Some entities in Half-Life experience gravity. A func_pushable box, when pushed off an edge, falls to the ground. However, the game computes gravity for these entities in a way that differs from the gravity for the player (see Gravity). Entity gravity is integrated using the simplest form of the Euler’s method. Suppose an entity has vertical velocity
where
where the terms in the brackets match the prediction from Newtonian mechanics. Indeed, after
Let
2.5. Friction¶
Entities of movetype MOVETYPE_STEP experience ground friction in a similar way as the player. The friction is similar to what is given in Ground friction, except with edgefriction
2.6. Player collision¶
Many entities in Half-Life collide with one another. The velocity of the colliding entity usually changes as a result, while the position and velocity of the entity receiving the collision usually stay constant, unlike real world Newtonian physics. The process of changing the velocity is usually referred to as velocity clipping. Collision between the player entity and a non-player entity is one of the most common and consequential events in Half-Life, so it is worthwhile to study its physics.
Collisions occur in the position update step of an entity. The player entity’s position update is described in Position update. A collision is detected by performing a player trace and checking if the trace strikes a plane.
Definition 2.1 (Generation collision equation)
Let sv_bounce (denoted as
Before we proceed, we must point out that this equation may be applied multiple times per frame when computing the position update for an entity.
Fig. 2.1. Depiction of a general case of collision, where the player collides with plane
Collisions in the general case is depicted in Fig. 2.1.. The point at which collision occurs is
In most cases, players have func_friction that modifies it (see func_friction). The value of MOVETYPE_BOUNCE, then
Care must be taken when
we see that if FlyMove functions to set
Hence, assuming
where
Again, this result assumes
Observe that the resultant velocity is always parallel to the plane, as one can
verify that
2.6.1. Speed preserving circular walls¶
In Half-Life, we can sometimes find concave walls made out of multiple planes that approximate a circular arc. Examples can be found in some Office Complex maps such as the wall shown in Fig. 2.2.. Circular walls can be a blessing for speedrunners because they allow making sharp turns without losing too much speed. In fact, the higher the number of planes, the better preserved the player speed.
Fig. 2.2. An example of a “speed preserving” wall in the Office Complex map of
c1a2, which is made up of multiple planes to approximate an arc.¶
Let
The general equation at frame
Theorem 2.1
Assume that
This demonstrates the speed preserving property of circular walls. Observe also
that the final speed is completely independent of the radius of the arc.
Perfectly circular walls are impossible in Half-Life due to the inherent
limitations in the map format, so some amount of speed loss is unavoidable.
Nevertheless, even with
This is somewhat analogous to uniform circular motion in the real world. In the
real world, an object rotating around a point in a circular path experiences
centripetal acceleration