Skip to content

Commit

Permalink
1.1.0 | Add effect and code improved
Browse files Browse the repository at this point in the history
  • Loading branch information
Vretu-Dev committed Oct 29, 2024
1 parent 832451f commit 86c6398
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 20 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.vs
bin
obj
25 changes: 23 additions & 2 deletions LifeForMoreStamina/LifeForMoreStamina.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Timers;
using Exiled.API.Enums;
using Exiled.API.Features;
using Exiled.Events.EventArgs.Player;
using Player = Exiled.API.Features.Player;

namespace LifeForMoreStamina
Expand All @@ -19,12 +20,14 @@ public override void OnEnabled()
{
Exiled.Events.Handlers.Server.RoundStarted += OnRoundStarted;
Exiled.Events.Handlers.Server.RestartingRound += OnRestartingRound;
Exiled.Events.Handlers.Player.Hurting += OnHurting;
base.OnEnabled();
}
public override void OnDisabled()
{
Exiled.Events.Handlers.Server.RoundStarted -= OnRoundStarted;
Exiled.Events.Handlers.Server.RestartingRound -= OnRestartingRound;
Exiled.Events.Handlers.Player.Hurting -= OnHurting;
base.OnDisabled();
}
private void OnRoundStarted()
Expand Down Expand Up @@ -55,14 +58,32 @@ private void OnStaminaCheck(object sender, ElapsedEventArgs e)
{
player.Health -= Config.HpRemoved;

if (player.Health < 0.8)
if (Config.VisualEffect)
{
player.EnableEffect(EffectType.Bleeding, 1, 1);
player.EnableEffect(EffectType.Bleeding, 1, 2);
}
if (!Config.VisualEffect && Config.KillOnZeroHp && player.Health < 0.8)
{
player.EnableEffect(EffectType.Bleeding, 1, 2);
}
}
}
}
}
}
private void OnHurting(HurtingEventArgs ev)
{
if (ev.DamageHandler.Type == DamageType.Bleeding)
{
if (Config.VisualEffect)
{
ev.IsAllowed = false;
}
if (Config.KillOnZeroHp && ev.Player.Health < 0.8)
{
ev.IsAllowed = true;
}
}
}
}
}
30 changes: 17 additions & 13 deletions LifeForMoreStamina/LifeForMoreStamina.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,9 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="0Harmony, Version=2.3.3.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Lib.Harmony.2.3.3\lib\net48\0Harmony.dll</HintPath>
</Reference>
<Reference Include="Assembly-CSharp" HintPath="..\packages\EXILEDOFFICIAL.8.11.0\lib\net48\Assembly-CSharp-Publicized.dll" Private="True" />
<Reference Include="Assembly-CSharp-firstpass" HintPath="..\SCPSL_Data\Managed\Assembly-CSharp-firstpass.dll" Private="false" />
<Reference Include="Assembly-CSharp-Publicized, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\EXILEDOFFICIAL.8.11.0\lib\net48\Assembly-CSharp-Publicized.dll</HintPath>
<Private>True</Private>
<Reference Include="Assembly-CSharp-firstpass">
<HintPath>..\..\Exiled References\Assembly-CSharp-firstpass.dll</HintPath>
</Reference>
<Reference Include="CommandSystem.Core, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\EXILEDOFFICIAL.8.11.0\lib\net48\CommandSystem.Core.dll</HintPath>
Expand All @@ -64,17 +59,15 @@
<Reference Include="Exiled.Permissions, Version=8.11.0.0, Culture=neutral, processorArchitecture=AMD64">
<HintPath>..\packages\EXILEDOFFICIAL.8.11.0\lib\net48\Exiled.Permissions.dll</HintPath>
</Reference>
<Reference Include="Mirror">
<HintPath>..\..\Exiled References\Mirror.dll</HintPath>
</Reference>
<Reference Include="NorthwoodLib, Version=1.3.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\EXILEDOFFICIAL.8.11.0\lib\net48\NorthwoodLib.dll</HintPath>
</Reference>
<Reference Include="PluginAPI, Version=13.1.3.0, Culture=neutral, processorArchitecture=AMD64">
<HintPath>..\packages\EXILEDOFFICIAL.8.11.0\lib\net48\PluginAPI.dll</HintPath>
</Reference>
<Reference Include="UnityEngine" HintPath="..\SCPSL_Data\Managed\UnityEngine.dll" Private="false" />
<Reference Include="UnityEngine.CoreModule" HintPath="..\SCPSL_Data\Managed\UnityEngine.CoreModule.dll" Private="false" />
<Reference Include="UnityEngine.PhysicsModule" HintPath="..\SCPSL_Data\Managed\UnityEngine.PhysicsModule.dll" Private="false" />
<Reference Include="Pooling" HintPath="..\SCPSL_Data\Managed\Pooling.dll" Private="false" />
<Reference Include="Mirror" HintPath="..\SCPSL_Data\Managed\Mirror.dll" Private="false" />
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
Expand All @@ -83,6 +76,15 @@
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
<Reference Include="UnityEngine">
<HintPath>..\..\Exiled References\UnityEngine.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.CoreModule">
<HintPath>..\..\Exiled References\UnityEngine.CoreModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.PhysicsModule">
<HintPath>..\..\Exiled References\UnityEngine.PhysicsModule.dll</HintPath>
</Reference>
<Reference Include="YamlDotNet, Version=11.0.0.0, Culture=neutral, PublicKeyToken=ec19458f3c15af5e, processorArchitecture=MSIL">
<HintPath>..\packages\EXILEDOFFICIAL.8.11.0\lib\net48\YamlDotNet.dll</HintPath>
</Reference>
Expand All @@ -93,7 +95,9 @@
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
<PackageReference Include="ExMod.Exiled">
<Version>8.13.1</Version>
</PackageReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
8 changes: 8 additions & 0 deletions LifeForMoreStamina/config.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
using Exiled.API.Interfaces;
using System.ComponentModel;

namespace LifeForMoreStamina
{
public class Config : IConfig
{
public bool IsEnabled { get; set; } = true;
public bool Debug { get; set; } = false;
[Description("How much stamina does the player receive when it runs out?")]
public float StaminaAdded { get; set; } = 0.060f;
[Description("Stamina level at which it starts to regenerate.")]
public float StaminaThreshold { get; set; } = 0.025f;
[Description("How much health is deducted?")]
public float HpRemoved { get; set; } = 0.5f;
[Description("Kills the player when their HP reaches zero.")]
public bool KillOnZeroHp { get; set; } = true;
[Description("Apply Bleeding Effect when HP is depleting (Visual Only)")]
public bool VisualEffect { get; set; } = true;
}
}
5 changes: 0 additions & 5 deletions LifeForMoreStamina/packages.config

This file was deleted.

7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,14 @@ Trades your hp into stamina when it's over
LifeForMoreStamina:
is_enabled: true
debug: false
# How much stamina does the player receive when it runs out?
stamina_added: 0.0599999987
# Stamina level at which it starts to regenerate.
stamina_threshold: 0.0250000004
# How much health is deducted?
hp_removed: 0.5
# Kills the player when their HP reaches zero.
kill_on_zero_hp: true
# Apply Bleeding Effect when HP is depleting (Visual Only)
visual_effect: true
```

0 comments on commit 86c6398

Please sign in to comment.