예제 #1
0
/*
===============
G_MeleeFireCheck
===============
*/
qboolean G_MeleeFireCheck( gentity_t *ent ) {
	trace_t		tr;
	vec3_t		end;
	gentity_t	*tent;
	gentity_t	*traceEnt;

	// only living beeings can attack
	if ( ent->client->ps.stats[STAT_HEALTH] <= 0 ) {
		return qfalse;
	}

	// set aiming directions
	AngleVectors ( ent->client->ps.viewangles, forward, right, up);

	CalcMuzzlePoint ( ent, forward, right, up, muzzle );

	VectorMA (muzzle, 32, forward, end);

	// compensate for lag
	G_CalcLagTimeAndShiftAllClients( ent );

	trap_Trace (&tr, muzzle, NULL, NULL, end, ent->s.number, MASK_SHOT);

    // move the clients back to their proper positions
	if ( level.delagWeapons && ent->client && !(ent->r.svFlags & SVF_BOT) ) {
		G_UnTimeShiftAllClients( ent );
	}

	if ( tr.surfaceFlags & SURF_NOIMPACT ) {
		return qfalse;
	}

	traceEnt = &g_entities[ tr.entityNum ];

	// send blood impact
	if ( traceEnt->takedamage && traceEnt->client ) {
		// compensate for lag effects
		if ( level.delagWeapons && ent->client && !(ent->r.svFlags & SVF_BOT) ) {
			VectorSubtract( traceEnt->client->saved.currentOrigin, traceEnt->r.currentOrigin, end );
			VectorAdd( tr.endpos, end, tr.endpos );
		}
		// snap the endpos to integers, but nudged towards the line
		SnapVectorTowards( tr.endpos, muzzle );

		// create impact entity
		tent = G_TempEntity( tr.endpos, EV_BULLET_HIT_FLESH );
		tent->s.eventParm = traceEnt->s.number;
	}

	if ( !traceEnt->takedamage) {
		return qfalse;
	}

	G_Damage( traceEnt, ent, ent, forward, tr.endpos,
		weLi[WP_SHOCKER].damage, 0, MOD_SHOCKER );

	return qtrue;
}
예제 #2
0
/*
==================
G_UndoTimeShiftFor

Put everyone except for this client back where they were
==================
*/
void G_UndoTimeShiftFor( gentity_t *ent ) {

	// don't un-time shift for mistakes or bots
	if ( !ent->inuse || !ent->client || (ent->r.svFlags & SVF_BOT) ) {
		return;
	}

	G_UnTimeShiftAllClients( ent );
}
예제 #3
0
/*
===============
FireWeapon
===============
*/
void FireWeapon( gentity_t *ent, int weaponTime ) {
	// track shots taken for accuracy tracking.
	if( qtrue ) {
		ent->client->accuracy_shots++;
	}

	// set aiming directions
	AngleVectors( ent->client->ps.viewangles, forward, right, up);

	CalcMuzzlePointOrigin( ent, ent->client->oldOrigin, forward, right, up, muzzle );

	// compensate for lag
	G_CalcLagTimeAndShiftAllClients( ent );

	// fire the specific weapon
	switch( weLi[ent->s.weapon].prediction ) {
	case PR_MELEE:
		// no weapon function needed here (look at g_active.c)
		break;
	case PR_BULLET:
		weapon_bullet_fire( ent );
		break;
	case PR_PELLETS:
		weapon_shotgun_fire( ent );
		break;
	case PR_MISSILE:
		weapon_missile_fire( ent, weaponTime );
		break;
	case PR_FLAME:
		weapon_flamethrower_fire( ent );
		break;
	case PR_OMEGA:
		weapon_omega_fire( ent, weaponTime );
		break;
	case PR_BEAM:
		weapon_beam_fire( ent );
		break;
	case PR_NONE:
		if ( ent->s.weapon == WP_BLAST ) weapon_blast_fire( ent );
		break;
	default:
		// shouldn't happen
		break;
	}

    // move the clients back to their proper positions
	if ( level.delagWeapons && ent->client && !(ent->r.svFlags & SVF_BOT) ) {
		G_UnTimeShiftAllClients( ent );
	}
}