diff --git a/plugins/l4d2_feedthetrolls.smx b/plugins/l4d2_feedthetrolls.smx index 531cf87..7b82d12 100644 Binary files a/plugins/l4d2_feedthetrolls.smx and b/plugins/l4d2_feedthetrolls.smx differ diff --git a/scripting/include/feedthetrolls.inc b/scripting/include/feedthetrolls.inc new file mode 100644 index 0000000..cbd7598 --- /dev/null +++ b/scripting/include/feedthetrolls.inc @@ -0,0 +1,18 @@ +#if defined _ftt_included_ + #endinput +#endif +#define _ftt_included_ + + +enum TrollModifier { + TrollMod_Invalid = 0, + TrollMod_Instant = 1 << 0, + TrollMod_Constant = 1 << 1, + TrollMod_PlayerOnly = 1 << 2, // Does the troll only work on players, not bots? If set, troll only applied on real user. If not, troll applied to both bot and idler +} + +native void ApplyTroll(int victim, const char[] name, TrollModifier modifier = TrollMod_Invalid, int flags, int activator, bool silent = false); + +forward void OnTrollApplied(int victim, const char[] trollName, int flags = 0, int activator = 0); + +forward void OnTrollMarked(int activator, int victim); \ No newline at end of file diff --git a/scripting/include/feedthetrolls/base.inc b/scripting/include/feedthetrolls/base.inc index a5ce655..58ab623 100644 --- a/scripting/include/feedthetrolls/base.inc +++ b/scripting/include/feedthetrolls/base.inc @@ -193,12 +193,13 @@ enum struct Troll { /////// TROLL ACTIVATION - void Activate(int client, int activator, trollModifier modifier = TrollMod_Invalid, int flags = 0) { + void Activate(int client, int activator, trollModifier modifier = TrollMod_Invalid, int flags = 0, bool silent = false) { if(modifier == TrollMod_Invalid) modifier = this.GetDefaultMod(); // Sadly, unable to pass in to ApplyTroll, so it has to do unnecessary lookup via string - ApplyTroll(client, this.name, activator, modifier, flags); + ApplyTroll(client, this.name, activator, modifier, flags, silent); } + void Toggle(int client, int flags) { ToggleTroll(client, this.name, flags); } @@ -371,6 +372,13 @@ void ApplyTroll(int victim, const char[] name, int activator, trollModifier modi LogAction(activator, victim, "\"%L\" deactivated {yellow}\"%s\"{default} on \"%L\"", activator, troll.name, victim); } else { static char flagName[MAX_TROLL_FLAG_LENGTH]; + // strcopy(flagName, sizeof(flagName), troll.name) + // Call_StartForward(g_TrollAppliedForward); + // Call_PushCell(victim); + // Call_PushString(flagName); + // Call_PushCell(flags); + // Call_PushCell(activator); + // Call_Finish(); flagName[0] = '\0'; for(int i = 0; i < 32; i++) { if(flags & (1 << i)) { @@ -445,3 +453,25 @@ public void SetCategory(const char[] newCat) { void GetCategory(int category, char[] buffer, int size) { categories.GetString(category, buffer, size); } + + +public int Native_ApplyTroll(Handle plugin, int numParams) { + int victim = GetNativeCell(1); + char name[MAX_TROLL_NAME_LENGTH]; + GetNativeString(2, name, sizeof(name)); + trollModifier modifier = view_as(GetNativeCell(3)); + if(view_as(modifier) < 0) { + ThrowNativeError(SP_ERROR_NATIVE, "Provided modifier is invalid (out of range)"); + } + int flags = GetNativeCell(4); + int activator = GetNativeCell(5); + + int index = GetTrollID(name); + if(index > 0) { + Trolls[index].Activate(victim, activator, modifier, flags, GetNativeCell(7)); + } else { + ThrowNativeError(SP_ERROR_NATIVE, "Could not find troll with name \"%s\"", name); + } + return 0; +} + \ No newline at end of file diff --git a/scripting/include/ftt.inc b/scripting/include/ftt.inc index 0f4b6d7..d23f85b 100644 --- a/scripting/include/ftt.inc +++ b/scripting/include/ftt.inc @@ -12,6 +12,7 @@ enum L4D2Infected }; GlobalForward g_PlayerMarkedForward; +GlobalForward g_TrollAppliedForward; Handle g_hWitchAttack; int g_iWitchAttackVictim; Handle hThrowTimer; diff --git a/scripting/l4d2_feedthetrolls.sp b/scripting/l4d2_feedthetrolls.sp index 5e0f44e..8024020 100644 --- a/scripting/l4d2_feedthetrolls.sp +++ b/scripting/l4d2_feedthetrolls.sp @@ -30,6 +30,11 @@ public Plugin myinfo = url = "https://github.com/Jackzmc/sourcemod-plugins" }; +public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max) { + CreateNative("ApplyTroll", Native_ApplyTroll); + return APLRes_Success; +} + public void OnPluginStart() { EngineVersion g_Game = GetEngineVersion(); @@ -38,7 +43,9 @@ public void OnPluginStart() { } LoadTranslations("common.phrases"); - g_PlayerMarkedForward = new GlobalForward("FTT_OnClientMarked", ET_Ignore, Param_Cell, Param_Cell); + g_PlayerMarkedForward = new GlobalForward("OnTrollMarked", ET_Ignore, Param_Cell, Param_Cell); + g_TrollAppliedForward = new GlobalForward("OnTrollApplied", ET_Ignore, Param_Cell, Param_Cell); + // Load core things (trolls & phrases): REPLACEMENT_PHRASES = new StringMap();