Raised This Month: $ Target: $400
 0% 

Healing for the whole team?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
D o o m
Veteran Member
Join Date: Sep 2005
Location: Germany
Old 03-22-2009 , 03:30   Healing for the whole team?
Reply With Quote #1

Good morning,

I just wanted to know how it is possible to let healing work for the whole team instead of just one person.

The following is my approach
Code:
public HERO_loop()
{
	if ( !sh_is_active() ) return

       static CsTeams:team

	static players[SH_MAXSLOTS], playerCount, player, i
	get_players(players, playerCount, "ah")

        for ( i = 0; i < playerCount; i++ ) {
            player = players[i]

            team = cs_get_user_team(player) //variable 'team' should save the team the player with the hero is in

		if ( gHasHERO[player] ) { //check if a player has the hero
		sh_add_hp(team, get_pcvar_num(pcvarHPReg)) //add the hp to the whole team not just the player himself
		}
	}
}
//----------------------------------------------------------------------------------------------
After this didn't work, I tried to look how other heroes checked the team the player is in (like Xavier or Zeus/Grandmaster), but I don't get it..

Thanks in advance
__________________
Heroes
:+: Deadpool :+:
D o o m is offline
G-Dog
Senior Member
Join Date: Dec 2005
Location: Thunderstorm Central
Old 03-22-2009 , 07:21   Re: Healing for the whole team?
Reply With Quote #2

kinda made this fast
PHP Code:
public HERO_loop()
{
    if ( !
sh_is_active() ) return

    static 
team_has_hero[4], idteam;
    
    
//figure out if each team has our hero
    
for( id 0id <= SH_MAXSLOTSid++)
        if ( 
ghasHERO[id] )
        {
            
team _:cs_get_user_team(id);
            
team_has_hero[team] = 1;
        }
        
    
//now to actually heal everyone
    
for( id 0id <= SH_MAXSLOTSid++)
    {
        if ( !
is_user_alive(id) ) continue;
        
        
team _:cs_get_user_team(id);
        if ( 
team_has_hero[team] ) 
            
sh_add_hp(idget_pcvar_num(pcvarHPReg));
    }

__________________
If at first you don't succeed, then skydiving isn't for you.

Last edited by G-Dog; 03-22-2009 at 07:33.
G-Dog is offline
Send a message via AIM to G-Dog
D o o m
Veteran Member
Join Date: Sep 2005
Location: Germany
Old 03-22-2009 , 09:45   Re: Healing for the whole team?
Reply With Quote #3

Now I don't get the tag mismatch warning

But it still doesn't work.

No matter in which team the players are or if both have the hero or only one or none and also it doesn't matter how they get damage (by shooting, fall damage, etc.).
__________________
Heroes
:+: Deadpool :+:
D o o m is offline
Xel0z
Senior Member
Join Date: Apr 2006
Location: Netherlands
Old 03-22-2009 , 12:13   Re: Healing for the whole team?
Reply With Quote #4

PHP Code:
#include <superheromod>

new g_HeroID
new g_HeroName[]="TeamHealer"
new bool:g_HasHero[SH_MAXSLOTS+1]
new 
pcvarHPReg

public plugin_init()
{
    
register_plugin("SUPERHERO TeamHealer""1.0""Xel0z")

    new 
pcvarLevel register_cvar("teamhealer_level""0")
    
pcvarHPReg register_cvar("teamhealer_healpoints""3")
    
    
g_HeroID sh_create_hero(g_HeroNamepcvarLevel)
    
sh_set_hero_info(g_HeroID"Heal Team""Heal Team")

    
set_task(1.0"riddick_teamhealer"___"b")
}

public 
sh_hero_init(idheroIDmode)
{
    if ( 
g_HeroID != heroID ) return

    switch(
mode) {
        case 
SH_HERO_ADDg_HasHero[id] = true
        
case SH_HERO_DROPg_HasHero[id] = false
    
}
}

public 
teamhealer_loop()
{
    if ( !
shModActive() ) return
    
    for ( new 
1<= SH_MAXSLOTSi++)
    {
        static 
players[SH_MAXSLOTS], pnumteam
        
        
if ( g_HasHero[i] && get_user_team(i) == )
        {
            
//get alive players from terrors.
            
get_players(playerspnum"ae""TE")
            
            for ( new 
0pnumj++ )
            {
                
team players[j]
                
                if ( 
is_user_alive(team) ) sh_add_hp(teamget_pcvar_num(pcvarHPReg))
            }
        } 
        else if ( 
g_HasHero[i] && get_user_team(i) == )
        {
            
//get alive players from ct.
            
get_players(playerspnum"ae""CT")
            
            for ( new 
0pnumk++ )
            {
                
team players[k]
                
                if ( 
is_user_alive(team) ) sh_add_hp(teamget_pcvar_num(pcvarHPReg))
            }
        }
    }

Not sure if this works, but it compiles fine.
__________________
Heroes: TESS-One Working on: Grit (Fixing bugs)
Xel0z is offline
Send a message via MSN to Xel0z
G-Dog
Senior Member
Join Date: Dec 2005
Location: Thunderstorm Central
Old 03-22-2009 , 16:19   Re: Healing for the whole team?
Reply With Quote #5

here's a different method altogether, also untested

and I will warn that while Xel0z's code will probably work, the heal would had a cumulative effect i.e. each player would get healed "teamhealer_healpoints" cvar times # of players on the team that have the hero
PHP Code:
#include <superheromod>

new pHealgHeroID;
new 
gHasHero[SH_MAXSLOTS+1];
//----------------------------------------------------------------------------------------------
public plugin_init()
{
    
// Plugin Info
    
register_plugin("SUPERHERO Example","0.1","Random1");

    
// DO NOT EDIT THIS FILE TO CHANGE CVARS, USE THE SHCONFIG.CFG
    
new pLevel register_cvar("test_level""0");
    
pHeal register_cvar("test_healpoints""3");
    
    
// FIRE THE EVENT TO CREATE THIS SUPERHERO!
    
gHeroID sh_create_hero("Healer"pLevel);
    
sh_set_hero_info(gHeroID"Team Regen""All players on your team will regenerate health");
    
    
register_event("TeamInfo""join_team","a");
}
//----------------------------------------------------------------------------------------------
public sh_hero_init(idheroIDmode)
{
    if ( 
gHeroID != heroID ) return;

    static 
team;
    switch(
mode) {
        case 
SH_HERO_ADD: {
            
gHasHero[id] = 1;
            
team _:cs_get_user_team(id);
            if ( !
task_exists(team) )
                
set_task(1.0"heal_loop"team__"b");
        }

        case 
SH_HERO_DROP: {
            
gHasHero[id] = 0;
            
check_change(id);
        }
    }
}

public 
join_team()    //in case a player changed teams we need to update which team gets the heal
{
    static 
id;
    
id read_data(1);
    if ( !
gHasHero[id] )
        return;
    
    static 
szTeam[2], team;    
    
read_data2szTeam);
    
    switch( 
szTeam[0] )
    {
        case 
'C'team 2;
        case 
'T'team 1;
        default: 
team 0;
    }
    if ( !
task_exists(team) && team )
        
set_task(1.0"heal_loop"team__"b");
        
    
check_change(id);
}

public 
heal_loop(tId)
{
    static 
idteam;
    for(
id 1id <= SH_MAXSLOTSid++)
    {
        if ( !
is_user_alive(id) ) continue;
        
        
team _:cs_get_user_team(id);
        if ( 
team == tId )
            
sh_add_hp(idget_pcvar_num(pHeal));
    }
}

check_change(id)
{
    static 
ikeeploopidteamplayerteam;
    
keeploop 0;
    
idteam _:cs_get_user_team(id);
    for(
1<= SH_MAXSLOTSi++)
        if ( 
gHasHero[i] )
        {
            
playerteam _:cs_get_user_team(i);
            if ( 
idteam == playerteam )
            {
                
keeploop 1;
                break;
            }
        }
    
    if ( !
keeploop )
        
remove_task(idteam);

__________________
If at first you don't succeed, then skydiving isn't for you.

Last edited by G-Dog; 03-22-2009 at 16:27.
G-Dog is offline
Send a message via AIM to G-Dog
D o o m
Veteran Member
Join Date: Sep 2005
Location: Germany
Old 03-22-2009 , 20:42   Re: Healing for the whole team?
Reply With Quote #6

Thank you very much

Now it works without any problems.
__________________
Heroes
:+: Deadpool :+:
D o o m 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 00:22.


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