home *** CD-ROM | disk | FTP | other *** search
/ Quake 'em / QUAKEEM.BIN / quake / programs / godelqc3 / godel.qc < prev    next >
Encoding:
Text File  |  1996-08-15  |  15.1 KB  |  487 lines

  1. .float grenadetimer;
  2. .float numminion;//init
  3. .float numholo;//init
  4. .float nextregen;
  5.  
  6. //prototypes
  7. float() crandom;
  8. void() GrenadeExplode;
  9. void() BecomeExplosion;
  10. void() CastLightning; //shambler.qc modified to change ligntning origin 
  11.  
  12. //Used to toss a weapon, ammo, or armor.
  13. void(float ax) TossBackpack =
  14. {
  15.     local entity    item;
  16.     if (self.flags & FL_OBSERVER) return;
  17.     if (self.impulse==55) ax=0;
  18.     else if (self.impulse==56) ax=1;
  19.     else if (self.impulse==57) ax=32;
  20.     if (ax==0) {
  21.         if (self.weapon==IT_SUPER_SHOTGUN) ax=3;
  22.         if (self.weapon==IT_NAILGUN) ax=4;
  23.         if (self.weapon==IT_SUPER_NAILGUN) ax=5;
  24.         if (self.weapon==IT_GRENADE_LAUNCHER) ax=6;
  25.         if (self.weapon==IT_ROCKET_LAUNCHER) ax=7;
  26.         if (self.weapon==IT_LIGHTNING) ax=8;
  27.     }
  28.     if (ax==1) {
  29.         if (self.weapon==IT_SHOTGUN) ax=16;
  30.         if (self.weapon==IT_SUPER_SHOTGUN) ax=16;
  31.         if (self.weapon==IT_NAILGUN) ax=17;
  32.         if (self.weapon==IT_SUPER_NAILGUN) ax=17;
  33.         if (self.weapon==IT_GRENADE_LAUNCHER) ax=18;
  34.         if (self.weapon==IT_ROCKET_LAUNCHER) ax=18;
  35.         if (self.weapon==IT_LIGHTNING) ax=19;
  36.     }
  37.     if (ax==2) {
  38.         if (!(self.ammo_shells+self.ammo_nails+self.ammo_rockets+self.ammo_cells))
  39.             return;    // nothing in it
  40.         item = spawn();
  41.         item.owner = self;
  42.         item.items = 0;
  43.         setmodel (item, "progs/backpack.mdl");
  44.         setsize (item, '-16 -16 0', '16 16 56');
  45.         item.touch = BackpackTouch;
  46.         item.ammo_shells = self.ammo_shells;
  47.         item.ammo_nails = self.ammo_nails;
  48.         item.ammo_rockets = self.ammo_rockets;
  49.         item.ammo_cells = self.ammo_cells;
  50.         item.classname="backpack";
  51.         self.ammo_shells = 0;
  52.         self.ammo_nails = 0;
  53.         self.ammo_rockets = 0;
  54.         self.ammo_cells = 0;    
  55.     } else if (ax==3) {
  56.         if (!(self.items & IT_SUPER_SHOTGUN)) return;
  57.         item = spawn();
  58.         item.owner = self;
  59.         item.items = IT_SUPER_SHOTGUN;
  60.         self.items = self.items - IT_SUPER_SHOTGUN;
  61.         if (self.weapon==IT_SUPER_SHOTGUN) self.weapon=W_BestWeapon();
  62.         setmodel (item, "progs/g_shot.mdl");
  63.         setsize (item, '-16 -16 0', '16 16 56');
  64.         item.touch = BackpackTouch;
  65.         if (self.ammo_shells < 10)
  66.         item.ammo_shells = self.ammo_shells;
  67.         else    item.ammo_shells = 10;
  68.         self.ammo_shells=self.ammo_shells-item.ammo_shells;
  69.         item.classname="weapon_supershotgun";
  70.     } else if (ax==4) {
  71.         if (!(self.items & IT_NAILGUN)) return;
  72.         item = spawn();
  73.         item.owner = self;
  74.         item.items = IT_NAILGUN;
  75.         self.items = self.items - IT_NAILGUN;
  76.         if (self.weapon==IT_NAILGUN) self.weapon=W_BestWeapon();
  77.         setmodel (item, "progs/g_nail.mdl");
  78.         setsize (item, '-16 -16 0', '16 16 56');
  79.         item.touch = BackpackTouch;
  80.         if (self.ammo_nails < 20)
  81.             item.ammo_nails = self.ammo_nails;
  82.         else    item.ammo_nails = 20;
  83.         self.ammo_nails=self.ammo_nails-item.ammo_nails;
  84.         item.classname="weapon_nailgun";
  85.     } else if (ax==5) {
  86.         if (!(self.items & IT_SUPER_NAILGUN)) return;
  87.         item = spawn();
  88.         item.owner = self;
  89.         item.items = IT_SUPER_NAILGUN;
  90.         self.items = self.items - IT_SUPER_NAILGUN;
  91.         if (self.weapon==IT_SUPER_NAILGUN) self.weapon=W_BestWeapon();
  92.         setmodel (item, "progs/g_nail2.mdl");
  93.         setsize (item, '-16 -16 0', '16 16 56');
  94.         item.touch = BackpackTouch;
  95.         if (self.ammo_nails < 20) item.ammo_nails = self.ammo_nails;
  96.         else    item.ammo_nails = 20;
  97.         self.ammo_nails=self.ammo_nails-item.ammo_nails;
  98.         item.classname="weapon_supernailgun";
  99.     } else if (ax==6) {
  100.         if (!(self.items & IT_GRENADE_LAUNCHER)) return;
  101.         item = spawn();
  102.         item.owner = self;
  103.         item.items = IT_GRENADE_LAUNCHER;
  104.         self.items = self.items - IT_GRENADE_LAUNCHER;
  105.         if (self.weapon==IT_GRENADE_LAUNCHER) self.weapon=W_BestWeapon();
  106.         setmodel (item, "progs/g_rock.mdl");
  107.         setsize (item, '-16 -16 0', '16 16 56');
  108.         item.touch = BackpackTouch;
  109.         if (self.ammo_rockets < 10) item.ammo_rockets = self.ammo_rockets;
  110.         else    item.ammo_rockets = 10;
  111.         self.ammo_rockets=self.ammo_rockets-item.ammo_rockets;
  112.         item.classname="weapon_grenadelauncher";
  113.     } else if (ax==7) {
  114.         if (!(self.items & IT_ROCKET_LAUNCHER)) return;
  115.         item = spawn();
  116.         item.owner = self;
  117.         item.items = IT_ROCKET_LAUNCHER;
  118.         self.items = self.items - IT_ROCKET_LAUNCHER;
  119.         if (self.weapon==IT_ROCKET_LAUNCHER) self.weapon=W_BestWeapon();
  120.         setmodel (item, "progs/g_rock2.mdl");
  121.         setsize (item, '-16 -16 0', '16 16 56');
  122.         item.touch = BackpackTouch;
  123.         if (self.ammo_rockets < 10) item.ammo_rockets = self.ammo_rockets;
  124.         else    item.ammo_rockets = 10;
  125.         self.ammo_rockets=self.ammo_rockets-item.ammo_rockets;
  126.         item.classname="weapon_rocketlauncher";
  127.     } else if (ax==8) {
  128.         if (!(self.items & IT_LIGHTNING)) return;
  129.         item = spawn();
  130.         item.owner = self;
  131.         item.items = IT_LIGHTNING;
  132.         self.items = self.items - IT_LIGHTNING;
  133.         if (self.weapon==IT_LIGHTNING) self.weapon=W_BestWeapon();
  134.         setmodel (item, "progs/g_light.mdl");
  135.         setsize (item, '-16 -16 0', '16 16 56');
  136.         item.touch = BackpackTouch;
  137.         if (self.ammo_cells < 10) item.ammo_cells = self.ammo_cells;
  138.         else    item.ammo_cells = 10;
  139.         self.ammo_cells=self.ammo_cells-item.ammo_cells;
  140.         item.classname="weapon_lightning";
  141.     } else if (ax==16) {
  142.         //shells
  143.         if (self.ammo_shells==0) return;
  144.         item = spawn();
  145.         if (self.ammo_shells < 10) item.ammo_shells = self.ammo_shells;
  146.         else    item.ammo_shells = 10;
  147.         item.owner = self;
  148.         self.ammo_shells=self.ammo_shells-item.ammo_shells;
  149.         setmodel (item, "maps/b_shell1.bsp");
  150.         setsize (item, '-16 -16 0', '16 16 56');
  151.         item.touch = BackpackTouch;
  152.         item.classname = "ammo_shells";
  153.     } else if (ax==17) {
  154.         //nails
  155.         if (self.ammo_nails==0) return;
  156.         item = spawn();
  157.         if (self.ammo_nails < 20) item.ammo_nails = self.ammo_nails;
  158.         else    item.ammo_nails = 20;
  159.         item.owner = self;
  160.         self.ammo_nails=self.ammo_nails-item.ammo_nails;
  161.         setmodel (item, "maps/b_nail1.bsp");
  162.         setsize (item, '-16 -16 0', '16 16 56');
  163.         item.touch = BackpackTouch;
  164.         item.classname = "ammo_nails";
  165.     } else if (ax==18) {
  166.         //rockets
  167.         if (self.ammo_rockets==0) return;
  168.         item = spawn();
  169.         if (self.ammo_rockets < 10) item.ammo_rockets=self.ammo_rockets;
  170.         else    item.ammo_rockets = 10;
  171.         item.owner = self;
  172.         self.ammo_rockets=self.ammo_rockets-item.ammo_rockets;
  173.         setmodel (item, "maps/b_rock1.bsp");
  174.         setsize (item, '-16 -16 0', '16 16 56');
  175.         item.touch = BackpackTouch;
  176.         item.classname = "ammo_rockets";
  177.     } else if (ax==19) {
  178.         //cells
  179.         if (self.ammo_cells==0) return;
  180.         item = spawn();
  181.         if (self.ammo_cells < 10) item.ammo_cells = self.ammo_cells;
  182.         else    item.ammo_cells = 10;
  183.         item.owner = self;
  184.         self.ammo_cells=self.ammo_cells-item.ammo_cells;
  185.         setmodel (item, "maps/b_batt1.bsp");
  186.         setsize (item, '-16 -16 0', '16 16 56');
  187.         item.touch = BackpackTouch;
  188.         item.classname = "ammo_cells";
  189.     } else if (ax==32) {
  190.         if (self.armorvalue<1) return;
  191.         sound (self, CHAN_WEAPON, "weapons/grenade.wav", 1, ATTN_NORM);
  192.         item = spawn();
  193.         item.owner = self;
  194.         item.armortype=self.armortype;
  195.         item.armorvalue=self.armorvalue;
  196.         self.armortype=0;
  197.         self.armorvalue=0;
  198.         setmodel (item, "progs/armor.mdl");
  199.         if (item.armortype==0.3) {
  200.             item.skin=0;
  201.             self.items=self.items-IT_ARMOR1;
  202.             item.items=IT_ARMOR1;
  203.             item.classname="item_armor1";
  204.         } else if (item.armortype==0.6) {
  205.             item.skin=1;
  206.             self.items=self.items-IT_ARMOR2;
  207.             item.items=IT_ARMOR2;
  208.             item.classname="item_armor2";
  209.         } else if (item.armortype==0.8) {
  210.             item.skin=2;
  211.             self.items=self.items-IT_ARMOR3;
  212.             item.items=IT_ARMOR3;
  213.             item.classname="item_armorInv";
  214.         }
  215.         setsize (item, '-16 -16 0', '16 16 56');
  216.         item.touch = armor_touch;
  217.     } else return;
  218.     sound (self, CHAN_WEAPON, "weapons/grenade.wav", 1, ATTN_NORM);
  219.     W_SetCurrentAmmo();    //Draw new weapon on screen (in hand)
  220. // set missile speed    
  221.     makevectors (self.v_angle);
  222.     if (self.v_angle_x)
  223.         item.velocity = v_forward*600 + v_up * 200 +
  224.         crandom()*v_right*10 + crandom()*v_up*10;
  225.     else
  226.     {
  227.         item.velocity = aim(self, 10000);
  228.         item.velocity = item.velocity * 600;
  229.     }
  230.     item.origin = self.origin + (item.velocity * 0.0); 
  231.     item.movetype = MOVETYPE_TOSS;
  232. //    so people cant pick it up immediately
  233.     item.nextthink = time + 0.25;
  234.     item.think = SUB_MakePickup;
  235. };
  236.  
  237. //Detonate all pipebombs
  238. void() DetPipeBombs =
  239. {
  240.         local entity    head;
  241.  
  242.         head = findradius (self.origin, 32000);
  243.         while(head)
  244.         {
  245.                 if((head.classname == "pipebomb") && (head.owner == self))
  246.                         head.nextthink = time;
  247.                 head = head.chain;
  248.         }
  249. };
  250.  
  251. //bouncing pipe bombs
  252. void() PipeBombTouch =
  253. {
  254.     if (other == self.owner)
  255.         return;        // don't explode on owner
  256.     sound (self, CHAN_WEAPON, "weapons/bounce.wav", 1, ATTN_NORM);    // bounce sound
  257.     if (self.velocity == '0 0 0')
  258.         self.avelocity = '0 0 0';
  259. };
  260.  
  261. //fire a pipe bomb
  262. void() W_FirePipeBomb =
  263. {
  264.     local    entity missile, mpuff;
  265.     if(self.ammo_rockets < 1)    // have to have ammo
  266.       return;
  267.     self.currentammo = self.ammo_rockets = self.ammo_rockets - 1;
  268.     missile = spawn ();
  269.     missile.owner = self;
  270.     missile.movetype = MOVETYPE_BOUNCE;
  271.     missile.solid = SOLID_BBOX;
  272.     missile.classname = "pipebomb";
  273.     makevectors (self.v_angle);
  274.     if (self.v_angle_x) missile.velocity = 
  275.     v_forward*600 + v_up * 200 + crandom()*v_right*10 + crandom()*v_up*10;
  276.     else {
  277.         missile.velocity = aim(self, 10000);
  278.         missile.velocity = missile.velocity * 600;
  279.         missile.velocity_z = 200;
  280.     }
  281.     missile.avelocity = '300 300 300';
  282.     missile.angles = vectoangles(missile.velocity);
  283.     missile.touch = PipeBombTouch;
  284.     //pipe bombs explode after 5 mins by default
  285.     missile.nextthink=time+300;
  286.     missile.think = GrenadeExplode;
  287.     setmodel (missile, "progs/grenade.mdl");
  288.     setsize (missile, '0 0 0', '0 0 0');        
  289.     setorigin (missile, self.origin);
  290. };
  291. // end pipebombs
  292.  
  293.  
  294. entity() LightFindTarget =   //this routine based on function by VHOLD
  295. {
  296.     local entity head, selected;
  297.     local float dist;
  298.     dist = 100000;
  299.     selected = world;
  300.     head = findradius(self.origin, 100000);
  301.     while(head)
  302.     {                         //(head.team > 0) &&
  303.         if (((coop) && (head.classname != "player")) || (!coop))
  304.         if (((teamplay) &&  (head.team != self.owner.team))
  305.              || (!teamplay))
  306.         if ((head.health > 1) && (head != self) && (head != self.owner))
  307.          {
  308.             traceline(self.origin,head.origin,TRUE,self);
  309.             if ( (trace_fraction == 1) && (vlen(head.origin - self.origin) < dist) )
  310.             {
  311.                 selected = head;
  312.                 dist = vlen(head.origin - self.origin);
  313.             }
  314.          }    
  315.        head = head.chain;
  316.     }
  317.     return selected;
  318. };
  319.  
  320. //Minion AI
  321. void() MinionThink =
  322. {
  323.     local vector dir, vtemp;
  324.     local string s;
  325.     if (self.owner.flags & FL_OBSERVER) self.ammo_cells=0;
  326.     self.enemy = self.owner;
  327.     if (self.enemy != world) 
  328.     {
  329.         vtemp = self.enemy.origin + '0 0 10';
  330.         dir = normalize(vtemp - self.origin + '0 0 25');
  331.         self.velocity = dir * 200;
  332.         self.angles = vectoangles(self.velocity);
  333.     }
  334.     self.enemy=LightFindTarget();
  335.  
  336.     if (self.enemy)
  337.     {
  338.      if (self.ammo_cells > 1) {
  339.     self.currentammo = self.ammo_cells =self.ammo_cells - 2; 
  340.     CastLightning();
  341.      }
  342.      else
  343.        { self.owner.numminion = 0; remove(self);return;}//self.think=SUB_Remove; self.nextthink=time; return;}
  344.     }
  345.     self.nextthink = time + 0.5;
  346.     self.think=MinionThink;
  347. };
  348.  
  349. //Create the minion
  350. void(vector vec) Minion = 
  351. {   sound (self, CHAN_WEAPON, "items/damage3.wav", 1, ATTN_NORM);
  352.    
  353.     vec = normalize(vec);
  354.     newmis = spawn();
  355.     newmis.owner = self;
  356.   newmis.classname = "electricminion";
  357.   newmis.movetype = MOVETYPE_NOCLIP;
  358.   newmis.solid = SOLID_NOT;
  359.     newmis.effects = EF_DIMLIGHT;
  360.   newmis.ammo_cells = 25;
  361.   newmis.items = IT_LIGHTNING;
  362.   setmodel (newmis, "progs/quaddama.mdl");
  363.   setsize (newmis, VEC_ORIGIN, VEC_ORIGIN);  
  364.   setorigin (newmis, self.origin + '0 0 25');// v_forward*8 + '0 0 16');
  365.   newmis.velocity = aim(self, 1000);
  366.   newmis.velocity = newmis.velocity * 1;
  367.   newmis.angles = vectoangles(newmis.velocity);
  368.     newmis.enemy = world;
  369.   newmis.nextthink = time + 2;
  370.   newmis.think = MinionThink;
  371.  
  372. };
  373.  
  374. //Fire the minion with your gun
  375. void() W_FireMinion =
  376. {   if ((self.ammo_cells < 40) || self.numminion) return;
  377.  
  378.         sound (self, CHAN_AUTO, "weapons/lstart.wav", 1, ATTN_NORM);
  379.     self.effects = self.effects | EF_MUZZLEFLASH;
  380.     self.currentammo = self.ammo_cells = self.ammo_cells - 40;
  381.     self.numminion = 1;
  382.     Minion(self.enemy.origin - self.origin);
  383. };
  384.  
  385. //after a minute, hologram disappears
  386. void() Holothink = { 
  387.   self.owner.numholo = self.owner.numholo - 1;
  388.   sound (self, CHAN_WEAPON, "enforcer/enfire.wav", 1, ATTN_NORM);
  389.   remove(self);
  390.    
  391. };
  392.  
  393. //Create a hologram
  394. void(vector vec) Hologram = {    
  395.     if (self.flags & FL_OBSERVER) return;
  396.     sound (self, CHAN_WEAPON, "enforcer/enfire.wav", 1, ATTN_NORM); 
  397.     vec = normalize(vec);
  398.     
  399.     newmis = spawn();
  400.     newmis.owner = self;
  401.     newmis.classname = "hologram";
  402.     newmis.solid = SOLID_NOT;
  403.     setmodel (newmis, self.model);
  404.     newmis.skin=self.skin;
  405.     newmis.frame=self.frame;
  406.     newmis.colormap=self.colormap;
  407.     newmis.modelindex=self.modelindex;
  408.  
  409.     setsize (newmis, VEC_ORIGIN, VEC_ORIGIN);
  410.         
  411.     setorigin (newmis, self.origin);
  412.     newmis.velocity = aim(self, 1000);
  413.     newmis.velocity = newmis.velocity * 1;
  414.     newmis.angles = vectoangles(newmis.velocity);
  415.     newmis.nextthink = time + 60;
  416.     newmis.think = Holothink;
  417. };
  418.  
  419. //Fire the Hologram
  420. void() W_FireHolo =
  421.     if ((self.ammo_cells < 12) || (self.numholo > 2)) return;
  422.  
  423.     self.effects = self.effects | EF_MUZZLEFLASH;
  424.     self.currentammo = self.ammo_cells = self.ammo_cells - 12;
  425.     self.numholo = self.numholo + 1;
  426.     Hologram(self.enemy.origin - self.origin);
  427. };
  428.  
  429.  
  430. //Become an Observer
  431. void() Observer =
  432. {
  433.     self.items = self.items | (IT_INVULNERABILITY + IT_INVISIBILITY); 
  434.     self.solid = SOLID_NOT;
  435.     centerprint(self,"OBSERVER MODE"); 
  436.      self.flags = self.flags | FL_OBSERVER;   
  437.     self.movetype=MOVETYPE_NOCLIP;
  438.     self.frags=self.frags - 1;
  439.     // Detonate Pipe Bombs so person cant use them later
  440.     DetPipeBombs();
  441.     bprint("\n");
  442.     bprint(self.netname); 
  443.     bprint(" ");
  444.     bprint("is now an observer.");   
  445.     bprint("\n");
  446.     setmodel(self,"");
  447. };              // END OBSERVER FUNCTION
  448.  
  449. //set the grenade timer based on impulses 53 and 54
  450. void ()SetGrenadeTimer = {
  451.     local string s;
  452.     local float iv; 
  453.     if (self.impulse==53){
  454.         if (self.grenadetimer==0.5) iv=0;
  455.         else iv= -0.5;
  456.         if (self.grenadetimer >5) iv = -1;
  457.         if (self.grenadetimer >20) iv= -5;
  458.         if (self.grenadetimer >60) iv= -15;
  459.         if (self.grenadetimer >120) iv= -30;
  460.     } else {
  461.         iv=0.5;
  462.         if (self.grenadetimer>=5) iv=1;
  463.         if (self.grenadetimer>=15) iv=5;
  464.         if (self.grenadetimer >=60) iv=15;
  465.         if (self.grenadetimer >=120) iv=30;
  466.         if (self.grenadetimer==300) iv=0;
  467.     }
  468.     self.grenadetimer=self.grenadetimer+iv;
  469.     if (!self.grenadetimer) self.grenadetimer=0.5;
  470.     sprint(self,"Grenade Timer: ");
  471.     s=ftos(self.grenadetimer);
  472.     sprint(self,s);
  473.     sprint(self,"\n");
  474. };
  475.  
  476. //If player has lightning gun and less than 50 cells, the gain a cell
  477. void ()CheckPowerRegen = {
  478.     if(self.nextregen <= time){
  479.         if((self.items & IT_LIGHTNING) && (self.ammo_cells < 50)){
  480.             self.ammo_cells=self.ammo_cells+1;
  481.             if (self.weapon==IT_LIGHTNING) self.currentammo=self.ammo_cells;
  482.         }
  483.         self.nextregen=time+5;
  484.     }    
  485. };
  486.