Advertisement
techforce

Quaked modified air bubbles rev 1

Aug 29th, 2011
476
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. void () make_bubbles =
  2. {
  3.    local entity bubble;
  4.  
  5.    bubble = spawn ();
  6.    setmodel (bubble, "progs/s_bubble.spr");
  7.    setorigin (bubble, self.origin);
  8.    bubble.movetype = MOVETYPE_FLY;
  9.    bubble.solid = SOLID_TRIGGER;
  10.    bubble.velocity = '0 0 7';
  11.    bubble.nextthink = (time + 0.5);
  12.    bubble.think = bubble_bob;
  13.    bubble.touch = bubble_remove;
  14.    bubble.classname = "bubble";
  15.    bubble.frame = FALSE;
  16.    bubble.cnt = FALSE;
  17.    setsize (bubble, '0 0 0', '1 1 1');
  18.    self.nextthink = ((time + random ()) + 0.5);
  19.    self.think = make_bubbles;
  20.     sound (bubble, CHAN_AUTO, "uwater.wav", 0.5, 2);   //  Underwater sound
  21. };
  22.  
  23. void () bubble_split =
  24. {
  25.    local entity bubble;
  26.  
  27.    bubble = spawn ();
  28.    setmodel (bubble, "progs/s_bubble.spr");
  29.    setorigin (bubble, self.origin);
  30.    bubble.movetype = MOVETYPE_FLY;
  31.    bubble.solid = SOLID_TRIGGER;
  32.    bubble.velocity = self.velocity;
  33.    bubble.nextthink = (time + 0.5);
  34.    bubble.think = bubble_bob;
  35.    bubble.touch = bubble_remove;
  36.    bubble.classname = "bubble";
  37.    bubble.frame = TRUE;
  38.    bubble.cnt = MOVETYPE_BOUNCE;
  39.    setsize (bubble, '0 0 0', '1 1 1');
  40.    sound (bubble, CHAN_AUTO, "uwater.wav", 0.5, 2);   //  Underwater sound
  41.    self.frame = TRUE;
  42.    self.cnt = MOVETYPE_BOUNCE;
  43.    if ((self.waterlevel != 3))
  44.    remove (self);
  45.  
  46. };
  47.  
  48. void () bubble_remove =
  49. {
  50.    
  51.    self.reserve = self.reserve + 1; // Counting number of touches
  52.    if (!self.solid)
  53.    self.flags = self.flags - (self.flags & FL_WATERJUMP);
  54.    if ((other.classname == self.classname))
  55.    {
  56.    self.origin_y = other.origin_x ;
  57.    self.origin_x = other.origin_y ;
  58.    }
  59.    if (other.solid && self.classname != other.classname)
  60.   {
  61.   if (self.reserve > 10)
  62.   return;
  63.    self.velocity_z = self.velocity_z * 0.9;
  64.    self.velocity_x = self.velocity_x  * nrandom ();
  65.    self.velocity_y = self.velocity_y *  nrandom ();
  66.    }
  67.    
  68.    
  69.    
  70. };
  71.  
  72. void () bubble_bob =
  73. {
  74.    local float rnd1;
  75.    local float rnd2;
  76.    local float rnd3;
  77.    local vector vtmp1;
  78.    local vector modi;
  79.  
  80.    self.cnt = (self.cnt + TRUE);
  81.    if ((self.cnt == MOVETYPE_STEP))
  82.    {
  83.       bubble_split ();
  84.    }
  85.    makevectors (self.angles);
  86. traceline (self.origin, self.origin + '0 0 4', TRUE, self);
  87. if (trace_inopen)
  88. {
  89. self.movetype = MOVETYPE_NOCLIP;
  90. self.solid = 0;
  91. self.touch = SUB_Null;
  92. setsize (self, '-8 -8 -8', '8 8 8');
  93. }  
  94.    
  95.    if (!self.solid)
  96.    self.flags = self.flags - (self.flags & FL_WATERJUMP);
  97.    if (!(self.waterlevel))
  98.    {
  99.    sound (self, CHAN_RUNE, "misc/water1.wav", 1, ATTN_IDLE);
  100.       SUB_Remove();
  101.    }
  102.    rnd1 = (self.velocity_x + (-10 + (random () * 20)));
  103.    rnd2 = (self.velocity_y + (-10 + (random () * 20)));
  104.    rnd3 = ((self.velocity_z + MOVETYPE_BOUNCE) + (random () * MOVETYPE_BOUNCE));
  105.    if ((rnd1 > MOVETYPE_BOUNCE))
  106.    {
  107.       rnd1 = MOVETYPE_FLY;
  108.    }
  109.    if ((rnd1 < -10))
  110.   {
  111.      rnd1 = CONTENT_LAVA;
  112.   }
  113.   if ((rnd2 > MOVETYPE_BOUNCE))
  114.    {
  115.       rnd2 = MOVETYPE_FLY;
  116.    }
  117.    if ((rnd2 < -10))
  118.   {
  119.      rnd2 = CONTENT_LAVA;
  120.   }
  121.   if ((rnd3 < MOVETYPE_BOUNCE))
  122.   {
  123.      rnd3 = 5;
  124.   }
  125.   if ((rnd3 > 30))
  126.    {
  127.       rnd3 = 25;
  128.    }
  129.    self.velocity_x = rnd1;
  130.    self.velocity_y = rnd2;
  131.    self.velocity_z = rnd3;
  132.    self.nextthink = (time + 0.5);
  133.    self.think = bubble_bob;
  134. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement