[RTCW]Decoy Entity not solid, plus it doesn't take damage

Discussions about ET modding (sdk code, player/weapon modeling)

Moderators: Forum moderators, developers

Post Reply
User avatar
dutchmeat
Posts: 62
Joined: Tue Jan 28, 2003 8:08 am
Location: Netherlands
Contact:

[RTCW]Decoy Entity not solid, plus it doesn't take damage

Post by dutchmeat »

Hi,
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;
}

Thanks in advance,

Dutchmeat
User avatar
dutchmeat
Posts: 62
Joined: Tue Jan 28, 2003 8:08 am
Location: Netherlands
Contact:

Post by dutchmeat »

bump ? or is this a dead forum ?
The Necromancer
Posts: 126
Joined: Sat Sep 25, 2004 7:12 am
Contact:

Post by The Necromancer »

this is quite funny thing :roll: , but you will probably have problems with this

Code: Select all

decoy->r.ownerNum = ent->s.number; 
Hi! I'm a .signature *virus*! Copy me into your ~/.signature to help me spread!
User avatar
dutchmeat
Posts: 62
Joined: Tue Jan 28, 2003 8:08 am
Location: Netherlands
Contact:

Post by dutchmeat »

So how did banimod did it? I recall they could let the owner shoot it's own decoy, and I think you could actually hear a 'break' sound when damaging(when it's not dead yet).
Post Reply