Compare commits
3 Commits
6a862fa814
...
2.0
Author | SHA1 | Date | |
---|---|---|---|
4e30b7f9d8 | |||
9f961f2c65 | |||
f01d721281 |
@ -53,8 +53,20 @@ public class OpenCS2hock
|
||||
case "OnRoundWin":
|
||||
this._cs2GSI.OnRoundWin += (cs2EventArgs) => shocker.Control(Settings.StringToAction(kv.Value));
|
||||
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;
|
||||
}
|
||||
}
|
@ -9,7 +9,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="CS2GSI" Version="1.0.2" />
|
||||
<PackageReference Include="CS2GSI" Version="1.0.3" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
</ItemGroup>
|
||||
|
||||
|
@ -32,7 +32,8 @@ public struct Settings
|
||||
{"OnRoundStart", "Vibrate"},
|
||||
{"OnRoundEnd", "Nothing"},
|
||||
{"OnRoundWin", "Beep"},
|
||||
{"OnRoundLoss", "Nothing"}
|
||||
{"OnRoundLoss", "Nothing"},
|
||||
{"OnDamageTaken", "Vibrate"}
|
||||
};
|
||||
|
||||
public Settings()
|
||||
|
@ -12,18 +12,18 @@ internal abstract class Shocker
|
||||
|
||||
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 duration = _duration.GetValue();
|
||||
this.Logger?.Log(LogLevel.Information, $"{action} {intensity} {duration}");
|
||||
int i = intensity ?? _intensity.GetValue();
|
||||
int d = duration ?? _duration.GetValue();
|
||||
this.Logger?.Log(LogLevel.Information, $"{action} {(intensity is not null ? "Overwrite " : "")}{i} {(duration is not null ? "Overwrite " : "")}{d}");
|
||||
if (action is ControlAction.Nothing)
|
||||
return;
|
||||
if(shockerId is null)
|
||||
foreach (string shocker in _shockerIds)
|
||||
ControlInternal(action, shocker, intensity, duration);
|
||||
ControlInternal(action, shocker, i, d);
|
||||
else
|
||||
ControlInternal(action, shockerId, intensity, duration);
|
||||
ControlInternal(action, shockerId, i, d);
|
||||
}
|
||||
|
||||
protected abstract void ControlInternal(ControlAction action, string shockerId, int intensity, int duration);
|
||||
|
11
README.md
11
README.md
@ -1,7 +1,7 @@
|
||||
Example `config.json`. Place next to executable. Will also be generated on first start.
|
||||
```
|
||||
```json
|
||||
{
|
||||
"SteamId": "<Your SteamId>",
|
||||
"LogLevel": 2,
|
||||
"OpenShockSettings": {
|
||||
"Endpoint": "https://api.shocklink.net",
|
||||
"ApiKey": "<Your Shocklink API Key>",
|
||||
@ -16,17 +16,16 @@
|
||||
"Max": 1000
|
||||
},
|
||||
"Actions": {
|
||||
"OnKill": "Beep",
|
||||
"OnKill": "Nothing",
|
||||
"OnDeath": "Shock",
|
||||
"OnRoundStart": "Nothing",
|
||||
"OnRoundEnd": "Vibrate",
|
||||
"OnRoundWin": "Nothing",
|
||||
"OnRoundLoss": "Shock"
|
||||
"OnRoundLoss": "Shock",
|
||||
"OnDamageTaken": "Vibrate"
|
||||
}
|
||||
}
|
||||
```
|
||||
### SteamId
|
||||
Your SteamId64 [here](https://steamid.io/lookup)
|
||||
|
||||
### ApiKey
|
||||
For OpenShock get token [here](https://shocklink.net/#/dashboard/tokens)
|
||||
|
Reference in New Issue
Block a user