home *** CD-ROM | disk | FTP | other *** search
/ Quake 'em / QUAKEEM.BIN / quake / programs / fall / fall.qc next >
Encoding:
Text File  |  1996-08-22  |  3.3 KB  |  122 lines

  1. /*
  2. ===========
  3. CheckFall
  4.  
  5. called when a player jumps (higher than normal - heh)
  6. ============
  7. */
  8. void() CheckFall =
  9. {
  10.  local float hgt;
  11.  local float BASE_DMG;
  12.  local string s;
  13.  
  14. // this is how much damage is taken for each 10 feet fallen
  15.  
  16.  BASE_DMG = 5;
  17.  
  18. // the following few lines inform the player how far s/he fell - I found 
  19. // that 11 units approximately equals 1 foot 
  20.  
  21.  hgt =  (self.jump_flag + 300) / -11;   // jump_flag is negative, thus -11
  22.  sprint(self, "You fell ");
  23.  s= ftos(hgt);
  24.  sprint(self, s);
  25.  sprint(self, " FT\n");
  26.  
  27. /* the player can be hurt by falling into water, whether or not there is a
  28.    hard surface beneath - try doing a belly flop from 40 feet up and you
  29.    won't exactly be breathing easy for the next few seconds - heh heh */
  30.  
  31.  if (self.watertype == CONTENT_WATER)
  32.  {
  33.   sound (self, CHAN_BODY, "player/h2ojump.wav", 1, ATTN_NORM);
  34.   if (hgt < 40)
  35.   {
  36.    T_Damage (self, world, world, BASE_DMG);
  37.    sound (self, CHAN_VOICE, "player/land2.wav", 1, ATTN_NORM);
  38.    self.deathtype = "falling";
  39.   }
  40.   else if (hgt < 50)
  41.   {
  42.    T_Damage (self, world, world, 2*BASE_DMG);
  43.    sound (self, CHAN_VOICE, "player/land2.wav", 1, ATTN_NORM);
  44.    self.deathtype = "falling";
  45.   }
  46.   else if (hgt < 60)
  47.   {
  48.    T_Damage (self, world, world, 4*BASE_DMG);
  49.    sound (self, CHAN_VOICE, "player/land2.wav", 1, ATTN_NORM);
  50.    self.deathtype = "falling";
  51.   }
  52.   else if (hgt < 70)
  53.   {
  54.    T_Damage (self, world, world, 8*BASE_DMG);
  55.    sound (self, CHAN_VOICE, "player/land2.wav", 1, ATTN_NORM);
  56.    self.deathtype = "falling";
  57.   }
  58.   else
  59.   {
  60.    T_Damage (self, world, world, 16*BASE_DMG);
  61.    sound (self, CHAN_VOICE, "player/land2.wav", 1, ATTN_NORM);
  62.    self.deathtype = "falling";
  63.   }
  64.  }
  65.  
  66. /* the following code damages the player varying degrees depending on the
  67.    height of their fall in feet (hgt) - I tried to be realistic, but I'm no
  68.    physics major - I figured damage would be at least geometric instead of
  69.    linear since your velocity when falling increases exponentially (?)...or
  70.    something - heh heh */
  71.  
  72.  else
  73.  {
  74.   if (hgt < 10)
  75.   {
  76.    sound (self, CHAN_VOICE, "player/land.wav", 1, ATTN_NORM);
  77.   }
  78.   else if (hgt < 20)
  79.   {
  80.    T_Damage (self, world, world, BASE_DMG);
  81.    sound (self, CHAN_VOICE, "player/land2.wav", 1, ATTN_NORM);
  82.    self.deathtype = "falling";
  83.   }
  84.   else if (hgt < 30)
  85.   {
  86.    T_Damage (self, world, world, 2*BASE_DMG);
  87.    sound (self, CHAN_VOICE, "player/land2.wav", 1, ATTN_NORM);
  88.    self.deathtype = "falling";
  89.   }
  90.   else if (hgt < 40)
  91.   {
  92.    T_Damage (self, world, world, 4*BASE_DMG);
  93.    sound (self, CHAN_VOICE, "player/land2.wav", 1, ATTN_NORM);
  94.    self.deathtype = "falling";
  95.   }
  96.   else if (hgt < 50)
  97.   {
  98.    T_Damage (self, world, world, 8*BASE_DMG);
  99.    sound (self, CHAN_VOICE, "player/land2.wav", 1, ATTN_NORM);
  100.    self.deathtype = "falling";
  101.   }
  102.   else if (hgt < 60)
  103.   {
  104.    T_Damage (self, world, world, 16*BASE_DMG);
  105.    sound (self, CHAN_VOICE, "player/land2.wav", 1, ATTN_NORM);
  106.    self.deathtype = "falling";
  107.   }
  108.   else if (hgt < 70)
  109.   {
  110.    T_Damage (self, world, world, 32*BASE_DMG);
  111.    sound (self, CHAN_VOICE, "player/land2.wav", 1, ATTN_NORM);
  112.    self.deathtype = "falling";
  113.   }
  114.   else 
  115.   {
  116.    T_Damage (self, world, world, 64*BASE_DMG);
  117.    sound (self, CHAN_VOICE, "player/land2.wav", 1, ATTN_NORM);
  118.    self.deathtype = "falling";
  119.   }
  120.  }
  121. };
  122.