-
Автор темы
- #1
Я хочу разбить настройку атачмент чамсов на врагов \ напарников \ локал, вот код функции и того, что она получает.
Само по себе оно работает хорошо, лишнего не рендерит, не окрашивает, но рендерит и на напарниках и у енеми, а в 3 лице и у себя. Может как то можно узнать из какого-то передаваемого класса информацию о владельце оружия, чтоб получить его команду? или как лучше сделать?
C++:
void chams::attachment(c_base_player* local_player, uintptr_t ecx, uintptr_t edx, void* results, DrawModelInfo_t* info, matrix3x4_t* bone_to_world, float* flex_weights, float* flex_delayed_weights, Vector& model_origin, int flags) {
if (!info || !info->client_entity)
return;
if (!local_player || !local_player->is_alive() || local_player->is_scoped())
return;
const auto entity = reinterpret_cast<c_base_player*>(info->client_entity->GetIClientUnknown()->GetBaseEntity());
auto is_arms = strstr(info->client_entity->GetModel()->szName, XORSTR("arms"));
auto is_weapon = strstr(info->client_entity->GetModel()->szName, XORSTR("models/weapons/v_")) && !strstr(info->client_entity->GetModel()->szName, XORSTR("tablet")) && !strstr(info->client_entity->GetModel()->szName, XORSTR("parachute")) && !strstr(info->client_entity->GetModel()->szName, XORSTR("fists")) && !strstr(info->client_entity->GetModel()->szName, XORSTR("arms"));
auto is_player = strstr(info->client_entity->GetModel()->szName, XORSTR("models/player")) && entity && !entity->IsDormant() && !entity->GetClientClass()->m_ClassID != classids::get(XORSTR("CCSPlayer")) && entity->is_alive();
auto name = info->client_entity->GetModel()->szName;
auto weapon_on_back = strstr(name, "_dropped.mdl") && strstr(name, "models/weapons/w") && !strstr(name, "arms") && !strstr(name, "ied_dropped");
auto weapon_enemy_hands = strstr(name, "models/weapons/w") && !strstr(name, "arms") && !strstr(name, "ied_dropped");
auto defuse_kit = strstr(name, "defuser") && !strstr(name, "arms") && !strstr(name, "ied_dropped");
if (g_interfaces.m_studio_render->IsForcedMaterialOverride() && !is_weapon && !is_arms && !weapon_on_back && !weapon_enemy_hands && !defuse_kit)
return o_draw_model_execute(ecx, edx, results, info, bone_to_world, flex_weights, flex_delayed_weights, model_origin, flags);
if (!weapon_on_back && !weapon_enemy_hands && !defuse_kit)
{
float color[3] = { 1.0f, 1.0f, 1.0f };
g_interfaces.m_render_view->set_color_modulation(color);
}
g_sdk.attachment_target_type = entity->get_team() != g_sdk.m_local()->get_team() ? 0 : entity == g_sdk.m_local() ? 2 : 1;
if (weapon_on_back || weapon_enemy_hands || defuse_kit)
{
const auto color_more = config.color_chams_attachment_more[g_sdk.attachment_target_type];
if (config.chams_attachment[g_sdk.attachment_target_type]) {
switch (config.chams_attachment_type[g_sdk.attachment_target_type]) {
case chams_type::chams_type_flat:
get_material(material_flat, false, config.chams_attachment_wireframe[g_sdk.attachment_target_type], config.color_chams_attachment[g_sdk.attachment_target_type][0], config.color_chams_attachment[g_sdk.attachment_target_type][1], config.color_chams_attachment[g_sdk.attachment_target_type][2], 1.f);
break;
case chams_type::chams_type_texture:
get_material(material_texture, false, config.chams_attachment_wireframe[g_sdk.attachment_target_type], config.color_chams_attachment[g_sdk.attachment_target_type][0], config.color_chams_attachment[g_sdk.attachment_target_type][1], config.color_chams_attachment[g_sdk.attachment_target_type][2], 1.f);
break;
case chams_type::chams_type_animated:
get_material(material_animated, false, config.chams_attachment_wireframe[g_sdk.attachment_target_type], config.color_chams_attachment[g_sdk.attachment_target_type][0], config.color_chams_attachment[g_sdk.attachment_target_type][1], config.color_chams_attachment[g_sdk.attachment_target_type][2], 1.f);
break;
case chams_type::chams_type_pearlescent:
get_material(material_pearlescent, false, config.chams_attachment_wireframe[g_sdk.attachment_target_type], config.color_chams_attachment[g_sdk.attachment_target_type][0], config.color_chams_attachment[g_sdk.attachment_target_type][1], config.color_chams_attachment[g_sdk.attachment_target_type][2], 1.f);
material_pearlescent->FindVar(XORSTR("$pearlescent"), nullptr, false)->SetValue(config.chams_attachment_pearlescent_value[g_sdk.attachment_target_type]);
break;
case chams_type::chams_type_ghost:
get_material(material_ghost, false, config.chams_attachment_wireframe[g_sdk.attachment_target_type], config.color_chams_attachment[g_sdk.attachment_target_type][0], config.color_chams_attachment[g_sdk.attachment_target_type][1], config.color_chams_attachment[g_sdk.attachment_target_type][2], 1.f);
break;
}
o_draw_model_execute(ecx, edx, results, info, bone_to_world, flex_weights, flex_delayed_weights, model_origin, flags);
}
if (config.chams_attachment_more_type[g_sdk.attachment_target_type] != 0) {
switch (config.chams_attachment_more_type[g_sdk.attachment_target_type]) {
case chams_more_type::chams_more_type_glow:
material = material_glow;
break;
case chams_more_type::chams_more_type_glow_overlay:
material = material_glow_overlay;
material->FindVar(XORSTR("$envmapfresnelminmaxexp"), nullptr, false)->SetVecComponentValue(3.8f, 2);
break;
case chams_more_type::chams_more_type_glow_pulse:
material = material_glow_overlay;
material->FindVar(XORSTR("$envmapfresnelminmaxexp"), nullptr, false)->SetVecComponentValue(9.0f * (1.2f - (0.5f * std::sin(g_interfaces.m_globals->m_current_time * 5.0f) * 0.5f + 0.5f)), 2);
break;
case chams_more_type::chams_more_type_gloss:
material = material_gloss;
break;
case chams_more_type::chams_more_type_crystal:
material = material_crystal;
break;
case chams_more_type::chams_more_type_glass:
material = material_glass;
break;
}
material->FindVar(XORSTR("$envmaptint"), nullptr, false)->SetVectorValue(config.color_chams_attachment_more[g_sdk.attachment_target_type][0], config.color_chams_attachment_more[g_sdk.attachment_target_type][1], config.color_chams_attachment_more[g_sdk.attachment_target_type][2]);
g_interfaces.m_studio_render->ForcedMaterialOverride(material);
o_draw_model_execute(ecx, edx, results, info, bone_to_world, flex_weights, flex_delayed_weights, model_origin, flags);
}
}
}