Hello people! This is a tutorial which you can run only if you have got enough "stamina".

Open WL_DEF.H and search for "Gamestate Structure" block. Add this as first line:


//==================
//
// gamestate structure
//
//==================

typedef struct
{
    int stamina;
    int difficulty;
    int mapon;

[...]

Open WL_AGENT.C, then reach the block called "Local variables". Add the following line under it:

void CalcStamina (void);

Do the same thing for WL_PLAY.C.

Go to the end of the file (WL_AGENT.C) and copy there this function:

/*
===============
=
=    CalcStamina
=
=    this will calculate and draw the current stamina
=
===============
*/

void CalcStamina (void)
{
    int x=201,y2=189,y1;
    long stamtics;

    stamtics+=tics;

    if (gamestate.stamina > 100)
        gamestate.stamina = 100;

    if (stamtics > 90l)
    {
        if (gamestate.stamina < 100)
            gamestate.stamina++;
        else if (gamestate.stamina && buttonstate[bt_run])
            gamestate.stamina--;
        stamtics=0;
    }

    if (gamestate.stamina)
        y1 = y2-(gamestate.stamina/5);
    
    if (gamestate.stamina>5 && gamestate.stamina<100)
    {
        VWB_Vlin(y1,y2,x,12);
        VWB_Vlin(y2-20,y1,x,0);
    }
    else if (gamestate.stamina==100)
    {
        VWB_Vlin(169,y2,x,12);
    }
    else if (gamestate.stamina <=5)
    {
        VWB_Vlin(169,y2,x,0);
    }
}

Now reach the function "PlayLoop" in WL_PLAY.C and search for the following block:

[...]

 //
// MAKE FUNNY FACE IF BJ DOESN'T MOVE FOR AWHILE
//
#ifdef SPEAR
    funnyticount += tics;
    if (funnyticount > 30l*70)
    {
        funnyticount = 0;
        StatusDrawPic (17,4,BJWAITING1PIC+(US_RndT()&1));
        facecount = 0;
    }
#endif

[...]

Add "CalcStamina();" after the "#endif" seen above, like this:

[...]

 //
// MAKE FUNNY FACE IF BJ DOESN'T MOVE FOR AWHILE
//
#ifdef SPEAR
    funnyticount += tics;
    if (funnyticount > 30l*70)
    {
        funnyticount = 0;
        StatusDrawPic (17,4,BJWAITING1PIC+(US_RndT()&1));
        facecount = 0;
    }
#endif

CalcStamina(); 

[...]

The block "B1)" must be modified ONLY if you applied my "Changing the player speed by the chosen weapon" tutorial. If you didn't apply it, read the block called "B2)"

B1) Goto "PollMouseMove" function. Search this block:

if (buttonstate[bt_run])
{
    cx = mousexmove*10/(13-mouseadjustment);
    cy = mouseymove*20/(13-mouseadjustment);
}
else
{
    cx = mousexmove*5/(13-mouseadjustment);
    cy = mouseymove*10/(13-mouseadjustment);
}

Modify it into this:

if (buttonstate[bt_run])
{
    cx = mousexmove*10/(13-mouseadjustment);
    cy = mouseymove*20/(13-mouseadjustment);

    if (gamestate.stamina>=2)
        gamestate.stamina-=2;
    else if (!gamestate.stamina)
        gamestate.stamina=0;
}
else
{
    cx = mousexmove*5/(13-mouseadjustment);
    cy = mouseymove*10/(13-mouseadjustment);
}

B2) Goto "PollMouseMove" function. Search this block:

controlx += mousexmove*10/(13-mouseadjustment);
controly += mouseymove*20/(13-mouseadjustment);

Rewrite it into this:

if (buttonstate[bt_run])
{
    controlx = mousexmove*10/(13-mouseadjustment);
    controly = mouseymove*20/(13-mouseadjustment);

    if (gamestate.stamina>=2)
        gamestate.stamina-=2;
    else if (!gamestate.stamina)
        gamestate.stamina=0;
}
else
{
    controlx = mousexmove*5/(13-mouseadjustment);
    controly = mouseymove*10/(13-mouseadjustment);
}

Now save and compile. If you want to run, you must have at least 5 stamina unit. The stamina counter is displayed next to the health one. Your stamina will be recharged in a few seconds.