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

  1. /*----------------------------------------------------------------------
  2.  IDGlobe.qc - Stan Smith (StoshSmith@worldnet.att.net) - 23 August 1996
  3.  
  4.     This routine adds an ID-globe (works about like IFF).  When
  5. aimed at another entity, it prints friend or foe, their netname, and
  6. current weapon. If you keep it aimed at them, it'll update every three
  7. game seconds.  It'll also ID monsters, though it's a wee-bit of a
  8. hack. (Quake-C uses ugly monster classnames, and doesn't register their
  9. weapons properly.  If you make your own creatures, please set the
  10. classnames to something cool!)
  11.     I also left in the lines that will make the IDGlobe work like a
  12. light; if you wanna use it as such, remove the //'s before the four
  13. rem'ed lines.  If the light/ID globe is aimed at a monster, it'll make
  14. them target you [almost] immediately.
  15.     If you have any questions, either email me, or visit any of the
  16. excellent Quake pages online (such as http://www.nuc.net/quake).
  17.  
  18. ---DIRECTIONS FOR INSTALLATION:-----------------------------------------
  19. **** Add the following 3 lines to the 'player only fields' in defs.qc:
  20. .float ID_inuse;        // Is ID Globe on?  1=Yes 0=No
  21. .float ID_time;        // Time until next ID unless re-aimed
  22. .entity ID_ent;        // Last entity ID'ed
  23. **** Add the following line to W_Precache() in weapons.qc:
  24. precache_sound("buttons/Switch21.wav");
  25.   ** and the following 2 lines to ImpulseCommands() in weapons.qc:
  26.      if(self.impulse==15)
  27.          ID_toggle();
  28. **** Modify progs.src to insert the following line before weapons.qc:
  29. IDglobe.qc 
  30. **** Modify the config.cfg in your game source directory to add:
  31. bind i "impulse 15"  (change i to the key you want to use)
  32. ----------------------------------------------------------------------*/
  33. void() ID_aim={
  34.     local vector src;
  35.     local entity me;
  36.     local float temp;
  37.     me=self.owner;
  38.     if(!me.ID_inuse){
  39.         remove(self);
  40.         return;}
  41.     makevectors(me.v_angle);
  42.     src=me.origin+v_forward*10;
  43.     src_z=me.absmin_z+me.size_z*0.7;
  44.     traceline(src,src+v_forward*2048,FALSE,me);
  45.     setorigin(self,trace_endpos-v_forward*10);
  46.     self.nextthink=time+0.1;
  47.     if(me.ID_ent!=trace_ent||time>me.ID_time){
  48.         if(trace_ent.classname=="player"){
  49.             if(trace_ent.team!=me.team) sprint(me,"FOE: ");
  50.             else sprint(me,"FRIEND: ");
  51.             sprint(me,trace_ent.netname);
  52.             temp=trace_ent.weapon;
  53.             if(temp==IT_AXE) sprint(me,"- Axe");
  54.             else if(temp==IT_SHOTGUN) sprint(me,"- Shotgun");
  55.             else if(temp==IT_SUPER_SHOTGUN) sprint(me,"- Super Shotgun");
  56.             else if(temp==IT_NAILGUN) sprint(me,"- Nailgun");
  57.             else if(temp==IT_SUPER_NAILGUN) sprint(me,"- Super Nailgun");
  58.             else if(temp==IT_GRENADE_LAUNCHER) sprint(me,"- Grenade Launcher");
  59.             else if(temp==IT_ROCKET_LAUNCHER) sprint(me,"- Rocket Launcher");
  60.             else if(temp==IT_LIGHTNING) sprint(me,"- Lightning Gun");
  61.             else sprint(me,"- Unknown Weapon");}
  62.         else if(!me.deadflag&&trace_ent.flags&FL_MONSTER){
  63. //            trace_ent.enemy=me;
  64. //            trace_ent.nextthink=time+0.2;
  65. //            trace_ent.think=FoundTarget;
  66.             sprint(me,"ID: ");
  67.             if(trace_ent.classname=="monster_ogre") sprint(me,"Ogre (Chainsaw/grenades)");
  68.             else if(trace_ent.classname=="monster_knight") sprint(me,"Knight (Sword)");
  69.             else if(trace_ent.classname=="monster_shambler") sprint(me,"Shambler (Claws/lightning bolt)");
  70.             else if(trace_ent.classname=="monster_demon1") sprint(me,"Fiend (Claw/horn)");
  71.             else if(trace_ent.classname=="monster_wizard") sprint(me,"Scrag (Particle beam)");
  72.             else if(trace_ent.classname=="monster_zombie") sprint(me,"Zombie (Chunk 'o flesh)");
  73.             else if(trace_ent.classname=="monster_dog") sprint(me,"Rottweiler (Tooth/claw)");
  74.             else if(trace_ent.classname=="monster_hell_knight") sprint(me,"Death Knight (Sword/flame fan)");
  75.             else if(trace_ent.classname=="monster_tarbaby") sprint(me,"Spawn (Corrosive touch)");
  76.             else if(trace_ent.classname=="monster_vomit") sprint(me,"Vore (Firepod)");
  77.             else if(trace_ent.classname=="monster_enforcer") sprint(me,"Enforcer (Laser rifle)");
  78.             else if(trace_ent.classname=="monster_army") sprint(me,"Grunt (Shotgun)");
  79.             else sprint(me,trace_ent.classname);}
  80.         else return;
  81.         sprint(me,"\n");
  82.         me.ID_time=time+3;
  83.         me.ID_ent=trace_ent;}};
  84.  
  85. void() ID_toggle={
  86.     local entity temp;
  87.     if(self.ID_inuse){
  88.         sprint(self,"I.D. globe off\n");
  89.         sound(self,CHAN_WEAPON,"buttons/Switch21.wav",1,ATTN_NORM);
  90.         self.ID_inuse=0;}
  91.     else{
  92.         sprint(self,"I.D. globe on\n");
  93.         sound(self,CHAN_VOICE,"buttons/Switch21.wav",1,ATTN_NORM);
  94.         self.ID_inuse=1;
  95.         temp=spawn();
  96.         setorigin(temp,self.origin);
  97.         setmodel(temp,"progs/s_bubble.spr");
  98.         setsize(temp,'0 0 0','0 0 0');
  99.         temp.classname="IDGlobe";
  100.         temp.movetype=MOVETYPE_NONE;
  101.         temp.solid=SOLID_NOT;
  102. //        temp.effects=EF_DIMLIGHT;
  103.         temp.owner=self;
  104.         temp.nextthink=time+0.1;
  105.         temp.think=ID_aim;}};
  106.