Преглед изворни кода

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!
Aleos пре 6 година
родитељ
комит
26720f041a

+ 25 - 24
doc/script_commands.txt

@@ -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
 
 ---------------------------------------
 

+ 1 - 1
npc/battleground/bg_common.txt

@@ -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")

+ 1 - 1
npc/custom/events/devil_square.txt

@@ -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;

+ 1 - 1
npc/custom/events/mvp_ladder.txt

@@ -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 );

+ 2 - 2
npc/custom/quests/hunting_missions.txt

@@ -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] );

+ 1 - 1
npc/events/halloween_2009.txt

@@ -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:

+ 1 - 1
npc/other/gm_npcs.txt

@@ -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;
 	}

+ 2 - 2
npc/other/monster_race.txt

@@ -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;

+ 3 - 3
npc/other/poring_war.txt

@@ -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);
 	}

+ 3 - 3
npc/quests/guildrelay.txt

@@ -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";

+ 1 - 1
npc/quests/partyrelay.txt

@@ -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]";

+ 2 - 2
npc/re/instances/FacewormsNest.txt

@@ -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));

+ 2 - 2
npc/re/instances/HorrorToyFactory.txt

@@ -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";

+ 1 - 1
npc/re/instances/IsleOfBios.txt

@@ -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];
 		}

+ 1 - 1
npc/re/instances/MalangdoCulvert.txt

@@ -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) {

+ 1 - 1
npc/re/instances/MorseCave.txt

@@ -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;

+ 3 - 3
npc/re/instances/OldGlastHeim.txt

@@ -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;

+ 1 - 1
npc/re/instances/SarahAndFenrir.txt

@@ -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;

+ 1 - 1
npc/re/jobs/3-1/guillotine_cross.txt

@@ -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;

+ 1 - 1
npc/re/jobs/3-1/ranger.txt

@@ -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;

+ 1 - 1
npc/re/quests/quests_15_2.txt

@@ -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];

+ 1 - 1
npc/re/quests/quests_16_1.txt

@@ -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

+ 1 - 1
npc/re/quests/quests_malangdo.txt

@@ -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

+ 42 - 34
src/map/script.cpp

@@ -14977,12 +14977,12 @@ BUILDIN_FUNC(getsavepoint)
  * @param x: Integer variable for output coord X
  * @param y: Integer variable for output coord Y
  * @param type: Type of object
- *   UNITTYPE_PC - Character coord
- *   UNITTYPE_NPC - NPC coord
- *   UNITTYPE_PET - Pet coord
- *   UNITTYPE_HOM - Homun coord
- *   UNITTYPE_MER - Mercenary coord
- *   UNITTYPE_ELEM - Elemental coord
+ *   BL_PC - Character coord
+ *   BL_NPC - NPC coord
+ *   BL_PET - Pet coord
+ *   BL_HOM - Homun coord
+ *   BL_MER - Mercenary coord
+ *   BL_ELEM - Elemental coord
  * @param charname: Name object. If empty or "this" use the current object
  * @return 0 - success; -1 - some error, MapName$,MapX,MapY contains unknown value.
  */
@@ -14995,7 +14995,7 @@ BUILDIN_FUNC(getmapxy)
 	const char *name;
 	char prefix;
 
-	int x,y,type;
+	int x,y,type = BL_PC;
 	char mapname[MAP_NAME_LENGTH];
 
 	if( !data_isreference(script_getdata(st,2)) ) {
@@ -15033,37 +15033,41 @@ BUILDIN_FUNC(getmapxy)
 	}
 
 	// Possible needly check function parameters on C_STR,C_INT,C_INT
-	type=script_getnum(st,5);
+	if (script_hasdata(st, 5))
+		type = script_getnum(st, 5);
 
 	switch (type) {
-		case UNITTYPE_PC:	//Get Character Position
-			if( script_nick2sd(6,sd) )
+		case BL_PC:	//Get Character Position
+			if ((script_isstring(st, 6) && script_nick2sd(6, sd)) || script_mapid2sd(6, sd))
 				bl = &sd->bl;
 			break;
-		case UNITTYPE_NPC:	//Get NPC Position
-			if( script_hasdata(st,6) )
-			{
+		case BL_NPC:	//Get NPC Position
+			if (script_hasdata(st, 6)) {
 				struct npc_data *nd;
-				nd=npc_name2id(script_getstr(st,6));
+
+				if (script_isstring(st, 6))
+					nd = npc_name2id(script_getstr(st, 6));
+				else
+					nd = map_id2nd(script_getnum(st, 6));
 				if (nd)
 					bl = &nd->bl;
-			} else //In case the origin is not an npc?
-				bl=map_id2bl(st->oid);
+			} else //In case the origin is not an NPC?
+				bl = map_id2bl(st->oid);
 			break;
-		case UNITTYPE_PET:	//Get Pet Position
-			if( script_nick2sd(6, sd) && sd->pd )
+		case BL_PET:	//Get Pet Position
+			if (sd->pd && ((script_isstring(st, 6) && script_nick2sd(6, sd)) || script_mapid2sd(6, sd)))
 				bl = &sd->pd->bl;
 			break;
-		case UNITTYPE_HOM:	//Get Homun Position
-			if( script_nick2sd(6, sd) && sd->hd )
+		case BL_HOM:	//Get Homun Position
+			if (sd->hd && ((script_isstring(st, 6) && script_nick2sd(6, sd)) || script_mapid2sd(6, sd)))
 				bl = &sd->hd->bl;
 			break;
-		case UNITTYPE_MER: //Get Mercenary Position
-			if( script_nick2sd(6, sd) && sd->md )
+		case BL_MER: //Get Mercenary Position
+			if (sd->md && ((script_isstring(st, 6) && script_nick2sd(6, sd)) || script_mapid2sd(6, sd)))
 				bl = &sd->md->bl;
 			break;
-		case UNITTYPE_ELEM: //Get Elemental Position
-			if( script_nick2sd(6, sd) && sd->ed )
+		case BL_ELEM: //Get Elemental Position
+			if (sd->ed && ((script_isstring(st, 6) && script_nick2sd(6, sd)) || script_mapid2sd(6, sd)))
 				bl = &sd->ed->bl;
 			break;
 		default:
@@ -17330,7 +17334,7 @@ BUILDIN_FUNC(unitexists)
 BUILDIN_FUNC(getunittype)
 {
 	struct block_list* bl;
-	uint8 value = 0;
+	int value = 0;
 
 	if(!script_rid2bl(2,bl))
 	{
@@ -17339,14 +17343,18 @@ BUILDIN_FUNC(getunittype)
 	}
 
 	switch (bl->type) {
-		case BL_PC:   value = UNITTYPE_PC; break;
-		case BL_NPC:  value = UNITTYPE_NPC; break;
-		case BL_PET:  value = UNITTYPE_PET; break;
-		case BL_MOB:  value = UNITTYPE_MOB; break;
-		case BL_HOM:  value = UNITTYPE_HOM; break;
-		case BL_MER:  value = UNITTYPE_MER; break;
-		case BL_ELEM: value = UNITTYPE_ELEM; break;
-		default:      value = -1; break;
+		case BL_PC:
+		case BL_NPC:
+		case BL_PET:
+		case BL_MOB:
+		case BL_HOM:
+		case BL_MER:
+		case BL_ELEM:
+			value = bl->type;
+			break;
+		default:
+			value = -1;
+			break;
 	}
 
 	script_pushint(st, value);
@@ -24411,7 +24419,7 @@ struct script_function buildin_func[] = {
 	BUILDIN_DEF(npcspeed,"i"), // [Valaris]
 	BUILDIN_DEF(npcwalkto,"ii"), // [Valaris]
 	BUILDIN_DEF(npcstop,""), // [Valaris]
-	BUILDIN_DEF(getmapxy,"rrri?"),	//by Lorky [Lupus]
+	BUILDIN_DEF(getmapxy,"rrr??"),	//by Lorky [Lupus]
 	BUILDIN_DEF(mapid2name,"i"),
 	BUILDIN_DEF(checkoption1,"i?"),
 	BUILDIN_DEF(checkoption2,"i?"),

+ 0 - 10
src/map/script.hpp

@@ -417,16 +417,6 @@ enum questinfo_types {
 	#define FW_HEAVY            900
 #endif
 
-enum getmapxy_types {
-	UNITTYPE_PC = 0,
-	UNITTYPE_NPC,
-	UNITTYPE_PET,
-	UNITTYPE_MOB,
-	UNITTYPE_HOM,
-	UNITTYPE_MER,
-	UNITTYPE_ELEM,
-};
-
 enum unitdata_mobtypes {
 	UMOB_SIZE = 0,
 	UMOB_LEVEL,

+ 8 - 7
src/map/script_constants.hpp

@@ -3930,13 +3930,14 @@
 	export_constant(SCSTART_NOICON);
 
 	/* unit control - types */
-	export_constant(UNITTYPE_PC);
-	export_constant(UNITTYPE_NPC);
-	export_constant(UNITTYPE_PET);
-	export_constant(UNITTYPE_MOB);
-	export_constant(UNITTYPE_HOM);
-	export_constant(UNITTYPE_MER);
-	export_constant(UNITTYPE_ELEM);
+	/* Send deprecation notice and temporarily replace with new constant value. */
+	export_deprecated_constant2("UNITTYPE_PC", BL_PC);
+	export_deprecated_constant2("UNITTYPE_NPC", BL_NPC);
+	export_deprecated_constant2("UNITTYPE_PET", BL_PET);
+	export_deprecated_constant2("UNITTYPE_MOB", BL_MOB);
+	export_deprecated_constant2("UNITTYPE_HOM", BL_HOM);
+	export_deprecated_constant2("UNITTYPE_MER", BL_MER);
+	export_deprecated_constant2("UNITTYPE_ELEM", BL_ELEM);
 
 	/* unit control - mob */
 	export_constant(UMOB_SIZE);