Jump to content

Automatic Healing


Go to solution Solved by JaceSolarisVIII,

Recommended Posts

Posted

1. Bind force heal to a key

2. Repeatedly hit said key

 

I'm trying not to laugh at this, does that make me a bad person?

MB2 Beta Tester / MB2 FA Assistant Dev

Posted

I've only ever seen auto health regen in RPmod and MB2 (MB2 it's hero specific and you need self heal 1-3(?) for it to work), in all other mods the point of it seemed moot when you have force heal/force drain since when it comes to ffa communities that allow Force powers and such, pretty much everyone stacks heal/drain up to full for the sake of health. MB2's force health however is painfully slow + it's Full Authentic specific characters and you can't do anything with it active.

 

Maybe introduce an optional addition where it can be toggled off and on through the console like "exec autoheal" or simply add "cg_autoheal <0/1>".

 

Personally I'm 50/50 on the subject of "Active background healing" over "Manual healing", it depends on the game and such. A soldier that can quickly heal back to full health like in COD made no sense vs a Jedi that uses the Force to recover. That said it put ideas in my head for a healing system which probably wouldn't work hehe.

 

@ that sounds like what happens in Halo with the armors self restoration technology.

Wystan likes this

MB2 Beta Tester / MB2 FA Assistant Dev

Posted

Moved to Coding & Scripts forum.
Xycaleth likes this
  • Solution
Posted

I want the protagonist to heal himself over time like in Call of Duty series.

 

 

If your doing it in code,try this.

 

This is multiplayer version


void ClientTimerActions( gentity_t *ent, int msec )
{
	gclient_t	*client;
	int clientNum = ent-g_entities;

	client = ent->client;
	client->timeResidual += msec;

	while ( client->timeResidual >= 1000 ) 
	{
		client->timeResidual -= 1000;
		
		//you heal 1 hp every 1 second.
		if ( ent->health < client->ps.stats[STAT_MAX_HEALTH] )
		{
			ent->health++;
		}
		if ( client->ps.stats[STAT_ARMOR] < client->ps.stats[STAT_MAX_HEALTH] ) 
		{
			client->ps.stats[STAT_ARMOR]++;
		}
		// count down health when over max
		if ( ent->health > client->ps.stats[STAT_MAX_HEALTH] )
		{
			ent->health--;
		}
		// count down armor when over max
		if ( client->ps.stats[STAT_ARMOR] > client->ps.stats[STAT_MAX_HEALTH] )
		{
			client->ps.stats[STAT_ARMOR]--;
		}
	}
}

This is singleplayer version

void ClientTimerActions( gentity_t *ent, int msec )
{
	gclient_t *client;

	client = ent->client;
	client->timeResidual += msec;

	while ( client->timeResidual >= 1000 ) 
	{
		client->timeResidual -= 1000;

		if ( ent->s.weapon != WP_NONE )
		{
			ent->client->sess.missionStats.weaponUsed[ent->s.weapon]++;
		}
		
		//you heal 1 hp every 1 second. 
		if ( ent->health < client->ps.stats[STAT_MAX_HEALTH] )
		{
			ent->health++;
		}
		if ( client->ps.stats[STAT_ARMOR] < client->ps.stats[STAT_MAX_HEALTH] ) 
		{
			client->ps.stats[STAT_ARMOR]++;
		}
		// count down health when over max
		if ( ent->health > client->ps.stats[STAT_MAX_HEALTH] )
		{
			ent->health--;
		}
		// count down armor when over max
		if ( client->ps.stats[STAT_ARMOR] > client->ps.stats[STAT_MAX_HEALTH] )
		{
			client->ps.stats[STAT_ARMOR]--;
		}

		if ( (ent->flags&FL_OVERCHARGED_HEALTH) )
		{//need to gradually reduce health back to max
			if ( ent->health > ent->client->ps.stats[STAT_MAX_HEALTH] )
			{//decrement it
				ent->health--;
				ent->client->ps.stats[STAT_HEALTH] = ent->health;
			}
			else
			{//done
				ent->flags &= ~FL_OVERCHARGED_HEALTH;
			}
		}
	}
}

Should give the effect you want for your mod

Vade Parvis likes this
Posted

If your doing it in code,try this.

 

This is multiplayer version


void ClientTimerActions( gentity_t *ent, int msec )
{
	gclient_t	*client;
	int clientNum = ent-g_entities;

	client = ent->client;
	client->timeResidual += msec;

	while ( client->timeResidual >= 1000 ) 
	{
		client->timeResidual -= 1000;
		
		//you heal 1 hp every 1 second.
		if ( ent->health < client->ps.stats[STAT_MAX_HEALTH] )
		{
			ent->health++;
		}
		if ( client->ps.stats[STAT_ARMOR] < client->ps.stats[STAT_MAX_HEALTH] ) 
		{
			client->ps.stats[STAT_ARMOR]++;
		}
		// count down health when over max
		if ( ent->health > client->ps.stats[STAT_MAX_HEALTH] )
		{
			ent->health--;
		}
		// count down armor when over max
		if ( client->ps.stats[STAT_ARMOR] > client->ps.stats[STAT_MAX_HEALTH] )
		{
			client->ps.stats[STAT_ARMOR]--;
		}
	}
}

This is singleplayer version

void ClientTimerActions( gentity_t *ent, int msec )
{
	gclient_t *client;

	client = ent->client;
	client->timeResidual += msec;

	while ( client->timeResidual >= 1000 ) 
	{
		client->timeResidual -= 1000;

		if ( ent->s.weapon != WP_NONE )
		{
			ent->client->sess.missionStats.weaponUsed[ent->s.weapon]++;
		}
		
		//you heal 1 hp every 1 second. 
		if ( ent->health < client->ps.stats[STAT_MAX_HEALTH] )
		{
			ent->health++;
		}
		if ( client->ps.stats[STAT_ARMOR] < client->ps.stats[STAT_MAX_HEALTH] ) 
		{
			client->ps.stats[STAT_ARMOR]++;
		}
		// count down health when over max
		if ( ent->health > client->ps.stats[STAT_MAX_HEALTH] )
		{
			ent->health--;
		}
		// count down armor when over max
		if ( client->ps.stats[STAT_ARMOR] > client->ps.stats[STAT_MAX_HEALTH] )
		{
			client->ps.stats[STAT_ARMOR]--;
		}

		if ( (ent->flags&FL_OVERCHARGED_HEALTH) )
		{//need to gradually reduce health back to max
			if ( ent->health > ent->client->ps.stats[STAT_MAX_HEALTH] )
			{//decrement it
				ent->health--;
				ent->client->ps.stats[STAT_HEALTH] = ent->health;
			}
			else
			{//done
				ent->flags &= ~FL_OVERCHARGED_HEALTH;
			}
		}
	}
}

Should give the effect you want for your mod

 

Wow! thanks! it's okay also for my mod! D: nosgoth vampires get autohealing their wounds. D:

JaceSolarisVIII likes this
Posted

@@JaceSolarisVIII

 

i am thinking to making some about this but in reverse way: i wanna to make a playable class that lose 1 point of health every 10 seconds.

in that way they will die if they not heal until 14 minutes of game. this class can be used on my mod for the class of Raziel and Soul Reapers.

how can i set the lose of health for 10 seconds, instead of 1 HP for second? D:

 

Wait a moment... i think i will add a custom while for that. D: nevermind man ^_^

Posted

@@JaceSolarisVIII

 

i am thinking to making some about this but in reverse way: i wanna to make a playable class that lose 1 point of health every 10 seconds.

in that way they will die if they not heal until 14 minutes of game. this class can be used on my mod for the class of Raziel and Soul Reapers.

how can i set the lose of health for 10 seconds, instead of 1 HP for second? D:

 

Wait a moment... i think i will add a custom while for that. D: nevermind man ^_^

 

 You will need to look in void ClientTimerActions( gentity_t *ent, int msec ) and  client->timeResidual >= 1000  is 1 second,you can alter this timer or make a separate section that is just for your class.

 

while ( client->timeResidual >= 1000 )

    {

        client->timeResidual -= 1000;

 

      if (NPC, "Your class definition")

       (

         client->timeResidual -= 140000; //14 sec just for this class

 

 

             if ( ent->health > client->ps.stats[STAT_NORMAL_HEATH] )    // "you may need to make a new STAT_  for this something like STAT_NORMAL_HEATH =10

             {

                ent->health--;

              }

Have it reduce health .

 

it should have a stop check just to be sure

 

           

 

             if ( ent->health > client->ps.stats[STAT_LOW_HEATH] )    // "you may need to make a new STAT_  for this something like STAT_LOW_HEATH =1

             {

                ent->health--;

                ent->client->ps.stats[STAT_LOW_HEATH] = ent->health;

              }.

 

Either way,let me know how you figure this out. :winkthumb:

Posted

 You will need to look in void ClientTimerActions( gentity_t *ent, int msec ) and  client->timeResidual >= 1000  is 1 second,you can alter this timer or make a separate section that is just for your class.

 

while ( client->timeResidual >= 1000 )

    {

        client->timeResidual -= 1000;

 

      if (NPC, "Your class definition")

       (

         client->timeResidual -= 140000; //14 sec just for this class

 

 

             if ( ent->health > client->ps.stats[STAT_NORMAL_HEATH] )    // "you may need to make a new STAT_  for this something like STAT_NORMAL_HEATH =10

             {

                ent->health--;

              }

Have it reduce health .

 

it should have a stop check just to be sure

 

           

 

             if ( ent->health > client->ps.stats[STAT_LOW_HEATH] )    // "you may need to make a new STAT_  for this something like STAT_LOW_HEATH =1

             {

                ent->health--;

                ent->client->ps.stats[STAT_LOW_HEATH] = ent->health;

              }.

 

Either way,let me know how you figure this out. :winkthumb:

 

Hello, here there is my entire void edit.

 

void ClientTimerActions( gentity_t *ent, int msec )
 {
    gclient_t *client;

    client = ent->client;
    client->timeResidual += msec;

    while ( client->timeResidual >= 10000 )
    {
        client->timeResidual -= 10000;

        if ( ent->s.weapon != WP_NONE )
        {
            ent->client->sess.missionStats.weaponUsed[ent->s.weapon]++;
        }
        // if we've got the seeker powerup, see if we can shoot it at someone
/*        if ( ent->client->ps.powerups[PW_SEEKER] > level.time )
        {
            vec3_t    seekerPos, dir;
            gentity_t *enemy = SeekerAcquiresTarget( ent, seekerPos );

            if ( enemy != NULL ) // set the client's enemy to a valid target
            {
                FireSeeker( ent, enemy, seekerPos, dir );

                gentity_t *tent;
                tent = G_TempEntity( seekerPos, EV_POWERUP_SEEKER_FIRE );
                VectorCopy( dir, tent->pos1 );
                tent->s.eventParm = ent->s.number;
            }
        }*/
        
        //you heal 1 hp every 1 second.
        if ( ent->health < client->ps.stats[STAT_MAX_HEALTH] )
        {
            // HEALTH SELF REGEN ON VAMPIRES, HYLDEN AND DEMONS! )
            if ( ent->client->NPC_class == CLASS_REBORN || ent->client->NPC_class == CLASS_KYLE ||
                ent->client->NPC_class == CLASS_TUSKEN || ent->client->NPC_class == CLASS_GLIDER ||
                ent->client->NPC_class == CLASS_NOGHRI || ent->client->NPC_class == CLASS_FLIER2 ||
                ent->client->NPC_class == CLASS_WEEQUAY || ent->client->NPC_class == CLASS_LIZARD ||
                ent->client->NPC_class == CLASS_SWAMPTROOPER || ent->client->NPC_class == CLASS_FISH ||
                ent->client->NPC_class == CLASS_GRAN || ent->client->NPC_class == CLASS_CLAW ||
                ent->client->NPC_class == CLASS_ALORA || ent->client->NPC_class == CLASS_MONMOTHA ||
                ent->client->NPC_class == CLASS_TAVION || ent->client->NPC_class == CLASS_DESANN ||
                ent->client->NPC_class == CLASS_WAMPA || ent->client->NPC_class == CLASS_MINEMONSTER )
            {
                ent->health++;
            }
        }
        // ARMOR SELFREGENERATION FOR MAGICAL CLASSES
        if ( ent->client->NPC_class == CLASS_KYLE || ent->client->NPC_class == CLASS_LUKE ||
                ent->client->NPC_class == CLASS_SHADOWTROOPER || ent->client->NPC_class == CLASS_MORGANKATARN ||
                ent->client->NPC_class == CLASS_PROTOCOL || ent->client->NPC_class == CLASS_CLAW ||
                ent->client->NPC_class == CLASS_ROCKETTROOPER || ent->client->NPC_class == CLASS_REELO ||
                ent->client->NPC_class == CLASS_GONK || ent->client->NPC_class == CLASS_LIZARD ||
                ent->client->NPC_class == CLASS_WEEQUAY || ent->client->NPC_class == CLASS_GALAKMECH ||
                ent->client->NPC_class == CLASS_LANDO || ent->client->NPC_class == CLASS_IMPWORKER ||
                ent->client->NPC_class == CLASS_IMPERIAL || ent->client->NPC_class == CLASS_JAN ||
                ent->client->NPC_class == CLASS_GALAK || ent->client->NPC_class == CLASS_WAMPA ||
                ent->client->NPC_class == CLASS_DESANN || ent->client->NPC_class == CLASS_GLIDER ||
                ent->client->NPC_class == CLASS_FISH || ent->client->NPC_class == CLASS_FLIER2 ||
                ent->client->NPC_class == CLASS_MURJJ || ent->client->NPC_class == CLASS_MARK2 ||
                ent->client->NPC_class == CLASS_R5D2 || ent->client->NPC_class == CLASS_HOWLER )
            {
                if ( client->ps.stats[STAT_ARMOR] < client->ps.stats[STAT_MAX_HEALTH] )
                {
                    client->ps.stats[STAT_ARMOR]++;
                }
            }
        
        // Health of reaper wounded decrease fast.
        if ( ent->health < client->ps.stats[STAT_MAX_HEALTH] )
        {
            if ( ent->client->NPC_class == CLASS_JEDI )
                {
                    ent->health--;
                }
        }
        // count down armor when over max
        if ( client->ps.stats[STAT_ARMOR] > client->ps.stats[STAT_MAX_HEALTH] )
        {
            client->ps.stats[STAT_ARMOR]--;
        }
            
        if ( (ent->flags&FL_OVERCHARGED_HEALTH) )
        {//need to gradually reduce health back to max
            if ( ent->health > ent->client->ps.stats[STAT_MAX_HEALTH] )
            {//decrement it
                ent->health--;
                ent->client->ps.stats[STAT_HEALTH] = ent->health;
            }
            else
            {//done
                ent->flags &= ~FL_OVERCHARGED_HEALTH;
            }
        }
    }
}

results: all class i set up are for various vampire classes, demons and hyldens. they can regen 1 HP every ten seconds. i changed time into 10000 instead 1000, 1000 was too fast as auto heal for my purpose.

the jedi class on my mod is used for reaper class (creatures like Raziel), and so, he lose 1 HP every 10 second. BUT... this happen only if his health is less than 100. XD that because in soul reaver raziel not lose health when he get full health because the soul reaver will substain him. he lose health into material world when he is wounded. 

works like a charm, man, thanks of all! :D

JaceSolarisVIII likes this

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...