Void function W_FireRocket();   // replaces W_FireRocket found in WEAPONS.QC
var
 missile : Object;
 mpuff : Object;
{
  self.currentammo = self.ammo_rockets = self.ammo_rockets - 1;
  sound(self, CHAN_WEAPON, "weapons/sgun1.wav", 1, 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, 1000);
  missile.velocity = missile.velocity * 1000;
  missile.angles = vectoangles(missile.velocity);
  missile.touch = T_MissileTouch;
  missile.nextthink = time + 0.1;
  missile.think = CommandeGouvernail;
  setmodel(missile, "progs/missile.mdl");
  setsize(missile, VEC_ORIGIN, VEC_ORIGIN);
  setorigin(missile, self.origin + v_forward * FL_CLIENT + [0 0 16]);
}

Void function CommandeGouvernail();
var
 o        : Object;
 PlusPres : Object;
 Dist     : Real;
 DistMin  : Real;
{
  self.nextthink = time + 0.1;
  o = findradius(self.origin, DistMin = 1000);
  while (o) {
    if (o != self.owner) {
      if (o.flags & FL_MONSTER) {
        if ((Dist = vlen(o.origin-self.origin)) < DistMin) {
          PlusPres = o;
          DistMin = Dist;
          }
        }
      }
    o = o.chain;
  }
  if (DistMin < 1000) {
    self.velocity = self.velocity * 0.8 + (PlusPres.origin-self.origin) * 0.2;
    self.angles = vectoangles(self.velocity);
  }
}
