callfunc Heal group in area

Tio Akima

New member
Messages
349
Points
0
Age
36
Discord
TioAkima#0636
Github
Tio Akima
Emulator
guys, can someone help me programming this callfunc
I'm trying to make a callfunc to use on an item
this item should heal the player and whoever is in the group (only if they are within a 10x10 area
I am still building, but I have a series of doubts and I am not able to get the id of the party members

function    script    F_HealGroup    {

    //members id
    getpartymember(getcharid(CHAR_ID_PARTY), 1);
    
    .@range= 10;
    .@porcent = 50;
    
    //map coordinate
    getmapxy(.@m$,.@x,.@y,0);

     //get user in area 10x10
   .@count = getunits((BL_MOB | BL_PC), .@units, -1, .@m$, max(0, .@x - .@range), max(0, .@y - .@range), .@x + .@range, .@y + .@range);
    
    // for the party member

    for (.@i = 0; .@i < .@count; .@i++) {
        dispbottom .@units[.@i]; //debug - print the user id
        percentheal( .@porcent, .@porcent);
        specialeffect(310, AREA, .@units[.@i] );                      
    }


    return;
}



I tried to get the idea with getpartymember (getcharid (CHAR_ID_PARTY), 1);
But I couldn't apply it in the code ... I also tried to use the areapercentheal ("map", x, y, x2, y2, hp, sp); but I couldn't apply it either ... Maybe it's even easier than the shape I'm trying to make.
I'm not very good with scripts.

 
Hi.

//members id
getpartymember(getcharid(CHAR_ID_PARTY), 1);


You have to use type 2 instead of 1 to get the account ID of all party members instead of their char IDs.
(The getunits() command will collect the GID of found units, which is the account ID for player type units. (BL_PC))

Additionally you should immediately save the IDs  and the member count to prevent other scripts from interfering with your data.

// Get party data.
getpartymember(getcharid(CHAR_ID_PARTY), 2);
.@p_mem_cnt = $@partymembercount;
copyarray(.@p_mem_aid[0], $@partymemberaid[0], .@p_mem_cnt);



                                                                                                                                                                                                                                                                                                                            

.@range= 10;


This should be 5 for a 10x10 area. When setting this to 10, your area is 20x20.

                                                                                                                                                                                                                                                                                                                            

.@count = getunits((BL_MOB | BL_PC), .@units, -1, .@m$, max(0, .@x - .@range), max(0, .@y - .@range), .@x + .@range, .@y + .@range);


Any reason to get monster type units (BL_MOB), too? 😯 If you only want to heal party members you should only collect player type units (BL_PC).

Also better use false for <limit>. -1 works, too, but is less readable.

.@count = getunits(BL_PC, .@units, false, .@m$, max(0, .@x - .@range), max(0, .@y - .@range), .@x + .@range, .@y + .@range);



                                                                                                                                                                                                                                                                                                                            

And finally you have to add a nested loop to your loop to compare the account IDs. (Loop through found units and for each iteration loop through party members.)

for (.@i = 0; .@i < .@count; .@i++) {
dispbottom(".@units[" + .@i + "]: " + .@units[.@i]); //debug - print the user id (getunits)

for (.@j = 0; .@j < .@p_mem_cnt; .@j++) {
dispbottom(".@p_mem_aid[" + .@j + "]: " + .@p_mem_aid[.@j]); //debug - print the user id (getpartymember)

if (.@units[.@i] == .@p_mem_aid[.@j]) {
dispbottom("Party member found. Try healing!"); //debug - party member found

if (attachrid(.@p_mem_aid[.@j])) {
percentheal(.@porcent, .@porcent);
specialeffect(310, AREA, playerattached());
}
}
}
}






That's just a quick draft. Syntax errors are for free. 😋


~Kenpachi

 
Hi.

//members id
getpartymember(getcharid(CHAR_ID_PARTY), 1);

//members id
getpartymember(getcharid(CHAR_ID_PARTY), 1);


You have to use type 2 instead of 1 to get the account ID of all party members instead of their char IDs.
(The getunits() command will collect the GID of found units, which is the account ID for player type units. (BL_PC))

Additionally you should immediately save the IDs  and the member count to prevent other scripts from interfering with your data.

// Get party data.
getpartymember(getcharid(CHAR_ID_PARTY), 2);
.@p_mem_cnt = $@partymembercount;
copyarray(.@p_mem_aid[0], $@partymemberaid[0], .@p_mem_cnt);

// Get party data.
getpartymember(getcharid(CHAR_ID_PARTY), 2);
.@p_mem_cnt = $@partymembercount;
copyarray(.@p_mem_aid[0], $@partymemberaid[0], .@p_mem_cnt);



                                                                                                                                                                                                                                                                                                                            

.@range= 10;

.@range= 10;


This should be 5 for a 10x10 area. When setting this to 10, your area is 20x20.

                                                                                                                                                                                                                                                                                                                            

.@count = getunits((BL_MOB | BL_PC), .@units, -1, .@m$, max(0, .@x - .@range), max(0, .@y - .@range), .@x + .@range, .@y + .@range);

.@count = getunits((BL_MOB | BL_PC), .@units, -1, .@m$, max(0, .@x - .@range), max(0, .@y - .@range), .@x + .@range, .@y + .@range);


Any reason to get monster type units (BL_MOB), too? 😯 If you only want to heal party members you should only collect player type units (BL_PC).

Also better use false for <limit>. -1 works, too, but is less readable.

.@count = getunits(BL_PC, .@units, false, .@m$, max(0, .@x - .@range), max(0, .@y - .@range), .@x + .@range, .@y + .@range);

.@count = getunits(BL_PC, .@units, false, .@m$, max(0, .@x - .@range), max(0, .@y - .@range), .@x + .@range, .@y + .@range);



                                                                                                                                                                                                                                                                                                                            

And finally you have to add a nested loop to your loop to compare the account IDs. (Loop through found units and for each iteration loop through party members.)

for (.@i = 0; .@i < .@count; .@i++) {
dispbottom(".@units[" + .@i + "]: " + .@units[.@i]); //debug - print the user id (getunits)

for (.@j = 0; .@j < .@p_mem_cnt; .@j++) {
dispbottom(".@p_mem_aid[" + .@j + "]: " + .@p_mem_aid[.@j]); //debug - print the user id (getpartymember)

if (.@units[.@i] == .@p_mem_aid[.@j]) {
dispbottom("Party member found. Try healing!"); //debug - party member found

if (attachrid(.@p_mem_aid[.@j])) {
percentheal(.@porcent, .@porcent);
specialeffect(310, AREA, playerattached());
}
}
}
}

for (.@i = 0; .@i < .@count; .@i++) {
dispbottom(".@units[" + .@i + "]: " + .@units[.@i]); //debug - print the user id (getunits)

for (.@j = 0; .@j < .@p_mem_cnt; .@j++) {
dispbottom(".@p_mem_aid[" + .@j + "]: " + .@p_mem_aid[.@j]); //debug - print the user id (getpartymember)

if (.@units[.@i] == .@p_mem_aid[.@j]) {
dispbottom("Party member found. Try healing!"); //debug - party member found

if (attachrid(.@p_mem_aid[.@j])) {
percentheal(.@porcent, .@porcent);
specialeffect(310, AREA, playerattached());
}
}
}
}






That's just a quick draft. Syntax errors are for free. 😋


~Kenpachi
hahahaha very nice ken! I laughed at the free syntax errors .. hahaha delivery
Thankssss haha ❤️ 

 
Back
Top