Silly hud code

Discuss programming in the QuakeC language.
Post Reply
r00k
Posts: 1111
Joined: Sat Nov 13, 2004 10:39 pm

Silly hud code

Post by r00k »

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 ;)
Post Reply