From 26720f041a3cd0edbaa975bfc70345a30e9bf706 Mon Sep 17 00:00:00 2001 From: Aleos Date: Wed, 30 Jan 2019 17:10:33 -0500 Subject: [PATCH] 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! --- doc/script_commands.txt | 49 +++++++++-------- npc/battleground/bg_common.txt | 2 +- npc/custom/events/devil_square.txt | 2 +- npc/custom/events/mvp_ladder.txt | 2 +- npc/custom/quests/hunting_missions.txt | 4 +- npc/events/halloween_2009.txt | 2 +- npc/other/gm_npcs.txt | 2 +- npc/other/monster_race.txt | 4 +- npc/other/poring_war.txt | 6 +- npc/quests/guildrelay.txt | 6 +- npc/quests/partyrelay.txt | 2 +- npc/re/instances/FacewormsNest.txt | 4 +- npc/re/instances/HorrorToyFactory.txt | 4 +- npc/re/instances/IsleOfBios.txt | 2 +- npc/re/instances/MalangdoCulvert.txt | 2 +- npc/re/instances/MorseCave.txt | 2 +- npc/re/instances/OldGlastHeim.txt | 6 +- npc/re/instances/SarahAndFenrir.txt | 2 +- npc/re/jobs/3-1/guillotine_cross.txt | 2 +- npc/re/jobs/3-1/ranger.txt | 2 +- npc/re/quests/quests_15_2.txt | 2 +- npc/re/quests/quests_16_1.txt | 2 +- npc/re/quests/quests_malangdo.txt | 2 +- src/map/script.cpp | 76 ++++++++++++++------------ src/map/script.hpp | 10 ---- src/map/script_constants.hpp | 15 ++--- 26 files changed, 107 insertions(+), 107 deletions(-) diff --git a/doc/script_commands.txt b/doc/script_commands.txt index ee08cde531..2efcc07469 100644 --- a/doc/script_commands.txt +++ b/doc/script_commands.txt @@ -3046,7 +3046,7 @@ If is false the command only returns the count of unidentified items. // --------------------------------------- -*getmapxy("",,,{,""}) +*getmapxy("",,{,,""}) 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 --------------------------------------- diff --git a/npc/battleground/bg_common.txt b/npc/battleground/bg_common.txt index 320ec68d87..7b6bd24706 100644 --- a/npc/battleground/bg_common.txt +++ b/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") diff --git a/npc/custom/events/devil_square.txt b/npc/custom/events/devil_square.txt index 2d7b9661cf..95046ba834 100644 --- a/npc/custom/events/devil_square.txt +++ b/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; diff --git a/npc/custom/events/mvp_ladder.txt b/npc/custom/events/mvp_ladder.txt index eac3b10b8f..83654141e8 100644 --- a/npc/custom/events/mvp_ladder.txt +++ b/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 ); diff --git a/npc/custom/quests/hunting_missions.txt b/npc/custom/quests/hunting_missions.txt index 58a1a68be7..bdc16db2dd 100644 --- a/npc/custom/quests/hunting_missions.txt +++ b/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] ); diff --git a/npc/events/halloween_2009.txt b/npc/events/halloween_2009.txt index 4681543269..565d9684f0 100644 --- a/npc/events/halloween_2009.txt +++ b/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: diff --git a/npc/other/gm_npcs.txt b/npc/other/gm_npcs.txt index 2b456c987e..718299cf81 100644 --- a/npc/other/gm_npcs.txt +++ b/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; } diff --git a/npc/other/monster_race.txt b/npc/other/monster_race.txt index e1f3704036..83b5e2888d 100644 --- a/npc/other/monster_race.txt +++ b/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; diff --git a/npc/other/poring_war.txt b/npc/other/poring_war.txt index bffeaf4f31..8c9e34621e 100644 --- a/npc/other/poring_war.txt +++ b/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); } diff --git a/npc/quests/guildrelay.txt b/npc/quests/guildrelay.txt index 606d276f94..96bdd6912b 100644 --- a/npc/quests/guildrelay.txt +++ b/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"; diff --git a/npc/quests/partyrelay.txt b/npc/quests/partyrelay.txt index 582ea1f471..cd31042b52 100644 --- a/npc/quests/partyrelay.txt +++ b/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]"; diff --git a/npc/re/instances/FacewormsNest.txt b/npc/re/instances/FacewormsNest.txt index 75878c23c7..a9a2edb8a6 100644 --- a/npc/re/instances/FacewormsNest.txt +++ b/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)); diff --git a/npc/re/instances/HorrorToyFactory.txt b/npc/re/instances/HorrorToyFactory.txt index af1a9a39d2..5234fad42d 100644 --- a/npc/re/instances/HorrorToyFactory.txt +++ b/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"; diff --git a/npc/re/instances/IsleOfBios.txt b/npc/re/instances/IsleOfBios.txt index f2addae517..262ab7113c 100644 --- a/npc/re/instances/IsleOfBios.txt +++ b/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]; } diff --git a/npc/re/instances/MalangdoCulvert.txt b/npc/re/instances/MalangdoCulvert.txt index c17df85a04..2d4e1bf859 100644 --- a/npc/re/instances/MalangdoCulvert.txt +++ b/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) { diff --git a/npc/re/instances/MorseCave.txt b/npc/re/instances/MorseCave.txt index 9aba203ab6..d960de72be 100644 --- a/npc/re/instances/MorseCave.txt +++ b/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; diff --git a/npc/re/instances/OldGlastHeim.txt b/npc/re/instances/OldGlastHeim.txt index ac862bf123..fbeec6d981 100644 --- a/npc/re/instances/OldGlastHeim.txt +++ b/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; diff --git a/npc/re/instances/SarahAndFenrir.txt b/npc/re/instances/SarahAndFenrir.txt index 53ad9d4f70..1348f1ae3e 100644 --- a/npc/re/instances/SarahAndFenrir.txt +++ b/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; diff --git a/npc/re/jobs/3-1/guillotine_cross.txt b/npc/re/jobs/3-1/guillotine_cross.txt index 9570ae84ce..24fe9311c0 100644 --- a/npc/re/jobs/3-1/guillotine_cross.txt +++ b/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; diff --git a/npc/re/jobs/3-1/ranger.txt b/npc/re/jobs/3-1/ranger.txt index 5328c804f2..8f37390987 100644 --- a/npc/re/jobs/3-1/ranger.txt +++ b/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; diff --git a/npc/re/quests/quests_15_2.txt b/npc/re/quests/quests_15_2.txt index 7d7ec96f47..d5f2bea129 100644 --- a/npc/re/quests/quests_15_2.txt +++ b/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]; diff --git a/npc/re/quests/quests_16_1.txt b/npc/re/quests/quests_16_1.txt index 2963bbbf24..82d25949fc 100644 --- a/npc/re/quests/quests_16_1.txt +++ b/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 diff --git a/npc/re/quests/quests_malangdo.txt b/npc/re/quests/quests_malangdo.txt index 0c5aa16cbf..096737e7c5 100644 --- a/npc/re/quests/quests_malangdo.txt +++ b/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 diff --git a/src/map/script.cpp b/src/map/script.cpp index db53e0bb0e..aedc124d51 100644 --- a/src/map/script.cpp +++ b/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?"), diff --git a/src/map/script.hpp b/src/map/script.hpp index 4a9eb798c6..303713831a 100644 --- a/src/map/script.hpp +++ b/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, diff --git a/src/map/script_constants.hpp b/src/map/script_constants.hpp index 86e6bd7698..d44bee3e5a 100644 --- a/src/map/script_constants.hpp +++ b/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);