ППХУДЕР
-
Автор темы
- #1
Кароче, захотел поверх регуляров сделать глоу. Крашит, дебаг тоже...
Что я сделал нетак?
база csgosimple
Что я сделал нетак?
C++:
#include "chams.hpp"
#include <fstream>
#include "../valve_sdk/csgostructs.hpp"
#include "../options.hpp"
#include "../hooks.hpp"
#include "../helpers/input.hpp"
Chams::Chams() {
materialRegular = g_MatSystem->FindMaterial("debug/debugambientcube");
materialFlat = g_MatSystem->FindMaterial("debug/debugdrawflat");
materialGlow = g_MatSystem->FindMaterial("regular_glow");
}
Chams::~Chams() {
}
void Chams::OverrideMaterial(bool ignoreZ, bool flat, bool wireframe, bool glass, const Color& rgba, const Color& rgba2) {
Color col = rgba2;
bool bFound = false;
IMaterial* material = nullptr;
IMaterial* material_style = nullptr;
if (flat) {
material = materialFlat;
}
if (g_Options.chams_player_glow) {
material_style = materialGlow;
}
material->SetMaterialVarFlag(MATERIAL_VAR_IGNOREZ, ignoreZ);
if (glass) {
material = materialFlat;
material->AlphaModulate(0.45f);
}
else {
material->AlphaModulate(
rgba.a() / 255.0f);
}
material->SetMaterialVarFlag(MATERIAL_VAR_WIREFRAME, wireframe);
material->ColorModulate(
rgba.r() / 255.0f,
rgba.g() / 255.0f,
rgba.b() / 255.0f);
material_style->ColorModulate(
rgba.r() / 255.0f,
rgba.g() / 255.0f,
rgba.b() / 255.0f);
g_MdlRender->ForcedMaterialOverride(material);
g_MdlRender->ForcedMaterialOverride(material_style);
}
void Chams::OnDrawModelExecute(
IMatRenderContext* ctx,
const DrawModelState_t& state,
const ModelRenderInfo_t& info,
matrix3x4_t* matrix)
{
static auto fnDME = Hooks::mdlrender_hook.get_original<decltype(&Hooks::hkDrawModelExecute)>(index::DrawModelExecute);
const auto mdl = info.pModel;
bool is_arm = strstr(mdl->szName, "arms") != nullptr;
bool is_player = strstr(mdl->szName, "models/player") != nullptr;
bool is_sleeve = strstr(mdl->szName, "sleeve") != nullptr;
//bool is_weapon = strstr(mdl->szName, "weapons/v_") != nullptr;
if (is_player && g_Options.chams_player_enabled) {
//
// Draw player Chams.
//
auto ent = C_BasePlayer::GetPlayerByIndex(info.entity_index);
if (ent && g_LocalPlayer && ent->IsAlive()) {
const auto enemy = ent->m_iTeamNum() != g_LocalPlayer->m_iTeamNum();
if (!enemy && g_Options.chams_player_enemies_only)
return;
const auto clr_front = enemy ? g_Options.color_chams_player_enemy_visible : g_Options.color_chams_player_ally_visible;
const auto clr_back = enemy ? g_Options.color_chams_player_enemy_occluded : g_Options.color_chams_player_ally_occluded;
if (g_Options.chams_player_ignorez) {
OverrideMaterial(
true,
g_Options.chams_player_flat,
g_Options.chams_player_wireframe,
false,
clr_back,
g_Options.color_chams_player_glow);
fnDME(g_MdlRender, 0, ctx, state, info, matrix);
OverrideMaterial(
false,
g_Options.chams_player_flat,
g_Options.chams_player_wireframe,
false,
clr_front,
g_Options.color_chams_player_glow);
}
else {
OverrideMaterial(
false,
g_Options.chams_player_flat,
g_Options.chams_player_wireframe,
g_Options.chams_player_glass,
clr_front,
g_Options.color_chams_player_glow);
}
}
}
else if (is_sleeve && g_Options.chams_arms_enabled) {
auto material = g_MatSystem->FindMaterial(mdl->szName, TEXTURE_GROUP_MODEL);
if (!material)
return;
//
// Remove sleeves when drawing Chams.
//
material->SetMaterialVarFlag(MATERIAL_VAR_NO_DRAW, true);
g_MdlRender->ForcedMaterialOverride(material);
}
else if (is_arm) {
auto material = g_MatSystem->FindMaterial(mdl->szName, TEXTURE_GROUP_MODEL);
if (!material)
return;
if (g_Options.misc_no_hands) {
//
// No hands.
//
material->SetMaterialVarFlag(MATERIAL_VAR_NO_DRAW, true);
g_MdlRender->ForcedMaterialOverride(material);
}
else if (g_Options.chams_arms_enabled) {
if (g_Options.chams_arms_ignorez) {
OverrideMaterial(
true,
g_Options.chams_arms_flat,
g_Options.chams_arms_wireframe,
false,
g_Options.color_chams_arms_occluded,
g_Options.color_chams_player_glow);
fnDME(g_MdlRender, 0, ctx, state, info, matrix);
OverrideMaterial(
false,
g_Options.chams_arms_flat,
g_Options.chams_arms_wireframe,
false,
g_Options.color_chams_arms_visible,
g_Options.color_chams_player_glow);
}
else {
OverrideMaterial(
false,
g_Options.chams_arms_flat,
g_Options.chams_arms_wireframe,
g_Options.chams_arms_glass,
g_Options.color_chams_arms_visible,
g_Options.color_chams_player_glow);
}
}
}
}