TGEA Fix for DamageFlash
by Jaimi McEntire · 01/25/2009 (9:54 pm) · 8 comments
In TGEA, the function to show the damage flash does not work. This is in part to two issues - one, a bug with pulling the correct amounts from the control object, and two, the GameRenderFilters function was not ported over. To fix this issue you must fix both issues:
in GameBase.h, getDamageFlash and getWhiteOut are incorrectly defined.
Find these two declarations:
Here is a simplistic GameRenderFilters function, This only supports the damage flash, but you can extend it as needed. I've verified it works correctly by running around and hitting myself with Thor's Hammer.
in addition, if you are using AFX in 1.7.1, then you will need to remove the #ifdef that prohibits GameRenderFilters from being called at all in afxTSCtrl.cpp, afxTSCtrl::onRender:
edit: Updated with a better fix from Alex Scarborough
getDamageFlash()
in GameBase.h, getDamageFlash and getWhiteOut are incorrectly defined.
Find these two declarations:
virtual F32 getDamageFlash() { return 1.0f; }
virtual F32 getWhiteOut() { return 1.0f; }and mark them const, like this:virtual F32 getDamageFlash() const { return 1.0f; }
virtual F32 getWhiteOut() const { return 1.0f; }GameRenderFilters()
Here is a simplistic GameRenderFilters function, This only supports the damage flash, but you can extend it as needed. I've verified it works correctly by running around and hitting myself with Thor's Hammer.
void GameRenderFilters(const CameraQuery& camq)
{
// Stubbed out currently - check version history for old code.
GameConnection* connection = GameConnection::getConnectionToServer();
F32 damageFlash = 0.0f;
F32 whiteOut = 0.0f;
F32 blackOut = 0.0f;
if(connection)
{
damageFlash = connection->getDamageFlash();
whiteOut = connection->getWhiteOut();
blackOut = connection->getBlackOut();
GuiTSCtrl *tsCtrl;
// if your screen is not called PlayGui, you will need to change this.
// I'd considered adding a pointer to the tsctrl to the CameraQuery, but
// since this is just a proof of concept, I didn't bother. I will do this
// for real later. (I want blood splatters, etc, not just a flash...)
if (! Sim::findObject("PlayGui", tsCtrl))
{
return;
}
ColorI color(255,0,0,255 * damageFlash);
GFX->getDrawUtil()->drawRectFill(Point2I(0,0),tsCtrl->getExtent(),color);
}
}in addition, if you are using AFX in 1.7.1, then you will need to remove the #ifdef that prohibits GameRenderFilters from being called at all in afxTSCtrl.cpp, afxTSCtrl::onRender:
//#if !defined(TGEA_ENGINE)
CameraQuery camq;
if (GameProcessCameraQuery(&camq))
GameRenderFilters(camq);
//#endifedit: Updated with a better fix from Alex Scarborough
About the author
Recent Blogs
• Replicator Updates for TGEA 1.8.1• GuiLensFlareHud - Lens flares and white out for TGEA 1.8.1
• fxGenericObject for TGEA 1.8.1
• GuiStatusCtrl - *Updated* Display Field Name, Values, Status Bar for any field or method on any named object. TGEA and (new! TGE 1.52)
• Bitmap Channel Embedder
#2
01/25/2009 (10:40 pm)
Thanks Jaimi that's great...saves me a job on my list of bugs to fix :)
#3
The real issue here is the getDamageFlash() method has different signatures in ShapeBase and GameBase, as does getWhiteOut(). Both should be changed to const methods in GameBase.
In fact, I'm going to review all of the getters in GameBase for this. It's just silly that they don't work.
Edit: onlyFirstPerson() and useObjsEyePoint() have the same issue. Both should be made const in GameBase.
01/26/2009 (1:47 am)
Quote:in GameConnection.h, mControlObject was changed to a GameBase SimObjectPtr instead of a ShapeBase SimObjectPtr. This results in getDamageFlash() always returning 1.0f;
The real issue here is the getDamageFlash() method has different signatures in ShapeBase and GameBase, as does getWhiteOut(). Both should be changed to const methods in GameBase.
In fact, I'm going to review all of the getters in GameBase for this. It's just silly that they don't work.
Edit: onlyFirstPerson() and useObjsEyePoint() have the same issue. Both should be made const in GameBase.
#4
01/26/2009 (1:54 am)
@Alex: Cool, I'd just assumed there was something goofy in SimObjectPtr (I'm not even sure why it exists...). I've updated the resource text with the correct fix.
#5
01/26/2009 (2:18 am)
If a SimObject is deleted, SimObjectPtr's holding it are set to NULL instead of hanging on to an invalid pointer. That's why they exist.
#6
01/26/2009 (2:46 pm)
Jaimi is MY hero, MINE I TELL YOU! yes, my hero indeed. lovely one jaimi. thanks for 2.
#7
03/22/2009 (6:49 am)
im using tgea 1.8.1 and i cant get this to work. it just always renders a red screen. are there any script changes we need too?
#8
Anyway, this resource doesn't work right in 1.8.1, due to various reasons. However, I have a much better resource coming very soon that will replace this functionality completely, and give a bunch more features to boot.
05/20/2009 (2:58 am)
@George: Sorry I didn't see this, the notification doesn't seem to be working.Anyway, this resource doesn't work right in 1.8.1, due to various reasons. However, I have a much better resource coming very soon that will replace this functionality completely, and give a bunch more features to boot.
Employee Matt Fairfax