Game Development Community

dev|Pro Game Development Curriculum

Code: Health repair/recharge rate

by Dustin Mullen · 06/16/2008 (6:22 am) · 6 comments

All this is done in player.cs (starter.fps/server/scripts/player.cs)

First, go to this line and change the repairRate to 0.01 or whatever suits your needs.

mass = 90;
   drag = 0.3;
   maxdrag = 0.4;
   density = 10;
   maxDamage = 100;
   maxEnergy =  60;
   repairRate = 0.01;
   energyPerDamagePoint = 75.0;



Next, go to this line found in the function function Armor::onAdd(%this,%obj)

Change the setRepairRate to look like this:

%obj.setRechargeRate(%this.rechargeRate);
   %obj.setRepairRate(%this.repairRate);


Now to test it, go into your game and shoot at your feet and you should take damage. After about 5 seconds, your health should slowly be regained.

#1
06/18/2008 (2:10 am)
Great!!!!!! Respect!
#2
06/22/2008 (3:53 am)
easy and simple good tutorail. thanks
#3
08/07/2008 (5:14 am)
hehe.... this.. is the handy thing!

:)
#4
10/07/2008 (6:03 am)
Fantastic! Been working on this myself, and this is better!
#5
01/18/2009 (12:13 pm)
So, I did this but there's a problem.

If I kill myself, I respawn and my old husk of a body is still standing there. Upright and ready to go.

In fact, he's so healthy that I can shoot my old body and I/myself takes damage. o.O

How do we make my clones go bye-bye? Anyone else have this issue?
(btw, once I kill my old-self from the 3rd person, then he seems to die properly and fade away after some time.)
#6
02/03/2009 (1:28 pm)
http://www.garagegames.com/community/forums/viewthread/82925/1#comment_form

check this if you have Health Regeneration issues