|
|
 |
08-18-2005, 12:59 AM
|
#1
|
|
Rookie
Join Date: May 2004
Posts: 139
|
Direction issues ( Shooting thru walls )
hey , im making it so the Disruptor can snipe through walls.
well auctually anything, apart form the sky.
So i figured i would make the Shot go foward a little bit at a time when it hit a wall. then when it gets out of the wall , count it as a shot.
anyway. my problem is.
the whole
'foward'
thing dose not seem to be working. instead of trying further infront,
it seems to be trying any random direction 0.0
Code:
AngleVectors(ent->client->ps.viewangles, fwd, NULL, NULL);//<< Wall shot
for (i = 0; i < traces; i++ )
{
if(hitwall==qtrue) start[1]=start[1] + fwd[2]*500;
Code:
if(traceEnt!=NULL ) { //<<GA Shooting thru walls
hitwall = qtrue;
Message(ent,va( "^1Sniped Something: ^3%i / %i",i,traces),0,1);
skip = tr.entityNum;
render_impact=qtrue;
if(tr.entityNum ==LastWall) {// Hit the same wall twice! , dont count it again
traces++;
VectorCopy(tr.endpos, start);
}
LastWall=tr.entityNum;
VectorCopy(tr.endpos, start);
tent = G_TempEntity( tr.endpos, EV_DISRUPTOR_HIT );
tent->s.eventParm = DirToByte( tr.plane.normal );
}else{
return;
}
Screenshot:
http://img355.imageshack.us/img355/3...creenie8mr.jpg
|
|
you may:
quote & reply,
|
08-18-2005, 01:24 AM
|
#2
|
|
Rookie
Join Date: May 2004
Posts: 139
|
nevermind , got it
Code:
float WallThickness= 50.0f;
Code:
//VectorMA(v,s,b,o) - make b s units long, add to v, result in o
VectorMA( start, shotRange, forward, end );
if(hitwall==qtrue)VectorMA( start, WallThickness, forward, start );
|
|
you may:
quote & reply,
|
08-18-2005, 02:55 AM
|
#3
|
|
Rookie
Join Date: May 2004
Posts: 139
|
Heres the function if anyone is intrested in sniping thru walls
http://img363.imageshack.us/img363/2...llsnipe9ui.jpg
Code:
void WP_DisruptorAltFire( gentity_t *ent )
//---------------------------------------------------------
{
int damage = 0, skip;
qboolean render_impact = qtrue;
vec3_t start, end,backofwall;
vec3_t muzzle2;
trace_t tr,tr2;
gentity_t *traceEnt, *tent;
float shotRange = 8192.0f;
float WallThickness= 50.0f;
int i;
int LastWall=0;//<<GA
int count, maxCount = 60;
int traces = DISRUPTOR_ALT_TRACES;
int wallshots=0;
int dubbleshots=0; //Times hit the same entity
qboolean fullCharge = qfalse;
qboolean hitwall = qfalse;
damage = DISRUPTOR_ALT_DAMAGE-30;
VectorCopy( muzzle, muzzle2 ); // making a backup copy
if (ent->client)
{
VectorCopy( ent->client->ps.origin, start );
start[2] += ent->client->ps.viewheight;//By eyes
count = ( level.time - ent->client->ps.weaponChargeTime ) / DISRUPTOR_CHARGE_UNIT;
if ( g_gametype.integer == GT_SIEGE )
{//maybe a full alt-charge should be a *bit* more dangerous in Siege mode?
//maxCount = ceil((200.0f-(float)damage)/2.0f);//cap at 200 damage total
maxCount = 200;//the previous line ALWAYS evaluated to 135 - was that on purpose?
}
}
else
{
VectorCopy( ent->r.currentOrigin, start );
start[2] += 24;
count = ( 100 ) / DISRUPTOR_CHARGE_UNIT;
}
count *= 2;
if ( count < 1 )
{
count = 1;
}
else if ( count >= maxCount )
{
count = maxCount;
fullCharge = qtrue;
}
// more powerful charges go through more things
if ( count < 10 )
{
traces = 1;
}
else if ( count < 20 )
{
traces = 2;
}
damage += count;
traces+=3;
skip = ent->s.number;
for (i = 0; i < traces; i++ )
{
//VectorMA(v,s,b,o) - make b s units long, add to v, result in o
VectorMA( start, shotRange, forward, end );
if(hitwall==qtrue) {
wallshots++;
VectorMA( start, WallThickness, forward, start );
if(i>0) {
LastWall=tr.entityNum;
}
}
if (d_projectileGhoul2Collision.integer)
{
trap_G2Trace( &tr, start, NULL, NULL, end, skip, MASK_SHOT, G2TRFLAG_DOGHOULTRACE|G2TRFLAG_GETSURFINDEX|G2TRFLAG_THICK|G2TRFLAG_HITCORPSES, g_g2TraceLod.integer );
}
else
{
trap_Trace( &tr, start, NULL, NULL, end, skip, MASK_SHOT );
}
traceEnt = &g_entities[tr.entityNum];
hitwall = qfalse;
traces=traces-1;
if(wallshots < 2 && dubbleshots < 4) {
if(traceEnt!=NULL ) { //<<GA Shooting thru walls
hitwall = qtrue;
//Message(ent,va( "^1Sniped Something: ^3%i / %i ^6Entity Num: %i",i,traces,tr.entityNum),0,1);
skip = tr.entityNum;
render_impact=qtrue;
if(tr.entityNum ==LastWall) {// Hit the same wall twice! , dont count it again
traces=traces+2;
VectorCopy(tr.endpos, start);
wallshots=wallshots-1;
dubbleshots++;
}else {
//New brush , so reset dubble shots
dubbleshots=0;
}
VectorCopy(tr.endpos, start);
if(tr.entityNum !=LastWall) {// Hit the same wall twice!
tent = G_TempEntity( tr.endpos, EV_DISRUPTOR_HIT );
tent->s.eventParm = DirToByte( tr.plane.normal );
}
}else{
return;
}
} //<< Wallshot limet
else{
break;
}
if (d_projectileGhoul2Collision.integer && traceEnt->inuse && traceEnt->client)
{ //g2 collision checks -rww
if (traceEnt->inuse && traceEnt->client && traceEnt->ghoul2)
{ //since we used G2TRFLAG_GETSURFINDEX, tr.surfaceFlags will actually contain the index of the surface on the ghoul2 model we collided with.
traceEnt->client->g2LastSurfaceHit = tr.surfaceFlags;
traceEnt->client->g2LastSurfaceTime = level.time;
}
if (traceEnt->ghoul2)
{
tr.surfaceFlags = 0; //clear the surface flags after, since we actually care about them in here.
}
}
if ( tr.surfaceFlags & SURF_NOIMPACT )
{
hitwall = qfalse;
render_impact = qfalse;
}
if (traceEnt && traceEnt->client && traceEnt->client->ps.duelInProgress &&
traceEnt->client->ps.duelIndex != ent->s.number)
{
hitwall = qfalse;
skip = tr.entityNum;
VectorCopy(tr.endpos, start);
continue;
}
if (Jedi_DodgeEvasion(traceEnt, ent, &tr, G_GetHitLocation(traceEnt, tr.endpos)))
{
skip = tr.entityNum;
VectorCopy(tr.endpos, start);
continue;
}
else if (traceEnt && traceEnt->client && traceEnt->client->ps.fd.forcePowerLevel[FP_SABER_DEFENSE] >= FORCE_LEVEL_3)
{
if (WP_SaberCanBlock(traceEnt, tr.endpos, 0, MOD_DISRUPTOR_SNIPER, qtrue, 0))
{ //broadcast and stop the shot because it was blocked
gentity_t *te = NULL;
/*
tent = G_TempEntity( tr.endpos, EV_DISRUPTOR_SNIPER_SHOT );
VectorCopy( muzzle, tent->s.origin2 );
tent->s.shouldtarget = fullCharge;
tent->s.eventParm = ent->s.number;
*/
te = G_TempEntity( tr.endpos, EV_SABER_BLOCK );
VectorCopy(tr.endpos, te->s.origin);
VectorCopy(tr.plane.normal, te->s.angles);
if (!te->s.angles[0] && !te->s.angles[1] && !te->s.angles[2])
{
te->s.angles[1] = 1;
}
te->s.eventParm = 0;
te->s.weapon = 0;//saberNum
te->s.legsAnim = 0;//bladeNum
if(hitwall==qfalse) return;
}
}
// always render a shot beam, doing this the old way because I don't much feel like overriding the effect.
if(tr.entityNum !=LastWall) {
//Dont keep rendering shots on the same entity. ( wall snipe )
tent = G_TempEntity( tr.endpos, EV_DISRUPTOR_SNIPER_SHOT );
VectorCopy( muzzle, tent->s.origin2 );
tent->s.shouldtarget = fullCharge;
tent->s.eventParm = ent->s.number;
}
// If the beam hits a skybox, etc. it would look foolish to add impact effects
if ( render_impact )
{
if ( traceEnt->takedamage && traceEnt->client )
{
tent->s.otherEntityNum = traceEnt->s.number;
hitwall = qfalse;
// Create a simple impact type mark
tent = G_TempEntity(tr.endpos, EV_MISSILE_MISS);
tent->s.eventParm = DirToByte(tr.plane.normal);
tent->s.eFlags |= EF_ALT_FIRING;
if ( LogAccuracyHit( traceEnt, ent ))
{
if (ent->client)
{
ent->client->accuracy_hits++;
}
}
}
else
{
if ( traceEnt->r.svFlags & SVF_GLASS_BRUSH
|| traceEnt->takedamage
|| traceEnt->s.eType == ET_MOVER )
{
if ( traceEnt->takedamage )
{
G_Damage( traceEnt, ent, ent, forward, tr.endpos, damage,
DAMAGE_NO_KNOCKBACK, MOD_DISRUPTOR_SNIPER );
tent = G_TempEntity( tr.endpos, EV_DISRUPTOR_HIT );
tent->s.eventParm = DirToByte( tr.plane.normal );
}
}
else
{
// Hmmm, maybe don't make any marks on things that could break
tent = G_TempEntity( tr.endpos, EV_DISRUPTOR_SNIPER_MISS );
tent->s.eventParm = DirToByte( tr.plane.normal );
}
if(hitwall==qfalse) break; // and don't try any more traces
}
if ( (traceEnt->flags&FL_SHIELDED) )
{//stops us cold
if(hitwall==qfalse) break;
}
if ( traceEnt->takedamage )
{
vec3_t preAng;
int preHealth = traceEnt->health;
int preLegs = 0;
int preTorso = 0;
if (traceEnt->client)
{
preLegs = traceEnt->client->ps.legsAnim;
preTorso = traceEnt->client->ps.torsoAnim;
VectorCopy(traceEnt->client->ps.viewangles, preAng);
}
G_Damage( traceEnt, ent, ent, forward, tr.endpos, damage, DAMAGE_NO_KNOCKBACK, MOD_DISRUPTOR_SNIPER );
if (traceEnt->client && preHealth > 0 && traceEnt->health <= 0 && fullCharge &&
G_CanDisruptify(traceEnt))
{ //was killed by a fully charged sniper shot, so disintegrate
VectorCopy(preAng, traceEnt->client->ps.viewangles);
traceEnt->client->ps.eFlags |= EF_DISINTEGRATION;
VectorCopy(tr.endpos, traceEnt->client->ps.lastHitLoc);
traceEnt->client->ps.legsAnim = preLegs;
traceEnt->client->ps.torsoAnim = preTorso;
traceEnt->r.contents = 0;
VectorClear(traceEnt->client->ps.velocity);
}
tent = G_TempEntity( tr.endpos, EV_DISRUPTOR_HIT );
tent->s.eventParm = DirToByte( tr.plane.normal );
if (traceEnt->client)
{
tent->s.weapon = 1;
}
}
}
else // not rendering impact, must be a skybox or other similar thing?
{
if(hitwall==qfalse) break; // don't try anymore traces
}
// Get ready for an attempt to trace through another person
VectorCopy( tr.endpos, muzzle );
VectorCopy( tr.endpos, start );
skip = tr.entityNum;
}
}
Last edited by GangsterAngel; 08-18-2005 at 03:07 AM.
|
|
you may:
quote & reply,
|
08-18-2005, 02:30 PM
|
#4
|
|
Rookie
Join Date: Feb 2005
Posts: 12
|
Hey GA i know this is off topic but could you tell me how u made that HP Bar drain instead of fading 1 piece at a time?
...........::::::::THIS IS MY SIG!::::::::........
Problem is.. i dont have a sig..
|
|
you may:
quote & reply,
|
08-18-2005, 06:30 PM
|
#5
|
|
Rookie
Join Date: May 2004
Posts: 139
|
its just a menu file , and it dose auctually fade, theres just carefully lade out copys of the progress bar texture layd ontop of each other. and as it fades out it looks like progress bar.
|
|
you may:
quote & reply,
|
08-21-2005, 04:34 PM
|
#6
|
|
Rookie
Join Date: Feb 2005
Posts: 12
|
care to explain sum more?
im affraid i dont get it
...........::::::::THIS IS MY SIG!::::::::........
Problem is.. i dont have a sig..
|
|
you may:
quote & reply,
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
Forum Jump
|
|
|
|
|
|