Game Development Community

Lava/Water Damage

by Jermaine Morgan · in Torque Game Engine · 10/01/2007 (6:08 am) · 5 replies

Here is what I am trying to do:
when the enters the water which like 10 feet deep I want the player to lose health.

Here is what I did:
I did something basic I changed the water type to "hot lava."
It work how its suppose to, the player loses health.

My Problem:
When the player goes under the water/lava he loses too much health. He loses like 95% of his health, and then quickly dies.

In the player.cs I did change the $DamageHotLava from 0.01 to 0.001. but that didnt really work.
Is there a fix to this?
I just want the player to lose health more slowly.

Thanks in advance.

#1
10/01/2007 (7:04 am)
There's a bug in the default starter.fps scripts. There has been for years, myself and others have already reported the issue but it never gets fixed.

In player.cs there is an onEnterLiquid() function that determines which type of liquid the player is in and how much damage to apply. It seems you've already noticed the damage rate variables, these are used to determine the amount of damage to apply per liquid type. The problem is that the resulting function that is called, setDamageDt(), is being called with the wrong number of parameters.

The second problem is in shapeBase.cs, where the setDamageDt() function is located. That function uses a null defined parameter, %obj, which means that a random value is being used to determine the amount of damage to apply.

Anyhow, here's the fix, yet again:

player.cs
function Armor::onEnterLiquid(%this, %obj, %coverage, %type)
{
   switch(%type)
   {
      case 0: //Water
      case 1: //Ocean Water
      case 2: //River Water
      case 3: //Stagnant Water
      case 4: //Lava
         %obj.setDamageDt($DamageLava, "Lava");
      case 5: //Hot Lava
         %obj.setDamageDt($DamageHotLava, "Lava");
      case 6: //Crusty Lava
         %obj.setDamageDt($DamageCrustyLava, "Lava");
      case 7: //Quick Sand
   }
}

shapeBase.cs
function ShapeBase::setDamageDt(%this, %damageAmount, %damageType)
{
   // This function is used to apply damage over time.  The damage
   // is applied at a fixed rate (50 ms).  Damage could be applied
   // over time using the built in ShapBase C++ repair functions
   // (using a neg. repair), but this has the advantage of going
   // through the normal script channels.
   if (%this.getState() !$= "Dead") {
      %this.damage(0, "0 0 0", %damageAmount, %damageType);
      %this.damageSchedule = %this.schedule(50, "setDamageDt", %damageAmount, %damageType);
   }
   else
      %this.damageSchedule = "";
}

function ShapeBase::clearDamageDt(%this)
{
   if (%this.damageSchedule !$= "") {
      cancel(%this.damageSchedule);
      %this.damageSchedule = "";
   }
}

Simply replace the above listed functions with the ones that I provide.

Now the player will gradually loose health whilst in the water block and stop loosing health upon exiting the water block. You can adjust how much damage the player receives with the variables at the top of player.cs.
#2
10/01/2007 (7:19 am)
Quote:There has been for years, myself and others have already reported the issue but it never gets fixed.
How long is that fix 5 minutes? Don't tell me GG has not the time to fix such silly bugs...
#3
10/01/2007 (7:29 am)
Not even 5 minues, try 15 seconds. There's plenty more bugs in the starter.fps scripts too, I guess they (GG) don't see starter.kit script related bugs as a priority.
#4
10/01/2007 (1:22 pm)
This is honestly the first time I have seen this bug report. Had I been aware of it last year at this time I would have fixed it for TGE 1.4.2 and TGE 1.5.
#5
10/01/2007 (1:40 pm)
Let's hope it will be fixed in next release then... 8-)