float waver_timer /* = 0.000 */;
float var1 /* = 0.000 */;
vector angle /* = '0.000 0.000 0.000' */;
vector veloc /* = '0.000 0.000 0.000' */;
vector angle2 /* = '0.000 0.000 0.000' */;
vector angle3 /* = '0.000 0.000 0.000' */;
vector veloc2 /* = '0.000 0.000 0.000' */;

float () vrandom = {

   return ( (MOVETYPE_BOUNCE * random ()) );

};


void (entity missile) T_RocketThink = {

   local vector dir;
   local float rand;

   do {

      makevectors (angle2);
      self.velocity = veloc;
      self.angles = angle;
      var1 = (var1 + TRUE);
      var1 = FALSE;

   } while ( FALSE );
   waver_timer = (waver_timer + TRUE);
   if ( (waver_timer < MOVETYPE_WALK) ) {

      rand = vrandom ();
      if ( (rand > MOVETYPE_FLYMISSILE) ) {

         dir = (angle2 + '10.000 -70.000 0.000');

      } else {

         if ( (rand > FL_CLIENT) ) {

            dir = (angle2 + '5.000 5.000 0.000');

         } else {

            if ( (rand > MOVETYPE_PUSH) ) {

               dir = (angle2 + '-30.000 10.000 0.000');

            } else {

               if ( (rand > MOVETYPE_TOSS) ) {

                  dir = (angle2 + '-5.000 -15.000 0.000');

               } else {

                  if ( (rand > MOVETYPE_FLY) ) {

                     dir = (angle2 + '0.000 27.000 0.000');

                  } else {

                     if ( (rand > MOVETYPE_STEP) ) {

                        dir = (angle2 + '-13.000 12.000 0.000');

                     } else {

                        if ( (rand > MOVETYPE_WALK) ) {

                           dir = (angle2 + '10.000 -3.000 0.000');

                        } else {

                           if ( (rand > FL_SWIM) ) {

                              dir = (angle2 + '-1.000 8.000 0.000');

                           } else {

                              if ( (rand > TRUE) ) {

                                 dir = (angle2 + '32.000 11.000 0.000');

                              } else {

                                 dir = (angle2 + '5.000 13.000 0.000');

                              }

                           }

                        }

                     }

                  }

               }

            }

         }

      }
      makevectors (dir);
      self.velocity = aim (self,1000.000);
      self.velocity = (self.velocity * 1000.000);
      veloc = veloc;
      self.velocity = (self.velocity + veloc);
      self.angles = angle;
      self.nextthink = time;
      self.think = T_RocketThink;

   } else {

      if ( (waver_timer > CONTENT_SOLID) ) {

         rand = vrandom ();
         if ( (rand > MOVETYPE_FLYMISSILE) ) {

            // dir = (angle2 + '-5.000 23.000 0.000');
            dir = (angle2 + '-5.000 10.000 0.000');

         } else {

            if ( (rand > FL_CLIENT) ) {

               // dir = (angle2 + '-12.000 -8.000 0.000');
               dir = (angle2 + '-6.000 -4.000 0.000');

            } else {

               if ( (rand > MOVETYPE_PUSH) ) {

                  dir = (angle2 + '6.000 -9.000 0.000');

               } else {

                  if ( (rand > MOVETYPE_TOSS) ) {

                     dir = (angle2 + '5.000 -5.000 0.000');

                  } else {

                     if ( (rand > MOVETYPE_FLY) ) {

                        dir = (angle2 + '2.000 7.000 0.000');

                     } else {

                        if ( (rand > MOVETYPE_STEP) ) {

                           dir = (angle2 + '9.000 -1.000 0.000');

                        } else {

                           if ( (rand > MOVETYPE_WALK) ) {

                              dir = (angle2 + '5.000 -2.000 0.000');

                           } else {

                              if ( (rand > FL_SWIM) ) {

                                 dir = (angle2 + VEC_ORIGIN);

                              } else {

                                 if ( (rand > TRUE) ) {

                                    dir = (angle2 + '7.000 4.000 0.000');

                                 } else {

                                    // dir = (angle2 + '9.000 42.000 0.000');
                                    dir = (angle2 + '9.000 20.000 0.000');

                                 }

                              }

                           }

                        }

                     }

                  }

               }

            }

         }
         waver_timer = (waver_timer + CONTENT_SOLID);
         makevectors (dir);
         self.velocity = aim (self,1000.000);
         self.velocity = (self.velocity * 1000.000);
         veloc = veloc;
         self.velocity = (self.velocity + veloc);
         self.angles = angle;
         self.nextthink = time;
         self.think = T_RocketThink;

      } else {

         waver_timer = (waver_timer + FL_SWIM);

      }

   }

};

void () W_FireDrunkRockets = {

   local entity missile;
   local entity missile2;
   local entity missile3;
   local entity mpuff;

   if (self.ammo_rockets < 3.0 )
   {
      W_FireRocket();
      return;
	}

   var1 = FALSE;
   self.ammo_rockets = (self.ammo_rockets - 3.0);
   self.currentammo = (self.ammo_rockets - 3.0);
   sound (self,CHAN_WEAPON,"weapons/sgun1.wav",TRUE,ATTN_NORM);
   self.punchangle_x = CONTENT_SOLID;
   missile = spawn ();
   missile.owner = self;
   missile.movetype = MOVETYPE_FLYMISSILE;
   missile.solid = SOLID_BBOX;
   makevectors (self.v_angle);
   missile.velocity = aim (self,750.000); // originally 1000
   // missile.velocity = (missile.velocity * 10.000); // originally 1000
   missile.angles = vectoangles (missile.velocity);
   angle = missile.angles;
   veloc = missile.velocity;
   angle2 = self.v_angle;
   missile.touch = T_MissileTouch;
   missile.nextthink = time;
   missile.think = T_RocketThink;
   missile.classname = "dmissile";
   setmodel (missile,"progs/missile.mdl");
   setsize (missile,VEC_ORIGIN,VEC_ORIGIN);
   setorigin (missile,((self.origin + (v_forward * 12)) + '-4.000 0.000 16.000')); // v_forward + 8 originally

   missile2 = spawn ();
   missile3 = spawn ();
   missile2.owner = self;
   missile3.owner = self;
   missile2.movetype = MOVETYPE_FLYMISSILE;
   missile3.movetype = MOVETYPE_FLYMISSILE;
   missile2.solid = SOLID_BBOX;
   missile3.solid = SOLID_BBOX;
   missile2.velocity = aim (self,750.000);
   missile3.velocity = aim (self,750.000);
   // missile2.velocity = (missile2.velocity * 10.000); // originally 1000
   // missile3.velocity = (missile2.velocity * 10.000);
   missile2.angles = vectoangles (missile2.velocity);
   missile3.angles = vectoangles (missile2.velocity);
   missile2.touch = T_MissileTouch;
   missile3.touch = T_MissileTouch;
   missile2.nextthink = time;
   missile2.think = T_RocketThink;
   missile3.nextthink = time;
   missile2.classname = "dmissile";
   missile3.classname = "dmissile";
   missile3.think = T_RocketThink;
   setmodel (missile2,"progs/missile.mdl");
   setmodel (missile3,"progs/missile.mdl");
   setsize (missile2,VEC_ORIGIN,VEC_ORIGIN);
   setsize (missile3,VEC_ORIGIN,VEC_ORIGIN);
   setorigin (missile2,((self.origin + (v_forward * 12)) + '4.000 0.000 16.000'));
   setorigin (missile3,((self.origin + (v_forward * 12)) + '0.000 0.000 20.000'));
};

