示例#1
0
//------------------------------------------------------------------------------------------------------------
void auto_turret_die ( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int damage, int meansOfDeath )
//------------------------------------------------------------------------------------------------------------
{
	vec3_t	forward = { 0,0, 1 }, pos;

	// Turn off the thinking of the base & use it's targets
	g_entities[self->r.ownerNum].think = NULL;
	g_entities[self->r.ownerNum].use = NULL;

	// clear my data
	self->die = NULL;
	self->takedamage = qfalse;
	self->s.health = self->health = 0;
	self->s.maxhealth = self->maxHealth = 0;
	self->s.loopSound = 0;
	self->s.shouldtarget = qfalse;
	//self->s.owner = MAX_CLIENTS; //not owned by any client

	VectorCopy( self->r.currentOrigin, pos );
	pos[2] += self->r.maxs[2]*0.5f;
	G_PlayEffect( EFFECT_EXPLOSION_TURRET, pos, forward );
	G_PlayEffectID( G_EffectIndex( "turret/explode" ), pos, forward );
	
	if ( self->splashDamage > 0 && self->splashRadius > 0 )
	{
		G_RadiusDamage( self->r.currentOrigin, 
						attacker, 
						self->splashDamage, 
						self->splashRadius, 
						attacker,
						NULL,
						MOD_UNKNOWN );
	}

	self->s.weapon = 0; // crosshair code uses this to mark crosshair red


	if ( self->s.modelindex2 )
	{
		// switch to damage model if we should
		self->s.modelindex = self->s.modelindex2;

		if (self->target_ent && self->target_ent->s.modelindex2)
		{
			self->target_ent->s.modelindex = self->target_ent->s.modelindex2;
		}

		VectorCopy( self->r.currentAngles, self->s.apos.trBase );
		VectorClear( self->s.apos.trDelta );
		
		if ( self->target )
		{
			G_UseTargets( self, attacker );
		}
	}
	else
	{
		ObjectDie( self, inflictor, attacker, damage, meansOfDeath );
	}
}
//------------------------------------------------------------------------------------------------------------
void turretG2_die ( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int damage, int meansOfDeath )
//------------------------------------------------------------------------------------------------------------
{
    vec3_t	forward = { 0,0,-1 }, pos;

    // Turn off the thinking of the base & use it's targets
    //self->think = NULL;
    self->use = NULL;

    // clear my data
    self->die  = NULL;
    self->pain = NULL;
    self->takedamage = qfalse;
    self->s.health = self->health = 0;
    self->s.loopSound = 0;
    self->s.shouldtarget = qfalse;
    //self->s.owner = MAX_CLIENTS; //not owned by any client

    // hack the effect angle so that explode death can orient the effect properly
    if ( self->spawnflags & 2 )
    {
        VectorSet( forward, 0, 0, 1 );
    }

//	VectorCopy( self->r.currentOrigin, self->s.pos.trBase );

    VectorMA( self->r.currentOrigin, 12, forward, pos );
    G_PlayEffect( EFFECT_EXPLOSION_TURRET, pos, forward );

    if ( self->splashDamage > 0 && self->splashRadius > 0 )
    {
        G_RadiusDamage( self->r.currentOrigin,
                        attacker,
                        self->splashDamage,
                        self->splashRadius,
                        attacker,
                        NULL,
                        MOD_UNKNOWN );
    }

    if ( self->s.eFlags & EF_SHADER_ANIM )
    {
        self->s.frame = 1; // black
    }

    self->s.weapon = 0; // crosshair code uses this to mark crosshair red

    if ( self->s.modelindex2 )
    {
        // switch to damage model if we should
        turretG2_set_models( self, qtrue );

        VectorCopy( self->r.currentAngles, self->s.apos.trBase );
        VectorClear( self->s.apos.trDelta );

        if ( self->target )
        {
            G_UseTargets( self, attacker );
        }

        if (self->spawnflags & SPF_TURRETG2_CANRESPAWN)
        {   //respawn
            if (self->health < 1 && !self->genericValue5)
            {   //we are dead, set our respawn delay if we have one
                self->genericValue5 = level.time + self->count;
            }
        }
    }
    else
    {
        ObjectDie( self, inflictor, attacker, damage, meansOfDeath );
    }
}