[Debug]: Draw lines from riot shield (#670)
This commit is contained in:
@ -6,6 +6,14 @@ namespace Components
|
||||
Dvar::Var Bullet::BGSurfacePenetration;
|
||||
Game::dvar_t* Bullet::BGBulletRange;
|
||||
|
||||
float Bullet::ContactPointSave[3];
|
||||
float Bullet::VCSave[3];
|
||||
float Bullet::CalcRicochetSave[3];
|
||||
|
||||
float Bullet::ColorYellow[] = {1.0f, 1.0f, 0.0f, 1.0f};
|
||||
float Bullet::ColorBlue[] = {0.0f, 0.0f, 1.0f, 1.0f};
|
||||
float Bullet::ColorOrange[] = {1.0f, 0.7f, 0.0f, 1.0f};
|
||||
|
||||
float Bullet::BG_GetSurfacePenetrationDepthStub(const Game::WeaponDef* weapDef, int surfaceType)
|
||||
{
|
||||
assert(weapDef);
|
||||
@ -48,6 +56,63 @@ namespace Components
|
||||
*pHoldrand = static_cast<unsigned int>(std::rand());
|
||||
}
|
||||
|
||||
void Bullet::BulletRicochet_Save(const float* contactPoint)
|
||||
{
|
||||
std::memcpy(ContactPointSave, contactPoint, sizeof(float[3]));
|
||||
}
|
||||
|
||||
__declspec(naked) void Bullet::BulletRicochet_Stub()
|
||||
{
|
||||
__asm
|
||||
{
|
||||
pushad
|
||||
push [esp + 0x20 + 0xC]
|
||||
call BulletRicochet_Save
|
||||
add esp, 0x4
|
||||
popad
|
||||
|
||||
// Game's code
|
||||
sub esp, 0x4C
|
||||
push ebp
|
||||
mov ebp, dword ptr [esp + 0x60]
|
||||
|
||||
push 0x5D5B08
|
||||
ret
|
||||
}
|
||||
}
|
||||
|
||||
void Bullet::_VectorMA_Stub(float* va, float scale, float* vb, float* vc)
|
||||
{
|
||||
vc[0] = va[0] + scale * vb[0];
|
||||
vc[1] = va[1] + scale * vb[1];
|
||||
vc[2] = va[2] + scale * vb[2];
|
||||
|
||||
std::memcpy(VCSave, vc, sizeof(float[3]));
|
||||
}
|
||||
|
||||
void Bullet::CalcRicochet_Stub(const float* incoming, const float* normal, float* result)
|
||||
{
|
||||
Utils::Hook::Call<void(const float*, const float*, float*)>(0x5D59F0)(incoming, normal, result);
|
||||
std::memcpy(CalcRicochetSave, result, sizeof(float[3]));
|
||||
}
|
||||
|
||||
int Bullet::Bullet_Fire_Stub(Game::gentity_s* attacker, [[maybe_unused]] float spread, Game::weaponParms* wp, Game::gentity_s* weaponEnt, Game::PlayerHandIndex hand, int gameTime)
|
||||
{
|
||||
float tmp[3];
|
||||
|
||||
Game::G_DebugStar(ContactPointSave, ColorYellow);
|
||||
|
||||
tmp[0] = (CalcRicochetSave[0] * 100.0f) + VCSave[0];
|
||||
tmp[1] = (CalcRicochetSave[1] * 100.0f) + VCSave[1];
|
||||
tmp[2] = (CalcRicochetSave[2] * 100.0f) + VCSave[1];
|
||||
|
||||
Game::G_DebugLineWithDuration(VCSave, tmp, ColorOrange, 1, 100);
|
||||
Game::G_DebugStar(tmp, ColorBlue);
|
||||
|
||||
// Set the spread to 0 when drawing
|
||||
return Game::Bullet_Fire(attacker, 0.0f, wp, weaponEnt, hand, gameTime);
|
||||
}
|
||||
|
||||
Bullet::Bullet()
|
||||
{
|
||||
BGSurfacePenetration = Dvar::Register<float>("bg_surfacePenetration", 0.0f,
|
||||
@ -59,5 +124,20 @@ namespace Components
|
||||
Utils::Hook(0x440340, Bullet_FireStub, HOOK_JUMP).install()->quick();
|
||||
|
||||
Utils::Hook(0x440368, BG_srand_Hk, HOOK_CALL).install()->quick();
|
||||
|
||||
std::memset(ContactPointSave, 0, sizeof(float[3]));
|
||||
std::memset(VCSave, 0, sizeof(float[3]));
|
||||
std::memset(CalcRicochetSave, 0, sizeof(float[3]));
|
||||
|
||||
#ifdef DEBUG_RIOT_SHIELD
|
||||
Utils::Hook(0x5D5B00, BulletRicochet_Stub, HOOK_JUMP).install()->quick();
|
||||
Utils::Hook::Nop(0x5D5B00 + 5, 3);
|
||||
|
||||
Utils::Hook(0x5D5BBA, CalcRicochet_Stub, HOOK_CALL).install()->quick();
|
||||
|
||||
Utils::Hook(0x5D5BD7, _VectorMA_Stub, HOOK_CALL).install()->quick();
|
||||
|
||||
Utils::Hook(0x5D5C0B, Bullet_Fire_Stub, HOOK_CALL).install()->quick();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
@ -12,10 +12,27 @@ namespace Components
|
||||
// Can't use Var class inside assembly stubs
|
||||
static Game::dvar_t* BGBulletRange;
|
||||
|
||||
static float ContactPointSave[];
|
||||
static float VCSave[];
|
||||
static float CalcRicochetSave[];
|
||||
|
||||
static float ColorYellow[];
|
||||
static float ColorBlue[];
|
||||
static float ColorOrange[];
|
||||
|
||||
static float BG_GetSurfacePenetrationDepthStub(const Game::WeaponDef* weapDef, int surfaceType);
|
||||
|
||||
static void Bullet_FireStub();
|
||||
|
||||
static void BG_srand_Hk(unsigned int* pHoldrand);
|
||||
|
||||
static void BulletRicochet_Save(const float* contactPoint);
|
||||
static void BulletRicochet_Stub();
|
||||
|
||||
static void CalcRicochet_Stub(const float* incoming, const float* normal, float* result);
|
||||
|
||||
static void _VectorMA_Stub(float* va, float scale, float* vb, float* vc);
|
||||
|
||||
static int Bullet_Fire_Stub(Game::gentity_s* attacker, float spread, Game::weaponParms* wp, Game::gentity_s* weaponEnt, Game::PlayerHandIndex hand, int gameTime);
|
||||
};
|
||||
}
|
||||
|
@ -94,15 +94,15 @@ namespace Components
|
||||
"EF_SOFT",
|
||||
};
|
||||
|
||||
const char Debug::strButtons[] =
|
||||
const char Debug::StrButtons[] =
|
||||
{
|
||||
'\x01', '\x02', '\x03', '\x04', '\x05', '\x06', '\x0E', '\x0F', '\x10',
|
||||
'\x11', '\x12', '\x13', '\x14', '\x15', '\x16', '\x17', '\0'
|
||||
};
|
||||
|
||||
const char Debug::strTemplate[] = "%s: %s All those moments will be lost in time, like tears in rain.";
|
||||
const char Debug::StrTemplate[] = "%s: %s All those moments will be lost in time, like tears in rain.";
|
||||
|
||||
const float Debug::colorWhite[] = {1.0f, 1.0f, 1.0f, 1.0f};
|
||||
const float Debug::ColorWhite[] = {1.0f, 1.0f, 1.0f, 1.0f};
|
||||
|
||||
std::string Debug::BuildPMFlagsString(const Game::playerState_s* ps)
|
||||
{
|
||||
@ -163,19 +163,19 @@ namespace Components
|
||||
auto* const font2 = Game::UI_GetFontHandle(scrPlace, 6, MY_SCALE2);
|
||||
|
||||
Game::UI_DrawText(scrPlace, "Client View of Flags", maxChars, font2, -60.0f, 0, 1, 1,
|
||||
MY_SCALE2, colorWhite, 1);
|
||||
MY_SCALE2, ColorWhite, 1);
|
||||
|
||||
const auto pmf = BuildPMFlagsString(&cgameGlob->predictedPlayerState);
|
||||
Game::UI_DrawText(scrPlace, pmf.data(), maxChars, font1, 30.0f, MY_Y, 1, 1, MY_SCALE_2, colorWhite, 3);
|
||||
Game::UI_DrawText(scrPlace, pmf.data(), maxChars, font1, 30.0f, MY_Y, 1, 1, MY_SCALE_2, ColorWhite, 3);
|
||||
|
||||
const auto pof = BuildPOFlagsString(&cgameGlob->predictedPlayerState);
|
||||
Game::UI_DrawText(scrPlace, pof.data(), maxChars, font1, 350.0f, MY_Y, 1, 1, MY_SCALE_2, colorWhite, 3);
|
||||
Game::UI_DrawText(scrPlace, pof.data(), maxChars, font1, 350.0f, MY_Y, 1, 1, MY_SCALE_2, ColorWhite, 3);
|
||||
|
||||
const auto plf = BuildPLFlagsString(&cgameGlob->predictedPlayerState);
|
||||
Game::UI_DrawText(scrPlace, plf.data(), maxChars, font1, 350.0f, 250.0f, 1, 1, MY_SCALE_2, colorWhite, 3);
|
||||
Game::UI_DrawText(scrPlace, plf.data(), maxChars, font1, 350.0f, 250.0f, 1, 1, MY_SCALE_2, ColorWhite, 3);
|
||||
|
||||
const auto pef = BuildPEFlagsString(&cgameGlob->predictedPlayerState);
|
||||
Game::UI_DrawText(scrPlace, pef.data(), maxChars, font1, 525.0f, MY_Y, 1, 1, MY_SCALE_2, colorWhite, 3);
|
||||
Game::UI_DrawText(scrPlace, pef.data(), maxChars, font1, 525.0f, MY_Y, 1, 1, MY_SCALE_2, ColorWhite, 3);
|
||||
}
|
||||
|
||||
void Debug::CG_DrawDebugPlayerHealth(const int localClientNum)
|
||||
@ -221,25 +221,25 @@ namespace Components
|
||||
auto* const font5 = Game::UI_GetFontHandle(scrPlace, 5, 0.4f);
|
||||
auto* const font6 = Game::UI_GetFontHandle(scrPlace, 6, 0.4f);
|
||||
|
||||
sprintf_s(strFinal, strTemplate, font1->fontName, strButtons);
|
||||
sprintf_s(strFinal, StrTemplate, font1->fontName, StrButtons);
|
||||
Game::UI_FilterStringForButtonAnimation(strFinal, sizeof(strFinal));
|
||||
Game::UI_DrawText(scrPlace, strFinal, std::numeric_limits<int>::max(), font1, MY_X, 10.0f, 1, 1, 0.4f, colorWhite, 3);
|
||||
Game::UI_DrawText(scrPlace, strFinal, std::numeric_limits<int>::max(), font1, MY_X, 10.0f, 1, 1, 0.4f, ColorWhite, 3);
|
||||
|
||||
sprintf_s(strFinal, strTemplate, font2->fontName, strButtons);
|
||||
sprintf_s(strFinal, StrTemplate, font2->fontName, StrButtons);
|
||||
Game::UI_FilterStringForButtonAnimation(strFinal, sizeof(strFinal));
|
||||
Game::UI_DrawText(scrPlace, strFinal, std::numeric_limits<int>::max(), font2, MY_X, 35.0f, 1, 1, 0.4f, colorWhite, 3);
|
||||
Game::UI_DrawText(scrPlace, strFinal, std::numeric_limits<int>::max(), font2, MY_X, 35.0f, 1, 1, 0.4f, ColorWhite, 3);
|
||||
|
||||
sprintf_s(strFinal, strTemplate, font3->fontName, strButtons);
|
||||
sprintf_s(strFinal, StrTemplate, font3->fontName, StrButtons);
|
||||
Game::UI_FilterStringForButtonAnimation(strFinal, sizeof(strFinal));
|
||||
Game::UI_DrawText(scrPlace, strFinal, std::numeric_limits<int>::max(), font3, MY_X, 60.0f, 1, 1, 0.4f, colorWhite, 3);
|
||||
Game::UI_DrawText(scrPlace, strFinal, std::numeric_limits<int>::max(), font3, MY_X, 60.0f, 1, 1, 0.4f, ColorWhite, 3);
|
||||
|
||||
sprintf_s(strFinal, strTemplate, font5->fontName, strButtons);
|
||||
sprintf_s(strFinal, StrTemplate, font5->fontName, StrButtons);
|
||||
Game::UI_FilterStringForButtonAnimation(strFinal, sizeof(strFinal));
|
||||
Game::UI_DrawText(scrPlace, strFinal, std::numeric_limits<int>::max(), font5, MY_X, 85.0f, 1, 1, 0.4f, colorWhite, 3);
|
||||
Game::UI_DrawText(scrPlace, strFinal, std::numeric_limits<int>::max(), font5, MY_X, 85.0f, 1, 1, 0.4f, ColorWhite, 3);
|
||||
|
||||
sprintf_s(strFinal, strTemplate, font6->fontName, strButtons);
|
||||
sprintf_s(strFinal, StrTemplate, font6->fontName, StrButtons);
|
||||
Game::UI_FilterStringForButtonAnimation(strFinal, sizeof(strFinal));
|
||||
Game::UI_DrawText(scrPlace, strFinal, std::numeric_limits<int>::max(), font6, MY_X, 110.0f, 1, 1, 0.4f, colorWhite, 3);
|
||||
Game::UI_DrawText(scrPlace, strFinal, std::numeric_limits<int>::max(), font6, MY_X, 110.0f, 1, 1, 0.4f, ColorWhite, 3);
|
||||
}
|
||||
|
||||
void Debug::CG_DrawDebugOverlays_Hk(const int localClientNum)
|
||||
|
@ -19,8 +19,8 @@ namespace Components
|
||||
static const char* PLFlagsValues[];
|
||||
static const char* PEFlagsValues[];
|
||||
|
||||
static const char strButtons[];
|
||||
static const char strTemplate[];
|
||||
static const char StrButtons[];
|
||||
static const char StrTemplate[];
|
||||
|
||||
static constexpr auto MY_SCALE2 = 0.5f;
|
||||
static constexpr auto MY_SCALE_2 = 0.201f;
|
||||
@ -28,7 +28,7 @@ namespace Components
|
||||
static constexpr auto MY_X = -25.0f;
|
||||
static constexpr auto MY_Y = 20.0f;
|
||||
|
||||
static const float colorWhite[];
|
||||
static const float ColorWhite[];
|
||||
|
||||
static std::string BuildPMFlagsString(const Game::playerState_s* ps);
|
||||
static std::string BuildPOFlagsString(const Game::playerState_s* ps);
|
||||
|
@ -751,7 +751,7 @@ namespace Components
|
||||
-yawRight
|
||||
};
|
||||
|
||||
Game::cgArray[0].selectedLocationAngle = Game::AngleNormalize360(Game::vectoyaw(&vec));
|
||||
Game::cgArray[0].selectedLocationAngle = Game::AngleNormalize360(Game::vectoryaw(&vec));
|
||||
Game::cgArray[0].selectedAngleLocation[0] = Game::cgArray[0].selectedLocation[0];
|
||||
Game::cgArray[0].selectedAngleLocation[1] = Game::cgArray[0].selectedLocation[1];
|
||||
}
|
||||
|
Reference in New Issue
Block a user