Health Charge Points

This is yet another varient on eLiTe's item placement tutorial. It allows you to place Half-Life style health recharge points around your maps (and other peoples maps) which you can activate with a key press to give you a quick 5 health boost. Currently the tut doesn't work with keeping the button held down, you have to keep hitting it, which is why I have it giving 5 health. You can get up to 104% health using this pack. I would fix that, but I leave it as a very minor challange for you.


First of all grab the zip file from the bottom of the page, it contains the c and h files created in this tut. the code should be fairly easy to understand, if you want an explanation of anything, mail me. Add the c file to your project/makefile. Add the line below to g_local.h, just below #include "game.h"

#include "healthcharge.h"

in the function addchargepoint within healthcharge.c, there is the line

        chargepoint->s.modelindex=gi.modelindex ("models/chargepoint.md2");

change the "models/chargepoint.md2" to whatever model you are using. chargepoint.md2 was one I threw togeher and it doesn't work right. You will also probably want to change the mins and maxes to fit your model properly.


there are a number of things in this tut that are also in the camera tut and the item placement tut, first of all the cvar edititems if you have done one of the other tuts , ignore the bit below.

add the line below to g_local.h underneath extern cvar_t *sv_maplist;

extern  cvar_t  *edititems;

Next add the line below to g_save.c below sv_gravity = gi.cvar ("sv_gravity", "800", 0);

        edititems = gi.cvar ("edititems","0",CVAR_LATCH|CVAR_SERVERINFO);

Finally for this cvar find the line which reads cvar_t *sv_maplist; in g_main.c

cvar_t  *edititems;

Thats the cvar added. it defaults to 0 (not adding items/cameras/health recharge points), change it to 1 and restart the server to be able to.


This applies if you have done one of the tutorials mentioned above. remove the function GetLineFromFile from one of the tutorial files, and add the prototype for it to g_local.h


This should now compile fine. it's a bit useless as you can't do anything yet, but it should compile.

Now we add the command code. paste the code below into g_cmds.c just above the final else statment

        else if (Q_stricmp(cmd,"usepoint")==0)
               Cmd_Use_Charge_Point(ent);
        else if (edititems->value){
               if (Q_stricmp(cmd, "addchargepoint") == 0)
                       Cmd_Add_Charge_f(ent);
               else if (Q_stricmp(cmd, "savechargepoints") == 0)
                       Cmd_SaveCharge_f(ent);
        }

You should be able to work out how to use the tut from the code above.


All we need to do now is allow the loading of files and the initilization of the linked list. open g_spawn.c. add the code below to the end of SpawnEntities

        loadchargepointdata();

and then go to the end of the file, just before the final } insert the code below

        newchargepoint_head=NULL;

Thats it. you should now be able to use the health points whenever you want. Mail me if you have problems, I'll see what I can do to fix them.


Resources

 


Skunkworks Tutorial