6 Commits

Author SHA1 Message Date
fa6a8d4e15 Update Dependency, Readme 2024-01-16 04:43:07 +01:00
96443f3c0a Update Readme 2024-01-16 01:36:06 +01:00
c7b9b6bc35 Update Readme 2024-01-16 01:35:25 +01:00
4e30b7f9d8 Update Readme 2024-01-16 01:22:53 +01:00
9f961f2c65 Add OnDamageTaken 2024-01-16 01:20:41 +01:00
f01d721281 Add Overwrite to Shocker.Control for intensity and duration 2024-01-16 01:20:28 +01:00
5 changed files with 40 additions and 16 deletions

View File

@ -53,8 +53,20 @@ public class OpenCS2hock
case "OnRoundWin": case "OnRoundWin":
this._cs2GSI.OnRoundWin += (cs2EventArgs) => shocker.Control(Settings.StringToAction(kv.Value)); this._cs2GSI.OnRoundWin += (cs2EventArgs) => shocker.Control(Settings.StringToAction(kv.Value));
break; break;
case "OnDamageTaken":
this._cs2GSI.OnDamageTaken += (cs2EventArgs) =>
shocker.Control(Settings.StringToAction(kv.Value),
intensity: MapInt(cs2EventArgs.ValueAsOrDefault<int>(), 0, 100,
_settings.IntensityRange.Min, _settings.IntensityRange.Max));
break;
} }
} }
} }
} }
private int MapInt(int input, int fromLow, int fromHigh, int toLow, int toHigh)
{
int mappedValue = (input - fromLow) * (toHigh - toLow) / (fromHigh - fromLow) + toLow;
return mappedValue;
}
} }

View File

@ -9,7 +9,7 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="CS2GSI" Version="1.0.2" /> <PackageReference Include="CS2GSI" Version="1.0.4" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" /> <PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup> </ItemGroup>

View File

@ -32,7 +32,8 @@ public struct Settings
{"OnRoundStart", "Vibrate"}, {"OnRoundStart", "Vibrate"},
{"OnRoundEnd", "Nothing"}, {"OnRoundEnd", "Nothing"},
{"OnRoundWin", "Beep"}, {"OnRoundWin", "Beep"},
{"OnRoundLoss", "Nothing"} {"OnRoundLoss", "Nothing"},
{"OnDamageTaken", "Vibrate"}
}; };
public Settings() public Settings()

View File

@ -12,18 +12,18 @@ internal abstract class Shocker
internal enum ControlAction { Beep, Vibrate, Shock, Nothing } internal enum ControlAction { Beep, Vibrate, Shock, Nothing }
internal void Control(ControlAction action, string? shockerId = null) internal void Control(ControlAction action, string? shockerId = null, int? intensity = null, int? duration = null)
{ {
int intensity = _intensity.GetValue(); int i = intensity ?? _intensity.GetValue();
int duration = _duration.GetValue(); int d = duration ?? _duration.GetValue();
this.Logger?.Log(LogLevel.Information, $"{action} {intensity} {duration}"); this.Logger?.Log(LogLevel.Information, $"{action} {(intensity is not null ? "Overwrite " : "")}{i} {(duration is not null ? "Overwrite " : "")}{d}");
if (action is ControlAction.Nothing) if (action is ControlAction.Nothing)
return; return;
if(shockerId is null) if(shockerId is null)
foreach (string shocker in _shockerIds) foreach (string shocker in _shockerIds)
ControlInternal(action, shocker, intensity, duration); ControlInternal(action, shocker, i, d);
else else
ControlInternal(action, shockerId, intensity, duration); ControlInternal(action, shockerId, i, d);
} }
protected abstract void ControlInternal(ControlAction action, string shockerId, int intensity, int duration); protected abstract void ControlInternal(ControlAction action, string shockerId, int intensity, int duration);

View File

@ -1,7 +1,17 @@
Example `config.json`. Place next to executable. Will also be generated on first start. # OpenCS2hock
``` ![GitHub License](https://img.shields.io/github/license/c9glax/OpenCS2hock)
![GitHub Release](https://img.shields.io/github/v/release/c9glax/OpenCS2hock)
Electrifying your Counter-Strike experience. With [OpenShock](https://openshock.org/)!
## How to use
Download [latest Release](https://github.com/C9Glax/OpenCS2hock/releases/latest) and execute.
Example `config.json`. Place next to executable. Will also be generated on first start.
```json
{ {
"SteamId": "<Your SteamId>", "LogLevel": 2,
"OpenShockSettings": { "OpenShockSettings": {
"Endpoint": "https://api.shocklink.net", "Endpoint": "https://api.shocklink.net",
"ApiKey": "<Your Shocklink API Key>", "ApiKey": "<Your Shocklink API Key>",
@ -16,17 +26,16 @@
"Max": 1000 "Max": 1000
}, },
"Actions": { "Actions": {
"OnKill": "Beep", "OnKill": "Nothing",
"OnDeath": "Shock", "OnDeath": "Shock",
"OnRoundStart": "Nothing", "OnRoundStart": "Nothing",
"OnRoundEnd": "Vibrate", "OnRoundEnd": "Vibrate",
"OnRoundWin": "Nothing", "OnRoundWin": "Nothing",
"OnRoundLoss": "Shock" "OnRoundLoss": "Shock",
"OnDamageTaken": "Vibrate"
} }
} }
``` ```
### SteamId
Your SteamId64 [here](https://steamid.io/lookup)
### ApiKey ### ApiKey
For OpenShock get token [here](https://shocklink.net/#/dashboard/tokens) For OpenShock get token [here](https://shocklink.net/#/dashboard/tokens)
@ -37,7 +46,7 @@ List of Shocker-Ids, comma seperated. Get Id [here](https://shocklink.net/#/dash
Example `[ "ID-1", "ID-2" ]` Example `[ "ID-1", "ID-2" ]`
### Intensity Range ### Intensity Range
`0-100` `0-100`%
### Duration Range ### Duration Range
@ -47,3 +56,5 @@ in ms
- Beep - Beep
- Shock - Shock
- Vibrate - Vibrate
# Using [CS2GSI](https://github.com/C9Glax/CS2GSI)