Disclaimer- The cut-and-paste code shown here may need to be adapted to your particular engine, which will already be heavily modded. This tutorial only applies to engines that already have the extensions system built-in, AND a network protocol that can write extended effects up to 32 bits.
Background- Pick-up item models are compiled with a flag set called EF_ROTATE to automatically make them spin around slowly. But vanilla Quake does not provide a way to bestow this rotation on any arbitrary entity from qc. An example would be a vwep model that doubles as a pick-up model. This was my original need, but the idea can be expanded to all model flags with DP_SV_MODELFLAGS_AS_EFFECTS.
Let's get messy- First back up your code!
Crack open the header file where entity effects are defined, typically server.h, and add:
Code: Select all
#define EF_NOMODELFLAGS 8388608 // indicates the model's .effects should be ignored (allows overriding them)
#define EF_ROCKET 16777216 // leave a trail
#define EF_GRENADE 33554432 // leave a trail
#define EF_GIB 67108864 // leave a trail
#define EF_ROTATE 134217728 // rotate (bonus items)
#define EF_TRACER 268435456 // green split trail
#define EF_ZOMGIB 536870912 // small blood trail
#define EF_TRACER2 1073741824 // orange split trail + rotate
#define EF_TRACER3 0x80000000 // purple trail
Code: Select all
#define MF_ROCKET 1 // leave a trail
#define MF_GRENADE 2 // leave a trail
#define MF_GIB 4 // leave a trail
#define MF_ROTATE 8 // rotate (bonus items)
#define MF_TRACER 16 // green split trail
#define MF_ZOMGIB 32 // small blood trail
#define MF_TRACER2 64 // orange split trail + rotate
#define MF_TRACER3 128 // purple trail
Code: Select all
int modelflags;
Code: Select all
mod->flags = LittleLong (pinmodel->flags);
Code: Select all
i = LittleLong (pinmodel->flags);
mod->flags = ((i & 255) << 24) | (i & 0x00FFFF00);
Code: Select all
if (!(ent->effects & 0xFF800000)) //qbism based on DP model flags
ent->effects |= ent->model->flags;
This conditional is using model flag overrides if they exist in ent->effects. Otherwise it uses the flags as read from the mdl.
Open sv_main.c and be careful where you stick the following, engines vary greatly here. Also maybe this could be written more concisely. Just prior to comparison of entity effects to baseline add
Code: Select all
if ((val = GetEdictFieldValue(ent, "modelflags")))
{
i= (unsigned int)ent->v.effects;
i |= ((unsigned int)val->_float & 0xff) << 24;
ent->v.effects = i;
}
Code: Select all
char *pr_extensions[] =
{
// add the extension names here, syntax: "extensionname",
"DP_SV_MODELFLAGS_AS_EFFECTS ",
qc source changes- In defs.qc in field definitions, add
Code: Select all
.float modelflags;
Code: Select all
float(string ext) dp_checkextension = #99;
Tack this to the effect definitions in defs.qc
Code: Select all
float EF_NOMODELFLAGS = 8388608; // ignore any effects in a model file and substitute your own
float MF_ROCKET = 1; // leave a trail
float MF_GRENADE = 2; // leave a trail
float MF_GIB = 4; // leave a trail
float MF_ROTATE = 8; // rotate (bonus items)
float MF_TRACER = 16; // green split trail
float MF_ZOMGIB = 32; // small blood trail
float MF_TRACER2 = 64; // orange split trail
float MF_TRACER3 = 128; // purple trail
Code: Select all
self.modelflags = MF_ROTATE;