AlliedModders Donor
Join Date: Jul 2014
Location: Houston, TX
|
01-18-2016
, 12:26
Re: [BOSS] Epic Scout (update v1.0.1, critical fix!)
|
|
Here's a debug version of the Epic Scout subplugin, so you can check if any AMS-supported abilities are initializing properly, especially if you're making any new AMS-supported abilities. This is only actually useful if you're developing AMS-supported abilities.
You'll also want to modify your freak_fortress_2.inc file if you want the debug to output to a separate logfile:
Spoiler
Code:
stock Debug(String:buffer[], any:...)
{
if(FF2_Debug())
{
decl String:message[192], String:debugLog[256];
VFormat(message, sizeof(message), buffer, 2);
CPrintToChatAll("{olive}[FF2 {darkorange}DEBUG{olive}]{default} %s", message);
BuildPath(Path_SM, debugLog, sizeof(debugLog), "logs/freak_fortress_2/ff2_debug.log");
if(!FileExists(debugLog))
{
OpenFile(debugLog, "a+");
}
LogToFile(debugLog, "[FF2 DEBUG] %s", message);
}
}
Files attached: - ff2_sarysapub3.smx & ff2_sarysapub3.sp:
- Debug-enabled build of the AMS_InitSubability stock
- Requires 'ff2_debug' to be set to 1 to view debug output
- ff2_ams.inc:
- Include file containing the 2 important stocks for initializing an AMS-supported or AMS-only ability.
- Be sure to add #include <ff2_ams> for subplugins that will have AMS support.
- List of stocks:
Spoiler
Code:
/**
* Ability Management System Include
*
* Due to load order issues, need to use reflection for these accessor methods.
**/
#if defined _ff2_ams_included
#endinput
#endif
#define _ff2_ams_included
#include <freak_fortress_2>
/**
* Retrieves the plugin's handle
* Useful for calling other subplugins, if using the reflective method.
*
* @param pluginName Plugin Name
* @return Handle of plugin
**/
stock Handle FindPlugin(char[] pluginName)
{
char buffer[256];
char path[PLATFORM_MAX_PATH];
Handle iter=GetPluginIterator();
Handle pl=null;
while(MorePlugins(iter))
{
pl=ReadPlugin(iter);
Format(path, sizeof(path), "%s", pluginName);
GetPluginFilename(pl, buffer, sizeof(buffer));
if(StrContains(buffer, path, false) >= 0)
{
break;
}
else
{
pl=null;
}
}
delete iter;
return pl;
}
/**
* Check if plugin exists
*
* @param pluginName Plugin Name
* @return True if plugin exists, false otherwise.
**/
stock bool PluginExists(char[] pluginName)
{
Handle plugin=FindPlugin(pluginName);
if(plugin!=null) return true;
return false;
}
/**
* Check if function exists
*
* @param pluginName Plugin Name
* @param functionName Function name of public analogue
* @return True if function exists, false otherwise.
**/
stock bool FunctionExists(char[] pluginName, char[] functionName)
{
Handle plugin=FindPlugin(pluginName);
if(plugin!=null)
{
Function func=GetFunctionByName(plugin, functionName);
if(func!=INVALID_FUNCTION)
{
return true;
}
return false;
}
else
{
return false;
}
}
/**
* Autodetect whether AMS will be used for managing RAGE, or a normal E / G RAGE.
*
* @param bossIdx Boss Index
* @param pluginName Plugin Name
* @param abilityName Ability Name
* @return True if ability is ready to be used with AMS, otherwise false
**/
stock bool AMS_IsSubabilityReady(int bossIdx, char[] pluginName, char[] abilityName)
{
return FunctionExists("ff2_sarysapub3.ff2", "AMS_InitSubability") && FF2_HasAbility(bossIdx, "ff2_sarysapub3", "ability_management_system") && !FF2_GetAbilityArgument(bossIdx, pluginName, abilityName, 0);
}
/**
* Initialize the AMS-supported ability or AMS sub-ability
*
* @param bossIdx Boss Index
* @param clientIdx Client Index
* @param pluginName Plugin Name
* @param abilityName Ability Name
* @param prefix Prefix (up to 5 characters long) used for <prefix>_CanInvoke(clientIdx) && <prefix>_Invoke(clientIdx) analogues
* @noreturn
**/
stock void AMS_InitSubability(int bossIdx, int clientIdx, const char[] pluginName, const char[] abilityName, const char[] prefix)
{
Handle plugin=FindPlugin("ff2_sarysapub3.ff2");
if(plugin!=null)
{
Function func=GetFunctionByName(plugin, "AMS_InitSubability");
if(func!=INVALID_FUNCTION)
{
Call_StartFunction(plugin, func);
Call_PushCell(bossIdx);
Call_PushCell(clientIdx);
Call_PushString(pluginName);
Call_PushString(abilityName);
Call_PushString(prefix);
Call_Finish();
}
else
{
LogError("ERROR: Unable to initialize ff2_sarysapub3:AMS_InitSubability()");
}
}
else
{
LogError("ERROR: Unable to initialize ff2_sarysapub3:AMS_InitSubability(). Make sure this plugin exists!");
}
}
- ff2_ams_sample.smx & ff2_ams_sample.sp:
- Sample sub-plugin with a single AMS-supported ability.
Code:
"abilityX"
{
"name" "rage_text"
"arg1" "1" // 0 - Triggered normally, 1 - Triggered by AMS
"arg2" "{red}RUUUUUUUUUUUUUN, {blue}COWARDS!"
// args reserved for the ability management system
"arg1001" "0.0" // delay before first use
"arg1002" "10.0" // cooldown
"arg1003" "Text Taunt" // name
"arg1004" "Prints a message to all clients" // description
"arg1005" "0" // rage cost
"arg1006" "0" // index for ability in the AMS menu
"plugin_name" "ff2_ams_sample"
}
__________________
Last edited by 93SHADoW; 09-08-2020 at 00:44.
Reason: v1.1, this fixes compile errors.
|
|