Game Development Community

make units leave corpses ... and make them not target(able)?

by Jeff Yaskus · in RTS Starter Kit · 04/15/2010 (5:34 pm) · 0 replies

How might I go about this ?

Currently, when a unit is disabled -- they "fade out" over 1000ms.
function RTSUnitData::onDisabled(%this,%obj,%state)
{  
...
   // Schedule corpse removal.  Just keeping the place clean.
   %obj.schedule($CorpseTimeoutValue - 1000, "startFade", 1000, 0, true);
   %obj.schedule($CorpseTimeoutValue, "delete"); 
}
But during this time, they are still "valid targets" ... and units keep attacking them, they keep attacking -- and animating.

I added a check to the player ::damage() function call -- but thats not helping.
function RTSUnitData::damage(%this, %obj, %sourceObject, %position, %damage, %damageType)
{
...
   if (%obj.getState() $= "Dead")
      {
         echo(" RTSUnitData::damage - object already dead, why hurt it more.");
         return;
      }


How do I ;
(a) leave a permanent corpse behind after a unit dies
(b) immediately make the "dead" unit -- stop moving -- play its death anim -- and not target-able

Should something like this work ?
function warriorBlock::onAttack(%this, %attacker, %target)
{
 ...
   if (%target.getState $= "dead")
     {
         // clear current target
         return;
     }
 ...
}


... and WHY do units not seem to play death animations and stop?

They seem to immediately revert back to their "idle" animation afterward -- just like when you stop running.

I'm thinking its related to their "state" and the engine code somewhere ...