AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Plugins (https://forums.alliedmods.net/forumdisplay.php?f=108)
-   -   [TF2] Dodge & Resist (https://forums.alliedmods.net/showthread.php?t=144572)

Tylerst 12-05-2010 12:28

[TF2] Dodge & Resist
 
4 Attachment(s)
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. :wink:

FlaminSarge 12-07-2010 03:05

Re: [TF2] Dodge & Resist
 
" TF2only()
CreateConVar("sm_dodgeresist_version", PLUGIN_VERSION, "Set dodge chance and/or damage resistance of a target(s)", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FC VAR_NOTIFY);"
looks like you're missing a semicolon after TF2only() ?

Tylerst 12-07-2010 06:37

Re: [TF2] Dodge & Resist
 
Quote:

Originally Posted by FlaminSarge (Post 1365013)
" TF2only()
CreateConVar("sm_dodgeresist_version", PLUGIN_VERSION, "Set dodge chance and/or damage resistance of a target(s)", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FC VAR_NOTIFY);"
looks like you're missing a semicolon after TF2only() ?

I don't have #pragma semicolon 1 set, that shouldn't be a problem.
(Or at least I've never had to do it before so I don't see why I'd need to here)

If it's an error you're getting I don't know what to tell you.
It's not giving me any errors when I compile it.

Tylerst 12-12-2010 12:01

Re: [TF2] Dodge & Resist
 
Plugin updated for an error I was getting

FaTony 12-12-2010 12:07

Re: [TF2] Dodge & Resist
 
God damn those RPG addicts.

psychonic 01-31-2011 10:51

Re: [TF2] Dodge & Resist
 
@ Tylerist

Before it can be approved, you need to load the common phrases translation file on plugin start or there will be errors if the target cannot be found.
Code:
LoadTranslations("common.phrases");

Some less-important stuff:
Consider adding lateload support for when the plugin is (re)loaded mid game (should just have to add looping through all clients at plugin start, adding the hook for those that are InGame).

Another suggestion, maybe add cvars for default dodge and default resistance (maybe even per class?)

Code:
if(!IsClientConnected(victim) || !IsClientInGame(victim)
Not critical, but IsClientInGame will return false if not connected, and a return a true on it implies connected so you can leave one check off.

Code:
damage *= 0;
Why not just = 0?

Code:
new Float:resist = 1.0 - (damageresist[victim]/100.0);
Is this giving the intended result? You're dividing an integer by a float.
I think it should be:
Code:
new Float:resist = 1.0 - (float(damageresist[victim])/100.0);

Tylerst 02-01-2011 04:36

Re: [TF2] Dodge & Resist
 
Quote:

@ Tylerst
Before it can be approved, you need to load the common phrases translation file on plugin start or there will be errors if the target cannot be found.
Doh, thats usually one of the first things I add to OnPluginStart, can't believe I missed it. :o

Quote:

Not critical, but IsClientInGame will return false if not connected, and a return a true on it implies connected so you can leave one check off.
Ah, I'll have to remember that, thanks.

Quote:

Code:

damage *= 0;
Why not just = 0?
Uh...good question? :oops:

Quote:

Code:


new Float:resist = 1.0 - (damageresist[victim]/100.0);

Is this giving the intended result? You're dividing an integer by a float.
I think it should be:

Code:

new Float:resist = 1.0 - (float(damageresist[victim])/100.0);

That had been working for us. Good point nonetheless, I changed it.






Quote:

Some less-important stuff:
Consider adding lateload support for when the plugin is (re)loaded mid game (should just have to add looping through all clients at plugin start, adding the hook for those that are InGame).

Another suggestion, maybe add cvars for default dodge and default resistance (maybe even per class?)
Before I start working on adding cvars...
Just to make sure, do you mean like this?
PHP Code:

public OnPluginStart()
{  
     for (new 
1<= MaxClientsi++)
     {
          if(
IsClientInGame(i)) 
          { 
                
SDKHook(iSDKHook_OnTakeDamageOnTakeDamage)
          }  
     }  



Unfortunately, my video card died last week, so I won't be able to test these changes for a little while, but I'll have it ready anyway.

psychonic 02-01-2011 08:59

Re: [TF2] Dodge & Resist
 
Quote:

Originally Posted by Tylerst (Post 1404383)
Just to make sure, do you mean like this?
PHP Code:

public OnPluginStart()
{  
     for (new 
1<= MaxClientsi++)
     {
          if(
IsClientInGame(i)) 
          { 
                
SDKHook(iSDKHook_OnTakeDamageOnTakeDamage)
          }  
     }  



Yup.

FlaminSarge 02-01-2011 18:10

Re: [TF2] Dodge & Resist
 
1 Attachment(s)
I made some changes a bit back.

Psy, if I use MAXPLAYERS + 1 instead of MaxClients, then I'm still good, right?

Also, I renamed the smx so it has no spaces (for using /rcon to load/reload it)

And when a client connects/disconnects, his dodge/resist settings are set back to 0 (so a client doesn't somehow gain another previous client's stuff).

Kevin_b_er 02-01-2011 18:18

Re: [TF2] Dodge & Resist
 
Quote:

Originally Posted by psychonic (Post 1403745)
@ Tylerist

Code:
new Float:resist = 1.0 - (damageresist[victim]/100.0);

Is this giving the intended result? You're dividing an integer by a float.
I think it should be:
Code:
new Float:resist = 1.0 - (float(damageresist[victim])/100.0);

Not an issue.

Code:

stock Float:operator/(oper1, Float:oper2)
{
    return FloatDiv(float(oper1), oper2);
}

What's more float/int or int/float will result in an int in most C-style languages. In this case, sourcepawn is no different.


All times are GMT -4. The time now is 01:59.

Powered by vBulletin®
Copyright ©2000 - 2019, vBulletin Solutions, Inc.