Initial commit

This commit is contained in:
2025-04-15 22:27:20 -04:00
parent 5b7b68f81f
commit 771d8fe8e8
597 changed files with 149544 additions and 0 deletions

289
scripting/rtd/#manager.sp Normal file
View File

@@ -0,0 +1,289 @@
/**********************************************************************************\
Welcome to the perk manager!
This script is responsible for actually applying and removing perks,
so after all the logic goes off in the core rtd2.sp first.
If you have a custom perk you want to add:
REMEMBER ABOUT INCLUDING IT IN rtd2.sp!
If you're done with the above, editing #manager.sp is all you are left with.
After you're done, remember to compile the rtd2.sp, and nothing else.
\**********************************************************************************/
/*
• Editing ManagePerk() is REQUIRED for your perk to work
• Fired when a perk is just about to be applied or removed
• parameters:
- (int) client: the client's index
- (int) iPerkId: unique ID of the perk undergoing changes
- (bool) enable: should the perk be applied(enabled) or removed(disabled)
- (int) iReason: ID of the reason to display (only on disabling perks)
• It will switch through the perk ID and fire the specified command with parameters:
- (int) client: the client's index
- (string) fPref: (part of perks' enum) the optional value, found under each "settings" in rtd2_perks.cfg
- (bool) enable: should the perk be applied(enabled) or removed(disabled)
*/
void ManagePerk(int client, int iPerkId, bool enable, int iReason=3, const char[] sReason=""){
//If the perk effect is NOT in this plugin, execute the function and stop, check if it's not being disabled and just stop right there.
if(ePerks[iPerkId][bIsExternal]){
Call_StartFunction(ePerks[iPerkId][plParent], ePerks[iPerkId][funcCallback]);
Call_PushCell(client);
Call_PushCell(iPerkId);
Call_PushCell(enable);
Call_Finish();
if(!enable) //Check if anything is needing to be printed.
RemovedPerk(client, iReason, sReason);
return; //Stop further exectuion of ManagePerk()
}
//This is the optional value for perks, found under "special" in rtd2_perks.cfg
char sSettings[PERK_MAX_HIGH]; strcopy(sSettings, PERK_MAX_HIGH, ePerks[iPerkId][sPref]);
//template: case <your_perk_id>:{YourPerk_Function(client, sSettings, enable);}
switch(iPerkId){
case 0: Godmode_Perk (client, sSettings, enable);
case 1: Toxic_Perk (client, sSettings, enable);
case 2: LuckySandvich_Perk (client, sSettings, enable);
case 3: IncreasedSpeed_Perk (client, sSettings, enable);
case 4: Noclip_Perk (client, sSettings, enable);
case 5: LowGravity_Perk (client, sSettings, enable);
case 6: FullUbercharge_Perk (client, sSettings, enable);
case 7: Invisibility_Perk (client, sSettings, enable);
case 8: InfiniteCloak_Perk (client, sSettings, enable);
case 9: Criticals_Perk (client, sSettings, enable);
case 10:InfiniteAmmo_Perk (client, sSettings, enable);
case 11:ScaryBullets_Perk (client, sSettings, enable);
case 12:SpawnSentry_Perk (client, sSettings, enable);
case 13:HomingProjectiles_Perk (client, sSettings, enable);
case 14:FullRifleCharge_Perk (client, sSettings, enable);
case 15:Explode_Perk (client, sSettings, enable);
case 16:Snail_Perk (client, sSettings, enable);
case 17:Frozen_Perk (client, sSettings, enable);
case 18:Timebomb_Perk (client, sSettings, enable);
case 19:Ignition_Perk (client, sSettings, enable);
case 20:LowHealth_Perk (client, sSettings, enable);
case 21:Drugged_Perk (client, sSettings, enable);
case 22:Blind_Perk (client, sSettings, enable);
case 23:StripToMelee_Perk (client, sSettings, enable);
case 24:Beacon_Perk (client, sSettings, enable);
case 25:ForcedTaunt_Perk (client, sSettings, enable);
case 26:Monochromia_Perk (client, sSettings, enable);
case 27:Earthquake_Perk (client, sSettings, enable);
case 28:FunnyFeeling_Perk (client, sSettings, enable);
case 29:BadSauce_Perk (client, sSettings, enable);
case 30:SpawnDispenser_Perk (client, sSettings, enable);
case 31:InfiniteJump_Perk (client, sSettings, enable);
case 32:PowerfulHits_Perk (client, sSettings, enable);
case 33:BigHead_Perk (client, sSettings, enable);
case 34:TinyMann_Perk (client, sSettings, enable);
case 35:Firework_Perk (client, sSettings, enable);
case 36:DeadlyVoice_Perk (client, sSettings, enable);
case 37:StrongGravity_Perk (client, sSettings, enable);
case 38:EyeForAnEye_Perk (client, sSettings, enable);
case 39:Weakened_Perk (client, sSettings, enable);
case 40:NecroMash_Perk (client, sSettings, enable);
case 41:ExtraAmmo_Perk (client, sSettings, enable);
case 42:Suffocation_Perk (client, sSettings, enable);
case 43:FastHands_Perk (client, sSettings, enable);
case 44:Outline_Perk (client, sSettings, enable);
case 45:Vital_Perk (client, sSettings, enable);
case 46:NoGravity_Perk (client, sSettings, enable);
case 47:TeamCriticals_Perk (client, sSettings, enable);
case 48:FireTimebomb_Perk (client, sSettings, enable);
case 49:FireBreath_Perk (client, sSettings, enable);
case 50:StrongRecoil_Perk (client, sSettings, enable);
case 51:Cursed_Perk (client, sSettings, enable);
case 52:ExtraThrowables_Perk (client, sSettings, enable);
case 53:PowerPlay_Perk (client, sSettings, enable);
case 54:ExplosiveArrows_Perk (client, sSettings, enable);
case 55:InclineProblem_Perk (client, sSettings, enable);
}
if(!enable)
RemovedPerk(client, iReason, sReason);
}
/*
• Editing Forward_OnMapStart() is OPTIONAL
• This is a forward of OnMapStart() from rtd2.sp
*/
void Forward_OnMapStart(){
Invisibility_Start();
InfiniteAmmo_Start();
HomingProjectiles_Start();
FullRifleCharge_Start();
Timebomb_Start();
Drugged_Start();
Blind_Start();
Beacon_Start();
ForcedTaunt_Start();
Earthquake_Start();
ScaryBullets_Start();
TinyMann_Start();
Firework_Start();
DeadlyVoice_Start();
EyeForAnEye_Start();
NecroMash_Start();
ExtraAmmo_Start();
FastHands_Start();
FireTimebomb_Start();
FireBreath_Start();
ExplosiveArrows_Start();
}
/*
• Editing Forward_OnClientPutInServer() is OPTIONAL
• This is a forward of OnClientPutInServer() from rtd2.sp
• ATTENTION: Also occures to every valid client on OnPluginStart()
*/
void Forward_OnClientPutInServer(int client){
PowerfulHits_OnClientPutInServer(client);
}
/*
• Editing Forward_Voice() is OPTIONAL
• This is a forward of Listener_Voice() from rtd2.sp
• Listener_Voice() fires when a client says something via Voicemenu
• Client is guaranteed to be valid and alive.
*/
void Forward_Voice(int client){
SpawnSentry_Voice(client);
SpawnDispenser_Voice(client);
DeadlyVoice_Voice(client);
FireBreath_Voice(client);
}
/*
• Editing Forward_OnEntityCreated() is OPTIONAL
• This is a forward of OnEntityCreated() from rtd2.sp
• Entity is NOT guaranteed to be valid.
*/
void Forward_OnEntityCreated(int iEntity, const char[] sClassname){
HomingProjectiles_OnEntityCreated(iEntity, sClassname);
FastHands_OnEntityCreated(iEntity, sClassname);
ExplosiveArrows_OnEntityCreated(iEntity, sClassname);
}
/*
• Editing Forward_OnGameFrame() is OPTIONAL
• It's a forward of OnGameFrame() from rtd2.sp
*/
void Forward_OnGameFrame(){
HomingProjectiles_OnGameFrame();
}
/*
• Editing Forward_OnConditionAdded() is OPTIONAL
• It's a forward of TF2_OnConditionAdded() from rtd2.sp
*/
void Forward_OnConditionAdded(int client, TFCond condition){
FullRifleCharge_OnConditionAdded(client, condition);
ForcedTaunt_OnConditionAdded(client, condition);
}
/*
• Editing Forward_OnConditionRemoved() is OPTIONAL
• It's a forward of TF2_OnConditionRemoved() from rtd2.sp
*/
void Forward_OnConditionRemoved(int client, TFCond condition){
FullUbercharge_OnConditionRemoved(client, condition);
FunnyFeeling_OnConditionRemoved(client, condition);
ForcedTaunt_OnConditionRemoved(client, condition);
}
/*
• Editing Forward_OnPlayerRunCmd() is OPTIONAL
• It's a forward of OnPlayerRunCmd() from rtd2.sp
• Client is guaranteed to be valid.
• Return TRUE if anything changed.
• You cannot block it from this forward.
*/
public bool Forward_OnPlayerRunCmd(int client, int &iButtons, int &iImpulse, float fVel[3], float fAng[3], int &iWeapon){
InfiniteJump_OnPlayerRunCmd(client, iButtons);
BigHead_OnPlayerRunCmd(client);
if(Cursed_OnPlayerRunCmd(client, iButtons, fVel))
return true;
return false;
}
/*
• Editing Forward_OnRemovePerkPre() is OPTIONAL
• It fires before a perk is about to be removed.
• REGARDLESS whether the client is in roll or not.
• Client is guaranteed to be valid.
• You cannot block it from this forward.
*/
void Forward_OnRemovePerkPre(int client){
Timebomb_OnRemovePerk(client);
FireTimebomb_OnRemovePerk(client);
}
/*
• Editing Forward_AttackIsCritical() is OPTIONAL
• Returning true from here means that the next attack is crit.
• REGARDLESS whether the client is in roll or not.
• Client is guaranteed to be valid.
• You cannot block it from this forward.
*/
public bool Forward_AttackIsCritical(int client, int iWeapon, const char[] sWeaponName){
StrongRecoil_CritCheck(client, iWeapon);
/*
if(Something_SetCritical(client)
|| Something2_SetCritical(client)
|| Something3_SetCritical(client))
return true;
*/
if(LuckySandvich_SetCritical(client))
return true;
return false;
}

63
scripting/rtd/#perks.sp Normal file
View File

@@ -0,0 +1,63 @@
// Include path your your perk starting from /scripting/ folder here.
//--------[ PERK INCLUDE ]------------[ ID ]--------
#include "rtd/godmode.sp" // 0
#include "rtd/toxic.sp" // 1
#include "rtd/luckysandvich.sp" // 2
#include "rtd/increasedspeed.sp" // 3
#include "rtd/noclip.sp" // 4
#include "rtd/lowgravity.sp" // 5
#include "rtd/fullubercharge.sp" // 6
#include "rtd/invisibility.sp" // 7
#include "rtd/infinitecloak.sp" // 8
#include "rtd/criticals.sp" // 9
#include "rtd/infiniteammo.sp" // 10
#include "rtd/scarybullets.sp" // 11
#include "rtd/spawnsentry.sp" // 12
#include "rtd/homingprojectiles.sp" // 13
#include "rtd/fullriflecharge.sp" // 14
#include "rtd/explode.sp" // 15
#include "rtd/snail.sp" // 16
#include "rtd/frozen.sp" // 17
#include "rtd/timebomb.sp" // 18
#include "rtd/ignition.sp" // 19
#include "rtd/lowhealth.sp" // 20
#include "rtd/drugged.sp" // 21
#include "rtd/blind.sp" // 22
#include "rtd/striptomelee.sp" // 23
#include "rtd/beacon.sp" // 24
#include "rtd/forcedtaunt.sp" // 25
#include "rtd/monochromia.sp" // 26
#include "rtd/earthquake.sp" // 27
#include "rtd/funnyfeeling.sp" // 28
#include "rtd/badsauce.sp" // 29
#include "rtd/spawndispenser.sp" // 30
#include "rtd/infinitejump.sp" // 31
#include "rtd/powerfulhits.sp" // 32
#include "rtd/bighead.sp" // 33
#include "rtd/tinymann.sp" // 34
#include "rtd/firework.sp" // 35
#include "rtd/deadlyvoice.sp" // 36
#include "rtd/stronggravity.sp" // 37
#include "rtd/eyeforaneye.sp" // 38
#include "rtd/weakened.sp" // 39
#include "rtd/necromash.sp" // 40
#include "rtd/extraammo.sp" // 41
#include "rtd/suffocation.sp" // 42
#include "rtd/fasthands.sp" // 43
#include "rtd/outline.sp" // 44
#include "rtd/vital.sp" // 45
#include "rtd/nogravity.sp" // 46
#include "rtd/teamcriticals.sp" // 47
#include "rtd/firetimebomb.sp" // 48
#include "rtd/firebreath.sp" // 49
#include "rtd/strongrecoil.sp" // 50
#include "rtd/cursed.sp" // 51
#include "rtd/extrathrowables.sp" // 52
#include "rtd/powerplay.sp" // 53
#include "rtd/explosivearrows.sp" // 54
#include "rtd/inclineproblem.sp" // 55

View File

@@ -0,0 +1,97 @@
/*
This script is a part of RTD2 plugin and is not meant to work by itself.
If you were to edit anything here, you'd have to recompile rtd2.sp instead of this one.
*** HOW TO ADD A PERK ***
A quick note: This tutorial may not be kept up to date; for an updated one, go to the plugin's thread.
https://forums.alliedmods.net/showpost.php?p=2389730&postcount=2
1. Set up:
a) Have <perkname>.sp in scripting/rtd.
b) Add it to the includes in scripting/rtd/#perks.sp.
c) Add a new section with a correct ID (highest one +1) to the config/rtd2_perks.cfg and set its settings.
2. Edit scripting/rtd/#manager.sp
a) In a function named ManagePerk() add a new case to the switch() with your perk's ID.
b) In the added case specify a function which is going to execute from <perkname>.sp with parameters:
1) @client - the client the perk should be applied to/removed from
2) @fSpecialPref - the optional "special" value in config/rtd2_perks.cfg
2) @enable - to specify whether the perk should be applied/removed
c) OPTIONAL: You can specify a function in your perk which should run at OnMapStart() in the Forward_OnMapStart() function.
You will need it if you'd want to, for example, precache a sound or loop through existing clients.
d) OPTIONAL: You can specify a function in your perk which should run at OnPlayerRunCmd() in the Forward_OnPlayerRunCmd() function.
You can use it if you'd need something to run each frame or on a certain button press.
NOTE: The forwarded client is guaranteed to be valid BUT NOT GUARANTEED IF THEY ARE ALIVE.
3. Script your perk:
a) Create a public function in <perkname>.sp with parameters @client, @iPref, @bool:apply as an example below
- This is the only function used to transfer info between the core and the include
- You don't need to include any includes that are in the rtd2.sp
b) NOTE: If you need to transfer the iPref to a different function, set it globally but remember to use an unique name
c) Name it AS SAME AS you named the function in the added case in the switch() in #manager.sp
d) From there, script the functionality like there's no tomorrow
e) You are free to use IsValidClient(). It returns false when:
- An incorrect client index is specified
- Client is not in game
- Client is fake (bot)
- Client is Coaching
4. Compile rtd2.sp and you're good to go!
*/
/*
THIS IS A TEMPLATE ON ADDING CUSTOM PERKS, FOR A FULL GUIDE INFO, GO TO:
https://forums.alliedmods.net/showpost.php?p=2389730&postcount=2
*/
//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]);
}

60
scripting/rtd/badsauce.sp Normal file
View File

@@ -0,0 +1,60 @@
/*
This script is a part of RTD2 plugin and is not meant to work by itself.
If you were to edit anything here, you'd have to recompile rtd2.sp instead of this one.
*** HOW TO ADD A PERK ***
A quick note: This tutorial may not be kept up to date; for an updated one, go to the plugin's thread.
1. Set up:
a) Have <perkname>.sp in scripting/rtd.
b) Add it to the includes in scripting/rtd/#perks.sp.
c) Add a new section with a correct ID (highest one +1) to the config/rtd2_perks.cfg and set its settings.
2. Edit scripting/rtd/#manager.sp
a) In a function named ManagePerk() add a new case to the switch() with your perk's ID.
b) In the added case specify a function which is going to execute from <perkname>.sp with parameters:
1) @client - the client the perk should be applied to/removed from
2) @fSpecialPref - the optional "special" value in config/rtd2_perks.cfg
2) @enable - to specify whether the perk should be applied/removed
c) OPTIONAL: You can specify a function in your perk which should run at OnMapStart() in the Forward_OnMapStart() function.
You will need it if you'd want to, for example, precache a sound or loop through existing clients.
d) OPTIONAL: You can specify a function in your perk which should run at OnPlayerRunCmd() in the Forward_OnPlayerRunCmd() function.
You can use it if you'd need something to run each frame or on a certain button press.
NOTE: The forwarded client is guaranteed to be valid BUT NOT GUARANTEED IF THEY ARE ALIVE.
3. Script your perk:
a) Create a public function in <perkname>.sp with parameters @client, @iPref, @bool:apply as an example below
- This is the only function used to transfer info between the core and the include
- You don't need to include any includes that are in the rtd2.sp
b) NOTE: If you need to transfer the iPref to a different function, set it globally but remember to use an unique name
c) Name it AS SAME AS you named the function in the added case in the switch() in #manager.sp
d) From there, script the functionality like there's no tomorrow
e) You are free to use IsValidClient(). It returns false when:
- An incorrect client index is specified
- Client is not in game
- Client is fake (bot)
- Client is Coaching
4. Compile rtd2.sp and you're good to go!
*/
void BadSauce_Perk(int client, const char[] sPref, bool apply){
if(!apply)
return;
char[][] sPieces = new char[3][4];
ExplodeString(sPref, ",", sPieces, 3, 4);
float fMilkDuration = StringToFloat(sPieces[0]);
float fJarateDuration = StringToFloat(sPieces[1]);
float fBleedDuration = StringToFloat(sPieces[2]);
float fPerkDuration = float(GetPerkTime(29));
if(fMilkDuration >= 0.0) TF2_AddCondition(client, TFCond_Milked, fMilkDuration > 0.0 ? fMilkDuration : fPerkDuration);
if(fJarateDuration >= 0.0) TF2_AddCondition(client, TFCond_Jarated, fJarateDuration > 0.0 ? fJarateDuration : fPerkDuration);
if(fBleedDuration >= 0.0) TF2_MakeBleed (client, client, fBleedDuration > 0.0 ? fBleedDuration : fPerkDuration);
}

121
scripting/rtd/beacon.sp Normal file
View File

@@ -0,0 +1,121 @@
/*
This script is a part of RTD2 plugin and is not meant to work by itself.
If you were to edit anything here, you'd have to recompile rtd2.sp instead of this one.
*** HOW TO ADD A PERK ***
A quick note: This tutorial may not be kept up to date; for an updated one, go to the plugin's thread.
1. Set up:
a) Have <perkname>.sp in scripting/rtd.
b) Add it to the includes in scripting/rtd/#perks.sp.
c) Add a new section with a correct ID (highest one +1) to the config/rtd2_perks.cfg and set its settings.
2. Edit scripting/rtd/#manager.sp
a) In a function named ManagePerk() add a new case to the switch() with your perk's ID.
b) In the added case specify a function which is going to execute from <perkname>.sp with parameters:
1) @client - the client the perk should be applied to/removed from
2) @fSpecialPref - the optional "special" value in config/rtd2_perks.cfg
2) @enable - to specify whether the perk should be applied/removed
c) OPTIONAL: You can specify a function in your perk which should run at OnMapStart() in the Forward_OnMapStart() function.
You will need it if you'd want to, for example, precache a sound or loop through existing clients.
d) OPTIONAL: You can specify a function in your perk which should run at OnPlayerRunCmd() in the Forward_OnPlayerRunCmd() function.
You can use it if you'd need something to run each frame or on a certain button press.
NOTE: The forwarded client is guaranteed to be valid BUT NOT GUARANTEED IF THEY ARE ALIVE.
3. Script your perk:
a) Create a public function in <perkname>.sp with parameters @client, @iPref, @bool:apply as an example below
- This is the only function used to transfer info between the core and the include
- You don't need to include any includes that are in the rtd2.sp
b) NOTE: If you need to transfer the iPref to a different function, set it globally but remember to use an unique name
c) Name it AS SAME AS you named the function in the added case in the switch() in #manager.sp
d) From there, script the functionality like there's no tomorrow
e) You are free to use IsValidClient(). It returns false when:
- An incorrect client index is specified
- Client is not in game
- Client is fake (bot)
- Client is Coaching
4. Compile rtd2.sp and you're good to go!
*/
#define SOUND_BEEP "buttons/blip1.wav"
bool g_bIsBeaconed[MAXPLAYERS+1] = {false, ...};
float g_fBeaconInterval = 1.0;
float g_fBeaconRadius = 375.0;
int g_iSpriteBeam, g_iSpriteHalo;
void Beacon_Start(){
PrecacheSound(SOUND_BEEP);
g_iSpriteBeam = PrecacheModel("materials/sprites/laser.vmt");
g_iSpriteHalo = PrecacheModel("materials/sprites/halo01.vmt");
}
void Beacon_Perk(int client, const char[] sPref, bool apply){
if(apply)
Beacon_ApplyPerk(client, sPref);
else
g_bIsBeaconed[client] = false;
}
void Beacon_ApplyPerk(int client, const char[] sSettings){
Beacon_ProcessSettings(sSettings);
CreateTimer(g_fBeaconInterval, Timer_BeaconBeep, GetClientSerial(client), TIMER_REPEAT);
g_bIsBeaconed[client] = true;
}
public Action Timer_BeaconBeep(Handle hTimer, int iSerial){
int client = GetClientFromSerial(iSerial);
if(!IsValidClient(client)) return Plugin_Stop;
if(!g_bIsBeaconed[client]) return Plugin_Stop;
Beacon_Beep(client);
return Plugin_Continue;
}
void Beacon_Beep(int client){
float fPos[3]; GetClientAbsOrigin(client, fPos);
fPos[2] += 10.0;
int iColorGra[4] = {128,128,128,255};
int iColorRed[4] = {255,75,75,255};
int iColorBlu[4] = {75,75,255,255};
TE_SetupBeamRingPoint(fPos, 10.0, g_fBeaconRadius, g_iSpriteBeam, g_iSpriteHalo, 0, 15, 0.5, 5.0, 0.0, iColorGra, 10, 0);
TE_SendToAll();
if(GetClientTeam(client) == _:TFTeam_Red)
TE_SetupBeamRingPoint(fPos, 10.0, g_fBeaconRadius, g_iSpriteBeam, g_iSpriteHalo, 0, 10, 0.6, 10.0, 0.5, iColorRed, 10, 0);
else
TE_SetupBeamRingPoint(fPos, 10.0, g_fBeaconRadius, g_iSpriteBeam, g_iSpriteHalo, 0, 10, 0.6, 10.0, 0.5, iColorBlu, 10, 0);
TE_SendToAll();
EmitSoundToAll(SOUND_BEEP, client);
}
void Beacon_ProcessSettings(const char[] sSettings){
char[][] sPieces = new char[2][4];
ExplodeString(sSettings, ",", sPieces, 2, 4);
g_fBeaconInterval = StringToFloat(sPieces[0]);
g_fBeaconRadius = StringToFloat(sPieces[1]);
}

66
scripting/rtd/bighead.sp Normal file
View File

@@ -0,0 +1,66 @@
/*
This script is a part of RTD2 plugin and is not meant to work by itself.
If you were to edit anything here, you'd have to recompile rtd2.sp instead of this one.
*** HOW TO ADD A PERK ***
A quick note: This tutorial may not be kept up to date; for an updated one, go to the plugin's thread.
1. Set up:
a) Have <perkname>.sp in scripting/rtd.
b) Add it to the includes in scripting/rtd/#perks.sp.
c) Add a new section with a correct ID (highest one +1) to the config/rtd2_perks.cfg and set its settings.
2. Edit scripting/rtd/#manager.sp
a) In a function named ManagePerk() add a new case to the switch() with your perk's ID.
b) In the added case specify a function which is going to execute from <perkname>.sp with parameters:
1) @client - the client the perk should be applied to/removed from
2) @fSpecialPref - the optional "special" value in config/rtd2_perks.cfg
2) @enable - to specify whether the perk should be applied/removed
c) OPTIONAL: You can specify a function in your perk which should run at OnMapStart() in the Forward_OnMapStart() function.
You will need it if you'd want to, for example, precache a sound or loop through existing clients.
d) OPTIONAL: You can specify a function in your perk which should run at OnPlayerRunCmd() in the Forward_OnPlayerRunCmd() function.
You can use it if you'd need something to run each frame or on a certain button press.
NOTE: The forwarded client is guaranteed to be valid BUT NOT GUARANTEED IF THEY ARE ALIVE.
3. Script your perk:
a) Create a public function in <perkname>.sp with parameters @client, @iPref, @bool:apply as an example below
- This is the only function used to transfer info between the core and the include
- You don't need to include any includes that are in the rtd2.sp
b) NOTE: If you need to transfer the iPref to a different function, set it globally but remember to use an unique name
c) Name it AS SAME AS you named the function in the added case in the switch() in #manager.sp
d) From there, script the functionality like there's no tomorrow
e) You are free to use IsValidClient(). It returns false when:
- An incorrect client index is specified
- Client is not in game
- Client is fake (bot)
- Client is Coaching
4. Compile rtd2.sp and you're good to go!
*/
#define ATTRIB_VOICEPITCH 2048
bool g_bHasBigHead[MAXPLAYERS+1] = {false, ...};
float g_fBigHeadMultiplayer = 2.0;
void BigHead_Perk(int client, const char[] sPref, bool apply){
g_fBigHeadMultiplayer = StringToFloat(sPref);
g_bHasBigHead[client] = apply;
if(apply)
TF2Attrib_SetByDefIndex(client, ATTRIB_VOICEPITCH, 1/g_fBigHeadMultiplayer);
else
TF2Attrib_RemoveByDefIndex(client, ATTRIB_VOICEPITCH);
}
void BigHead_OnPlayerRunCmd(client){
if(!g_bHasBigHead[client]) return;
SetEntPropFloat(client, Prop_Send, "m_flHeadScale", g_fBigHeadMultiplayer);
}

67
scripting/rtd/blind.sp Normal file
View File

@@ -0,0 +1,67 @@
/*
This script is a part of RTD2 plugin and is not meant to work by itself.
If you were to edit anything here, you'd have to recompile rtd2.sp instead of this one.
*** HOW TO ADD A PERK ***
A quick note: This tutorial may not be kept up to date; for an updated one, go to the plugin's thread.
1. Set up:
a) Have <perkname>.sp in scripting/rtd.
b) Add it to the includes in scripting/rtd/#perks.sp.
c) Add a new section with a correct ID (highest one +1) to the config/rtd2_perks.cfg and set its settings.
2. Edit scripting/rtd/#manager.sp
a) In a function named ManagePerk() add a new case to the switch() with your perk's ID.
b) In the added case specify a function which is going to execute from <perkname>.sp with parameters:
1) @client - the client the perk should be applied to/removed from
2) @fSpecialPref - the optional "special" value in config/rtd2_perks.cfg
2) @enable - to specify whether the perk should be applied/removed
c) OPTIONAL: You can specify a function in your perk which should run at OnMapStart() in the Forward_OnMapStart() function.
You will need it if you'd want to, for example, precache a sound or loop through existing clients.
d) OPTIONAL: You can specify a function in your perk which should run at OnPlayerRunCmd() in the Forward_OnPlayerRunCmd() function.
You can use it if you'd need something to run each frame or on a certain button press.
NOTE: The forwarded client is guaranteed to be valid BUT NOT GUARANTEED IF THEY ARE ALIVE.
3. Script your perk:
a) Create a public function in <perkname>.sp with parameters @client, @iPref, @bool:apply as an example below
- This is the only function used to transfer info between the core and the include
- You don't need to include any includes that are in the rtd2.sp
b) NOTE: If you need to transfer the iPref to a different function, set it globally but remember to use an unique name
c) Name it AS SAME AS you named the function in the added case in the switch() in #manager.sp
d) From there, script the functionality like there's no tomorrow
e) You are free to use IsValidClient(). It returns false when:
- An incorrect client index is specified
- Client is not in game
- Client is fake (bot)
- Client is Coaching
4. Compile rtd2.sp and you're good to go!
*/
UserMsg g_BlindMsgId;
void Blind_Start(){
g_BlindMsgId = GetUserMessageId("Fade");
}
void Blind_Perk(int client, const char[] sPref, bool apply){
int iTargets[2];
iTargets[0] = client;
Handle hMsg = StartMessageEx(g_BlindMsgId, iTargets, 1);
BfWriteShort(hMsg, 1536);
BfWriteShort(hMsg, 1536);
BfWriteShort(hMsg, apply ? (0x0002 | 0x0008) : (0x0001 | 0x0010));
BfWriteByte(hMsg, 0);
BfWriteByte(hMsg, 0);
BfWriteByte(hMsg, 0);
BfWriteByte(hMsg, apply ? StringToInt(sPref) : 0);
EndMessage();
}

View File

@@ -0,0 +1,69 @@
/*
This script is a part of RTD2 plugin and is not meant to work by itself.
If you were to edit anything here, you'd have to recompile rtd2.sp instead of this one.
*** HOW TO ADD A PERK ***
A quick note: This tutorial may not be kept up to date; for an updated one, go to the plugin's thread.
1. Set up:
a) Have <perkname>.sp in scripting/rtd.
b) Add it to the includes in scripting/rtd/#perks.sp.
c) Add a new section with a correct ID (highest one +1) to the config/rtd2_perks.cfg and set its settings.
2. Edit scripting/rtd/#manager.sp
a) In a function named ManagePerk() add a new case to the switch() with your perk's ID.
b) In the added case specify a function which is going to execute from <perkname>.sp with parameters:
1) @client - the client the perk should be applied to/removed from
2) @fSpecialPref - the optional "special" value in config/rtd2_perks.cfg
2) @enable - to specify whether the perk should be applied/removed
c) OPTIONAL: You can specify a function in your perk which should run at OnMapStart() in the Forward_OnMapStart() function.
You will need it if you'd want to, for example, precache a sound or loop through existing clients.
d) OPTIONAL: You can specify a function in your perk which should run at OnPlayerRunCmd() in the Forward_OnPlayerRunCmd() function.
You can use it if you'd need something to run each frame or on a certain button press.
NOTE: The forwarded client is guaranteed to be valid BUT NOT GUARANTEED IF THEY ARE ALIVE.
3. Script your perk:
a) Create a public function in <perkname>.sp with parameters @client, @iPref, @bool:apply as an example below
- This is the only function used to transfer info between the core and the include
- You don't need to include any includes that are in the rtd2.sp
b) NOTE: If you need to transfer the iPref to a different function, set it globally but remember to use an unique name
c) Name it AS SAME AS you named the function in the added case in the switch() in #manager.sp
d) From there, script the functionality like there's no tomorrow
e) You are free to use IsValidClient(). It returns false when:
- An incorrect client index is specified
- Client is not in game
- Client is fake (bot)
- Client is Coaching
4. Compile rtd2.sp and you're good to go!
*/
#define MINICRIT TFCond_Buffed
#define FULLCRIT TFCond_CritOnFirstBlood
bool g_bMiniCrits[MAXPLAYERS+1] = {false, ...};
void Criticals_Perk(int client, const char[] sPref, bool apply){
if(apply)
Criticals_ApplyPerk(client, StringToInt(sPref));
else
Criticals_RemovePerk(client);
}
void Criticals_ApplyPerk(int client, int iValue){
g_bMiniCrits[client] = (iValue > 0) ? false : true;
TF2_AddCondition(client, g_bMiniCrits[client] ? MINICRIT : FULLCRIT);
}
void Criticals_RemovePerk(int client){
TF2_RemoveCondition(client, g_bMiniCrits[client] ? MINICRIT : FULLCRIT);
}

90
scripting/rtd/cursed.sp Normal file
View File

@@ -0,0 +1,90 @@
/*
This script is a part of RTD2 plugin and is not meant to work by itself.
If you were to edit anything here, you'd have to recompile rtd2.sp instead of this one.
*** HOW TO ADD A PERK ***
A quick note: This tutorial may not be kept up to date; for an updated one, go to the plugin's thread.
1. Set up:
a) Have <perkname>.sp in scripting/rtd.
b) Add it to the includes in scripting/rtd/#perks.sp.
c) Add a new section with a correct ID (highest one +1) to the config/rtd2_perks.cfg and set its settings.
2. Edit scripting/rtd/#manager.sp
a) In a function named ManagePerk() add a new case to the switch() with your perk's ID.
b) In the added case specify a function which is going to execute from <perkname>.sp with parameters:
1) @client - the client the perk should be applied to/removed from
2) @fSpecialPref - the optional "special" value in config/rtd2_perks.cfg
2) @enable - to specify whether the perk should be applied/removed
c) OPTIONAL: You can specify a function in your perk which should run at OnMapStart() in the Forward_OnMapStart() function.
You will need it if you'd want to, for example, precache a sound or loop through existing clients.
d) OPTIONAL: You can specify a function in your perk which should run at OnPlayerRunCmd() in the Forward_OnPlayerRunCmd() function.
You can use it if you'd need something to run each frame or on a certain button press.
NOTE: The forwarded client is guaranteed to be valid BUT NOT GUARANTEED IF THEY ARE ALIVE.
3. Script your perk:
a) Create a public function in <perkname>.sp with parameters @client, @iPref, @bool:apply as an example below
- This is the only function used to transfer info between the core and the include
- You don't need to include any includes that are in the rtd2.sp
b) NOTE: If you need to transfer the iPref to a different function, set it globally but remember to use an unique name
c) Name it AS SAME AS you named the function in the added case in the switch() in #manager.sp
d) From there, script the functionality like there's no tomorrow
e) You are free to use IsValidClient(). It returns false when:
- An incorrect client index is specified
- Client is not in game
- Client is fake (bot)
- Client is Coaching
4. Compile rtd2.sp and you're good to go!
*/
/*
This perk's behaviour is taken from Farbror Godis' Curse
https://forums.alliedmods.net/showthread.php?p=2401008
*/
bool g_bIsCursed[MAXPLAYERS+1] = {false, ...};
public void Cursed_Perk(int client, const char[] sPref, bool apply){
g_bIsCursed[client] = apply;
}
bool Cursed_OnPlayerRunCmd(int client, int &iButtons, float fVel[3]){
if(!g_bIsCursed[client])
return false;
fVel[0] = -fVel[0];
fVel[1] = -fVel[1];
if(iButtons & IN_MOVELEFT){
iButtons &= ~IN_MOVELEFT;
iButtons |= IN_MOVERIGHT;
}else if(iButtons & IN_MOVERIGHT){
iButtons &= ~IN_MOVERIGHT;
iButtons |= IN_MOVELEFT;
}
if(iButtons & IN_FORWARD){
iButtons &= ~IN_FORWARD;
iButtons |= IN_BACK;
}else if(iButtons & IN_BACK){
iButtons &= ~IN_BACK;
iButtons |= IN_FORWARD;
}
return true;
}

View File

@@ -0,0 +1,194 @@
/*
This script is a part of RTD2 plugin and is not meant to work by itself.
If you were to edit anything here, you'd have to recompile rtd2.sp instead of this one.
*** HOW TO ADD A PERK ***
A quick note: This tutorial may not be kept up to date; for an updated one, go to the plugin's thread.
1. Set up:
a) Have <perkname>.sp in scripting/rtd.
b) Add it to the includes in scripting/rtd/#perks.sp.
c) Add a new section with a correct ID (highest one +1) to the config/rtd2_perks.cfg and set its settings.
2. Edit scripting/rtd/#manager.sp
a) In a function named ManagePerk() add a new case to the switch() with your perk's ID.
b) In the added case specify a function which is going to execute from <perkname>.sp with parameters:
1) @client - the client the perk should be applied to/removed from
2) @fSpecialPref - the optional "special" value in config/rtd2_perks.cfg
2) @enable - to specify whether the perk should be applied/removed
c) OPTIONAL: You can specify a function in your perk which should run at OnMapStart() in the Forward_OnMapStart() function.
You will need it if you'd want to, for example, precache a sound or loop through existing clients.
d) OPTIONAL: You can specify a function in your perk which should run at OnPlayerRunCmd() in the Forward_OnPlayerRunCmd() function.
You can use it if you'd need something to run each frame or on a certain button press.
NOTE: The forwarded client is guaranteed to be valid BUT NOT GUARANTEED IF THEY ARE ALIVE.
3. Script your perk:
a) Create a public function in <perkname>.sp with parameters @client, @iPref, @bool:apply as an example below
- This is the only function used to transfer info between the core and the include
- You don't need to include any includes that are in the rtd2.sp
b) NOTE: If you need to transfer the iPref to a different function, set it globally but remember to use an unique name
c) Name it AS SAME AS you named the function in the added case in the switch() in #manager.sp
d) From there, script the functionality like there's no tomorrow
e) You are free to use IsValidClient(). It returns false when:
- An incorrect client index is specified
- Client is not in game
- Client is fake (bot)
- Client is Coaching
4. Compile rtd2.sp and you're good to go!
*/
#define DEADLYVOICE_SOUND_ATTACK "weapons/cow_mangler_explosion_charge_04.wav"
char g_sDeadlyVoiceParticles[][] = {
"default", "default",
"powerup_supernova_explode_red",
"powerup_supernova_explode_blue"
};
bool g_bHasDeadlyVoice[MAXPLAYERS+1] = {false, ...};
int g_iDeadlyVoiceParticle[MAXPLAYERS+1] = {0, ...};
float g_fDeadlyVoiceLastAttack[MAXPLAYERS+1] = {0.0, ...};
float g_fDeadlyVoiceRate = 1.0;
float g_fDeadlyVoiceRange = 128.0;
float g_fDeadlyVoiceDamage= 72.0;
void DeadlyVoice_Start(){
PrecacheSound(DEADLYVOICE_SOUND_ATTACK);
}
void DeadlyVoice_Perk(int client, const char[] sPref, bool apply){
if(apply)
DeadlyVoice_ApplyPerk(client, sPref);
else
DeadlyVoice_RemovePerk(client);
}
void DeadlyVoice_ApplyPerk(int client, const char[] sPref){
DeadlyVoice_ProcessSettings(sPref);
g_bHasDeadlyVoice[client] = true;
PrintToChat(client, "%s %T", "\x07FFD700[RTD]\x01", "RTD2_Perk_Attack", LANG_SERVER, 0x03, 0x01);
}
void DeadlyVoice_RemovePerk(int client){
g_bHasDeadlyVoice[client] = false;
}
void DeadlyVoice_Voice(int client){
if(!g_bHasDeadlyVoice[client]) return;
float fEngineTime = GetEngineTime();
if(fEngineTime < g_fDeadlyVoiceLastAttack[client] +g_fDeadlyVoiceRate)
return;
g_fDeadlyVoiceLastAttack[client] = fEngineTime;
if(g_iDeadlyVoiceParticle[client] < 1)
g_iDeadlyVoiceParticle[client] = CreateParticle(client, g_sDeadlyVoiceParticles[GetClientTeam(client)]);
float fShake[3];
fShake[0] = GetRandomFloat(-5.0, -25.0);
SetEntPropVector(client, Prop_Send, "m_vecPunchAngle", fShake);
DeadlyVoice_HurtSurroundings(client);
EmitSoundToAll(DEADLYVOICE_SOUND_ATTACK, client);
CreateTimer(g_fDeadlyVoiceRate, Timer_DeadlyVoice_DestroyParticle, GetClientSerial(client));
}
public Action Timer_DeadlyVoice_DestroyParticle(Handle hTimer, int iSerial){
int client = GetClientFromSerial(iSerial);
if(g_iDeadlyVoiceParticle[client] > MaxClients && IsValidEntity(g_iDeadlyVoiceParticle[client])){
AcceptEntityInput(g_iDeadlyVoiceParticle[client], "Kill");
g_iDeadlyVoiceParticle[client] = 0;
}
return Plugin_Stop;
}
void DeadlyVoice_HurtSurroundings(client){
if(!IsValidClient(client)) return;
float fClientPos[3];
GetClientAbsOrigin(client, fClientPos);
for(int i = 1; i <= MaxClients; i++){
if(!DeadlyVoice_IsValidTargetFor(client, i)) continue;
float fTargetPos[3];
GetClientAbsOrigin(i, fTargetPos);
float fDistance = GetVectorDistance(fClientPos, fTargetPos);
if(fDistance < g_fDeadlyVoiceRange){
DeadlyVoice_ShakeScreen(i);
SDKHooks_TakeDamage(i, 0, client, g_fDeadlyVoiceDamage, DMG_BLAST);
}
}
}
void DeadlyVoice_ShakeScreen(int client){
if(!IsValidClient(client)) return;
float vec[3];
vec[0] = GetRandomFloat(-15.0, 15.0);
vec[1] = GetRandomFloat(-15.0, 15.0);
vec[2] = GetRandomFloat(-15.0, 15.0);
SetEntPropVector(client, Prop_Send, "m_vecPunchAngle", vec);
}
stock bool DeadlyVoice_IsValidTargetFor(int client, int target){
if(client == target)
return false;
if(!IsClientInGame(target))
return false;
if(!IsPlayerAlive(target))
return false;
if(!CanEntitySeeTarget(client, target))
return false;
return CanPlayerBeHurt(target, client);
}
void DeadlyVoice_ProcessSettings(const char[] sSettings){
char[][] sPieces = new char[3][8];
ExplodeString(sSettings, ",", sPieces, 3, 8);
g_fDeadlyVoiceRate = StringToFloat(sPieces[0]);
g_fDeadlyVoiceRange = StringToFloat(sPieces[1]);
g_fDeadlyVoiceDamage = StringToFloat(sPieces[2]);
}

135
scripting/rtd/drugged.sp Normal file
View File

@@ -0,0 +1,135 @@
/*
This script is a part of RTD2 plugin and is not meant to work by itself.
If you were to edit anything here, you'd have to recompile rtd2.sp instead of this one.
*** HOW TO ADD A PERK ***
A quick note: This tutorial may not be kept up to date; for an updated one, go to the plugin's thread.
1. Set up:
a) Have <perkname>.sp in scripting/rtd.
b) Add it to the includes in scripting/rtd/#perks.sp.
c) Add a new section with a correct ID (highest one +1) to the config/rtd2_perks.cfg and set its settings.
2. Edit scripting/rtd/#manager.sp
a) In a function named ManagePerk() add a new case to the switch() with your perk's ID.
b) In the added case specify a function which is going to execute from <perkname>.sp with parameters:
1) @client - the client the perk should be applied to/removed from
2) @fSpecialPref - the optional "special" value in config/rtd2_perks.cfg
2) @enable - to specify whether the perk should be applied/removed
c) OPTIONAL: You can specify a function in your perk which should run at OnMapStart() in the Forward_OnMapStart() function.
You will need it if you'd want to, for example, precache a sound or loop through existing clients.
d) OPTIONAL: You can specify a function in your perk which should run at OnPlayerRunCmd() in the Forward_OnPlayerRunCmd() function.
You can use it if you'd need something to run each frame or on a certain button press.
NOTE: The forwarded client is guaranteed to be valid BUT NOT GUARANTEED IF THEY ARE ALIVE.
3. Script your perk:
a) Create a public function in <perkname>.sp with parameters @client, @iPref, @bool:apply as an example below
- This is the only function used to transfer info between the core and the include
- You don't need to include any includes that are in the rtd2.sp
b) NOTE: If you need to transfer the iPref to a different function, set it globally but remember to use an unique name
c) Name it AS SAME AS you named the function in the added case in the switch() in #manager.sp
d) From there, script the functionality like there's no tomorrow
e) You are free to use IsValidClient(). It returns false when:
- An incorrect client index is specified
- Client is not in game
- Client is fake (bot)
- Client is Coaching
4. Compile rtd2.sp and you're good to go!
*/
bool g_bIsDrugged[MAXPLAYERS+1] = {false, ...};
UserMsg g_DruggedMsgId;
void Drugged_Start(){
g_DruggedMsgId = GetUserMessageId("Fade");
}
void Drugged_Perk(int client, const char[] sPref, bool apply){
if(apply)
Drugged_ApplyPerk(client, StringToFloat(sPref));
else
g_bIsDrugged[client] = false;
}
void Drugged_ApplyPerk(int client, float fInterval){
CreateTimer(fInterval, Timer_DrugTick, GetClientSerial(client), TIMER_REPEAT);
g_bIsDrugged[client] = true;
}
public Action Timer_DrugTick(Handle hTimer, int iSerial){
int client = GetClientFromSerial(iSerial);
if(!IsValidClient(client))
return Plugin_Stop;
if(!g_bIsDrugged[client]){
Drugged_RemovePerk(client);
return Plugin_Stop;
}
Drugged_Tick(client);
return Plugin_Continue;
}
void Drugged_Tick(int client){
float fPunch[3];
fPunch[0] = GetRandomFloat(-45.0, 45.0);
fPunch[1] = GetRandomFloat(-45.0, 45.0);
fPunch[2] = GetRandomFloat(-45.0, 45.0);
SetEntPropVector(client, Prop_Send, "m_vecPunchAngle", fPunch);
int iClients[2];
iClients[0] = client;
Handle hMsg = StartMessageEx(g_DruggedMsgId, iClients, 1);
BfWriteShort(hMsg, 255);
BfWriteShort(hMsg, 255);
BfWriteShort(hMsg, (0x0002));
BfWriteByte(hMsg, GetRandomInt(0,255));
BfWriteByte(hMsg, GetRandomInt(0,255));
BfWriteByte(hMsg, GetRandomInt(0,255));
BfWriteByte(hMsg, 128);
EndMessage();
}
void Drugged_RemovePerk(int client){
float fAng[3]; GetClientEyeAngles(client, fAng);
fAng[2] = 0.0;
TeleportEntity(client, NULL_VECTOR, fAng, NULL_VECTOR);
int iClients[2];
iClients[0] = client;
Handle hMsg = StartMessageEx(g_DruggedMsgId, iClients, 1);
BfWriteShort(hMsg, 1536);
BfWriteShort(hMsg, 1536);
BfWriteShort(hMsg, (0x0001 | 0x0010));
BfWriteByte(hMsg, 0);
BfWriteByte(hMsg, 0);
BfWriteByte(hMsg, 0);
BfWriteByte(hMsg, 0);
EndMessage();
}

View File

@@ -0,0 +1,76 @@
/*
This script is a part of RTD2 plugin and is not meant to work by itself.
If you were to edit anything here, you'd have to recompile rtd2.sp instead of this one.
*** HOW TO ADD A PERK ***
A quick note: This tutorial may not be kept up to date; for an updated one, go to the plugin's thread.
1. Set up:
a) Have <perkname>.sp in scripting/rtd.
b) Add it to the includes in scripting/rtd/#perks.sp.
c) Add a new section with a correct ID (highest one +1) to the config/rtd2_perks.cfg and set its settings.
2. Edit scripting/rtd/#manager.sp
a) In a function named ManagePerk() add a new case to the switch() with your perk's ID.
b) In the added case specify a function which is going to execute from <perkname>.sp with parameters:
1) @client - the client the perk should be applied to/removed from
2) @fSpecialPref - the optional "special" value in config/rtd2_perks.cfg
2) @enable - to specify whether the perk should be applied/removed
c) OPTIONAL: You can specify a function in your perk which should run at OnMapStart() in the Forward_OnMapStart() function.
You will need it if you'd want to, for example, precache a sound or loop through existing clients.
d) OPTIONAL: You can specify a function in your perk which should run at OnPlayerRunCmd() in the Forward_OnPlayerRunCmd() function.
You can use it if you'd need something to run each frame or on a certain button press.
NOTE: The forwarded client is guaranteed to be valid BUT NOT GUARANTEED IF THEY ARE ALIVE.
3. Script your perk:
a) Create a public function in <perkname>.sp with parameters @client, @iPref, @bool:apply as an example below
- This is the only function used to transfer info between the core and the include
- You don't need to include any includes that are in the rtd2.sp
b) NOTE: If you need to transfer the iPref to a different function, set it globally but remember to use an unique name
c) Name it AS SAME AS you named the function in the added case in the switch() in #manager.sp
d) From there, script the functionality like there's no tomorrow
e) You are free to use IsValidClient(). It returns false when:
- An incorrect client index is specified
- Client is not in game
- Client is fake (bot)
- Client is Coaching
4. Compile rtd2.sp and you're good to go!
*/
UserMsg g_EarthquakeMsgId;
void Earthquake_Start(){
g_EarthquakeMsgId = GetUserMessageId("Shake");
}
void Earthquake_Perk(int client, const char[] sPref, bool apply){
if(!apply)
return;
char[][] sPieces = new char[3][8];
ExplodeString(sPref, ",", sPieces, 2, 8);
float fAmplitude = StringToFloat(sPieces[0]);
float fFrequency = StringToFloat(sPieces[1]);
int iClients[2];
iClients[0] = client;
Handle hMsg = StartMessageEx(g_EarthquakeMsgId, iClients, 1);
if(hMsg != INVALID_HANDLE){
BfWriteByte(hMsg, 0);
BfWriteFloat(hMsg, fAmplitude);
BfWriteFloat(hMsg, fFrequency);
BfWriteFloat(hMsg, float(GetPerkTime(27)));
EndMessage();
}
}

47
scripting/rtd/explode.sp Normal file
View File

@@ -0,0 +1,47 @@
/*
This script is a part of RTD2 plugin and is not meant to work by itself.
If you were to edit anything here, you'd have to recompile rtd2.sp instead of this one.
*** HOW TO ADD A PERK ***
A quick note: This tutorial may not be kept up to date; for an updated one, go to the plugin's thread.
1. Set up:
a) Have <perkname>.sp in scripting/rtd.
b) Add it to the includes in scripting/rtd/#perks.sp.
c) Add a new section with a correct ID (highest one +1) to the config/rtd2_perks.cfg and set its settings.
2. Edit scripting/rtd/#manager.sp
a) In a function named ManagePerk() add a new case to the switch() with your perk's ID.
b) In the added case specify a function which is going to execute from <perkname>.sp with parameters:
1) @client - the client the perk should be applied to/removed from
2) @fSpecialPref - the optional "special" value in config/rtd2_perks.cfg
2) @enable - to specify whether the perk should be applied/removed
c) OPTIONAL: You can specify a function in your perk which should run at OnMapStart() in the Forward_OnMapStart() function.
You will need it if you'd want to, for example, precache a sound or loop through existing clients.
d) OPTIONAL: You can specify a function in your perk which should run at OnPlayerRunCmd() in the Forward_OnPlayerRunCmd() function.
You can use it if you'd need something to run each frame or on a certain button press.
NOTE: The forwarded client is guaranteed to be valid BUT NOT GUARANTEED IF THEY ARE ALIVE.
3. Script your perk:
a) Create a public function in <perkname>.sp with parameters @client, @iPref, @bool:apply as an example below
- This is the only function used to transfer info between the core and the include
- You don't need to include any includes that are in the rtd2.sp
b) NOTE: If you need to transfer the iPref to a different function, set it globally but remember to use an unique name
c) Name it AS SAME AS you named the function in the added case in the switch() in #manager.sp
d) From there, script the functionality like there's no tomorrow
e) You are free to use IsValidClient(). It returns false when:
- An incorrect client index is specified
- Client is not in game
- Client is fake (bot)
- Client is Coaching
4. Compile rtd2.sp and you're good to go!
*/
public void Explode_Perk(int client, const char[] sPref, bool apply){
FakeClientCommand(client, "explode");
}

View File

@@ -0,0 +1,132 @@
/*
This script is a part of RTD2 plugin and is not meant to work by itself.
If you were to edit anything here, you'd have to recompile rtd2.sp instead of this one.
*** HOW TO ADD A PERK ***
A quick note: This tutorial may not be kept up to date; for an updated one, go to the plugin's thread.
1. Set up:
a) Have <perkname>.sp in scripting/rtd.
b) Add it to the includes in scripting/rtd/#perks.sp.
c) Add a new section with a correct ID (highest one +1) to the config/rtd2_perks.cfg and set its settings.
2. Edit scripting/rtd/#manager.sp
a) In a function named ManagePerk() add a new case to the switch() with your perk's ID.
b) In the added case specify a function which is going to execute from <perkname>.sp with parameters:
1) @client - the client the perk should be applied to/removed from
2) @fSpecialPref - the optional "special" value in config/rtd2_perks.cfg
2) @enable - to specify whether the perk should be applied/removed
c) OPTIONAL: You can specify a function in your perk which should run at OnMapStart() in the Forward_OnMapStart() function.
You will need it if you'd want to, for example, precache a sound or loop through existing clients.
d) OPTIONAL: You can specify a function in your perk which should run at OnPlayerRunCmd() in the Forward_OnPlayerRunCmd() function.
You can use it if you'd need something to run each frame or on a certain button press.
NOTE: The forwarded client is guaranteed to be valid BUT NOT GUARANTEED IF THEY ARE ALIVE.
3. Script your perk:
a) Create a public function in <perkname>.sp with parameters @client, @iPref, @bool:apply as an example below
- This is the only function used to transfer info between the core and the include
- You don't need to include any includes that are in the rtd2.sp
b) NOTE: If you need to transfer the iPref to a different function, set it globally but remember to use an unique name
c) Name it AS SAME AS you named the function in the added case in the switch() in #manager.sp
d) From there, script the functionality like there's no tomorrow
e) You are free to use IsValidClient(). It returns false when:
- An incorrect client index is specified
- Client is not in game
- Client is fake (bot)
- Client is Coaching
4. Compile rtd2.sp and you're good to go!
*/
bool g_bHasExplosiveArrows[MAXPLAYERS+1] = {false, ...};
char g_sExplosiveArrowsDamage[8] = "100";
char g_sExplosiveArrowsRadius[8] = "80";
float g_fExplosiveArrowsForce = 100.0;
Handle g_hExplosiveArrows = INVALID_HANDLE;
void ExplosiveArrows_Start(){
g_hExplosiveArrows = CreateArray();
}
void ExplosiveArrows_Perk(int client, const char[] sPref, bool apply){
ExplosiveArrows_ProcessSettings(sPref);
g_bHasExplosiveArrows[client] = apply;
}
void ExplosiveArrows_OnEntityCreated(int iEnt, const char[] sClassname){
if(ExplosiveArrows_ValidClassname(sClassname))
SDKHook(iEnt, SDKHook_Spawn, Timer_ExplosiveArrows_ProjectileSpawn);
}
public void Timer_ExplosiveArrows_ProjectileSpawn(int iProjectile){
int iLauncher = GetEntPropEnt(iProjectile, Prop_Send, "m_hOwnerEntity");
if(iLauncher < 1 || !IsValidClient(iLauncher) || !IsPlayerAlive(iLauncher))
return;
if(!g_bHasExplosiveArrows[iLauncher])
return;
if(FindValueInArray(g_hExplosiveArrows, iProjectile) > -1)
return;
PushArrayCell(g_hExplosiveArrows, iProjectile);
SDKHook(iProjectile, SDKHook_StartTouchPost, ExplosiveArrows_ProjectileTouch);
}
public void ExplosiveArrows_ProjectileTouch(int iEntity, int iOther){
int iExplosion = CreateEntityByName("env_explosion");
RemoveFromArray(g_hExplosiveArrows, FindValueInArray(g_hExplosiveArrows, iEntity));
if(!IsValidEntity(iExplosion))
return;
DispatchKeyValue(iExplosion, "iMagnitude", g_sExplosiveArrowsDamage);
DispatchKeyValue(iExplosion, "iRadiusOverride", g_sExplosiveArrowsRadius);
DispatchKeyValueFloat(iExplosion, "DamageForce", g_fExplosiveArrowsForce);
DispatchSpawn(iExplosion);
ActivateEntity(iExplosion);
SetEntPropEnt(iExplosion, Prop_Data, "m_hOwnerEntity", GetEntPropEnt(iEntity, Prop_Send, "m_hOwnerEntity"));
float fPos[3];
GetEntPropVector(iEntity, Prop_Send, "m_vecOrigin", fPos);
TeleportEntity(iExplosion, fPos, NULL_VECTOR, NULL_VECTOR);
AcceptEntityInput(iExplosion, "Explode");
AcceptEntityInput(iExplosion, "Kill");
}
bool ExplosiveArrows_ValidClassname(const char[] sCls){
if(StrEqual(sCls, "tf_projectile_healing_bolt")
|| StrEqual(sCls, "tf_projectile_arrow"))
return true;
return false;
}
void ExplosiveArrows_ProcessSettings(const char[] sSettings){
char[][] sPieces = new char[3][8];
ExplodeString(sSettings, ",", sPieces, 3, 8);
strcopy(g_sExplosiveArrowsDamage, 8, sPieces[0]);
strcopy(g_sExplosiveArrowsRadius, 8, sPieces[1]);
g_fExplosiveArrowsForce = StringToFloat(sPieces[3]);
}

124
scripting/rtd/extraammo.sp Normal file
View File

@@ -0,0 +1,124 @@
/*
This script is a part of RTD2 plugin and is not meant to work by itself.
If you were to edit anything here, you'd have to recompile rtd2.sp instead of this one.
*** HOW TO ADD A PERK ***
A quick note: This tutorial may not be kept up to date; for an updated one, go to the plugin's thread.
1. Set up:
a) Have <perkname>.sp in scripting/rtd.
b) Add it to the includes in scripting/rtd/#perks.sp.
c) Add a new section with a correct ID (highest one +1) to the config/rtd2_perks.cfg and set its settings.
2. Edit scripting/rtd/#manager.sp
a) In a function named ManagePerk() add a new case to the switch() with your perk's ID.
b) In the added case specify a function which is going to execute from <perkname>.sp with parameters:
1) @client - the client the perk should be applied to/removed from
2) @fSpecialPref - the optional "special" value in config/rtd2_perks.cfg
2) @enable - to specify whether the perk should be applied/removed
c) OPTIONAL: You can specify a function in your perk which should run at OnMapStart() in the Forward_OnMapStart() function.
You will need it if you'd want to, for example, precache a sound or loop through existing clients.
d) OPTIONAL: You can specify a function in your perk which should run at OnPlayerRunCmd() in the Forward_OnPlayerRunCmd() function.
You can use it if you'd need something to run each frame or on a certain button press.
NOTE: The forwarded client is guaranteed to be valid BUT NOT GUARANTEED IF THEY ARE ALIVE.
3. Script your perk:
a) Create a public function in <perkname>.sp with parameters @client, @iPref, @bool:apply as an example below
- This is the only function used to transfer info between the core and the include
- You don't need to include any includes that are in the rtd2.sp
b) NOTE: If you need to transfer the iPref to a different function, set it globally but remember to use an unique name
c) Name it AS SAME AS you named the function in the added case in the switch() in #manager.sp
d) From there, script the functionality like there's no tomorrow
e) You are free to use IsValidClient(). It returns false when:
- An incorrect client index is specified
- Client is not in game
- Client is fake (bot)
- Client is Coaching
4. Compile rtd2.sp and you're good to go!
*/
int g_iExtraAmmoOffsetClip, g_iExtraAmmoOffsetAmmo, g_iExtraAmmoOffsetAmmoType;
void ExtraAmmo_Start(){
g_iExtraAmmoOffsetClip = FindSendPropInfo("CTFWeaponBase", "m_iClip1");
g_iExtraAmmoOffsetAmmo = FindSendPropInfo("CTFPlayer", "m_iAmmo");
g_iExtraAmmoOffsetAmmoType = FindSendPropInfo("CBaseCombatWeapon", "m_iPrimaryAmmoType");
}
void ExtraAmmo_Perk(int client, const char[] sPref, bool apply){
if(!apply)
return;
int iWeapon = -1;
for(int i = 0; i < 2; i++){
iWeapon = GetPlayerWeaponSlot(client, i);
if(iWeapon <= MaxClients || !IsValidEntity(iWeapon))
continue;
ExtraAmmo_MultiplyAmmo(client, iWeapon, StringToFloat(sPref));
}
}
void ExtraAmmo_MultiplyAmmo(int client, int iWeapon, float fMultiplier){
switch(GetEntProp(iWeapon, Prop_Send, "m_iItemDefinitionIndex")){
case 441,442,588:{
SetEntPropFloat(iWeapon, Prop_Send, "m_flEnergy", 20.0*fMultiplier);
}
default:{
int iClip = ExtraAmmo_GetClip(iWeapon);
if(iClip > -1)
ExtraAmmo_SetClip(iWeapon, iClip < 1 ? RoundFloat(fMultiplier) : RoundFloat(float(iClip) *fMultiplier));
int iAmmo = ExtraAmmo_GetAmmo(client, iWeapon);
if(iAmmo > -1)
ExtraAmmo_SetAmmo(client, iWeapon, iAmmo < 1 ? RoundFloat(fMultiplier) : RoundFloat(float(iAmmo) *fMultiplier));
}
}
}
//The bellow are ripped straight from the original RTD
int ExtraAmmo_SetAmmo(int client, int iWeapon, int iAmount){
return SetEntData(client, g_iExtraAmmoOffsetAmmo + GetEntData(iWeapon, g_iExtraAmmoOffsetAmmoType, 1) * 4, iAmount);
}
int ExtraAmmo_GetAmmo(int client, int iWeapon){
int iAmmoType = GetEntData(iWeapon, g_iExtraAmmoOffsetAmmoType, 1);
if(iAmmoType == 4) return -1;
return GetEntData(client, g_iExtraAmmoOffsetAmmo + iAmmoType * 4);
}
int ExtraAmmo_SetClip(int iWeapon, int iAmount){
return SetEntData(iWeapon, g_iExtraAmmoOffsetClip, iAmount, _, true);
}
int ExtraAmmo_GetClip(int iWeapon){
return GetEntData(iWeapon, g_iExtraAmmoOffsetClip);
}

View File

@@ -0,0 +1,85 @@
/*
This script is a part of RTD2 plugin and is not meant to work by itself.
If you were to edit anything here, you'd have to recompile rtd2.sp instead of this one.
*** HOW TO ADD A PERK ***
A quick note: This tutorial may not be kept up to date; for an updated one, go to the plugin's thread.
1. Set up:
a) Have <perkname>.sp in scripting/rtd.
b) Add it to the includes in scripting/rtd/#perks.sp.
c) Add a new section with a correct ID (highest one +1) to the config/rtd2_perks.cfg and set its settings.
2. Edit scripting/rtd/#manager.sp
a) In a function named ManagePerk() add a new case to the switch() with your perk's ID.
b) In the added case specify a function which is going to execute from <perkname>.sp with parameters:
1) @client - the client the perk should be applied to/removed from
2) @fSpecialPref - the optional "special" value in config/rtd2_perks.cfg
2) @enable - to specify whether the perk should be applied/removed
c) OPTIONAL: You can specify a function in your perk which should run at OnMapStart() in the Forward_OnMapStart() function.
You will need it if you'd want to, for example, precache a sound or loop through existing clients.
d) OPTIONAL: You can specify a function in your perk which should run at OnPlayerRunCmd() in the Forward_OnPlayerRunCmd() function.
You can use it if you'd need something to run each frame or on a certain button press.
NOTE: The forwarded client is guaranteed to be valid BUT NOT GUARANTEED IF THEY ARE ALIVE.
3. Script your perk:
a) Create a public function in <perkname>.sp with parameters @client, @iPref, @bool:apply as an example below
- This is the only function used to transfer info between the core and the include
- You don't need to include any includes that are in the rtd2.sp
b) NOTE: If you need to transfer the iPref to a different function, set it globally but remember to use an unique name
c) Name it AS SAME AS you named the function in the added case in the switch() in #manager.sp
d) From there, script the functionality like there's no tomorrow
e) You are free to use IsValidClient(). It returns false when:
- An incorrect client index is specified
- Client is not in game
- Client is fake (bot)
- Client is Coaching
4. Compile rtd2.sp and you're good to go!
*/
void ExtraThrowables_Perk(int client, const char[] sPref, bool apply){
if(!apply)
return;
int iAmount = StringToInt(sPref);
int iWeapon = 0;
if(TF2_GetPlayerClass(client) == TFClass_Scout){
iWeapon = GetPlayerWeaponSlot(client, 2);
if(IsValidEntity(iWeapon)){
int iIndex = GetEntProp(iWeapon, Prop_Send, "m_iItemDefinitionIndex");
if(iIndex == 44 || iIndex == 648)
ExtraThrowables_Set(client, iWeapon, iAmount);
}
}
iWeapon = GetPlayerWeaponSlot(client, 1);
if(!IsValidEntity(iWeapon))
return;
int iIndex = GetEntProp(iWeapon, Prop_Send, "m_iItemDefinitionIndex");
switch(iIndex){
case 222, 812, 833, 1121, 42, 159, 311, 433, 863, 1002, 58, 1083, 1105:
ExtraThrowables_Set(client, iWeapon, iAmount);
}
}
stock void ExtraThrowables_Set(int client, int iWeapon, int iAmount){
int iOffset = GetEntProp(iWeapon, Prop_Send, "m_iPrimaryAmmoType", 1)*4;
int iAmmoTable = FindSendPropInfo("CTFPlayer", "m_iAmmo");
SetEntData(client, iAmmoTable+iOffset, iAmount, 4, true);
}

View File

@@ -0,0 +1,65 @@
/*
This script is a part of RTD2 plugin and is not meant to work by itself.
If you were to edit anything here, you'd have to recompile rtd2.sp instead of this one.
*** HOW TO ADD A PERK ***
A quick note: This tutorial may not be kept up to date; for an updated one, go to the plugin's thread.
1. Set up:
a) Have <perkname>.sp in scripting/rtd.
b) Add it to the includes in scripting/rtd/#perks.sp.
c) Add a new section with a correct ID (highest one +1) to the config/rtd2_perks.cfg and set its settings.
2. Edit scripting/rtd/#manager.sp
a) In a function named ManagePerk() add a new case to the switch() with your perk's ID.
b) In the added case specify a function which is going to execute from <perkname>.sp with parameters:
1) @client - the client the perk should be applied to/removed from
2) @fSpecialPref - the optional "special" value in config/rtd2_perks.cfg
2) @enable - to specify whether the perk should be applied/removed
c) OPTIONAL: You can specify a function in your perk which should run at OnMapStart() in the Forward_OnMapStart() function.
You will need it if you'd want to, for example, precache a sound or loop through existing clients.
d) OPTIONAL: You can specify a function in your perk which should run at OnPlayerRunCmd() in the Forward_OnPlayerRunCmd() function.
You can use it if you'd need something to run each frame or on a certain button press.
NOTE: The forwarded client is guaranteed to be valid BUT NOT GUARANTEED IF THEY ARE ALIVE.
3. Script your perk:
a) Create a public function in <perkname>.sp with parameters @client, @iPref, @bool:apply as an example below
- This is the only function used to transfer info between the core and the include
- You don't need to include any includes that are in the rtd2.sp
b) NOTE: If you need to transfer the iPref to a different function, set it globally but remember to use an unique name
c) Name it AS SAME AS you named the function in the added case in the switch() in #manager.sp
d) From there, script the functionality like there's no tomorrow
e) You are free to use IsValidClient(). It returns false when:
- An incorrect client index is specified
- Client is not in game
- Client is fake (bot)
- Client is Coaching
4. Compile rtd2.sp and you're good to go!
*/
bool g_bHasEyeForAnEye[MAXPLAYERS+1] = {false, ...};
void EyeForAnEye_Start(){
HookEvent("player_hurt", EyeForAnEye_PlayerHurt);
}
public void EyeForAnEye_Perk(int client, const char[] sPref, bool apply){
g_bHasEyeForAnEye[client] = apply;
}
public EyeForAnEye_PlayerHurt(Handle hEvent, const char[] sEventName, bool bDontBroadcast){
int attacker = GetClientOfUserId(GetEventInt(hEvent, "attacker"));
if(!g_bHasEyeForAnEye[attacker])
return;
SDKHooks_TakeDamage(attacker, 0, 0, float(GetEventInt(hEvent, "damageamount")));
}

164
scripting/rtd/fasthands.sp Normal file
View File

@@ -0,0 +1,164 @@
/*
This script is a part of RTD2 plugin and is not meant to work by itself.
If you were to edit anything here, you'd have to recompile rtd2.sp instead of this one.
*** HOW TO ADD A PERK ***
A quick note: This tutorial may not be kept up to date; for an updated one, go to the plugin's thread.
1. Set up:
a) Have <perkname>.sp in scripting/rtd.
b) Add it to the includes in scripting/rtd/#perks.sp.
c) Add a new section with a correct ID (highest one +1) to the config/rtd2_perks.cfg and set its settings.
2. Edit scripting/rtd/#manager.sp
a) In a function named ManagePerk() add a new case to the switch() with your perk's ID.
b) In the added case specify a function which is going to execute from <perkname>.sp with parameters:
1) @client - the client the perk should be applied to/removed from
2) @fSpecialPref - the optional "special" value in config/rtd2_perks.cfg
2) @enable - to specify whether the perk should be applied/removed
c) OPTIONAL: You can specify a function in your perk which should run at OnMapStart() in the Forward_OnMapStart() function.
You will need it if you'd want to, for example, precache a sound or loop through existing clients.
d) OPTIONAL: You can specify a function in your perk which should run at OnPlayerRunCmd() in the Forward_OnPlayerRunCmd() function.
You can use it if you'd need something to run each frame or on a certain button press.
NOTE: The forwarded client is guaranteed to be valid BUT NOT GUARANTEED IF THEY ARE ALIVE.
3. Script your perk:
a) Create a public function in <perkname>.sp with parameters @client, @iPref, @bool:apply as an example below
- This is the only function used to transfer info between the core and the include
- You don't need to include any includes that are in the rtd2.sp
b) NOTE: If you need to transfer the iPref to a different function, set it globally but remember to use an unique name
c) Name it AS SAME AS you named the function in the added case in the switch() in #manager.sp
d) From there, script the functionality like there's no tomorrow
e) You are free to use IsValidClient(). It returns false when:
- An incorrect client index is specified
- Client is not in game
- Client is fake (bot)
- Client is Coaching
4. Compile rtd2.sp and you're good to go!
*/
#define ATTRIB_RATE 6
#define ATTRIB_RELOAD 97
bool g_bHasFastHands[MAXPLAYERS+1] = {false, ...};
bool g_bHasFastHands2[MAXPLAYERS+1] = {false, ...};
float g_fFastHandsRateMultiplier = 2.0;
float g_fFastHandsReloadMultiplier = 2.0;
void FastHands_Start(){
HookEvent("post_inventory_application", FastHands_Resupply, EventHookMode_Post);
}
public void FastHands_OnEntityCreated(int iEnt, const char[] sClassname){
if(StrEqual(sClassname, "tf_dropped_weapon"))
SDKHook(iEnt, SDKHook_SpawnPost, FastHands_OnDroppedWeaponSpawn);
}
public void FastHands_OnDroppedWeaponSpawn(int iEnt){
int client = AccountIDToClient(GetEntProp(iEnt, Prop_Send, "m_iAccountID"));
if(client == -1)
return;
if(g_bHasFastHands2[client])
AcceptEntityInput(iEnt, "Kill");
}
void FastHands_Perk(int client, const char[] sPref, bool apply){
if(apply)
FastHands_ApplyPerk(client, sPref);
else
FastHands_RemovePerk(client);
}
void FastHands_ApplyPerk(int client, const char[] sSettings){
FastHands_ProcessSettings(sSettings);
FastHands_EditClientWeapons(client, true);
g_bHasFastHands[client] = true;
g_bHasFastHands2[client]= true;
}
void FastHands_RemovePerk(int client){
FastHands_EditClientWeapons(client, false);
g_bHasFastHands[client] = false;
CreateTimer(0.5, Timer_FastHands_FullUnset, GetClientSerial(client));
}
public Action Timer_FastHands_FullUnset(Handle hTimer, int iSerial){
int client = GetClientFromSerial(iSerial);
if(client < 1)
return Plugin_Stop;
g_bHasFastHands2[client] = false;
return Plugin_Stop;
}
void FastHands_EditClientWeapons(int client, bool apply){
int iWeapon = 0;
for(int i = 0; i < 3; i++){
iWeapon = GetPlayerWeaponSlot(client, i);
if(iWeapon <= MaxClients || !IsValidEntity(iWeapon))
continue;
if(apply){
if(g_fFastHandsRateMultiplier != 0.0)
TF2Attrib_SetByDefIndex(iWeapon, ATTRIB_RATE, g_fFastHandsRateMultiplier);
if(g_fFastHandsReloadMultiplier != 0.0)
TF2Attrib_SetByDefIndex(iWeapon, ATTRIB_RELOAD, g_fFastHandsReloadMultiplier);
}else{
TF2Attrib_RemoveByDefIndex(iWeapon, ATTRIB_RATE);
TF2Attrib_RemoveByDefIndex(iWeapon, ATTRIB_RELOAD);
}
}
}
public void FastHands_Resupply(Handle hEvent, const char[] sEventName, bool bDontBroadcast){
int client = GetClientOfUserId(GetEventInt(hEvent, "userid"));
if(!IsValidClient(client)) return;
if(!g_bHasFastHands[client]) return;
FastHands_EditClientWeapons(client, true);
}
void FastHands_ProcessSettings(const char[] sSettings){
char[][] sPieces = new char[2][8];
ExplodeString(sSettings, ",", sPieces, 2, 8);
g_fFastHandsRateMultiplier = Pow(StringToFloat(sPieces[0]), -1.0);
g_fFastHandsReloadMultiplier = Pow(StringToFloat(sPieces[1]), -1.0);
}

143
scripting/rtd/firebreath.sp Normal file
View File

@@ -0,0 +1,143 @@
/*
This script is a part of RTD2 plugin and is not meant to work by itself.
If you were to edit anything here, you'd have to recompile rtd2.sp instead of this one.
*** HOW TO ADD A PERK ***
A quick note: This tutorial may not be kept up to date; for an updated one, go to the plugin's thread.
1. Set up:
a) Have <perkname>.sp in scripting/rtd.
b) Add it to the includes in scripting/rtd/#perks.sp.
c) Add a new section with a correct ID (highest one +1) to the config/rtd2_perks.cfg and set its settings.
2. Edit scripting/rtd/#manager.sp
a) In a function named ManagePerk() add a new case to the switch() with your perk's ID.
b) In the added case specify a function which is going to execute from <perkname>.sp with parameters:
1) @client - the client the perk should be applied to/removed from
2) @fSpecialPref - the optional "special" value in config/rtd2_perks.cfg
2) @enable - to specify whether the perk should be applied/removed
c) OPTIONAL: You can specify a function in your perk which should run at OnMapStart() in the Forward_OnMapStart() function.
You will need it if you'd want to, for example, precache a sound or loop through existing clients.
d) OPTIONAL: You can specify a function in your perk which should run at OnPlayerRunCmd() in the Forward_OnPlayerRunCmd() function.
You can use it if you'd need something to run each frame or on a certain button press.
NOTE: The forwarded client is guaranteed to be valid BUT NOT GUARANTEED IF THEY ARE ALIVE.
3. Script your perk:
a) Create a public function in <perkname>.sp with parameters @client, @iPref, @bool:apply as an example below
- This is the only function used to transfer info between the core and the include
- You don't need to include any includes that are in the rtd2.sp
b) NOTE: If you need to transfer the iPref to a different function, set it globally but remember to use an unique name
c) Name it AS SAME AS you named the function in the added case in the switch() in #manager.sp
d) From there, script the functionality like there's no tomorrow
e) You are free to use IsValidClient(). It returns false when:
- An incorrect client index is specified
- Client is not in game
- Client is fake (bot)
- Client is Coaching
4. Compile rtd2.sp and you're good to go!
*/
#define FIREBREATH_SOUND_ATTACK "player/taunt_fire.wav"
bool g_bHasFireBreath[MAXPLAYERS+1] = {false, ...};
float g_fFireBreathLastAttack[MAXPLAYERS+1] = {0.0, ...};
float g_fFireBreathRate = 2.0;
float g_fFireBreathCritChance = 0.05;
void FireBreath_Start(){
PrecacheSound(FIREBREATH_SOUND_ATTACK);
}
void FireBreath_Perk(int client, const char[] sPref, bool apply){
if(apply)
FireBreath_ApplyPerk(client, sPref);
else
g_bHasFireBreath[client] = false;
}
void FireBreath_ApplyPerk(int client, const char[] sPref){
FireBreath_ProcessString(sPref);
g_bHasFireBreath[client] = true;
PrintToChat(client, "%s %T", "\x07FFD700[RTD]\x01", "RTD2_Perk_Attack", LANG_SERVER, 0x03, 0x01);
}
void FireBreath_Voice(int client){
if(!g_bHasFireBreath[client])
return;
float fEngineTime = GetEngineTime();
if(fEngineTime < g_fFireBreathLastAttack[client] +g_fFireBreathRate)
return;
g_fFireBreathLastAttack[client] = fEngineTime;
float fShake[3];
fShake[0] = GetRandomFloat(-5.0, -25.0);
SetEntPropVector(client, Prop_Send, "m_vecPunchAngle", fShake);
FireBreath_Fireball(client);
EmitSoundToAll(FIREBREATH_SOUND_ATTACK, client);
}
/*
Code borrowed from: [TF2] Spell casting!
https://forums.alliedmods.net/showthread.php?p=2054678
*/
void FireBreath_Fireball(client){
float fAng[3], fPos[3];
GetClientEyeAngles(client, fAng);
GetClientEyePosition(client, fPos);
int iTeam = GetClientTeam(client);
int iSpell = CreateEntityByName("tf_projectile_spellfireball");
if(!IsValidEntity(iSpell))
return;
float fVel[3], fBuf[3];
GetAngleVectors(fAng, fBuf, NULL_VECTOR, NULL_VECTOR);
fVel[0] = fBuf[0]*1100.0; //Speed of a tf2 rocket.
fVel[1] = fBuf[1]*1100.0;
fVel[2] = fBuf[2]*1100.0;
SetEntPropEnt (iSpell, Prop_Send, "m_hOwnerEntity", client);
SetEntProp (iSpell, Prop_Send, "m_bCritical", (GetURandomFloat() <= g_fFireBreathCritChance) ? 1 : 0, 1);
SetEntProp (iSpell, Prop_Send, "m_iTeamNum", iTeam, 1);
SetEntProp (iSpell, Prop_Send, "m_nSkin", iTeam-2);
SetVariantInt(iTeam);
AcceptEntityInput(iSpell, "TeamNum", -1, -1, 0);
SetVariantInt(iTeam);
AcceptEntityInput(iSpell, "SetTeam", -1, -1, 0);
DispatchSpawn(iSpell);
TeleportEntity(iSpell, fPos, fAng, fVel);
}
void FireBreath_ProcessString(const char[] sSettings){
char[][] sPieces = new char[2][8];
ExplodeString(sSettings, ",", sPieces, 3, 8);
g_fFireBreathRate = StringToFloat(sPieces[0]);
g_fFireBreathCritChance = StringToFloat(sPieces[1]);
}

View File

@@ -0,0 +1,290 @@
/*
This script is a part of RTD2 plugin and is not meant to work by itself.
If you were to edit anything here, you'd have to recompile rtd2.sp instead of this one.
*** HOW TO ADD A PERK ***
A quick note: This tutorial may not be kept up to date; for an updated one, go to the plugin's thread.
1. Set up:
a) Have <perkname>.sp in scripting/rtd.
b) Add it to the includes in scripting/rtd/#perks.sp.
c) Add a new section with a correct ID (highest one +1) to the config/rtd2_perks.cfg and set its settings.
2. Edit scripting/rtd/#manager.sp
a) In a function named ManagePerk() add a new case to the switch() with your perk's ID.
b) In the added case specify a function which is going to execute from <perkname>.sp with parameters:
1) @client - the client the perk should be applied to/removed from
2) @fSpecialPref - the optional "special" value in config/rtd2_perks.cfg
2) @enable - to specify whether the perk should be applied/removed
c) OPTIONAL: You can specify a function in your perk which should run at OnMapStart() in the Forward_OnMapStart() function.
You will need it if you'd want to, for example, precache a sound or loop through existing clients.
d) OPTIONAL: You can specify a function in your perk which should run at OnPlayerRunCmd() in the Forward_OnPlayerRunCmd() function.
You can use it if you'd need something to run each frame or on a certain button press.
NOTE: The forwarded client is guaranteed to be valid BUT NOT GUARANTEED IF THEY ARE ALIVE.
3. Script your perk:
a) Create a public function in <perkname>.sp with parameters @client, @iPref, @bool:apply as an example below
- This is the only function used to transfer info between the core and the include
- You don't need to include any includes that are in the rtd2.sp
b) NOTE: If you need to transfer the iPref to a different function, set it globally but remember to use an unique name
c) Name it AS SAME AS you named the function in the added case in the switch() in #manager.sp
d) From there, script the functionality like there's no tomorrow
e) You are free to use IsValidClient(). It returns false when:
- An incorrect client index is specified
- Client is not in game
- Client is fake (bot)
- Client is Coaching
4. Compile rtd2.sp and you're good to go!
*/
#define MODEL_BOMB "models/props_lakeside_event/bomb_temp_hat.mdl"
#define SOUND_FTIMEBOMB_TICK "buttons/button17.wav"
#define SOUND_FTIMEBOMB_GOFF "weapons/cguard/charging.wav"
#define SOUND_FEXPLODE "misc/halloween/spell_fireball_impact.wav"
#define TICK_SLOW 0.75
#define TICK_FAST 0.35
int g_iFTimebombTicks = 10;
float g_fFTimebombRadius = 512.0;
bool g_bHasFTimebomb[MAXPLAYERS+1] = {false, ...};
int g_iFTimebombClientTicks[MAXPLAYERS+1] = {0, ...};
float g_fFTimebombClientBeeps[MAXPLAYERS+1] = {TICK_SLOW, ...};
int g_iFTimebombHead[MAXPLAYERS+1] = {0, ...};
int g_iFTimebombState[MAXPLAYERS+1] = {0, ...};
int g_iFTimebombFlame[MAXPLAYERS+1] = {0, ...};
void FireTimebomb_Start(){
PrecacheModel(MODEL_BOMB);
PrecacheSound(SOUND_FEXPLODE);
PrecacheSound(SOUND_FTIMEBOMB_TICK);
PrecacheSound(SOUND_FTIMEBOMB_GOFF);
}
void FireTimebomb_Perk(int client, const char[] sPref, bool apply){
if(!apply)
return;
g_bHasFTimebomb[client] = true;
FireTimebomb_ProcessSettings(sPref);
if(g_iFTimebombHead[client] <= MaxClients)
g_iFTimebombHead[client] = FireTimebomb_SpawnBombHead(client);
int iSerial = GetClientSerial(client);
CreateTimer(1.0, Timer_FireTimebomb_Tick, iSerial, TIMER_REPEAT);
SetVariantInt(1);
AcceptEntityInput(client, "SetForcedTauntCam");
}
public Action Timer_FireTimebomb_Tick(Handle hTimer, int iSerial){
int client = GetClientFromSerial(iSerial);
if(!IsValidClient(client))
return Plugin_Stop;
if(!g_bHasFTimebomb[client])
return Plugin_Stop;
g_iFTimebombClientTicks[client]++;
if(g_iFTimebombHead[client] > MaxClients && IsValidEntity(g_iFTimebombHead[client]))
if(g_iFTimebombClientTicks[client] >= RoundToFloor(g_iFTimebombTicks*0.3))
if(g_iFTimebombClientTicks[client] < RoundToFloor(g_iFTimebombTicks*0.7))
FireTimebomb_BombState(client, 1);
else FireTimebomb_BombState(client, 2);
if(g_iFTimebombClientTicks[client] == g_iFTimebombTicks-1)
EmitSoundToAll(SOUND_FTIMEBOMB_GOFF, client);
else if(g_iFTimebombClientTicks[client] >= g_iFTimebombTicks){
FireTimebomb_Explode(client);
return Plugin_Stop;
}
return Plugin_Continue;
}
public Action Timer_FireTimebomb_Beep(Handle hTimer, int iSerial){
int client = GetClientFromSerial(iSerial);
if(!IsValidClient(client))
return Plugin_Stop;
if(!g_bHasFTimebomb[client])
return Plugin_Stop;
EmitSoundToAll(SOUND_FTIMEBOMB_TICK, client);
CreateTimer(g_fFTimebombClientBeeps[client], Timer_FireTimebomb_Beep, GetClientSerial(client));
return Plugin_Stop;
}
void FireTimebomb_BombState(int client, int iState){
if(iState == g_iFTimebombState[client])
return;
switch(iState){
case 1:{
EmitSoundToAll(SOUND_FTIMEBOMB_TICK, client);
g_fFTimebombClientBeeps[client] = TICK_SLOW;
CreateTimer(g_fFTimebombClientBeeps[client], Timer_FireTimebomb_Beep, GetClientSerial(client));
}
case 2:{
g_fFTimebombClientBeeps[client] = TICK_FAST;
}
}
SetEntProp(g_iFTimebombHead[client], Prop_Send, "m_nSkin", g_iFTimebombState[client]+1);
g_iFTimebombState[client] = iState;
}
void FireTimebomb_OnRemovePerk(int client){
if(g_bHasFTimebomb[client])
FireTimebomb_Explode(client, true);
}
void FireTimebomb_Explode(int client, bool bSilent=false){
SetVariantInt(0);
AcceptEntityInput(client, "SetForcedTauntCam");
g_iFTimebombClientTicks[client] = 0;
g_bHasFTimebomb[client] = false;
g_fFTimebombClientBeeps[client] = TICK_SLOW;
g_iFTimebombState[client] = 0;
if(g_iFTimebombHead[client] > MaxClients && IsValidEntity(g_iFTimebombHead[client]))
AcceptEntityInput(g_iFTimebombHead[client], "Kill");
if(g_iFTimebombFlame[client] > MaxClients && IsValidEntity(g_iFTimebombFlame[client]))
AcceptEntityInput(g_iFTimebombFlame[client], "Kill");
g_iFTimebombHead[client] = 0;
g_iFTimebombFlame[client] = 0;
if(bSilent)
return;
float fPos[3]; GetClientAbsOrigin(client, fPos);
int iPlayersIgnited = 0;
for(int i = 1; i <= MaxClients; i++){
if(i == client || !IsClientInGame(i) || !IsPlayerAlive(i))
continue;
if(!CanPlayerBeHurt(i, client))
continue;
if(!CanEntitySeeTarget(client, i))
continue;
float fPosTarget[3];
GetClientAbsOrigin(i, fPosTarget);
if(GetVectorDistance(fPos, fPosTarget) <= g_fFTimebombRadius){
TF2_IgnitePlayer(i, client);
iPlayersIgnited++;
}
}
int iExplosion = CreateParticle(client, "bombinomicon_burningdebris");
CreateTimer(1.0, Timer_FTimebombRemoveTempParticle, EntIndexToEntRef(iExplosion));
PrintToChat(client, "%s %T", "\x07FFD700[RTD]\x01", "RTD2_Perk_Timebomb_Ignite", LANG_SERVER, 0x03, iPlayersIgnited, 0x01);
EmitSoundToAll(SOUND_FEXPLODE, client);
TF2_IgnitePlayer(client, client);
}
public Action Timer_FTimebombRemoveTempParticle(Handle hTimer, int iRef){
int iEnt = EntRefToEntIndex(iRef);
if(iEnt <= MaxClients)
return Plugin_Stop;
if(!IsValidEntity(iEnt))
return Plugin_Stop;
AcceptEntityInput(iEnt, "Kill");
return Plugin_Stop;
}
int FireTimebomb_SpawnBombHead(int client){
int iBomb = CreateEntityByName("prop_dynamic");
DispatchKeyValue(iBomb, "model", MODEL_BOMB);
DispatchSpawn(iBomb);
SetVariantString("!activator");
AcceptEntityInput(iBomb, "SetParent", client, -1, 0);
TFClassType clsPlayer = TF2_GetPlayerClass(client);
if(clsPlayer == TFClass_Pyro || clsPlayer == TFClass_Engineer)
SetVariantString("OnUser1 !self,SetParentAttachment,head,0.0,-1");
else
SetVariantString("OnUser1 !self,SetParentAttachment,eyes,0.0,-1");
AcceptEntityInput(iBomb, "AddOutput");
AcceptEntityInput(iBomb, "FireUser1");
float fOffs[3];
fOffs[2] = 64.0;
g_iFTimebombFlame[client] = CreateParticle(client, "rockettrail", true, "", fOffs);
return iBomb;
}
void FireTimebomb_ProcessSettings(const char[] sSettings){
char[][] sPieces = new char[2][8];
ExplodeString(sSettings, ",", sPieces, 2, 8);
g_iFTimebombTicks = StringToInt(sPieces[0]);
g_fFTimebombRadius = StringToFloat(sPieces[1]);
}

89
scripting/rtd/firework.sp Normal file
View File

@@ -0,0 +1,89 @@
/*
This script is a part of RTD2 plugin and is not meant to work by itself.
If you were to edit anything here, you'd have to recompile rtd2.sp instead of this one.
*** HOW TO ADD A PERK ***
A quick note: This tutorial may not be kept up to date; for an updated one, go to the plugin's thread.
1. Set up:
a) Have <perkname>.sp in scripting/rtd.
b) Add it to the includes in scripting/rtd/#perks.sp.
c) Add a new section with a correct ID (highest one +1) to the config/rtd2_perks.cfg and set its settings.
2. Edit scripting/rtd/#manager.sp
a) In a function named ManagePerk() add a new case to the switch() with your perk's ID.
b) In the added case specify a function which is going to execute from <perkname>.sp with parameters:
1) @client - the client the perk should be applied to/removed from
2) @fSpecialPref - the optional "special" value in config/rtd2_perks.cfg
2) @enable - to specify whether the perk should be applied/removed
c) OPTIONAL: You can specify a function in your perk which should run at OnMapStart() in the Forward_OnMapStart() function.
You will need it if you'd want to, for example, precache a sound or loop through existing clients.
d) OPTIONAL: You can specify a function in your perk which should run at OnPlayerRunCmd() in the Forward_OnPlayerRunCmd() function.
You can use it if you'd need something to run each frame or on a certain button press.
NOTE: The forwarded client is guaranteed to be valid BUT NOT GUARANTEED IF THEY ARE ALIVE.
3. Script your perk:
a) Create a public function in <perkname>.sp with parameters @client, @iPref, @bool:apply as an example below
- This is the only function used to transfer info between the core and the include
- You don't need to include any includes that are in the rtd2.sp
b) NOTE: If you need to transfer the iPref to a different function, set it globally but remember to use an unique name
c) Name it AS SAME AS you named the function in the added case in the switch() in #manager.sp
d) From there, script the functionality like there's no tomorrow
e) You are free to use IsValidClient(). It returns false when:
- An incorrect client index is specified
- Client is not in game
- Client is fake (bot)
- Client is Coaching
4. Compile rtd2.sp and you're good to go!
*/
#define FIREWORK_EXPLOSION "weapons/flare_detonator_explode.wav"
#define FIREWORK_PARTICLE "burningplayer_rainbow_flame"
int g_iFireworkParticle[MAXPLAYERS+1] = {-1, ...};
void Firework_Start(){
PrecacheSound(FIREWORK_EXPLOSION);
}
void Firework_Perk(int client, const char[] sPref, bool apply){
if(!apply)
if(g_iFireworkParticle[client] > MaxClients && IsValidEntity(g_iFireworkParticle[client])){
AcceptEntityInput(g_iFireworkParticle[client], "Kill");
g_iFireworkParticle[client] = -1;
}
float fPush[3];
fPush[2] = StringToFloat(sPref);
TeleportEntity(client, NULL_VECTOR, NULL_VECTOR, fPush);
if(g_iFireworkParticle[client] < 0)
g_iFireworkParticle[client] = CreateParticle(client, FIREWORK_PARTICLE);
CreateTimer(0.5, Timer_Firework_Explode, GetClientSerial(client));
}
public Action Timer_Firework_Explode(Handle hTimer, int iSerial){
int client = GetClientFromSerial(iSerial);
EmitSoundToAll(FIREWORK_EXPLOSION, client);
int iParticle = g_iFireworkParticle[client];
if(iParticle > MaxClients && IsValidEntity(iParticle))
AcceptEntityInput(iParticle, "Kill");
g_iFireworkParticle[client] = -1;
FakeClientCommandEx(client, "explode");
return Plugin_Stop;
}

View File

@@ -0,0 +1,138 @@
/*
This script is a part of RTD2 plugin and is not meant to work by itself.
If you were to edit anything here, you'd have to recompile rtd2.sp instead of this one.
*** HOW TO ADD A PERK ***
A quick note: This tutorial may not be kept up to date; for an updated one, go to the plugin's thread.
1. Set up:
a) Have <perkname>.sp in scripting/rtd.
b) Add it to the includes in scripting/rtd/#perks.sp.
c) Add a new section with a correct ID (highest one +1) to the config/rtd2_perks.cfg and set its settings.
2. Edit scripting/rtd/#manager.sp
a) In a function named ManagePerk() add a new case to the switch() with your perk's ID.
b) In the added case specify a function which is going to execute from <perkname>.sp with parameters:
1) @client - the client the perk should be applied to/removed from
2) @fSpecialPref - the optional "special" value in config/rtd2_perks.cfg
2) @enable - to specify whether the perk should be applied/removed
c) OPTIONAL: You can specify a function in your perk which should run at OnMapStart() in the Forward_OnMapStart() function.
You will need it if you'd want to, for example, precache a sound or loop through existing clients.
d) OPTIONAL: You can specify a function in your perk which should run at OnPlayerRunCmd() in the Forward_OnPlayerRunCmd() function.
You can use it if you'd need something to run each frame or on a certain button press.
NOTE: The forwarded client is guaranteed to be valid BUT NOT GUARANTEED IF THEY ARE ALIVE.
3. Script your perk:
a) Create a public function in <perkname>.sp with parameters @client, @iPref, @bool:apply as an example below
- This is the only function used to transfer info between the core and the include
- You don't need to include any includes that are in the rtd2.sp
b) NOTE: If you need to transfer the iPref to a different function, set it globally but remember to use an unique name
c) Name it AS SAME AS you named the function in the added case in the switch() in #manager.sp
d) From there, script the functionality like there's no tomorrow
e) You are free to use IsValidClient(). It returns false when:
- An incorrect client index is specified
- Client is not in game
- Client is fake (bot)
- Client is Coaching
4. Compile rtd2.sp and you're good to go!
*/
bool g_bIsForcedTaunt[MAXPLAYERS+1] = {false, ...};
float g_fTauntInterval = 1.0;
bool g_bShouldTaunt[MAXPLAYERS+1] = {false, ...};
char g_sSoundScoutBB[][] = {
"items/scout_boombox_02.wav",
"items/scout_boombox_03.wav",
"items/scout_boombox_04.wav",
"items/scout_boombox_05.wav"
};
void ForcedTaunt_Start(){
for(int i = 0; i < sizeof(g_sSoundScoutBB); i++){
PrecacheSound(g_sSoundScoutBB[i]);
}
}
void ForcedTaunt_Perk(int client, const char[] sPref, bool apply){
if(apply)
ForcedTaunt_ApplyPerk(client, StringToFloat(sPref));
else
g_bIsForcedTaunt[client] = false;
}
void ForcedTaunt_ApplyPerk(int client, float fInterval){
g_fTauntInterval = fInterval;
ForceTaunt_PerformTaunt(client);
g_bIsForcedTaunt[client] = true;
}
public Action Timer_ForceTaunt(Handle hTimer, int iSerial){
int client = GetClientFromSerial(iSerial);
if(!IsValidClient(client)) return Plugin_Stop;
if(!g_bIsForcedTaunt[client]) return Plugin_Stop;
ForceTaunt_PerformTaunt(client);
return Plugin_Stop;
}
void ForceTaunt_PerformTaunt(int client){
if(GetEntProp(client, Prop_Send, "m_hGroundEntity") > -1){
FakeClientCommand(client, "taunt");
return;
}
g_bShouldTaunt[client] = true;
CreateTimer(0.1, Timer_RetryForceTaunt, GetClientSerial(client), TIMER_REPEAT);
}
public Action Timer_RetryForceTaunt(Handle hTimer, int iSerial){
int client = GetClientFromSerial(iSerial);
if(!IsValidClient(client)) return Plugin_Stop;
if(!g_bIsForcedTaunt[client]) return Plugin_Stop;
if(!g_bShouldTaunt[client]) return Plugin_Stop;
if(GetEntProp(client, Prop_Send, "m_hGroundEntity") < 0)
return Plugin_Continue;
g_bShouldTaunt[client] = false;
FakeClientCommand(client, "taunt");
return Plugin_Stop;
}
void ForcedTaunt_OnConditionAdded(int client, TFCond condition){
if(g_bIsForcedTaunt[client] && condition == TFCond_Taunting)
EmitSoundToAll(g_sSoundScoutBB[GetRandomInt(0, sizeof(g_sSoundScoutBB)-1)], client);
}
void ForcedTaunt_OnConditionRemoved(int client, TFCond condition){
if(g_bIsForcedTaunt[client] && condition == TFCond_Taunting)
CreateTimer(g_fTauntInterval, Timer_ForceTaunt, GetClientSerial(client));
}

189
scripting/rtd/frozen.sp Normal file
View File

@@ -0,0 +1,189 @@
/*
This script is a part of RTD2 plugin and is not meant to work by itself.
If you were to edit anything here, you'd have to recompile rtd2.sp instead of this one.
*** HOW TO ADD A PERK ***
A quick note: This tutorial may not be kept up to date; for an updated one, go to the plugin's thread.
1. Set up:
a) Have <perkname>.sp in scripting/rtd.
b) Add it to the includes in scripting/rtd/#perks.sp.
c) Add a new section with a correct ID (highest one +1) to the config/rtd2_perks.cfg and set its settings.
2. Edit scripting/rtd/#manager.sp
a) In a function named ManagePerk() add a new case to the switch() with your perk's ID.
b) In the added case specify a function which is going to execute from <perkname>.sp with parameters:
1) @client - the client the perk should be applied to/removed from
2) @fSpecialPref - the optional "special" value in config/rtd2_perks.cfg
2) @enable - to specify whether the perk should be applied/removed
c) OPTIONAL: You can specify a function in your perk which should run at OnMapStart() in the Forward_OnMapStart() function.
You will need it if you'd want to, for example, precache a sound or loop through existing clients.
d) OPTIONAL: You can specify a function in your perk which should run at OnPlayerRunCmd() in the Forward_OnPlayerRunCmd() function.
You can use it if you'd need something to run each frame or on a certain button press.
NOTE: The forwarded client is guaranteed to be valid BUT NOT GUARANTEED IF THEY ARE ALIVE.
3. Script your perk:
a) Create a public function in <perkname>.sp with parameters @client, @iPref, @bool:apply as an example below
- This is the only function used to transfer info between the core and the include
- You don't need to include any includes that are in the rtd2.sp
b) NOTE: If you need to transfer the iPref to a different function, set it globally but remember to use an unique name
c) Name it AS SAME AS you named the function in the added case in the switch() in #manager.sp
d) From there, script the functionality like there's no tomorrow
e) You are free to use IsValidClient(). It returns false when:
- An incorrect client index is specified
- Client is not in game
- Client is fake (bot)
- Client is Coaching
4. Compile rtd2.sp and you're good to go!
*/
int g_iIceStatue[MAXPLAYERS+1] = {0, ...};
int g_iBaseFrozen[MAXPLAYERS+1] = {255, ...};
public void Frozen_Perk(int client, const char[] sPref, bool apply){
if(apply)
Frozen_ApplyPerk(client);
else
Frozen_RemovePerk(client);
}
void Frozen_ApplyPerk(int client){
g_iBaseFrozen[client] = Frozen_GetEntityAlpha(client);
Frozen_Set(client, 0);
Frozen_DisarmWeapons(client, true);
if(g_iIceStatue[client] < 1){
g_iIceStatue[client] = CreateDummy(client);
if(g_iIceStatue[client] > MaxClients && IsValidEntity(g_iIceStatue[client]))
SetClientViewEntity(client, g_iIceStatue[client]);
}
SetEntityMoveType(client, MOVETYPE_NONE);
SetVariantInt(1);
AcceptEntityInput(client, "SetForcedTauntCam");
}
void Frozen_RemovePerk(int client){
SetClientViewEntity(client, client);
if(g_iIceStatue[client] > MaxClients && IsValidEntity(g_iIceStatue[client]))
AcceptEntityInput(g_iIceStatue[client], "Kill");
g_iIceStatue[client] = 0;
Frozen_Set(client, g_iBaseFrozen[client]);
Frozen_DisarmWeapons(client, false);
SetEntityMoveType(client, MOVETYPE_WALK);
SetVariantInt(0);
AcceptEntityInput(client, "SetForcedTauntCam");
}
int CreateDummy(client){
int iRag = CreateEntityByName("tf_ragdoll");
if(iRag < 1 || iRag <= MaxClients || !IsValidEntity(iRag))
return 0;
float fPos[3], fAng[3], fVel[3];
GetClientAbsOrigin(client, fPos);
GetClientAbsAngles(client, fAng);
GetEntPropVector(client, Prop_Data, "m_vecVelocity", fVel);
TeleportEntity(iRag, fPos, fAng, fVel);
SetEntProp(iRag, Prop_Send, "m_iPlayerIndex", client);
SetEntProp(iRag, Prop_Send, "m_bIceRagdoll", 1);
SetEntProp(iRag, Prop_Send, "m_iTeam", GetClientTeam(client));
SetEntProp(iRag, Prop_Send, "m_iClass", _:TF2_GetPlayerClass(client));
SetEntProp(iRag, Prop_Send, "m_bOnGround", 1);
//Scale fix by either SHADoW NiNE TR3S or ddhoward (dunno who was first :p)
//https://forums.alliedmods.net/showpost.php?p=2383502&postcount=1491
//https://forums.alliedmods.net/showpost.php?p=2366104&postcount=1487
SetEntPropFloat(iRag, Prop_Send, "m_flHeadScale", GetEntPropFloat(client, Prop_Send, "m_flHeadScale"));
SetEntPropFloat(iRag, Prop_Send, "m_flTorsoScale", GetEntPropFloat(client, Prop_Send, "m_flTorsoScale"));
SetEntPropFloat(iRag, Prop_Send, "m_flHandScale", GetEntPropFloat(client, Prop_Send, "m_flHandScale"));
SetEntityMoveType(iRag, MOVETYPE_NONE);
DispatchSpawn(iRag);
ActivateEntity(iRag);
return iRag;
}
void Frozen_Set(int client, int iValue){
if(GetEntityRenderMode(client) == RENDER_NORMAL)
SetEntityRenderMode(client, RENDER_TRANSCOLOR);
Frozen_SetEntityAlpha(client, iValue);
int iWeapon = 0;
for(int i = 0; i < 5; i++){
iWeapon = GetPlayerWeaponSlot(client, i);
if(iWeapon <= MaxClients || !IsValidEntity(iWeapon))
continue;
if(GetEntityRenderMode(iWeapon) == RENDER_NORMAL)
SetEntityRenderMode(iWeapon, RENDER_TRANSCOLOR);
Frozen_SetEntityAlpha(iWeapon, iValue);
}
char sClass[24];
for(int i = MaxClients+1; i < GetMaxEntities(); i++){
if(!IsCorrectWearable(client, i, sClass, sizeof(sClass))) continue;
if(GetEntityRenderMode(i) == RENDER_NORMAL)
SetEntityRenderMode(i, RENDER_TRANSCOLOR);
Frozen_SetEntityAlpha(i, iValue);
}
}
stock int Frozen_GetEntityAlpha(int entity){
return GetEntData(entity, GetEntSendPropOffs(entity, "m_clrRender") + 3, 1);
}
stock void Frozen_SetEntityAlpha(int entity, int value){
SetEntData(entity, GetEntSendPropOffs(entity, "m_clrRender") + 3, value, 1, true);
}
void Frozen_DisarmWeapons(int client, bool bDisarm){
int iWeapon = 0;
for(int i = 0; i < 3; i++){
iWeapon = GetPlayerWeaponSlot(client, i);
if(iWeapon <= MaxClients || !IsValidEntity(iWeapon))
continue;
SetEntPropFloat(iWeapon, Prop_Data, "m_flNextPrimaryAttack", bDisarm ? GetGameTime() + 86400.0 : 0.1);
SetEntPropFloat(iWeapon, Prop_Data, "m_flNextSecondaryAttack", bDisarm ? GetGameTime() + 86400.0 : 0.1);
}
}

View File

@@ -0,0 +1,115 @@
/*
This script is a part of RTD2 plugin and is not meant to work by itself.
If you were to edit anything here, you'd have to recompile rtd2.sp instead of this one.
*** HOW TO ADD A PERK ***
A quick note: This tutorial may not be kept up to date; for an updated one, go to the plugin's thread.
1. Set up:
a) Have <perkname>.sp in scripting/rtd.
b) Add it to the includes in scripting/rtd/#perks.sp.
c) Add a new section with a correct ID (highest one +1) to the config/rtd2_perks.cfg and set its settings.
2. Edit scripting/rtd/#manager.sp
a) In a function named ManagePerk() add a new case to the switch() with your perk's ID.
b) In the added case specify a function which is going to execute from <perkname>.sp with parameters:
1) @client - the client the perk should be applied to/removed from
2) @fSpecialPref - the optional "special" value in config/rtd2_perks.cfg
2) @enable - to specify whether the perk should be applied/removed
c) OPTIONAL: You can specify a function in your perk which should run at OnMapStart() in the Forward_OnMapStart() function.
You will need it if you'd want to, for example, precache a sound or loop through existing clients.
d) OPTIONAL: You can specify a function in your perk which should run at OnPlayerRunCmd() in the Forward_OnPlayerRunCmd() function.
You can use it if you'd need something to run each frame or on a certain button press.
NOTE: The forwarded client is guaranteed to be valid BUT NOT GUARANTEED IF THEY ARE ALIVE.
3. Script your perk:
a) Create a public function in <perkname>.sp with parameters @client, @iPref, @bool:apply as an example below
- This is the only function used to transfer info between the core and the include
- You don't need to include any includes that are in the rtd2.sp
b) NOTE: If you need to transfer the iPref to a different function, set it globally but remember to use an unique name
c) Name it AS SAME AS you named the function in the added case in the switch() in #manager.sp
d) From there, script the functionality like there's no tomorrow
e) You are free to use IsValidClient(). It returns false when:
- An incorrect client index is specified
- Client is not in game
- Client is fake (bot)
- Client is Coaching
4. Compile rtd2.sp and you're good to go!
*/
int g_iSniperPrimary[MAXPLAYERS+1] = {0, ...};
bool g_bHasFullCharge[MAXPLAYERS+1] = {false, ...};
bool g_bHasBow[MAXPLAYERS+1] = {false, ...};
void FullRifleCharge_Start(){
HookEvent("post_inventory_application", Event_FullRifleCharge_Resupply, EventHookMode_Post);
}
public void FullRifleCharge_Perk(int client, const char[] sPref, bool apply){
if(apply)
FullRifleCharge_ApplyPerk(client);
else
g_bHasFullCharge[client] = false;
}
void FullRifleCharge_ApplyPerk(int client){
FullRifleCharge_SetSniperPrimary(client);
g_bHasFullCharge[client] = true;
}
void FullRifleCharge_SetSniperPrimary(int client){
int iWeapon = GetPlayerWeaponSlot(client, 0);
if(iWeapon > MaxClients && IsValidEntity(iWeapon)){
char sClass[32];GetEdictClassname(iWeapon, sClass, sizeof(sClass));
if(StrContains(sClass, "tf_weapon_sniperrifle") > -1){
g_iSniperPrimary[client] = iWeapon;
g_bHasBow[client] = false;
}else if(StrContains(sClass, "tf_weapon_compound_bow") > -1){
g_iSniperPrimary[client] = iWeapon;
g_bHasBow[client] = true;
}
}
}
void FullRifleCharge_OnConditionAdded(int client, TFCond condition){
if(!IsValidClient(client)) return;
if(!g_bHasFullCharge[client]) return;
if(condition != TFCond_Slowed) return;
if(g_iSniperPrimary[client] > MaxClients && IsValidEntity(g_iSniperPrimary[client]))
SetEntPropFloat(
g_iSniperPrimary[client], Prop_Send,
g_bHasBow[client] ? "m_flChargeBeginTime" : "m_flChargedDamage",
g_bHasBow[client] ? GetGameTime()-1.0 : 150.0
);
}
public void Event_FullRifleCharge_Resupply(Handle hEvent, const char[] sEventName, bool bDontBroadcast){
int client = GetClientOfUserId(GetEventInt(hEvent, "userid"));
if(!IsValidClient(client)) return;
if(!g_bHasFullCharge[client]) return;
FullRifleCharge_SetSniperPrimary(client);
}

View File

@@ -0,0 +1,139 @@
/*
This script is a part of RTD2 plugin and is not meant to work by itself.
If you were to edit anything here, you'd have to recompile rtd2.sp instead of this one.
*** HOW TO ADD A PERK ***
A quick note: This tutorial may not be kept up to date; for an updated one, go to the plugin's thread.
1. Set up:
a) Have <perkname>.sp in scripting/rtd.
b) Add it to the includes in scripting/rtd/#perks.sp.
c) Add a new section with a correct ID (highest one +1) to the config/rtd2_perks.cfg and set its settings.
2. Edit scripting/rtd/#manager.sp
a) In a function named ManagePerk() add a new case to the switch() with your perk's ID.
b) In the added case specify a function which is going to execute from <perkname>.sp with parameters:
1) @client - the client the perk should be applied to/removed from
2) @fSpecialPref - the optional "special" value in config/rtd2_perks.cfg
2) @enable - to specify whether the perk should be applied/removed
c) OPTIONAL: You can specify a function in your perk which should run at OnMapStart() in the Forward_OnMapStart() function.
You will need it if you'd want to, for example, precache a sound or loop through existing clients.
d) OPTIONAL: You can specify a function in your perk which should run at OnPlayerRunCmd() in the Forward_OnPlayerRunCmd() function.
You can use it if you'd need something to run each frame or on a certain button press.
NOTE: The forwarded client is guaranteed to be valid BUT NOT GUARANTEED IF THEY ARE ALIVE.
3. Script your perk:
a) Create a public function in <perkname>.sp with parameters @client, @iPref, @bool:apply as an example below
- This is the only function used to transfer info between the core and the include
- You don't need to include any includes that are in the rtd2.sp
b) NOTE: If you need to transfer the iPref to a different function, set it globally but remember to use an unique name
c) Name it AS SAME AS you named the function in the added case in the switch() in #manager.sp
d) From there, script the functionality like there's no tomorrow
e) You are free to use IsValidClient(). It returns false when:
- An incorrect client index is specified
- Client is not in game
- Client is fake (bot)
- Client is Coaching
4. Compile rtd2.sp and you're good to go!
*/
int g_iMediGunCond[MAXPLAYERS+1] = {-1, ...};
int g_iMediGun[MAXPLAYERS+1] = {0, ...};
bool g_bRefreshUber[MAXPLAYERS+1] = {false, ...};
bool g_bUberComplete[MAXPLAYERS+1] = {true, ...};
public void FullUbercharge_Perk(int client, const char[] sPref, bool apply){
if(apply)
FullUbercharge_ApplyPerk(client);
else
FullUbercharge_RemovePerk(client);
}
void FullUbercharge_ApplyPerk(int client){
int iWeapon = GetPlayerWeaponSlot(client, 1);
if(iWeapon > MaxClients && IsValidEntity(iWeapon)){
char sClass[20];GetEdictClassname(iWeapon, sClass, sizeof(sClass));
if(strcmp(sClass, "tf_weapon_medigun") == 0){
g_iMediGun[client] = iWeapon;
g_bRefreshUber[client] = true;
g_bUberComplete[client] = false;
CreateTimer(0.2, Timer_RefreshUber, GetClientSerial(client), TIMER_REPEAT);
int iWeapIndex = GetEntProp(iWeapon, Prop_Send, "m_iItemDefinitionIndex");
switch(iWeapIndex){
case 35: g_iMediGunCond[client] = view_as<int>(TFCond_Kritzkrieged); //Kritzkrieg
case 411: g_iMediGunCond[client] = view_as<int>(TFCond_MegaHeal); //Quick-Fix
case 998: g_iMediGunCond[client] = -1; //Screw you, Vaccinator
default: g_iMediGunCond[client] = view_as<int>(TFCond_Ubercharged); //Default
}
}
}
}
void FullUbercharge_RemovePerk(int client){
g_bRefreshUber[client] = false;
if(g_iMediGunCond[client] > -1)
CreateTimer(0.2, Timer_UberchargeEnd, GetClientSerial(client), TIMER_REPEAT);
}
public Action Timer_RefreshUber(Handle hTimer, int iSerial){
int client = GetClientFromSerial(iSerial);
if(!IsValidClient(client))
return Plugin_Stop;
if(!g_bRefreshUber[client])
return Plugin_Stop;
SetEntPropFloat(g_iMediGun[client], Prop_Send, "m_flChargeLevel", 1.0);
return Plugin_Continue;
}
public Action Timer_UberchargeEnd(Handle hTimer, int iSerial){
int client = GetClientFromSerial(iSerial);
if(!IsValidClient(client))
return Plugin_Stop;
if(GetEntPropFloat(g_iMediGun[client], Prop_Send, "m_flChargeLevel") > 0.05)
return Plugin_Continue;
g_bUberComplete[client] = true;
return Plugin_Stop;
}
void FullUbercharge_OnConditionRemoved(int client, TFCond cond){
if(g_bUberComplete[client])
return;
if(view_as<int>(cond) != g_iMediGunCond[client])
return;
if(GetEntPropEnt(client, Prop_Send, "m_hActiveWeapon") == g_iMediGun[client])
TF2_AddCondition(client, cond, 2.0);
}

View File

@@ -0,0 +1,84 @@
/*
This script is a part of RTD2 plugin and is not meant to work by itself.
If you were to edit anything here, you'd have to recompile rtd2.sp instead of this one.
*** HOW TO ADD A PERK ***
A quick note: This tutorial may not be kept up to date; for an updated one, go to the plugin's thread.
1. Set up:
a) Have <perkname>.sp in scripting/rtd.
b) Add it to the includes in scripting/rtd/#perks.sp.
c) Add a new section with a correct ID (highest one +1) to the config/rtd2_perks.cfg and set its settings.
2. Edit scripting/rtd/#manager.sp
a) In a function named ManagePerk() add a new case to the switch() with your perk's ID.
b) In the added case specify a function which is going to execute from <perkname>.sp with parameters:
1) @client - the client the perk should be applied to/removed from
2) @fSpecialPref - the optional "special" value in config/rtd2_perks.cfg
2) @enable - to specify whether the perk should be applied/removed
c) OPTIONAL: You can specify a function in your perk which should run at OnMapStart() in the Forward_OnMapStart() function.
You will need it if you'd want to, for example, precache a sound or loop through existing clients.
d) OPTIONAL: You can specify a function in your perk which should run at OnPlayerRunCmd() in the Forward_OnPlayerRunCmd() function.
You can use it if you'd need something to run each frame or on a certain button press.
NOTE: The forwarded client is guaranteed to be valid BUT NOT GUARANTEED IF THEY ARE ALIVE.
3. Script your perk:
a) Create a public function in <perkname>.sp with parameters @client, @iPref, @bool:apply as an example below
- This is the only function used to transfer info between the core and the include
- You don't need to include any includes that are in the rtd2.sp
b) NOTE: If you need to transfer the iPref to a different function, set it globally but remember to use an unique name
c) Name it AS SAME AS you named the function in the added case in the switch() in #manager.sp
d) From there, script the functionality like there's no tomorrow
e) You are free to use IsValidClient(). It returns false when:
- An incorrect client index is specified
- Client is not in game
- Client is fake (bot)
- Client is Coaching
4. Compile rtd2.sp and you're good to go!
*/
int g_iBaseFunnyFov[MAXPLAYERS+1] = {75, ...};
bool g_bHasFunnyFeeling[MAXPLAYERS+1] = {false, ...};
int g_iDesiredFunnyFov = 160;
void FunnyFeeling_Perk(int client, const char[] sPref, bool apply){
if(apply)
FunnyFeeling_ApplyPerk(client, StringToInt(sPref));
else
FunnyFeeling_RemovePerk(client);
}
void FunnyFeeling_ApplyPerk(int client, int iValue){
g_iDesiredFunnyFov = iValue;
g_iBaseFunnyFov[client] = GetEntProp(client, Prop_Send, "m_iFOV");
SetEntProp(client, Prop_Send, "m_iFOV", g_iDesiredFunnyFov);
g_bHasFunnyFeeling[client] = true;
}
void FunnyFeeling_RemovePerk(int client){
SetEntProp(client, Prop_Send, "m_iFOV", g_iBaseFunnyFov[client]);
g_bHasFunnyFeeling[client] = false;
}
void FunnyFeeling_OnConditionRemoved(int client, TFCond condition){
if(!IsValidClient(client)) return;
if(!g_bHasFunnyFeeling[client]) return;
if(condition != TFCond_Zoomed) return;
SetEntProp(client, Prop_Send, "m_iFOV", g_iDesiredFunnyFov);
}

98
scripting/rtd/godmode.sp Normal file
View File

@@ -0,0 +1,98 @@
/*
This script is a part of RTD2 plugin and is not meant to work by itself.
If you were to edit anything here, you'd have to recompile rtd2.sp instead of this one.
*** HOW TO ADD A PERK ***
A quick note: This tutorial may not be kept up to date; for an updated one, go to the plugin's thread.
1. Set up:
a) Have <perkname>.sp in scripting/rtd.
b) Add it to the includes in scripting/rtd/#perks.sp.
c) Add a new section with a correct ID (highest one +1) to the config/rtd2_perks.cfg and set its settings.
2. Edit scripting/rtd/#manager.sp
a) In a function named ManagePerk() add a new case to the switch() with your perk's ID.
b) In the added case specify a function which is going to execute from <perkname>.sp with parameters:
1) @client - the client the perk should be applied to/removed from
2) @fSpecialPref - the optional "special" value in config/rtd2_perks.cfg
2) @enable - to specify whether the perk should be applied/removed
c) OPTIONAL: You can specify a function in your perk which should run at OnMapStart() in the Forward_OnMapStart() function.
You will need it if you'd want to, for example, precache a sound or loop through existing clients.
d) OPTIONAL: You can specify a function in your perk which should run at OnPlayerRunCmd() in the Forward_OnPlayerRunCmd() function.
You can use it if you'd need something to run each frame or on a certain button press.
NOTE: The forwarded client is guaranteed to be valid BUT NOT GUARANTEED IF THEY ARE ALIVE.
3. Script your perk:
a) Create a public function in <perkname>.sp with parameters @client, @iPref, @bool:apply as an example below
- This is the only function used to transfer info between the core and the include
- You don't need to include any includes that are in the rtd2.sp
b) NOTE: If you need to transfer the iPref to a different function, set it globally but remember to use an unique name
c) Name it AS SAME AS you named the function in the added case in the switch() in #manager.sp
d) From there, script the functionality like there's no tomorrow
e) You are free to use IsValidClient(). It returns false when:
- An incorrect client index is specified
- Client is not in game
- Client is fake (bot)
- Client is Coaching
4. Compile rtd2.sp and you're good to go!
*/
#define GODMODE_PARTICLE "powerup_supernova_ready"
int g_iGodmodeParticle[MAXPLAYERS+1] = {0, ...};
int g_iPref_Godmode = 0;
void Godmode_Perk(int client, const char[] sPref, bool apply){
if(apply)
Godmode_ApplyPerk(client, StringToInt(sPref));
else
Godmode_RemovePerk(client);
}
void Godmode_ApplyPerk(int client, int iValue){
float fParticleOffset[3] = {0.0, 0.0, 12.0};
g_iGodmodeParticle[client] = CreateParticle(client, GODMODE_PARTICLE, _, _, fParticleOffset);
g_iPref_Godmode = iValue;
SDKHook(client, SDKHook_OnTakeDamage, Godmode_OnTakeDamage);
}
void Godmode_RemovePerk(int client){
if(g_iGodmodeParticle[client] > MaxClients && IsValidEntity(g_iGodmodeParticle[client])){
AcceptEntityInput(g_iGodmodeParticle[client], "Kill");
g_iGodmodeParticle[client] = 0;
}
SDKUnhook(client, SDKHook_OnTakeDamage, Godmode_OnTakeDamage);
}
public Action Godmode_OnTakeDamage(int iVic, int &iAttacker){//, int &iInflictor, float &fDamage, int &iDamageType, int &weapon, float damageForce[3], float damagePosition[3]){
if(iVic != iAttacker)
return Plugin_Handled;
if(g_iPref_Godmode > 0)
return Plugin_Continue;
if(g_iPref_Godmode > -1)
TF2_AddCondition(iVic, TFCond_Bonked, 0.001);
else
return Plugin_Handled;
return Plugin_Continue;
}

View File

@@ -0,0 +1,292 @@
/*
This script is a part of RTD2 plugin and is not meant to work by itself.
If you were to edit anything here, you'd have to recompile rtd2.sp instead of this one.
*** HOW TO ADD A PERK ***
A quick note: This tutorial may not be kept up to date; for an updated one, go to the plugin's thread.
1. Set up:
a) Have <perkname>.sp in scripting/rtd.
b) Add it to the includes in scripting/rtd/#perks.sp.
c) Add a new section with a correct ID (highest one +1) to the config/rtd2_perks.cfg and set its settings.
2. Edit scripting/rtd/#manager.sp
a) In a function named ManagePerk() add a new case to the switch() with your perk's ID.
b) In the added case specify a function which is going to execute from <perkname>.sp with parameters:
1) @client - the client the perk should be applied to/removed from
2) @fSpecialPref - the optional "special" value in config/rtd2_perks.cfg
2) @enable - to specify whether the perk should be applied/removed
c) OPTIONAL: You can specify a function in your perk which should run at OnMapStart() in the Forward_OnMapStart() function.
You will need it if you'd want to, for example, precache a sound or loop through existing clients.
d) OPTIONAL: You can specify a function in your perk which should run at OnPlayerRunCmd() in the Forward_OnPlayerRunCmd() function.
You can use it if you'd need something to run each frame or on a certain button press.
NOTE: The forwarded client is guaranteed to be valid BUT NOT GUARANTEED IF THEY ARE ALIVE.
3. Script your perk:
a) Create a public function in <perkname>.sp with parameters @client, @iPref, @bool:apply as an example below
- This is the only function used to transfer info between the core and the include
- You don't need to include any includes that are in the rtd2.sp
b) NOTE: If you need to transfer the iPref to a different function, set it globally but remember to use an unique name
c) Name it AS SAME AS you named the function in the added case in the switch() in #manager.sp
d) From there, script the functionality like there's no tomorrow
e) You are free to use IsValidClient(). It returns false when:
- An incorrect client index is specified
- Client is not in game
- Client is fake (bot)
- Client is Coaching
4. Compile rtd2.sp and you're good to go!
*/
#define HOMING_SPEED 0.5
#define HOMING_REFLE 1.1
#define MINICRIT TFCond_Buffed
#define FULLCRIT TFCond_CritOnFirstBlood
bool g_bHasHomingProjectiles[MAXPLAYERS+1] = {false, ...};
Handle g_hArrayHoming;
int g_iHomingCrits = 0;
void HomingProjectiles_Start(){
g_hArrayHoming = CreateArray(2);
ClearArray(g_hArrayHoming);
HookEvent("teamplay_round_start", Event_HomingProjectiles_RoundStart);
}
void HomingProjectiles_Perk(int client, const char[] sPref, bool apply){
if(apply)
HomingProjectiles_ApplyPerk(client, StringToInt(sPref));
else
HomingProjectiles_RemovePerk(client);
}
void HomingProjectiles_ApplyPerk(int client, int iPref){
g_bHasHomingProjectiles[client] = true;
g_iHomingCrits = iPref;
if(g_iHomingCrits > 0)
TF2_AddCondition(client, g_iHomingCrits < 2 ? MINICRIT : FULLCRIT);
}
void HomingProjectiles_RemovePerk(int client){
g_bHasHomingProjectiles[client] = false;
if(g_iHomingCrits > 0)
TF2_RemoveCondition(client, g_iHomingCrits < 2 ? MINICRIT : FULLCRIT);
}
public Event_HomingProjectiles_RoundStart(Handle hEvent, const char[] strEventName, bool bDontBroadcast){
ClearArray(g_hArrayHoming);
}
//Just copy every bit of code from the original RTD!
void HomingProjectiles_OnEntityCreated(int iEnt, const char[] sClassname){
if(!IsAcceptableForHoming(sClassname))
return;
if(!IsHomingPerkPresent())
return;
CreateTimer(0.2, Timer_HomingProjectiles_CheckOwnership, EntIndexToEntRef(iEnt));
}
public Action Timer_HomingProjectiles_CheckOwnership(Handle hTimer, any iRef){
int iProjectile = EntRefToEntIndex(iRef);
if(iProjectile <= MaxClients || !IsValidEntity(iProjectile))
return Plugin_Handled;
int iLauncher = GetEntPropEnt(iProjectile, Prop_Send, "m_hOwnerEntity");
if(iLauncher < 1 || !IsValidClient(iLauncher) || !IsPlayerAlive(iLauncher))
return Plugin_Handled;
if(!g_bHasHomingProjectiles[iLauncher])
return Plugin_Handled;
if(GetEntProp(iProjectile, Prop_Send, "m_nForceBone") != 0)
return Plugin_Handled;
SetEntProp(iProjectile, Prop_Send, "m_nForceBone", 1);
int iData[2];
iData[0] = EntIndexToEntRef(iProjectile);
PushArrayArray(g_hArrayHoming, iData);
return Plugin_Handled;
}
void HomingProjectiles_OnGameFrame(){
for(int i = GetArraySize(g_hArrayHoming)-1; i >= 0; i--){
int iData[2];
GetArrayArray(g_hArrayHoming, i, iData);
if(iData[0] == 0){
RemoveFromArray(g_hArrayHoming, i);
continue;
}
int iProjectile = EntRefToEntIndex(iData[0]);
if(iProjectile > MaxClients)
HomingProjectile_Think(iProjectile, iData[0], i, iData[1]);
else
RemoveFromArray(g_hArrayHoming, i);
}
}
public void HomingProjectile_Think(int iProjectile, int iRefProjectile, int iArrayIndex, int iCurrentTarget){
int iTeam = GetEntProp(iProjectile, Prop_Send, "m_iTeamNum");
if(!HomingProjectile_IsValidTarget(iCurrentTarget, iProjectile, iTeam))
HomingProjectile_FindTarget(iProjectile, iRefProjectile, iArrayIndex);
else
HomingProjectile_TurnToTarget(iCurrentTarget, iProjectile);
}
bool HomingProjectile_IsValidTarget(int client, int iProjectile, int iTeam){
if(client < 1 || client > MaxClients)return false;
if(!IsClientInGame(client)) return false;
if(!IsPlayerAlive(client)) return false;
if(GetClientTeam(client) == iTeam) return false;
if(TF2_IsPlayerInCondition(client, TFCond_Cloaked))
return false;
if(TF2_IsPlayerInCondition(client, TFCond_Disguised) && GetEntProp(client, Prop_Send, "m_nDisguiseTeam") == iTeam)
return false;
if(IsPlayerFriendly(client))
return false;
return CanEntitySeeTarget(iProjectile, client);
}
void HomingProjectile_FindTarget(int iProjectile, int iRefProjectile, int iArrayIndex){
int iTeam = GetEntProp(iProjectile, Prop_Send, "m_iTeamNum");
float fPos1[3];
GetEntPropVector(iProjectile, Prop_Send, "m_vecOrigin", fPos1);
int iBestTarget;
float fBestLength = 99999.9;
for(int i = 1; i <= MaxClients; i++){
if(HomingProjectile_IsValidTarget(i, iProjectile, iTeam)){
float fPos2[3];
GetClientEyePosition(i, fPos2);
float fDistance = GetVectorDistance(fPos1, fPos2);
if(fDistance < fBestLength)
{
iBestTarget = i;
fBestLength = fDistance;
}
}
}
if(iBestTarget >= 1 && iBestTarget <= MaxClients){
int iData[2];
iData[0] = iRefProjectile;
iData[1] = iBestTarget;
SetArrayArray(g_hArrayHoming, iArrayIndex, iData);
HomingProjectile_TurnToTarget(iBestTarget, iProjectile);
}else{
int iData[2];
iData[0] = iRefProjectile;
iData[1] = 0;
SetArrayArray(g_hArrayHoming, iArrayIndex, iData);
}
}
void HomingProjectile_TurnToTarget(int client, int iProjectile){
float fTargetPos[3], fRocketPos[3], fInitialVelocity[3];
GetClientAbsOrigin(client, fTargetPos);
GetEntPropVector(iProjectile, Prop_Send, "m_vecOrigin", fRocketPos);
GetEntPropVector(iProjectile, Prop_Send, "m_vInitialVelocity", fInitialVelocity);
float fSpeedInit = GetVectorLength(fInitialVelocity);
float fSpeedBase = fSpeedInit *HOMING_SPEED;
fTargetPos[2] += 30 +Pow(GetVectorDistance(fTargetPos, fRocketPos), 2.0) /10000;
float fNewVec[3], fAng[3];
SubtractVectors(fTargetPos, fRocketPos, fNewVec);
NormalizeVector(fNewVec, fNewVec);
GetVectorAngles(fNewVec, fAng);
float fSpeedNew = fSpeedBase +GetEntProp(iProjectile, Prop_Send, "m_iDeflected") *fSpeedBase *HOMING_REFLE;
ScaleVector(fNewVec, fSpeedNew);
TeleportEntity(iProjectile, NULL_VECTOR, fAng, fNewVec);
}
stock bool IsAcceptableForHoming(const char[] sClassname){
if(strcmp(sClassname, "tf_projectile_rocket") == 0
|| strcmp(sClassname, "tf_projectile_arrow") == 0
|| strcmp(sClassname, "tf_projectile_flare") == 0
|| strcmp(sClassname, "tf_projectile_energy_ball") == 0
|| strcmp(sClassname, "tf_projectile_healing_bolt") == 0)
return true;
return false;
}
stock bool IsHomingPerkPresent(){
for(int i = 1; i <= MaxClients; i++){
if(!IsValidClient(i))
continue;
if(!IsPlayerAlive(i))
continue;
if(g_bHasHomingProjectiles[i])
return true;
}
return false;
}

47
scripting/rtd/ignition.sp Normal file
View File

@@ -0,0 +1,47 @@
/*
This script is a part of RTD2 plugin and is not meant to work by itself.
If you were to edit anything here, you'd have to recompile rtd2.sp instead of this one.
*** HOW TO ADD A PERK ***
A quick note: This tutorial may not be kept up to date; for an updated one, go to the plugin's thread.
1. Set up:
a) Have <perkname>.sp in scripting/rtd.
b) Add it to the includes in scripting/rtd/#perks.sp.
c) Add a new section with a correct ID (highest one +1) to the config/rtd2_perks.cfg and set its settings.
2. Edit scripting/rtd/#manager.sp
a) In a function named ManagePerk() add a new case to the switch() with your perk's ID.
b) In the added case specify a function which is going to execute from <perkname>.sp with parameters:
1) @client - the client the perk should be applied to/removed from
2) @fSpecialPref - the optional "special" value in config/rtd2_perks.cfg
2) @enable - to specify whether the perk should be applied/removed
c) OPTIONAL: You can specify a function in your perk which should run at OnMapStart() in the Forward_OnMapStart() function.
You will need it if you'd want to, for example, precache a sound or loop through existing clients.
d) OPTIONAL: You can specify a function in your perk which should run at OnPlayerRunCmd() in the Forward_OnPlayerRunCmd() function.
You can use it if you'd need something to run each frame or on a certain button press.
NOTE: The forwarded client is guaranteed to be valid BUT NOT GUARANTEED IF THEY ARE ALIVE.
3. Script your perk:
a) Create a public function in <perkname>.sp with parameters @client, @iPref, @bool:apply as an example below
- This is the only function used to transfer info between the core and the include
- You don't need to include any includes that are in the rtd2.sp
b) NOTE: If you need to transfer the iPref to a different function, set it globally but remember to use an unique name
c) Name it AS SAME AS you named the function in the added case in the switch() in #manager.sp
d) From there, script the functionality like there's no tomorrow
e) You are free to use IsValidClient(). It returns false when:
- An incorrect client index is specified
- Client is not in game
- Client is fake (bot)
- Client is Coaching
4. Compile rtd2.sp and you're good to go!
*/
public void Ignition_Perk(int client, const char[] sPref, bool apply){
TF2_IgnitePlayer(client, client);
}

View File

@@ -0,0 +1,55 @@
/*
This script is a part of RTD2 plugin and is not meant to work by itself.
If you were to edit anything here, you'd have to recompile rtd2.sp instead of this one.
*** HOW TO ADD A PERK ***
A quick note: This tutorial may not be kept up to date; for an updated one, go to the plugin's thread.
1. Set up:
a) Have <perkname>.sp in scripting/rtd.
b) Add it to the includes in scripting/rtd/#perks.sp.
c) Add a new section with a correct ID (highest one +1) to the config/rtd2_perks.cfg and set its settings.
2. Edit scripting/rtd/#manager.sp
a) In a function named ManagePerk() add a new case to the switch() with your perk's ID.
b) In the added case specify a function which is going to execute from <perkname>.sp with parameters:
1) @client - the client the perk should be applied to/removed from
2) @fSpecialPref - the optional "special" value in config/rtd2_perks.cfg
2) @enable - to specify whether the perk should be applied/removed
c) OPTIONAL: You can specify a function in your perk which should run at OnMapStart() in the Forward_OnMapStart() function.
You will need it if you'd want to, for example, precache a sound or loop through existing clients.
d) OPTIONAL: You can specify a function in your perk which should run at OnPlayerRunCmd() in the Forward_OnPlayerRunCmd() function.
You can use it if you'd need something to run each frame or on a certain button press.
NOTE: The forwarded client is guaranteed to be valid BUT NOT GUARANTEED IF THEY ARE ALIVE.
3. Script your perk:
a) Create a public function in <perkname>.sp with parameters @client, @iPref, @bool:apply as an example below
- This is the only function used to transfer info between the core and the include
- You don't need to include any includes that are in the rtd2.sp
b) NOTE: If you need to transfer the iPref to a different function, set it globally but remember to use an unique name
c) Name it AS SAME AS you named the function in the added case in the switch() in #manager.sp
d) From there, script the functionality like there's no tomorrow
e) You are free to use IsValidClient(). It returns false when:
- An incorrect client index is specified
- Client is not in game
- Client is fake (bot)
- Client is Coaching
4. Compile rtd2.sp and you're good to go!
*/
float g_fDefaultStepSize[MAXPLAYERS+1] = {0.0, ...};
public void InclineProblem_Perk(int client, const char[] sPref, bool apply){
if(apply){
g_fDefaultStepSize[client] = GetEntPropFloat(client, Prop_Send, "m_flStepSize");
SetEntPropFloat(client, Prop_Send, "m_flStepSize", 1.0);
}else
SetEntPropFloat(client, Prop_Send, "m_flStepSize", g_fDefaultStepSize[client]);
}

View File

@@ -0,0 +1,80 @@
/*
This script is a part of RTD2 plugin and is not meant to work by itself.
If you were to edit anything here, you'd have to recompile rtd2.sp instead of this one.
*** HOW TO ADD A PERK ***
A quick note: This tutorial may not be kept up to date; for an updated one, go to the plugin's thread.
1. Set up:
a) Have <perkname>.sp in scripting/rtd.
b) Add it to the includes in scripting/rtd/#perks.sp.
c) Add a new section with a correct ID (highest one +1) to the config/rtd2_perks.cfg and set its settings.
2. Edit scripting/rtd/#manager.sp
a) In a function named ManagePerk() add a new case to the switch() with your perk's ID.
b) In the added case specify a function which is going to execute from <perkname>.sp with parameters:
1) @client - the client the perk should be applied to/removed from
2) @fSpecialPref - the optional "special" value in config/rtd2_perks.cfg
2) @enable - to specify whether the perk should be applied/removed
c) OPTIONAL: You can specify a function in your perk which should run at OnMapStart() in the Forward_OnMapStart() function.
You will need it if you'd want to, for example, precache a sound or loop through existing clients.
d) OPTIONAL: You can specify a function in your perk which should run at OnPlayerRunCmd() in the Forward_OnPlayerRunCmd() function.
You can use it if you'd need something to run each frame or on a certain button press.
NOTE: The forwarded client is guaranteed to be valid BUT NOT GUARANTEED IF THEY ARE ALIVE.
3. Script your perk:
a) Create a public function in <perkname>.sp with parameters @client, @iPref, @bool:apply as an example below
- This is the only function used to transfer info between the core and the include
- You don't need to include any includes that are in the rtd2.sp
b) NOTE: If you need to transfer the iPref to a different function, set it globally but remember to use an unique name
c) Name it AS SAME AS you named the function in the added case in the switch() in #manager.sp
d) From there, script the functionality like there's no tomorrow
e) You are free to use IsValidClient(). It returns false when:
- An incorrect client index is specified
- Client is not in game
- Client is fake (bot)
- Client is Coaching
4. Compile rtd2.sp and you're good to go!
*/
#define ATTRIB_SPEED 107 //the player speed attribute
float g_fBaseSpeed[MAXPLAYERS+1] = {0.0, ...};
void IncreasedSpeed_Perk(int client, const char[] sPref, bool apply){
if(apply)
IncreasedSpeed_ApplyPerk(client, StringToFloat(sPref));
else
IncreasedSpeed_RemovePerk(client);
}
void IncreasedSpeed_ApplyPerk(int client, float fValue){
switch(TF2_GetPlayerClass(client)){
case TFClass_Scout: {g_fBaseSpeed[client] = 400.0;}
case TFClass_Soldier: {g_fBaseSpeed[client] = 240.0;}
case TFClass_DemoMan: {g_fBaseSpeed[client] = 280.0;}
case TFClass_Heavy: {g_fBaseSpeed[client] = 230.0;}
case TFClass_Medic: {g_fBaseSpeed[client] = 320.0;}
default: {g_fBaseSpeed[client] = 300.0;}
}
TF2Attrib_SetByDefIndex(client, ATTRIB_SPEED, fValue);
SetEntPropFloat(client, Prop_Send, "m_flMaxspeed", g_fBaseSpeed[client]*fValue);
}
void IncreasedSpeed_RemovePerk(int client){
TF2Attrib_RemoveByDefIndex(client, ATTRIB_SPEED);
SetEntPropFloat(client, Prop_Send, "m_flMaxspeed", g_fBaseSpeed[client]);
}

View File

@@ -0,0 +1,188 @@
/*
This script is a part of RTD2 plugin and is not meant to work by itself.
If you were to edit anything here, you'd have to recompile rtd2.sp instead of this one.
*** HOW TO ADD A PERK ***
A quick note: This tutorial may not be kept up to date; for an updated one, go to the plugin's thread.
1. Set up:
a) Have <perkname>.sp in scripting/rtd.
b) Add it to the includes in scripting/rtd/#perks.sp.
c) Add a new section with a correct ID (highest one +1) to the config/rtd2_perks.cfg and set its settings.
2. Edit scripting/rtd/#manager.sp
a) In a function named ManagePerk() add a new case to the switch() with your perk's ID.
b) In the added case specify a function which is going to execute from <perkname>.sp with parameters:
1) @client - the client the perk should be applied to/removed from
2) @fSpecialPref - the optional "special" value in config/rtd2_perks.cfg
2) @enable - to specify whether the perk should be applied/removed
c) OPTIONAL: You can specify a function in your perk which should run at OnMapStart() in the Forward_OnMapStart() function.
You will need it if you'd want to, for example, precache a sound or loop through existing clients.
d) OPTIONAL: You can specify a function in your perk which should run at OnPlayerRunCmd() in the Forward_OnPlayerRunCmd() function.
You can use it if you'd need something to run each frame or on a certain button press.
NOTE: The forwarded client is guaranteed to be valid BUT NOT GUARANTEED IF THEY ARE ALIVE.
3. Script your perk:
a) Create a public function in <perkname>.sp with parameters @client, @iPref, @bool:apply as an example below
- This is the only function used to transfer info between the core and the include
- You don't need to include any includes that are in the rtd2.sp
b) NOTE: If you need to transfer the iPref to a different function, set it globally but remember to use an unique name
c) Name it AS SAME AS you named the function in the added case in the switch() in #manager.sp
d) From there, script the functionality like there's no tomorrow
e) You are free to use IsValidClient(). It returns false when:
- An incorrect client index is specified
- Client is not in game
- Client is fake (bot)
- Client is Coaching
4. Compile rtd2.sp and you're good to go!
*/
bool g_bResupplyAmmo[MAXPLAYERS+1] = {false, ...};
bool g_bNoReload = true;
int g_iWeaponCache[MAXPLAYERS+1][3];
int g_iOffsetClip, g_iOffsetAmmo, g_iOffsetAmmoType;
void InfiniteAmmo_Start(){
g_iOffsetClip = FindSendPropInfo("CTFWeaponBase", "m_iClip1");
g_iOffsetAmmo = FindSendPropInfo("CTFPlayer", "m_iAmmo");
g_iOffsetAmmoType = FindSendPropInfo("CBaseCombatWeapon", "m_iPrimaryAmmoType");
}
void InfiniteAmmo_Perk(int client, const char[] sPref, bool apply){
if(apply)
InfiniteAmmo_ApplyPerk(client, StringToInt(sPref));
else
g_bResupplyAmmo[client] = false;
}
void InfiniteAmmo_ApplyPerk(int client, int iNoReload){
g_bNoReload = (iNoReload < 1) ? true : false;
g_bResupplyAmmo[client] = true;
CreateTimer(0.25, Timer_ResupplyAmmo, GetClientSerial(client), TIMER_REPEAT);
}
public Action Timer_ResupplyAmmo(Handle hTimer, int iSerial){
int client = GetClientFromSerial(iSerial);
if(!IsValidClient(client)) return Plugin_Stop;
if(!g_bResupplyAmmo[client]) return Plugin_Stop;
InfiniteAmmo_Resupply(client);
return Plugin_Continue;
}
void InfiniteAmmo_Resupply(int client){
switch(TF2_GetPlayerClass(client)){
case TFClass_Engineer:{
SetEntProp(client, Prop_Data, "m_iAmmo", 200, 4, 3);
}
case TFClass_Spy:{
SetEntPropFloat(client, Prop_Send, "m_flCloakMeter", 100.0);
}
}
int iWeapon = GetEntPropEnt(client, Prop_Send, "m_hActiveWeapon");
if(iWeapon <= MaxClients || !IsValidEntity(iWeapon))
return;
switch(GetEntProp(iWeapon, Prop_Send, "m_iItemDefinitionIndex")){
case 441,442,588:{
SetEntPropFloat(iWeapon, Prop_Send, "m_flEnergy", 20.0);
}
case 307:{
SetEntProp(iWeapon, Prop_Send, "m_bBroken", 0);
SetEntProp(iWeapon, Prop_Send, "m_iDetonated", 0);
}
default:{
if(g_iWeaponCache[client][0] != iWeapon){
g_iWeaponCache[client][0] = iWeapon;
g_iWeaponCache[client][1] = GetClip(iWeapon);
g_iWeaponCache[client][2] = GetAmmo(client, iWeapon);
}else{
int iClip = g_bNoReload ? GetClip(iWeapon) : -1;
if(iClip > -1){
if(iClip > g_iWeaponCache[client][1])
g_iWeaponCache[client][1] = iClip;
else if(iClip < g_iWeaponCache[client][1])
SetClip(iWeapon, g_iWeaponCache[client][1]);
}
int iAmmo = GetAmmo(client, iWeapon);
if(iAmmo > -1){
if(iAmmo > g_iWeaponCache[client][2])
g_iWeaponCache[client][2] = iAmmo;
else if(iAmmo < g_iWeaponCache[client][2])
SetAmmo(client, iWeapon, g_iWeaponCache[client][2]);
}
}
}
}
}
//The bellow are ripped straight from the original RTD
int SetAmmo(int client, int iWeapon, int iAmount){
return SetEntData(client, g_iOffsetAmmo + GetEntData(iWeapon, g_iOffsetAmmoType, 1) * 4, iAmount);
}
int GetAmmo(int client, int iWeapon){
int iAmmoType = GetEntData(iWeapon, g_iOffsetAmmoType, 1);
if(iAmmoType == 4) return -1;
return GetEntData(client, g_iOffsetAmmo + iAmmoType * 4);
}
int SetClip(int iWeapon, int iAmount){
return SetEntData(iWeapon, g_iOffsetClip, iAmount, _, true);
}
int GetClip(int iWeapon){
return GetEntData(iWeapon, g_iOffsetClip);
}

View File

@@ -0,0 +1,73 @@
/*
This script is a part of RTD2 plugin and is not meant to work by itself.
If you were to edit anything here, you'd have to recompile rtd2.sp instead of this one.
*** HOW TO ADD A PERK ***
A quick note: This tutorial may not be kept up to date; for an updated one, go to the plugin's thread.
1. Set up:
a) Have <perkname>.sp in scripting/rtd.
b) Add it to the includes in scripting/rtd/#perks.sp.
c) Add a new section with a correct ID (highest one +1) to the config/rtd2_perks.cfg and set its settings.
2. Edit scripting/rtd/#manager.sp
a) In a function named ManagePerk() add a new case to the switch() with your perk's ID.
b) In the added case specify a function which is going to execute from <perkname>.sp with parameters:
1) @client - the client the perk should be applied to/removed from
2) @fSpecialPref - the optional "special" value in config/rtd2_perks.cfg
2) @enable - to specify whether the perk should be applied/removed
c) OPTIONAL: You can specify a function in your perk which should run at OnMapStart() in the Forward_OnMapStart() function.
You will need it if you'd want to, for example, precache a sound or loop through existing clients.
d) OPTIONAL: You can specify a function in your perk which should run at OnPlayerRunCmd() in the Forward_OnPlayerRunCmd() function.
You can use it if you'd need something to run each frame or on a certain button press.
NOTE: The forwarded client is guaranteed to be valid BUT NOT GUARANTEED IF THEY ARE ALIVE.
3. Script your perk:
a) Create a public function in <perkname>.sp with parameters @client, @iPref, @bool:apply as an example below
- This is the only function used to transfer info between the core and the include
- You don't need to include any includes that are in the rtd2.sp
b) NOTE: If you need to transfer the iPref to a different function, set it globally but remember to use an unique name
c) Name it AS SAME AS you named the function in the added case in the switch() in #manager.sp
d) From there, script the functionality like there's no tomorrow
e) You are free to use IsValidClient(). It returns false when:
- An incorrect client index is specified
- Client is not in game
- Client is fake (bot)
- Client is Coaching
4. Compile rtd2.sp and you're good to go!
*/
bool g_bInfiniteCloak[MAXPLAYERS+1] = {false, ...};
public void InfiniteCloak_Perk(int client, const char[] sPref, bool apply){
if(apply)
InfiniteCloak_ApplyPerk(client);
else
g_bInfiniteCloak[client] = false;
}
void InfiniteCloak_ApplyPerk(int client){
g_bInfiniteCloak[client] = true;
CreateTimer(0.25, Timer_RefreshCloak, GetClientSerial(client), TIMER_REPEAT);
}
public Action Timer_RefreshCloak(Handle hTimer, int iSerial){
int client = GetClientFromSerial(iSerial);
if(!IsValidClient(client)) return Plugin_Stop;
if(!g_bInfiniteCloak[client]) return Plugin_Stop;
SetEntPropFloat(client, Prop_Send, "m_flCloakMeter", 105.0);
return Plugin_Continue;
}

View File

@@ -0,0 +1,59 @@
/*
This script is a part of RTD2 plugin and is not meant to work by itself.
If you were to edit anything here, you'd have to recompile rtd2.sp instead of this one.
*** HOW TO ADD A PERK ***
A quick note: This tutorial may not be kept up to date; for an updated one, go to the plugin's thread.
1. Set up:
a) Have <perkname>.sp in scripting/rtd.
b) Add it to the includes in scripting/rtd/#perks.sp.
c) Add a new section with a correct ID (highest one +1) to the config/rtd2_perks.cfg and set its settings.
2. Edit scripting/rtd/#manager.sp
a) In a function named ManagePerk() add a new case to the switch() with your perk's ID.
b) In the added case specify a function which is going to execute from <perkname>.sp with parameters:
1) @client - the client the perk should be applied to/removed from
2) @fSpecialPref - the optional "special" value in config/rtd2_perks.cfg
2) @enable - to specify whether the perk should be applied/removed
c) OPTIONAL: You can specify a function in your perk which should run at OnMapStart() in the Forward_OnMapStart() function.
You will need it if you'd want to, for example, precache a sound or loop through existing clients.
d) OPTIONAL: You can specify a function in your perk which should run at OnPlayerRunCmd() in the Forward_OnPlayerRunCmd() function.
You can use it if you'd need something to run each frame or on a certain button press.
NOTE: The forwarded client is guaranteed to be valid BUT NOT GUARANTEED IF THEY ARE ALIVE.
3. Script your perk:
a) Create a public function in <perkname>.sp with parameters @client, @iPref, @bool:apply as an example below
- This is the only function used to transfer info between the core and the include
- You don't need to include any includes that are in the rtd2.sp
b) NOTE: If you need to transfer the iPref to a different function, set it globally but remember to use an unique name
c) Name it AS SAME AS you named the function in the added case in the switch() in #manager.sp
d) From there, script the functionality like there's no tomorrow
e) You are free to use IsValidClient(). It returns false when:
- An incorrect client index is specified
- Client is not in game
- Client is fake (bot)
- Client is Coaching
4. Compile rtd2.sp and you're good to go!
*/
bool g_bHasInfiniteDoubleJump[MAXPLAYERS+1] = {false, ...};
public void InfiniteJump_Perk(int client, const char[] sPref, bool apply){
g_bHasInfiniteDoubleJump[client] = apply;
}
void InfiniteJump_OnPlayerRunCmd(int client, int iButtons){
if(!g_bHasInfiniteDoubleJump[client])
return;
if(iButtons & IN_JUMP)
SetEntProp(client, Prop_Send, "m_iAirDash", 0);
}

View File

@@ -0,0 +1,173 @@
/*
This script is a part of RTD2 plugin and is not meant to work by itself.
If you were to edit anything here, you'd have to recompile rtd2.sp instead of this one.
*** HOW TO ADD A PERK ***
A quick note: This tutorial may not be kept up to date; for an updated one, go to the plugin's thread.
1. Set up:
a) Have <perkname>.sp in scripting/rtd.
b) Add it to the includes in scripting/rtd/#perks.sp.
c) Add a new section with a correct ID (highest one +1) to the config/rtd2_perks.cfg and set its settings.
2. Edit scripting/rtd/#manager.sp
a) In a function named ManagePerk() add a new case to the switch() with your perk's ID.
b) In the added case specify a function which is going to execute from <perkname>.sp with parameters:
1) @client - the client the perk should be applied to/removed from
2) @fSpecialPref - the optional "special" value in config/rtd2_perks.cfg
2) @enable - to specify whether the perk should be applied/removed
c) OPTIONAL: You can specify a function in your perk which should run at OnMapStart() in the Forward_OnMapStart() function.
You will need it if you'd want to, for example, precache a sound or loop through existing clients.
d) OPTIONAL: You can specify a function in your perk which should run at OnPlayerRunCmd() in the Forward_OnPlayerRunCmd() function.
You can use it if you'd need something to run each frame or on a certain button press.
NOTE: The forwarded client is guaranteed to be valid BUT NOT GUARANTEED IF THEY ARE ALIVE.
3. Script your perk:
a) Create a public function in <perkname>.sp with parameters @client, @iPref, @bool:apply as an example below
- This is the only function used to transfer info between the core and the include
- You don't need to include any includes that are in the rtd2.sp
b) NOTE: If you need to transfer the iPref to a different function, set it globally but remember to use an unique name
c) Name it AS SAME AS you named the function in the added case in the switch() in #manager.sp
d) From there, script the functionality like there's no tomorrow
e) You are free to use IsValidClient(). It returns false when:
- An incorrect client index is specified
- Client is not in game
- Client is fake (bot)
- Client is Coaching
4. Compile rtd2.sp and you're good to go!
*/
/*
IF YOU TELL ME HOW TO GET THE INSIDE OF THE B.A.S.E. JUMPER TO DISAPPEAR I WILL LOVE YOU FOREVER
*/
int g_iBaseAlpha[MAXPLAYERS+1] = {255, ...};
bool g_bBaseSentry[MAXPLAYERS+1] = {true, ...};
bool g_bHasInvis[MAXPLAYERS+1] = {false, ...};
int g_iInvisValue = 0;
void Invisibility_Start(){
HookEvent("post_inventory_application", Event_Invisibility_Resupply, EventHookMode_Post);
}
void Invisibility_Perk(int client, const char[] sPref, bool apply){
if(apply)
Invisibility_ApplyPerk(client, StringToInt(sPref));
else
Invisibility_RemovePerk(client);
}
void Invisibility_ApplyPerk(int client, int iValue){
g_bHasInvis[client] = true;
g_iInvisValue = iValue;
g_iBaseAlpha[client] = GetEntityAlpha(client);
g_bBaseSentry[client] = (GetEntityFlags(client) & FL_NOTARGET) ? true : false;
Invisibility_Set(client, iValue);
SetSentryTarget(client, false);
}
void Invisibility_RemovePerk(int client){
g_bHasInvis[client] = false;
Invisibility_Set(client, g_iBaseAlpha[client]);
SetSentryTarget(client, g_bBaseSentry[client]);
}
void Invisibility_Set(int client, int iValue){
if(GetEntityRenderMode(client) == RENDER_NORMAL)
SetEntityRenderMode(client, RENDER_TRANSCOLOR);
SetEntityAlpha(client, iValue);
int iWeapon = 0;
for(int i = 0; i < 5; i++){
iWeapon = GetPlayerWeaponSlot(client, i);
if(iWeapon <= MaxClients || !IsValidEntity(iWeapon))
continue;
if(GetEntityRenderMode(iWeapon) == RENDER_NORMAL)
SetEntityRenderMode(iWeapon, RENDER_TRANSCOLOR);
SetEntityAlpha(iWeapon, iValue);
}
char sClass[24];
for(int i = MaxClients+1; i < GetMaxEntities(); i++){
if(!IsCorrectWearable(client, i, sClass, sizeof(sClass))) continue;
if(GetEntityRenderMode(i) == RENDER_NORMAL)
SetEntityRenderMode(i, RENDER_TRANSCOLOR);
SetEntityAlpha(i, iValue);
}
}
public void Event_Invisibility_Resupply(Handle hEvent, const char[] sEventName, bool bDontBroadcast){
int client = GetClientOfUserId(GetEventInt(hEvent, "userid"));
if(!IsValidClient(client)) return;
if(!g_bHasInvis[client]) return;
Invisibility_Set(client, g_iInvisValue);
}
stock int GetEntityAlpha(int iEntity){
return GetEntData(iEntity, GetEntSendPropOffs(iEntity, "m_clrRender") + 3, 1);
}
stock void SetEntityAlpha(int iEntity, int iValue){
SetEntData(iEntity, GetEntSendPropOffs(iEntity, "m_clrRender") + 3, iValue, 1, true);
}
bool IsCorrectWearable(int client, int i, char[] sClass, iBufferSize){
if(!IsValidEntity(i))
return false;
GetEdictClassname(i, sClass, iBufferSize);
if(StrContains(sClass, "tf_wearable", false) < 0 && StrContains(sClass, "tf_powerup", false) < 0)
return false;
if(GetEntPropEnt(i, Prop_Send, "m_hOwnerEntity") != client)
return false;
return true;
}
void SetSentryTarget(int client, bool bTarget){
int iFlags = GetEntityFlags(client);
if(bTarget)
SetEntityFlags(client, iFlags &~ FL_NOTARGET);
else
SetEntityFlags(client, iFlags | FL_NOTARGET);
}

View File

@@ -0,0 +1,60 @@
/*
This script is a part of RTD2 plugin and is not meant to work by itself.
If you were to edit anything here, you'd have to recompile rtd2.sp instead of this one.
*** HOW TO ADD A PERK ***
A quick note: This tutorial may not be kept up to date; for an updated one, go to the plugin's thread.
1. Set up:
a) Have <perkname>.sp in scripting/rtd.
b) Add it to the includes in scripting/rtd/#perks.sp.
c) Add a new section with a correct ID (highest one +1) to the config/rtd2_perks.cfg and set its settings.
2. Edit scripting/rtd/#manager.sp
a) In a function named ManagePerk() add a new case to the switch() with your perk's ID.
b) In the added case specify a function which is going to execute from <perkname>.sp with parameters:
1) @client - the client the perk should be applied to/removed from
2) @fSpecialPref - the optional "special" value in config/rtd2_perks.cfg
2) @enable - to specify whether the perk should be applied/removed
c) OPTIONAL: You can specify a function in your perk which should run at OnMapStart() in the Forward_OnMapStart() function.
You will need it if you'd want to, for example, precache a sound or loop through existing clients.
d) OPTIONAL: You can specify a function in your perk which should run at OnPlayerRunCmd() in the Forward_OnPlayerRunCmd() function.
You can use it if you'd need something to run each frame or on a certain button press.
NOTE: The forwarded client is guaranteed to be valid BUT NOT GUARANTEED IF THEY ARE ALIVE.
3. Script your perk:
a) Create a public function in <perkname>.sp with parameters @client, @iPref, @bool:apply as an example below
- This is the only function used to transfer info between the core and the include
- You don't need to include any includes that are in the rtd2.sp
b) NOTE: If you need to transfer the iPref to a different function, set it globally but remember to use an unique name
c) Name it AS SAME AS you named the function in the added case in the switch() in #manager.sp
d) From there, script the functionality like there's no tomorrow
e) You are free to use IsValidClient(). It returns false when:
- An incorrect client index is specified
- Client is not in game
- Client is fake (bot)
- Client is Coaching
4. Compile rtd2.sp and you're good to go!
*/
float g_fBaseGravity[MAXPLAYERS+1] = {0.0, ...};
void LowGravity_Perk(int client, const char[] sPref, bool apply){
if(apply)
LowGravity_ApplyPerk(client, StringToFloat(sPref));
else
SetEntityGravity(client, g_fBaseGravity[client]);
}
void LowGravity_ApplyPerk(int client, float fMultp){
g_fBaseGravity[client] = GetEntityGravity(client);
SetEntityGravity(client, fMultp);
}

View File

@@ -0,0 +1,50 @@
/*
This script is a part of RTD2 plugin and is not meant to work by itself.
If you were to edit anything here, you'd have to recompile rtd2.sp instead of this one.
*** HOW TO ADD A PERK ***
A quick note: This tutorial may not be kept up to date; for an updated one, go to the plugin's thread.
1. Set up:
a) Have <perkname>.sp in scripting/rtd.
b) Add it to the includes in scripting/rtd/#perks.sp.
c) Add a new section with a correct ID (highest one +1) to the config/rtd2_perks.cfg and set its settings.
2. Edit scripting/rtd/#manager.sp
a) In a function named ManagePerk() add a new case to the switch() with your perk's ID.
b) In the added case specify a function which is going to execute from <perkname>.sp with parameters:
1) @client - the client the perk should be applied to/removed from
2) @fSpecialPref - the optional "special" value in config/rtd2_perks.cfg
2) @enable - to specify whether the perk should be applied/removed
c) OPTIONAL: You can specify a function in your perk which should run at OnMapStart() in the Forward_OnMapStart() function.
You will need it if you'd want to, for example, precache a sound or loop through existing clients.
d) OPTIONAL: You can specify a function in your perk which should run at OnPlayerRunCmd() in the Forward_OnPlayerRunCmd() function.
You can use it if you'd need something to run each frame or on a certain button press.
NOTE: The forwarded client is guaranteed to be valid BUT NOT GUARANTEED IF THEY ARE ALIVE.
3. Script your perk:
a) Create a public function in <perkname>.sp with parameters @client, @iPref, @bool:apply as an example below
- This is the only function used to transfer info between the core and the include
- You don't need to include any includes that are in the rtd2.sp
b) NOTE: If you need to transfer the iPref to a different function, set it globally but remember to use an unique name
c) Name it AS SAME AS you named the function in the added case in the switch() in #manager.sp
d) From there, script the functionality like there's no tomorrow
e) You are free to use IsValidClient(). It returns false when:
- An incorrect client index is specified
- Client is not in game
- Client is fake (bot)
- Client is Coaching
4. Compile rtd2.sp and you're good to go!
*/
void LowHealth_Perk(int client, const char[] sPref, bool apply){
if(!apply)
return;
SetEntityHealth(client, StringToInt(sPref));
}

View File

@@ -0,0 +1,63 @@
/*
This script is a part of RTD2 plugin and is not meant to work by itself.
If you were to edit anything here, you'd have to recompile rtd2.sp instead of this one.
*** HOW TO ADD A PERK ***
A quick note: This tutorial may not be kept up to date; for an updated one, go to the plugin's thread.
1. Set up:
a) Have <perkname>.sp in scripting/rtd.
b) Add it to the includes in scripting/rtd/#perks.sp.
c) Add a new section with a correct ID (highest one +1) to the config/rtd2_perks.cfg and set its settings.
2. Edit scripting/rtd/#manager.sp
a) In a function named ManagePerk() add a new case to the switch() with your perk's ID.
b) In the added case specify a function which is going to execute from <perkname>.sp with parameters:
1) @client - the client the perk should be applied to/removed from
2) @fSpecialPref - the optional "special" value in config/rtd2_perks.cfg
2) @enable - to specify whether the perk should be applied/removed
c) OPTIONAL: You can specify a function in your perk which should run at OnMapStart() in the Forward_OnMapStart() function.
You will need it if you'd want to, for example, precache a sound or loop through existing clients.
d) OPTIONAL: You can specify a function in your perk which should run at OnPlayerRunCmd() in the Forward_OnPlayerRunCmd() function.
You can use it if you'd need something to run each frame or on a certain button press.
NOTE: The forwarded client is guaranteed to be valid BUT NOT GUARANTEED IF THEY ARE ALIVE.
3. Script your perk:
a) Create a public function in <perkname>.sp with parameters @client, @iPref, @bool:apply as an example below
- This is the only function used to transfer info between the core and the include
- You don't need to include any includes that are in the rtd2.sp
b) NOTE: If you need to transfer the iPref to a different function, set it globally but remember to use an unique name
c) Name it AS SAME AS you named the function in the added case in the switch() in #manager.sp
d) From there, script the functionality like there's no tomorrow
e) You are free to use IsValidClient(). It returns false when:
- An incorrect client index is specified
- Client is not in game
- Client is fake (bot)
- Client is Coaching
4. Compile rtd2.sp and you're good to go!
*/
bool g_bLuckySandvich_HasCrit[MAXPLAYERS+1] = {false, ...};
void LuckySandvich_Perk(int client, const char[] sPref, bool apply){
if(!apply)
return;
SetEntityHealth(client, GetEntProp(client, Prop_Data, "m_iHealth") +StringToInt(sPref));
g_bLuckySandvich_HasCrit[client] = true;
}
bool LuckySandvich_SetCritical(int client){
if(!g_bLuckySandvich_HasCrit[client])
return false;
g_bLuckySandvich_HasCrit[client] = false;
return true;
}

View File

@@ -0,0 +1,50 @@
/*
This script is a part of RTD2 plugin and is not meant to work by itself.
If you were to edit anything here, you'd have to recompile rtd2.sp instead of this one.
*** HOW TO ADD A PERK ***
A quick note: This tutorial may not be kept up to date; for an updated one, go to the plugin's thread.
1. Set up:
a) Have <perkname>.sp in scripting/rtd.
b) Add it to the includes in scripting/rtd/#perks.sp.
c) Add a new section with a correct ID (highest one +1) to the config/rtd2_perks.cfg and set its settings.
2. Edit scripting/rtd/#manager.sp
a) In a function named ManagePerk() add a new case to the switch() with your perk's ID.
b) In the added case specify a function which is going to execute from <perkname>.sp with parameters:
1) @client - the client the perk should be applied to/removed from
2) @fSpecialPref - the optional "special" value in config/rtd2_perks.cfg
2) @enable - to specify whether the perk should be applied/removed
c) OPTIONAL: You can specify a function in your perk which should run at OnMapStart() in the Forward_OnMapStart() function.
You will need it if you'd want to, for example, precache a sound or loop through existing clients.
d) OPTIONAL: You can specify a function in your perk which should run at OnPlayerRunCmd() in the Forward_OnPlayerRunCmd() function.
You can use it if you'd need something to run each frame or on a certain button press.
NOTE: The forwarded client is guaranteed to be valid BUT NOT GUARANTEED IF THEY ARE ALIVE.
3. Script your perk:
a) Create a public function in <perkname>.sp with parameters @client, @iPref, @bool:apply as an example below
- This is the only function used to transfer info between the core and the include
- You don't need to include any includes that are in the rtd2.sp
b) NOTE: If you need to transfer the iPref to a different function, set it globally but remember to use an unique name
c) Name it AS SAME AS you named the function in the added case in the switch() in #manager.sp
d) From there, script the functionality like there's no tomorrow
e) You are free to use IsValidClient(). It returns false when:
- An incorrect client index is specified
- Client is not in game
- Client is fake (bot)
- Client is Coaching
4. Compile rtd2.sp and you're good to go!
*/
public void Monochromia_Perk(int client, const char[] sPref, bool apply){
int iFlags = GetCommandFlags("r_screenoverlay") & (~FCVAR_CHEAT);
SetCommandFlags("r_screenoverlay", iFlags);
ClientCommand(client, "r_screenoverlay \"%s\"", apply ? "debug/yuv" : "");
}

258
scripting/rtd/necromash.sp Normal file
View File

@@ -0,0 +1,258 @@
/*
THESE FUNCTIONS ARE ENTIRELY MADE BY Pelipoika IN HIS PLUGIN "Necromasher":
https://forums.alliedmods.net/showthread.php?p=2300875
All credits go to him!
*/
bool g_bShouldBeSmashed[MAXPLAYERS+1] = {false, ...};
void NecroMash_Start(){
PrecacheModel("models/props_halloween/hammer_gears_mechanism.mdl");
PrecacheModel("models/props_halloween/hammer_mechanism.mdl");
PrecacheModel("models/props_halloween/bell_button.mdl");
PrecacheSound("misc/halloween/strongman_fast_impact_01.wav");
PrecacheSound("ambient/explosions/explode_1.wav");
PrecacheSound("misc/halloween/strongman_fast_whoosh_01.wav");
PrecacheSound("misc/halloween/strongman_fast_swing_01.wav");
PrecacheSound("doors/vent_open2.wav");
}
public void NecroMash_Perk(int client, const char[] sPref, bool apply){
if(!apply)
return;
if(GetEntPropEnt(client, Prop_Send, "m_hGroundEntity") > -1)
NecroMash_SmashClient(client);
else{
g_bShouldBeSmashed[client] = true;
CreateTimer(0.1, Timer_NecroMash_Retry, GetClientSerial(client), TIMER_REPEAT);
}
}
public Action Timer_NecroMash_Retry(Handle hTimer, int iSerial){
int client = GetClientFromSerial(iSerial);
if(!IsValidClient(client)) return Plugin_Stop;
if(!g_bShouldBeSmashed[client]) return Plugin_Stop;
if(GetEntProp(client, Prop_Send, "m_hGroundEntity") < 0)
return Plugin_Continue;
g_bShouldBeSmashed[client] = false;
NecroMash_SmashClient(client);
return Plugin_Stop;
}
void NecroMash_SmashClient(int client){
float flPos[3], flPpos[3], flAngles[3];
GetClientAbsOrigin(client, flPos);
GetClientAbsOrigin(client, flPpos);
GetClientEyeAngles(client, flAngles);
flAngles[0] = 0.0;
float vForward[3];
GetAngleVectors(flAngles, vForward, NULL_VECTOR, NULL_VECTOR);
flPos[0] -= (vForward[0] * 750);
flPos[1] -= (vForward[1] * 750);
flPos[2] -= (vForward[2] * 750);
flPos[2] += 350.0;
int gears = CreateEntityByName("prop_dynamic");
if(IsValidEntity(gears)){
DispatchKeyValueVector(gears, "origin", flPos);
DispatchKeyValueVector(gears, "angles", flAngles);
DispatchKeyValue(gears, "model", "models/props_halloween/hammer_gears_mechanism.mdl");
DispatchSpawn(gears);
}
int hammer = CreateEntityByName("prop_dynamic");
if(IsValidEntity(hammer)){
DispatchKeyValueVector(hammer, "origin", flPos);
DispatchKeyValueVector(hammer, "angles", flAngles);
DispatchKeyValue(hammer, "model", "models/props_halloween/hammer_mechanism.mdl");
DispatchSpawn(hammer);
}
int button = CreateEntityByName("prop_dynamic");
if(IsValidEntity(button)){
flPos[0] += (vForward[0] * 600);
flPos[1] += (vForward[1] * 600);
flPos[2] += (vForward[2] * 600);
flPos[2] -= 100.0;
flAngles[1] += 180.0;
DispatchKeyValueVector(button, "origin", flPos);
DispatchKeyValueVector(button, "angles", flAngles);
DispatchKeyValue(button, "model", "models/props_halloween/bell_button.mdl");
DispatchSpawn(button);
Handle pack;
CreateDataTimer(1.3, Timer_NecroMash_Hit, pack);
WritePackFloat(pack, flPpos[0]); //Position of effects
WritePackFloat(pack, flPpos[1]); //Position of effects
WritePackFloat(pack, flPpos[2]); //Position of effects
Handle pack2;
CreateDataTimer(1.0, Timer_NecroMash_Whoosh, pack2);
WritePackFloat(pack2, flPpos[0]); //Position of effects
WritePackFloat(pack2, flPpos[1]); //Position of effects
WritePackFloat(pack2, flPpos[2]); //Position of effects
EmitSoundToAll("misc/halloween/strongman_fast_swing_01.wav", _, _, _, _, _, _, _, flPpos);
}
SetVariantString("OnUser1 !self:SetAnimation:smash:0:1");
AcceptEntityInput(gears, "AddOutput");
AcceptEntityInput(gears, "FireUser1");
SetVariantString("OnUser1 !self:SetAnimation:smash:0:1");
AcceptEntityInput(hammer, "AddOutput");
AcceptEntityInput(hammer, "FireUser1");
SetVariantString("OnUser1 !self:SetAnimation:hit:1.3:1");
AcceptEntityInput(button, "AddOutput");
AcceptEntityInput(button, "FireUser1");
SetVariantString("OnUser2 !self:Kill::5.0:1");
AcceptEntityInput(gears, "AddOutput");
AcceptEntityInput(gears, "FireUser2");
SetVariantString("OnUser2 !self:Kill::5.0:1");
AcceptEntityInput(hammer, "AddOutput");
AcceptEntityInput(hammer, "FireUser2");
SetVariantString("OnUser2 !self:Kill::5.0:1");
AcceptEntityInput(button, "AddOutput");
AcceptEntityInput(button, "FireUser2");
}
public Action Timer_NecroMash_Hit(Handle timer, any pack){
ResetPack(pack);
float pos[3];
pos[0] = ReadPackFloat(pack);
pos[1] = ReadPackFloat(pack);
pos[2] = ReadPackFloat(pack);
int shaker = CreateEntityByName("env_shake");
if(shaker != -1){
DispatchKeyValue(shaker, "amplitude", "10");
DispatchKeyValue(shaker, "radius", "1500");
DispatchKeyValue(shaker, "duration", "1");
DispatchKeyValue(shaker, "frequency", "2.5");
DispatchKeyValue(shaker, "spawnflags", "4");
DispatchKeyValueVector(shaker, "origin", pos);
DispatchSpawn(shaker);
AcceptEntityInput(shaker, "StartShake");
SetVariantString("OnUser1 !self:Kill::1.0:1");
AcceptEntityInput(shaker, "AddOutput");
AcceptEntityInput(shaker, "FireUser1");
}
EmitSoundToAll("ambient/explosions/explode_1.wav", _, _, _, _, _, _, _, pos);
EmitSoundToAll("misc/halloween/strongman_fast_impact_01.wav", _, _, _, _, _, _, _, pos);
float pos2[3], Vec[3], AngBuff[3];
for(int i = 1; i <= MaxClients; i++){
if(IsClientInGame(i) && IsPlayerAlive(i)){
GetClientAbsOrigin(i, pos2);
if(GetVectorDistance(pos, pos2) <= 500.0){
MakeVectorFromPoints(pos, pos2, Vec);
GetVectorAngles(Vec, AngBuff);
AngBuff[0] -= 30.0;
GetAngleVectors(AngBuff, Vec, NULL_VECTOR, NULL_VECTOR);
NormalizeVector(Vec, Vec);
ScaleVector(Vec, 500.0);
Vec[2] += 250.0;
TeleportEntity(i, NULL_VECTOR, NULL_VECTOR, Vec);
}
if(GetVectorDistance(pos, pos2) <= 60.0)
SDKHooks_TakeDamage(i, i, i, 999999.0, DMG_CLUB|DMG_ALWAYSGIB|DMG_BLAST);
}
}
pos[2] += 10.0;
NecroMash_CreateParticle("hammer_impact_button", pos);
NecroMash_CreateParticle("hammer_bones_kickup", pos);
}
public Action Timer_NecroMash_Whoosh(Handle timer, any pack){
ResetPack(pack);
float pos[3];
pos[0] = ReadPackFloat(pack);
pos[1] = ReadPackFloat(pack);
pos[2] = ReadPackFloat(pack);
EmitSoundToAll("misc/halloween/strongman_fast_whoosh_01.wav", _, _, _, _, _, _, _, pos);
}
stock void NecroMash_CreateParticle(char[] particle, float pos[3]){
int tblidx = FindStringTable("ParticleEffectNames");
char tmp[256];
int count = GetStringTableNumStrings(tblidx);
int stridx = INVALID_STRING_INDEX;
for(int i = 0; i < count; i++){
ReadStringTable(tblidx, i, tmp, sizeof(tmp));
if(StrEqual(tmp, particle, false)){
stridx = i;
break;
}
}
for(int i = 1; i <= GetMaxClients(); i++){
if(!IsValidEntity(i)) continue;
if(!IsClientInGame(i)) continue;
TE_Start("TFParticleEffect");
TE_WriteFloat("m_vecOrigin[0]", pos[0]);
TE_WriteFloat("m_vecOrigin[1]", pos[1]);
TE_WriteFloat("m_vecOrigin[2]", pos[2]);
TE_WriteNum("m_iParticleSystemIndex", stridx);
TE_WriteNum("entindex", -1);
TE_WriteNum("m_iAttachType", 2);
TE_SendToClient(i, 0.0);
}
}

55
scripting/rtd/noclip.sp Normal file
View File

@@ -0,0 +1,55 @@
/*
This script is a part of RTD2 plugin and is not meant to work by itself.
If you were to edit anything here, you'd have to recompile rtd2.sp instead of this one.
*** HOW TO ADD A PERK ***
A quick note: This tutorial may not be kept up to date; for an updated one, go to the plugin's thread.
1. Set up:
a) Have <perkname>.sp in scripting/rtd.
b) Add it to the includes in scripting/rtd/#perks.sp.
c) Add a new section with a correct ID (highest one +1) to the config/rtd2_perks.cfg and set its settings.
2. Edit scripting/rtd/#manager.sp
a) In a function named ManagePerk() add a new case to the switch() with your perk's ID.
b) In the added case specify a function which is going to execute from <perkname>.sp with parameters:
1) @client - the client the perk should be applied to/removed from
2) @fSpecialPref - the optional "special" value in config/rtd2_perks.cfg
2) @enable - to specify whether the perk should be applied/removed
c) OPTIONAL: You can specify a function in your perk which should run at OnMapStart() in the Forward_OnMapStart() function.
You will need it if you'd want to, for example, precache a sound or loop through existing clients.
d) OPTIONAL: You can specify a function in your perk which should run at OnPlayerRunCmd() in the Forward_OnPlayerRunCmd() function.
You can use it if you'd need something to run each frame or on a certain button press.
NOTE: The forwarded client is guaranteed to be valid BUT NOT GUARANTEED IF THEY ARE ALIVE.
3. Script your perk:
a) Create a public function in <perkname>.sp with parameters @client, @iPref, @bool:apply as an example below
- This is the only function used to transfer info between the core and the include
- You don't need to include any includes that are in the rtd2.sp
b) NOTE: If you need to transfer the iPref to a different function, set it globally but remember to use an unique name
c) Name it AS SAME AS you named the function in the added case in the switch() in #manager.sp
d) From there, script the functionality like there's no tomorrow
e) You are free to use IsValidClient(). It returns false when:
- An incorrect client index is specified
- Client is not in game
- Client is fake (bot)
- Client is Coaching
4. Compile rtd2.sp and you're good to go!
*/
void Noclip_Perk(int client, const char[] sPref, bool apply){
if(apply)
SetEntityMoveType(client, StringToInt(sPref) < 1 ? MOVETYPE_FLY : MOVETYPE_NOCLIP);
else{
SetEntityMoveType(client, MOVETYPE_WALK);
FixPotentialStuck(client);
}
}

View File

@@ -0,0 +1,60 @@
/*
This script is a part of RTD2 plugin and is not meant to work by itself.
If you were to edit anything here, you'd have to recompile rtd2.sp instead of this one.
*** HOW TO ADD A PERK ***
A quick note: This tutorial may not be kept up to date; for an updated one, go to the plugin's thread.
1. Set up:
a) Have <perkname>.sp in scripting/rtd.
b) Add it to the includes in scripting/rtd/#perks.sp.
c) Add a new section with a correct ID (highest one +1) to the config/rtd2_perks.cfg and set its settings.
2. Edit scripting/rtd/#manager.sp
a) In a function named ManagePerk() add a new case to the switch() with your perk's ID.
b) In the added case specify a function which is going to execute from <perkname>.sp with parameters:
1) @client - the client the perk should be applied to/removed from
2) @fSpecialPref - the optional "special" value in config/rtd2_perks.cfg
2) @enable - to specify whether the perk should be applied/removed
c) OPTIONAL: You can specify a function in your perk which should run at OnMapStart() in the Forward_OnMapStart() function.
You will need it if you'd want to, for example, precache a sound or loop through existing clients.
d) OPTIONAL: You can specify a function in your perk which should run at OnPlayerRunCmd() in the Forward_OnPlayerRunCmd() function.
You can use it if you'd need something to run each frame or on a certain button press.
NOTE: The forwarded client is guaranteed to be valid BUT NOT GUARANTEED IF THEY ARE ALIVE.
3. Script your perk:
a) Create a public function in <perkname>.sp with parameters @client, @iPref, @bool:apply as an example below
- This is the only function used to transfer info between the core and the include
- You don't need to include any includes that are in the rtd2.sp
b) NOTE: If you need to transfer the iPref to a different function, set it globally but remember to use an unique name
c) Name it AS SAME AS you named the function in the added case in the switch() in #manager.sp
d) From there, script the functionality like there's no tomorrow
e) You are free to use IsValidClient(). It returns false when:
- An incorrect client index is specified
- Client is not in game
- Client is fake (bot)
- Client is Coaching
4. Compile rtd2.sp and you're good to go!
*/
float g_fNoGravBaseGravity[MAXPLAYERS+1] = {0.0, ...};
public void NoGravity_Perk(int client, const char[] sPref, bool apply){
if(apply)
NoGravity_ApplyPerk(client);
else
SetEntityGravity(client, g_fNoGravBaseGravity[client]);
}
void NoGravity_ApplyPerk(int client){
g_fBaseGravity[client] = GetEntityGravity(client);
SetEntityGravity(client, 0.01);
}

71
scripting/rtd/outline.sp Normal file
View File

@@ -0,0 +1,71 @@
/*
This script is a part of RTD2 plugin and is not meant to work by itself.
If you were to edit anything here, you'd have to recompile rtd2.sp instead of this one.
*** HOW TO ADD A PERK ***
A quick note: This tutorial may not be kept up to date; for an updated one, go to the plugin's thread.
1. Set up:
a) Have <perkname>.sp in scripting/rtd.
b) Add it to the includes in scripting/rtd/#perks.sp.
c) Add a new section with a correct ID (highest one +1) to the config/rtd2_perks.cfg and set its settings.
2. Edit scripting/rtd/#manager.sp
a) In a function named ManagePerk() add a new case to the switch() with your perk's ID.
b) In the added case specify a function which is going to execute from <perkname>.sp with parameters:
1) @client - the client the perk should be applied to/removed from
2) @fSpecialPref - the optional "special" value in config/rtd2_perks.cfg
2) @enable - to specify whether the perk should be applied/removed
c) OPTIONAL: You can specify a function in your perk which should run at OnMapStart() in the Forward_OnMapStart() function.
You will need it if you'd want to, for example, precache a sound or loop through existing clients.
d) OPTIONAL: You can specify a function in your perk which should run at OnPlayerRunCmd() in the Forward_OnPlayerRunCmd() function.
You can use it if you'd need something to run each frame or on a certain button press.
NOTE: The forwarded client is guaranteed to be valid BUT NOT GUARANTEED IF THEY ARE ALIVE.
3. Script your perk:
a) Create a public function in <perkname>.sp with parameters @client, @iPref, @bool:apply as an example below
- This is the only function used to transfer info between the core and the include
- You don't need to include any includes that are in the rtd2.sp
b) NOTE: If you need to transfer the iPref to a different function, set it globally but remember to use an unique name
c) Name it AS SAME AS you named the function in the added case in the switch() in #manager.sp
d) From there, script the functionality like there's no tomorrow
e) You are free to use IsValidClient(). It returns false when:
- An incorrect client index is specified
- Client is not in game
- Client is fake (bot)
- Client is Coaching
4. Compile rtd2.sp and you're good to go!
*/
bool g_bOutlined_Outline[MAXPLAYERS+1] = {false, ...};
public void Outline_Perk(int client, const char[] sPref, bool apply){
if(apply)
Outline_ApplyPerk(client);
else
Outline_RemovePerk(client);
}
void Outline_ApplyPerk(int client){
g_bOutlined_Outline[client] = view_as<bool>(GetEntProp(client, Prop_Send, "m_bGlowEnabled"));
if(g_bOutlined_Outline[client])
return;
SetEntProp(client, Prop_Send, "m_bGlowEnabled", 1);
}
void Outline_RemovePerk(int client){
if(!g_bOutlined_Outline[client])
SetEntProp(client, Prop_Send, "m_bGlowEnabled", 0);
}

View File

@@ -0,0 +1,77 @@
/*
This script is a part of RTD2 plugin and is not meant to work by itself.
If you were to edit anything here, you'd have to recompile rtd2.sp instead of this one.
*** HOW TO ADD A PERK ***
A quick note: This tutorial may not be kept up to date; for an updated one, go to the plugin's thread.
1. Set up:
a) Have <perkname>.sp in scripting/rtd.
b) Add it to the includes in scripting/rtd/#perks.sp.
c) Add a new section with a correct ID (highest one +1) to the config/rtd2_perks.cfg and set its settings.
2. Edit scripting/rtd/#manager.sp
a) In a function named ManagePerk() add a new case to the switch() with your perk's ID.
b) In the added case specify a function which is going to execute from <perkname>.sp with parameters:
1) @client - the client the perk should be applied to/removed from
2) @fSpecialPref - the optional "special" value in config/rtd2_perks.cfg
2) @enable - to specify whether the perk should be applied/removed
c) OPTIONAL: You can specify a function in your perk which should run at OnMapStart() in the Forward_OnMapStart() function.
You will need it if you'd want to, for example, precache a sound or loop through existing clients.
d) OPTIONAL: You can specify a function in your perk which should run at OnPlayerRunCmd() in the Forward_OnPlayerRunCmd() function.
You can use it if you'd need something to run each frame or on a certain button press.
NOTE: The forwarded client is guaranteed to be valid BUT NOT GUARANTEED IF THEY ARE ALIVE.
3. Script your perk:
a) Create a public function in <perkname>.sp with parameters @client, @iPref, @bool:apply as an example below
- This is the only function used to transfer info between the core and the include
- You don't need to include any includes that are in the rtd2.sp
b) NOTE: If you need to transfer the iPref to a different function, set it globally but remember to use an unique name
c) Name it AS SAME AS you named the function in the added case in the switch() in #manager.sp
d) From there, script the functionality like there's no tomorrow
e) You are free to use IsValidClient(). It returns false when:
- An incorrect client index is specified
- Client is not in game
- Client is fake (bot)
- Client is Coaching
4. Compile rtd2.sp and you're good to go!
*/
bool g_bHasPowerfulHits[MAXPLAYERS+1] = {false, ...};
float g_fPowerFulHitsMultiplayer = 5.0;
void PowerfulHits_OnClientPutInServer(int client){
SDKHook(client, SDKHook_OnTakeDamage, PowerfulHits_OnTakeDamage);
}
void PowerfulHits_Perk(int client, const char[] sPref, bool apply){
g_bHasPowerfulHits[client] = apply;
g_fPowerFulHitsMultiplayer = StringToFloat(sPref);
}
public Action PowerfulHits_OnTakeDamage(int victim, int &attacker, int &inflictor, float &damage, int &damagetype){
if(victim == attacker)
return Plugin_Continue;
if(attacker < 1 || attacker > MaxClients)
return Plugin_Continue;
if(!IsClientInGame(attacker))
return Plugin_Continue;
if(!g_bHasPowerfulHits[attacker])
return Plugin_Continue;
damage *= g_fPowerFulHitsMultiplayer;
return Plugin_Changed;
}

View File

@@ -0,0 +1,75 @@
/*
This script is a part of RTD2 plugin and is not meant to work by itself.
If you were to edit anything here, you'd have to recompile rtd2.sp instead of this one.
*** HOW TO ADD A PERK ***
A quick note: This tutorial may not be kept up to date; for an updated one, go to the plugin's thread.
1. Set up:
a) Have <perkname>.sp in scripting/rtd.
b) Add it to the includes in scripting/rtd/#perks.sp.
c) Add a new section with a correct ID (highest one +1) to the config/rtd2_perks.cfg and set its settings.
2. Edit scripting/rtd/#manager.sp
a) In a function named ManagePerk() add a new case to the switch() with your perk's ID.
b) In the added case specify a function which is going to execute from <perkname>.sp with parameters:
1) @client - the client the perk should be applied to/removed from
2) @fSpecialPref - the optional "special" value in config/rtd2_perks.cfg
2) @enable - to specify whether the perk should be applied/removed
c) OPTIONAL: You can specify a function in your perk which should run at OnMapStart() in the Forward_OnMapStart() function.
You will need it if you'd want to, for example, precache a sound or loop through existing clients.
d) OPTIONAL: You can specify a function in your perk which should run at OnPlayerRunCmd() in the Forward_OnPlayerRunCmd() function.
You can use it if you'd need something to run each frame or on a certain button press.
NOTE: The forwarded client is guaranteed to be valid BUT NOT GUARANTEED IF THEY ARE ALIVE.
3. Script your perk:
a) Create a public function in <perkname>.sp with parameters @client, @iPref, @bool:apply as an example below
- This is the only function used to transfer info between the core and the include
- You don't need to include any includes that are in the rtd2.sp
b) NOTE: If you need to transfer the iPref to a different function, set it globally but remember to use an unique name
c) Name it AS SAME AS you named the function in the added case in the switch() in #manager.sp
d) From there, script the functionality like there's no tomorrow
e) You are free to use IsValidClient(). It returns false when:
- An incorrect client index is specified
- Client is not in game
- Client is fake (bot)
- Client is Coaching
4. Compile rtd2.sp and you're good to go!
*/
public void PowerPlay_Perk(int client, const char[] sPref, bool apply){
if(apply)
PowerPlay_ApplyPerk(client);
else
PowerPlay_RemovePerk(client);
}
void PowerPlay_ApplyPerk(int client){
TF2_AddCondition(client, TFCond_UberchargedCanteen);
TF2_AddCondition(client, TFCond_CritOnFirstBlood);
TF2_AddCondition(client, TFCond_UberBulletResist);
TF2_AddCondition(client, TFCond_UberBlastResist);
TF2_AddCondition(client, TFCond_UberFireResist);
TF2_AddCondition(client, TFCond_MegaHeal);
TF2_SetPlayerPowerPlay(client, true);
}
void PowerPlay_RemovePerk(int client){
TF2_RemoveCondition(client, TFCond_UberchargedCanteen);
TF2_RemoveCondition(client, TFCond_CritOnFirstBlood);
TF2_RemoveCondition(client, TFCond_UberBulletResist);
TF2_RemoveCondition(client, TFCond_UberBlastResist);
TF2_RemoveCondition(client, TFCond_UberFireResist);
TF2_RemoveCondition(client, TFCond_MegaHeal);
TF2_SetPlayerPowerPlay(client, false);
}

View File

@@ -0,0 +1,101 @@
/*
This script is a part of RTD2 plugin and is not meant to work by itself.
If you were to edit anything here, you'd have to recompile rtd2.sp instead of this one.
*** HOW TO ADD A PERK ***
A quick note: This tutorial may not be kept up to date; for an updated one, go to the plugin's thread.
1. Set up:
a) Have <perkname>.sp in scripting/rtd.
b) Add it to the includes in scripting/rtd/#perks.sp.
c) Add a new section with a correct ID (highest one +1) to the config/rtd2_perks.cfg and set its settings.
2. Edit scripting/rtd/#manager.sp
a) In a function named ManagePerk() add a new case to the switch() with your perk's ID.
b) In the added case specify a function which is going to execute from <perkname>.sp with parameters:
1) @client - the client the perk should be applied to/removed from
2) @fSpecialPref - the optional "special" value in config/rtd2_perks.cfg
2) @enable - to specify whether the perk should be applied/removed
c) OPTIONAL: You can specify a function in your perk which should run at OnMapStart() in the Forward_OnMapStart() function.
You will need it if you'd want to, for example, precache a sound or loop through existing clients.
d) OPTIONAL: You can specify a function in your perk which should run at OnPlayerRunCmd() in the Forward_OnPlayerRunCmd() function.
You can use it if you'd need something to run each frame or on a certain button press.
NOTE: The forwarded client is guaranteed to be valid BUT NOT GUARANTEED IF THEY ARE ALIVE.
3. Script your perk:
a) Create a public function in <perkname>.sp with parameters @client, @iPref, @bool:apply as an example below
- This is the only function used to transfer info between the core and the include
- You don't need to include any includes that are in the rtd2.sp
b) NOTE: If you need to transfer the iPref to a different function, set it globally but remember to use an unique name
c) Name it AS SAME AS you named the function in the added case in the switch() in #manager.sp
d) From there, script the functionality like there's no tomorrow
e) You are free to use IsValidClient(). It returns false when:
- An incorrect client index is specified
- Client is not in game
- Client is fake (bot)
- Client is Coaching
4. Compile rtd2.sp and you're good to go!
*/
#define SCARYBULLETS_PARTICLE "ghost_glow"
int g_bHasScaryBullets[MAXPLAYERS+1] = {false, ...};
int g_bScaryParticle[MAXPLAYERS+1] = {-1, ...};
float g_fScaryStunDuration = 4.0;
void ScaryBullets_Start(){
HookEvent("player_hurt", Event_ScaryBullets_PlayerHurt);
}
void ScaryBullets_Perk(int client, const char[] sPref, bool apply){
if(apply)
ScaryBullets_ApplyPerk(client, StringToFloat(sPref));
else
ScaryBullets_RemovePerk(client);
}
void ScaryBullets_ApplyPerk(int client, float fDuration){
g_fScaryStunDuration = fDuration;
g_bHasScaryBullets[client] = true;
if(g_bScaryParticle[client] < 0)
g_bScaryParticle[client] = CreateParticle(client, SCARYBULLETS_PARTICLE);
}
void ScaryBullets_RemovePerk(int client){
if(g_bScaryParticle[client] > MaxClients && IsValidEntity(g_bScaryParticle[client])){
AcceptEntityInput(g_bScaryParticle[client], "Kill");
g_bScaryParticle[client] = -1;
}
g_bHasScaryBullets[client] = false;
}
public void Event_ScaryBullets_PlayerHurt(Handle hEvent, const char[] sEventName, bool bDontBroadcast){
int attacker = GetClientOfUserId(GetEventInt(hEvent, "attacker"));
if(!IsValidClient(attacker)) return;
if(!g_bHasScaryBullets[attacker]) return;
int victim = GetClientOfUserId(GetEventInt(hEvent, "userid"));
if(attacker == victim) return;
if(!IsClientInGame(victim)) return;
if(victim < 1 || victim > MaxClients) return;
if(IsPlayerAlive(victim) && GetEventInt(hEvent, "health") > 0 && !TF2_IsPlayerInCondition(victim, TFCond_Dazed))
TF2_StunPlayer(victim, g_fScaryStunDuration, _, TF_STUNFLAGS_GHOSTSCARE, attacker);
}

80
scripting/rtd/snail.sp Normal file
View File

@@ -0,0 +1,80 @@
/*
This script is a part of RTD2 plugin and is not meant to work by itself.
If you were to edit anything here, you'd have to recompile rtd2.sp instead of this one.
*** HOW TO ADD A PERK ***
A quick note: This tutorial may not be kept up to date; for an updated one, go to the plugin's thread.
1. Set up:
a) Have <perkname>.sp in scripting/rtd.
b) Add it to the includes in scripting/rtd/#perks.sp.
c) Add a new section with a correct ID (highest one +1) to the config/rtd2_perks.cfg and set its settings.
2. Edit scripting/rtd/#manager.sp
a) In a function named ManagePerk() add a new case to the switch() with your perk's ID.
b) In the added case specify a function which is going to execute from <perkname>.sp with parameters:
1) @client - the client the perk should be applied to/removed from
2) @fSpecialPref - the optional "special" value in config/rtd2_perks.cfg
2) @enable - to specify whether the perk should be applied/removed
c) OPTIONAL: You can specify a function in your perk which should run at OnMapStart() in the Forward_OnMapStart() function.
You will need it if you'd want to, for example, precache a sound or loop through existing clients.
d) OPTIONAL: You can specify a function in your perk which should run at OnPlayerRunCmd() in the Forward_OnPlayerRunCmd() function.
You can use it if you'd need something to run each frame or on a certain button press.
NOTE: The forwarded client is guaranteed to be valid BUT NOT GUARANTEED IF THEY ARE ALIVE.
3. Script your perk:
a) Create a public function in <perkname>.sp with parameters @client, @iPref, @bool:apply as an example below
- This is the only function used to transfer info between the core and the include
- You don't need to include any includes that are in the rtd2.sp
b) NOTE: If you need to transfer the iPref to a different function, set it globally but remember to use an unique name
c) Name it AS SAME AS you named the function in the added case in the switch() in #manager.sp
d) From there, script the functionality like there's no tomorrow
e) You are free to use IsValidClient(). It returns false when:
- An incorrect client index is specified
- Client is not in game
- Client is fake (bot)
- Client is Coaching
4. Compile rtd2.sp and you're good to go!
*/
#define ATTRIB_SPEED 107 //the player speed attribute
float g_fBaseSpeed_Snail[MAXPLAYERS+1] = {0.0, ...};
void Snail_Perk(int client, const char[] sPref, bool apply){
if(apply)
Snail_ApplyPerk(client, StringToFloat(sPref));
else
Snail_RemovePerk(client);
}
void Snail_ApplyPerk(int client, float fMultp){
switch(TF2_GetPlayerClass(client)){
case TFClass_Scout: {g_fBaseSpeed_Snail[client] = 400.0;}
case TFClass_Soldier: {g_fBaseSpeed_Snail[client] = 240.0;}
case TFClass_DemoMan: {g_fBaseSpeed_Snail[client] = 280.0;}
case TFClass_Heavy: {g_fBaseSpeed_Snail[client] = 230.0;}
case TFClass_Medic: {g_fBaseSpeed_Snail[client] = 320.0;}
default: {g_fBaseSpeed_Snail[client] = 300.0;}
}
TF2Attrib_SetByDefIndex(client, ATTRIB_SPEED, fMultp);
SetEntPropFloat(client, Prop_Send, "m_flMaxspeed", g_fBaseSpeed_Snail[client]*fMultp);
}
void Snail_RemovePerk(int client){
TF2Attrib_RemoveByDefIndex(client, ATTRIB_SPEED);
SetEntPropFloat(client, Prop_Send, "m_flMaxspeed", g_fBaseSpeed_Snail[client]);
}

View File

@@ -0,0 +1,163 @@
/*
This script is a part of RTD2 plugin and is not meant to work by itself.
If you were to edit anything here, you'd have to recompile rtd2.sp instead of this one.
*** HOW TO ADD A PERK ***
A quick note: This tutorial may not be kept up to date; for an updated one, go to the plugin's thread.
1. Set up:
a) Have <perkname>.sp in scripting/rtd.
b) Add it to the includes in scripting/rtd/#perks.sp.
c) Add a new section with a correct ID (highest one +1) to the config/rtd2_perks.cfg and set its settings.
2. Edit scripting/rtd/#manager.sp
a) In a function named ManagePerk() add a new case to the switch() with your perk's ID.
b) In the added case specify a function which is going to execute from <perkname>.sp with parameters:
1) @client - the client the perk should be applied to/removed from
2) @fSpecialPref - the optional "special" value in config/rtd2_perks.cfg
2) @enable - to specify whether the perk should be applied/removed
c) OPTIONAL: You can specify a function in your perk which should run at OnMapStart() in the Forward_OnMapStart() function.
You will need it if you'd want to, for example, precache a sound or loop through existing clients.
d) OPTIONAL: You can specify a function in your perk which should run at OnPlayerRunCmd() in the Forward_OnPlayerRunCmd() function.
You can use it if you'd need something to run each frame or on a certain button press.
NOTE: The forwarded client is guaranteed to be valid BUT NOT GUARANTEED IF THEY ARE ALIVE.
3. Script your perk:
a) Create a public function in <perkname>.sp with parameters @client, @iPref, @bool:apply as an example below
- This is the only function used to transfer info between the core and the include
- You don't need to include any includes that are in the rtd2.sp
b) NOTE: If you need to transfer the iPref to a different function, set it globally but remember to use an unique name
c) Name it AS SAME AS you named the function in the added case in the switch() in #manager.sp
d) From there, script the functionality like there's no tomorrow
e) You are free to use IsValidClient(). It returns false when:
- An incorrect client index is specified
- Client is not in game
- Client is fake (bot)
- Client is Coaching
4. Compile rtd2.sp and you're good to go!
*/
bool g_bCanSpawnDispenser[MAXPLAYERS+1] = {false, ...};
Handle g_iSpawnedDispensers[MAXPLAYERS+1] = INVALID_HANDLE;
int g_iDispenserLevel = 2;
bool g_bShouldDispenserStay = true;
int g_iMaxDispensers = 1;
public SpawnDispenser_Perk(int client, const char[] sPref, bool apply){
if(apply)
SpawnDispenser_ApplyPerk(client, sPref);
else
SpawnDispenser_RemovePerk(client);
}
void SpawnDispenser_ApplyPerk(int client, const char[] sPref){
SpawnDispenser_ProcessSettings(sPref);
if(g_iSpawnedDispensers[client] == INVALID_HANDLE)
g_iSpawnedDispensers[client] = CreateArray();
else
ClearArray(g_iSpawnedDispensers[client]);
g_bCanSpawnDispenser[client] = true;
PrintToChat(client, "%s %T", "\x07FFD700[RTD]\x01", "RTD2_Perk_Dispenser_Initialization", LANG_SERVER, 0x03, 0x01);
}
void SpawnDispenser_RemovePerk(int client){
g_bCanSpawnDispenser[client] = false;
if(g_bShouldDispenserStay)
return;
int iSize = GetArraySize(g_iSpawnedDispensers[client]);
for(int i = 0; i < iSize; i++){
int iEnt = EntRefToEntIndex(GetArrayCell(g_iSpawnedDispensers[client], i));
if(iEnt > MaxClients && IsValidEntity(iEnt))
AcceptEntityInput(iEnt, "Kill");
}
}
void SpawnDispenser_Voice(int client){
if(!g_bCanSpawnDispenser[client])
return;
float fPos[3];
if(GetClientLookPosition(client, fPos)){
if(CanBuildAtPos(fPos, false)){
float fDispenserAng[3], fClientAng[3];
GetClientEyeAngles(client, fClientAng);
fDispenserAng[1] = fClientAng[1];
PushArrayCell(g_iSpawnedDispensers[client], EntIndexToEntRef(SpawnDispenser(client, fPos, fDispenserAng, g_iDispenserLevel)));
int iSpawned = GetArraySize(g_iSpawnedDispensers[client]);
PrintToChat(client, "%s %T", "\x07FFD700[RTD]\x01", "RTD2_Perk_Dispenser_Spawned", LANG_SERVER, 0x03, iSpawned, g_iMaxDispensers, 0x01);
if(iSpawned >= g_iMaxDispensers)
if(g_bShouldDispenserStay)
ForceRemovePerk(client);
else
g_bCanSpawnDispenser[client] = false;
}
}
}
/*
The SpawnDispenser stock is taken from Pelipoika's TF2 Building Spawner EXTREME
https://forums.alliedmods.net/showthread.php?p=2148102
*/
stock int SpawnDispenser(int builder, float Position[3], float Angle[3], int level, int flags=4){
int dispenser = CreateEntityByName("obj_dispenser");
if(!IsValidEntity(dispenser)) return 0;
int iTeam = GetClientTeam(builder);
DispatchKeyValueVector(dispenser, "origin", Position);
DispatchKeyValueVector(dispenser, "angles", Angle);
SetEntProp(dispenser, Prop_Send, "m_iHighestUpgradeLevel", level);
SetEntProp(dispenser, Prop_Data, "m_spawnflags", flags);
SetEntProp(dispenser, Prop_Send, "m_bBuilding", 1);
DispatchSpawn(dispenser);
SetVariantInt(iTeam);
AcceptEntityInput(dispenser, "SetTeam");
SetEntProp(dispenser, Prop_Send, "m_nSkin", iTeam -2);
ActivateEntity(dispenser);
SetEntPropEnt(dispenser, Prop_Send, "m_hBuilder", builder);
return dispenser;
}
void SpawnDispenser_ProcessSettings(const char[] sSettings){
char[][] sPieces = new char[3][8];
ExplodeString(sSettings, ",", sPieces, 3, 8);
g_iDispenserLevel = StringToInt(sPieces[0]);
g_bShouldDispenserStay = StringToInt(sPieces[1]) > 0 ? true : false;
g_iMaxDispensers = StringToInt(sPieces[2]);
}

View File

@@ -0,0 +1,206 @@
/*
This script is a part of RTD2 plugin and is not meant to work by itself.
If you were to edit anything here, you'd have to recompile rtd2.sp instead of this one.
*** HOW TO ADD A PERK ***
A quick note: This tutorial may not be kept up to date; for an updated one, go to the plugin's thread.
1. Set up:
a) Have <perkname>.sp in scripting/rtd.
b) Add it to the includes in scripting/rtd/#perks.sp.
c) Add a new section with a correct ID (highest one +1) to the config/rtd2_perks.cfg and set its settings.
2. Edit scripting/rtd/#manager.sp
a) In a function named ManagePerk() add a new case to the switch() with your perk's ID.
b) In the added case specify a function which is going to execute from <perkname>.sp with parameters:
1) @client - the client the perk should be applied to/removed from
2) @fSpecialPref - the optional "special" value in config/rtd2_perks.cfg
2) @enable - to specify whether the perk should be applied/removed
c) OPTIONAL: You can specify a function in your perk which should run at OnMapStart() in the Forward_OnMapStart() function.
You will need it if you'd want to, for example, precache a sound or loop through existing clients.
d) OPTIONAL: You can specify a function in your perk which should run at OnPlayerRunCmd() in the Forward_OnPlayerRunCmd() function.
You can use it if you'd need something to run each frame or on a certain button press.
NOTE: The forwarded client is guaranteed to be valid BUT NOT GUARANTEED IF THEY ARE ALIVE.
3. Script your perk:
a) Create a public function in <perkname>.sp with parameters @client, @iPref, @bool:apply as an example below
- This is the only function used to transfer info between the core and the include
- You don't need to include any includes that are in the rtd2.sp
b) NOTE: If you need to transfer the iPref to a different function, set it globally but remember to use an unique name
c) Name it AS SAME AS you named the function in the added case in the switch() in #manager.sp
d) From there, script the functionality like there's no tomorrow
e) You are free to use IsValidClient(). It returns false when:
- An incorrect client index is specified
- Client is not in game
- Client is fake (bot)
- Client is Coaching
4. Compile rtd2.sp and you're good to go!
*/
bool g_bCanSpawnSentry[MAXPLAYERS+1] = {false, ...};
Handle g_hSpawnedSentries[MAXPLAYERS+1]= INVALID_HANDLE;
int g_iSentryLevel = 2;
bool g_bShouldStay = true;
int g_iMaxSentries = 1;
void SpawnSentry_Perk(int client, const char[] sPref, bool apply){
if(apply)
SpawnSentry_ApplyPerk(client, sPref);
else
SpawnSentry_RemovePerk(client);
}
void SpawnSentry_ApplyPerk(int client, const char[] sPref){
SpawnSentry_ProcessSettings(sPref);
if(g_hSpawnedSentries[client] == INVALID_HANDLE)
g_hSpawnedSentries[client] = CreateArray();
else
ClearArray(g_hSpawnedSentries[client]);
g_bCanSpawnSentry[client] = true;
PrintToChat(client, "%s %T", "\x07FFD700[RTD]\x01", "RTD2_Perk_Sentry_Initialization", LANG_SERVER, 0x03, 0x01);
}
void SpawnSentry_RemovePerk(int client){
g_bCanSpawnSentry[client] = false;
if(g_bShouldStay)
return;
int iSize = GetArraySize(g_hSpawnedSentries[client]);
for(int i = 0; i < iSize; i++){
int iEnt = EntRefToEntIndex(GetArrayCell(g_hSpawnedSentries[client], i));
if(iEnt > MaxClients && IsValidEntity(iEnt))
AcceptEntityInput(iEnt, "Kill");
}
}
void SpawnSentry_Voice(int client){
if(!g_bCanSpawnSentry[client])
return;
float fPos[3];
if(GetClientLookPosition(client, fPos)){
if(CanBuildAtPos(fPos, true)){
float fSentryAng[3], fClientAng[3];
GetClientEyeAngles(client, fClientAng);
fSentryAng[1] = fClientAng[1];
PushArrayCell(g_hSpawnedSentries[client], EntIndexToEntRef(SpawnSentry(client, fPos, fSentryAng, g_iSentryLevel > 0 ? g_iSentryLevel : 1, g_iSentryLevel < 1 ? true : false)));
int iSpawned = GetArraySize(g_hSpawnedSentries[client]);
PrintToChat(client, "%s %T", "\x07FFD700[RTD]\x01", "RTD2_Perk_Sentry_Spawned", LANG_SERVER, 0x03, iSpawned, g_iMaxSentries, 0x01);
if(iSpawned >= g_iMaxSentries)
if(g_bShouldStay)
ForceRemovePerk(client);
else
g_bCanSpawnSentry[client] = false;
}
}
}
/*
The SpawnSentry stock is taken from Pelipoika's TF2 Building Spawner EXTREME
https://forums.alliedmods.net/showthread.php?p=2148102
*/
stock int SpawnSentry(int builder, float Position[3], float Angle[3], int level, bool mini=false, bool disposable=false, int flags=4){
float m_vecMinsMini[3] = {-15.0, -15.0, 0.0}, m_vecMaxsMini[3] = {15.0, 15.0, 49.5};
float m_vecMinsDisp[3] = {-13.0, -13.0, 0.0}, m_vecMaxsDisp[3] = {13.0, 13.0, 42.9};
int sentry = CreateEntityByName("obj_sentrygun");
if(!IsValidEntity(sentry)) return 0;
int iTeam = GetClientTeam(builder);
SetEntPropEnt(sentry, Prop_Send, "m_hBuilder", builder);
SetVariantInt(iTeam);
AcceptEntityInput(sentry, "SetTeam");
DispatchKeyValueVector(sentry, "origin", Position);
DispatchKeyValueVector(sentry, "angles", Angle);
if(mini){
SetEntProp(sentry, Prop_Send, "m_bMiniBuilding", 1);
SetEntProp(sentry, Prop_Send, "m_iUpgradeLevel", level);
SetEntProp(sentry, Prop_Send, "m_iHighestUpgradeLevel", level);
SetEntProp(sentry, Prop_Data, "m_spawnflags", flags);
SetEntProp(sentry, Prop_Send, "m_bBuilding", 1);
SetEntProp(sentry, Prop_Send, "m_nSkin", level == 1 ? iTeam : iTeam -2);
DispatchSpawn(sentry);
SetVariantInt(100);
AcceptEntityInput(sentry, "SetHealth");
SetEntPropFloat(sentry, Prop_Send, "m_flModelScale", 0.75);
SetEntPropVector(sentry, Prop_Send, "m_vecMins", m_vecMinsMini);
SetEntPropVector(sentry, Prop_Send, "m_vecMaxs", m_vecMaxsMini);
}else if(disposable){
SetEntProp(sentry, Prop_Send, "m_bMiniBuilding", 1);
SetEntProp(sentry, Prop_Send, "m_bDisposableBuilding", 1);
SetEntProp(sentry, Prop_Send, "m_iUpgradeLevel", level);
SetEntProp(sentry, Prop_Send, "m_iHighestUpgradeLevel", level);
SetEntProp(sentry, Prop_Data, "m_spawnflags", flags);
SetEntProp(sentry, Prop_Send, "m_bBuilding", 1);
SetEntProp(sentry, Prop_Send, "m_nSkin", level == 1 ? iTeam : iTeam -2);
DispatchSpawn(sentry);
SetVariantInt(100);
AcceptEntityInput(sentry, "SetHealth");
SetEntPropFloat(sentry, Prop_Send, "m_flModelScale", 0.60);
SetEntPropVector(sentry, Prop_Send, "m_vecMins", m_vecMinsDisp);
SetEntPropVector(sentry, Prop_Send, "m_vecMaxs", m_vecMaxsDisp);
}else{
SetEntProp(sentry, Prop_Send, "m_iUpgradeLevel", level);
SetEntProp(sentry, Prop_Send, "m_iHighestUpgradeLevel", level);
SetEntProp(sentry, Prop_Data, "m_spawnflags", flags);
SetEntProp(sentry, Prop_Send, "m_bBuilding", 1);
SetEntProp(sentry, Prop_Send, "m_nSkin", iTeam -2);
DispatchSpawn(sentry);
}
return sentry;
}
void SpawnSentry_ProcessSettings(const char[] sSettings){
char[][] sPieces = new char[3][8];
ExplodeString(sSettings, ",", sPieces, 3, 8);
g_iSentryLevel = StringToInt(sPieces[0]);
g_bShouldStay = StringToInt(sPieces[1]) > 0 ? true : false;
g_iMaxSentries = StringToInt(sPieces[2]);
}

View File

@@ -0,0 +1,61 @@
/*
This script is a part of RTD2 plugin and is not meant to work by itself.
If you were to edit anything here, you'd have to recompile rtd2.sp instead of this one.
*** HOW TO ADD A PERK ***
A quick note: This tutorial may not be kept up to date; for an updated one, go to the plugin's thread.
1. Set up:
a) Have <perkname>.sp in scripting/rtd.
b) Add it to the includes in scripting/rtd/#perks.sp.
c) Add a new section with a correct ID (highest one +1) to the config/rtd2_perks.cfg and set its settings.
2. Edit scripting/rtd/#manager.sp
a) In a function named ManagePerk() add a new case to the switch() with your perk's ID.
b) In the added case specify a function which is going to execute from <perkname>.sp with parameters:
1) @client - the client the perk should be applied to/removed from
2) @fSpecialPref - the optional "special" value in config/rtd2_perks.cfg
2) @enable - to specify whether the perk should be applied/removed
c) OPTIONAL: You can specify a function in your perk which should run at OnMapStart() in the Forward_OnMapStart() function.
You will need it if you'd want to, for example, precache a sound or loop through existing clients.
d) OPTIONAL: You can specify a function in your perk which should run at OnPlayerRunCmd() in the Forward_OnPlayerRunCmd() function.
You can use it if you'd need something to run each frame or on a certain button press.
NOTE: The forwarded client is guaranteed to be valid BUT NOT GUARANTEED IF THEY ARE ALIVE.
3. Script your perk:
a) Create a public function in <perkname>.sp with parameters @client, @iPref, @bool:apply as an example below
- This is the only function used to transfer info between the core and the include
- You don't need to include any includes that are in the rtd2.sp
b) NOTE: If you need to transfer the iPref to a different function, set it globally but remember to use an unique name
c) Name it AS SAME AS you named the function in the added case in the switch() in #manager.sp
d) From there, script the functionality like there's no tomorrow
e) You are free to use IsValidClient(). It returns false when:
- An incorrect client index is specified
- Client is not in game
- Client is fake (bot)
- Client is Coaching
4. Compile rtd2.sp and you're good to go!
*/
void StripToMelee_Perk(int client, const char[] sPref, bool apply){
if(!apply)
return;
TF2_RemoveWeaponSlot(client, 0);
TF2_RemoveWeaponSlot(client, 1);
int iWeapon = GetPlayerWeaponSlot(client, 2);
if(iWeapon > MaxClients && IsValidEntity(iWeapon))
SetEntPropEnt(client, Prop_Send, "m_hActiveWeapon", iWeapon);
TF2_RemoveWeaponSlot(client, 3);
TF2_RemoveWeaponSlot(client, 4);
if(StringToInt(sPref) > 0)
SetEntityHealth(client, GetEntProp(client, Prop_Data, "m_iMaxHealth"));
}

View File

@@ -0,0 +1,60 @@
/*
This script is a part of RTD2 plugin and is not meant to work by itself.
If you were to edit anything here, you'd have to recompile rtd2.sp instead of this one.
*** HOW TO ADD A PERK ***
A quick note: This tutorial may not be kept up to date; for an updated one, go to the plugin's thread.
1. Set up:
a) Have <perkname>.sp in scripting/rtd.
b) Add it to the includes in scripting/rtd/#perks.sp.
c) Add a new section with a correct ID (highest one +1) to the config/rtd2_perks.cfg and set its settings.
2. Edit scripting/rtd/#manager.sp
a) In a function named ManagePerk() add a new case to the switch() with your perk's ID.
b) In the added case specify a function which is going to execute from <perkname>.sp with parameters:
1) @client - the client the perk should be applied to/removed from
2) @fSpecialPref - the optional "special" value in config/rtd2_perks.cfg
2) @enable - to specify whether the perk should be applied/removed
c) OPTIONAL: You can specify a function in your perk which should run at OnMapStart() in the Forward_OnMapStart() function.
You will need it if you'd want to, for example, precache a sound or loop through existing clients.
d) OPTIONAL: You can specify a function in your perk which should run at OnPlayerRunCmd() in the Forward_OnPlayerRunCmd() function.
You can use it if you'd need something to run each frame or on a certain button press.
NOTE: The forwarded client is guaranteed to be valid BUT NOT GUARANTEED IF THEY ARE ALIVE.
3. Script your perk:
a) Create a public function in <perkname>.sp with parameters @client, @iPref, @bool:apply as an example below
- This is the only function used to transfer info between the core and the include
- You don't need to include any includes that are in the rtd2.sp
b) NOTE: If you need to transfer the iPref to a different function, set it globally but remember to use an unique name
c) Name it AS SAME AS you named the function in the added case in the switch() in #manager.sp
d) From there, script the functionality like there's no tomorrow
e) You are free to use IsValidClient(). It returns false when:
- An incorrect client index is specified
- Client is not in game
- Client is fake (bot)
- Client is Coaching
4. Compile rtd2.sp and you're good to go!
*/
float g_fBaseStrongGravity[MAXPLAYERS+1] = {0.0, ...};
void StrongGravity_Perk(int client, const char[] sPref, bool apply){
if(apply)
StrongGravity_ApplyPerk(client, StringToFloat(sPref));
else
SetEntityGravity(client, g_fBaseStrongGravity[client]);
}
void StrongGravity_ApplyPerk(int client, float fMultp){
g_fBaseStrongGravity[client] = GetEntityGravity(client);
SetEntityGravity(client, fMultp);
}

View File

@@ -0,0 +1,65 @@
/*
This script is a part of RTD2 plugin and is not meant to work by itself.
If you were to edit anything here, you'd have to recompile rtd2.sp instead of this one.
*** HOW TO ADD A PERK ***
A quick note: This tutorial may not be kept up to date; for an updated one, go to the plugin's thread.
1. Set up:
a) Have <perkname>.sp in scripting/rtd.
b) Add it to the includes in scripting/rtd/#perks.sp.
c) Add a new section with a correct ID (highest one +1) to the config/rtd2_perks.cfg and set its settings.
2. Edit scripting/rtd/#manager.sp
a) In a function named ManagePerk() add a new case to the switch() with your perk's ID.
b) In the added case specify a function which is going to execute from <perkname>.sp with parameters:
1) @client - the client the perk should be applied to/removed from
2) @fSpecialPref - the optional "special" value in config/rtd2_perks.cfg
2) @enable - to specify whether the perk should be applied/removed
c) OPTIONAL: You can specify a function in your perk which should run at OnMapStart() in the Forward_OnMapStart() function.
You will need it if you'd want to, for example, precache a sound or loop through existing clients.
d) OPTIONAL: You can specify a function in your perk which should run at OnPlayerRunCmd() in the Forward_OnPlayerRunCmd() function.
You can use it if you'd need something to run each frame or on a certain button press.
NOTE: The forwarded client is guaranteed to be valid BUT NOT GUARANTEED IF THEY ARE ALIVE.
3. Script your perk:
a) Create a public function in <perkname>.sp with parameters @client, @iPref, @bool:apply as an example below
- This is the only function used to transfer info between the core and the include
- You don't need to include any includes that are in the rtd2.sp
b) NOTE: If you need to transfer the iPref to a different function, set it globally but remember to use an unique name
c) Name it AS SAME AS you named the function in the added case in the switch() in #manager.sp
d) From there, script the functionality like there's no tomorrow
e) You are free to use IsValidClient(). It returns false when:
- An incorrect client index is specified
- Client is not in game
- Client is fake (bot)
- Client is Coaching
4. Compile rtd2.sp and you're good to go!
*/
bool g_bHasStrongRecoil[MAXPLAYERS+1] = {false, ...};
public void StrongRecoil_Perk(int client, const char[] sPref, bool apply){
g_bHasStrongRecoil[client] = apply;
}
void StrongRecoil_CritCheck(int client, int iWeapon){
if(!g_bHasStrongRecoil[client])
return;
if(GetPlayerWeaponSlot(client, 2) == iWeapon)
return;
float fShake[3];
fShake[0] = GetRandomFloat(-20.0, -80.0);
fShake[1] = GetRandomFloat(-25.0, 25.0);
fShake[2] = GetRandomFloat(-25.0, 25.0);
SetEntPropVector(client, Prop_Send, "m_vecPunchAngle", fShake);
}

View File

@@ -0,0 +1,111 @@
/*
This script is a part of RTD2 plugin and is not meant to work by itself.
If you were to edit anything here, you'd have to recompile rtd2.sp instead of this one.
*** HOW TO ADD A PERK ***
A quick note: This tutorial may not be kept up to date; for an updated one, go to the plugin's thread.
1. Set up:
a) Have <perkname>.sp in scripting/rtd.
b) Add it to the includes in scripting/rtd/#perks.sp.
c) Add a new section with a correct ID (highest one +1) to the config/rtd2_perks.cfg and set its settings.
2. Edit scripting/rtd/#manager.sp
a) In a function named ManagePerk() add a new case to the switch() with your perk's ID.
b) In the added case specify a function which is going to execute from <perkname>.sp with parameters:
1) @client - the client the perk should be applied to/removed from
2) @fSpecialPref - the optional "special" value in config/rtd2_perks.cfg
2) @enable - to specify whether the perk should be applied/removed
c) OPTIONAL: You can specify a function in your perk which should run at OnMapStart() in the Forward_OnMapStart() function.
You will need it if you'd want to, for example, precache a sound or loop through existing clients.
d) OPTIONAL: You can specify a function in your perk which should run at OnPlayerRunCmd() in the Forward_OnPlayerRunCmd() function.
You can use it if you'd need something to run each frame or on a certain button press.
NOTE: The forwarded client is guaranteed to be valid BUT NOT GUARANTEED IF THEY ARE ALIVE.
3. Script your perk:
a) Create a public function in <perkname>.sp with parameters @client, @iPref, @bool:apply as an example below
- This is the only function used to transfer info between the core and the include
- You don't need to include any includes that are in the rtd2.sp
b) NOTE: If you need to transfer the iPref to a different function, set it globally but remember to use an unique name
c) Name it AS SAME AS you named the function in the added case in the switch() in #manager.sp
d) From there, script the functionality like there's no tomorrow
e) You are free to use IsValidClient(). It returns false when:
- An incorrect client index is specified
- Client is not in game
- Client is fake (bot)
- Client is Coaching
4. Compile rtd2.sp and you're good to go!
*/
bool g_bIsSuffocating[MAXPLAYERS+1] = {false, ...};
float g_fSuffocationStart = 12.0;
float g_fSuffocationInterval = 1.0;
float g_fSuffocationDamage = 5.0;
void Suffocation_Perk(int client, const char[] sPref, bool apply){
if(apply)
Suffocation_ApplyPerk(client, sPref);
else
g_bIsSuffocating[client] = false;
}
void Suffocation_ApplyPerk(client, const char[] sPref){
Suffocation_ProcessSettings(sPref);
g_bIsSuffocating[client] = true;
CreateTimer(g_fSuffocationStart, Timer_Suffocation_Begin, GetClientSerial(client));
}
public Action Timer_Suffocation_Begin(Handle hTimer, int iSerial){
int client = GetClientFromSerial(iSerial);
if(!IsValidClient(client))
return Plugin_Stop;
if(!g_bIsSuffocating[client])
return Plugin_Stop;
SDKHooks_TakeDamage(client, 0, 0, g_fSuffocationDamage, DMG_DROWN);
CreateTimer(g_fSuffocationInterval, Timer_Suffocation_Cont, GetClientSerial(client), TIMER_REPEAT);
return Plugin_Stop;
}
public Action Timer_Suffocation_Cont(Handle hTimer, int iSerial){
int client = GetClientFromSerial(iSerial);
if(!IsValidClient(client))
return Plugin_Stop;
if(!g_bIsSuffocating[client])
return Plugin_Stop;
SDKHooks_TakeDamage(client, 0, 0, g_fSuffocationDamage, DMG_DROWN);
return Plugin_Continue;
}
void Suffocation_ProcessSettings(const char[] sSettings){
char[][] sPieces = new char[3][8];
ExplodeString(sSettings, ",", sPieces, 3, 8);
g_fSuffocationStart = StringToFloat(sPieces[0]);
g_fSuffocationInterval = StringToFloat(sPieces[1]);
g_fSuffocationDamage = StringToFloat(sPieces[2]);
}

View File

@@ -0,0 +1,210 @@
/*
This script is a part of RTD2 plugin and is not meant to work by itself.
If you were to edit anything here, you'd have to recompile rtd2.sp instead of this one.
*** HOW TO ADD A PERK ***
A quick note: This tutorial may not be kept up to date; for an updated one, go to the plugin's thread.
https://forums.alliedmods.net/showpost.php?p=2389730&postcount=2
1. Set up:
a) Have <perkname>.sp in scripting/rtd.
b) Add it to the includes in scripting/rtd/#perks.sp.
c) Add a new section with a correct ID (highest one +1) to the config/rtd2_perks.cfg and set its settings.
2. Edit scripting/rtd/#manager.sp
a) In a function named ManagePerk() add a new case to the switch() with your perk's ID.
b) In the added case specify a function which is going to execute from <perkname>.sp with parameters:
1) @client - the client the perk should be applied to/removed from
2) @fSpecialPref - the optional "special" value in config/rtd2_perks.cfg
2) @enable - to specify whether the perk should be applied/removed
c) OPTIONAL: You can specify a function in your perk which should run at OnMapStart() in the Forward_OnMapStart() function.
You will need it if you'd want to, for example, precache a sound or loop through existing clients.
d) OPTIONAL: You can specify a function in your perk which should run at OnPlayerRunCmd() in the Forward_OnPlayerRunCmd() function.
You can use it if you'd need something to run each frame or on a certain button press.
NOTE: The forwarded client is guaranteed to be valid BUT NOT GUARANTEED IF THEY ARE ALIVE.
3. Script your perk:
a) Create a public function in <perkname>.sp with parameters @client, @iPref, @bool:apply as an example below
- This is the only function used to transfer info between the core and the include
- You don't need to include any includes that are in the rtd2.sp
b) NOTE: If you need to transfer the iPref to a different function, set it globally but remember to use an unique name
c) Name it AS SAME AS you named the function in the added case in the switch() in #manager.sp
d) From there, script the functionality like there's no tomorrow
e) You are free to use IsValidClient(). It returns false when:
- An incorrect client index is specified
- Client is not in game
- Client is fake (bot)
- Client is Coaching
4. Compile rtd2.sp and you're good to go!
*/
#define MINICRIT TFCond_Buffed
#define FULLCRIT TFCond_CritOnFirstBlood
float g_fTeamCritsRange = 270.0;
bool g_bTeamCritsFull = true;
bool g_bHasTeamCriticals[MAXPLAYERS+1] = {false, ...};
int g_iCritBoostEnt[MAXPLAYERS+1][MAXPLAYERS+1];
int g_iCritBoostsGetting[MAXPLAYERS+1] = {0, ...};
void TeamCriticals_Perk(int client, const char[] sPref, bool apply){
if(apply)
TeamCriticals_ApplyPerk(client, sPref);
else
TeamCriticals_RemovePerk(client);
}
void TeamCriticals_ApplyPerk(int client, const char[] sPref){
TeamCriticals_ProcessSettings(sPref);
g_bHasTeamCriticals[client] = true;
TF2_AddCondition(client, g_bTeamCritsFull ? FULLCRIT : MINICRIT);
g_iCritBoostsGetting[client]++;
CreateTimer(0.25, Timer_DrawBeamsFor, GetClientSerial(client), TIMER_REPEAT);
}
void TeamCriticals_RemovePerk(int client){
g_bHasTeamCriticals[client] = false;
TF2_RemoveCondition(client, g_bTeamCritsFull ? FULLCRIT : MINICRIT);
g_iCritBoostsGetting[client]--;
for(int i = 1; i <= MaxClients; i++){
if(g_iCritBoostEnt[client][i] > MaxClients)
TeamCriticals_SetCritBoost(client, i, false, 0);
}
}
public Action Timer_DrawBeamsFor(Handle hTimer, int iSerial){
int client = GetClientFromSerial(iSerial);
if(!IsValidClient(client))
return Plugin_Stop;
if(!g_bHasTeamCriticals[client])
return Plugin_Stop;
TeamCriticals_DrawBeamsFor(client);
return Plugin_Continue;
}
void TeamCriticals_DrawBeamsFor(int client){
int iTeam = GetClientTeam(client);
for(int i = 1; i <= MaxClients; i++){
if(i == client)
continue;
if(!IsClientInGame(i)){
if(g_iCritBoostEnt[client][i] > MaxClients)
TeamCriticals_SetCritBoost(client, i, false, iTeam);
continue;
}
if(!TeamCriticals_IsValidTarget(client, i, iTeam)){
if(g_iCritBoostEnt[client][i] > MaxClients)
TeamCriticals_SetCritBoost(client, i, false, iTeam);
continue;
}
if(!CanEntitySeeTarget(client, i)){
if(g_iCritBoostEnt[client][i] > MaxClients)
TeamCriticals_SetCritBoost(client, i, false, iTeam);
continue;
}
if(g_iCritBoostEnt[client][i] <= MaxClients)
TeamCriticals_SetCritBoost(client, i, true, iTeam);
}
}
bool TeamCriticals_IsValidTarget(int client, int iTrg, int iClientTeam){
float fPos[3], fEndPos[3];
GetClientAbsOrigin(client, fPos);
GetClientAbsOrigin(iTrg, fEndPos);
if(GetVectorDistance(fPos, fEndPos) > g_fTeamCritsRange)
return false;
if(TF2_IsPlayerInCondition(iTrg, TFCond_Cloaked))
return false;
int iEndTeam = GetClientTeam(iTrg);
if(TF2_IsPlayerInCondition(iTrg, TFCond_Disguised)){
if(iClientTeam == iEndTeam)
return false;
else
return true;
}
return (iClientTeam == iEndTeam);
}
void TeamCriticals_SetCritBoost(int client, int iTrg, bool bSet, int iTeam){
g_iCritBoostsGetting[iTrg] += bSet ? 1 : -1;
if(bSet){
g_iCritBoostEnt[client][iTrg] = ConnectWithBeam(client, iTrg, iTeam == 2 ? 255 : 64, 64, iTeam == 2 ? 64 : 255);
if(g_iCritBoostsGetting[iTrg] < 2)
TF2_AddCondition(iTrg, g_bTeamCritsFull ? FULLCRIT : MINICRIT);
}else{
if(IsValidEntity(g_iCritBoostEnt[client][iTrg]))
AcceptEntityInput(g_iCritBoostEnt[client][iTrg], "Kill");
g_iCritBoostEnt[client][iTrg] = 0;
if(g_iCritBoostsGetting[iTrg] < 1)
TF2_RemoveCondition(iTrg, g_bTeamCritsFull ? FULLCRIT : MINICRIT);
}
}
void TeamCriticals_ProcessSettings(const char[] sSettings){
char[][] sPieces = new char[2][8];
ExplodeString(sSettings, ",", sPieces, 2, 8);
g_fTeamCritsRange = StringToFloat(sPieces[0]);
g_bTeamCritsFull = StringToInt(sPieces[1]) > 0 ? true : false;
}

296
scripting/rtd/timebomb.sp Normal file
View File

@@ -0,0 +1,296 @@
/*
This script is a part of RTD2 plugin and is not meant to work by itself.
If you were to edit anything here, you'd have to recompile rtd2.sp instead of this one.
*** HOW TO ADD A PERK ***
A quick note: This tutorial may not be kept up to date; for an updated one, go to the plugin's thread.
1. Set up:
a) Have <perkname>.sp in scripting/rtd.
b) Add it to the includes in scripting/rtd/#perks.sp.
c) Add a new section with a correct ID (highest one +1) to the config/rtd2_perks.cfg and set its settings.
2. Edit scripting/rtd/#manager.sp
a) In a function named ManagePerk() add a new case to the switch() with your perk's ID.
b) In the added case specify a function which is going to execute from <perkname>.sp with parameters:
1) @client - the client the perk should be applied to/removed from
2) @fSpecialPref - the optional "special" value in config/rtd2_perks.cfg
2) @enable - to specify whether the perk should be applied/removed
c) OPTIONAL: You can specify a function in your perk which should run at OnMapStart() in the Forward_OnMapStart() function.
You will need it if you'd want to, for example, precache a sound or loop through existing clients.
d) OPTIONAL: You can specify a function in your perk which should run at OnPlayerRunCmd() in the Forward_OnPlayerRunCmd() function.
You can use it if you'd need something to run each frame or on a certain button press.
NOTE: The forwarded client is guaranteed to be valid BUT NOT GUARANTEED IF THEY ARE ALIVE.
3. Script your perk:
a) Create a public function in <perkname>.sp with parameters @client, @iPref, @bool:apply as an example below
- This is the only function used to transfer info between the core and the include
- You don't need to include any includes that are in the rtd2.sp
b) NOTE: If you need to transfer the iPref to a different function, set it globally but remember to use an unique name
c) Name it AS SAME AS you named the function in the added case in the switch() in #manager.sp
d) From there, script the functionality like there's no tomorrow
e) You are free to use IsValidClient(). It returns false when:
- An incorrect client index is specified
- Client is not in game
- Client is fake (bot)
- Client is Coaching
4. Compile rtd2.sp and you're good to go!
*/
#define MODEL_BOMB "models/props_lakeside_event/bomb_temp_hat.mdl"
#define SOUND_TIMEBOMB_TICK "buttons/button17.wav"
#define SOUND_TIMEBOMB_GOFF "weapons/cguard/charging.wav"
#define SOUND_EXPLODE "weapons/explode3.wav"
#define TICK_SLOW 0.75
#define TICK_FAST 0.35
int iTimebombTicks = 10;
float fTimebombRadius = 512.0;
float g_fTimebombDamage = 270.0;
bool g_bHasTimebomb[MAXPLAYERS+1] = {false, ...};
int g_iTimebombClientTicks[MAXPLAYERS+1] = {0, ...};
float g_fTimebombClientBeeps[MAXPLAYERS+1] = {TICK_SLOW, ...};
int g_iTimebombHead[MAXPLAYERS+1] = {0, ...};
int g_iTimebombState[MAXPLAYERS+1] = {0, ...};
int g_iTimebombFlame[MAXPLAYERS+1] = {0, ...};
void Timebomb_Start(){
PrecacheModel(MODEL_BOMB);
PrecacheSound(SOUND_EXPLODE);
PrecacheSound(SOUND_TIMEBOMB_TICK);
PrecacheSound(SOUND_TIMEBOMB_GOFF);
}
void Timebomb_Perk(int client, const char[] sPref, bool apply){
if(!apply)
return;
g_bHasTimebomb[client] = true;
Timebomb_ProcessSettings(sPref);
if(g_iTimebombHead[client] <= MaxClients)
g_iTimebombHead[client] = Timebomb_SpawnBombHead(client);
int iSerial = GetClientSerial(client);
CreateTimer(1.0, Timer_Timebomb_Tick, iSerial, TIMER_REPEAT);
SetVariantInt(1);
AcceptEntityInput(client, "SetForcedTauntCam");
}
public Action Timer_Timebomb_Tick(Handle hTimer, int iSerial){
int client = GetClientFromSerial(iSerial);
if(!IsValidClient(client))
return Plugin_Stop;
if(!g_bHasTimebomb[client])
return Plugin_Stop;
g_iTimebombClientTicks[client]++;
if(g_iTimebombHead[client] > MaxClients && IsValidEntity(g_iTimebombHead[client]))
if(g_iTimebombClientTicks[client] >= RoundToFloor(iTimebombTicks*0.3))
if(g_iTimebombClientTicks[client] < RoundToFloor(iTimebombTicks*0.7))
Timebomb_BombState(client, 1);
else Timebomb_BombState(client, 2);
if(g_iTimebombClientTicks[client] == iTimebombTicks-1)
EmitSoundToAll(SOUND_TIMEBOMB_GOFF, client);
else if(g_iTimebombClientTicks[client] >= iTimebombTicks){
Timebomb_Explode(client);
return Plugin_Stop;
}
return Plugin_Continue;
}
public Action Timer_Timebomb_Beep(Handle hTimer, int iSerial){
int client = GetClientFromSerial(iSerial);
if(!IsValidClient(client))
return Plugin_Stop;
if(!g_bHasTimebomb[client])
return Plugin_Stop;
EmitSoundToAll(SOUND_TIMEBOMB_TICK, client);
CreateTimer(g_fTimebombClientBeeps[client], Timer_Timebomb_Beep, GetClientSerial(client));
return Plugin_Stop;
}
void Timebomb_BombState(int client, int iState){
if(iState == g_iTimebombState[client])
return;
switch(iState){
case 1:{
EmitSoundToAll(SOUND_TIMEBOMB_TICK, client);
g_fTimebombClientBeeps[client] = TICK_SLOW;
CreateTimer(g_fTimebombClientBeeps[client], Timer_Timebomb_Beep, GetClientSerial(client));
}
case 2:{
g_fTimebombClientBeeps[client] = TICK_FAST;
}
}
SetEntProp(g_iTimebombHead[client], Prop_Send, "m_nSkin", g_iTimebombState[client]+1);
g_iTimebombState[client] = iState;
}
void Timebomb_OnRemovePerk(int client){
if(g_bHasTimebomb[client])
Timebomb_Explode(client, true);
}
void Timebomb_Explode(int client, bool bSilent=false){
SetVariantInt(0);
AcceptEntityInput(client, "SetForcedTauntCam");
g_iTimebombClientTicks[client] = 0;
g_bHasTimebomb[client] = false;
g_fTimebombClientBeeps[client] = TICK_SLOW;
g_iTimebombState[client] = 0;
if(g_iTimebombHead[client] > MaxClients && IsValidEntity(g_iTimebombHead[client]))
AcceptEntityInput(g_iTimebombHead[client], "Kill");
if(g_iTimebombFlame[client] > MaxClients && IsValidEntity(g_iTimebombFlame[client]))
AcceptEntityInput(g_iTimebombFlame[client], "Kill");
g_iTimebombHead[client] = 0;
g_iTimebombFlame[client] = 0;
if(bSilent)
return;
float fDamage, fPos[3]; GetClientAbsOrigin(client, fPos);
int iPlayerDamage;
for(int i = 1; i <= MaxClients; i++){
if(i == client || !IsClientInGame(i) || !IsPlayerAlive(i))
continue;
if(!CanPlayerBeHurt(i, client))
continue;
if(!CanEntitySeeTarget(client, i))
continue;
float fPosTarget[3];
GetClientAbsOrigin(i, fPosTarget);
if(GetVectorDistance(fPos, fPosTarget) <= fTimebombRadius){
fDamage = g_fTimebombDamage;
iPlayerDamage += RoundToFloor(fDamage);
SDKHooks_TakeDamage(i, 0, client, fDamage, DMG_PREVENT_PHYSICS_FORCE|DMG_CRUSH|DMG_ALWAYSGIB|DMG_BLAST);
}
}
int iShockwave = CreateParticle(client, "rd_robot_explosion_shockwave");
CreateTimer(1.0, Timer_TimebombRemoveTempParticle, EntIndexToEntRef(iShockwave));
int iExplosion = CreateParticle(client, "rd_robot_explosion");
CreateTimer(1.0, Timer_TimebombRemoveTempParticle, EntIndexToEntRef(iExplosion));
PrintToChat(client, "%s %T", "\x07FFD700[RTD]\x01", "RTD2_Perk_Timebomb_Damage", LANG_SERVER, 0x03, iPlayerDamage, 0x01);
EmitSoundToAll(SOUND_EXPLODE, client);
FakeClientCommandEx(client, "explode");
}
public Action Timer_TimebombRemoveTempParticle(Handle hTimer, int iRef){
int iEnt = EntRefToEntIndex(iRef);
if(iEnt <= MaxClients)
return Plugin_Stop;
if(!IsValidEntity(iEnt))
return Plugin_Stop;
AcceptEntityInput(iEnt, "Kill");
return Plugin_Stop;
}
int Timebomb_SpawnBombHead(int client){
int iBomb = CreateEntityByName("prop_dynamic");
DispatchKeyValue(iBomb, "model", MODEL_BOMB);
DispatchSpawn(iBomb);
SetVariantString("!activator");
AcceptEntityInput(iBomb, "SetParent", client, -1, 0);
TFClassType clsPlayer = TF2_GetPlayerClass(client);
if(clsPlayer == TFClass_Pyro || clsPlayer == TFClass_Engineer)
SetVariantString("OnUser1 !self,SetParentAttachment,head,0.0,-1");
else
SetVariantString("OnUser1 !self,SetParentAttachment,eyes,0.0,-1");
AcceptEntityInput(iBomb, "AddOutput");
AcceptEntityInput(iBomb, "FireUser1");
float fOffs[3];
fOffs[2] = 64.0;
g_iTimebombFlame[client] = CreateParticle(client, "burningplayer_corpse", true, "", fOffs);
return iBomb;
}
void Timebomb_ProcessSettings(const char[] sSettings){
char[][] sPieces = new char[3][8];
ExplodeString(sSettings, ",", sPieces, 3, 8);
iTimebombTicks = StringToInt(sPieces[0]);
fTimebombRadius = StringToFloat(sPieces[1]);
g_fTimebombDamage = StringToFloat(sPieces[2]);
}

100
scripting/rtd/tinymann.sp Normal file
View File

@@ -0,0 +1,100 @@
/*
This script is a part of RTD2 plugin and is not meant to work by itself.
If you were to edit anything here, you'd have to recompile rtd2.sp instead of this one.
*** HOW TO ADD A PERK ***
A quick note: This tutorial may not be kept up to date; for an updated one, go to the plugin's thread.
1. Set up:
a) Have <perkname>.sp in scripting/rtd.
b) Add it to the includes in scripting/rtd/#perks.sp.
c) Add a new section with a correct ID (highest one +1) to the config/rtd2_perks.cfg and set its settings.
2. Edit scripting/rtd/#manager.sp
a) In a function named ManagePerk() add a new case to the switch() with your perk's ID.
b) In the added case specify a function which is going to execute from <perkname>.sp with parameters:
1) @client - the client the perk should be applied to/removed from
2) @fSpecialPref - the optional "special" value in config/rtd2_perks.cfg
2) @enable - to specify whether the perk should be applied/removed
c) OPTIONAL: You can specify a function in your perk which should run at OnMapStart() in the Forward_OnMapStart() function.
You will need it if you'd want to, for example, precache a sound or loop through existing clients.
d) OPTIONAL: You can specify a function in your perk which should run at OnPlayerRunCmd() in the Forward_OnPlayerRunCmd() function.
You can use it if you'd need something to run each frame or on a certain button press.
NOTE: The forwarded client is guaranteed to be valid BUT NOT GUARANTEED IF THEY ARE ALIVE.
3. Script your perk:
a) Create a public function in <perkname>.sp with parameters @client, @iPref, @bool:apply as an example below
- This is the only function used to transfer info between the core and the include
- You don't need to include any includes that are in the rtd2.sp
b) NOTE: If you need to transfer the iPref to a different function, set it globally but remember to use an unique name
c) Name it AS SAME AS you named the function in the added case in the switch() in #manager.sp
d) From there, script the functionality like there's no tomorrow
e) You are free to use IsValidClient(). It returns false when:
- An incorrect client index is specified
- Client is not in game
- Client is fake (bot)
- Client is Coaching
4. Compile rtd2.sp and you're good to go!
*/
float g_fBaseTinyMann[MAXPLAYERS+1] = {1.0, ...};
bool g_bIsTinyMann[MAXPLAYERS+1] = {false, ...};
float g_fTinyMannScale = 0.15;
void TinyMann_Start(){
AddNormalSoundHook(NormalSHook:TinyMann_SoundHook);
}
void TinyMann_Perk(int client, const char[] sPref, bool apply){
if(apply)
TinyMann_ApplyPerk(client, StringToFloat(sPref));
else
TinyMann_RemovePerk(client);
}
void TinyMann_ApplyPerk(int client, float fMultiplayer){
g_bIsTinyMann[client] = true;
g_fTinyMannScale = fMultiplayer;
g_fBaseTinyMann[client] = GetEntPropFloat(client, Prop_Send, "m_flModelScale");
SetEntPropFloat(client, Prop_Send, "m_flModelScale", fMultiplayer);
}
void TinyMann_RemovePerk(int client){
g_bIsTinyMann[client] = false;
SetEntPropFloat(client, Prop_Send, "m_flModelScale", g_fBaseTinyMann[client]);
FixPotentialStuck(client);
}
public Action TinyMann_SoundHook(int iClients[64], int &iClientsNum, char sSample[PLATFORM_MAX_PATH], int &iEntity, int &iChannel, float &fVolume, int &iLevel, int &iPitch, int &iSoundFlags){
if(StrContains(sSample, "/footstep", false) > -1)
return Plugin_Continue;
if(iChannel != SNDCHAN_VOICE) return Plugin_Continue;
if(!IsValidClient(iEntity)) return Plugin_Continue;
if(!g_bIsTinyMann[iEntity]) return Plugin_Continue;
int iTempPitch = RoundToFloor(100.0 *Pow(g_fTinyMannScale, -1.0));
if(iTempPitch < 25) iTempPitch = 25;
else if(iTempPitch > 250) iTempPitch = 250;
iPitch = iTempPitch;
iSoundFlags |= SND_CHANGEPITCH;
return Plugin_Changed;
}

145
scripting/rtd/toxic.sp Normal file
View File

@@ -0,0 +1,145 @@
/*
This script is a part of RTD2 plugin and is not meant to work by itself.
If you were to edit anything here, you'd have to recompile rtd2.sp instead of this one.
*** HOW TO ADD A PERK ***
A quick note: This tutorial may not be kept up to date; for an updated one, go to the plugin's thread.
1. Set up:
a) Have <perkname>.sp in scripting/rtd.
b) Add it to the includes in scripting/rtd/#perks.sp.
c) Add a new section with a correct ID (highest one +1) to the config/rtd2_perks.cfg and set its settings.
2. Edit scripting/rtd/#manager.sp
a) In a function named ManagePerk() add a new case to the switch() with your perk's ID.
b) In the added case specify a function which is going to execute from <perkname>.sp with parameters:
1) @client - the client the perk should be applied to/removed from
2) @fSpecialPref - the optional "special" value in config/rtd2_perks.cfg
2) @enable - to specify whether the perk should be applied/removed
c) OPTIONAL: You can specify a function in your perk which should run at OnMapStart() in the Forward_OnMapStart() function.
You will need it if you'd want to, for example, precache a sound or loop through existing clients.
d) OPTIONAL: You can specify a function in your perk which should run at OnPlayerRunCmd() in the Forward_OnPlayerRunCmd() function.
You can use it if you'd need something to run each frame or on a certain button press.
NOTE: The forwarded client is guaranteed to be valid BUT NOT GUARANTEED IF THEY ARE ALIVE.
3. Script your perk:
a) Create a public function in <perkname>.sp with parameters @client, @iPref, @bool:apply as an example below
- This is the only function used to transfer info between the core and the include
- You don't need to include any includes that are in the rtd2.sp
b) NOTE: If you need to transfer the iPref to a different function, set it globally but remember to use an unique name
c) Name it AS SAME AS you named the function in the added case in the switch() in #manager.sp
d) From there, script the functionality like there's no tomorrow
e) You are free to use IsValidClient(). It returns false when:
- An incorrect client index is specified
- Client is not in game
- Client is fake (bot)
- Client is Coaching
4. Compile rtd2.sp and you're good to go!
*/
#define TOXIC_PARTICLE "eb_aura_angry01"
float g_fToxicRange = 128.0;
float g_fToxicInterval = 0.25;
float g_fToxicDamage = 24.0;
bool g_bIsToxic[MAXPLAYERS+1] = {false, ...};
int g_iToxicParticle[MAXPLAYERS+1] = {0, ...};
void Toxic_Perk(int client, const char[] sPref, bool apply){
if(apply)
Toxic_ApplyPerk(client, sPref);
else
g_bIsToxic[client] = false;
}
void Toxic_ApplyPerk(int client, const char[] sSettings){
Toxic_ProcessSettings(sSettings);
g_bIsToxic[client] = true;
g_iToxicParticle[client] = CreateParticle(client, TOXIC_PARTICLE);
CreateTimer(g_fToxicInterval, Timer_Toxic, GetClientSerial(client), TIMER_REPEAT);
}
public Action Timer_Toxic(Handle hTimer, int iSerial){
int client = GetClientFromSerial(iSerial);
if(!IsValidClient(client)) return Plugin_Stop;
if(!g_bIsToxic[client]){
if(g_iToxicParticle[client] > MaxClients && IsValidEntity(g_iToxicParticle[client])){
AcceptEntityInput(g_iToxicParticle[client], "Kill");
g_iToxicParticle[client] = 0;
}
return Plugin_Stop;
}
Toxic_HurtSurroundings(client);
return Plugin_Continue;
}
void Toxic_HurtSurroundings(client){
if(!IsValidClient(client)) return;
float fClientPos[3];
GetClientAbsOrigin(client, fClientPos);
for(int i = 1; i <= MaxClients; i++){
if(!Toxic_IsValidTargetFor(client, i)) continue;
float fTargetPos[3];
GetClientAbsOrigin(i, fTargetPos);
float fDistance = GetVectorDistance(fClientPos, fTargetPos);
if(fDistance < g_fToxicRange)
SDKHooks_TakeDamage(i, 0, client, g_fToxicDamage, DMG_BLAST);
}
}
stock bool Toxic_IsValidTargetFor(int client, int target){
if(client == target)
return false;
if(!IsClientInGame(target))
return false;
if(!IsPlayerAlive(target))
return false;
if(!CanEntitySeeTarget(client, target))
return false;
return CanPlayerBeHurt(target, client);
}
void Toxic_ProcessSettings(const char[] sSettings){
char[][] sPieces = new char[3][8];
ExplodeString(sSettings, ",", sPieces, 3, 8);
g_fToxicRange = StringToFloat(sPieces[0]);
g_fToxicInterval = StringToFloat(sPieces[1]);
g_fToxicDamage = StringToFloat(sPieces[2]);
}

61
scripting/rtd/vital.sp Normal file
View File

@@ -0,0 +1,61 @@
/*
This script is a part of RTD2 plugin and is not meant to work by itself.
If you were to edit anything here, you'd have to recompile rtd2.sp instead of this one.
*** HOW TO ADD A PERK ***
A quick note: This tutorial may not be kept up to date; for an updated one, go to the plugin's thread.
1. Set up:
a) Have <perkname>.sp in scripting/rtd.
b) Add it to the includes in scripting/rtd/#perks.sp.
c) Add a new section with a correct ID (highest one +1) to the config/rtd2_perks.cfg and set its settings.
2. Edit scripting/rtd/#manager.sp
a) In a function named ManagePerk() add a new case to the switch() with your perk's ID.
b) In the added case specify a function which is going to execute from <perkname>.sp with parameters:
1) @client - the client the perk should be applied to/removed from
2) @fSpecialPref - the optional "special" value in config/rtd2_perks.cfg
2) @enable - to specify whether the perk should be applied/removed
c) OPTIONAL: You can specify a function in your perk which should run at OnMapStart() in the Forward_OnMapStart() function.
You will need it if you'd want to, for example, precache a sound or loop through existing clients.
d) OPTIONAL: You can specify a function in your perk which should run at OnPlayerRunCmd() in the Forward_OnPlayerRunCmd() function.
You can use it if you'd need something to run each frame or on a certain button press.
NOTE: The forwarded client is guaranteed to be valid BUT NOT GUARANTEED IF THEY ARE ALIVE.
3. Script your perk:
a) Create a public function in <perkname>.sp with parameters @client, @iPref, @bool:apply as an example below
- This is the only function used to transfer info between the core and the include
- You don't need to include any includes that are in the rtd2.sp
b) NOTE: If you need to transfer the iPref to a different function, set it globally but remember to use an unique name
c) Name it AS SAME AS you named the function in the added case in the switch() in #manager.sp
d) From there, script the functionality like there's no tomorrow
e) You are free to use IsValidClient(). It returns false when:
- An incorrect client index is specified
- Client is not in game
- Client is fake (bot)
- Client is Coaching
4. Compile rtd2.sp and you're good to go!
*/
#define MAX_HEALTH_ATTRIB 26
public void Vital_Perk(int client, const char[] sPref, bool apply){
if(apply)
Vital_ApplyPerk(client, StringToInt(sPref));
else
TF2Attrib_RemoveByDefIndex(client, MAX_HEALTH_ATTRIB);
}
void Vital_ApplyPerk(int client, int iValue){
TF2Attrib_SetByDefIndex(client, MAX_HEALTH_ATTRIB, float(iValue));
SetEntityHealth(client, GetEntProp(client, Prop_Data, "m_iHealth") +iValue);
}

71
scripting/rtd/weakened.sp Normal file
View File

@@ -0,0 +1,71 @@
/*
This script is a part of RTD2 plugin and is not meant to work by itself.
If you were to edit anything here, you'd have to recompile rtd2.sp instead of this one.
*** HOW TO ADD A PERK ***
A quick note: This tutorial may not be kept up to date; for an updated one, go to the plugin's thread.
1. Set up:
a) Have <perkname>.sp in scripting/rtd.
b) Add it to the includes in scripting/rtd/#perks.sp.
c) Add a new section with a correct ID (highest one +1) to the config/rtd2_perks.cfg and set its settings.
2. Edit scripting/rtd/#manager.sp
a) In a function named ManagePerk() add a new case to the switch() with your perk's ID.
b) In the added case specify a function which is going to execute from <perkname>.sp with parameters:
1) @client - the client the perk should be applied to/removed from
2) @fSpecialPref - the optional "special" value in config/rtd2_perks.cfg
2) @enable - to specify whether the perk should be applied/removed
c) OPTIONAL: You can specify a function in your perk which should run at OnMapStart() in the Forward_OnMapStart() function.
You will need it if you'd want to, for example, precache a sound or loop through existing clients.
d) OPTIONAL: You can specify a function in your perk which should run at OnPlayerRunCmd() in the Forward_OnPlayerRunCmd() function.
You can use it if you'd need something to run each frame or on a certain button press.
NOTE: The forwarded client is guaranteed to be valid BUT NOT GUARANTEED IF THEY ARE ALIVE.
3. Script your perk:
a) Create a public function in <perkname>.sp with parameters @client, @iPref, @bool:apply as an example below
- This is the only function used to transfer info between the core and the include
- You don't need to include any includes that are in the rtd2.sp
b) NOTE: If you need to transfer the iPref to a different function, set it globally but remember to use an unique name
c) Name it AS SAME AS you named the function in the added case in the switch() in #manager.sp
d) From there, script the functionality like there's no tomorrow
e) You are free to use IsValidClient(). It returns false when:
- An incorrect client index is specified
- Client is not in game
- Client is fake (bot)
- Client is Coaching
4. Compile rtd2.sp and you're good to go!
*/
float g_fWeakenedMultiplayer = 2.5;
void Weakened_Perk(int client, const char[] sPref, bool apply){
if(apply)
Weakened_ApplyPerk(client, StringToFloat(sPref));
else
SDKUnhook(client, SDKHook_OnTakeDamage, Weakened_OnTakeDamage);
}
void Weakened_ApplyPerk(int client, float fMultiplayer){
g_fWeakenedMultiplayer = fMultiplayer;
SDKHook(client, SDKHook_OnTakeDamage, Weakened_OnTakeDamage);
}
public Action Weakened_OnTakeDamage(int iVic, int &iAttacker, int &iInflictor, float &fDamage, int &iDamageType){//, int &weapon, float damageForce[3], float damagePosition[3]){
if(iVic == iAttacker)
return Plugin_Continue;
fDamage *= g_fWeakenedMultiplayer;
return Plugin_Changed;
}