Forum

Silly hud code

Discuss programming in the QuakeC language.

Moderator: InsideQC Admins

Silly hud code

Postby r00k » Mon Dec 15, 2008 10:10 pm

Okay I was digging thru some old code and found something I wrote so long ago i barely remember it....

Code: Select all


void() flash_rune_on  =
{
  if ((self.owner.player_flag & ITEM_RUNE_MASK) && (self.lip < 11))
  {
    self.lip          = (self.lip + 1.00);//lip is a counter for the flash
    self.think        = flash_rune_off;
    self.nextthink    = time + 0.1;
    self.owner.items2 = (self.owner.items2 | self.cnt); //--toggle rune
  }
  else
  {
    remove(self);
  }
}

void() flash_rune_off =
{
  if ((self.owner.player_flag & ITEM_RUNE_MASK) && (self.lip < 10))
  {
    self.lip          = (self.lip + 1.00);  //--lip is a counter for the flash
    self.think        = flash_rune_on;
    self.nextthink    = time + 0.1;   
    self.owner.items2 = self.owner.items2 - (self.owner.items2 & self.cnt);//--toggle rune off
  }
  else
  {
    remove(self);
  }
}

void(float sig) flash_rune_stat =
{
    local entity flash;
   
    flash           = spawn();
    flash.think     = flash_rune_on;
    flash.nextthink = time + 0.1;
    flash.cnt       = sig;//remember the rune we have
    flash.owner     = self;   
};


then for example call flash like this

void () RegenerationSound =
{
   if ((self.player_flag & ITEM_RUNE4_FLAG))
   {
      if ((self.regeneration_sound < time))
      {
         self.regeneration_sound = (time + 1);
         sound (self, CHAN_AUTO, "items/r_item1.wav", 1, ATTN_NORM);
         flash_rune_stat(IT2_SIGIL4);
      }
   }
};


Basically when u get the rune items the corresponding icon on the hud will flash intermittently to draw attention. can be used i suppose as a global filter also... again its old code havent even retried it ;)
r00k
 
Posts: 1110
Joined: Sat Nov 13, 2004 10:39 pm

Return to QuakeC Programming

Who is online

Users browsing this forum: No registered users and 1 guest