From 6ec6a0b8952d2241d90d39725da210cf8abd7da8 Mon Sep 17 00:00:00 2001 From: Rushaway Date: Sat, 23 Mar 2024 13:28:37 +0100 Subject: [PATCH] feat: dynamic channels, DRY, CI update (#15) --- .github/dependabot.yml | 6 +++ .github/workflows/ci.yml | 20 +++++++--- addons/sourcemod/scripting/BossHUD.sp | 53 ++++++++++++++++++++++++--- sourceknight.yaml | 13 +++++-- 4 files changed, 79 insertions(+), 13 deletions(-) create mode 100644 .github/dependabot.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..120c689 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,6 @@ +version: 2 +updates: + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "weekly" \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0261132..ae9b079 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,11 +1,21 @@ name: CI -on: [push, pull_request, workflow_dispatch] +on: + push: + branches: + - main + - master + tags: + - '*' + pull_request: + branches: + - main + - master jobs: build: name: "Build" - runs-on: ${{ matrix.os }} + runs-on: package strategy: fail-fast: false matrix: @@ -27,7 +37,7 @@ jobs: - name: Upload build archive for test runners uses: actions/upload-artifact@v3 with: - name: ${{ runner.os }} + name: package path: /tmp/package tag: @@ -72,8 +82,8 @@ jobs: - name: Package run: | ls -Rall - if [ -d "./Linux/" ]; then - cd ./Linux/ + if [ -d "./package/" ]; then + cd ./package/ tar -czf ../${{ github.event.repository.name }}-${{ env.RELEASE_VERSION }}.tar.gz -T <(\ls -1) cd - fi diff --git a/addons/sourcemod/scripting/BossHUD.sp b/addons/sourcemod/scripting/BossHUD.sp index 24d30cb..3391acc 100644 --- a/addons/sourcemod/scripting/BossHUD.sp +++ b/addons/sourcemod/scripting/BossHUD.sp @@ -10,6 +10,10 @@ #include #include +#undef REQUIRE_PLUGIN +#tryinclude +#define REQUIRE_PLUGIN + #pragma newdecls required #define MAX_TEXT_LENGTH 64 @@ -19,7 +23,7 @@ ConVar g_cVDisplayType; ConVar g_cVTopHitsPos, g_cVTopHitsColor, g_cVPlayersInTable; ConVar g_cVStatsReward, g_cVBossHitMoney; ConVar g_cVHudMinHealth, g_cVHudMaxHealth; -ConVar g_cVHudTimeout; +ConVar g_cVHudTimeout, g_cvHUDChannel; ConVar g_cVIgnoreFakeClients; ConVar g_cVHudHealthPercentageSquares; @@ -40,6 +44,7 @@ float g_fHudPos[2], g_fTopHitsPos[2]; bool g_bLate = false; bool g_bIsCSGO = false; +bool g_bDynamicChannels = false; char g_sHUDText[256]; char g_sHUDTextSave[256]; @@ -58,7 +63,7 @@ public Plugin myinfo = { name = "BossHUD", author = "AntiTeal, Cloud Strife, maxime1907", description = "Show the health of bosses and breakables", - version = "3.6.5", + version = "3.6.6", url = "antiteal.com" }; @@ -103,6 +108,7 @@ public void OnPluginStart() g_cVHudMinHealth = CreateConVar("sm_bhud_health_min", "1000", "Determines what minimum hp entities should have to be detected.", _, true, 0.0, true, 1000000.0); g_cVHudMaxHealth = CreateConVar("sm_bhud_health_max", "100000", "Determines what maximum hp entities should have to be detected.", _, true, 0.0, true, 1000000.0); g_cVHudTimeout = CreateConVar("sm_bhud_timeout", "0.5", "Determines when the entity health is supposed to fade away when it doesnt change.", _, true, 0.0, true, 10.0); + g_cvHUDChannel = CreateConVar("sm_bhud_hud_channel", "1", "The channel for the hud if using DynamicChannels", _, true, 0.0, true, 6.0); g_cVTopHitsPos = CreateConVar("sm_bhud_tophits_position", "0.02 0.3", "The X and Y position for the hud."); g_cVTopHitsColor = CreateConVar("sm_bhud_tophits_color", "255 255 0", "RGB color value for the hud."); @@ -139,6 +145,23 @@ public void OnPluginStart() } } +public void OnAllPluginsLoaded() +{ + g_bDynamicChannels = LibraryExists("DynamicChannels"); +} + +public void OnLibraryAdded(const char[] name) +{ + if (strcmp(name, "DynamicChannels", false) == 0) + g_bDynamicChannels = true; +} + +public void OnLibraryRemoved(const char[] name) +{ + if (strcmp(name, "DynamicChannels", false) == 0) + g_bDynamicChannels = false; +} + public void OnPluginEnd() { // Late unload @@ -967,11 +990,31 @@ void SendHudMsg( if (hHudSync != INVALID_HANDLE) { SetHudTextParams(fPosition[0], fPosition[1], fDuration, iColors[0], iColors[1], iColors[2], iTransparency, 0, 0.0, 0.0, 0.0); - ClearSyncHud(client, hHudSync); char szMessageFinale[512]; FormatEx(szMessageFinale, sizeof(szMessageFinale), "%s", szMessage); ReplaceString(szMessageFinale,sizeof(szMessageFinale), "PERCENTAGE", "%"); - ShowSyncHudText(client, hHudSync, "%s", szMessageFinale); + + bool bDynamicAvailable = false; + int iHUDChannel = -1; + + int iChannel = g_cvHUDChannel.IntValue; + if (iChannel < 0 || iChannel > 6) + iChannel = 1; + + bDynamicAvailable = g_bDynamicChannels && CanTestFeatures() && GetFeatureStatus(FeatureType_Native, "GetDynamicChannel") == FeatureStatus_Available; + + #if defined _DynamicChannels_included_ + if (bDynamicAvailable) + iHUDChannel = GetDynamicChannel(iChannel); + #endif + + if (bDynamicAvailable) + ShowHudText(client, iHUDChannel, "%s", szMessageFinale); + else + { + ClearSyncHud(client, hHudSync); + ShowSyncHudText(client, hHudSync, "%s", szMessageFinale); + } } } else if (type == DISPLAY_HINT && !IsVoteInProgress()) @@ -1298,4 +1341,4 @@ int EntitySetHealth(int client, int entity, int value, bool bAdd = true) AcceptEntityInput(entity, sValue, client, client); } return health; -} +} \ No newline at end of file diff --git a/sourceknight.yaml b/sourceknight.yaml index 9e3d2ee..d2c0dd8 100644 --- a/sourceknight.yaml +++ b/sourceknight.yaml @@ -1,11 +1,11 @@ project: - sourceknight: 0.1 + sourceknight: 0.2 name: BossHUD dependencies: - name: sourcemod type: tar - version: 1.11.0-git6917 - location: https://sm.alliedmods.net/smdrop/1.11/sourcemod-1.11.0-git6917-linux.tar.gz + version: 1.11.0-git6934 + location: https://sm.alliedmods.net/smdrop/1.11/sourcemod-1.11.0-git6934-linux.tar.gz unpack: - source: /addons dest: /addons @@ -45,6 +45,13 @@ project: - source: /addons/sourcemod/scripting/include dest: /addons/sourcemod/scripting/include + - name: dynamicchannels + type: git + repo: https://github.com/srcdslab/sm-plugin-DynamicChannels + unpack: + - source: /scripting/include + dest: /addons/sourcemod/scripting/include + root: / output: /addons/sourcemod/plugins targets: