View Single Post
Author Message
Tylerst
Veteran Member
Join Date: Oct 2010
Old 12-05-2010 , 11:28   [TF2] Dodge & Resist
Reply With Quote #1

TF2 Dodge & Resist (Requires SDKhooks!)
Thanks to L.Duke for his particles via tempents thread and [AAA]Thrawn for the updated list of effects in this post

Description:
Set dodge chance and/or damage resistance of a target(s), specific classes, or all players

Cvars(default values shown):

sm_dodgeresist_version "1.1.6"

sm_dodgeresist_chat "1" - Enable/Disable (1/0) Showing dodge/resist changes in chat
sm_dodgeresist_log "1" - Enable/Disable (1/0) Logging of dodge/resist changes


IMPORTANT:
Class specific cvars override base dodge/resist for that class
For both dodge and resistance priority order is
Admin Command>Class Cvar>Base Cvar

All following cvars are limited from 0-100(Just like the admin commands)

sm_basedodge "0" - Set the default dodge chance for all players
sm_baseresist "0" - Set the default damage resistance for all players

sm_scoutdodge "0" - Set dodge chance of all scouts
sm_scoutresist "0" - Set damage resistance of all scouts

sm_soldierdodge "0" - Same as sbove,but for soldier
sm_soldierresist "0" - Same as above, but for soldier

sm_pyrododge "0" - Yeah, still the same, but for pyro
sm_pyroresist "0" - Still the same, blah blah

sm_demomandodge "0" - See the pattern yet?
sm_demomanresist "0"

sm_heavydodge "0"
sm_heavyresist "0"

sm_engineerdodge "0"
sm_engineerresist "0"

sm_medicdodge "0"
sm_medicresist "0"

sm_sniperdodge "0"
sm_sniperresist "0"

sm_spydodge "0"
sm_spyresist "0"


Commands:

sm_dodge <target> <0-100> - Set dodge chance of a target(s), use -1 to reset to default- Default Slay Flag
Will show "Miss" text when an attack misses
sm_resist <target> <0-100> - Set damage resistance of a target(s), use -1 to reset to default -Default Slay Flag

Examples:
sm_dodge Thetarget 50 - 50% of attacks will miss Thetarget
sm_resist Thetarget 75 - Attacks that hit Thetarget will only do 25% damage
sm_dodge @me 100 - All attacks will miss you
sm_resist @me 100 - Attacks that hit will not damage you
sm_dodge @bots 75 - Bots will dodge 75% of attacks
sm_resist @humans 100 - players won't take damage
sm_dodge @red 25 - Red team will dodge 25% of attacks
sm_resist @blue - Blue team will take 75% damage
sm_dodge @all 10 - everyone will dodge 10% of attacks

sm_dodge @all -1 - reset everyones dodge chance to default
sm_resist @all -1 - reset everyones damage resistance to default

Changelog:
Code:
Version 1.0.0 - December 5, 2010
* Initial Release
Version 1.0.1 - December 12, 2010
* Added code to check for valid clients
Version 1.1.0 - February 03, 2011
* Added missing translation code
* Added Cvars to change default values and per class values
* Added separate functions to calculate dodge and resistance with new cvars
* Added player loop in OnPluginStart to account for late loading
* Lots of other minor coding changes
Version 1.1.3 - April 4, 2011
* Minor code change due to some errors
Version 1.1.5 - August 6, 2011
* Added code to allow rocket/sticky jumping, etc
* Plugin now uses AskPluginLoad2 to check the game
Version 1.1.6 - August 7, 2011
* Small fix for not showing 'miss' text when hitting a bot that dodged
Todo:
Allow resistance values above 100 that heal the target hit, and values below 0 to increase the damage done to the target
Will probably need to move resetting to an admin command instead of -1 on sm_resist, or maybe strcmp to allow something like sm_resist @all reset

List of things I'm not adding:
Admin Menu Integration
I tried this out on my Set Class Plugin(for practice), and it ended up using more code than the actual plugin. Use the Custom Admin Menu, it's muuuuuuch easier.

Allow the cvars for base dodge/resistance and classes to be admin only
That's what the admin commands are for! Besides, it's open source. If you want it that badly noone is stopping you from coding it in for your server.
Attached Files
File Type: sp Get Plugin or Get Source (TF2 Dodge & Resist.sp - 560 views - 12.2 KB)
File Type: smx TF2 Dodge & Resist.smx (9.4 KB, 556 views)

Last edited by Tylerst; 08-07-2011 at 06:43. Reason: Update
Tylerst is offline