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

Team healing


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
egbertjan
Senior Member
Join Date: Mar 2007
Location: The Netherlands
Old 07-26-2011 , 11:24   Team healing
Reply With Quote #1

Hello, I got some problems with a team heal function.

Code:
//init
    register_cvar("diablo_Monk_heal", "20")
    register_cvar("diablo_Monk_distance", "300")

// my task
        case Monk:
        {
            Monk_healteam(id)
            
        }

public Monk_healteam(id) {

    new team1 = get_user_team(id);
    new team2;
    new p_origin[3], t_origin[3];
    get_user_origin(id, p_origin);

    for(new i = 0; i < 3; i++) {
        team2 = get_user_team(i);
        if(team2 != team1 && is_user_alive(i)) {
            get_user_origin(i, t_origin);
            if(get_distance(p_origin, t_origin) <= get_cvar_num("diablo_Monk_distance")) {
                set_user_health(i, get_user_health(i)+get_cvar_num("diablo_Monk_heal"));
                show_hudmessage(i, "You have healed your team for %i HP within %i feet",get_cvar_num("diablo_Monk_heal"),get_cvar_num("diablo_Monk_distance")) 
            } else {
            show_hudmessage(i, "You have to get closer to your team mates to heal them!") 
            
            }    
        }
    }
}
I have a task for running this function, but I don't know what's wrong with this.

I'm started to understand some basics of scripting, but still there are many things I have to learn, so please if you see what's wrong also explain me why it was wrong.

Edit: There are no compiling errors, just when I do the task it doesn't do anything.

Thanks in advance!

Last edited by egbertjan; 07-26-2011 at 11:30.
egbertjan is offline
eXtrem
Member
Join Date: Jul 2011
Old 07-26-2011 , 11:37   Re: Team healing
Reply With Quote #2

If I'm not wrong,

Code:
if( team1 != team2 /* ... */ )

should be

Code:
if( team1 == team2 /* ... */ )
eXtrem is offline
egbertjan
Senior Member
Join Date: Mar 2007
Location: The Netherlands
Old 07-26-2011 , 11:50   Re: Team healing
Reply With Quote #3

Edit: This only heals myself and not my team members as I expected.

Last edited by egbertjan; 07-26-2011 at 11:54.
egbertjan is offline
egbertjan
Senior Member
Join Date: Mar 2007
Location: The Netherlands
Old 07-26-2011 , 16:41   Re: Team healing
Reply With Quote #4

I figured out another way to use this and after some time I also found out how to use this for purpose, thanks for helping me out though!

For the other interested people:

Code:
public monk_heal(id)
{
    new MaxHealth = race_heal[player_class[id]]+player_strength[id]*2
    new healRadius=get_cvar_num("diablo_monk_distance")
    new specialHeal=get_cvar_num("diablo_monk_heal")
    new location[3], allyOrigin[3], distanceBetween
    
    if (is_user_alive(id)) {        
        get_user_origin(id, location)  // Find out where Medic is
        for(new i = 0; i < 33; i++) {
            if ( (is_user_alive(i) && get_user_team(id)==get_user_team(i)) )  {
                get_user_origin(i, allyOrigin)
                // Check to see if any ally are within radius
                distanceBetween=get_distance(location, allyOrigin)
                if ( distanceBetween < healRadius && get_user_health(id) <= MaxHealth ) {
                    set_user_health(i, get_user_health(i)+specialHeal )
                    
                }
            }
        }
    }
}
egbertjan 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 05:09.


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