Game Development Community

Health does not get applied instantly.

by Juan Aramburu · in Torque Game Engine · 06/09/2006 (2:15 am) · 5 replies

Is there a way for health to get applied instantly instead of gradually? For example, if I did:

===>%player.applyDamage(10);
===>echo(%player.getDamagePercent());
0.1

Then I pick up a health kit that just has this:

%col.applyRepair(%this.repairAmount);

back to the console, it gets applied slowly; this is a problem as there's no callback for me to update my HUD. My HUD will show health @ 90% (after picking up the health) but in reality it's gradually climbing to 100% as in 90%, 91%, 92%, ..., 99%, 100%.

#1
06/09/2006 (2:59 am)
It's not difficult to add a callback, like onRepair();
That's what I would do if I were you.

Other than that, you could use setDamageLevel.
#2
06/09/2006 (1:28 pm)
Even with setDamageLevel(), the repair is still not applied instantly. I want the player's health (damagePercent) to jump from say 75% to 100% at the instant it is picked up. I have set repairRate and rechargeRate both to 0, but they do not seem to have any effect.
#3
06/10/2006 (2:36 am)
Stefan, I was unable to locate an onRepair callback function? Do you have a sample script?
#4
06/14/2006 (5:50 pm)
Bump.
#5
06/14/2006 (6:40 pm)
Assuming you don't want the gradual health increase, just do the calculation of what the health is going to repair yourself and send _that_ information to the gui, then use setDamageLevel and it should be applied near instantly enough.

If you wanted an onRepair callback, go find this code in in shapebase.cc and add the callback there, it'll get called everytime the gradual repair increases.
if (mRepairReserve > 0.0)
      {
         F32 rate = getMin(mDataBlock->repairRate, mRepairReserve);
         mDamage -= rate;
         mRepairReserve -= rate;		 
         Con::executef(mDataBlock,2,"onRepair",scriptThis()); //Add this
      }
Though it's probably more efficient to have a custom GUI written that reads that data like the guiHealthBarHUD.