You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm a beginner programmer who is still learning English. I wanted to contribute to the Valthrun CS2 project, so I created a mod that increases the volume of enemy sounds.
I used an AI to generate the code, so I'm not sure if it's the best way to do it. I also don't know if the mod is actually useful or not.
I'm posting this mod here in case it's helpful to anyone. I'm always looking for feedback, so please let me know if you have any suggestions.
Thanks!
Description:
This mod increases the volume of enemy sounds by a percentage. This can be useful for players who want to be able to hear enemy footsteps and other sounds more easily.
impl Enhancement for SoundVolumeEnhancement {
fn update(&mut self, ctx: &UpdateContext) -> anyhow::Result<()> {
let enemies_sound_volume = match SoundVolumeIncrease::from_settings(&ctx.settings) {
SoundVolumeIncrease::None => 1.0,
SoundVolumeIncrease::Percent(percent) => percent,
};
for entity_identity in ctx.cs2_entities.all_identities() {
let class_name = ctx
.class_name_cache
.lookup(&entity_identity.entity_class_info()?)
.context("class name")?;
if class_name == "C_BaseEntity" && entity_identity.team() != ctx.player_info.team {
let entity = entity_identity
.entity_ptr::<C_BaseEntity>()?
.read_schema()?;
// Update enemy sound volume for the entity
entity.m_flSoundVolume()? = enemies_sound_volume;
}
}
Ok(false)
}
fn update_settings(
&mut self,
ui: &imgui::Ui,
settings: &mut AppSettings,
) -> anyhow::Result<bool> {
if ui.collapsing_header("Sound Enhancement") {
// Enable/disable mode
let mut checkbox = ui.checkbox("Enable Mode", &mut settings.enemies_sound_volume_enabled);
if checkbox.changed() {
// Update mode state
settings.enemies_sound_volume_enabled = checkbox.checked();
}
// Increase factor setting
let mut slider = ui.slider_float("Increase Factor", &mut settings.enemies_sound_volume_increase_percent, 0.0, 100.0);
if slider.changed() {
// Update increase factor
settings.enemies_sound_volume_increase_percent = slider.value();
}
// Information
ui.text("This mod increases the volume of enemy sounds by a percentage.");
ui.text("A value of 0 means that the sounds are not modified.");
ui.text("A value of 1 means that the sounds are 1% louder.");
ui.text("A value of 100 means that the sounds are twice as loud.");
}
Ok(false)
}
}
The text was updated successfully, but these errors were encountered:
Hi everyone,
I'm a beginner programmer who is still learning English. I wanted to contribute to the Valthrun CS2 project, so I created a mod that increases the volume of enemy sounds.
I used an AI to generate the code, so I'm not sure if it's the best way to do it. I also don't know if the mod is actually useful or not.
I'm posting this mod here in case it's helpful to anyone. I'm always looking for feedback, so please let me know if you have any suggestions.
Thanks!
Description:
This mod increases the volume of enemy sounds by a percentage. This can be useful for players who want to be able to hear enemy footsteps and other sounds more easily.
use crate::settings::AppSettings;
pub trait Enhancement {
fn update(&mut self, ctx: &UpdateContext) -> anyhow::Result<()>;
}
mod bomb;
pub use bomb::*;
mod player;
pub use player::*;
mod trigger;
pub use trigger::*;
mod spectators_list;
pub use spectators_list::*;
mod aim;
pub use aim::*;
use crate::{
view::ViewController,
UpdateContext,
};
enum SoundVolumeIncrease {
None,
Percent(f32),
}
impl SoundVolumeIncrease {
fn from_settings(settings: &AppSettings) -> Self {
if settings.enemies_sound_volume_enabled {
if settings.enemies_sound_volume_increase_percent == 0.0 {
SoundVolumeIncrease::None
} else {
SoundVolumeIncrease::Percent(settings.enemies_sound_volume_increase_percent)
}
} else {
SoundVolumeIncrease::None
}
}
}
impl Enhancement for SoundVolumeEnhancement {
fn update(&mut self, ctx: &UpdateContext) -> anyhow::Result<()> {
let enemies_sound_volume = match SoundVolumeIncrease::from_settings(&ctx.settings) {
SoundVolumeIncrease::None => 1.0,
SoundVolumeIncrease::Percent(percent) => percent,
};
}
The text was updated successfully, but these errors were encountered: