2019-05-30 19:24:47 +00:00
|
|
|
#include "common.h"
|
2020-04-17 13:31:11 +00:00
|
|
|
|
2019-05-30 19:24:47 +00:00
|
|
|
#include "WeaponEffects.h"
|
2020-03-22 14:23:40 +00:00
|
|
|
#include "TxdStore.h"
|
2020-03-28 20:55:23 +00:00
|
|
|
#include "Sprite.h"
|
|
|
|
|
|
|
|
RwTexture *gpCrossHairTex;
|
|
|
|
RwRaster *gpCrossHairRaster;
|
2020-03-22 14:23:40 +00:00
|
|
|
|
2020-03-28 20:55:23 +00:00
|
|
|
CWeaponEffects gCrossHair;
|
2019-07-04 20:31:21 +00:00
|
|
|
|
2020-03-28 20:55:23 +00:00
|
|
|
CWeaponEffects::CWeaponEffects()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
CWeaponEffects::~CWeaponEffects()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
2019-07-04 20:31:21 +00:00
|
|
|
|
2020-01-23 20:21:50 +00:00
|
|
|
void
|
2020-03-28 20:55:23 +00:00
|
|
|
CWeaponEffects::Init(void)
|
2019-07-04 20:31:21 +00:00
|
|
|
{
|
2020-03-29 13:32:11 +00:00
|
|
|
gCrossHair.m_bActive = false;
|
|
|
|
gCrossHair.m_vecPos = CVector(0.0f, 0.0f, 0.0f);
|
|
|
|
gCrossHair.m_nRed = 0;
|
|
|
|
gCrossHair.m_nGreen = 0;
|
|
|
|
gCrossHair.m_nBlue = 0;
|
|
|
|
gCrossHair.m_nAlpha = 255;
|
|
|
|
gCrossHair.m_fSize = 1.0f;
|
|
|
|
gCrossHair.m_fRotation = 0.0f;
|
2020-03-28 20:55:23 +00:00
|
|
|
|
|
|
|
|
|
|
|
CTxdStore::PushCurrentTxd();
|
2020-03-29 13:32:11 +00:00
|
|
|
int32 slot = CTxdStore::FindTxdSlot("particle");
|
|
|
|
CTxdStore::SetCurrentTxd(slot);
|
2020-03-28 20:55:23 +00:00
|
|
|
|
2020-03-29 13:35:50 +00:00
|
|
|
gpCrossHairTex = RwTextureRead("crosshair", nil);
|
2020-03-28 20:55:23 +00:00
|
|
|
gpCrossHairRaster = RwTextureGetRaster(gpCrossHairTex);
|
|
|
|
|
2020-03-29 13:32:11 +00:00
|
|
|
CTxdStore::PopCurrentTxd();
|
2020-03-28 20:55:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CWeaponEffects::Shutdown(void)
|
|
|
|
{
|
|
|
|
RwTextureDestroy(gpCrossHairTex);
|
2020-11-29 11:26:34 +00:00
|
|
|
#if GTA_VERSION >= GTA3_PC_11
|
2020-04-19 14:38:10 +00:00
|
|
|
gpCrossHairTex = nil;
|
|
|
|
#endif
|
2019-07-04 20:31:21 +00:00
|
|
|
}
|
2020-01-23 20:21:50 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
CWeaponEffects::MarkTarget(CVector pos, uint8 red, uint8 green, uint8 blue, uint8 alpha, float size)
|
|
|
|
{
|
2020-03-29 13:32:11 +00:00
|
|
|
gCrossHair.m_bActive = true;
|
|
|
|
gCrossHair.m_vecPos = pos;
|
|
|
|
gCrossHair.m_nRed = red;
|
|
|
|
gCrossHair.m_nGreen = green;
|
|
|
|
gCrossHair.m_nBlue = blue;
|
|
|
|
gCrossHair.m_nAlpha = alpha;
|
|
|
|
gCrossHair.m_fSize = size;
|
2020-01-23 20:21:50 +00:00
|
|
|
}
|
2020-03-22 14:23:40 +00:00
|
|
|
|
|
|
|
void
|
2020-03-28 20:55:23 +00:00
|
|
|
CWeaponEffects::ClearCrossHair(void)
|
2020-03-22 14:23:40 +00:00
|
|
|
{
|
2020-03-28 20:55:23 +00:00
|
|
|
gCrossHair.m_bActive = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CWeaponEffects::Render(void)
|
|
|
|
{
|
|
|
|
if ( gCrossHair.m_bActive )
|
|
|
|
{
|
|
|
|
RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void *)FALSE);
|
|
|
|
RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void *)TRUE);
|
|
|
|
RwRenderStateSet(rwRENDERSTATESRCBLEND, (void *)rwBLENDONE);
|
|
|
|
RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void *)rwBLENDONE);
|
|
|
|
RwRenderStateSet(rwRENDERSTATETEXTURERASTER, (void *)gpCrossHairRaster);
|
|
|
|
|
|
|
|
RwV3d pos;
|
|
|
|
float w, h;
|
|
|
|
if ( CSprite::CalcScreenCoors(gCrossHair.m_vecPos, &pos, &w, &h, true) )
|
|
|
|
{
|
|
|
|
float recipz = 1.0f / pos.z;
|
|
|
|
CSprite::RenderOneXLUSprite(pos.x, pos.y, pos.z,
|
2020-04-10 07:52:47 +00:00
|
|
|
gCrossHair.m_fSize * w, gCrossHair.m_fSize * h,
|
2020-03-28 20:55:23 +00:00
|
|
|
gCrossHair.m_nRed, gCrossHair.m_nGreen, gCrossHair.m_nBlue, 255,
|
|
|
|
recipz, 255);
|
|
|
|
}
|
|
|
|
|
|
|
|
RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void *)FALSE);
|
|
|
|
RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void *)FALSE);
|
|
|
|
RwRenderStateSet(rwRENDERSTATESRCBLEND, (void *)rwBLENDSRCALPHA);
|
|
|
|
RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void *)rwBLENDINVSRCALPHA);
|
|
|
|
}
|
2020-04-17 13:31:11 +00:00
|
|
|
}
|