-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from oscar-wos/1.0.0
INIT
- Loading branch information
Showing
8 changed files
with
247 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
name: Build and Release | ||
|
||
on: push | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup .NET | ||
uses: actions/setup-dotnet@v4 | ||
with: | ||
dotnet-version: '8.0.x' | ||
|
||
- name: Restore dependencies | ||
run: dotnet restore | ||
|
||
- name: Build | ||
run: dotnet build -c Release | ||
|
||
release: | ||
needs: build | ||
runs-on: ubuntu-latest | ||
permissions: write-all | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup .NET | ||
uses: actions/setup-dotnet@v4 | ||
with: | ||
dotnet-version: '8.0.x' | ||
|
||
- name: Restore dependencies | ||
run: dotnet restore | ||
|
||
- name: Build | ||
run: dotnet build -c Release | ||
|
||
- name: Create Directories | ||
run: | | ||
mkdir -p plugin/plugins/Refiller | ||
- name: Move Files | ||
run: | | ||
mv ./src/bin/Release/net8.0/* ./plugin/plugins/Refiller | ||
- name: Zip | ||
run: | | ||
cd plugin/ | ||
zip -r Refiller-${{ github.sha }}.zip . | ||
- name: Extract version and create tag | ||
id: extract_version | ||
run: | | ||
version=$(grep -oP 'public override string ModuleVersion => "\K(.*)(?=";)' ./src/Globals.cs) | ||
echo "Version found: $version" | ||
git config --global user.email "actions@github.com" | ||
git config --global user.name "GitHub Actions" | ||
git tag $version | ||
git push origin $version | ||
echo "::set-output name=version::$version" | ||
- name: Publish | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: Refiller-${{ github.sha }} | ||
path: plugin | ||
|
||
- name: Create Release | ||
id: create_release | ||
uses: actions/create-release@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
tag_name: ${{ steps.extract_version.outputs.version }} | ||
release_name: ${{ steps.extract_version.outputs.version }} | ||
body: | | ||
This is an automated release. | ||
draft: false | ||
prerelease: false | ||
|
||
- name: Upload Release Asset | ||
id: upload_release_asset | ||
uses: actions/upload-release-asset@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
upload_url: ${{ steps.create_release.outputs.upload_url }} | ||
asset_path: ./plugin/Refiller-${{ github.sha }}.zip | ||
asset_name: Refiller.zip | ||
asset_content_type: application/zip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,3 @@ | ||
# Prerequisites | ||
*.d | ||
|
||
# Object files | ||
*.o | ||
*.ko | ||
*.obj | ||
*.elf | ||
|
||
# Linker output | ||
*.ilk | ||
*.map | ||
*.exp | ||
|
||
# Precompiled Headers | ||
*.gch | ||
*.pch | ||
|
||
# Libraries | ||
*.lib | ||
*.a | ||
*.la | ||
*.lo | ||
|
||
# Shared objects (inc. Windows DLLs) | ||
*.dll | ||
*.so | ||
*.so.* | ||
*.dylib | ||
|
||
# Executables | ||
*.exe | ||
*.out | ||
*.app | ||
*.i*86 | ||
*.x86_64 | ||
*.hex | ||
|
||
# Debug files | ||
*.dSYM/ | ||
*.su | ||
*.idb | ||
*.pdb | ||
|
||
# Kernel Module Compile Results | ||
*.mod* | ||
*.cmd | ||
.tmp_versions/ | ||
modules.order | ||
Module.symvers | ||
Mkfile.old | ||
dkms.conf | ||
bin/ | ||
obj/ | ||
.vs/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,9 @@ | ||
# Refiller | ||
CS2 - Heal | ||
`counterstrikesharp/configs/plugins/Refiller/Refiller.json` | ||
```json | ||
{ | ||
"AssistRefill": // true, false - Apply refill's to assisters | ||
"HealthRefill": // "all", "0", "100" - Amount of health to refill | ||
"AmmoRefill": // "all", "current", "off" - "all" = slot1,slot2,slot3,slot4 - "current" = current weapon | ||
"ArmorRefill": // true, false - Refill armor | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 17 | ||
VisualStudioVersion = 17.10.34928.147 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Refiller", "src\Refiller.csproj", "{C62E916A-1F2B-456C-95DE-DA718B446F37}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{C62E916A-1F2B-456C-95DE-DA718B446F37}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{C62E916A-1F2B-456C-95DE-DA718B446F37}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{C62E916A-1F2B-456C-95DE-DA718B446F37}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{C62E916A-1F2B-456C-95DE-DA718B446F37}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {5204CE6F-E75D-4148-9B62-B1B293097F09} | ||
EndGlobalSection | ||
EndGlobal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using CounterStrikeSharp.API.Core; | ||
using System.Text.Json.Serialization; | ||
|
||
namespace Refiller; | ||
|
||
public class RefillerConfig : BasePluginConfig | ||
{ | ||
public override int Version { get; set; } = 1; | ||
[JsonPropertyName("AssistRefill")] public bool AssistRefill { get; set; } = true; // true, false | ||
[JsonPropertyName("HealthRefill")] public string HealthRefill { get; set; } = "all"; // "all", "0", "100" | ||
[JsonPropertyName("AmmoRefill")] public string AmmoRefill { get; set; } = "all"; // "all", "current", "off" | ||
[JsonPropertyName("ArmorRefill")] public bool ArmorRefill { get; set; } = true; // true, false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
namespace Refiller; | ||
|
||
public partial class Refiller | ||
{ | ||
public RefillerConfig Config { get; set; } = new(); | ||
public override string ModuleName => "Refiller"; | ||
public override string ModuleAuthor => "github.com/oscar-wos/Refiller"; | ||
public override string ModuleVersion => "1.0.0"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
using CounterStrikeSharp.API; | ||
using CounterStrikeSharp.API.Core; | ||
using CounterStrikeSharp.API.Modules.Utils; | ||
using Microsoft.Extensions.Logging; | ||
|
||
namespace Refiller; | ||
|
||
public partial class Refiller : BasePlugin, IPluginConfig<RefillerConfig> | ||
{ | ||
public void OnConfigParsed(RefillerConfig config) | ||
{ | ||
Config = config; | ||
} | ||
|
||
public override void Load(bool isReload) | ||
{ | ||
RegisterEventHandler<EventPlayerDeath>(OnPlayerDeath); | ||
} | ||
|
||
public HookResult OnPlayerDeath(EventPlayerDeath @event, GameEventInfo info) | ||
{ | ||
var victim = @event.Userid; | ||
|
||
if (victim == null || !victim.IsValid) | ||
return HookResult.Continue; | ||
|
||
List<CCSPlayerController?> players = | ||
[ | ||
@event.Attacker, | ||
Config.AssistRefill ? @event.Assister : null | ||
]; | ||
|
||
List<CHandle<CBasePlayerWeapon>> weapons = []; | ||
|
||
foreach (var player in players.Where(player => player != null && player.IsValid)) | ||
{ | ||
if (Config.AmmoRefill == "all") | ||
weapons.AddRange(player!.PlayerPawn!.Value!.WeaponServices!.MyWeapons); | ||
else if (Config.AmmoRefill == "current") | ||
weapons.Add(player!.PlayerPawn!.Value!.WeaponServices!.ActiveWeapon); | ||
} | ||
|
||
Server.NextFrame(() => | ||
{ | ||
foreach (var weapon in weapons) | ||
{ | ||
var weaponData = weapon.Value!.As<CCSWeaponBase>().VData; | ||
|
||
if (weaponData == null) | ||
continue; | ||
|
||
weapon.Value!.Clip1 = weaponData.MaxClip1; | ||
weapon.Value!.ReserveAmmo[0] = weaponData.PrimaryReserveAmmoMax; | ||
Utilities.SetStateChanged(weapon.Value!.As<CCSWeaponBase>(), "CBasePlayerWeapon", "m_pReserveAmmo"); | ||
} | ||
|
||
foreach (var player in players.Where(player => player != null && player.IsValid)) | ||
{ | ||
var currentHealth = player!.PlayerPawn.Value!.Health; | ||
|
||
player!.PlayerPawn.Value!.Health = Config.HealthRefill switch | ||
{ | ||
"all" => 100, | ||
_ => currentHealth + int.Parse(Config.HealthRefill) >= 100 ? 100 : currentHealth + int.Parse(Config.HealthRefill) | ||
}; | ||
|
||
Utilities.SetStateChanged(player!.PlayerPawn.Value!, "CBaseEntity", "m_iHealth"); | ||
|
||
if (!Config.ArmorRefill) | ||
continue; | ||
|
||
player!.PlayerPawn.Value!.ArmorValue = 100; | ||
Utilities.SetStateChanged(player!.PlayerPawn.Value!, "CCSPlayerPawn", "m_ArmorValue"); | ||
} | ||
}); | ||
|
||
return HookResult.Continue; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="CounterStrikeSharp.API" Version="*" ExcludeAssets="runtime" /> | ||
</ItemGroup> | ||
|
||
</Project> |