ref: aa5529bc6cbd5424c33f624d8a33fc482d18c489
parent: fd43740b94137503a58bc4819a83c616ad660c0d
author: James Haley <[email protected]>
date: Fri Sep 24 01:59:54 EDT 2010
Fixes for P_GiveBody. Subversion-branch: /branches/strife-branch Subversion-revision: 2133
--- a/src/strife/p_inter.c
+++ b/src/strife/p_inter.c
@@ -238,29 +238,50 @@
//
boolean P_GiveBody(player_t* player, int num)
{
- int health;
+ int maxhealth;
+ int healing;
- if(num >= 0)
- {
- health = player->stamina + MAXHEALTH;
+ maxhealth = MAXHEALTH + player->stamina;
- if(health <= player->health)
+ if(num >= 0) // haleyjd 09/23/10: fixed to give proper amount of health
+ {
+ // any healing to do?
+ if(player->health >= maxhealth)
return false;
+ // give, and cap to maxhealth
player->health += num;
+ if(player->health >= maxhealth)
+ player->health = maxhealth;
- if(health < player->health + num)
- player->health = health;
+ // Set mo->health for consistency.
player->mo->health = player->health;
}
- // [STRIFE] handle healing from the front's medic
else
{
- health = (-num * (player->stamina + MAXHEALTH)) / MAXHEALTH;
- if(health <= player->health)
+ // [STRIFE] handle healing from the Front's medic
+ // The amount the player's health will be set to scales up with stamina
+ // increases.
+ // Ex 1: On the wimpiest skill level, -100 is sent in. This restores
+ // full health no matter what your stamina.
+ // (100*100)/100 = 100
+ // (200*100)/100 = 200
+ // Ex 2: On the most stringent skill levels, -50 is sent in. This will
+ // restore at most half of your health.
+ // (100*50)/100 = 50
+ // (200*50)/100 = 100
+ healing = (-num * maxhealth) / MAXHEALTH;
+
+ // This is also the "threshold" of healing. You need less health than
+ // the amount that will be restored in order to get any benefit.
+ // So on the easiest skill you will always be fully healed.
+ // On the hardest skill you must have less than 50 health, and will
+ // only recover to 50 (assuming base stamina stat)
+ if(player->health >= healing)
return false;
- player->health = health;
+ // Set health. Oddly, mo->health is NOT set here...
+ player->health = healing;
}
return true;