/* lights.c */ #include "g_local.h" /* 8===============> FL_make make the dang thing <===============8 */ void FL_make(edict_t *self) { vec3_t start,forward,right,end; int color; if ( self->flashlight ) { G_FreeEdict(self->flashlight); self->flashlight = NULL; return; } AngleVectors (self->client->v_angle, forward, right, NULL); VectorSet(end,100 , 0, 0); G_ProjectSource (self->s.origin, end, forward, right, start); self->flashlight = G_Spawn (); self->flashlight->owner = self; self->flashlight->movetype = MOVETYPE_NOCLIP; self->flashlight->solid = SOLID_NOT; self->flashlight->classname = "flashlight"; self->flashlight->s.modelindex = gi.modelindex ("sprites/null/null.sp2"); self->flashlight->s.skinnum = 0; //4 possible colors for flashlight if (flashlight_color->value == 2) { self->flashlight->s.effects = EF_BFG; //Green gi.cprintf (self, PRINT_HIGH, "Green flashlight on.\n"); } else if (flashlight_color->value == 3) { self->flashlight->s.effects = EF_FLAG1; //Red gi.cprintf (self, PRINT_HIGH, "Red flashlight on.\n"); } //particles else if (flashlight_color->value == 4) { self->flashlight->s.effects = EF_FLAG2; //Blue gi.cprintf (self, PRINT_HIGH, "Blue flashlight on.\n"); } else { self->flashlight->s.effects = EF_HYPERBLASTER; //Yellow gi.cprintf (self, PRINT_HIGH, "Flashlight on.\n"); } self->flashlight->think = FL_think; self->flashlight->nextthink = level.time + 0.1; } /* 8===============> FL_make make the dang thing <===============8 */ void FL_think (edict_t *self) { vec3_t start,end,endp,offset; vec3_t forward,right,up; trace_t tr; AngleVectors (self->owner->client->v_angle, forward, right, up); VectorSet(offset,24 , 6, self->owner->viewheight-7); G_ProjectSource (self->owner->s.origin, offset, forward, right, start); VectorMA(start,8192,forward,end); tr = gi.trace (start,NULL,NULL, end,self->owner,CONTENTS_SOLID|CONTENTS_MONSTER|CONTENTS_DEADMONSTER); if (tr.fraction != 1) { VectorMA(tr.endpos,-4,forward,endp); VectorCopy(endp,tr.endpos); } if ((tr.ent->svflags & SVF_MONSTER) || (tr.ent->client)) { if ((tr.ent->takedamage) && (tr.ent != self->owner)) { self->s.skinnum = 1; } } else self->s.skinnum = 0; vectoangles(tr.plane.normal,self->s.angles); VectorCopy(tr.endpos,self->s.origin); gi.linkentity (self); self->nextthink = level.time + 0.1; } void elecshock(edict_t *ent) { int i; ent->client->elec_shock_framenum-=1; // subtracts 1 from elec_shock_framenum if (ent->client->elec_shock_framenum>0) // in case I screwed up and this gets called without the person being shocked. { ent->s.effects |= EF_COLOR_SHELL; ent->s.renderfx |= RF_SHELL_BLUE; // these two lines add a blue shell to the person. for (i=0 ; i<3 ; i++) { ent->client->kick_origin[i] = crandom() * 0.35; ent->client->kick_angles[i] = crandom() * 0.7; // make the screen shake increase the multiplier fo the angles for a greater shaking effect } // unfortunatly you have to add the blueness to thier screen elsewhere (in p_view.c) } else { // the last frame will clean up all the effects ent->s.effects &= ~EF_COLOR_SHELL; ent->s.renderfx &= ~RF_SHELL_RED; } } /*---------------------------------------- SP_LaserSight Create/remove the laser sight entity -----------------------------------------*/ #define lss self->lasersight void SP_LaserSight(edict_t *self) { vec3_t start,forward,right,end; if ( lss ) { G_FreeEdict(lss); lss = NULL; gi.bprintf (PRINT_HIGH, "lasersight off."); return; } gi.bprintf (PRINT_HIGH, "lasersight on."); AngleVectors (self->client->v_angle, forward, right, NULL); VectorSet(end,100 , 0, 0); G_ProjectSource (self->s.origin, end, forward, right, start); lss = G_Spawn (); lss->owner = self; lss->movetype = MOVETYPE_NOCLIP; lss->solid = SOLID_NOT; lss->classname = "lasersight"; lss->s.modelindex = gi.modelindex ("sprites/null/null.sp2"); lss->s.effects |= EF_IONRIPPER; lss->s.skinnum = 0; lss->s.renderfx |= RF_FULLBRIGHT; lss->think = LaserSightThink; lss->nextthink = level.time + 0.1; } /*--------------------------------------------- LaserSightThink Updates the sights position, angle, and shape is the lasersight entity ---------------------------------------------*/ void LaserSightThink (edict_t *self) { vec3_t start,end,endp,offset; vec3_t forward,right,up; trace_t tr; AngleVectors (self->owner->client->v_angle, forward, right, up); VectorSet(offset,24 , 6, self->owner->viewheight-7); G_ProjectSource (self->owner->s.origin, offset, forward, right, start); VectorMA(start,8192,forward,end); tr = gi.trace (start,NULL,NULL, end,self->owner,CONTENTS_SOLID|CONTENTS_MONSTER|CONTENTS_DEADMONSTER); if (tr.fraction != 1) { VectorMA(tr.endpos,-4,forward,endp); VectorCopy(endp,tr.endpos); } if ((tr.ent->svflags & SVF_MONSTER) || (tr.ent->client)){ if ((tr.ent->takedamage) && (tr.ent != self->owner)) { self->s.skinnum = 1; } } else self->s.skinnum = 0; vectoangles(tr.plane.normal,self->s.angles); VectorCopy(tr.endpos,self->s.origin); gi.linkentity (self); self->nextthink = level.time + 0.1; }