Raised This Month: $12 Target: $400
 3% 

Plugin: Superhero Handicap


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
1sh0t2killz
Senior Member
Join Date: Dec 2004
Old 08-01-2010 , 18:45   Plugin: Superhero Handicap
Reply With Quote #1

Superhero Handicap version 1.21

Description
This plugin is for those who want to give their low level players an extra push to help them even the odds against higher level opponents. This helps a lot in my server and I thought I'd share it. Please post bugs, as I did a couple quick modifications before releasing this.

Define:
Code:
#define USE_DAMAGE_REDUCTION		//Comment out if you don't want damage reduced on players
Cvars:
Code:
//Superhero Handicap
handicap_lvlcap 10			//The max level players will recieve handicap benefits
handicap_healpoints 25			//The amount of health handicap players get
handicap_maxhealth 250			//The maximum health handicap players can heal to 
					//(set to 0 to use heroes max health)
handicap_healtime 2.0			//How many seconds it takes to heal handicap players
handicap_dmgreduc 0.50			//The amount of damage reduced on handicap players (only if USE_DAMAGE_REDUCTION is defined)
					//(ex. 1.0 for full damage, 0.50 for half damage)
Change Log:
Code:
v 1.1 - August 1, 2010
	- initial public release
v 1.2 - August 1, 2010
	- minor changes/fixes to code preventing bots from gaining handicap benefits
v 1.21 - August 1, 2010
	- added a message to tell players what the handicap plugin does
v 1.22 - August 5, 2010
	- Optimized code thanks to Fr33m@n
Notes:
If defined: USE_DAMAGE_REDUCTION
Code:
	//Only reduce damage if the victim is within the handicap threshold and the attacker is above the handicap level
	//therefore players within the handicap threshold deal regular damage to each other, as where players above the
	//handicap level deal reduced damage to handicap players
Attached Files
File Type: sma Get Plugin or Get Source (sh_handicap_pub.sma - 1002 views - 4.0 KB)
__________________
I ♥ ⌂ ♫

Last edited by 1sh0t2killz; 08-06-2010 at 02:09. Reason: Updated
1sh0t2killz is offline
D.P!
Junior Member
Join Date: Jul 2010
Old 08-01-2010 , 19:52   Re: Plugin: Superhero Handicap
Reply With Quote #2

not bad
D.P! is offline
Fr33m@n
Veteran Member
Join Date: May 2008
Location: France Marne
Old 08-04-2010 , 17:32   Re: Plugin: Superhero Handicap
Reply With Quote #3

nicely done.
I would suggest the get_pcvar_num outside the player loop (in Handicap_Heal_Loop) for a better optimization.
Fr33m@n is offline
1sh0t2killz
Senior Member
Join Date: Dec 2004
Old 08-05-2010 , 16:47   Re: Plugin: Superhero Handicap
Reply With Quote #4

Quote:
Originally Posted by Fr33m@n View Post
nicely done.
I would suggest the get_pcvar_num outside the player loop (in Handicap_Heal_Loop) for a better optimization.
you mean instead of
Code:
	set_task( get_pcvar_float(HandicapHealTime), "Handicap_Heal_Loop", _, _, _, "b" )
do this?
Code:
	set_task( get_pcvar_num(HandicapHealTime), "Handicap_Heal_Loop", _, _, _, "b" )
__________________
I ♥ ⌂ ♫
1sh0t2killz is offline
DarkGod
SourceMod DarkCrab
Join Date: Jul 2007
Location: Sweden
Old 08-05-2010 , 16:48   Re: Plugin: Superhero Handicap
Reply With Quote #5

Quote:
Originally Posted by 1sh0t2killz View Post
you mean instead of
Code:
	set_task( get_pcvar_float(HandicapHealTime), "Handicap_Heal_Loop", _, _, _, "b" )
do this?
Code:
	set_task( get_pcvar_num(HandicapHealTime), "Handicap_Heal_Loop", _, _, _, "b" )
PHP Code:
    for ( 0playerCounti++ ) 
    {
        
player players[i]

        if ( 
sh_get_user_lvl(player) <= get_pcvar_num(HandicapLevelCap) && !is_user_bot(player) )
            
sh_add_hp(playerget_pcvar_num(HandicapHealPoints), get_pcvar_num(HandicapMaxHealth))
    } 
Cache the cvar values before the loop.
__________________
DarkGod is offline
Send a message via AIM to DarkGod Send a message via MSN to DarkGod
Fr33m@n
Veteran Member
Join Date: May 2008
Location: France Marne
Old 08-05-2010 , 17:26   Re: Plugin: Superhero Handicap
Reply With Quote #6

something like that :

PHP Code:
public Handicap_Heal_Loop()
{
    if ( !
sh_is_active() ) return
 
    static 
players[SH_MAXSLOTS], playerCountplayeri
 
    
static iHandicapLevelCapiHandicapHealPointsiHandicapMaxHealth
    iHandicapLevelCap 
get_pcvar_num(HandicapLevelCap)
    
iHandicapHealPoints get_pcvar_num(HandicapHealPoints)
    
iHandicapMaxHealth get_pcvar_num(HandicapMaxHealth)
 
    
get_players(playersplayerCount"ah")
 
    for ( 
0playerCounti++ ) 
    {
        
player players[i]
 
        if ( 
sh_get_user_lvl(player) <= iHandicapLevelCap && !is_user_bot(player) )
            
sh_add_hp(playeriHandicapHealPointsiHandicapMaxHealth)
    }


Last edited by Fr33m@n; 08-05-2010 at 17:33.
Fr33m@n is offline
1sh0t2killz
Senior Member
Join Date: Dec 2004
Old 08-05-2010 , 20:43   Re: Plugin: Superhero Handicap
Reply With Quote #7

kkay, will post an update soon

EDIT: updated
__________________
I ♥ ⌂ ♫

Last edited by 1sh0t2killz; 08-06-2010 at 02:10. Reason: update
1sh0t2killz is offline
Fr33m@n
Veteran Member
Join Date: May 2008
Location: France Marne
Old 08-06-2010 , 09:22   Re: Plugin: Superhero Handicap
Reply With Quote #8

PHP Code:
//You call the same native two time when time is needed here, get_pcvar_num(HandicapLevelCap) -> cache the value
if ( sh_get_user_lvl(iVictim) <= get_pcvar_num(HandicapLevelCap) && sh_get_user_lvl(iAttacker) >= get_pcvar_num(HandicapLevelCap) && !is_user_bot(iVictim) )
{
    
//unlike the previous situation you are creating a var, who is called only one time, useless
    
new FloatNewDamage = ( fDamage get_pcvar_float(HandicapDamageReduc) )
    
SetHamParamFloatNewDamage )

just some good habits to take.
Fr33m@n is offline
1sh0t2killz
Senior Member
Join Date: Dec 2004
Old 08-06-2010 , 23:44   Re: Plugin: Superhero Handicap
Reply With Quote #9

thnx, I'll keep that in mind whenever I code, since I usually speed through everything I make.
__________________
I ♥ ⌂ ♫
1sh0t2killz 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 14:46.


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