QuakeZone
MOD Coding Tutorials
Quake II Coding Tutorials!

Introduction
Code
Notes
Exercises
Quake II Coding Tutorials

11 Low-Health Chunder

Introduction Introduction

This tutorial is based on the chunder tutorial on the QDevels site (see Links page). For added realism, once a player's health drops below 50 he starts to chuck his guts up, the less health the more chunder. And while his health remains below 50 the screen reddens as a little reminder.

This tutorial will only work if the Throwup tutorial on the QDevels site has already been implemented.

Code Code


throwup.c

Add the following lines to the end of procedure ThrowUpNow:

	// cough up some gibs.
	if (self->health < 25)
	{
		for (i = 0; i<3; i++)
		{
			ThrowVomit (self, mouth_pos, forward, right, self->velocity);
		}
	}

	// every now and again, cough up MEGA vomit
	if (self->health < 10)
	{
		for (i = 0; i<10; i++)
		{
			ThrowVomit (self, mouth_pos, forward, right, self->velocity);
		}
	}
		

p_client.c

Add the following lines to the start of procedure ClientThink:

	// PJT - throw up
   	if ((level.time > ent->client->next_chunder) && (ent->health<50) && (!ent->deadflag))
		{
		ThrowUpNow(ent);
		ent->client->next_chunder = level.time + 5.0;
		}
    	// PJT	
		

g_local.h

Add the folloiwng line to the end of structure gclient_s:
	float		next_chunder;		// PJT - next chunder when ill
		

p_view.c

To procedure SV_CalcBlend, add the following lines as indicated:

	// PJT - screen red when damaged
	if ((ent->health < 50) && (ent->health > 0))
		SV_AddBlend (1.0, 0.0, 0.0, (50.0 - ent->health)/100.0, ent->client->ps.blend);
	// PJT - end of insert

	// add for powerups
	if (ent->client->quad_framenum > level.framenum)
	{
		
Notes Notes to code


throwup.c
  • ThrowUpNow has been amended as follows:
    • when health is less than 25, 3 bits are coughed up
    • when health is less than 10, another 10 bits are coughed up

p_client.c
  • ClientThink has been amended so that, if a player's health is less than 50, check the chunder timer stored in the client structure
  • if it has expired, call the chuck routine and reset the timer

g_local.h
  • a chunder timer has been added to the client structure

p_view.c
  • SV_CalcBlend calculates, every client frame, the colour of the screen:
    • if the player's health is below 50, the screen is reddened in proportion to the amount of health
Exercises Exercises

  • use server (cvar) variables to specify the various health limits


Page last updated 26th November 2000