Attempting to fix ShockOnDamage
This commit is contained in:
parent
0dbb4aa734
commit
3a6d61b54b
|
@ -77,15 +77,29 @@ namespace DalamudShock
|
||||||
|
|
||||||
if (player == null) return;
|
if (player == null) return;
|
||||||
var currentHealth = player.CurrentHp;
|
var currentHealth = player.CurrentHp;
|
||||||
|
|
||||||
if (currentHealth == lastHealth) return;
|
if (currentHealth == lastHealth) return;
|
||||||
lastHealth = currentHealth;
|
lastHealth = currentHealth;
|
||||||
|
|
||||||
if (currentHealth != lastHealth)
|
if (Configuration.ZapOnDamage)
|
||||||
{
|
{
|
||||||
lastHealth = currentHealth;
|
if ((DateTime.Now - lastShockTime).TotalSeconds >= 15)
|
||||||
|
{
|
||||||
|
lastShockTime = DateTime.Now;
|
||||||
|
|
||||||
if (Configuration.ZapOnDamage)
|
if (Configuration.UsePishock)
|
||||||
|
{
|
||||||
|
SendPiShockApiRequest();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SendOscApiRequest();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (currentHealth < player.MaxHp * 0.5)
|
||||||
{
|
{
|
||||||
if ((DateTime.Now - lastShockTime).TotalSeconds >= 15)
|
if ((DateTime.Now - lastShockTime).TotalSeconds >= 15)
|
||||||
{
|
{
|
||||||
|
@ -101,32 +115,10 @@ namespace DalamudShock
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
if (currentHealth < player.MaxHp * 0.5)
|
|
||||||
{
|
|
||||||
if ((DateTime.Now - lastShockTime).TotalSeconds >= 15)
|
|
||||||
{
|
|
||||||
PluginLog.Information($"Player health changed to {currentHealth}, time conditions met.");
|
|
||||||
lastShockTime = DateTime.Now;
|
|
||||||
|
|
||||||
if (Configuration.UsePishock)
|
|
||||||
{
|
|
||||||
PluginLog.Information("Using PiShock, triggering PiShock API request.");
|
|
||||||
SendPiShockApiRequest();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
PluginLog.Information(
|
|
||||||
"Using default shock API, triggering standard shock API request.");
|
|
||||||
SendOscApiRequest();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private async void SendOscApiRequest()
|
private async void SendOscApiRequest()
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(Configuration.openshockApiKey) || string.IsNullOrEmpty(Configuration.OpenshockShockerID))
|
if (string.IsNullOrEmpty(Configuration.openshockApiKey) || string.IsNullOrEmpty(Configuration.OpenshockShockerID))
|
||||||
|
@ -141,7 +133,6 @@ namespace DalamudShock
|
||||||
var intensity = random.Next(0, Configuration.MaxValue);
|
var intensity = random.Next(0, Configuration.MaxValue);
|
||||||
var duration = random.Next(1000, Configuration.MaxDuration * 1000);
|
var duration = random.Next(1000, Configuration.MaxDuration * 1000);
|
||||||
|
|
||||||
// Calculate the type based on weighted odds
|
|
||||||
var type = "shock";
|
var type = "shock";
|
||||||
if (isVibrationAllowed)
|
if (isVibrationAllowed)
|
||||||
{
|
{
|
||||||
|
|
|
@ -8,7 +8,7 @@ namespace DalamudShock.Windows
|
||||||
public class ConfigWindow : Window, IDisposable
|
public class ConfigWindow : Window, IDisposable
|
||||||
{
|
{
|
||||||
private Configuration Configuration;
|
private Configuration Configuration;
|
||||||
public ConfigWindow(Plugin plugin) : base("DalamudShock Config###With a constant ID")
|
public ConfigWindow(Plugin plugin) : base("DalamudShock Config###69420")
|
||||||
{
|
{
|
||||||
Flags = ImGuiWindowFlags.NoScrollWithMouse;
|
Flags = ImGuiWindowFlags.NoScrollWithMouse;
|
||||||
Size = new Vector2(600, 400);
|
Size = new Vector2(600, 400);
|
||||||
|
@ -32,17 +32,42 @@ namespace DalamudShock.Windows
|
||||||
|
|
||||||
public override void Draw()
|
public override void Draw()
|
||||||
{
|
{
|
||||||
|
var isVibrationAllowed = Configuration.IsVibrationAllowed;
|
||||||
|
if (ImGui.Checkbox("Allow Vibration", ref isVibrationAllowed))
|
||||||
|
{
|
||||||
|
Configuration.IsVibrationAllowed = isVibrationAllowed;
|
||||||
|
}
|
||||||
|
ImGui.SameLine();
|
||||||
|
var usePsc = Configuration.UsePishock;
|
||||||
|
if (ImGui.Checkbox("Use PiShock API", ref usePsc))
|
||||||
|
{
|
||||||
|
Configuration.UsePishock = usePsc;
|
||||||
|
}
|
||||||
|
ImGui.SameLine();
|
||||||
|
var instantZap = Configuration.ZapOnDamage;
|
||||||
|
if (ImGui.Checkbox("Shock on Damage", ref instantZap))
|
||||||
|
{
|
||||||
|
Configuration.ZapOnDamage = instantZap;
|
||||||
|
}
|
||||||
|
ImGui.Spacing();
|
||||||
var apiKey = Configuration.openshockApiKey;
|
var apiKey = Configuration.openshockApiKey;
|
||||||
if (ImGui.InputText("API Key", ref apiKey, 100))
|
if (ImGui.InputText("Openshock/PiShock API Key", ref apiKey, 100))
|
||||||
{
|
{
|
||||||
Configuration.openshockApiKey = apiKey;
|
Configuration.openshockApiKey = apiKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
var shockerID = Configuration.OpenshockShockerID;
|
var shockerId = Configuration.OpenshockShockerID;
|
||||||
if (ImGui.InputText("Shocker ID or Share Code", ref shockerID, 100))
|
if (ImGui.InputText("Shocker ID or Share Code", ref shockerId, 100))
|
||||||
{
|
{
|
||||||
Configuration.OpenshockShockerID = shockerID;
|
Configuration.OpenshockShockerID = shockerId;
|
||||||
}
|
}
|
||||||
|
if (usePsc)
|
||||||
|
{
|
||||||
|
var pishockUsername = Configuration.PiShockUser;
|
||||||
|
ImGui.InputText("PiShock Username", ref pishockUsername, 100);
|
||||||
|
Configuration.PiShockUser = pishockUsername;
|
||||||
|
}
|
||||||
|
ImGui.Spacing();
|
||||||
var maxShock = Configuration.MaxValue;
|
var maxShock = Configuration.MaxValue;
|
||||||
if (ImGui.SliderInt("Intensity cap", ref maxShock, 0, 100))
|
if (ImGui.SliderInt("Intensity cap", ref maxShock, 0, 100))
|
||||||
{
|
{
|
||||||
|
@ -54,31 +79,6 @@ namespace DalamudShock.Windows
|
||||||
// Map the value from [1, 30] to [1000, 30000]
|
// Map the value from [1, 30] to [1000, 30000]
|
||||||
Configuration.MaxDuration = maxLength;
|
Configuration.MaxDuration = maxLength;
|
||||||
}
|
}
|
||||||
bool isVibrationAllowed = Configuration.IsVibrationAllowed;
|
|
||||||
if (ImGui.Checkbox("Allow Vibration", ref isVibrationAllowed))
|
|
||||||
{
|
|
||||||
Configuration.IsVibrationAllowed = isVibrationAllowed;
|
|
||||||
}
|
|
||||||
ImGui.SameLine();
|
|
||||||
bool usePsc = Configuration.UsePishock;
|
|
||||||
if (ImGui.Checkbox("Use PiShock API", ref usePsc))
|
|
||||||
{
|
|
||||||
Configuration.UsePishock = usePsc;
|
|
||||||
Configuration.IsVibrationAllowed = usePsc;
|
|
||||||
}
|
|
||||||
ImGui.Spacing();
|
|
||||||
if (usePsc)
|
|
||||||
{
|
|
||||||
string pishockUsername = Configuration.PiShockUser;
|
|
||||||
ImGui.InputText("PiShock Username", ref pishockUsername, 100);
|
|
||||||
Configuration.PiShockUser = pishockUsername;
|
|
||||||
}
|
|
||||||
ImGui.Spacing();
|
|
||||||
bool instantZap = Configuration.ZapOnDamage;
|
|
||||||
if (ImGui.Checkbox("Allow Vibration", ref instantZap))
|
|
||||||
{
|
|
||||||
Configuration.ZapOnDamage = instantZap;
|
|
||||||
}
|
|
||||||
ImGui.Spacing();
|
ImGui.Spacing();
|
||||||
if (ImGui.Button("Save Configuration"))
|
if (ImGui.Button("Save Configuration"))
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue