-- [ UNIVERSAL UPGRADES ] --
My first (and probably only) attempt at making a SourceMod plugin,
this plugin allows you to purchase upgrades via an in-game currency gained by killing people.
::FEATURES::- Kill Streak: Gain bonus money based on the number of players you've killed!
- Customizable Upgrades System: Works in non-MVM gamemodes!
- Toggleable: Can be turned off to reset everyone's stats!
- Purchase upgrades through a menu!
::REQUIREMENTS::
TF2Attributes
LATEST SNAPSHOT OF BOTH SOURCEMOD AND METAMOD
::SCREENSHOTS::
(Old)
http://steamcommunity.com/sharedfile.../?id=144495940
http://steamcommunity.com/sharedfile.../?id=144496692
::INSTALLATION::
Put "sm_tf2_upgrades.smx" into your server's "addons/sourcemod/plugins" folder.
Put "uu_upgrades.txt" into your server's "addons/sourcemod/configs" folder.
Put "sm_tf2_upgrades.phrases.txt" into your server's "addons/sourcemod/translations" folder.
Make sure you have TF2Attributes installed as well.
::CVARS::
univeralupgrades_version
Don't change this. It's the version number of the plugin.
sm_uu_enabled
Enables (1) the plugin or Disables (0) it.
sm_uu_currencystart
How much money each player starts with. Defaults to 500.
sm_uu_currencyonkill
How much money you earn per kill. Defaults to 25.
sm_uu_killstreakstart
After so many kills, you gain a percentage of bonus money every kill! This is the kill streak requirement before you get extra money. Defaults to 2.
sm_uu_killstreakbonus
This is the percentage of extra money you get per kill. This gets multiplied by your kill streak, by the way. Defaults to 0.05.
sm_uu_costincrease
This adds so much money to each upgrade, based on the upgrade's original cost. It's disabled by default (0.0). 1.0 causes each upgrade to cost 100% more than the previous amount.
sm_uu_currencyonassist
The percentage of money given to people who assist in a kill. Defaults to 50% of Kill money (0.5).
sm_uu_currencyondeath
The percentage of money given to people who have died. Defaults to 25% of Kill money (0.25).
sm_uu_poorkillbonus
This is bonus money you earn from kills and assists based on how much money your opponent has compared to you. Defaults to 10% (0.1).
sm_uu_poorcheck
This is the percentage of total money you have compared to your opponent before you gain bonus money from killing rich people. Defaults to 75% (0.75). Setting to 1.0 will give you bonus money every kill unless your money is equivelant to your opponent's.
::COMMANDS::
sm_upgrade
Opens up the upgrade menu! Use /upgrade, !upgrade, or bind sm_upgrade to a key.
sm_checkcurrency
This tells you how much money you have in total. /checkcurrency, !checkcurrency, or binding works with this too.
sm_reset
This will reset all of your stats and refund you all of the money you spent.
sm_uu_givecurrency <user> <amount> (ROOT ADMIN ONLY)
This allows you to give money to 1 or more players. I recommend not using negative values for the amount.
::NOTES::
- Upgrades and money are removed when using "sm_uu_enabled 0" or when the round ends and restarts.
- When you die, your kill streak will be set back to zero, causing you to gain normal money again.
- Upgrades can optionally NOT discriminate what they're allowed to be on. This doesn't me they'll always work, though.
- Switching classes will give you all of your spent money back, but will reset all of your stats.
- Read the included uu_upgrades.txt to learn how the file works. Just looking at the "Upgrade Creation" section might not be good enough.
::UPGRADE CREATION::
The file "uu_upgrades.txt" is where all the upgrades are stored. Here's an example of a Weapon-Specific upgrade, a Class-specific upgrade, and a General upgrade:
Code:
"Upgrades" // Generic File Section Name.
{
"tf_weapon_scattergun" // This is a Weapon Class. To be specific, the Base Scattergun Class.
{
"damage bonus" // This is the name of an existing TF2 Attribute.
{
"menuname" "Damage +25%" // Name that shows up in the menu.
"cost" "500" // The cost of the upgrade.
"upgrade" "0.25" // The upgrade value that gets applied to the attribute.
"max" "5.0" // The maximum value of the attribute.
"start" "1.0" // The starting position of the attribute.
"onweapon" "1" // 1 = On Weapon, 0 = On Player. It's a weapon upgrade.
}
}
"scout" // This is a Player Class. To be specific, this is the Scout's Upgrade list.
{
"move speed bonus" // Another Attribute.
{
"menuname" "Movement Speed +5%" // Display name in menu.
"cost" "1500" // Upgrade cost.
"upgrade" "0.05" // Upgrade increase value.
"max" "1.5" // Maximum value.
"start" "1.0" // Starting value.
"onweapon" "0" // Like above, but it's 0 (zero), so it's for the player.
}
}
"all" // This is the Generic Upgrade list. This makes it so any weapon or player class can use it.
{
"max health additive bonus" // Another Attribute.
{
"menuname" "Max Health +25" // Display name again.
"cost" "400" // Upgrade cost again.
"upgrade" "25.0" // Upgrade value again.
"max" "500.0" // Maximum value again.
"start" "0.0" // Starting value again.
"onweapon" "0" // 0 = Player Class upgrade, remember that.
}
}
}
::FINAL NOTES::
I honestly hope this gets used. I know there's another plugin like this that's being tested, but I had made this without actually knowing someone else was doing the same thing. Either way, whoever uses this, I hope you enjoy it.
I have no plans on altering this any further. Someone else can pick up the source, I don't know enough about SourcePawn to maintain this any further.
::CHANGELOG::
- V1.4
- Added "sm_uu_givecurrency" as an admin command and "sm_reset" as a player command.
- Attempted to fix bandwidth issues. (Thanks, lobnico!)
- There is now an Upgrade Category Selection menu, which allows you to upgrade Player stats and Weapon stats more easily.
- Added a "Translation" file, but it's not perfect.
- V1.3
- Added "sm_uu_currencyondeath", "sm_uu_currencyonassist", "sm_uu_poorkillbonus", and "sm_uu_poorcheck" for extra money possibilities.
- You now start with either sm_uu_currencystart's value as money or the lowest player currency count as money.
- You now gain all of your spent money back if you switch classes. Spent money counts towards your total money and affects poor kill bonuses.
- Upgrades can now be in a variety of sections in uu_upgrades.txt. There's Player Class, Weapon Class, and "all". "all" is the old way it worked and will give that upgrade to either the player or their equipped weapon.
- Current Money and Total Money are both displayed in the Upgrade Menu and with sm_checkcurrency.
- Upgrade Menu now loops until you hit 0. This is to make upgrading faster.
- V1.2
- Upgrade Menu now displayers [Player] or [Weapon] and the required price for each item.
- Panel that askes you if you want to upgrade tells you how much money you have now.
- Upgrade Menu is created when a player opens it.
- Added "universalupgrades_version" as a Version Tracking Cvar.
- V1.1
- Fixed negative-valued upgrades not getting price increases.
- Fixed resetting of all players in a weird way. Causes respawning.
- V1.0