Skip to content

Commit

Permalink
Merge branch 'master' into getguildmember
Browse files Browse the repository at this point in the history
  • Loading branch information
MishimaHaruna authored Aug 31, 2024
2 parents 5cb55bb + 17cd588 commit 7cd029a
Show file tree
Hide file tree
Showing 18 changed files with 122 additions and 154 deletions.
6 changes: 6 additions & 0 deletions doc/constants_pre-re.md
Original file line number Diff line number Diff line change
Expand Up @@ -5568,6 +5568,12 @@
- `SIEGE_TYPE_SE`: 1
- `SIEGE_TYPE_TE`: 2

### partymember types

- `PT_MEMBER_NAME`: 0
- `PT_MEMBER_CHARID`: 1
- `PT_MEMBER_ACCID`: 2

### guildinfo types

- `GUILDINFO_NAME`: 0
Expand Down
6 changes: 6 additions & 0 deletions doc/constants_re.md
Original file line number Diff line number Diff line change
Expand Up @@ -5568,6 +5568,12 @@
- `SIEGE_TYPE_SE`: 1
- `SIEGE_TYPE_TE`: 2

### partymember types

- `PT_MEMBER_NAME`: 0
- `PT_MEMBER_CHARID`: 1
- `PT_MEMBER_ACCID`: 2

### guildinfo types

- `GUILDINFO_NAME`: 0
Expand Down
113 changes: 20 additions & 93 deletions doc/script_commands.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3000,118 +3000,45 @@ Lets say the ID of a party was saved as a global variable:

---------------------------------------

*getpartymember(<party id>{, <type>})
*getpartymember(<party_id>, <type>, <array>)

This command will find all members of a specified party and returns their
names (or character id or account id depending on the value of "type")
into an array of temporary global variables. There's actually quite a few
commands like this which will fill a special variable with data upon
execution and not do anything else.

Upon executing this,

$@partymembername$[] is a global temporary string array which contains all
the names of these party members.
(only set when type is 0 or not specified)

$@partymembercid[] is a global temporary number array which contains the
character id of these party members.
(only set when type is 1)

$@partymemberaid[] is a global temporary number array which contains the
account id of these party members.
(only set when type is 2)
This command will find all members of a specified <party_id>, copy their
names (or character id or account id) depending on the <type> into <array>
and returns the number of party members that were found.

$@partymembercount is the number of party members that were found.
Valid <type> are:

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

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

Example 1: list party member names
Example 1: Listing party member names

// get the party member names
getpartymember(getcharid(CHAR_ID_PARTY), 0);

// It's a good idea to copy the global temporary $@partymember*****
// variables to your own scope variables because if you have pauses in
// this script (sleep, sleep2, next, close2, input, menu, select, or
// prompt), another player could click this NPC, trigger
// 'getpartymember', and overwrite the $@partymember***** variables.
.@count = $@partymembercount;
copyarray(.@name$[0], $@partymembername$[0], $@partymembercount);
.@count = getpartymember(getcharid(CHAR_ID_PARTY), PT_MEMBER_NAME, .@name$);

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


Example 2: check party count (with a next() pause), before warping to event

.register_num = 5; // How many party members are required?
Example 2: Get online count

// get the charID and accountID of character's party members
getpartymember(getcharid(CHAR_ID_PARTY), 1);
getpartymember(getcharid(CHAR_ID_PARTY), 2);

if ($@partymembercount != .register_num) {
mes("Please form a party of "+ .register_num +" to continue");
close();
}
// we only need to count the member once so we assign that
// to the our second command call
getpartymember(getcharid(CHAR_ID_PARTY), PT_MEMBER_CHARID, .@charid);
.@count = getpartymember(getcharid(CHAR_ID_PARTY), PT_MEMBER_ACCID, .@accid);

// loop through both and use 'isloggedin' to count online party members
for (.@i = 0; .@i < $@partymembercount; ++.@i)
if (isloggedin($@partymemberaid[.@i], $@partymembercid[.@i]))
for (.@i = 0; .@i < .@count; ++.@i) {
if (isloggedin(.@accid[.@i], .@charid[.@i]))
.@count_online++;
// We search accountID & charID because a single party can have
// multiple characters from the same account. Without searching
// through the charID, if a player has 2 characters from the same
// account inside the party but only 1 char online, it would count
// their online char twice.

if (.@count_online != .register_num) {
mes("All your party members must be online to continue");
close();
}

// copy the array to prevent players cheating the system
copyarray(.@partymembercid, $@partymembercid, .register_num);

mes("Are you ready?");
next(); // careful here
select("Yes");

// When a script hits a next, menu, sleep or input that pauses the
// script, players can invite or /leave and make changes in their
// party. To prevent this, we call getpartymember again and compare
// with the original values.

getpartymember(getcharid(CHAR_ID_PARTY), 1);
if ($@partymembercount != .register_num) {
mes("You've made changes to your party !");
close();
}
for (.@i = 0; .@i < $@partymembercount; ++.@i) {
if (.@partymembercid[.@i] != $@partymembercid[.@i]) {
mes("You've made changes to your party !");
close();
}
}

// Finally, it's safe to start the event!
warpparty("event_map", 0, 0, getcharid(CHAR_ID_PARTY), true);
end;

---------------------------------------

Expand Down
Binary file modified maps/re/iz_ac02.mcache
Binary file not shown.
Binary file modified maps/re/iz_ac02_a.mcache
Binary file not shown.
Binary file modified maps/re/iz_ac02_b.mcache
Binary file not shown.
Binary file modified maps/re/iz_ac02_c.mcache
Binary file not shown.
Binary file modified maps/re/iz_ac02_d.mcache
Binary file not shown.
10 changes: 5 additions & 5 deletions npc/custom/quests/hunting_missions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -275,11 +275,11 @@ OnNPCKillEvent:
} else if (.Party) {
set .@mob, killedrid;
getmapxy(.@map1$, .@x1, .@y1, UNITTYPE_PC);
getpartymember getcharid(CHAR_ID_PARTY),1;
getpartymember getcharid(CHAR_ID_PARTY),2;
for(set .@i,0; .@i<$@partymembercount; set .@i,.@i+1) {
if (isloggedin($@partymemberaid[.@i], $@partymembercid[.@i])) {
attachrid $@partymemberaid[.@i];
getpartymember(getcharid(CHAR_ID_PARTY), PT_MEMBER_ACCID, .@accid);
.@count = getpartymember(getcharid(CHAR_ID_PARTY), PT_MEMBER_CHARID, .@charid);
for (.@i = 0; .@i < .@count; .@i++) {
if (isloggedin(.@accid[.@i], .@charid[.@i])) {
attachrid(.@accid[.@i]);
if (#Mission_Count && Mission0 && Hp > 0) {
getmapxy(.@map2$, .@x2, .@y2, UNITTYPE_PC);
if ((.@map1$ == .@map2$ || .Party == 1) && (distance(.@x1,.@y1,.@x2,.@y2) <= 30 || .Party < 3)) {
Expand Down
6 changes: 2 additions & 4 deletions npc/other/marriage.txt
Original file line number Diff line number Diff line change
Expand Up @@ -577,8 +577,7 @@ prt_church,100,128,4 script Bishop#w 1_M_PASTOR,{
if (!getpartnerid()) {
if (!$@wedding) {
if (wedding_sign == 1) {
getpartymember(getcharid(CHAR_ID_PARTY));
.@partymembercount = $@partymembercount;
.@partymembercount = getpartymember(getcharid(CHAR_ID_PARTY), PT_MEMBER_ACCID, .@temp);
if (.@partymembercount == 2) {
if (Sex == SEX_MALE) {
$@wedding = 1;
Expand Down Expand Up @@ -648,8 +647,7 @@ prt_church,100,128,4 script Bishop#w 1_M_PASTOR,{
}
else if ($@wedding == 1) {
if (wedding_sign == 1) {
getpartymember(getcharid(CHAR_ID_PARTY));
.@partymembercount = $@partymembercount;
.@partymembercount = getpartymember(getcharid(CHAR_ID_PARTY), PT_MEMBER_ACCID, .@temp);
if (.@partymembercount == 2) {
if (Sex == SEX_FEMALE) {
if (strcharinfo(PC_NAME) == $@wed_bride$) {
Expand Down
3 changes: 1 addition & 2 deletions npc/quests/guildrelay.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2527,8 +2527,7 @@
close;
}
}
getpartymember(getcharid(CHAR_ID_PARTY));
.@partymembercount = $@partymembercount;
.@partymembercount = getpartymember(getcharid(CHAR_ID_PARTY), PT_MEMBER_ACCID, .@temp);
.@partyleader = getpartyleader(getcharid(CHAR_ID_PARTY),2);
if (guildrelay_q == 91) {
if (.@partymembercount == 6) {
Expand Down
12 changes: 4 additions & 8 deletions npc/quests/partyrelay.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@
//=========================================================================

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

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

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

payon,168,314,3 script Lospii#payon::RelayLospii 4_M_KID1,{
getpartymember(getcharid(CHAR_ID_PARTY));
.@partymembercount = $@partymembercount;
.@partymembercount = getpartymember(getcharid(CHAR_ID_PARTY), PT_MEMBER_ACCID, .@temp);
.@partyleader = getpartyleader(getcharid(CHAR_ID_PARTY),2);
if (checkweight(Resin,300) == 0) {
mes "^3355FFWait a minute! You're";
Expand Down
9 changes: 3 additions & 6 deletions npc/quests/quests_louyang.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4643,8 +4643,7 @@ lou_in02,77,37,7 script Hermit 4_M_CHNOLD,{
mes strcharinfo(PC_NAME)+ "...!";
mes "Your name is now engraved on this bloody pledge board. We will fight together to the death for Louyang's future!";
next;
getpartymember(getcharid(CHAR_ID_PARTY));
@partymember = $@partymembercount;
@partymember = getpartymember(getcharid(CHAR_ID_PARTY), PT_MEMBER_ACCID, .@temp);
if (getpartyleader(getcharid(CHAR_ID_PARTY),1) == getcharid(CHAR_ID_CHAR) || !@partymember) {
mes "[Sun Mao]";
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.";
Expand Down Expand Up @@ -4677,8 +4676,7 @@ lou_in02,77,37,7 script Hermit 4_M_CHNOLD,{
mes "Go back safe.";
close;
}
getpartymember(getcharid(CHAR_ID_PARTY));
@partymember = $@partymembercount;
@partymember = getpartymember(getcharid(CHAR_ID_PARTY), PT_MEMBER_ACCID, .@temp);
if (QL_REVOL < 8) {
if (@partymember == QL_REVOL +1) {
if (@partymember != 8) {
Expand Down Expand Up @@ -4869,8 +4867,7 @@ lou_in02,77,37,7 script Hermit 4_M_CHNOLD,{

lou_in01,43,147,3 script Gunpowder Expert 4_M_ALCHE_C,{
if (ch_make == 0) {
getpartymember(getcharid(CHAR_ID_PARTY));
@partymember = $@partymembercount;
@partymember = getpartymember(getcharid(CHAR_ID_PARTY), PT_MEMBER_ACCID, .@temp);
if (!QL_REVOL) {
mes "[Hao Chenryu]";
mes "Who...";
Expand Down
8 changes: 2 additions & 6 deletions npc/quests/quests_morocc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -946,9 +946,7 @@ moc_fild20,354,183,3 script Continental Guard#01::MocConGuard 4_M_MOC_SOLDIER,3,
close;
case 2:
if ($@re_moc < 3) {
getpartymember(getcharid(CHAR_ID_PARTY));
.@partymembercount = $@partymembercount;
copyarray .@partymembername$[0],$@partymembername$[0],.@partymembercount;
.@partymembercount = getpartymember(getcharid(CHAR_ID_PARTY), PT_MEMBER_NAME, .@partymembername$);
while (.@partymembercount >= 0) {
.@name$ = .@partymembername$[.@partymembercount];
if (isloggedin(getcharid(CHAR_ID_ACCOUNT,.@name$))) {
Expand Down Expand Up @@ -1009,9 +1007,7 @@ moc_fild20,354,183,3 script Continental Guard#01::MocConGuard 4_M_MOC_SOLDIER,3,
mes "[Continental Guard]";
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.";
next;
getpartymember(getcharid(CHAR_ID_PARTY));
.@partymembercount = $@partymembercount;
copyarray .@partymembername$[0],$@partymembername$[0],.@partymembercount;
.@partymembercount = getpartymember(getcharid(CHAR_ID_PARTY), PT_MEMBER_NAME, .@partymembername$);
while (.@partymembercount >= 0) {
.@name$ = .@partymembername$[.@partymembercount];
if (isloggedin(getcharid(CHAR_ID_ACCOUNT,.@name$))) {
Expand Down
3 changes: 1 addition & 2 deletions npc/quests/quests_nameless.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10177,8 +10177,7 @@ moc_fild18,108,116,0 script #treasure CLEAR_NPC,{
mes "protection to get the treasure.^000000";
next;
input(.@input$);
getpartymember(getcharid(CHAR_ID_PARTY));
.@partymembercount = $@partymembercount;
.@partymembercount = getpartymember(getcharid(CHAR_ID_PARTY), PT_MEMBER_ACCID, .@temp);
if (.@partymembercount > 1) {
if ((.@input$ == "OpenSesame" && treasure_nd == 9) || (.@input$ == "UnlockTreasure" && treasure_nd == 10)) {
mes "^3355FFThe Z Gang must have split";
Expand Down
5 changes: 2 additions & 3 deletions npc/re/instances/MalangdoCulvert.txt
Original file line number Diff line number Diff line change
Expand Up @@ -784,9 +784,8 @@ OnEnable:
areamonster(.@map$, .@c[0], .@c[1], .@c[2], .@c[3], _("Abysmal Cornutus"), MD_CORNUTUS, rand(1, 3), .@label$);
specialeffect(EF_MAPPILLAR2, ALL_SAMEMAP); //currently broken
getmapxy(.@map$, .@x, .@y, UNITTYPE_NPC);
getpartymember('party_id, 2);
copyarray(.@partymemberaid[0], $@partymemberaid[0], $@partymembercount);
for(.@i = 0; .@i<$@partymembercount; ++.@i) {
.@partymembercount = getpartymember('party_id, PT_MEMBER_ACCID, .@partymemberaid);
for(.@i = 0; .@i < .@partymembercount; ++.@i) {
if (attachrid(.@partymemberaid[.@i])) {
if (strcharinfo(PC_MAP) == .@map$)
viewpoint(0, .@x, .@y, .@index, C_YELLOW);
Expand Down
Loading

0 comments on commit 7cd029a

Please sign in to comment.