home *** CD-ROM | disk | FTP | other *** search
/ Quake 'em / QUAKEEM.BIN / quake / programs / idglobe / globe.qc < prev    next >
Encoding:
Text File  |  1996-08-21  |  2.6 KB  |  67 lines

  1. /*----------------------------------------------------------------------
  2.  Globe.qc - Stan Smith  (StoshSmith@worldnet.att.net) - 16 August 1996
  3.  
  4. This code adds a light-globe that shines ahead of you like a flashlight.
  5.         Watch your aim; it'll anger any creature it's pointed at!
  6. Since it's not intended to be a true flashlight, There isn't a source
  7.         light near the player.  If you want the player to also be lit,
  8.         (nice target for multiplayer games) just uncomment the two lines
  9.         that reference self.effects.  Note that this doesn't add a
  10.         separate light source-it just makes the globe's user cast light.
  11. If you have any questions, either email me, or visit any of the
  12.         excellent Quake pages online (such as http://www.nuc.net/quake).
  13.  
  14. ---DIRECTIONS FOR INSTALLATION:-----------------------------------------
  15. ** Add the following line to the 'player only fields' in defs.qc:
  16.     .float globe_power;
  17. ** Add the following line to W_Precache() in weapons.qc:
  18.     precache_sound("buttons/Switch21.wav");
  19.    and the following 2 lines to ImpulseCommands() in weapons.qc:
  20.      if(self.impulse==13)
  21.          Globe_toggle();
  22. ** Modify progs.src to insert the line globe.qc before weapons.qc
  23. ** Modify the config.cfg in your game source directory to add:
  24.     bind l "impulse 13"  (change l to the key you want to use)
  25. ----------------------------------------------------------------------*/
  26. void() Globe_aim={
  27.     local vector src;
  28.     local entity me;
  29.     me=self.owner;
  30.     if(!me.globe_power){
  31.         remove(self);
  32.         return;}
  33.     makevectors(me.v_angle);
  34.     src=me.origin+v_forward*10;
  35.     src_z=me.absmin_z+me.size_z*0.7;
  36.     traceline(src,src+v_forward*2048,FALSE,me);
  37.     setorigin(self,trace_endpos-v_forward*10);
  38.     self.nextthink=time+0.1;
  39.     if(!me.deadflag&&trace_ent.flags&FL_MONSTER&&!trace_ent.enemy){
  40.         trace_ent.enemy=me;
  41.         trace_ent.nextthink=time+0.2;
  42.         trace_ent.think=FoundTarget;}};
  43.  
  44. void() Globe_toggle={
  45.     local entity temp;
  46.     if(self.globe_power){
  47.         sprint(self,"Light globe off\n");
  48.         sound(self,CHAN_WEAPON,"buttons/Switch21.wav",1,ATTN_NORM);
  49. //        if(self.effects&EF_DIMLIGHT) self.effects=self.effects-EF_DIMLIGHT;
  50.         self.globe_power=0;}
  51.     else{
  52.         sprint(self,"Light globe on\n");
  53.         sound(self,CHAN_VOICE,"buttons/Switch21.wav",1,ATTN_NORM);
  54.         self.globe_power=1;
  55. //        self.effects=self.effects|EF_DIMLIGHT;
  56.         temp=spawn();
  57.         setorigin(temp,self.origin);
  58.         setmodel(temp,"progs/s_bubble.spr");
  59.         setsize(temp,'0 0 0','0 0 0');
  60.         temp.classname="LightGlobe";
  61.         temp.movetype=MOVETYPE_NONE;
  62.         temp.solid=SOLID_NOT;
  63.         temp.effects=EF_DIMLIGHT;
  64.         temp.owner=self;
  65.         temp.nextthink=time+0.1;
  66.         temp.think=Globe_aim;}};
  67.