Game Development Community

How to re-enable Energy level for RTS Units

by Jeff Yaskus · in RTS Starter Kit · 04/09/2010 (1:43 pm) · 0 replies

I am adding AFX to my RTS Starter kit build ... and started using spells.

Then I noticed that getEnergyLevel() was not working client side for units ... even though it was server side.

After much digging, finally realized the code was commented out in RTSunit.cc

Here is all it takes to fix it.

------

un-comment (and recompile) these in RTSunit.cc to fix it;

packUpdate()
// Ghost needs energy to predict reliably (but not in RTS -- BJG)
   stream->writeFloat(getEnergyLevel() / mDataBlock->maxEnergy,EnergyLevelBits);

unpackUpdate()
// Ghost needs energy to predict reliably (but not in RTS -- BJG)
   F32 energy = stream->readFloat(EnergyLevelBits) * mDataBlock->maxEnergy;
   setEnergyLevel(energy);