I have used Icculuses Decoy spawning system, but the decoy are not solid, and they don't take damage from playerclips/knives, atleast not from their owners.
They do die/hurt from explosions, so i don't know why the bullets go right throught them.
This is the decoy spawn example from http://cvs.icculus.org/cvs/fi/game/g_fi.c?rev=1.9
Code: Select all
gentity_t *
fi_decoy_spawn (gentity_t *ent)
{
int contents;
gentity_t *decoy, *tent;
vec3_t forward;
float veclen;
// if client is in a nodrop area, don't leave the body
contents = trap_PointContents( ent->s.origin, -1 );
if ( contents & CONTENTS_NODROP ) {
return NULL;
}
//Create new object.
decoy = G_Spawn();
//Prevent game interaction for now.
trap_UnlinkEntity(decoy);
decoy->classname = classname_decoy; /* Constant string address, to avoid expensive string compare. */
decoy->s = ent->s; //Entity shared object. Copying.
decoy->s.number = decoy - g_entities;
decoy->s.eFlags |= EF_TALK;
/* Clear various attributes. */
decoy->s.powerups = 0;
decoy->s.loopSound = 0;
decoy->timestamp = level.time;
decoy->physicsObject = qtrue; /* Push around! Push around! */
decoy->physicsBounce = 0; /* XXX: hrm. No bouncy? */
/* For collision detection. */
VectorCopy(ent->r.mins, decoy->r.mins);
VectorCopy(ent->r.maxs, decoy->r.maxs);
VectorCopy(ent->r.absmin, decoy->r.absmin);
VectorCopy(ent->r.absmax, decoy->r.absmax);
decoy->clipmask = MASK_SHOT;
decoy->r.contents = CONTENTS_BODY; /* XXX: or something else? */
/* Initial trajectory. */
/* Decide where to materialize. Decoy shouldn't "wedge" inside parent. */
/* Maximum length that the object can possibly take up. */
VectorSubtract(decoy->r.maxs, decoy->r.mins, forward);
veclen = VectorLength(forward);
G_Printf("decoy_spawn: calculated position offset = %f\n", veclen);
if (ent->client)
{
AngleVectors(ent->client->ps.viewangles, forward, NULL, NULL);
VectorCopy(forward, decoy->r.currentAngles);
}
else
{
AngleVectors(ent->r.currentAngles, forward, NULL, NULL);
VectorCopy(ent->r.currentAngles, decoy->r.currentAngles);
}
forward[2] = 0.1;
VectorNormalizeFast(forward);
VectorMA(decoy->s.pos.trBase, veclen, forward, decoy->s.pos.trBase);
decoy->s.pos.trType = TR_GRAVITY;
decoy->s.pos.trTime = level.time;
VectorCopy(ent->client->ps.velocity, decoy->s.pos.trDelta); /* parent velocity. */
decoy->s.event = 0; /* XXX: I don't get this... */
#if 0
/* XXX: Force animation frame, or inherit from parent? */
decoy->s.legsAnim = LEGS_IDLE;
decoy->s.torsoAnim = TORSO_STAND;
#endif /* 0 */
decoy->r.svFlags = ent->r.svFlags;
decoy->r.ownerNum = ent->s.number;
decoy->takedamage = qtrue;
decoy->health = 10; /* XXX: make configurable. */
decoy->parent = ent;
/* Callbacks. */
decoy->nextthink = level.time + 1000;
decoy->think = fi_decoy_think;
decoy->die = fi_decoy_die;
VectorCopy(decoy->s.pos.trBase, decoy->r.currentOrigin);
decoy->r.s = decoy->s; /* Shallow copy. */
G_Printf("decoy_spawn: numbers: #%d, r->s.num=%d, clientNum=%d, ownernum=%d\n", decoy->s.number, decoy->r.s.number, decoy->s.clientNum, decoy->r.ownerNum);
#if 1
/* Create teleporter effect. */
tent = G_TempEntity(decoy->r.currentOrigin, EV_PLAYER_TELEPORT_IN);
tent->s.clientNum = decoy->s.clientNum;
#endif /* 0|1 */
/* Now make interactive with world. */
trap_LinkEntity(decoy);
return decoy;
}
Dutchmeat