From a99da7b94e275e7437c7802d509697cd313d1166 Mon Sep 17 00:00:00 2001 From: majestic Date: Wed, 10 Jun 2020 13:19:05 -0700 Subject: more original cheats - CSmokeTrails and CSmokeTrail classes added in new files - more cheats added --- src/core/Pad.cpp | 220 ++++++++++++++++++++++++++++++++++----------- src/render/Fluff.cpp | 7 ++ src/render/SmokeTrails.cpp | 139 ++++++++++++++++++++++++++++ src/render/SmokeTrails.h | 23 +++++ 4 files changed, 335 insertions(+), 54 deletions(-) create mode 100644 src/render/SmokeTrails.cpp create mode 100644 src/render/SmokeTrails.h (limited to 'src') diff --git a/src/core/Pad.cpp b/src/core/Pad.cpp index f38e48f0..c5d3f1b0 100644 --- a/src/core/Pad.cpp +++ b/src/core/Pad.cpp @@ -37,6 +37,7 @@ #include "Wanted.h" #include "WaterLevel.h" #include "General.h" +#include "SmokeTrails.h" CPad Pads[MAX_PADS]; CMousePointerStateHelper MousePointerStateHelper; @@ -249,6 +250,14 @@ void ChangePlayerCheat() } } +void ChangePlayerModel(const char* name) { + if (!FindPlayerVehicle()) { + FindPlayerPed()->Undress(name); + CStreaming::LoadAllRequestedModels(0); + FindPlayerPed()->Dress(); + } +} + void MayhemCheat() { CHud::SetHelpMessage(TheText.Get("CHEAT1"), true); @@ -404,6 +413,10 @@ void BackToTheFuture(void) CVehicle::bHoverCheat = !CVehicle::bHoverCheat; } +void SuicideCheat(void) { + CHud::SetHelpMessage(TheText.Get("CHEAT1"), true); + FindPlayerPed()->InflictDamage(nil, WEAPONTYPE_UNARMED, 1000.0f, PEDPIECE_TORSO, 0); +} ////////////////////////////////////////////////////////////////////////// @@ -1089,50 +1102,169 @@ void CPad::AddToPCCheatString(char c) KeyBoardCheatString[0] = ' '; WeaponsForAllCheat(); } + // "ONSPEED" + else if (!Cheat_strncmp(KeyBoardCheatString, "GJLQ`iR")) { + KeyBoardCheatString[0] = ' '; + FastTimeCheat(); + } + // "BOOOOOORING" + else if (!Cheat_strncmp(KeyBoardCheatString, "JSPS\\jRVPZO")) { + KeyBoardCheatString[0] = ' '; + SlowTimeCheat(); + } + // "WHEELSAREALLINEED" + else if (!Cheat_strncmp(KeyBoardCheatString, "GJLOVgOHF]N[SeRNs")) { + KeyBoardCheatString[0] = ' '; + OnlyRenderWheelsCheat(); + } + //COMEFLYWITHME + else if (!Cheat_strncmp(KeyBoardCheatString, "HROUVr\\SGPZWJ")) { + KeyBoardCheatString[0] = ' '; + } + // "GRIPISEVERYTHING" + else if (!Cheat_strncmp(KeyBoardCheatString, "JSPIatULWP`QWi_M")) { + KeyBoardCheatString[0] = ' '; + StrongGripCheat(); + } + // "CHASESTAT" + else if (!Cheat_strncmp(KeyBoardCheatString, "WF[TRnDOD")) { + KeyBoardCheatString[0] = ' '; + } + // "CHICKSWITHGUNS" + else if (!Cheat_strncmp(KeyBoardCheatString, "VS\\HUoL^TVPQOc")) { + KeyBoardCheatString[0] = ' '; + } + // "ICANTTAKEITANYMORE" + else if (!Cheat_strncmp(KeyBoardCheatString, "HWVNfiD[JPXI[t[G_\\")) { + KeyBoardCheatString[0] = ' '; + SuicideCheat(); + } + // "GREENLIGHT" + else if (!Cheat_strncmp(KeyBoardCheatString, "WMNJYiHLSR")) { + KeyBoardCheatString[0] = ' '; + } + // "MIAMITRAFFIC" + else if (!Cheat_strncmp(KeyBoardCheatString, "FNMGNmWPNLVU")) { + KeyBoardCheatString[0] = ' '; + } + // "AHAIRDRESSERSCAR" + else if (!Cheat_strncmp(KeyBoardCheatString, "UFJT_`VZF]QZPaUG")) { + KeyBoardCheatString[0] = ' '; + PinkCarsCheat(); + } + // "IWANTITPAINTEDBLACK" + else if (!Cheat_strncmp(KeyBoardCheatString, "NHHMO_H[OTNX[iaT]jS")) { + KeyBoardCheatString[0] = ' '; + BlackCarsCheat(); + } // "TRAVELINSTYLE" - if (!_CHEATCMP("ELYTSNILEVART")) + else if (!Cheat_strncmp(KeyBoardCheatString, "HQ`U`iLSFaNZ[")) { + KeyBoardCheatString[0] = ' '; VehicleCheat(true, MI_BLOODRA); - - // "GETTHEREQUICKLY" - if (!_CHEATCMP("YLKCIUQEREHTTEG")) - VehicleCheat(true, MI_BLOODRB); - - // "GETTHEREFAST" - if (!_CHEATCMP("TSAFEREHTTEG")) - VehicleCheat(true, MI_SABRETUR); - - // "GETTHEREVERYFASTINDEED" - if (!_CHEATCMP("DEEDNITSAFYREVEREHTTEG")) - VehicleCheat(true, MI_HOTRINA); - - // "GETTHEREAMAZINGLYFAST" - if (!_CHEATCMP("TSAFYLGNIZAMAEREHTTEG")) - VehicleCheat(true, MI_HOTRINB); - + } // "THELASTRIDE" - if (!_CHEATCMP("EDIRTSALEHT")) + else if (!Cheat_strncmp(KeyBoardCheatString, "HIPSanDSFSa")) { + KeyBoardCheatString[0] = ' '; VehicleCheat(true, MI_ROMERO); - + } // "ROCKANDROLLCAR" - if (!_CHEATCMP("RACLLORDNAKCOR")) + else if (!Cheat_strncmp(KeyBoardCheatString, "UFJMYjUKOLXKVr")) { + KeyBoardCheatString[0] = ' '; VehicleCheat(true, MI_LOVEFIST); - + } // "RUBBISHCAR" - if (!_CHEATCMP("RACHSIBBUR")) + else if (!Cheat_strncmp(KeyBoardCheatString, "UFJI`dEIV]")) { + KeyBoardCheatString[0] = ' '; VehicleCheat(true, MI_TRASH); - + } + // "GETTHEREQUICKLY" + else if (!Cheat_strncmp(KeyBoardCheatString, "\\QRDVpTLSPU\\[eT")) { + KeyBoardCheatString[0] = ' '; + VehicleCheat(true, MI_BLOODRB); + } + // "GETTHEREFAST" + else if (!Cheat_strncmp(KeyBoardCheatString, "WXHGRmHOU_RO")) { + KeyBoardCheatString[0] = ' '; + VehicleCheat(true, MI_SABRETUR); + } // "BETTERTHANWALKING" - if (!_CHEATCMP("GNIKLAWNAHTRETTEB")) + else if (!Cheat_strncmp(KeyBoardCheatString, "JSPLY\\ZUBSaZLtaK^")) { + KeyBoardCheatString[0] = ' '; VehicleCheat(true, MI_CADDY); - - // "TIMEFLIESWHENYOU" - if (!_CHEATCMP("UOYNEHWSEILFEMIT")) - FastTimeCheat(); - - // "BOOOOORING" - if (!_CHEATCMP("GNIROOOOOB")) - SlowTimeCheat(); - + } + // "GETTHEREFASTINDEED" + else if (!Cheat_strncmp(KeyBoardCheatString, "GJLE[dWZBQfZLvRXa[^WHL")) { + KeyBoardCheatString[0] = ' '; + VehicleCheat(true, MI_HOTRINA); + } + // "GETTHEREAMAZINGLYFAST" + else if (!Cheat_strncmp(KeyBoardCheatString, "WXHGfgJUJeNUHe_Kdg^HJ")) { + KeyBoardCheatString[0] = ' '; + VehicleCheat(true, MI_HOTRINB); + } + // LOOKLIKELANCE + else if (!Cheat_strncmp(KeyBoardCheatString, "HHUBY`NPMV\\WS")) { + KeyBoardCheatString[0] = ' '; + ChangePlayerModel("igbuddy"); + } + // IWANTBIGTITS + else if (!Cheat_strncmp(KeyBoardCheatString, "VYPUTdE[OLdQ")) { + KeyBoardCheatString[0] = ' '; + ChangePlayerModel("igcandy"); + } + // MYSONISALAWYER + else if (!Cheat_strncmp(KeyBoardCheatString, "UJ`XNgDZJY\\[`m")) { + KeyBoardCheatString[0] = ' '; + ChangePlayerModel("igken"); + } + // ILOOKLIKEHILARY + else if (!Cheat_strncmp(KeyBoardCheatString, "\\WHMVcHRJWXWVlV")) { + KeyBoardCheatString[0] = ' '; + ChangePlayerModel("ighlary"); + } + // ROCKANDROLLMAN + else if (!Cheat_strncmp(KeyBoardCheatString, "QFTMYjUKOLXKVr")) { + KeyBoardCheatString[0] = ' '; + ChangePlayerModel("igjezz"); + } + // ONEARMEDBANDIT + else if (!Cheat_strncmp(KeyBoardCheatString, "WNKON]GLN]NMUo")) { + KeyBoardCheatString[0] = ' '; + ChangePlayerModel("igphil"); + } + // IDONTHAVETHEMONEYSONNY + else if (!Cheat_strncmp(KeyBoardCheatString, "\\SUP`tHUPXRP[ecGdgXRGN")) { + KeyBoardCheatString[0] = ' '; + ChangePlayerModel("igsonny"); + } + // FOXYLITTLETHING + else if (!Cheat_strncmp(KeyBoardCheatString, "JSPIa`O[UTYa_oS")) { + KeyBoardCheatString[0] = ' '; + ChangePlayerModel("igmerc"); + } + // WELOVEOURDICK + else if (!Cheat_strncmp(KeyBoardCheatString, "NHPE_pRLWZYM^")) { + KeyBoardCheatString[0] = ' '; + ChangePlayerModel("igdick"); + } + // CHEATSHAVEBEENCRACKED + else if (!Cheat_strncmp(KeyBoardCheatString, "GJRDNmFUFPOM]aUYpTOKF")) { + KeyBoardCheatString[0] = ' '; + ChangePlayerModel("igdiaz"); + } + // SEAWAYS + else if (!Cheat_strncmp(KeyBoardCheatString, "V^HXN`V")) { + KeyBoardCheatString[0] = ' '; + BackToTheFuture(); + } + //CERTAINDEATH + else if (!Cheat_strncmp(KeyBoardCheatString, "KYHFQiLHU]RK")) { + KeyBoardCheatString[0] = ' '; + if (!CSmokeTrails::CigOn) + CSmokeTrails::CigOn = true; + else + CSmokeTrails::CigOn = false; + } // "ILOVESCOTLAND" if (!_CHEATCMP("DNALTOCSEVOLI")) RainyWeatherCheat(); @@ -1141,30 +1273,14 @@ void CPad::AddToPCCheatString(char c) if (!_CHEATCMP("REHTAEWDAM")) FastWeatherCheat(); - // "ANICESETOFWHEELS" - if (!_CHEATCMP("SLEEHWFOTESECINA")) - OnlyRenderWheelsCheat(); - // "CHITTYCHITTYBB" if (!_CHEATCMP("BBYTTIHCYTTIHC")) ChittyChittyBangBangCheat(); - // "CORNERSLIKEMAD" - if (!_CHEATCMP("DAMEKILSRENROC")) - StrongGripCheat(); - // "NASTYLIMBSCHEAT" if (!_CHEATCMP("TAEHCSBMILYTSAN")) NastyLimbsCheat(); - // "IWANTITPAINTEDBLACK" - if (!_CHEATCMP("KCALBDETNIAPTITNAWI")) - BlackCarsCheat(); - - // "AHAIRDRESSERSCAR" - if (!_CHEATCMP("RACSRESSERDRIAHA")) - PinkCarsCheat(); - #ifdef KANGAROO_CHEAT // "KANGAROO" if (!_CHEATCMP("OORAGNAK")) @@ -1199,10 +1315,6 @@ void CPad::AddToPCCheatString(char c) RenderWaterLayersCheat(); #endif - // SEAWAYS - if (!_CHEATCMP("SYAWAES")) - BackToTheFuture(); - #undef _CHEATCMP } diff --git a/src/render/Fluff.cpp b/src/render/Fluff.cpp index 1056d6ff..00267e30 100644 --- a/src/render/Fluff.cpp +++ b/src/render/Fluff.cpp @@ -13,6 +13,7 @@ #include "Stats.h" #include "maths.h" #include "Frontend.h" +#include "SmokeTrails.h" uint8 ScrollCharSet[59][5] = { { 0x00, 0x00, 0x00, 0x00, 0x00 }, // ' ' @@ -99,6 +100,8 @@ CMovingThing CMovingThings::aMovingThings[NUMMOVINGTHINGS]; void CMovingThings::Init() { + CSmokeTrails::Init(); + StartCloseList.m_pNext = &CMovingThings::EndCloseList; StartCloseList.m_pPrev = nil; EndCloseList.m_pNext = nil; @@ -189,6 +192,8 @@ void CMovingThings::Update() void CMovingThings::Render() { + CSmokeTrails::Update(); + int i; for (i = 0; i < 11; ++i) { @@ -205,6 +210,8 @@ void CMovingThings::Render() if (aDigitalClocks[i].IsVisible()) aDigitalClocks[i].Render(); } + + CSmokeTrails::Render(); } // ---------- CMovingThing ---------- diff --git a/src/render/SmokeTrails.cpp b/src/render/SmokeTrails.cpp new file mode 100644 index 00000000..3913c806 --- /dev/null +++ b/src/render/SmokeTrails.cpp @@ -0,0 +1,139 @@ +#include "common.h" +#include "SmokeTrails.h" +#include "Camera.h" +#include "World.h" +#include "CutsceneMgr.h" +#include "PlayerPed.h" +#include "Entity.h" +#include "rpworld.h" +#include "Bones.h" +#include "Timer.h" +#include "Weather.h" + +bool CSmokeTrails::CigOn = false; +CSmokeTrail CSmokeTrails::aSmoke[3]; + +extern RwImVertexIndex SmokeTrailIndices[32] = { 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, +9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16 }; + +float RandomSmoke[16] = { 10.0f, 5.0f, -1.0f, -9.0f, -7.0f, -1.0f, 0.0f, 3.0f, 6.0f, 7.0f, 4.0f, 2.0f, +5.0f, 7.0f }; + + +void +CSmokeTrail::RegisterPoint(CVector regPosition, float opacity) { + bool bShifted = false; + + if (m_time[0] && CTimer::GetTimeInMilliseconds() - m_time[0] > 150) { + bShifted = true; + for (int32 i = 15; i > 0; i--) { + m_pos[i] = m_pos[i - 1]; + m_time[i] = m_time[i - 1]; + m_density[i] = m_density[i - 1]; + } + ++m_seed; + } + m_pos[0] = regPosition; + + if (bShifted || !m_time[0]) { + m_time[0] = CTimer::GetTimeInMilliseconds(); + float currentDensity = 0.1f / (m_pos[1] - m_pos[2]).Magnitude(); + m_density[1] = opacity * Min(currentDensity, 1.0f); + } + m_density[0] = 0.0f; +} + +void +CSmokeTrail::Init(int num) { + for (int32 i = 0; i < 16; i++) + m_time[i] = 0; + m_seed = num * 2; +} + +void +CSmokeTrails::Init(void) { + for(int32 i = 0; i < 3; i++) + aSmoke[i].Init(i); +} + +void +CSmokeTrails::Render(void) { + for (int32 i = 0; i < 3; i++) + aSmoke[i].Render(); +} + +void +CSmokeTrail::Render(void) { + int numVerts = 0; + RwIm3DVertex TempVertexBuffer[16]; + + if (TheCamera.IsSphereVisible(m_pos[0], 10.0f)) { + for (int32 i = 0; i < 16; i++) { + int timeSinceSpawned = CTimer::GetTimeInMilliseconds() - m_time[i]; + + if (timeSinceSpawned > 2250) + m_time[i] = 0; + + if (m_time[i]) { + int alpha = (1.0f - timeSinceSpawned / 2250.0f) * 110.0f * m_density[i]; + float offset = timeSinceSpawned * CWeather::Wind * 0.000099f; + float currentX = (m_pos[i].x + timeSinceSpawned * RandomSmoke[(i - m_seed) & 0xF] * 0.0000099f) - offset; + float currentY = (m_pos[i].y + timeSinceSpawned * RandomSmoke[(i - m_seed + 5) & 0xF] * 0.0000099f) - offset; + float currentZ = m_pos[i].z + timeSinceSpawned * 0.00039f; + RwIm3DVertexSetRGBA(&TempVertexBuffer[i], 200, 200, 200, alpha); + RwIm3DVertexSetPos(&TempVertexBuffer[i], currentX, currentY, currentZ); + numVerts++; + } + } + } + + if (numVerts > 1) { + RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)TRUE); + RwRenderStateSet(rwRENDERSTATESRCBLEND, (void*)rwBLENDSRCALPHA); + RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void*)rwBLENDINVSRCALPHA); + RwRenderStateSet(rwRENDERSTATETEXTURERASTER, nil); + + if (RwIm3DTransform(TempVertexBuffer, numVerts, nil, rwIM3D_VERTEXXYZ | rwIM3D_VERTEXRGBA)) { + RwIm3DRenderIndexedPrimitive(rwPRIMTYPEPOLYLINE, SmokeTrailIndices, 2*(numVerts - 1)); + RwIm3DEnd(); + } + } +} + +void +CSmokeTrails::Update(void) { + + if (!CSmokeTrails::CigOn || TheCamera.Using1stPersonWeaponMode() || !FindPlayerPed() || + FindPlayerVehicle() || CCutsceneMgr::IsRunning() || !FindPlayerPed()->GetClump()) + return; + + RwV3d startPos = {0.026f, 0.15f, 0.02f}; + RwV3d endPos = {0.026f, 0.05f, 0.02f}; + + RpHAnimHierarchy *hier = GetAnimHierarchyFromSkinClump(FindPlayerPed()->GetClump()); + int32 idx = RpHAnimIDGetIndex(hier, ConvertPedNode2BoneTag(PED_HEAD)); + RwMatrix *head = &RpHAnimHierarchyGetMatrixArray(hier)[idx]; + RwV3dTransformPoints(&startPos, &startPos, 1, head); + RwV3dTransformPoints(&endPos, &endPos, 1, head); + + aSmoke[0].RegisterPoint(startPos, 1.0f); + aSmoke[1].RegisterPoint(startPos, 0.75f); + aSmoke[2].RegisterPoint(startPos, 0.5f); + + RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)FALSE); + RwRenderStateSet(rwRENDERSTATESRCBLEND, (void*)rwBLENDSRCALPHA); + RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void*)rwBLENDINVSRCALPHA); + RwRenderStateSet(rwRENDERSTATETEXTURERASTER, nil); + + int32 color = 255; + RwIm3DVertex TempVertexBuffer[2]; + RwIm3DVertexSetRGBA(&TempVertexBuffer[0], color, color, color, color); + RwIm3DVertexSetPos(&TempVertexBuffer[0], startPos.x, startPos.y, startPos.z); + RwIm3DVertexSetRGBA(&TempVertexBuffer[1], color, color, color, color); + RwIm3DVertexSetPos(&TempVertexBuffer[1], endPos.x, endPos.y, endPos.z); + + if (RwIm3DTransform(TempVertexBuffer, 2, nil, rwIM3D_VERTEXXYZ | rwIM3D_VERTEXRGBA)) { + RwIm3DRenderIndexedPrimitive(rwPRIMTYPEPOLYLINE, SmokeTrailIndices, 2); + RwIm3DEnd(); + } +} diff --git a/src/render/SmokeTrails.h b/src/render/SmokeTrails.h new file mode 100644 index 00000000..87fc8b2b --- /dev/null +++ b/src/render/SmokeTrails.h @@ -0,0 +1,23 @@ +#pragma once + +class CSmokeTrail { + CVector m_pos[16]; + float m_density[16]; + int m_time[16]; + char m_unused[536]; + int m_seed; +public: + void Render(void); + void RegisterPoint(CVector position, float a); + void Init(int num); +}; + +class CSmokeTrails { + static CSmokeTrail aSmoke[3]; +public: + static bool CigOn; + static void Update(void); + static void Render(void); + static void Init(void); +}; + -- cgit v1.2.3 From 287987b8fe46cf7e1d1258551e7a5f807e36bdd2 Mon Sep 17 00:00:00 2001 From: majestic Date: Wed, 10 Jun 2020 13:47:48 -0700 Subject: SmokeTrail(s) moved to Fluff, variables' names fixed, floats rounded --- src/core/Pad.cpp | 2 +- src/render/Fluff.cpp | 132 +++++++++++++++++++++++++++++++++++++++++- src/render/Fluff.h | 21 +++++++ src/render/SmokeTrails.cpp | 139 --------------------------------------------- src/render/SmokeTrails.h | 23 -------- 5 files changed, 153 insertions(+), 164 deletions(-) delete mode 100644 src/render/SmokeTrails.cpp delete mode 100644 src/render/SmokeTrails.h (limited to 'src') diff --git a/src/core/Pad.cpp b/src/core/Pad.cpp index c5d3f1b0..897923dd 100644 --- a/src/core/Pad.cpp +++ b/src/core/Pad.cpp @@ -37,7 +37,7 @@ #include "Wanted.h" #include "WaterLevel.h" #include "General.h" -#include "SmokeTrails.h" +#include "Fluff.h" CPad Pads[MAX_PADS]; CMousePointerStateHelper MousePointerStateHelper; diff --git a/src/render/Fluff.cpp b/src/render/Fluff.cpp index 00267e30..582468e7 100644 --- a/src/render/Fluff.cpp +++ b/src/render/Fluff.cpp @@ -13,7 +13,20 @@ #include "Stats.h" #include "maths.h" #include "Frontend.h" -#include "SmokeTrails.h" +#include "CutsceneMgr.h" +#include "PlayerPed.h" +#include "Bones.h" +#include "World.h" + + +bool CSmokeTrails::CigOn = false; +CSmokeTrail CSmokeTrails::aSmoke[3]; + +extern RwImVertexIndex SmokeTrailIndices[32] = { 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, +9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16 }; + +float RandomSmoke[16] = { 10.0f, 5.0f, -1.0f, -9.0f, -7.0f, -1.0f, 0.0f, 3.0f, 6.0f, 7.0f, 4.0f, 2.0f, +5.0f, 7.0f }; uint8 ScrollCharSet[59][5] = { { 0x00, 0x00, 0x00, 0x00, 0x00 }, // ' ' @@ -873,3 +886,120 @@ void CDigitalClock::Render() CSprite::FlushSpriteBuffer(); } } + +void +CSmokeTrail::RegisterPoint(CVector regPosition, float opacity) { + bool bAddedNewPoint = false; + + if (m_time[0] && CTimer::GetTimeInMilliseconds() - m_time[0] > 150) { + bAddedNewPoint = true; + for (int32 i = 15; i > 0; i--) { + m_pos[i] = m_pos[i - 1]; + m_time[i] = m_time[i - 1]; + m_density[i] = m_density[i - 1]; + } + ++m_seed; + } + m_pos[0] = regPosition; + + if (bAddedNewPoint || !m_time[0]) { + m_time[0] = CTimer::GetTimeInMilliseconds(); + float density = 0.1f / (m_pos[1] - m_pos[2]).Magnitude(); + m_density[1] = opacity * Min(density, 1.0f); + } + m_density[0] = 0.0f; +} + +void +CSmokeTrail::Init(int num) { + for (int32 i = 0; i < 16; i++) + m_time[i] = 0; + m_seed = num * 2; +} + +void +CSmokeTrails::Init(void) { + for (int32 i = 0; i < 3; i++) + aSmoke[i].Init(i); +} + +void +CSmokeTrails::Render(void) { + for (int32 i = 0; i < 3; i++) + aSmoke[i].Render(); +} + +void +CSmokeTrail::Render(void) { + int numVerts = 0; + RwIm3DVertex TempVertexBuffer[16]; + + if (TheCamera.IsSphereVisible(m_pos[0], 10.0f)) { + for (int32 i = 0; i < 16; i++) { + int timeSinceSpawned = CTimer::GetTimeInMilliseconds() - m_time[i]; + + if (timeSinceSpawned > 2250) + m_time[i] = 0; + + if (m_time[i]) { + int alpha = (1.0f - timeSinceSpawned / 2250.0f) * 110.0f * m_density[i]; + float offset = timeSinceSpawned * CWeather::Wind * 0.0001f; + float posX = (m_pos[i].x + timeSinceSpawned * RandomSmoke[(i - m_seed) & 0xF] * 0.00001f) - offset; + float posY = (m_pos[i].y + timeSinceSpawned * RandomSmoke[(i - m_seed + 5) & 0xF] * 0.00001f) - offset; + float posZ = m_pos[i].z + timeSinceSpawned * 0.0004f; + RwIm3DVertexSetRGBA(&TempVertexBuffer[i], 200, 200, 200, alpha); + RwIm3DVertexSetPos(&TempVertexBuffer[i], posX, posY, posZ); + numVerts++; + } + } + } + + if (numVerts > 1) { + RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)TRUE); + RwRenderStateSet(rwRENDERSTATESRCBLEND, (void*)rwBLENDSRCALPHA); + RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void*)rwBLENDINVSRCALPHA); + RwRenderStateSet(rwRENDERSTATETEXTURERASTER, nil); + + if (RwIm3DTransform(TempVertexBuffer, numVerts, nil, rwIM3D_VERTEXXYZ | rwIM3D_VERTEXRGBA)) { + RwIm3DRenderIndexedPrimitive(rwPRIMTYPEPOLYLINE, SmokeTrailIndices, 2 * (numVerts - 1)); + RwIm3DEnd(); + } + } +} + +void +CSmokeTrails::Update(void) { + + if (!CSmokeTrails::CigOn || TheCamera.Using1stPersonWeaponMode() || !FindPlayerPed() || + FindPlayerVehicle() || CCutsceneMgr::IsRunning() || !FindPlayerPed()->GetClump()) + return; + + RwV3d startPos = { 0.026f, 0.15f, 0.02f }; + RwV3d endPos = { 0.026f, 0.05f, 0.02f }; + + RpHAnimHierarchy *hier = GetAnimHierarchyFromSkinClump(FindPlayerPed()->GetClump()); + int32 idx = RpHAnimIDGetIndex(hier, ConvertPedNode2BoneTag(PED_HEAD)); + RwMatrix *head = &RpHAnimHierarchyGetMatrixArray(hier)[idx]; + RwV3dTransformPoints(&startPos, &startPos, 1, head); + RwV3dTransformPoints(&endPos, &endPos, 1, head); + + aSmoke[0].RegisterPoint(startPos, 1.0f); + aSmoke[1].RegisterPoint(startPos, 0.75f); + aSmoke[2].RegisterPoint(startPos, 0.5f); + + RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)FALSE); + RwRenderStateSet(rwRENDERSTATESRCBLEND, (void*)rwBLENDSRCALPHA); + RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void*)rwBLENDINVSRCALPHA); + RwRenderStateSet(rwRENDERSTATETEXTURERASTER, nil); + + RwIm3DVertex TempVertexBuffer[2]; + RwIm3DVertexSetRGBA(&TempVertexBuffer[0], 255, 255, 255, 255); + RwIm3DVertexSetPos(&TempVertexBuffer[0], startPos.x, startPos.y, startPos.z); + RwIm3DVertexSetRGBA(&TempVertexBuffer[1], 255, 255, 255, 255); + RwIm3DVertexSetPos(&TempVertexBuffer[1], endPos.x, endPos.y, endPos.z); + + if (RwIm3DTransform(TempVertexBuffer, 2, nil, rwIM3D_VERTEXXYZ | rwIM3D_VERTEXRGBA)) { + RwIm3DRenderIndexedPrimitive(rwPRIMTYPEPOLYLINE, SmokeTrailIndices, 2); + RwIm3DEnd(); + } +} \ No newline at end of file diff --git a/src/render/Fluff.h b/src/render/Fluff.h index fe3ab256..958de5b5 100644 --- a/src/render/Fluff.h +++ b/src/render/Fluff.h @@ -103,4 +103,25 @@ public: void Init(CVector, float, float, uint8, uint8, uint8, float, float); void Update(); void Render(); +}; + +class CSmokeTrail { + CVector m_pos[16]; + float m_density[16]; + int m_time[16]; + char m_unused[536]; + int m_seed; +public: + void Render(void); + void RegisterPoint(CVector position, float a); + void Init(int num); +}; + +class CSmokeTrails { + static CSmokeTrail aSmoke[3]; +public: + static bool CigOn; + static void Update(void); + static void Render(void); + static void Init(void); }; \ No newline at end of file diff --git a/src/render/SmokeTrails.cpp b/src/render/SmokeTrails.cpp deleted file mode 100644 index 3913c806..00000000 --- a/src/render/SmokeTrails.cpp +++ /dev/null @@ -1,139 +0,0 @@ -#include "common.h" -#include "SmokeTrails.h" -#include "Camera.h" -#include "World.h" -#include "CutsceneMgr.h" -#include "PlayerPed.h" -#include "Entity.h" -#include "rpworld.h" -#include "Bones.h" -#include "Timer.h" -#include "Weather.h" - -bool CSmokeTrails::CigOn = false; -CSmokeTrail CSmokeTrails::aSmoke[3]; - -extern RwImVertexIndex SmokeTrailIndices[32] = { 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, -9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16 }; - -float RandomSmoke[16] = { 10.0f, 5.0f, -1.0f, -9.0f, -7.0f, -1.0f, 0.0f, 3.0f, 6.0f, 7.0f, 4.0f, 2.0f, -5.0f, 7.0f }; - - -void -CSmokeTrail::RegisterPoint(CVector regPosition, float opacity) { - bool bShifted = false; - - if (m_time[0] && CTimer::GetTimeInMilliseconds() - m_time[0] > 150) { - bShifted = true; - for (int32 i = 15; i > 0; i--) { - m_pos[i] = m_pos[i - 1]; - m_time[i] = m_time[i - 1]; - m_density[i] = m_density[i - 1]; - } - ++m_seed; - } - m_pos[0] = regPosition; - - if (bShifted || !m_time[0]) { - m_time[0] = CTimer::GetTimeInMilliseconds(); - float currentDensity = 0.1f / (m_pos[1] - m_pos[2]).Magnitude(); - m_density[1] = opacity * Min(currentDensity, 1.0f); - } - m_density[0] = 0.0f; -} - -void -CSmokeTrail::Init(int num) { - for (int32 i = 0; i < 16; i++) - m_time[i] = 0; - m_seed = num * 2; -} - -void -CSmokeTrails::Init(void) { - for(int32 i = 0; i < 3; i++) - aSmoke[i].Init(i); -} - -void -CSmokeTrails::Render(void) { - for (int32 i = 0; i < 3; i++) - aSmoke[i].Render(); -} - -void -CSmokeTrail::Render(void) { - int numVerts = 0; - RwIm3DVertex TempVertexBuffer[16]; - - if (TheCamera.IsSphereVisible(m_pos[0], 10.0f)) { - for (int32 i = 0; i < 16; i++) { - int timeSinceSpawned = CTimer::GetTimeInMilliseconds() - m_time[i]; - - if (timeSinceSpawned > 2250) - m_time[i] = 0; - - if (m_time[i]) { - int alpha = (1.0f - timeSinceSpawned / 2250.0f) * 110.0f * m_density[i]; - float offset = timeSinceSpawned * CWeather::Wind * 0.000099f; - float currentX = (m_pos[i].x + timeSinceSpawned * RandomSmoke[(i - m_seed) & 0xF] * 0.0000099f) - offset; - float currentY = (m_pos[i].y + timeSinceSpawned * RandomSmoke[(i - m_seed + 5) & 0xF] * 0.0000099f) - offset; - float currentZ = m_pos[i].z + timeSinceSpawned * 0.00039f; - RwIm3DVertexSetRGBA(&TempVertexBuffer[i], 200, 200, 200, alpha); - RwIm3DVertexSetPos(&TempVertexBuffer[i], currentX, currentY, currentZ); - numVerts++; - } - } - } - - if (numVerts > 1) { - RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)TRUE); - RwRenderStateSet(rwRENDERSTATESRCBLEND, (void*)rwBLENDSRCALPHA); - RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void*)rwBLENDINVSRCALPHA); - RwRenderStateSet(rwRENDERSTATETEXTURERASTER, nil); - - if (RwIm3DTransform(TempVertexBuffer, numVerts, nil, rwIM3D_VERTEXXYZ | rwIM3D_VERTEXRGBA)) { - RwIm3DRenderIndexedPrimitive(rwPRIMTYPEPOLYLINE, SmokeTrailIndices, 2*(numVerts - 1)); - RwIm3DEnd(); - } - } -} - -void -CSmokeTrails::Update(void) { - - if (!CSmokeTrails::CigOn || TheCamera.Using1stPersonWeaponMode() || !FindPlayerPed() || - FindPlayerVehicle() || CCutsceneMgr::IsRunning() || !FindPlayerPed()->GetClump()) - return; - - RwV3d startPos = {0.026f, 0.15f, 0.02f}; - RwV3d endPos = {0.026f, 0.05f, 0.02f}; - - RpHAnimHierarchy *hier = GetAnimHierarchyFromSkinClump(FindPlayerPed()->GetClump()); - int32 idx = RpHAnimIDGetIndex(hier, ConvertPedNode2BoneTag(PED_HEAD)); - RwMatrix *head = &RpHAnimHierarchyGetMatrixArray(hier)[idx]; - RwV3dTransformPoints(&startPos, &startPos, 1, head); - RwV3dTransformPoints(&endPos, &endPos, 1, head); - - aSmoke[0].RegisterPoint(startPos, 1.0f); - aSmoke[1].RegisterPoint(startPos, 0.75f); - aSmoke[2].RegisterPoint(startPos, 0.5f); - - RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)FALSE); - RwRenderStateSet(rwRENDERSTATESRCBLEND, (void*)rwBLENDSRCALPHA); - RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void*)rwBLENDINVSRCALPHA); - RwRenderStateSet(rwRENDERSTATETEXTURERASTER, nil); - - int32 color = 255; - RwIm3DVertex TempVertexBuffer[2]; - RwIm3DVertexSetRGBA(&TempVertexBuffer[0], color, color, color, color); - RwIm3DVertexSetPos(&TempVertexBuffer[0], startPos.x, startPos.y, startPos.z); - RwIm3DVertexSetRGBA(&TempVertexBuffer[1], color, color, color, color); - RwIm3DVertexSetPos(&TempVertexBuffer[1], endPos.x, endPos.y, endPos.z); - - if (RwIm3DTransform(TempVertexBuffer, 2, nil, rwIM3D_VERTEXXYZ | rwIM3D_VERTEXRGBA)) { - RwIm3DRenderIndexedPrimitive(rwPRIMTYPEPOLYLINE, SmokeTrailIndices, 2); - RwIm3DEnd(); - } -} diff --git a/src/render/SmokeTrails.h b/src/render/SmokeTrails.h deleted file mode 100644 index 87fc8b2b..00000000 --- a/src/render/SmokeTrails.h +++ /dev/null @@ -1,23 +0,0 @@ -#pragma once - -class CSmokeTrail { - CVector m_pos[16]; - float m_density[16]; - int m_time[16]; - char m_unused[536]; - int m_seed; -public: - void Render(void); - void RegisterPoint(CVector position, float a); - void Init(int num); -}; - -class CSmokeTrails { - static CSmokeTrail aSmoke[3]; -public: - static bool CigOn; - static void Update(void); - static void Render(void); - static void Init(void); -}; - -- cgit v1.2.3 From cf8fcada6e9989c7c5ea88a797b98914de815aec Mon Sep 17 00:00:00 2001 From: majestic Date: Wed, 10 Jun 2020 14:01:37 -0700 Subject: m_density renamed to m_opacity --- src/render/Fluff.cpp | 8 ++++---- src/render/Fluff.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/render/Fluff.cpp b/src/render/Fluff.cpp index 582468e7..9074ee66 100644 --- a/src/render/Fluff.cpp +++ b/src/render/Fluff.cpp @@ -896,7 +896,7 @@ CSmokeTrail::RegisterPoint(CVector regPosition, float opacity) { for (int32 i = 15; i > 0; i--) { m_pos[i] = m_pos[i - 1]; m_time[i] = m_time[i - 1]; - m_density[i] = m_density[i - 1]; + m_opacity[i] = m_opacity[i - 1]; } ++m_seed; } @@ -905,9 +905,9 @@ CSmokeTrail::RegisterPoint(CVector regPosition, float opacity) { if (bAddedNewPoint || !m_time[0]) { m_time[0] = CTimer::GetTimeInMilliseconds(); float density = 0.1f / (m_pos[1] - m_pos[2]).Magnitude(); - m_density[1] = opacity * Min(density, 1.0f); + m_opacity[1] = opacity * Min(density, 1.0f); } - m_density[0] = 0.0f; + m_opacity[0] = 0.0f; } void @@ -942,7 +942,7 @@ CSmokeTrail::Render(void) { m_time[i] = 0; if (m_time[i]) { - int alpha = (1.0f - timeSinceSpawned / 2250.0f) * 110.0f * m_density[i]; + int alpha = (1.0f - timeSinceSpawned / 2250.0f) * 110.0f * m_opacity[i]; float offset = timeSinceSpawned * CWeather::Wind * 0.0001f; float posX = (m_pos[i].x + timeSinceSpawned * RandomSmoke[(i - m_seed) & 0xF] * 0.00001f) - offset; float posY = (m_pos[i].y + timeSinceSpawned * RandomSmoke[(i - m_seed + 5) & 0xF] * 0.00001f) - offset; diff --git a/src/render/Fluff.h b/src/render/Fluff.h index 958de5b5..41db75ec 100644 --- a/src/render/Fluff.h +++ b/src/render/Fluff.h @@ -107,7 +107,7 @@ public: class CSmokeTrail { CVector m_pos[16]; - float m_density[16]; + float m_opacity[16]; int m_time[16]; char m_unused[536]; int m_seed; -- cgit v1.2.3 From 669db1a2937a259f22318093d0cab080cefc3a60 Mon Sep 17 00:00:00 2001 From: majestic Date: Wed, 10 Jun 2020 23:26:51 -0700 Subject: minigun rotation fix --- src/peds/Ped.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/peds/Ped.cpp b/src/peds/Ped.cpp index 1c5e5ce5..16029a4f 100644 --- a/src/peds/Ped.cpp +++ b/src/peds/Ped.cpp @@ -13423,6 +13423,7 @@ CPed::Render(void) // TODO(Miami): What are those numbers?! // localAdjMat.Rotate(flt_691FFC * flt_97F878, flt_691FF8 * flt_97F87C, flt_691FF4 * flt_97F880); + localAdjMat.Rotate(0.078f, -0.519f, -0.0185f); localAdjMat.GetPosition() += CVector(0.829f, -0.001f, 0.226f); mgTopMat = mgTopMat * localAdjMat; mgTopMat.UpdateRW(); -- cgit v1.2.3 From 94e3c3005448fef54b73e6eea3912532e2dfdd47 Mon Sep 17 00:00:00 2001 From: majestic Date: Thu, 11 Jun 2020 00:59:23 -0700 Subject: original multiplying rotational cords for minigun --- src/peds/Ped.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/peds/Ped.cpp b/src/peds/Ped.cpp index 16029a4f..0395abff 100644 --- a/src/peds/Ped.cpp +++ b/src/peds/Ped.cpp @@ -13389,6 +13389,8 @@ CPed::PossiblyFindBetterPosToSeekCar(CVector *pos, CVehicle *veh) return true; } +extern CVector vecTestTemp(-1.0f, -1.0f, -1.0f); + // --MIAMI: Done except comment void CPed::Render(void) @@ -13423,7 +13425,10 @@ CPed::Render(void) // TODO(Miami): What are those numbers?! // localAdjMat.Rotate(flt_691FFC * flt_97F878, flt_691FF8 * flt_97F87C, flt_691FF4 * flt_97F880); - localAdjMat.Rotate(0.078f, -0.519f, -0.0185f); + float rotX = DEGTORAD(-4.469f)* vecTestTemp.x; + float rotY = DEGTORAD(27.736f) * vecTestTemp.y; + float rotZ = DEGTORAD(1.064f) * vecTestTemp.z; + localAdjMat.Rotate(rotX, rotY, rotZ); localAdjMat.GetPosition() += CVector(0.829f, -0.001f, 0.226f); mgTopMat = mgTopMat * localAdjMat; mgTopMat.UpdateRW(); -- cgit v1.2.3 From 2cc8ecbb90b044fc10829d14dc7e21d46af826e1 Mon Sep 17 00:00:00 2001 From: majestic Date: Thu, 11 Jun 2020 01:36:45 -0700 Subject: removed extern from RwImVertexIndex SmokeTrailIndices and additional rotational variables for minigun --- src/peds/Ped.cpp | 8 +------- src/render/Fluff.cpp | 2 +- 2 files changed, 2 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/peds/Ped.cpp b/src/peds/Ped.cpp index 0395abff..785050c9 100644 --- a/src/peds/Ped.cpp +++ b/src/peds/Ped.cpp @@ -13422,13 +13422,7 @@ CPed::Render(void) CMatrix mgTopMat, localAdjMat; mgTopMat.Attach(RwFrameGetMatrix(frame)); localAdjMat.SetRotateX(player->m_fGunSpinAngle); - - // TODO(Miami): What are those numbers?! - // localAdjMat.Rotate(flt_691FFC * flt_97F878, flt_691FF8 * flt_97F87C, flt_691FF4 * flt_97F880); - float rotX = DEGTORAD(-4.469f)* vecTestTemp.x; - float rotY = DEGTORAD(27.736f) * vecTestTemp.y; - float rotZ = DEGTORAD(1.064f) * vecTestTemp.z; - localAdjMat.Rotate(rotX, rotY, rotZ); + localAdjMat.Rotate(DEGTORAD(-4.477f)* vecTestTemp.x, DEGTORAD(29.731f) * vecTestTemp.y, DEGTORAD(1.064f) * vecTestTemp.z); localAdjMat.GetPosition() += CVector(0.829f, -0.001f, 0.226f); mgTopMat = mgTopMat * localAdjMat; mgTopMat.UpdateRW(); diff --git a/src/render/Fluff.cpp b/src/render/Fluff.cpp index 9074ee66..9770eb0a 100644 --- a/src/render/Fluff.cpp +++ b/src/render/Fluff.cpp @@ -22,7 +22,7 @@ bool CSmokeTrails::CigOn = false; CSmokeTrail CSmokeTrails::aSmoke[3]; -extern RwImVertexIndex SmokeTrailIndices[32] = { 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, +RwImVertexIndex SmokeTrailIndices[32] = { 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16 }; float RandomSmoke[16] = { 10.0f, 5.0f, -1.0f, -9.0f, -7.0f, -1.0f, 0.0f, 3.0f, 6.0f, 7.0f, 4.0f, 2.0f, -- cgit v1.2.3