summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHaru <haru@dotalux.com>2019-03-11 00:56:49 +0100
committerGitHub <noreply@github.com>2019-03-11 00:56:49 +0100
commit47cfee479ebf61942be2af9540013469d6806f13 (patch)
treeba5958cdd3893c0bf1a2e43cd6f53de2d34768e6
parent28eb50882484697b10fa4764b3e0fd91d9e12a4e (diff)
parent0d99c3487f4efa10407879112ad0db24be86d5ff (diff)
downloadhercules-47cfee479ebf61942be2af9540013469d6806f13.tar.gz
hercules-47cfee479ebf61942be2af9540013469d6806f13.tar.bz2
hercules-47cfee479ebf61942be2af9540013469d6806f13.tar.xz
hercules-47cfee479ebf61942be2af9540013469d6806f13.zip
Merge pull request #2397 from AnnieRuru/68-getmercinfo
Add constants and MERCINFO_GID to *getmercinfo script command
-rw-r--r--doc/script_commands.txt23
-rw-r--r--npc/re/jobs/3-1/archbishop.txt12
-rw-r--r--npc/re/jobs/3-1/ranger.txt4
-rw-r--r--npc/re/quests/eden/eden_tutorial.txt2
-rw-r--r--src/map/script.c91
-rw-r--r--src/map/script.h17
6 files changed, 97 insertions, 52 deletions
diff --git a/doc/script_commands.txt b/doc/script_commands.txt
index 30d7f9512..f2852e93e 100644
--- a/doc/script_commands.txt
+++ b/doc/script_commands.txt
@@ -9845,17 +9845,18 @@ If char id is given, the information of that character is retrieved
instead. Type specifies what information to retrieve and can be one of the
following:
- 0 - Database ID
- 1 - Class
- 2 - Name
- 3 - Faith value for this mercenary's guild, if any
- 4 - Calls value for this mercenary's guild, if any
- 5 - Kill count
- 6 - Remaining life time in msec
- 7 - Level
-
-If the character does not have a mercenary, the command returns ""
-for name and 0 for all other types.
+ MERCINFO_ID - Mercenary Database ID
+ MERCINFO_CLASS - Mercenary Class
+ MERCINFO_NAME - Mercenary Name
+ MERCINFO_FAITH - Mercenary faith value for this mercenary's guild, if any
+ MERCINFO_CALLS - Mercenary calls value for this mercenary's guild, if any
+ MERCINFO_KILLCOUNT - Mercenary kill count
+ MERCINFO_LIFETIME - Mercenary remaining life time in mili-second
+ MERCINFO_LEVEL - Mercenary Level
+ MERCINFO_GID - Mercenary Game ID
+
+If the character does not have a mercenary, the command returns "" for MERCINFO_NAME
+and 0 for all other types.
---------------------------------------
//=====================================
diff --git a/npc/re/jobs/3-1/archbishop.txt b/npc/re/jobs/3-1/archbishop.txt
index e59492ce5..e37087857 100644
--- a/npc/re/jobs/3-1/archbishop.txt
+++ b/npc/re/jobs/3-1/archbishop.txt
@@ -779,7 +779,7 @@ job3_arch01,29,34,3 script Valkyrie#arch 4_F_VALKYRIE2,{
warp "odin_tem02",282,263;
end;
}
- if (getmercinfo(1)) {
+ if (getmercinfo(MERCINFO_CLASS)) {
mes "[Valkyrie]";
mes "If you want to talk with me, you have to ^3131FFcancel all contracts^000000 with any mercenaries you have.";
close;
@@ -1006,7 +1006,7 @@ OnTouch:
if (countitem(ValkyrieA_Scroll)) {
delitem ValkyrieA_Scroll,1;
// fall through
- } else if (getmercinfo(1) == 2037) {
+ } else if (getmercinfo(MERCINFO_CLASS) == VALKYRIE_A) {
if (strnpcinfo(NPC_NAME) == "#arch_1_10")
viewpoint 1,113,327,1,0xFF9900;
.@randht = rand(1,10);
@@ -1038,7 +1038,7 @@ OnTouch:
if (countitem(ValkyrieA_Scroll)) {
delitem ValkyrieA_Scroll,1;
// fall through
- } else if (getmercinfo(1) == 2037) {
+ } else if (getmercinfo(MERCINFO_CLASS) == VALKYRIE_A) {
mapannounce "job3_arch02","Valkyrie's Nightmare: An incompetent illusion of Valkyrie came here with the assistance of humans. You wanna have that nightmare?",bc_map,"0xFF0000";
donpcevent "mob#arch_1::OnKill";
end;
@@ -1113,7 +1113,7 @@ OnKill:
}
job3_arch02,113,327,5 script Valkyrie#arch_01 4_F_VALKYRIE2,{
- if (getmercinfo(1)) {
+ if (getmercinfo(MERCINFO_CLASS)) {
mes "[Valkyrie]";
mes "If you want to talk with me, you have to ^3131FFcancel all contracts^000000 with any mercenaries you have.";
close;
@@ -1355,7 +1355,7 @@ OnTouch:
if (countitem(ValkyrieB_Scroll)) {
delitem ValkyrieB_Scroll,1;
// fall through
- } else if (getmercinfo(1) == 2038) {
+ } else if (getmercinfo(MERCINFO_CLASS) == VALKYRIE_B) {
.@randht = rand(1,10);
if (.@randht < 8)
mapannounce "job3_arch02","Whispering of an impersonation: I can feel the devil's spirits. Can you hear? The sound of gathering in crowds.",bc_map,"0xFFCE00";
@@ -1400,7 +1400,7 @@ OnTouch:
if (countitem(ValkyrieB_Scroll)) {
delitem ValkyrieB_Scroll,1;
// fall through
- } else if (getmercinfo(1) == 2038) {
+ } else if (getmercinfo(MERCINFO_CLASS) == VALKYRIE_B) {
mapannounce "job3_arch02","A shout of devil: You are so childish. I invite you a party of devil. I'll make you have a fun!",bc_map,"0xFF0000";
end;
}
diff --git a/npc/re/jobs/3-1/ranger.txt b/npc/re/jobs/3-1/ranger.txt
index 41e5b476f..166a1d42e 100644
--- a/npc/re/jobs/3-1/ranger.txt
+++ b/npc/re/jobs/3-1/ranger.txt
@@ -613,7 +613,7 @@ tur_dun01,91,169,3 script Test Instructor#jr02 4_M_JOB_HUNTER,{
mes "Don't hang around here doing nothing. This is my area!";
close;
L_Start:
- if (getmercinfo(1)) {
+ if (getmercinfo(MERCINFO_CLASS)) {
mes "[Test Instructor, Teardrop]";
mes "Stop!";
next;
@@ -1491,7 +1491,7 @@ job3_rang02,251,49,3 script Test Supervisor#jr_13 4_M_JOB_HUNTER,{
setquest 8261;
close;
}
- if (getmercinfo(1) == 2034) {
+ if (getmercinfo(MERCINFO_CLASS) == M_DESERT_WOLF_B) {
erasequest 8261;
mes "Good! Then I'll start the test right now!";
next;
diff --git a/npc/re/quests/eden/eden_tutorial.txt b/npc/re/quests/eden/eden_tutorial.txt
index 902db7945..188bc514a 100644
--- a/npc/re/quests/eden/eden_tutorial.txt
+++ b/npc/re/quests/eden/eden_tutorial.txt
@@ -228,7 +228,7 @@ moc_para01,34,178,3 script Tutorial Instructor 4_M_KHMAN,{
close;
}
} else if (questprogress(9167) == 1) {
- if (!getmercinfo(1)) {
+ if (!getmercinfo(MERCINFO_CLASS)) {
mes "[Tutorial Instructor]";
mes "You haven't gotten a mercenary yet.";
next;
diff --git a/src/map/script.c b/src/map/script.c
index 1977d3b58..b0a3b6929 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -15613,20 +15613,15 @@ static BUILDIN(gethominfo)
return true;
}
-/// Retrieves information about character's mercenary
-/// getmercinfo <type>[,<char id>];
+/*
+ * Retrieves information about character's mercenary
+ * getmercinfo <type>{, <char id> };
+ */
static BUILDIN(getmercinfo)
{
- int type;
- struct map_session_data* sd;
- struct mercenary_data* md;
-
- type = script_getnum(st,2);
-
- if (script_hasdata(st,3)) {
- int char_id = script_getnum(st,3);
-
- if ((sd = script->charid2sd(st, char_id)) == NULL) {
+ struct map_session_data *sd;
+ if (script_hasdata(st, 3)) {
+ if ((sd = script->charid2sd(st, script_getnum(st, 3))) == NULL) {
script_pushnil(st);
return true;
}
@@ -15635,27 +15630,48 @@ static BUILDIN(getmercinfo)
return true;
}
- md = ( sd->status.mer_id && sd->md ) ? sd->md : NULL;
+ struct mercenary_data *md = (sd->status.mer_id && sd->md)? sd->md : NULL;
+ int type = script_getnum(st, 2);
+ if (md == NULL) {
+ if (type == MERCINFO_NAME)
+ script_pushconststr(st, "");
+ else
+ script_pushint(st, 0);
+ return true;
+ }
- switch( type )
- {
- case 0: script_pushint(st,md ? md->mercenary.mercenary_id : 0); break;
- case 1: script_pushint(st,md ? md->mercenary.class_ : 0); break;
- case 2:
- if( md )
- script_pushstrcopy(st,md->db->name);
- else
- script_pushconststr(st,"");
- break;
- case 3: script_pushint(st,md ? mercenary->get_faith(md) : 0); break;
- case 4: script_pushint(st,md ? mercenary->get_calls(md) : 0); break;
- case 5: script_pushint(st,md ? md->mercenary.kill_count : 0); break;
- case 6: script_pushint(st,md ? mercenary->get_lifetime(md) : 0); break;
- case 7: script_pushint(st,md ? md->db->lv : 0); break;
- default:
- ShowError("buildin_getmercinfo: Invalid type %d (char_id=%d).\n", type, sd->status.char_id);
- script_pushnil(st);
- return false;
+ switch (type) {
+ case MERCINFO_ID:
+ script_pushint(st, md->mercenary.mercenary_id);
+ break;
+ case MERCINFO_CLASS:
+ script_pushint(st, md->mercenary.class_);
+ break;
+ case MERCINFO_NAME:
+ script_pushstrcopy(st, md->db->name);
+ break;
+ case MERCINFO_FAITH:
+ script_pushint(st, mercenary->get_faith(md));
+ break;
+ case MERCINFO_CALLS:
+ script_pushint(st, mercenary->get_calls(md));
+ break;
+ case MERCINFO_KILLCOUNT:
+ script_pushint(st, md->mercenary.kill_count);
+ break;
+ case MERCINFO_LIFETIME:
+ script_pushint(st, mercenary->get_lifetime(md));
+ break;
+ case MERCINFO_LEVEL:
+ script_pushint(st, md->db->lv);
+ break;
+ case MERCINFO_GID:
+ script_pushint(st, md->bl.id);
+ break;
+ default:
+ ShowError("buildin_getmercinfo: Invalid type %d (char_id=%d).\n", type, sd->status.char_id);
+ script_pushnil(st);
+ return false;
}
return true;
@@ -26118,6 +26134,17 @@ static void script_hardcoded_constants(void)
script->set_constant("ITEMINFO_VIEWSPRITE", ITEMINFO_VIEWSPRITE, false, false);
script->set_constant("ITEMINFO_TRADE", ITEMINFO_TRADE, false, false);
+ script->constdb_comment("getmercinfo options");
+ script->set_constant("MERCINFO_ID,", MERCINFO_ID, false, false);
+ script->set_constant("MERCINFO_CLASS", MERCINFO_CLASS, false, false);
+ script->set_constant("MERCINFO_NAME", MERCINFO_NAME, false, false);
+ script->set_constant("MERCINFO_FAITH", MERCINFO_FAITH, false, false);
+ script->set_constant("MERCINFO_CALLS", MERCINFO_CALLS, false, false);
+ script->set_constant("MERCINFO_KILLCOUNT", MERCINFO_KILLCOUNT, false, false);
+ script->set_constant("MERCINFO_LIFETIME", MERCINFO_LIFETIME, false, false);
+ script->set_constant("MERCINFO_LEVEL", MERCINFO_LEVEL, false, false);
+ script->set_constant("MERCINFO_GID", MERCINFO_GID, false, false);
+
script->constdb_comment("monster skill states");
script->set_constant("MSS_ANY", MSS_ANY, false, false);
script->set_constant("MSS_IDLE", MSS_IDLE, false, false);
diff --git a/src/map/script.h b/src/map/script.h
index 549ad3284..54c5aad2a 100644
--- a/src/map/script.h
+++ b/src/map/script.h
@@ -461,6 +461,23 @@ enum script_iteminfo_types {
};
/**
+ * Mercenary Info types.
+ */
+enum script_mercinfo_types {
+ MERCINFO_ID = 0,
+ MERCINFO_CLASS,
+ MERCINFO_NAME,
+ MERCINFO_FAITH,
+ MERCINFO_CALLS,
+ MERCINFO_KILLCOUNT,
+ MERCINFO_LIFETIME,
+ MERCINFO_LEVEL,
+ MERCINFO_GID,
+
+ MERCINFO_MAX
+};
+
+/**
* Player blocking actions related flags.
*/
enum pcblock_action_flag {