Skip to content

Commit

Permalink
Merge pull request #1855 from stuntguy3000/fix-csgo
Browse files Browse the repository at this point in the history
Fix ammo/health indicators & new effects and customizations to CS:GO
  • Loading branch information
diogotr7 authored Feb 16, 2020
2 parents 9fea68f + 8537212 commit 3272755
Show file tree
Hide file tree
Showing 18 changed files with 598 additions and 87 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ public CSGO()
new LayerHandlerEntry("CSGOBurning", "CSGO Burning Effect Layer", typeof(CSGOBurningLayerHandler)),
new LayerHandlerEntry("CSGOFlashbang", "CSGO Flashbang Layer", typeof(CSGOFlashbangLayerHandler)),
new LayerHandlerEntry("CSGOTyping", "CSGO Typing Layer", typeof(CSGOTypingIndicatorLayerHandler)),
new LayerHandlerEntry("CSGOWinningTeam", "CSGO Winning Team Effect Layer", typeof(CSGOWinningTeamLayerHandler)),
new LayerHandlerEntry("CSGODeathEffect", "CSGO Death Effect Layer", typeof(CSGODeathLayerHandler)),
};

Global.LightingStateManager.RegisterLayerHandlers(extra, false);
Expand Down
58 changes: 48 additions & 10 deletions Project-Aurora/Project-Aurora/Profiles/CSGO/CSGOProfile.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
using Aurora.Settings;
using Aurora.Profiles.CSGO.GSI.Nodes;
using Aurora.Settings;
using Aurora.Settings.Layers;
using Aurora.Settings.Overrides.Logic;
using Aurora.Settings.Overrides.Logic.Builder;
using System;
using System.Collections.Generic;
using System.Drawing;
Expand All @@ -21,10 +24,41 @@ public override void Reset()
base.Reset();
Layers = new System.Collections.ObjectModel.ObservableCollection<Layer>()
{

new Layer("CSGO Typing Indicator", new Layers.CSGOTypingIndicatorLayerHandler()),
new Layer("CSGO Kills Indicator", new Layers.CSGOKillIndicatorLayerHandler()),
new Layer("CSGO Flashbang Effect", new Layers.CSGOFlashbangLayerHandler()),
new Layer("Typing Indicator", new SolidColorLayerHandler()
{
Properties = new LayerHandlerProperties()
{
_PrimaryColor = Color.FromArgb(0, 255, 0),
_Sequence = new KeySequence(new Devices.DeviceKeys[] { Devices.DeviceKeys.TILDE, Devices.DeviceKeys.ONE, Devices.DeviceKeys.TWO, Devices.DeviceKeys.THREE, Devices.DeviceKeys.FOUR, Devices.DeviceKeys.FIVE, Devices.DeviceKeys.SIX, Devices.DeviceKeys.SEVEN, Devices.DeviceKeys.EIGHT, Devices.DeviceKeys.NINE, Devices.DeviceKeys.ZERO, Devices.DeviceKeys.MINUS, Devices.DeviceKeys.EQUALS, Devices.DeviceKeys.BACKSPACE,
Devices.DeviceKeys.TAB, Devices.DeviceKeys.Q, Devices.DeviceKeys.W, Devices.DeviceKeys.E, Devices.DeviceKeys.R, Devices.DeviceKeys.T, Devices.DeviceKeys.Y, Devices.DeviceKeys.U, Devices.DeviceKeys.I, Devices.DeviceKeys.O, Devices.DeviceKeys.P, Devices.DeviceKeys.CLOSE_BRACKET, Devices.DeviceKeys.OPEN_BRACKET, Devices.DeviceKeys.BACKSLASH,
Devices.DeviceKeys.CAPS_LOCK, Devices.DeviceKeys.A, Devices.DeviceKeys.S, Devices.DeviceKeys.D, Devices.DeviceKeys.F, Devices.DeviceKeys.G, Devices.DeviceKeys.H, Devices.DeviceKeys.J, Devices.DeviceKeys.K, Devices.DeviceKeys.L, Devices.DeviceKeys.SEMICOLON, Devices.DeviceKeys.APOSTROPHE, Devices.DeviceKeys.HASHTAG, Devices.DeviceKeys.ENTER,
Devices.DeviceKeys.LEFT_SHIFT, Devices.DeviceKeys.BACKSLASH_UK, Devices.DeviceKeys.Z, Devices.DeviceKeys.X, Devices.DeviceKeys.C, Devices.DeviceKeys.V, Devices.DeviceKeys.B, Devices.DeviceKeys.N, Devices.DeviceKeys.M, Devices.DeviceKeys.COMMA, Devices.DeviceKeys.PERIOD, Devices.DeviceKeys.FORWARD_SLASH, Devices.DeviceKeys.RIGHT_SHIFT,
Devices.DeviceKeys.LEFT_CONTROL, Devices.DeviceKeys.LEFT_WINDOWS, Devices.DeviceKeys.LEFT_ALT, Devices.DeviceKeys.SPACE, Devices.DeviceKeys.RIGHT_ALT, Devices.DeviceKeys.RIGHT_WINDOWS, Devices.DeviceKeys.APPLICATION_SELECT, Devices.DeviceKeys.RIGHT_CONTROL,
Devices.DeviceKeys.ARROW_UP, Devices.DeviceKeys.ARROW_LEFT, Devices.DeviceKeys.ARROW_DOWN, Devices.DeviceKeys.ARROW_RIGHT, Devices.DeviceKeys.ESC
})
}
}, new OverrideLogicBuilder()
.SetDynamicBoolean("_Enabled", new BooleanGSIEnum("Player/Activity", PlayerActivity.TextInput))
),
new Layer("Winning Team Effect", new Layers.CSGOWinningTeamLayerHandler()),
new Layer("Death Effect", new Layers.CSGODeathLayerHandler()),
new Layer("Kills Indicator", new Layers.CSGOKillIndicatorLayerHandler()),
new Layer("Flashbang Effect", new SolidFillLayerHandler() {
Properties = new SolidFillLayerHandlerProperties()
{
_PrimaryColor = Color.FromArgb(255, 255, 255)
}
}, new OverrideLogicBuilder()
.SetDynamicFloat("_LayerOpacity", new NumberMathsOperation(new NumberGSINumeric("Player/State/Flashed"), MathsOperator.Div, 255))
),
new Layer("Smoke Effect", new SolidFillLayerHandler() {
Properties = new SolidFillLayerHandlerProperties()
{
_PrimaryColor = Color.FromArgb(200, 200, 200)
}
}, new OverrideLogicBuilder()
.SetDynamicFloat("_LayerOpacity", new NumberMathsOperation(new NumberGSINumeric("Player/State/Smoked"), MathsOperator.Div, 255))
),
new Layer("Health Indicator", new PercentLayerHandler()
{
Properties = new PercentLayerHandlerProperties()
Expand All @@ -43,7 +77,9 @@ public override void Reset()
_MaxVariablePath = "100"
},

}),
}, new OverrideLogicBuilder()
.SetDynamicBoolean("_Enabled", new BooleanGSIEnum("Round/Phase", RoundPhase.Live))
),
new Layer("Ammo Indicator", new PercentLayerHandler()
{
Properties = new PercentLayerHandlerProperties()
Expand All @@ -61,10 +97,12 @@ public override void Reset()
_VariablePath = "Player/Weapons/ActiveWeapon/AmmoClip",
_MaxVariablePath = "Player/Weapons/ActiveWeapon/AmmoClipMax"
},
}),
new Layer("CSGO Bomb Effect", new Layers.CSGOBombLayerHandler()),
new Layer("CSGO Burning Effect", new Layers.CSGOBurningLayerHandler()),
new Layer("CSGO Background", new Layers.CSGOBackgroundLayerHandler())
}, new OverrideLogicBuilder()
.SetDynamicBoolean("_Enabled", new BooleanGSIEnum("Round/Phase", RoundPhase.Live))
),
new Layer("Bomb Effect", new Layers.CSGOBombLayerHandler()),
new Layer("Burning Effect", new Layers.CSGOBurningLayerHandler()),
new Layer("Background", new Layers.CSGOBackgroundLayerHandler())
};
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Aurora.EffectsEngine;

using Aurora.EffectsEngine;
using Aurora.Profiles.CSGO.GSI;
using Aurora.Profiles.CSGO.GSI.Nodes;
using Aurora.Settings;
Expand Down Expand Up @@ -41,6 +42,11 @@ public class CSGOBackgroundLayerHandlerProperties : LayerHandlerProperties2Color
[JsonIgnore]
public double DimDelay { get { return Logic._DimDelay ?? _DimDelay ?? 0.0; } }

public int? _DimAmount { get; set; }

[JsonIgnore]
public int DimAmount { get { return Logic._DimAmount ?? _DimAmount ?? 100; } }

public CSGOBackgroundLayerHandlerProperties() : base() { }

public CSGOBackgroundLayerHandlerProperties(bool assign_default = false) : base(assign_default) { }
Expand All @@ -50,18 +56,19 @@ public override void Default()
base.Default();

this._DefaultColor = Color.FromArgb(158, 205, 255);
this._CTColor = Color.FromArgb(158, 205, 255);
this._CTColor = Color.FromArgb(33, 155, 221);
this._TColor = Color.FromArgb(221, 99, 33);
this._DimEnabled = true;
this._DimDelay = 15;
this._DimAmount = 20;
}

}

public class CSGOBackgroundLayerHandler : LayerHandler<CSGOBackgroundLayerHandlerProperties>
{
private bool isDimming = false;
private double dim_value = 1.0;
private double dim_value = 100.0;
private long dim_bg_at = 15;

public CSGOBackgroundLayerHandler() : base()
Expand All @@ -86,7 +93,7 @@ public override EffectLayer Render(IGameState state)
{
isDimming = false;
dim_bg_at = Utils.Time.GetMillisecondsSinceEpoch() + (long)(this.Properties.DimDelay * 1000D);
dim_value = 1.0;
dim_value = 100.0;
}

Color bg_color = this.Properties.DefaultColor;
Expand All @@ -108,12 +115,12 @@ public override EffectLayer Render(IGameState state)
if (dim_bg_at <= Utils.Time.GetMillisecondsSinceEpoch() || csgostate.Player.State.Health == 0)
{
isDimming = true;
bg_color = Utils.ColorUtils.MultiplyColorByScalar(bg_color, getDimmingValue());
bg_color = Utils.ColorUtils.MultiplyColorByScalar(bg_color, (getDimmingValue() / 100));
}
else
{
isDimming = false;
dim_value = 1.0;
dim_value = 100.0;
}
}

Expand All @@ -133,11 +140,11 @@ private double getDimmingValue()
{
if (isDimming && Properties.DimEnabled)
{
dim_value -= 0.02;
return dim_value = (dim_value < 0.0 ? 0.0 : dim_value);
dim_value -= 2.0;
return dim_value = (dim_value < Math.Abs(Properties.DimAmount - 100) ? Math.Abs(Properties.DimAmount - 100) : dim_value);
}
else
return dim_value = 1.0;
return dim_value = 100.0;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,6 @@ namespace Aurora.Profiles.CSGO.Layers
{
public class CSGOBombLayerHandlerProperties : LayerHandlerProperties2Color<CSGOBombLayerHandlerProperties>
{
public Color? _CTColor { get; set; }

[JsonIgnore]
public Color CTColor { get { return Logic._CTColor ?? _CTColor ?? Color.Empty; } }

public Color? _TColor { get; set; }

[JsonIgnore]
public Color TColor { get { return Logic._TColor ?? _TColor ?? Color.Empty; } }

public Color? _FlashColor { get; set; }

[JsonIgnore]
Expand Down Expand Up @@ -61,8 +51,6 @@ public override void Default()
base.Default();

this._Sequence = new KeySequence(new Devices.DeviceKeys[] { Devices.DeviceKeys.NUM_LOCK, Devices.DeviceKeys.NUM_SLASH, Devices.DeviceKeys.NUM_ASTERISK, Devices.DeviceKeys.NUM_MINUS, Devices.DeviceKeys.NUM_SEVEN, Devices.DeviceKeys.NUM_EIGHT, Devices.DeviceKeys.NUM_NINE, Devices.DeviceKeys.NUM_PLUS, Devices.DeviceKeys.NUM_FOUR, Devices.DeviceKeys.NUM_FIVE, Devices.DeviceKeys.NUM_SIX, Devices.DeviceKeys.NUM_ONE, Devices.DeviceKeys.NUM_TWO, Devices.DeviceKeys.NUM_THREE, Devices.DeviceKeys.NUM_ZERO, Devices.DeviceKeys.NUM_PERIOD, Devices.DeviceKeys.NUM_ENTER });
this._CTColor = Color.FromArgb(158, 205, 255);
this._TColor = Color.FromArgb(221, 99, 33);
this._FlashColor = Color.FromArgb(255, 0, 0);
this._PrimedColor = Color.FromArgb(0, 255, 0);
this._DisplayWinningTeamColor = true;
Expand Down Expand Up @@ -161,28 +149,6 @@ public override EffectLayer Render(IGameState state)
if (Properties.PeripheralUse)
bomb_effect_layer.Set(Devices.DeviceKeys.Peripheral, bombcolor);
}
else if (csgostate.Round.Bomb == BombState.Defused)
{
bombtimer.Stop();
if (Properties.DisplayWinningTeamColor)
{
bomb_effect_layer.Set(Properties.Sequence, Properties.CTColor);

if (Properties.PeripheralUse)
bomb_effect_layer.Set(Devices.DeviceKeys.Peripheral, Properties.CTColor);
}
}
else if (csgostate.Round.Bomb == BombState.Exploded)
{
bombtimer.Stop();
if (Properties.DisplayWinningTeamColor)
{
bomb_effect_layer.Set(Properties.Sequence, Properties.TColor);

if (Properties.PeripheralUse)
bomb_effect_layer.Set(Devices.DeviceKeys.Peripheral, Properties.TColor);
}
}
else
{
bombtimer.Stop();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
using Aurora.EffectsEngine;
using Aurora.Profiles.CSGO.GSI;
using Aurora.Profiles.CSGO.GSI.Nodes;
using Aurora.Settings;
using Aurora.Settings.Layers;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;

namespace Aurora.Profiles.CSGO.Layers
{
public class CSGODeathLayerHandlerProperties : LayerHandlerProperties2Color<CSGODeathLayerHandlerProperties>
{
public Color? _DeathColor { get; set; }

[JsonIgnore]
public Color DeathColor { get { return Logic._DeathColor ?? _DeathColor ?? Color.Empty; } }

public int? _FadeOutAfter { get; set; }

[JsonIgnore]
public int FadeOutAfter { get { return Logic._FadeOutAfter ?? _FadeOutAfter ?? 5; } }

public CSGODeathLayerHandlerProperties() : base() { }

public CSGODeathLayerHandlerProperties(bool assign_default = false) : base(assign_default) { }

public override void Default()
{
base.Default();

this._DeathColor = Color.Red;
this._FadeOutAfter = 3;
}

}

public class CSGODeathLayerHandler : LayerHandler<CSGODeathLayerHandlerProperties>
{
private bool isDead = false;
private long fadeStartAt = 15;
private int fadeAlpha = 255;

public CSGODeathLayerHandler() : base()
{
_ID = "CSGODeathEffect";
}

protected override UserControl CreateControl()
{
return new Control_CSGODeathLayer(this);
}

public override EffectLayer Render(IGameState state)
{
EffectLayer effectLayer = new EffectLayer("CSGO - Death Effect");

if (state is GameState_CSGO)
{
GameState_CSGO gameState = state as GameState_CSGO;
Color deathColor = this.Properties.DeathColor;

// Confirm if CS:GO Player is correct
if (gameState.Provider.SteamID.Equals(gameState.Player.SteamID))
{

// Are they dead?
if (!isDead && gameState.Player.State.Health <= 0 && gameState.Previously.Player.State.Health > 0)
{
isDead = true;

fadeAlpha = 255;
fadeStartAt = Utils.Time.GetMillisecondsSinceEpoch() + (long)(this.Properties.FadeOutAfter * 1000D);
} else if (gameState.Player.State.Health > 0)
{
isDead = false;
return effectLayer;
}

// If so...
if (isDead)
{

Global.logger.Info("IsDead");
if (fadeStartAt <= Utils.Time.GetMillisecondsSinceEpoch())
{
int fadeAlpha = getFadeAlpha();
Global.logger.Info(fadeAlpha);

deathColor = Color.FromArgb(fadeAlpha, deathColor.R, deathColor.G, deathColor.B);

if (fadeAlpha == 0)
{
isDead = false;
}
}

effectLayer.Fill(deathColor);
}
}
}

return effectLayer;
}

public override void SetApplication(Application profile)
{
(Control as Control_CSGODeathLayer).SetProfile(profile);
base.SetApplication(profile);
}

private int getFadeAlpha()
{
fadeAlpha -= 15;
return fadeAlpha = (fadeAlpha < 0 ? 0 : fadeAlpha);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public override void Default()

}

[Obsolete("This layer is obselete and has been replaced by the Overrides system.")]
public class CSGOFlashbangLayerHandler : LayerHandler<CSGOFlashbangLayerHandlerProperties>
{
public CSGOFlashbangLayerHandler() : base()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ public override void Default()
base.Default();

this._Sequence = new KeySequence(new Devices.DeviceKeys[] { Devices.DeviceKeys.G1, Devices.DeviceKeys.G2, Devices.DeviceKeys.G3, Devices.DeviceKeys.G4, Devices.DeviceKeys.G5 });
this._RegularKillColor = Color.FromArgb(0, 255, 0);
this._HeadshotKillColor = Color.FromArgb(255, 80, 0);
this._RegularKillColor = Color.FromArgb(255, 204, 0);
this._HeadshotKillColor = Color.FromArgb(255, 0, 0);
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public override void Default()
}
}

[Obsolete("This layer is obselete and has been replaced by the Overrides system.")]
public class CSGOTypingIndicatorLayerHandler : LayerHandler<CSGOTypingIndicatorLayerHandlerProperties>
{
public CSGOTypingIndicatorLayerHandler() : base()
Expand Down
Loading

0 comments on commit 3272755

Please sign in to comment.