gloss-click / cs2-buttplug

Updated CS plugin for buttplug.io
Other
3 stars 4 forks source link

"Vibrating per Kill" Feature Malfunctioning in Online Casual Games #4

Open C0nvert opened 3 months ago

C0nvert commented 3 months ago

As the title suggests, the "Vibrating per Kill" feature does not function as intended during online casual games when I am alive and achieve a kill. However, it works correctly if I am spectating another player and they get a kill.

Additionally, when using a Rhai script for game logic that causes vibration while shooting, the same error occurs.

I tried to debug the CSGO-GSI module to see if the information received from online servers somehow differs from the offline ones, but I didn't find any differences.

In offline maps or games hosted by me, the feature operates as expected.

let current_weapon = "none";
let x = -1;
let falloff = 0.5;

let kills = 0;
let assists = 0;

fn handle_update(update) {
    if update.player != () {
        if update.player.match_stats != () {
            if kills < update.player.match_stats.kills {
                kills = update.player.match_stats.kills;
                vibrate(0.3 + kills.to_float()/25.0, 1.0);
            }
            if assists < update.player.match_stats.assists {
                assists = update.player.match_stats.assists;
                vibrate(0.15, 1.0);
            }

            if update.player.match_stats.kills == 0 {
                kills = 0;
            }
            if update.player.match_stats.assists == 0 {
                assists = 0;
            }
        }
    }
}

Vibrating while Shooting Script

fn handle_update(update) {
    if update.player != () {
         for weapon in values(update.player.weapons) {
            let state = weapon.state.to_string();
            if state in ["Active", "Reloading"] {
                let current = weapon.ammo_clip;
                let max = weapon.ammo_clip_max;
                if current != () {
                    vibrate(1.0 - current.to_float() / max.to_float(), 1.0)
                }
            }
        }
    }
}
gloss-click commented 3 months ago

Weird, I'll have a look

C0nvert commented 2 months ago

Thanks mate i would like to tip you a coffee or something :)

gloss-click commented 2 months ago

Nah don't worry about it!

I had a look, I wasn't able to reproduce an issue with the shooting script, that seemed to work fine for me. There was an issue with the kills script when you spectated someone with more kills than you which I've updated the default to prevent happening - it will only fire now for the first steam id it seems which I'm assuming will be the player. Give it a go with the latest build (0.9.0) and let me know.

C0nvert commented 2 months ago

It works!

However, I have a question about the "falloff" variable. By default, it's set to "0.0" and isn't used anywhere. Did you just forget it in the Rhai script? :D

I encountered an issue with the shooting logic where the toy continued to vibrate in waves even after I stopped firing. To resolve this, I adjusted the Rhai script as follows:

let current_weapon = "none";
let x = -1;
let falloff = 3.0;

let steam_id = "";
let previous_ammo = 0; 

fn handle_update(update) {
    if update.player != () {
        if steam_id == "" {
            steam_id = update.player.steam_id;
        }
        if steam_id == update.player.steam_id {

            let new_ammo = 0; 

            for weapon in values(update.player.weapons) {
                let state = weapon.state.to_string();
                let current = weapon.ammo_clip;
                let max = weapon.ammo_clip_max;

                if state in ["Active", "Reloading"] {
                    new_ammo = current;

                    if new_ammo != max && new_ammo != previous_ammo {
                        let intensity = 1.0 - new_ammo.to_float() / max.to_float();
                        vibrate(intensity, 1.0);
                    }

                    previous_ammo = new_ammo;
                }
            }
        }
    }
}
C0nvert commented 2 months ago

Could you help me with Variables for update.round.bomb and update.round?

I don't know how to compile the gsi alone to get all available variables in rust

gloss-click commented 2 months ago

You can browse all the relevant objects in these files: https://github.com/gloss-click/csgo-gsi/tree/main/src/update

The 'falloff' variable is probably a holdover from the original default script which I edited.

C0nvert commented 2 months ago

I’m encountering an issue with my Rhai script where I am unable to access attributes of the round object properly. Here is the function I am using:

    if update.round != () {
        log("Round exists.");

        let round = update.round;

        let round_phase = if round.phase == "Live" {
            "Live"
        } else if round.phase == "Over" {
            "Over"
        } else if round.phase == "FreezeTime" {
            "FreezeTime"
        } else {
            "Unknown"
        };

        let round_bomb = if round.bomb == "Planted" {
            "Planted"
        } else if round.bomb == "Defused" {
            "Defused"
        } else if round.bomb == "Exploded" {
            "Exploded"
        } else {
            "None"
        };

        let round_win_team = if round.win_team == "Terrorist" {
            "Terrorist"
        } else if round.win_team == "CounterTerrorist" {
            "CounterTerrorist"
        } else {
            "None"
        };

        log("Round Phase: " + round_phase);
        log("Bomb State: " + round_bomb);
        log("Winning Team: " + round_win_team);

    } else {
        log("Round does NOT exist.");
    }
}

However, I’m running into issues where it seems like the attributes (phase, bomb, win_team) are not being recognized or accessed properly. The script is not behaving as expected, and I am unable to log the attributes correctly.