Raised This Month: $ Target: $400
 0% 

[TF2] Toastmaster code cleanup


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
PC Gamer
Veteran Member
Join Date: Mar 2014
Old 10-05-2022 , 15:02   [TF2] Toastmaster code cleanup
Reply With Quote #1

Can you recommend any code cleanup or feature enhancement for this plugin?

I'm in the process of cleaning up Halloween plugins in preparation for Scream Fortress. This plugin works just fine as-is. However, if you have any tips for code cleanup or feature ideas I'd love to hear them. I'm eager to learn.

Note: Credit for the Toastmaster model goes to MegapiemanPHD, creator of the TF2 map 'Sinthetic' which is where I obtained the model.

Current plugin functionality:
Target player becomes the Toastmaster (boss from map called 'Sinthetic'). Changes to gray team and can attack players on RED and BLU team. Changes to sniper class with Toastmaster player model. Removes all weapons and uses fists to melee attack. Can cast unlimited lightning spells. Melee attacks have increased range and instantly kills victim.

Command: !betoastmaster (target)

Plugin dependency: TF2Attributes by the talented nosoop. Here's a link: https://github.com/nosoop/tf2attributes

Video of Be the Toastmaster Plugin:


Installation:
Place betoastmaster.txt file in your /sourcemod/gamedata/ folder
Place betoastmaster.smx file in your /sourcemod/plugins/ folder
Change map
Attached Files
File Type: txt betoastmaster.txt (339 Bytes, 26 views)
File Type: sp Get Plugin or Get Source (betoastmaster.sp - 35 views - 27.9 KB)
File Type: smx betoastmaster.smx (19.4 KB, 24 views)
PC Gamer is offline
luki1412
Veteran Member
Join Date: Oct 2008
Location: OnPluginStart()
Old 10-06-2022 , 19:15   Re: [TF2] Toastmaster code cleanup
Reply With Quote #2

- Your plugin wont work on late load due to custom files not being precached. Your OnMapStart callback wont be called on late load.
- The for loop in OnPluginStart is what I assume you used for late load of the plugin, however it is redundant if it is not a late load. No one should be connected when the plugins are being loaded on normal map start. Should be wrapped in an if statement.
- On that map they use Skeleton King which does 100 dmg per hit not an instant kill. Even in your video it seems OP. There should be at least a cvar for that.
- No OnClientDisconnect for cleanup. Your global bools will be set to true even if the player is not even present, if they disconnect while they are the boss. Currently it does not seem to have any negative effects in the code but if you add something later on, this can be an annoying bug.
- Instead of a timer with 0.0 duration, you can use RequestFrame()
- If you're already using weapon attributes, why not use one for hp? Could be your preference, just asking. With attributes, there would be no overheal. They would be able to pick up health kits though, unless blocked.
- To change a team without killing the player, you can do:
Code:
SetEntProp(iClient, Prop_Send, "m_lifeState", 2);
ChangeClientTeam(iClient, 0);
SetEntProp(iClient, Prop_Send, "m_lifeState", 0);
Dont need an SDK call, unless you want it for a specific reason that I dont see.
- damage = damage * 20; can be written as
Code:
damage *= 20;
- A strange decision to precache sounds in a sound hook. I get that its easier but you emit sounds before they are precached(unless tf2 precaches mvm sounds even in non-mvm modes) and you keep using PrecacheSound on every sound for the boss. I assume that there is a check inside PrecacheSound but its gonna be called 1000s of times for no reason.
- sm_betoastmaster cant be toggled/turned off. Can only die/commit suicide to get rid of it.
- stock is for functions in include files. The compiler wont yell at you for not using the function anywhere and it wont be compiled into the plugin but it will stay in the source code. Its a bad habit to copy them with the function body.
__________________
luki1412 is offline
PC Gamer
Veteran Member
Join Date: Mar 2014
Old 10-06-2022 , 20:17   Re: [TF2] Toastmaster code cleanup
Reply With Quote #3

Thanks for the coding tips luki1412, your comments are very useful and I'll work to implement them.

I agree that the Toastmaster is way too powerful for most servers. I use the plugin in my Uber Upgrades server where players upgrade themselves to become extremely powerful (such as having 3000 health and doing 1000hp damage per hit). In that environment this plugin is pretty tame.

Thanks again for the feedback!

Does anyone else have any feature enhancements or coding improvements to share?
PC Gamer is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 07:18.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode