Skip to content

Commit

Permalink
Post-TFConnect fixes (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mikusch authored Dec 19, 2023
1 parent e8d0736 commit d336a3a
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 26 deletions.
16 changes: 9 additions & 7 deletions README.MD
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
# TF2 Chaos Mod

<img alt="Logo" src="https://user-images.githubusercontent.com/25514044/216839199-de0a68ae-27d4-44c6-b394-54c98c85d701.png" width="500"/>
**As seen on [TFConnect 2023](https://tfconnect.org)!**

<img alt="TF2 Chaos Mod Logo" src="https://user-images.githubusercontent.com/25514044/216839199-de0a68ae-27d4-44c6-b394-54c98c85d701.png" width="500"/>

**Welcome to the official home of the TF2 Chaos Mod!**

Every few seconds a new random effect is activated to shake up the game.
Every couple seconds, one of over 150 different effects is activated. Some effects are good and empower certain classes, but others can be bad, hindering gameplay.

You can easily add your own effects using Squirrel (VScript) or SourcePawn.
See [here](https://github.com/Mikusch/ChaosModTF2/wiki) for more information.
You can easily add your own effects using the provided Squirrel (VScript) or SourcePawn API. See [here](https://github.com/Mikusch/ChaosModTF2/wiki) for more information on effect creation.

## Requirements

Expand All @@ -22,6 +23,7 @@ See [here](https://github.com/Mikusch/ChaosModTF2/wiki) for more information.

## Special Thanks

* [ficool2](https://github.com/ficool2) - For helping me set up the VScript API
* [RatX](https://steamcommunity.com/id/ratx15/) - For creating the Chaos Mod logo
* [Red Sun Over Paradise](https://redsun.tf) - For playtesting and giving feedback
* [ficool2](https://github.com/ficool2) - For assistance in setting up the VScript API
* [RatX](https://steamcommunity.com/id/ratx15) - For creating the Chaos Mod logo
* [Red Sun Over Paradise](https://redsun.tf) - For playtesting and giving feedback
* [TFConnect](https://tfconnect.org) - For featuring Chaos Mod in TFConnect 2023, supporting SpecialEffect's mission to aid & empower gamers with physical disabilities by helping them play video games
30 changes: 20 additions & 10 deletions addons/sourcemod/scripting/chaos.sp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include <vscript>
#include <morecolors>

#define PLUGIN_VERSION "1.5.0"
#define PLUGIN_VERSION "1.5.1"

ConVar sm_chaos_enabled;
ConVar sm_chaos_effect_cooldown;
Expand Down Expand Up @@ -125,14 +125,6 @@ public void OnPluginStart()
g_hTimerBarHudSync = CreateHudSynchronizer();

Events_Initialize();

GameData hGameConf = new GameData("chaos");
if (!hGameConf)
LogError("Failed to find chaos gamedata");

Data_Initialize(hGameConf);

delete hGameConf;
}

public void OnPluginEnd()
Expand All @@ -147,6 +139,18 @@ public void OnMapStart()
// Initialize VScript system
ServerCommand("script_execute %s", "chaos");

// Initialize all effects
GameData hGameConf = new GameData("chaos");
if (hGameConf)
{
Data_Initialize(hGameConf);
delete hGameConf;
}
else
{
LogError("Failed to find chaos gamedata");
}

int nLength = g_hEffects.Length;
for (int i = 0; i < nLength; i++)
{
Expand Down Expand Up @@ -743,7 +747,7 @@ bool ActivateEffectById(const char[] szEffectId, bool bForce = false)

char szMessage[256];
Format(szMessage, sizeof(szMessage), "%t", "#Chaos_Effect_Activated", szName, client);
SendHudNotificationCustom(client, szMessage, "ico_notify_flag_moving_alt");
SendCustomHudNotificationCustom(client, szMessage, "ico_notify_flag_moving_alt");
}
}

Expand Down Expand Up @@ -1058,6 +1062,9 @@ static void ConVarChanged_ChaosEnable(ConVar convar, const char[] oldValue, cons

static Action ConCmd_SetNextEffect(int client, int args)
{
if (!g_bEnabled)
return Plugin_Continue;

if (args < 1)
{
ReplyToCommand(client, "[SM] Usage: sm_chaos_setnexteffect <id>");
Expand Down Expand Up @@ -1085,6 +1092,9 @@ static Action ConCmd_SetNextEffect(int client, int args)

static Action ConCmd_ForceEffect(int client, int args)
{
if (!g_bEnabled)
return Plugin_Continue;

if (args < 1)
{
ReplyToCommand(client, "[SM] Usage: sm_chaos_forceeffect <id>");
Expand Down
18 changes: 9 additions & 9 deletions addons/sourcemod/scripting/chaos/util.sp
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,15 @@ void SendHudNotification(HudNotification_t iType, bool bForceShow = false)
EndMessage();
}

void SendCustomHudNotificationCustom(int client, const char[] szText, const char[] szIcon, TFTeam nTeam = TFTeam_Unassigned)
{
BfWrite bf = UserMessageToBfWrite(StartMessageOne("HudNotifyCustom", client));
bf.WriteString(szText);
bf.WriteString(szIcon);
bf.WriteByte(view_as<int>(nTeam));
EndMessage();
}

void PrintKeyHintText(int client, const char[] format, any...)
{
char buffer[256];
Expand Down Expand Up @@ -338,12 +347,3 @@ int FindItemOffset(int entity)

return FindSendPropInfo(szNetClass, "m_Item");
}

void SendHudNotificationCustom(int client, const char[] szText, const char[] szIcon, TFTeam nTeam = TFTeam_Unassigned)
{
BfWrite bf = UserMessageToBfWrite(StartMessageOne("HudNotifyCustom", client));
bf.WriteString(szText);
bf.WriteString(szIcon);
bf.WriteByte(view_as<int>(nTeam));
EndMessage();
}

0 comments on commit d336a3a

Please sign in to comment.