// this should match CG_ShotgunPattern void ShotgunPattern( vec3_t origin, vec3_t origin2, int seed, gentity_t *ent ) { int i; float r, u; vec3_t end; vec3_t forward, right, up; int oldScore; qboolean hitClient = qfalse; // derive the right and up vectors from the forward vector, because // the client won't have any other information VectorNormalize2( origin2, forward ); PerpendicularVector( right, forward ); CrossProduct( forward, right, up ); oldScore = ent->client->ps.persistant[PERS_SCORE]; // generate the "random" spread pattern for ( i = 0 ; i < DEFAULT_SHOTGUN_COUNT ; i++ ) { r = Q_crandom( &seed ) * DEFAULT_SHOTGUN_SPREAD * 16; u = Q_crandom( &seed ) * DEFAULT_SHOTGUN_SPREAD * 16; VectorMA( origin, 8192 * 16, forward, end); VectorMA (end, r, right, end); VectorMA (end, u, up, end); if( ShotgunPellet( origin, end, ent ) && !hitClient ) { hitClient = qtrue; ent->client->accuracy_hits++; } } }
/* this should match CG_ShotgunPattern */ void ShotgunPattern(Vec3 origin, Vec3 origin2, int seed, Gentity *ent) { int i; float r, u; Vec3 end; Vec3 forward, right, up; qbool hitClient = qfalse; /* derive the right and up vectors from the forward vector, because * the client won't have any other information */ norm2v3(origin2, forward); perpv3(right, forward); crossv3(forward, right, up); /* generate the "random" spread pattern */ for(i = 0; i < DEFAULT_SHOTGUN_COUNT; i++){ r = Q_crandom(&seed) * DEFAULT_SHOTGUN_SPREAD * 16; u = Q_crandom(&seed) * DEFAULT_SHOTGUN_SPREAD * 16; saddv3(origin, 8192 * 16, forward, end); saddv3 (end, r, right, end); saddv3 (end, u, up, end); if(ShotgunPellet(origin, end, ent) && !hitClient){ hitClient = qtrue; ent->client->accuracy_hits++; } } }
/* ================ Shotgun_Pattern ================ */ void ShotgunPattern( vec3_t origin, vec3_t origin2, gentity_t *ent ) { int i; float r, u; vec3_t end; vec3_t forward, right, up; int randomSeed; // derive the right and up vectors from the forward vector, because // the client won't have any other information VectorNormalize2( origin2, forward ); PerpendicularVector( right, forward ); CrossProduct( forward, right, up ); randomSeed = ent->client->ps.randomSeed; // generate the "random" spread pattern for ( i = 0 ; i < weLi[ent->s.weapon].recoil_shot ; i++ ) { r = Q_crandom( &randomSeed ) * weLi[ent->s.weapon].spread_recoil * 16; u = Q_crandom( &randomSeed ) * weLi[ent->s.weapon].spread_recoil * 16; VectorMA( origin, 8192 * 16, forward, end); VectorMA (end, r, right, end); VectorMA (end, u, up, end); ShotgunPellet( origin, end, ent ); } }
// this should match CG_ShotgunPattern void ShotgunPattern( vec3_t origin, vec3_t origin2, int seed, gentity_t *ent ) { int i; float r, u; vec3_t end; vec3_t forward, right, up; qboolean hitPlayer = qfalse; // derive the right and up vectors from the forward vector, because // the client won't have any other information VectorNormalize2( origin2, forward ); PerpendicularVector( right, forward ); CrossProduct( forward, right, up ); // backward-reconcile the other clients G_DoTimeShiftFor( ent ); // generate the "random" spread pattern for ( i = 0 ; i < DEFAULT_SHOTGUN_COUNT ; i++ ) { r = Q_crandom( &seed ) * DEFAULT_SHOTGUN_SPREAD * 16; u = Q_crandom( &seed ) * DEFAULT_SHOTGUN_SPREAD * 16; VectorMA( origin, 8192 * 16, forward, end); VectorMA (end, r, right, end); VectorMA (end, u, up, end); if( ShotgunPellet( origin, end, ent ) && !hitPlayer ) { hitPlayer = qtrue; ent->player->accuracy_hits++; } } // put them back G_UndoTimeShiftFor( ent ); }
// this should match CG_ShotgunPattern void ShotgunPattern( vec3_t origin, vec3_t origin2, int seed, gentity_t *ent ) { int i, n, c; float r, u, d; vec3_t end; vec3_t forward, right, up; qboolean hitClient = qfalse; // derive the right and up vectors from the forward vector, because // the client won't have any other information VectorNormalize2( origin2, forward ); PerpendicularVector( right, forward ); CrossProduct( forward, right, up ); n = DEFAULT_SHOTGUN_COUNT; d = DEFAULT_SHOTGUN_SPREAD / 2; c = 3; while (n > 0) { float stepSize = (2 * M_PI) / c; float step; for (step = -M_PI; step < M_PI && n > 0; step += stepSize) { r = cos(step) * d; u = sin(step) * d; VectorMA( origin, 8192, forward, end); VectorMA (end, r, right, end); VectorMA (end, u, up, end); if( ShotgunPellet( origin, end, ent ) && !hitClient ) { hitClient = qtrue; ent->client->accuracy_hits++; } n--; } d += DEFAULT_SHOTGUN_SPREAD / 2; c += 4; } /* // generate the "random" spread pattern for ( i = 0 ; i < DEFAULT_SHOTGUN_COUNT ; i++ ) { r = Q_crandom( &seed ) * DEFAULT_SHOTGUN_SPREAD; // CPM u = Q_crandom( &seed ) * DEFAULT_SHOTGUN_SPREAD; // CPM VectorMA( origin, 8192, forward, end); VectorMA (end, r, right, end); VectorMA (end, u, up, end); if( ShotgunPellet( origin, end, ent ) && !hitClient ) { hitClient = qtrue; ent->client->accuracy_hits++; } } */ }
// this should match CG_ShotgunPattern void ShotgunPattern( vec3_t origin, vec3_t origin2, int seed, gentity_t *ent ) { int i; float r, u; vec3_t end; vec3_t forward, right, up; qboolean hitClient = qfalse; //unlagged - attack prediction #2 // use this for testing /* if ( g_unlagged.integer ) Com_Printf( "Server seed: %d\n", seed ); */ //-unlagged - attack prediction #2 // derive the right and up vectors from the forward vector, because // the client won't have any other information VectorNormalize2( origin2, forward ); PerpendicularVector( right, forward ); CrossProduct( forward, right, up ); //unlagged - backward reconciliation #2 // backward-reconcile the other clients if ( g_unlagged.integer ) G_DoTimeShiftFor( ent ); //-unlagged - backward reconciliation #2 // generate the "random" spread pattern for ( i = 0 ; i < DEFAULT_SHOTGUN_COUNT ; i++ ) { r = Q_crandom( &seed ) * DEFAULT_SHOTGUN_SPREAD * 16; u = Q_crandom( &seed ) * DEFAULT_SHOTGUN_SPREAD * 16; VectorMA( origin, 8192 * 16, forward, end); VectorMA (end, r, right, end); VectorMA (end, u, up, end); if( ShotgunPellet( origin, end, ent ) && !hitClient ) { hitClient = qtrue; ent->client->accuracy_hits++; } } //unlagged - backward reconciliation #2 // put them back if ( g_unlagged.integer ) G_UndoTimeShiftFor( ent ); //-unlagged - backward reconciliation #2 }