Skip to content
Permalink
Browse files
Updated script command getmapxy parameters (#3890)
* Fixes #3100.
* Script command getmapxy will now allow integer values for the search value.
* Deprecated UNITTYPE constants as they were replaced by BL.
* Defaulted BL_PC as the target for script command getmapxpy.
* Updated script command getunittype return value to return BL constants.
* Updated scripts to new BL constants.
Thanks to @pajodex's suggestion and @Lemongrass3110!
  • Loading branch information
aleos89 committed Jan 30, 2019
1 parent de8c707 commit 26720f041a3cd0edbaa975bfc70345a30e9bf706
@@ -3046,7 +3046,7 @@ If <type> is false the command only returns the count of unidentified items.
//
---------------------------------------

*getmapxy("<variable for map name>",<variable for x>,<variable for y>,<type>{,"<search string>"})
*getmapxy("<variable for map name>",<variable for x>,<variable for y>{,<type>,"<search value>"})

This function will locate a character object, NPC object or pet's coordinates
and place their coordinates into the variables specified when calling it. It
@@ -3055,23 +3055,23 @@ not variables or the search was not successful.

Type is the type of object to search for:

UNITTYPE_PC - Character object
UNITTYPE_NPC - NPC object
UNITTYPE_PET - Pet object
UNITTYPE_HOM - Homunculus object
UNITTYPE_MER - Mercenary object
UNITTYPE_ELEM - Elemental object
BL_PC - Character object (default)
BL_NPC - NPC object
BL_PET - Pet object
BL_HOM - Homunculus object
BL_MER - Mercenary object
BL_ELEM - Elemental object

The search string is optional. If it is not specified, the location of the
invoking character will always be returned for types UNITTYPE_PC and UNITTYPE_PET,
the location of the NPC running this function for type 1.
The search value is optional. If it is not specified, the location of the
invoking character will always be returned for types BL_PC and BL_PET,
the location of the NPC running this function for type BL_NPC.

If a search string is specified, for types UNITTYPE_PC and UNITTYPE_NPC, the
character or NPC with the specified name will be located.
If a search value is specified, for types BL_PC and BL_NPC, the
character or NPC with the specified name or GID will be located.

If type is UNITTYPE_PET/UNITTYPE_HOM/UNITTYPE_MER/UNITTYPE_ELEM, the search
will locate the current object of the character who's name is given in the
search string, it will NOT locate the object by name.
If type is BL_PET/BL_HOM/BL_MER/BL_ELEM, the search
will locate the current object of the character who's name/GID is given in the
search value, it will NOT locate the object by name.

Example:

@@ -3083,7 +3083,7 @@ Example:
prontera,164,299,3%TAB%script%TAB%Nyah%TAB%730,{
mes "My name is Nyah.";
mes "I will now search for Meh all across the world!";
if (getmapxy(@mapname$, @mapx, @mapy, UNITTYPE_NPC, "Meh") != 0) {
if (getmapxy(@mapname$, @mapx, @mapy, BL_NPC, "Meh") != 0) {
mes "I can't seem to find Meh anywhere!";
close;
}
@@ -4844,7 +4844,7 @@ Example to get Crimson Weapon with Ghost property:
// when Valkyrie Randgris killed
OnNPCKillEvent:
if (killedrid == 1751 && rand(0,1000) > 950) { // Valkyrie Randgris
getmapxy(.@map$,.@x,.@y,UNITTYPE_PC);
getmapxy(.@map$,.@x,.@y,BL_PC);
setarray .@OptID[0],RDMOPT_ATTR_TOLERACE_NOTHING,RDMOPT_RACE_TOLERACE_HUMAN;
setarray .@OptVal[0],10,5;
setarray .@OptParam[0],0;
@@ -7815,13 +7815,14 @@ it does.
Returns the type of object from the given Game ID. Returns -1 if the given GID does not
exist.

UNITTYPE_PC 0
UNITTYPE_NPC 1
UNITTYPE_PET 2
UNITTYPE_MOB 3
UNITTYPE_HOM 4
UNITTYPE_MER 5
UNITTYPE_ELEM 6
Return values:
BL_PC - Character object
BL_MOB - Monster object
BL_PET - Pet object
BL_HOM - Homunculus object
BL_MER - Mercenary object
BL_NPC - NPC object
BL_ELEM - Elemental object

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

@@ -250,7 +250,7 @@ bat_room,148,150,5 script Teleporter#Battlefield 124,{
mes "[Maroll Battle Recruiter]";
mes "May the war god bless you.";
close2;
getmapxy(.@mapname$,.@x,.@y,UNITTYPE_NPC);
getmapxy(.@mapname$,.@x,.@y,BL_NPC);
if (.@mapname$ == "prontera")
set bat_return,1;
else if (.@mapname$ == "moc_ruins")
@@ -107,7 +107,7 @@ OnClock2200:
disablenpc "ord11-12"; //from npc/warps/pvp.txt
disablenpc "Devil Square Guardian#2";
mapannounce "ordeal_1-1","Devil Square is now closed.", bc_map;
getmapxy .@map$, .@x, .@y, UNITTYPE_NPC;
getmapxy .@map$, .@x, .@y, BL_NPC;
mapwarp "ordeal_1-1", .@map$, .@x, .@y;
killmonsterall "ordeal_1-1";
announce "Devil Square is OPEN. The event will begin in 5 minutes.", bc_all;
@@ -311,7 +311,7 @@ OnInit:
// Config Ends --------------------------------------------------------------

mapannounce .eventmap$, "An administrator has refreshed the server. Please re-register. We apologize for the inconvenience.", bc_map;
getmapxy .map$, .x, .y, UNITTYPE_NPC;
getmapxy .map$, .x, .y, BL_NPC;
mapwarp .eventmap$, .map$, .x, .y;
killmonsterall .eventmap$;
.@size = getarraysize( .@mapflag );
@@ -277,7 +277,7 @@ OnNPCKillEvent:
}
} else if (.Party) {
.@mob = killedrid;
getmapxy(.@map1$,.@x1,.@y1,UNITTYPE_PC);
getmapxy(.@map1$,.@x1,.@y1);
getpartymember getcharid(1),1;
getpartymember getcharid(1),2;
for (.@i = 0; .@i < $@partymembercount; .@i++) {
@@ -287,7 +287,7 @@ OnNPCKillEvent:
set .@HP, readparam(HP, $@partymembercid[.@i]);

if (.@Mission_Count && .@Mission0 && .@HP > 0) {
getmapxy(.@map2$,.@x2,.@y2,UNITTYPE_PC,rid2name($@partymemberaid[.@i]));
getmapxy(.@map2$,.@x2,.@y2,BL_PC,rid2name($@partymemberaid[.@i]));
if ((.@map1$ == .@map2$ || .Party == 1) && (distance(.@x1,.@y1,.@x2,.@y2) <= 30 || .Party < 3)) {
for (.@j = 0; .@j < .Quests; .@j++) {
.@my_mob_id = getvar( getd("Mission"+.@j),$@partymembercid[.@i] );
@@ -244,7 +244,7 @@ prontera,220,72,5 duplicate(09Treats) Trick or Treater#iRO8 706,2,2
mes "[Halloween Wizard]";
mes "Which town do you want to play a trick on?";
next;
getmapxy(.@mapname$,.@mapx,.@mapy,UNITTYPE_PC,""+strcharinfo(0)+"");
getmapxy(.@mapname$,.@mapx,.@mapy,BL_PC,""+strcharinfo(0)+"");
if (.@mapname$ == "prontera") {
switch(select("Geffen:Payon:Alberta:Aldebaran")) {
case 1:
@@ -21,7 +21,7 @@ function script F_GM_NPC {
// To set a minimum GM level to access the NPCs, edit the line below.
if (getgmlevel() < 99) {
// Log the event.
getmapxy(.@map$,.@x,.@y,UNITTYPE_NPC);
getmapxy(.@map$,.@x,.@y,BL_NPC);
logmes strcharinfo(0)+" attempted to access GM NPC "+strnpcinfo(0)+" ("+.@map$+","+.@x+","+.@y+").";
end;
}
@@ -209,7 +209,7 @@ OnInit:
OnEnable:
emotion ET_SURPRISE;
enablenpc strnpcinfo(0);
getmapxy(.@m$,.@x,.@y,UNITTYPE_NPC);
getmapxy(.@m$,.@x,.@y,BL_NPC);
setarray .@mob[1], 1725,1726,1727,1728,1730,1729;
.@n = atoi( strnpcinfo(2) );
monster "p_track01",58,.@y,"The "+ callfunc("F_GetNumSuffix",.@n) +" Racer",.@mob[.@n],1,strnpcinfo(0)+"::OnMyMobDead";
@@ -1692,7 +1692,7 @@ function MN {
OnEnable:
enablenpc strnpcinfo(0);
setarray .@n[1], 1725,1726,1727,1728,1730,1729;
getmapxy(.@m$,.@x,.@y,UNITTYPE_NPC);
getmapxy(.@m$,.@x,.@y,BL_NPC);
.@i = MN;
monster "p_track02",58,.@y,"Monster "+.@i,.@n[.@i],1,strnpcinfo(0)+"::OnMyMobDead";
end;
@@ -302,7 +302,7 @@ poring_w01,96,97,3 script Sweet Devi#wop 738,{
}

OnPCLogoutEvent:
getmapxy .@map$,.@x,.@y,UNITTYPE_PC;
getmapxy .@map$,.@x,.@y;
if (.@map$ == "poring_w02") {
if (WoP_SaveMap$ != "") {
savepoint WoP_SaveMap$,WoP_SaveMap_X,WoP_SaveMap_Y,1,1;
@@ -316,7 +316,7 @@ OnPCLogoutEvent:
end;

OnPCDieEvent:
getmapxy .@map$,.@x,.@y,UNITTYPE_PC;
getmapxy .@map$,.@x,.@y;
if (.@map$ == "poring_w02" && wop_team) {
if (getsavepoint(0) != "poring_w02" && WoP_SaveMap$ == "") {
set WoP_SaveMap$,getsavepoint(0);
@@ -333,7 +333,7 @@ OnPCDieEvent:
end;

OnPCKillEvent:
getmapxy .@map$,.@x,.@y,UNITTYPE_PC;
getmapxy .@map$,.@x,.@y;
if (.@map$ == "poring_w02" && wop_team) {
getnameditem 7773,rid2name(killedrid);
}
@@ -1222,7 +1222,7 @@

- script RelayDummy2::GuildRelay2 754,{
set .@name$,strnpcinfo(1);
getmapxy(.@m$,.@x,.@x,UNITTYPE_NPC);
getmapxy(.@m$,.@x,.@x,BL_NPC);
set .@GID, GetCastleData(.@m$,1);
if (checkweight(1201,1) == 0) {
mes "^3355FFWait a minute! You're";
@@ -1731,7 +1731,7 @@

- script RelayDummy3::GuildRelay3 754,{
set .@name$,strnpcinfo(1);
getmapxy(.@m$,.@x,.@x,UNITTYPE_NPC);
getmapxy(.@m$,.@x,.@x,BL_NPC);
set .@GID, GetCastleData(.@m$,1);
if (checkweight(1201,1) == 0) {
mes "^3355FFWait a minute! You're";
@@ -2416,7 +2416,7 @@

- script GuildDummy4::GuildRelay4 754,{
set .@name$,strnpcinfo(1);
getmapxy(.@m$,.@x,.@x,UNITTYPE_NPC);
getmapxy(.@m$,.@x,.@x,BL_NPC);
set .@GID, GetCastleData(.@m$,1);
if (checkweight(1201,1) == 0) {
mes "^3355FFWait a minute! You're";
@@ -2465,7 +2465,7 @@ payon,168,314,3 script Lospii#payon::RelayLospii 706,{
close;
}
set .@relaytime,gettime(DT_HOUR);
getmapxy(.@m$,.@x,.@y,UNITTYPE_NPC,strnpcinfo(3));
getmapxy(.@m$,.@x,.@y,BL_NPC,strnpcinfo(3));
set .@juwi,getareausers(.@m$,.@x-8,.@y-8,.@x+8,.@y+8);
if (party_relay == 32) {
mes "[Lospii]";
@@ -2043,7 +2043,7 @@ OnTouch_:
specialeffect EF_VENOMDUST;
disablenpc .@npc_name$;
killmonster 'map_name$, .@npc_name$ + "::OnMyMobDead";
getmapxy 'map_name$, .@x, .@y, UNITTYPE_NPC;
getmapxy 'map_name$, .@x, .@y, BL_NPC;
.@mon_num = .@num[atoi(strnpcinfo(2))];
areamonster 'map_name$,.@x-1,.@y-1,.@x+1,.@y+1,"Faceworm Larva",2541,.@mon_num,.@npc_name$ + "::OnMyMobDead";
initnpctimer;
@@ -2215,7 +2215,7 @@ OnInstanceInit:
.@time_txt$ = callfunc( "F_InsertPlural", .@time_m, "Minute" ) + " " + callfunc( "F_InsertPlural", .@time_s, "Second" );
mapannounce 'map_name$, "The actual time for the battle at this stage remaining is " + .@time_txt$ + ".",bc_map,"0xffff33";

getmapxy .@map$, .@x, .@y, UNITTYPE_NPC;
getmapxy .@map$, .@x, .@y, BL_NPC;
stopnpctimer;
specialeffect EF_COIN;
hideonnpc instance_npcname(strnpcinfo(0));
@@ -497,7 +497,7 @@ OnTouch_:
.@count = 5;
break;
}
getmapxy .@map$, .@x, .@y, 0;
getmapxy .@map$, .@x, .@y;
.@npc_name$ = instance_npcname( strnpcinfo(0) );
.@event$ = .@npc_name$ + "::OnMyMobDead";
playBGM "125";
@@ -786,7 +786,7 @@ OnAlert:
setarray .@coord[0],209,27;
break;
default:
getmapxy .@map$, .@coord[0], .@coord[1], UNITTYPE_NPC;
getmapxy .@map$, .@coord[0], .@coord[1], BL_NPC;
break;
}
areamonster 'xm_d_map$,(.@coord[0]-8),(.@coord[1]-8),(.@coord[0]+8),(.@coord[1]+8), "Guard",2990,21, .@npc_name$ + "::OnMyMobDead";
@@ -471,7 +471,7 @@ OnTimer52700:
getpartymember 'party_id, 2, .@account_id;
for ( .@i = 0; .@i < $@partymembercount; .@i++ ) {
if (isloggedin(.@account_id[.@i],.@char_id[.@i]) == true) {
getmapxy .@map$,.@x,.@y, UNITTYPE_PC, .@player_name$[.@i];
getmapxy .@map$,.@x,.@y, BL_PC, .@player_name$[.@i];
if (.@map$ == 'map_dth3$ && distance(.@x,.@y,69,67) < 30)
sc_start SC_FREEZE,17500,0,10000, (SCSTART_NOAVOID|SCSTART_NOTICKDEF|SCSTART_NORATEDEF), .@account_id[.@i];
}
@@ -737,7 +737,7 @@ OnEnable:
areamonster .@map$,.@c[0],.@c[1],.@c[2],.@c[3],"Ancient Kukre",2179,rand(1,3),.@label$;
areamonster .@map$,.@c[0],.@c[1],.@c[2],.@c[3],"Abysmal Cornutus",2177,rand(1,3),.@label$;
specialeffect EF_MAPPILLAR2,ALL_SAMEMAP; //currently broken
getmapxy(.@map$,.@x,.@y,UNITTYPE_NPC);
getmapxy(.@map$,.@x,.@y,BL_NPC);
getpartymember 'party_id,2;
copyarray .@partymemberaid[0],$@partymemberaid[0],$@partymembercount;
for(set .@i,0; .@i<$@partymembercount; set .@i,.@i+1) {
@@ -885,7 +885,7 @@ OnMobDead:
OnStart:
.@npc_name$ = instance_npcname( strnpcinfo(0) );
enablenpc .@npc_name$;
getmapxy .@map$,.@x,.@y, UNITTYPE_NPC;
getmapxy .@map$,.@x,.@y, BL_NPC;
monster 'map_rev$,.@x,.@y,('soul_name$ + "'s Soul"),3007,1, .@npc_name$ + "::OnStop"; // EP14_MORS_DUMMY
initnpctimer;
specialeffect EF_STORMGUST;
@@ -774,7 +774,7 @@ OnTouch_:
else if (.@i == 3) .@mobs = 5;
else if (.@i < 7) .@mobs = 6;
else .@mobs = 7;
getmapxy .@map$,.@x,.@y, UNITTYPE_NPC;
getmapxy .@map$,.@x,.@y, BL_NPC;
specialeffect EF_VENOMDUST;
monster .@map$,.@x,.@y,"Maggot",2467,.@mobs;
disablenpc instance_npcname( strnpcinfo(0) );
@@ -1083,7 +1083,7 @@ OnTouch_:
.@label$ = instance_npcname("#ghmemorialmob05") + "::OnMyMobDead";
else
.@label$ = instance_npcname("#ghmemorialmob06") + "::OnMyMobDead";
getmapxy .@map$,.@x,.@y, UNITTYPE_NPC;
getmapxy .@map$,.@x,.@y, BL_NPC;
monster .@map$,.@x,.@y, "Corrupted Palace Guard", 2468,1, .@label$;
monster .@map$,.@x,.@y, "Archer of Death", 2469,1, .@label$;
monster .@map$,.@x,.@y, "Corrupted Abysmal Knight", 2470,1, .@label$;
@@ -1260,7 +1260,7 @@ OnTouch_:
else if (.@i == 3) .@mobs = 5;
else if (.@i < 7) .@mobs = 6;
else .@mobs = 7;
getmapxy .@map$,.@x,.@y, UNITTYPE_NPC;
getmapxy .@map$,.@x,.@y, BL_NPC;
specialeffect EF_VENOMDUST;
monster .@map$,.@x,.@y,"Maggot",2467,.@mobs;
initnpctimer;
@@ -2021,7 +2021,7 @@ OnMobDead:
1@glast,277,130,8 script Stone Gargoyle#glast_01 4_GARGOYLE_STATUE,2,2,{
end;
OnTouch:
getmapxy .@map$,.@x,.@y, UNITTYPE_NPC;
getmapxy .@map$,.@x,.@y, BL_NPC;
monster .@map$,.@x,.@y, "Mutant Gargoyle",3197,1, instance_npcname( strnpcinfo(0) ) + "::OnMobDead"; // MM_M_GARGOYLE
disablenpc instance_npcname( strnpcinfo(0) );
end;
@@ -3443,7 +3443,7 @@ OnTouch_:
OnTimer:
//FIXME: This is a workaround for...
//var pccount_tt = GetNeighborPcNumber 2
getmapxy(.@map$,.@x,.@y,UNITTYPE_NPC);
getmapxy(.@map$,.@x,.@y,BL_NPC);
setarray .@x[1],.@x-2,.@x+2;
setarray .@y[1],.@y-2,.@y+2;
sleep 1000;
@@ -1582,7 +1582,7 @@ OnInit:
OnEnable:
enablenpc strnpcinfo(0);
initnpctimer;
getmapxy(.@map$,.@x,.@y,UNITTYPE_NPC);
getmapxy(.@map$,.@x,.@y,BL_NPC);
monster "job3_rang02",.@x,.@y,"Egg Bomb",1047,1,strnpcinfo(0)+"::OnMyMobDead";
switch(atoi(strnpcinfo(2))%3) {
case 0: set .@str$,"Hey, I am going to explode. What are you going to do?"; break;
@@ -1902,7 +1902,7 @@ un_bk_q,276,243,4 script Nurse Lapplad#EP15.2MR 4_F_BRZ_WOMAN,{

S_Random:
.rand_npc = getarg(0);
getmapxy .@map$,.@x,.@y, UNITTYPE_NPC, "Patient#EP15.2MR_0" + .rand_npc;
getmapxy .@map$,.@x,.@y, BL_NPC, "Patient#EP15.2MR_0" + .rand_npc;
disablenpc "Patient#EP15.2MR_0" + .rand_npc;
monster .@map$,.@x,.@y, "Convulsing Patient",1015,1,"Nurse Lapplad#EP15.2MR::OnMobDead";
.mob_id = $@mobid[0];
@@ -14869,7 +14869,7 @@ OnTouch_:
unittalk getcharid(3), "" + strcharinfo(0) + " : ?";
sleep2 1000;
specialeffect EF_POISONSMOKE;
getmapxy .@map$, .@x, .@y, UNITTYPE_NPC;
getmapxy .@map$, .@x, .@y, BL_NPC;
monster "prt_q",.@x,.@y,"Resurrected Corpse",1015,1, strnpcinfo(0) + "::OnMyMobDead";// ZOMBIE
monster "prt_q",.@x,.@y,"Maggot",1194,1, strnpcinfo(0) + "::OnMyMobDead";// ARCLOUSE
monster "prt_q",.@x,.@y,"Fly",1035,1, strnpcinfo(0) + "::OnMyMobDead";// HUNTER_FLY
@@ -4184,7 +4184,7 @@ malangdo,133,134,0 script Strange Pile of Sand#7 557,{
setquest .@quest;
if (!rand(3)) {
emotion ET_HUK;
getmapxy(.@map$,.@x,.@y,UNITTYPE_NPC);
getmapxy(.@map$,.@x,.@y,BL_NPC);
monster .@map$,.@x,.@y,"Quick Dark Shadow",2209,1;
} else
getitem 11536,1; //Cat_Hard_Biscuit

0 comments on commit 26720f0

Please sign in to comment.