How to add a condition in bg_misc.c


(Madras) #1

Hi! I must to add a condition in bg_misc.c, but I can’t.
I want to changing the value of extraHP depending on CS_M_EXTRAHP (1-True, 0-False).

float extraHP = ( atoi( CG_ConfigString( CS_M_EXTRAHP )) ) ? 1.12 : 1.0;

The problem is that from bg_misc.c level don’t see CG_ConfigString() function. I don’t know how to skip this issue. Thanks! :confused:


(Shanks) #2

What are you trying to do with it? It would seem far more logical to put your changes in the server code only.


(Madras) #3

I want to determine health pickup condition. In bg_misc.h there’s a function ‘can item be grabbed’:

qboolean	BG_CanItemBeGrabbed( const entityState_t *ent, const playerState_t *ps, int *skill, int teamNum ) {
	gitem_t	*item;

	if ( ent->modelindex < 1 || ent->modelindex >= bg_numItems ) {
		Com_Error( ERR_DROP, "BG_CanItemBeGrabbed: index out of range" );
	}

	item = &bg_itemlist[ent->modelindex];

	switch( item->giType ) {

[...]

	case IT_HEALTH:
		if( ps->teamNum == PC_MEDIC ) {
			float extraHP = ( atoi( CG_ConfigString( CS_M_EXTRAHP )) ) ? 1.12 : 1.0;
			if( ps->stats[STAT_HEALTH] >= (int)(ps->stats[STAT_MAX_HEALTH] * extraHP) ) {
			return qfalse;
			}
		}
		else {
			if( ps->stats[STAT_HEALTH] >= ps->stats[STAT_MAX_HEALTH] ) {
			return qfalse;
			}
		}
		return qtrue;

I want to auto changing multiplier of STAT_MAX_HEALTH. This function is two sides - client & server, I think. Is there another way to do this, because from bg_misc.c level compiler doesn’t recognize a lots of functions including CG_ConfigString() which gets configstring value. Thx for reply.


(Shanks) #4

You’d be better off making your changes in Touch_Item in g_items.c.
Health is communicated to the client so there’s no need to make changes to the client. That is unless you make changes to the max health then you’d need to make changes to CG_DrawPlayerHealthBar in cg_draw.c.


(Madras) #5

I made changes in cg_draw.c previously, but I couldnt do that right whith health pickup, so I wrote on the forum. Ok, I’ll try and will tell you if work out or not, soon. Thanks Bacon!


(Madras) #6

Ok, I wrote in Touch_Item() function these lines, like you said:

if( !( g_medics.integer & MEDIC_EXTRAHP ) && other->client->ps.stats[STAT_HEALTH] >= other->client->ps.stats[STAT_MAX_HEALTH] )
	return;

and all works excellent! Thanks Bacon for helping!