Skip to content

Commit

Permalink
feat: dynamic channels, DRY, CI update (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
Rushaway authored Mar 23, 2024
1 parent 171545c commit 6ec6a0b
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 13 deletions.
6 changes: 6 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
20 changes: 15 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -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:
Expand Down Expand Up @@ -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
Expand Down
53 changes: 48 additions & 5 deletions addons/sourcemod/scripting/BossHUD.sp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
#include <LagReducer>
#include <multicolors>

#undef REQUIRE_PLUGIN
#tryinclude <DynamicChannels>
#define REQUIRE_PLUGIN

#pragma newdecls required

#define MAX_TEXT_LENGTH 64
Expand All @@ -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;

Expand All @@ -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];
Expand All @@ -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"
};

Expand Down Expand Up @@ -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.");
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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())
Expand Down Expand Up @@ -1298,4 +1341,4 @@ int EntitySetHealth(int client, int entity, int value, bool bAdd = true)
AcceptEntityInput(entity, sValue, client, client);
}
return health;
}
}
13 changes: 10 additions & 3 deletions sourceknight.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 6ec6a0b

Please sign in to comment.