[TF2] Roll The Dice Revamped v2.5.5
Rewrite of pheadxdll's Roll The Dice. Kudos to him for a great idea.
Description:
Roll The Dice mod for Team Fortress 2. It allows players to "roll the dice" for one of 82 random effects, some good, some bad. The effect will be applied for its custom time to the player and removed afterwards.
This plugin comes with many customization options (see "ConVars" or "Customizing Perks") and developer tools (see "For developers").
Roll The Dice (Revamped) is a rewrite of pheadxdll's Roll The Dice with numerous features added, most notable of which are listed here:
ATTENTION: These tutorials are outdated! Please review the newest API documentation and examples here.
Tutorial on Adding Custom Perks
Note: There are two types of perks - Core & External:
Core perks are added via editing the RTD plugin, External ones are added via a different plugin.
Core perks have consistent IDs specified in the config file, whereas External ones do not necessarly have a consistent ID and they are always greater than the last core perk's ID.
Core perks have custom settings in the config file, but External ones have to handle different perk settings themselves.
You will have to update your custom Core perks with new RTD releases.
External Perks: 1. Register the perk using the RTD2_RegisterPerk() native.
Look in the Include File under For Developers in the main post for an in-depth explanation.
A practical usage could be found in the example plugin attached to this post.
2. RTD2_RegisterPerk() should be used in 2 instances:
In OnPluginStart(), but only when the RTD2_IsRegOpen() native returns TRUE. (to account for late load)
Each time in the RTD2_OnRegOpen() forward. (regular perk registration)
3. Last parameter of RTD2_RegisterPerk() is the callback function with parameters:
int client – The client index to set the perk to, guaranteed to be valid.
int perk ID – Your custom perk's ID which was given to it upon registration with RTD2_RegisterPerk().
bool apply - TRUE if perk should be applied, FALSE if perk should be removed; FALSE is never passed on instant perks.
4. A few notes:
Perks cannot be unregistered once registered. You can use the RTD2_SetPerkBy*() natives to disable them.
If an existent token is passed in the RTD2_RegisterPerk() native, it will override the functionality of a perk with that token. This applies to Core perks as well.
If a Core perk's functionality has been overriden, you can use the RTD2_DefaultCorePerk() native to set it back to default. This native should not be used on External perks.
If your perks hurts other players with SDKHooks_TakeDamage(), I advise you to use the RTD2_CanPlayerBeHurt() native, as it additionally checks whether the player is in Friendly Mode.
Core Perks (simple):
Put your perk's .sp in the scripting/rtd/ folder.
Create a function in it with parameters: (int client, char[] const sPref, bool apply)
Include your perk in scripting/rtd/#perks.sp.
Add your perk to the rtd2_perks.cfg and configure it, having the ID consistency in mind.
Add your initialization function to the switch() statement in the ManagerPerk() function of the scripting/rtd/#manager.sp.
Core Perks (detailed):
First, to clarify, in order to add a custom Core perk, you don't need to edit the base rtd2.sp in the slightest. Everything you need to edit is in the scripting/rtd/ folder.
Before you get started, you should familiarize yourself with the Detailed Breakdown of the rtd2_perks.cfg.
Start Up
Create an .sp with your desired perk's name and place it in the scripting/rtd folder.
This file is where all the magic happens, you can go ahead and use this template:
Template
PHP Code:
//Let's have some global variables so our perk could behave in a customized way char g_sValue1[32]; int g_iValue2; bool g_bValue3; float g_fValue4;
//PerkName_Perk is the only function being called by the base script. You can name it whatever you wish, as long as you'll be able to keep the consistency in other places. void PerkName_Perk(int client, const char[] sPref, bool bApply){
if(bApply) PerkName_ApplyPerk(client, sPref);
else PerkName_RemovePerk(client);
}
//Let's split it into two functions for simplicity's sake. void PerkName_ApplyPerk(int client, const char[] sPref){
//We have a string of settings that is getting passed from the base plugin, let's process it. PerkName_ProcessSettings(sPref); //NOTE: YOU SHOULDN'T USE THIS IF THERE'S JUST A SINGLE SETTING
//Enable perk on the client here
}
void PerkName_RemovePerk(int client){
//Disable perk on the client here
}
//The parameter looks simiilar to this: "X,Y,Z,W" (no spaces, more than a one value, should be separated by a special symbol) void PerkName_ProcessSettings(const char[] sSettings){ //NOTE: YOU SHOULDN'T USE THIS IF THERE'S JUST A SINGLE SETTING
char sPieces = new char[AMOUNT_OF_SETTINGS][LENGTH_OF_A_SETTING];//Let's set up a buffer to split the settings string into ExplodeString(sSettings, ",", sPieces, AMOUNT_OF_SETTINGS, LENGTH_OF_A_SETTING);//Split the string every 'comma' character
//Do whatever we want with this information, such as assigning it to global variables, for one strcopy(sValue1, sizeof(sValue1), sPieces[0]); g_iValue2 = StringToInt(sPieces[1]); g_bValue3 = StringToInt(sPieces[2]) > 0 ? true : false; g_fValue4 = StringToFloat(sPieces[3]);
}
Create a function in that script with which you want to initiate an enable or a disable of your perk. For template, see: PerkName_Perk()
Head over to scripting/rtd/#perks.sp and include your .sp.
Head over to scripting/rtd/#manager.sp and add your initiation function in the switch() statement of the ManagePerk() function.
The #manager.sp
This is what actualy invokes your perk, specifically the ManagePerk() function.
This function is all you need for your perk to work. However, if you want to provide some more functionality, check out the forwards below.
If you wish to use any forward, let's say you want to precache a sound in OnMapStart(), go to Forward_OnMapStart() and add a function corresponding to the one in your perk's .sp.
You can use these forwards in any way you like, but if there's an Action type one, you won't be able to return Plugin_Handled in order to stop it.
Configure rtd2_perks.cfg
Make sure that when adding your perk, its ID is greater than the previous one by 1. They have to be consistent.
Configure the rest. Once more, make sure you'd understood Detailed Breakdown of the config file.
Your .sp
The initiation function:
This function is used to enable or disable a perk on a client.
Parameters:
(int) client - the client index. It is guaranteed to be a valid, non-bot client.
(char) sPref - the perk's own settings string, found in rtd2_perks.cfg. For more info, go to "Detailed Breakdown" of the Config file.
(bool) apply - Should the perk be applied (true) or removed (false)? For instant ("time" set to -1) perks, false never occures.
From the initiation function, forward the functionality to the rest of the script.
Some valuable stocks:
The plugin has some stocks and functions in its core, you can use pretty much all of them.
The ones which I feel should be included in this list, are:
L 02/05/2016 - 00:00:31: [SM] Native "IsClientInGame" reported: Client index 0 is invalid
L 02/05/2016 - 00:00:31: [SM] Displaying call stack trace for plugin "rtd2.smx":
L 02/05/2016 - 00:00:31: [SM] [0] Line 64, rtd/powerfulhits.sp::PowerfulHits_OnTakeDamage()
L 02/05/2016 - 00:00:47: [SM] Native "IsClientInGame" reported: Client index 0 is invalid
L 02/05/2016 - 00:00:47: [SM] Displaying call stack trace for plugin "rtd2.smx":
L 02/05/2016 - 00:00:47: [SM] [0] Line 64, rtd/powerfulhits.sp::PowerfulHits_OnTakeDamage()
L 02/05/2016 - 00:01:00: [SM] Native "IsClientInGame" reported: Client index 0 is invalid
L 02/05/2016 - 00:01:00: [SM] Displaying call stack trace for plugin "rtd2.smx":
L 02/05/2016 - 00:01:00: [SM] [0] Line 64, rtd/powerfulhits.sp::PowerfulHits_OnTakeDamage()
L 02/05/2016 - 00:01:14: [SM] Native "IsClientInGame" reported: Client index 0 is invalid
L 02/05/2016 - 00:01:14: [SM] Displaying call stack trace for plugin "rtd2.smx":
L 02/05/2016 - 00:01:14: [SM] [0] Line 64, rtd/powerfulhits.sp::PowerfulHits_OnTakeDamage()
L 02/05/2016 - 00:02:08: [SM] Native "IsClientInGame" reported: Client index 0 is invalid
L 02/05/2016 - 00:02:08: [SM] Displaying call stack trace for plugin "rtd2.smx":
L 02/05/2016 - 00:02:08: [SM] [0] Line 64, rtd/powerfulhits.sp::PowerfulHits_OnTakeDamage()
L 02/05/2016 - 00:02:25: [SM] Native "IsClientInGame" reported: Client index 0 is invalid
L 02/05/2016 - 00:02:25: [SM] Displaying call stack trace for plugin "rtd2.smx":
L 02/05/2016 - 00:02:25: [SM] [0] Line 64, rtd/powerfulhits.sp::PowerfulHits_OnTakeDamage()
L 02/05/2016 - 00:02:45: [SM] Native "IsClientInGame" reported: Client index 0 is invalid
L 02/05/2016 - 00:02:45: [SM] Displaying call stack trace for plugin "rtd2.smx":
L 02/05/2016 - 00:02:45: [SM] [0] Line 64, rtd/powerfulhits.sp::PowerfulHits_OnTakeDamage()
L 02/05/2016 - 00:02:46: [SM] Native "IsClientInGame" reported: Client index 0 is invalid
L 02/05/2016 - 00:02:46: [SM] Displaying call stack trace for plugin "rtd2.smx":
L 02/05/2016 - 00:02:46: [SM] [0] Line 64, rtd/powerfulhits.sp::PowerfulHits_OnTakeDamage()
L 02/05/2016 - 00:03:00: [SM] Native "IsClientInGame" reported: Client index 0 is invalid
L 02/05/2016 - 00:03:00: [SM] Displaying call stack trace for plugin "rtd2.smx":
L 02/05/2016 - 00:03:00: [SM] [0] Line 64, rtd/powerfulhits.sp::PowerfulHits_OnTakeDamage()
L 02/05/2016 - 00:03:13: [SM] Native "IsClientInGame" reported: Client index 0 is invalid
L 02/05/2016 - 00:03:13: [SM] Displaying call stack trace for plugin "rtd2.smx":
L 02/05/2016 - 00:03:13: [SM] [0] Line 64, rtd/powerfulhits.sp::PowerfulHits_OnTakeDamage()
L 02/05/2016 - 00:03:17: [SM] Native "IsClientInGame" reported: Client index 0 is invalid
L 02/05/2016 - 00:03:17: [SM] Displaying call stack trace for plugin "rtd2.smx":
L 02/05/2016 - 00:03:17: [SM] [0] Line 64, rtd/powerfulhits.sp::PowerfulHits_OnTakeDamage()
L 02/05/2016 - 00:03:39: [SM] Native "IsClientInGame" reported: Client index 0 is invalid
L 02/05/2016 - 00:03:39: [SM] Displaying call stack trace for plugin "rtd2.smx":
L 02/05/2016 - 00:03:39: [SM] [0] Line 64, rtd/powerfulhits.sp::PowerfulHits_OnTakeDamage()
L 02/05/2016 - 00:03:42: [SM] Native "IsClientInGame" reported: Client index 0 is invalid
L 02/05/2016 - 00:03:42: [SM] Displaying call stack trace for plugin "rtd2.smx":
L 02/05/2016 - 00:03:42: [SM] [0] Line 64, rtd/powerfulhits.sp::PowerfulHits_OnTakeDamage()
L 02/05/2016 - 00:03:57: [SM] Native "IsClientInGame" reported: Client index 0 is invalid
L 02/05/2016 - 00:03:57: [SM] Displaying call stack trace for plugin "rtd2.smx":
L 02/05/2016 - 00:03:57: [SM] [0] Line 64, rtd/powerfulhits.sp::PowerfulHits_OnTakeDamage()
L 02/05/2016 - 00:03:59: [SM] Native "IsClientInGame" reported: Client index 0 is invalid
L 02/05/2016 - 00:03:59: [SM] Displaying call stack trace for plugin "rtd2.smx":
L 02/05/2016 - 00:03:59: [SM] [0] Line 64, rtd/powerfulhits.sp::PowerfulHits_OnTakeDamage()
L 02/05/2016 - 00:04:00: [SM] Native "IsClientInGame" reported: Client index 0 is invalid
L 02/05/2016 - 00:04:00: [SM] Displaying call stack trace for plugin "rtd2.smx":
L 02/05/2016 - 00:04:00: [SM] [0] Line 64, rtd/powerfulhits.sp::PowerfulHits_OnTakeDamage()
L 02/05/2016 - 00:04:10: [SM] Native "IsClientInGame" reported: Client index 0 is invalid
L 02/05/2016 - 00:04:10: [SM] Displaying call stack trace for plugin "rtd2.smx":
L 02/05/2016 - 00:04:10: [SM] [0] Line 64, rtd/powerfulhits.sp::PowerfulHits_OnTakeDamage()
L 02/05/2016 - 00:04:21: [SM] Native "IsClientInGame" reported: Client index 0 is invalid
L 02/05/2016 - 00:04:21: [SM] Displaying call stack trace for plugin "rtd2.smx":
L 02/05/2016 - 00:04:21: [SM] [0] Line 64, rtd/powerfulhits.sp::PowerfulHits_OnTakeDamage()
L 02/05/2016 - 00:04:21: [SM] Native "IsClientInGame" reported: Client index 0 is invalid
L 02/05/2016 - 00:04:21: [SM] Displaying call stack trace for plugin "rtd2.smx":
L 02/05/2016 - 00:04:21: [SM] [0] Line 64, rtd/powerfulhits.sp::PowerfulHits_OnTakeDamage()
L 02/05/2016 - 00:04:29: [SM] Native "IsClientInGame" reported: Client index 0 is invalid
L 02/05/2016 - 00:04:29: [SM] Displaying call stack trace for plugin "rtd2.smx":
L 02/05/2016 - 00:04:29: [SM] [0] Line 64, rtd/powerfulhits.sp::PowerfulHits_OnTakeDamage()
L 02/05/2016 - 00:04:30: [SM] Native "IsClientInGame" reported: Client index 0 is invalid
L 02/05/2016 - 00:04:30: [SM] Displaying call stack trace for plugin "rtd2.smx":
L 02/05/2016 - 00:04:30: [SM] [0] Line 64, rtd/powerfulhits.sp::PowerfulHits_OnTakeDamage()
L 02/05/2016 - 00:04:39: [SM] Native "IsClientInGame" reported: Client index 0 is invalid
L 02/05/2016 - 00:04:39: [SM] Displaying call stack trace for plugin "rtd2.smx":
L 02/05/2016 - 00:04:39: [SM] [0] Line 64, rtd/powerfulhits.sp::PowerfulHits_OnTakeDamage()
L 02/05/2016 - 00:04:42: [SM] Native "IsClientInGame" reported: Client index 0 is invalid
L 02/05/2016 - 00:04:42: [SM] Displaying call stack trace for plugin "rtd2.smx":
L 02/05/2016 - 00:04:42: [SM] [0] Line 64, rtd/powerfulhits.sp::PowerfulHits_OnTakeDamage()
L 02/05/2016 - 00:04:54: [SM] Native "IsClientInGame" reported: Client index 0 is invalid
L 02/05/2016 - 00:04:54: [SM] Displaying call stack trace for plugin "rtd2.smx":
L 02/05/2016 - 00:04:54: [SM] [0] Line 64, rtd/powerfulhits.sp::PowerfulHits_OnTakeDamage()
L 02/05/2016 - 00:05:04: [SM] Native "IsClientInGame" reported: Client index 105 is invalid
L 02/05/2016 - 00:05:04: [SM] Displaying call stack trace for plugin "rtd2.smx":
L 02/05/2016 - 00:05:04: [SM] [0] Line 64, rtd/powerfulhits.sp::PowerfulHits_OnTakeDamage()
L 02/05/2016 - 00:05:06: [SM] Native "IsClientInGame" reported: Client index 0 is invalid
L 02/05/2016 - 00:05:06: [SM] Displaying call stack trace for plugin "rtd2.smx":
L 02/05/2016 - 00:05:06: [SM] [0] Line 64, rtd/powerfulhits.sp::PowerfulHits_OnTakeDamage()
L 02/05/2016 - 00:05:38: [SM] Native "IsClientInGame" reported: Client index 0 is invalid
L 02/05/2016 - 00:05:38: [SM] Displaying call stack trace for plugin "rtd2.smx":
L 02/05/2016 - 00:05:38: [SM] [0] Line 64, rtd/powerfulhits.sp::PowerfulHits_OnTakeDamage()
L 02/05/2016 - 00:05:39: [SM] Native "IsClientInGame" reported: Client index 0 is invalid
L 02/05/2016 - 00:05:39: [SM] Displaying call stack trace for plugin "rtd2.smx":
L 02/05/2016 - 00:05:39: [SM] [0] Line 64, rtd/powerfulhits.sp::PowerfulHits_OnTakeDamage()
L 02/05/2016 - 00:06:00: [SM] Native "IsClientInGame" reported: Client index 105 is invalid
L 02/05/2016 - 00:06:00: [SM] Displaying call stack trace for plugin "rtd2.smx":
L 02/05/2016 - 00:06:00: [SM] [0] Line 64, rtd/powerfulhits.sp::PowerfulHits_OnTakeDamage()
L 02/05/2016 - 00:06:09: [SM] Native "IsClientInGame" reported: Client index 104 is invalid
L 02/05/2016 - 00:06:09: [SM] Displaying call stack trace for plugin "rtd2.smx":
L 02/05/2016 - 00:06:09: [SM] [0] Line 64, rtd/powerfulhits.sp::PowerfulHits_OnTakeDamage()
L 02/05/2016 - 00:06:10: [SM] Native "IsClientInGame" reported: Client index 104 is invalid
L 02/05/2016 - 00:06:10: [SM] Displaying call stack trace for plugin "rtd2.smx":
L 02/05/2016 - 00:06:10: [SM] [0] Line 64, rtd/powerfulhits.sp::PowerfulHits_OnTakeDamage()
L 02/05/2016 - 00:06:10: [SM] Native "IsClientInGame" reported: Client index 104 is invalid
L 02/05/2016 - 00:06:10: [SM] Displaying call stack trace for plugin "rtd2.smx":
L 02/05/2016 - 00:06:10: [SM] [0] Line 64, rtd/powerfulhits.sp::PowerfulHits_OnTakeDamage()
L 02/05/2016 - 00:06:11: [SM] Native "IsClientInGame" reported: Client index 104 is invalid
L 02/05/2016 - 00:06:11: [SM] Displaying call stack trace for plugin "rtd2.smx":
L 02/05/2016 - 00:06:11: [SM] [0] Line 64, rtd/powerfulhits.sp::PowerfulHits_OnTakeDamage()
L 02/05/2016 - 00:06:13: [SM] Native "IsClientInGame" reported: Client index 104 is invalid
L 02/05/2016 - 00:06:13: [SM] Displaying call stack trace for plugin "rtd2.smx":
L 02/05/2016 - 00:06:13: [SM] [0] Line 64, rtd/powerfulhits.sp::PowerfulHits_OnTakeDamage()
L 02/05/2016 - 00:06:13: [SM] Native "IsClientInGame" reported: Client index 104 is invalid
L 02/05/2016 - 00:06:13: [SM] Displaying call stack trace for plugin "rtd2.smx":
L 02/05/2016 - 00:06:13: [SM] [0] Line 64, rtd/powerfulhits.sp::PowerfulHits_OnTakeDamage()
L 02/05/2016 - 00:06:14: [SM] Native "IsClientInGame" reported: Client index 104 is invalid
L 02/05/2016 - 00:06:14: [SM] Displaying call stack trace for plugin "rtd2.smx":
L 02/05/2016 - 00:06:14: [SM] [0] Line 64, rtd/powerfulhits.sp::PowerfulHits_OnTakeDamage()
L 02/05/2016 - 00:06:14: [SM] Native "IsClientInGame" reported: Client index 104 is invalid
L 02/05/2016 - 00:06:14: [SM] Displaying call stack trace for plugin "rtd2.smx":
L 02/05/2016 - 00:06:14: [SM] [0] Line 64, rtd/powerfulhits.sp::PowerfulHits_OnTakeDamage()
L 02/05/2016 - 00:06:15: [SM] Native "IsClientInGame" reported: Client index 104 is invalid
L 02/05/2016 - 00:06:15: [SM] Displaying call stack trace for plugin "rtd2.smx":
L 02/05/2016 - 00:06:15: [SM] [0] Line 64, rtd/powerfulhits.sp::PowerfulHits_OnTakeDamage()
L 02/05/2016 - 00:06:15: [SM] Native "IsClientInGame" reported: Client index 104 is invalid
L 02/05/2016 - 00:06:15: [SM] Displaying call stack trace for plugin "rtd2.smx":
L 02/05/2016 - 00:06:15: [SM] [0] Line 64, rtd/powerfulhits.sp::PowerfulHits_OnTakeDamage()
L 02/05/2016 - 00:06:58: [SM] Native "IsClientInGame" reported: Client index 0 is invalid
L 02/05/2016 - 00:06:58: [SM] Displaying call stack trace for plugin "rtd2.smx":
L 02/05/2016 - 00:00:31: [SM] Native "IsClientInGame" reported: Client index 0 is invalid
L 02/05/2016 - 00:00:31: [SM] Displaying call stack trace for plugin "rtd2.smx":
L 02/05/2016 - 00:00:31: [SM] [0] Line 64, rtd/powerfulhits.sp::PowerfulHits_OnTakeDamage()
L 02/05/2016 - 00:00:47: [SM] Native "IsClientInGame" reported: Client index 0 is invalid
I actually released a version which fixes that issue about an hour before your comment.
New version important note:
There now 2 config files: rtd2_perks.default.cfg and rtd2_perks.custom.cfg.
If you wish to override a value, you should stick to editing rtd2_perks.custom.cfgonly (see examples in the file itself).
You may go ahead and delete the old rtd2_perks.cfg.
Before this gets more popular, I'd recommend removing the "2" from the filenames and such. It's not needed, as servers should not be running both this and the other plugin.
Before this gets more popular, I'd recommend removing the "2" from the filenames and such. It's not needed, as servers should not be running both this and the other plugin.
Now that... that is a very good point. I uploaded new .zip which contains rtd.smx, I'm gonna keep the config and translation files with the "2" as to differentiate between the versions.
To anyone who has installed this RTD on their server:
You must remove rtd2.smx and replace it with rtd.smx found it the newly uploaded .zip.
I apologize for the inconvenience.