1
0
Fork 0
mirror of https://git.rip/DMCA_FUCKER/re3.git synced 2024-11-14 06:39:17 +00:00
re3/src/weapons/WeaponEffects.cpp

130 lines
3 KiB
C++
Raw Normal View History

#include "common.h"
2020-04-17 13:31:11 +00:00
#include "WeaponEffects.h"
2020-03-22 14:23:40 +00:00
#include "TxdStore.h"
#include "Sprite.h"
2020-08-27 16:52:43 +00:00
#include "PlayerPed.h"
#include "World.h"
#include "WeaponType.h"
RwTexture *gpCrossHairTex;
RwRaster *gpCrossHairRaster;
2020-03-22 14:23:40 +00:00
CWeaponEffects gCrossHair;
2019-07-04 20:31:21 +00:00
CWeaponEffects::CWeaponEffects()
{
}
CWeaponEffects::~CWeaponEffects()
{
}
2019-07-04 20:31:21 +00:00
2020-01-23 20:21:50 +00:00
void
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);
2020-08-27 16:52:43 +00:00
gCrossHair.m_nRed = 255;
2020-03-29 13:32:11 +00:00
gCrossHair.m_nGreen = 0;
gCrossHair.m_nBlue = 0;
2020-08-27 16:52:43 +00:00
gCrossHair.m_nAlpha = 127;
2020-03-29 13:32:11 +00:00
gCrossHair.m_fSize = 1.0f;
gCrossHair.m_fRotation = 0.0f;
CTxdStore::PushCurrentTxd();
2020-03-29 13:32:11 +00:00
int32 slot = CTxdStore::FindTxdSlot("particle");
CTxdStore::SetCurrentTxd(slot);
2020-05-26 23:16:31 +00:00
gpCrossHairTex = RwTextureRead("target256", "target256m");
gpCrossHairRaster = RwTextureGetRaster(gpCrossHairTex);
2020-03-29 13:32:11 +00:00
CTxdStore::PopCurrentTxd();
}
void
CWeaponEffects::Shutdown(void)
{
RwTextureDestroy(gpCrossHairTex);
2020-04-19 14:38:10 +00:00
gpCrossHairTex = nil;
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_fSize = size;
2020-01-23 20:21:50 +00:00
}
2020-03-22 14:23:40 +00:00
void
CWeaponEffects::ClearCrossHair(void)
2020-03-22 14:23:40 +00:00
{
gCrossHair.m_bActive = false;
}
void
CWeaponEffects::Render(void)
{
2020-08-27 16:52:43 +00:00
static float aCrossHairSize[WEAPONTYPE_TOTALWEAPONS] =
{
1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
0.4f, 0.4f,
0.5f,
0.3f,
0.9f, 0.9f, 0.9f,
0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f,
0.1f, 0.1f,
1.0f,
0.6f,
0.7f,
0.0f, 0.0f
};
if ( gCrossHair.m_bActive )
{
2020-08-27 16:52:43 +00:00
float size = aCrossHairSize[FindPlayerPed()->GetWeapon()->m_eWeaponType];
RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void *)FALSE);
2020-08-27 16:52:43 +00:00
RwRenderStateSet(rwRENDERSTATEZTESTENABLE, (void *)FALSE);
RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void *)TRUE);
2020-08-27 16:52:43 +00:00
RwRenderStateSet(rwRENDERSTATESRCBLEND, (void *)rwBLENDSRCALPHA);
2020-11-11 18:10:22 +00:00
#ifdef FIX_BUGS
RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void *)rwBLENDINVSRCALPHA);
#else
2020-08-27 16:52:43 +00:00
RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void *)rwBLENDINVDESTALPHA);
2020-11-11 18:10:22 +00:00
#endif
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;
2020-08-27 16:52:43 +00:00
CSprite::RenderOneXLUSprite_Rotate_Aspect(pos.x, pos.y, pos.z,
w, h,
255, 88, 100, 158,
recipz, gCrossHair.m_fRotation, gCrossHair.m_nAlpha);
float recipz2 = 1.0f / pos.z;
CSprite::RenderOneXLUSprite_Rotate_Aspect(pos.x, pos.y, pos.z,
size*w, size*h,
107, 134, 247, 158,
recipz2, TWOPI - gCrossHair.m_fRotation, gCrossHair.m_nAlpha);
gCrossHair.m_fRotation += 0.02f;
if ( gCrossHair.m_fRotation > TWOPI )
gCrossHair.m_fRotation = 0.0;
}
2020-08-27 16:52:43 +00:00
RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void *)FALSE);
2020-08-27 16:52:43 +00:00
RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void *)TRUE);
RwRenderStateSet(rwRENDERSTATEZTESTENABLE, (void *)TRUE);
}
2020-04-17 13:31:11 +00:00
}