Skip to content

Commit 7cd029a

Browse files
Merge branch 'master' into getguildmember
2 parents 5cb55bb + 17cd588 commit 7cd029a

18 files changed

+122
-154
lines changed

doc/constants_pre-re.md

+6
Original file line numberDiff line numberDiff line change
@@ -5568,6 +5568,12 @@
55685568
- `SIEGE_TYPE_SE`: 1
55695569
- `SIEGE_TYPE_TE`: 2
55705570

5571+
### partymember types
5572+
5573+
- `PT_MEMBER_NAME`: 0
5574+
- `PT_MEMBER_CHARID`: 1
5575+
- `PT_MEMBER_ACCID`: 2
5576+
55715577
### guildinfo types
55725578

55735579
- `GUILDINFO_NAME`: 0

doc/constants_re.md

+6
Original file line numberDiff line numberDiff line change
@@ -5568,6 +5568,12 @@
55685568
- `SIEGE_TYPE_SE`: 1
55695569
- `SIEGE_TYPE_TE`: 2
55705570

5571+
### partymember types
5572+
5573+
- `PT_MEMBER_NAME`: 0
5574+
- `PT_MEMBER_CHARID`: 1
5575+
- `PT_MEMBER_ACCID`: 2
5576+
55715577
### guildinfo types
55725578

55735579
- `GUILDINFO_NAME`: 0

doc/script_commands.txt

+20-93
Original file line numberDiff line numberDiff line change
@@ -3000,118 +3000,45 @@ Lets say the ID of a party was saved as a global variable:
30003000

30013001
---------------------------------------
30023002

3003-
*getpartymember(<party id>{, <type>})
3003+
*getpartymember(<party_id>, <type>, <array>)
30043004

3005-
This command will find all members of a specified party and returns their
3006-
names (or character id or account id depending on the value of "type")
3007-
into an array of temporary global variables. There's actually quite a few
3008-
commands like this which will fill a special variable with data upon
3009-
execution and not do anything else.
3010-
3011-
Upon executing this,
3012-
3013-
$@partymembername$[] is a global temporary string array which contains all
3014-
the names of these party members.
3015-
(only set when type is 0 or not specified)
3016-
3017-
$@partymembercid[] is a global temporary number array which contains the
3018-
character id of these party members.
3019-
(only set when type is 1)
3020-
3021-
$@partymemberaid[] is a global temporary number array which contains the
3022-
account id of these party members.
3023-
(only set when type is 2)
3005+
This command will find all members of a specified <party_id>, copy their
3006+
names (or character id or account id) depending on the <type> into <array>
3007+
and returns the number of party members that were found.
30243008

3025-
$@partymembercount is the number of party members that were found.
3009+
Valid <type> are:
30263010

3027-
The party members will (apparently) be found regardless of whether they
3028-
are online or offline. Note that the names come in no particular order.
3011+
PT_MEMBER_NAME - Party member names
3012+
PT_MEMBER_CHARID - Party member character ID
3013+
PT_MEMBER_ACCID - Party member account ID
30293014

3030-
Be sure to use $@partymembercount to go through this array, and not
3031-
'getarraysize', because it is not cleared between runs of 'getpartymember'.
3032-
If someone with 7 party members invokes this script, the array would have
3033-
7 elements. But if another person calls up the NPC, and he has a party of
3034-
5, the server will not clear the array for you, overwriting the values
3035-
instead. So in addition to returning the 5 member names, the 6th and 7th
3036-
elements from the last call remain, and you will get 5+2 members, of which
3037-
the last 2 don't belong to the new guy's party. $@partymembercount will
3038-
always contain the correct number, (5) unlike 'getarraysize()' which will
3039-
return 7 in this case.
3015+
Make sure to use string variable for PT_MEMBER_NAME and
3016+
int variable for PT_MEMBER_CHARID and PT_MEMBER_ACCID
30403017

3041-
Example 1: list party member names
3018+
Example 1: Listing party member names
30423019

30433020
// get the party member names
3044-
getpartymember(getcharid(CHAR_ID_PARTY), 0);
3045-
3046-
// It's a good idea to copy the global temporary $@partymember*****
3047-
// variables to your own scope variables because if you have pauses in
3048-
// this script (sleep, sleep2, next, close2, input, menu, select, or
3049-
// prompt), another player could click this NPC, trigger
3050-
// 'getpartymember', and overwrite the $@partymember***** variables.
3051-
.@count = $@partymembercount;
3052-
copyarray(.@name$[0], $@partymembername$[0], $@partymembercount);
3021+
.@count = getpartymember(getcharid(CHAR_ID_PARTY), PT_MEMBER_NAME, .@name$);
30533022

30543023
// list the party member names
30553024
for (.@i = 0; .@i < .@count; ++.@i) {
30563025
mes((.@i +1) + ". ^0000FF" + .@name$[.@i] + "^000000");
30573026
}
30583027
close();
30593028

3060-
3061-
Example 2: check party count (with a next() pause), before warping to event
3062-
3063-
.register_num = 5; // How many party members are required?
3029+
Example 2: Get online count
30643030

30653031
// get the charID and accountID of character's party members
3066-
getpartymember(getcharid(CHAR_ID_PARTY), 1);
3067-
getpartymember(getcharid(CHAR_ID_PARTY), 2);
3068-
3069-
if ($@partymembercount != .register_num) {
3070-
mes("Please form a party of "+ .register_num +" to continue");
3071-
close();
3072-
}
3032+
// we only need to count the member once so we assign that
3033+
// to the our second command call
3034+
getpartymember(getcharid(CHAR_ID_PARTY), PT_MEMBER_CHARID, .@charid);
3035+
.@count = getpartymember(getcharid(CHAR_ID_PARTY), PT_MEMBER_ACCID, .@accid);
30733036

3074-
// loop through both and use 'isloggedin' to count online party members
3075-
for (.@i = 0; .@i < $@partymembercount; ++.@i)
3076-
if (isloggedin($@partymemberaid[.@i], $@partymembercid[.@i]))
3037+
for (.@i = 0; .@i < .@count; ++.@i) {
3038+
if (isloggedin(.@accid[.@i], .@charid[.@i]))
30773039
.@count_online++;
3078-
// We search accountID & charID because a single party can have
3079-
// multiple characters from the same account. Without searching
3080-
// through the charID, if a player has 2 characters from the same
3081-
// account inside the party but only 1 char online, it would count
3082-
// their online char twice.
3083-
3084-
if (.@count_online != .register_num) {
3085-
mes("All your party members must be online to continue");
3086-
close();
30873040
}
3088-
3089-
// copy the array to prevent players cheating the system
3090-
copyarray(.@partymembercid, $@partymembercid, .register_num);
3091-
3092-
mes("Are you ready?");
3093-
next(); // careful here
3094-
select("Yes");
3095-
3096-
// When a script hits a next, menu, sleep or input that pauses the
3097-
// script, players can invite or /leave and make changes in their
3098-
// party. To prevent this, we call getpartymember again and compare
3099-
// with the original values.
3100-
3101-
getpartymember(getcharid(CHAR_ID_PARTY), 1);
3102-
if ($@partymembercount != .register_num) {
3103-
mes("You've made changes to your party !");
3104-
close();
3105-
}
3106-
for (.@i = 0; .@i < $@partymembercount; ++.@i) {
3107-
if (.@partymembercid[.@i] != $@partymembercid[.@i]) {
3108-
mes("You've made changes to your party !");
3109-
close();
3110-
}
3111-
}
3112-
3113-
// Finally, it's safe to start the event!
3114-
warpparty("event_map", 0, 0, getcharid(CHAR_ID_PARTY), true);
3041+
end;
31153042

31163043
---------------------------------------
31173044

maps/re/iz_ac02.mcache

-93 Bytes
Binary file not shown.

maps/re/iz_ac02_a.mcache

-93 Bytes
Binary file not shown.

maps/re/iz_ac02_b.mcache

-93 Bytes
Binary file not shown.

maps/re/iz_ac02_c.mcache

-93 Bytes
Binary file not shown.

maps/re/iz_ac02_d.mcache

-93 Bytes
Binary file not shown.

npc/custom/quests/hunting_missions.txt

+5-5
Original file line numberDiff line numberDiff line change
@@ -275,11 +275,11 @@ OnNPCKillEvent:
275275
} else if (.Party) {
276276
set .@mob, killedrid;
277277
getmapxy(.@map1$, .@x1, .@y1, UNITTYPE_PC);
278-
getpartymember getcharid(CHAR_ID_PARTY),1;
279-
getpartymember getcharid(CHAR_ID_PARTY),2;
280-
for(set .@i,0; .@i<$@partymembercount; set .@i,.@i+1) {
281-
if (isloggedin($@partymemberaid[.@i], $@partymembercid[.@i])) {
282-
attachrid $@partymemberaid[.@i];
278+
getpartymember(getcharid(CHAR_ID_PARTY), PT_MEMBER_ACCID, .@accid);
279+
.@count = getpartymember(getcharid(CHAR_ID_PARTY), PT_MEMBER_CHARID, .@charid);
280+
for (.@i = 0; .@i < .@count; .@i++) {
281+
if (isloggedin(.@accid[.@i], .@charid[.@i])) {
282+
attachrid(.@accid[.@i]);
283283
if (#Mission_Count && Mission0 && Hp > 0) {
284284
getmapxy(.@map2$, .@x2, .@y2, UNITTYPE_PC);
285285
if ((.@map1$ == .@map2$ || .Party == 1) && (distance(.@x1,.@y1,.@x2,.@y2) <= 30 || .Party < 3)) {

npc/other/marriage.txt

+2-4
Original file line numberDiff line numberDiff line change
@@ -577,8 +577,7 @@ prt_church,100,128,4 script Bishop#w 1_M_PASTOR,{
577577
if (!getpartnerid()) {
578578
if (!$@wedding) {
579579
if (wedding_sign == 1) {
580-
getpartymember(getcharid(CHAR_ID_PARTY));
581-
.@partymembercount = $@partymembercount;
580+
.@partymembercount = getpartymember(getcharid(CHAR_ID_PARTY), PT_MEMBER_ACCID, .@temp);
582581
if (.@partymembercount == 2) {
583582
if (Sex == SEX_MALE) {
584583
$@wedding = 1;
@@ -648,8 +647,7 @@ prt_church,100,128,4 script Bishop#w 1_M_PASTOR,{
648647
}
649648
else if ($@wedding == 1) {
650649
if (wedding_sign == 1) {
651-
getpartymember(getcharid(CHAR_ID_PARTY));
652-
.@partymembercount = $@partymembercount;
650+
.@partymembercount = getpartymember(getcharid(CHAR_ID_PARTY), PT_MEMBER_ACCID, .@temp);
653651
if (.@partymembercount == 2) {
654652
if (Sex == SEX_FEMALE) {
655653
if (strcharinfo(PC_NAME) == $@wed_bride$) {

npc/quests/guildrelay.txt

+1-2
Original file line numberDiff line numberDiff line change
@@ -2527,8 +2527,7 @@
25272527
close;
25282528
}
25292529
}
2530-
getpartymember(getcharid(CHAR_ID_PARTY));
2531-
.@partymembercount = $@partymembercount;
2530+
.@partymembercount = getpartymember(getcharid(CHAR_ID_PARTY), PT_MEMBER_ACCID, .@temp);
25322531
.@partyleader = getpartyleader(getcharid(CHAR_ID_PARTY),2);
25332532
if (guildrelay_q == 91) {
25342533
if (.@partymembercount == 6) {

npc/quests/partyrelay.txt

+4-8
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@
3434
//=========================================================================
3535

3636
payon,103,113,3 script Ledrion#payon::RelayLedrion 4_M_MANAGER,{
37-
getpartymember(getcharid(CHAR_ID_PARTY));
38-
.@partymembercount = $@partymembercount;
37+
.@partymembercount = getpartymember(getcharid(CHAR_ID_PARTY), PT_MEMBER_ACCID, .@temp);
3938
.@partyleader = getpartyleader(getcharid(CHAR_ID_PARTY),2);
4039
if (checkweight(Resin,300) == 0) {
4140
mes "^3355FFWait a minute! You're";
@@ -402,8 +401,7 @@ payon,103,113,3 script Ledrion#payon::RelayLedrion 4_M_MANAGER,{
402401
}
403402

404403
payon,83,327,3 script Gatan#payon::RelayGatan 4_M_04,{
405-
getpartymember(getcharid(CHAR_ID_PARTY));
406-
.@partymembercount = $@partymembercount;
404+
.@partymembercount = getpartymember(getcharid(CHAR_ID_PARTY), PT_MEMBER_ACCID, .@temp);
407405
.@partyleader = getpartyleader(getcharid(CHAR_ID_PARTY),2);
408406
if (checkweight(Resin,300) == 0) {
409407
mes "^3355FFWait a minute! You're";
@@ -1837,8 +1835,7 @@ payon,83,327,3 script Gatan#payon::RelayGatan 4_M_04,{
18371835
}
18381836

18391837
payon,204,221,3 script Bafhail#payon::RelayBafhail 4_M_JOB_BLACKSMITH,{
1840-
getpartymember(getcharid(CHAR_ID_PARTY));
1841-
.@partymembercount = $@partymembercount;
1838+
.@partymembercount = getpartymember(getcharid(CHAR_ID_PARTY), PT_MEMBER_ACCID, .@temp);
18421839
.@partyleader = getpartyleader(getcharid(CHAR_ID_PARTY),2);
18431840
if (checkweight(Resin,300) == 0) {
18441841
mes "^3355FFWait a minute! You're";
@@ -2470,8 +2467,7 @@ payon,204,221,3 script Bafhail#payon::RelayBafhail 4_M_JOB_BLACKSMITH,{
24702467
}
24712468

24722469
payon,168,314,3 script Lospii#payon::RelayLospii 4_M_KID1,{
2473-
getpartymember(getcharid(CHAR_ID_PARTY));
2474-
.@partymembercount = $@partymembercount;
2470+
.@partymembercount = getpartymember(getcharid(CHAR_ID_PARTY), PT_MEMBER_ACCID, .@temp);
24752471
.@partyleader = getpartyleader(getcharid(CHAR_ID_PARTY),2);
24762472
if (checkweight(Resin,300) == 0) {
24772473
mes "^3355FFWait a minute! You're";

npc/quests/quests_louyang.txt

+3-6
Original file line numberDiff line numberDiff line change
@@ -4643,8 +4643,7 @@ lou_in02,77,37,7 script Hermit 4_M_CHNOLD,{
46434643
mes strcharinfo(PC_NAME)+ "...!";
46444644
mes "Your name is now engraved on this bloody pledge board. We will fight together to the death for Louyang's future!";
46454645
next;
4646-
getpartymember(getcharid(CHAR_ID_PARTY));
4647-
@partymember = $@partymembercount;
4646+
@partymember = getpartymember(getcharid(CHAR_ID_PARTY), PT_MEMBER_ACCID, .@temp);
46484647
if (getpartyleader(getcharid(CHAR_ID_PARTY),1) == getcharid(CHAR_ID_CHAR) || !@partymember) {
46494648
mes "[Sun Mao]";
46504649
mes "Now, the most important thing for our cause is to gather more recruits and increase our numbers. Please find others who will join us in our fight.";
@@ -4677,8 +4676,7 @@ lou_in02,77,37,7 script Hermit 4_M_CHNOLD,{
46774676
mes "Go back safe.";
46784677
close;
46794678
}
4680-
getpartymember(getcharid(CHAR_ID_PARTY));
4681-
@partymember = $@partymembercount;
4679+
@partymember = getpartymember(getcharid(CHAR_ID_PARTY), PT_MEMBER_ACCID, .@temp);
46824680
if (QL_REVOL < 8) {
46834681
if (@partymember == QL_REVOL +1) {
46844682
if (@partymember != 8) {
@@ -4869,8 +4867,7 @@ lou_in02,77,37,7 script Hermit 4_M_CHNOLD,{
48694867

48704868
lou_in01,43,147,3 script Gunpowder Expert 4_M_ALCHE_C,{
48714869
if (ch_make == 0) {
4872-
getpartymember(getcharid(CHAR_ID_PARTY));
4873-
@partymember = $@partymembercount;
4870+
@partymember = getpartymember(getcharid(CHAR_ID_PARTY), PT_MEMBER_ACCID, .@temp);
48744871
if (!QL_REVOL) {
48754872
mes "[Hao Chenryu]";
48764873
mes "Who...";

npc/quests/quests_morocc.txt

+2-6
Original file line numberDiff line numberDiff line change
@@ -946,9 +946,7 @@ moc_fild20,354,183,3 script Continental Guard#01::MocConGuard 4_M_MOC_SOLDIER,3,
946946
close;
947947
case 2:
948948
if ($@re_moc < 3) {
949-
getpartymember(getcharid(CHAR_ID_PARTY));
950-
.@partymembercount = $@partymembercount;
951-
copyarray .@partymembername$[0],$@partymembername$[0],.@partymembercount;
949+
.@partymembercount = getpartymember(getcharid(CHAR_ID_PARTY), PT_MEMBER_NAME, .@partymembername$);
952950
while (.@partymembercount >= 0) {
953951
.@name$ = .@partymembername$[.@partymembercount];
954952
if (isloggedin(getcharid(CHAR_ID_ACCOUNT,.@name$))) {
@@ -1009,9 +1007,7 @@ moc_fild20,354,183,3 script Continental Guard#01::MocConGuard 4_M_MOC_SOLDIER,3,
10091007
mes "[Continental Guard]";
10101008
mes "Ah, you're an adventurer working for the Continental Guard. Nice to meet you. Feel free to ask me if you need my assistance.";
10111009
next;
1012-
getpartymember(getcharid(CHAR_ID_PARTY));
1013-
.@partymembercount = $@partymembercount;
1014-
copyarray .@partymembername$[0],$@partymembername$[0],.@partymembercount;
1010+
.@partymembercount = getpartymember(getcharid(CHAR_ID_PARTY), PT_MEMBER_NAME, .@partymembername$);
10151011
while (.@partymembercount >= 0) {
10161012
.@name$ = .@partymembername$[.@partymembercount];
10171013
if (isloggedin(getcharid(CHAR_ID_ACCOUNT,.@name$))) {

npc/quests/quests_nameless.txt

+1-2
Original file line numberDiff line numberDiff line change
@@ -10177,8 +10177,7 @@ moc_fild18,108,116,0 script #treasure CLEAR_NPC,{
1017710177
mes "protection to get the treasure.^000000";
1017810178
next;
1017910179
input(.@input$);
10180-
getpartymember(getcharid(CHAR_ID_PARTY));
10181-
.@partymembercount = $@partymembercount;
10180+
.@partymembercount = getpartymember(getcharid(CHAR_ID_PARTY), PT_MEMBER_ACCID, .@temp);
1018210181
if (.@partymembercount > 1) {
1018310182
if ((.@input$ == "OpenSesame" && treasure_nd == 9) || (.@input$ == "UnlockTreasure" && treasure_nd == 10)) {
1018410183
mes "^3355FFThe Z Gang must have split";

npc/re/instances/MalangdoCulvert.txt

+2-3
Original file line numberDiff line numberDiff line change
@@ -784,9 +784,8 @@ OnEnable:
784784
areamonster(.@map$, .@c[0], .@c[1], .@c[2], .@c[3], _("Abysmal Cornutus"), MD_CORNUTUS, rand(1, 3), .@label$);
785785
specialeffect(EF_MAPPILLAR2, ALL_SAMEMAP); //currently broken
786786
getmapxy(.@map$, .@x, .@y, UNITTYPE_NPC);
787-
getpartymember('party_id, 2);
788-
copyarray(.@partymemberaid[0], $@partymemberaid[0], $@partymembercount);
789-
for(.@i = 0; .@i<$@partymembercount; ++.@i) {
787+
.@partymembercount = getpartymember('party_id, PT_MEMBER_ACCID, .@partymemberaid);
788+
for(.@i = 0; .@i < .@partymembercount; ++.@i) {
790789
if (attachrid(.@partymemberaid[.@i])) {
791790
if (strcharinfo(PC_MAP) == .@map$)
792791
viewpoint(0, .@x, .@y, .@index, C_YELLOW);

0 commit comments

Comments
 (0)