From 194ddc5f40835476673655bd3895f2b7fe7fee0c Mon Sep 17 00:00:00 2001 From: Fire-Head Date: Sat, 28 Mar 2020 23:55:23 +0300 Subject: CWeaponEffects(autoaim crosshair) done, CGame done. restored some original R* names --- src/render/Rubbish.cpp | 1 + src/render/Rubbish.h | 1 + src/render/Skidmarks.cpp | 1 + src/render/Skidmarks.h | 1 + src/render/SpecialFX.cpp | 1 + src/render/SpecialFX.h | 1 + src/render/WeaponEffects.cpp | 111 +++++++++++++++++++++++++++++++++---------- src/render/WeaponEffects.h | 30 +++++++----- 8 files changed, 109 insertions(+), 38 deletions(-) (limited to 'src/render') diff --git a/src/render/Rubbish.cpp b/src/render/Rubbish.cpp index c336eb47..a52e59a0 100644 --- a/src/render/Rubbish.cpp +++ b/src/render/Rubbish.cpp @@ -7,3 +7,4 @@ WRAPPER void CRubbish::StirUp(CVehicle *veh) { EAXJMP(0x512690); } WRAPPER void CRubbish::Update(void) { EAXJMP(0x511B90); } WRAPPER void CRubbish::SetVisibility(bool) { EAXJMP(0x512AA0); } WRAPPER void CRubbish::Init(void) { EAXJMP(0x511940); } +WRAPPER void CRubbish::Shutdown(void) { EAXJMP(0x511B50); } diff --git a/src/render/Rubbish.h b/src/render/Rubbish.h index c94ff303..17323694 100644 --- a/src/render/Rubbish.h +++ b/src/render/Rubbish.h @@ -10,4 +10,5 @@ public: static void Update(void); static void SetVisibility(bool); static void Init(void); + static void Shutdown(void); }; diff --git a/src/render/Skidmarks.cpp b/src/render/Skidmarks.cpp index deb5a648..c2725ed6 100644 --- a/src/render/Skidmarks.cpp +++ b/src/render/Skidmarks.cpp @@ -9,3 +9,4 @@ WRAPPER void CSkidmarks::Render(void) { EAXJMP(0x5182E0); } WRAPPER void CSkidmarks::RegisterOne(uint32 id, CVector pos, float fwdx, float fwdY, bool *isMuddy, bool *isBloddy) { EAXJMP(0x5185C0); } WRAPPER void CSkidmarks::Init(void) { EAXJMP(0x517D70); } +WRAPPER void CSkidmarks::Shutdown(void) { EAXJMP(0x518100); } diff --git a/src/render/Skidmarks.h b/src/render/Skidmarks.h index 2f669575..bf2da7e4 100644 --- a/src/render/Skidmarks.h +++ b/src/render/Skidmarks.h @@ -8,4 +8,5 @@ public: static void Render(void); static void RegisterOne(uint32 id, CVector pos, float fwdx, float fwdY, bool *isMuddy, bool *isBloddy); static void Init(void); + static void Shutdown(void); }; diff --git a/src/render/SpecialFX.cpp b/src/render/SpecialFX.cpp index 8ec2d9a1..301ae265 100644 --- a/src/render/SpecialFX.cpp +++ b/src/render/SpecialFX.cpp @@ -20,6 +20,7 @@ WRAPPER void CSpecialFX::Render(void) { EAXJMP(0x518DC0); } WRAPPER void CSpecialFX::Update(void) { EAXJMP(0x518D40); } WRAPPER void CSpecialFX::Init(void) { EAXJMP(0x5189E0); } +WRAPPER void CSpecialFX::Shutdown(void) { EAXJMP(0x518BE0); } WRAPPER void CMotionBlurStreaks::RegisterStreak(int32 id, uint8 r, uint8 g, uint8 b, CVector p1, CVector p2) { EAXJMP(0x519460); } diff --git a/src/render/SpecialFX.h b/src/render/SpecialFX.h index 701b89a0..fc155a53 100644 --- a/src/render/SpecialFX.h +++ b/src/render/SpecialFX.h @@ -6,6 +6,7 @@ public: static void Render(void); static void Update(void); static void Init(void); + static void Shutdown(void); }; class CMotionBlurStreaks diff --git a/src/render/WeaponEffects.cpp b/src/render/WeaponEffects.cpp index 932c661e..1c29caf8 100644 --- a/src/render/WeaponEffects.cpp +++ b/src/render/WeaponEffects.cpp @@ -1,45 +1,106 @@ #include "common.h" #include "patcher.h" #include "WeaponEffects.h" - #include "TxdStore.h" +#include "Sprite.h" + +RwTexture *gpCrossHairTex; +RwRaster *gpCrossHairRaster; -WRAPPER void CWeaponEffects::Render(void) { EAXJMP(0x564D70); } +CWeaponEffects gCrossHair; -CWeaponEffects &gCrossHair = *(CWeaponEffects*)0x6503BC; +CWeaponEffects::CWeaponEffects() +{ + +} + +CWeaponEffects::~CWeaponEffects() +{ + +} void -CWeaponEffects::ClearCrossHair() +CWeaponEffects::Init(void) { - gCrossHair.m_bCrosshair = false; + 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; + + + CTxdStore::PushCurrentTxd(); + int32 slut = CTxdStore::FindTxdSlot("particle"); + CTxdStore::SetCurrentTxd(slut); + + gpCrossHairTex = RwTextureRead("crosshair", NULL); + gpCrossHairRaster = RwTextureGetRaster(gpCrossHairTex); + + CTxdStore::PopCurrentTxd(); +} + +void +CWeaponEffects::Shutdown(void) +{ + RwTextureDestroy(gpCrossHairTex); } void CWeaponEffects::MarkTarget(CVector pos, uint8 red, uint8 green, uint8 blue, uint8 alpha, float size) { - gCrossHair.m_bCrosshair = true; + gCrossHair.m_bActive = true; gCrossHair.m_vecPos = pos; - gCrossHair.m_red = red; - gCrossHair.m_green = green; - gCrossHair.m_blue = blue; - gCrossHair.m_alpha = alpha; - gCrossHair.m_size = size; + gCrossHair.m_nRed = red; + gCrossHair.m_nGreen = green; + gCrossHair.m_nBlue = blue; + gCrossHair.m_nAlpha = alpha; + gCrossHair.m_fSize = size; } void -CWeaponEffects::Init() +CWeaponEffects::ClearCrossHair(void) { - gCrossHair.m_bCrosshair = false; - gCrossHair.m_vecPos = CVector(0.0f, 0.0f, 0.0f); - gCrossHair.m_red = 0; - gCrossHair.m_green = 0; - gCrossHair.m_blue = 0; - gCrossHair.m_alpha = 255; - gCrossHair.m_size = 1.0f; - gCrossHair.field_24 = 0; - CTxdStore::PushCurrentTxd(); - CTxdStore::SetCurrentTxd(CTxdStore::FindTxdSlot("particle")); - gCrossHair.m_pTexture = RwTextureRead("crosshair", nil); - gCrossHair.m_pRaster = gCrossHair.m_pTexture->raster; - CTxdStore::PopCurrentTxd(); + 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, + gCrossHair.m_fSize * w, gCrossHair.m_fSize * h, + 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); + } } + +STARTPATCHES + //InjectHook(0x564C40, CWeaponEffects::CWeaponEffects, PATCH_JUMP); + //InjectHook(0x564C50, CWeaponEffects::~CWeaponEffects, PATCH_JUMP); + InjectHook(0x564C60, CWeaponEffects::Init, PATCH_JUMP); + InjectHook(0x564CF0, CWeaponEffects::Shutdown, PATCH_JUMP); + InjectHook(0x564D00, CWeaponEffects::MarkTarget, PATCH_JUMP); + InjectHook(0x564D60, CWeaponEffects::ClearCrossHair, PATCH_JUMP); + InjectHook(0x564D70, CWeaponEffects::Render, PATCH_JUMP); +ENDPATCHES \ No newline at end of file diff --git a/src/render/WeaponEffects.h b/src/render/WeaponEffects.h index e4d0461a..31c5a309 100644 --- a/src/render/WeaponEffects.h +++ b/src/render/WeaponEffects.h @@ -3,21 +3,25 @@ class CWeaponEffects { public: - bool m_bCrosshair; - int8 gap_1[3]; + bool m_bActive; + char _pad[3]; CVector m_vecPos; - uint8 m_red; - uint8 m_green; - uint8 m_blue; - uint8 m_alpha; - float m_size; - int32 field_24; - RwTexture *m_pTexture; - RwRaster *m_pRaster; + uint8 m_nRed; + uint8 m_nGreen; + uint8 m_nBlue; + uint8 m_nAlpha; + float m_fSize; + float m_fRotation; public: - static void Render(void); - static void ClearCrossHair(); - static void MarkTarget(CVector, uint8, uint8, uint8, uint8, float); + CWeaponEffects(); + ~CWeaponEffects(); + static void Init(void); + static void Shutdown(void); + static void MarkTarget(CVector pos, uint8 red, uint8 green, uint8 blue, uint8 alpha, float size); + static void ClearCrossHair(void); + static void Render(void); }; + +VALIDATE_SIZE(CWeaponEffects, 0x1C); \ No newline at end of file -- cgit v1.2.3