I'm using ubuntu (newest version as of now), and I would like to know how to edit the Advanced Marauders decreasing zap damage as more targets are "zapped". Is this in the g_weapon.c?
Here is the code for the Advanced Marauder section so you won't have to open it up (from g_weapon.c)
g_findnewzaptarget
/*
===============
G_FindNewZapTarget
===============
*/
static gentity_t *G_FindNewZapTarget( gentity_t *ent )
{
int entityList[ MAX_GENTITIES ];
vec3_t range = { LEVEL2_AREAZAP_RANGE, LEVEL2_AREAZAP_RANGE, LEVEL2_AREAZAP_RANGE };
vec3_t mins, maxs;
int i, j, k, num;
gentity_t *enemy;
trace_t tr;
VectorScale( range, 1.0f / M_ROOT3, range );
VectorAdd( ent->s.origin, range, maxs );
VectorSubtract( ent->s.origin, range, mins );
num = trap_EntitiesInBox( mins, maxs, entityList, MAX_GENTITIES );
for( i = 0; i < num; i++ )
{
enemy = &g_entities[ entityList[ i ] ];
if( ( ( enemy->client && enemy->client->ps.stats[ STAT_PTEAM ] == PTE_HUMANS ) ||
( enemy->s.eType == ET_BUILDABLE &&
BG_FindTeamForBuildable( enemy->s.modelindex ) == BIT_HUMANS ) ) && enemy->health > 0 )
{
qboolean foundOldTarget = qfalse;
trap_Trace( &tr, muzzle, NULL, NULL, enemy->s.origin, ent->s.number, MASK_SHOT );
//can't see target from here
if( tr.entityNum == ENTITYNUM_WORLD )
continue;
for( j = 0; j < MAX_ZAPS; j++ )
{
zap_t *zap = &zaps[ j ];
for( k = 0; k < zap->numTargets; k++ )
{
if( zap->targets[ k ] == enemy )
{
foundOldTarget = qtrue;
break;
}
}
if( foundOldTarget )
break;
}
// enemy is already targetted
if( foundOldTarget )
continue;
return enemy;
}
}
return NULL;
}
/*
g_updatezapeffect
===============
G_UpdateZapEffect
===============
*/
static void G_UpdateZapEffect( zap_t *zap )
{
int j;
gentity_t *effect = zap->effectChannel;
effect->s.eType = ET_LEV2_ZAP_CHAIN;
effect->classname = "lev2zapchain";
G_SetOrigin( effect, zap->creator->s.origin );
effect->s.powerups = zap->creator->s.number;
effect->s.time = effect->s.time2 = effect->s.constantLight = -1;
for( j = 0; j < zap->numTargets; j++ )
{
int number = zap->targets[ j ]->s.number;
switch( j )
{
case 0: effect->s.time = number; break;
case 1: effect->s.time2 = number; break;
case 2: effect->s.constantLight = number; break;
default: break;
}
}
trap_LinkEntity( effect );
}
/*
g_createnewzap
===============
G_CreateNewZap
===============
*/
static void G_CreateNewZap( gentity_t *creator, gentity_t *target )
{
int i, j;
zap_t *zap;
for( i = 0; i < MAX_ZAPS; i++ )
{
zap = &zaps[ i ];
if( !zap->used )
{
zap->used = qtrue;
zap->timeToLive = LEVEL2_AREAZAP_TIME;
zap->damageUsed = 0;
zap->creator = creator;
zap->targets[ 0 ] = target;
zap->numTargets = 1;
for( j = 1; j < MAX_ZAP_TARGETS && zap->targets[ j - 1 ]; j++ )
{
zap->targets[ j ] = G_FindNewZapTarget( zap->targets[ j - 1 ] );
if( zap->targets[ j ] )
zap->numTargets++;
}
zap->effectChannel = G_Spawn( );
G_UpdateZapEffect( zap );
return;
}
}
}
/*
g_updatezaps
===============
G_UpdateZaps
===============
*/
void G_UpdateZaps( int msec )
{
int i, j;
zap_t *zap;
int damage;
for( i = 0; i < MAX_ZAPS; i++ )
{
zap = &zaps[ i ];
if( zap->used )
{
//check each target is valid
for( j = 0; j < zap->numTargets; j++ )
{
gentity_t *source;
gentity_t *target = zap->targets[ j ];
if( j == 0 )
source = zap->creator;
else
source = zap->targets[ j - 1 ];
if( target->health <= 0 || !target->inuse || //early out
Distance( source->s.origin, target->s.origin ) > LEVEL2_AREAZAP_RANGE )
{
target = zap->targets[ j ] = G_FindNewZapTarget( source );
//couldn't find a target, so forget about the rest of the chain
if( !target )
zap->numTargets = j;
}
}
if( zap->numTargets )
{
for( j = 0; j < zap->numTargets; j++ )
{
gentity_t *source;
gentity_t *target = zap->targets[ j ];
float r = 1.0f / zap->numTargets;
float damageFraction = 2 * r - 2 * j * r * r - r * r;
vec3_t forward;
if( j == 0 )
source = zap->creator;
else
source = zap->targets[ j - 1 ];
damage = ceil( ( (float)msec / LEVEL2_AREAZAP_TIME ) *
LEVEL2_AREAZAP_DMG * damageFraction );
// don't let a high msec value inflate the total damage
if( damage + zap->damageUsed > LEVEL2_AREAZAP_DMG )
damage = LEVEL2_AREAZAP_DMG - zap->damageUsed;
VectorSubtract( target->s.origin, source->s.origin, forward );
VectorNormalize( forward );
//do the damage
if( damage )
{
G_Damage( target, source, zap->creator, forward, target->s.origin,
damage, DAMAGE_NO_KNOCKBACK | DAMAGE_NO_LOCDAMAGE, MOD_LEVEL2_ZAP );
zap->damageUsed += damage;
}
}
}
G_UpdateZapEffect( zap );
zap->timeToLive -= msec;
if( zap->timeToLive <= 0 || zap->numTargets == 0 || zap->creator->health <= 0 )
{
zap->used = qfalse;
G_FreeEntity( zap->effectChannel );
}
}
}
}
/*
areazapfire
===============
areaZapFire
===============
*/
void areaZapFire( gentity_t *ent )
{
trace_t tr;
vec3_t end;
gentity_t *traceEnt;
vec3_t mins, maxs;
VectorSet( mins, -LEVEL2_AREAZAP_WIDTH, -LEVEL2_AREAZAP_WIDTH, -LEVEL2_AREAZAP_WIDTH );
VectorSet( maxs, LEVEL2_AREAZAP_WIDTH, LEVEL2_AREAZAP_WIDTH, LEVEL2_AREAZAP_WIDTH );
// set aiming directions
AngleVectors( ent->client->ps.viewangles, forward, right, up );
CalcMuzzlePoint( ent, forward, right, up, muzzle );
VectorMA( muzzle, LEVEL2_AREAZAP_RANGE, forward, end );
G_UnlaggedOn( ent, muzzle, LEVEL2_AREAZAP_RANGE );
trap_Trace( &tr, muzzle, mins, maxs, end, ent->s.number, MASK_SHOT );
G_UnlaggedOff( );
if( tr.surfaceFlags & SURF_NOIMPACT )
return;
traceEnt = &g_entities[ tr.entityNum ];
if( ( ( traceEnt->client && traceEnt->client->ps.stats[ STAT_PTEAM ] == PTE_HUMANS ) ||
( traceEnt->s.eType == ET_BUILDABLE &&
BG_FindTeamForBuildable( traceEnt->s.modelindex ) == BIT_HUMANS ) ) && traceEnt->health > 0 )
{
G_CreateNewZap( ent, traceEnt );
}
}
/*
If anyone knows where to find the 1.2 code for this, that would be appreciated.
-tibs