Packetentities Galore! |
Quake2 Demo Editing Tutorial |
Written 12/99 by Overman |
In this tutorial, we will take an in-depth look at the .dm2 message type that is considered the "heart & soul" of a Quake2 demo file... the packetentities message. Every parameter that gets listed in Keygrip2 will be described, and then discussed in the context of it's possible uses.
Entity
This is the Entity number that the packetentities message refers to. Generally, Quake2 uses the first several numbers (1 through whatever) to number the players connected to the server. Other entity numbers are either hard-coded into the map (i.e. for stationary items) or generated on the fly (pieces of debris from an explosion, for example).
There should only be one packetentities message per Entity number per block, to avoid errors. Quake2 will never violate this rule on it's own, but careless editing can result in multiple packetentities messages for a single entity, which can cause your demo to crash.
If you are manually inserting new entities into your demo (not for the faint of heart), it is often helpful to copy an existing packetentities message and paste it again into the same block. In this case, it's imperative that you change the Entity number to something that is not being used by Quake2 in that demo. Of course, in order to keep the new entity from taking up the same space as the original one, you'll have to change the location info as well (see Origin below for details).
Modelindex
The Modelindex points to an index in the Model List in Keygrip2, plain and simple. If the entity is a player, this value will be 255, and the actual model and skin will be defined by the Skin Number parameter below. Clearing this value will make the entity invisible (no model). Some Effects and RenderFX (discussed below) will not display when Modelindex is set to 0.
Using this parameter, any item can be changed to look like any other item. Static items are simple... you can change a pack of bullets into a teleporter, for example, by simply changing this parameter accordingly. If you want to change between models that have frames of animation (i.e. from a player to a monster), you'll need to be mindful of the Frame parameter below: player models have one animation structure, while monsters each have their own scheme. If you are changing from an animated model to a non-animated model (ex. monster to a box of shells), you'll need to be sure and set the Frame to zero (0) to avoid errors.
Modelindex2
The Modelindex2 parameter is used primarily for Visual Weapons (VWep) display. For players, set this to 255 to enable Vwep, which will cause the skin and weapon choice to be defined in the Skin Number parameter. Setting this to 0 will remove all weapons from the player's hands. If the player appears to be holding a "diaper" for a weapon, this is the parameter that needs adjustment; it may be that the demo was somehow recorded without VWep enabled, or perhaps the particular player model being used does not have VWep support, in which case the Skin Number parameter needs to be adjusted to one where the standard weapon is being held (see Tutorial 9).
Modelindex2 can also be set to an index from the Model List, but generally this produces undesirable results; VWep models are designed according to a specific alignment relative to the player, and other models will generally clip the player's body or hang in midair. However, maybe this is what you want...
Modelindex3, Modelindex4
These work just like Modelindex2, and are intended for mod authors to use for custom items that the player might carry on his/her person. The most popular example is the flag model in Capture the Flag and similar mods. If the flag model is appearing as a "diaper", look at one of these parameters and make sure it is pointing to the flag's entry in the Model List.
In general, if these parameters are not supported by a mod, they will prove to be ineffective to edit.
Frame
The Frame parameter is used to control animation for models that support it. For non-animated models, this should remain at 0. Monster models are each on their own animation scheme. At this time, I know of no location on the web where monster animation frames are documented; the best approach to figure them out is to open up the appropriate monster model (.md2) file in the Quake Model Editor program and examine the way the frames are layed out. The same approach can be used to examine any player model, but these frames are well documented at the Quake 2 Player Model Pack website on this page.
Using the Frame parameter, you have complete control over which frame of animation is used in any given block. This is particularly useful in movie-making, when specific poses of a character are required. In fact, if you create a custom player model for use in a movie, you can many more than 198 frames of animation in a single .md2 file (I'm honestly not certain of the limit), and then trigger their usage by the Frame parameter in Keygrip2. Strange Company's film Nightfall is an excellent example of the use of many custom frames of animation.
Skin Number
The Skin Number parameter allows you to control the player model and skin of an entity. For a complete chart of allowed values, see this page in Tutorial 9. For this parameter to work correctly, Modelindex and Modelindex2 must be set to 255.
Monsters also have multiple skin types, to reflect various levels of damage they have taken. Occasionally, static models also have multiple skins; triggering these skins will require some experimentation on your part.
If you get an error message on playback that says something about "no such skin", chances are this is the parameter that needs adjustment. Usually, this occurs when a Skin Number other than 0 has been assigned to a static model (such as a gibbed head or a box of ammo).
Effects
The Effects parameter is a flag that will assign certain special effects to the entity in question. Effects are things handled on the client side (lights, particles, frame animations) that happen constantly on the given entity. An entity that has effects will be sent to the client even if it has a zero in Modelindex.
All values for Effects are documented in the Quake2 3.20 Source Code in qshared.h, but I've found the best method to be experimentation. The Value Calculator, added in the latest version of Keygrip2, makes determining these values a breeze, and if you have the 3d Preview set to the same block you are editing, the effects will be displayed in real time.
RenderFX
RenderFX works similarly to Effects, allowing still another set of special effects to be applied. RenderFX is also a flag, and it's values are documented in the Quake2 3.20 Source Code in qshared.h, but again the Value Calculator in Keygrip2 proves to be invaluable for setting these values. Experimentation is again the best learning tool here.
Origin - X, Y, and Z
The Origin coordinates represent the location in 3d space of the entity in question. The legal values of these coordinates are +/- 4048 (the limits of Quake2 space). However, you obviously want to keep an entity's position within the bounds of the map (for the most part).
One method of entity placement would be to make adjustments and watch the results in real time. This can be done by having the 3d Preview paused on the same block you are editing, with the camera focused on the entity you will be moving. In this way, you can get a feel for how the values affect the entity placement.
Another method would be to move the camera itself to the location you want the entity, and using the camera coordinates to determine the proper Origin value. On the Demo Server window, directly below the playback controls, the camera position coordinates are continually displayed (X, Y, and Z). However, these numbers require some translation before they can be set as Origin coordinates. To convert a camera position to an Origin, simply divide the camera coordinates by 8 (or multiply them by .125), and they will work properly.
Angles X, Y, and Z
The Angles parameters relate to the facing direction of an entity. Static (non-animated) entities usually have their angles set to 0. Other entities can "point" in a particular direction. Players obviously have a facing, as do other objects such as rockets. Facing can be adjusted by 360 degrees on all three axes. Using this parameter, you can have complete control of which direction any entity in your demo faces.
Old Origin X, Y, and Z
As you might remember, a Quake2 demo plays back at 10 blocks per second. However, when a computer is displaying the demo at greater than 10 frames per second, Quake2 "interpolates" entity movement between these blocks in order to keep movement looking smooth. At any given block, the Old Origin coordinates tell Quake2 where the entity was one block ago. Therefore under normal circumstances, the Old Origin will equal the Origin for that entity from the previous block. However, this does not have to be the case. Using different Old Origin coordinates, you can create some unconventional movement effects on machines with good framerates. This obviously has limited applications, but could prove to be useful in some circumstances.
The same rules apply to Old Origin as they do to Origin, if you are translating from camera coordinates. (see Origin above)
Sound
Any entity can have a looping sound emitted from it. Popular examples would be the railgun or BFG hum when a player is holding one of these weapons. In these cases, the Sound parameter uses an index from the Sound List in Keygrip2. This Sound can be manipulated to any other sound in the list as well, allowing for some interesting effects if applied tastefully. Obviously, not all sounds are made for smooth looping, but this parameter still has a variety of uses. Remember the final scene of Father Frags Best where Dad is emitting an insane gurgling? This was accomplished by changing the Sound parameter from the BFG hum to another sound. Setting Sound to 0 will make sure the looping sound for that entity is turned off.
Event
The Event parameter was discussed in Tutorial 11. It handles certain "special" events for an entity. Possible values are:
Event Value | Description |
0 | No event sound |
1 | Item Respawning sound |
2 | Player Footsteps sound |
3,4,5 | Player Falling sounds |
6,7 | Player (and other) Teleport sounds |
Tutorial 11 talked about removing these events, which may include both sound and visual occurrences. There's no reason why you couldn't add them in as well. In general, a number in the Event parameter usually occurs for one block, and is automatically turned off by Quake2 in the next block (unless, of course, you set Event to do otherwise).
Solid
Finally, there is the Solid parameter. This is used solely for client-side prediction of entity movement, as discussed with Old Origin above. In my experience, I have rarely seen this parameter's value at anything but 0 in a Quake2 demo, and it's uses are fairly limited. However, if you are a technically-minded individual, you may find the following information useful, from Uwe Girlich's Demospecs:
8*(bits 0-4) is x/y radius 8*(bits 5-9) is z down distance, 8(bits10-15) is z up
Summary
Editing packetentities messages can be a tedious process, even with the new Find/Replace features in Keygrip2. However, the results of careful editing can be powerful visuals and special effects which cannot be accomplished otherwise. In-depth knowledge of packetentities editing can make the difference between a normal demo/movie and one that is a mind-blower.