diff options
author | Asheraf <acheraf1998@gmail.com> | 2018-10-03 11:30:02 +0100 |
---|---|---|
committer | Asheraf <acheraf1998@gmail.com> | 2018-10-03 12:00:13 +0100 |
commit | 0e38fa59227ec3892fdeb0a9dfdd1037c9225e4d (patch) | |
tree | 96a840c231dadd04e94c4bfe857b4bc77ccdc485 /src | |
parent | 852c13305f67948531bd0277eb1922dbd02b1f26 (diff) | |
download | hercules-0e38fa59227ec3892fdeb0a9dfdd1037c9225e4d.tar.gz hercules-0e38fa59227ec3892fdeb0a9dfdd1037c9225e4d.tar.bz2 hercules-0e38fa59227ec3892fdeb0a9dfdd1037c9225e4d.tar.xz hercules-0e38fa59227ec3892fdeb0a9dfdd1037c9225e4d.zip |
Add new type for mercenary class to setquestinfo()
Diffstat (limited to 'src')
-rw-r--r-- | src/common/mmo.h | 3 | ||||
-rw-r--r-- | src/map/map.h | 1 | ||||
-rw-r--r-- | src/map/quest.c | 27 | ||||
-rw-r--r-- | src/map/quest.h | 1 | ||||
-rw-r--r-- | src/map/script.c | 12 |
5 files changed, 43 insertions, 1 deletions
diff --git a/src/common/mmo.h b/src/common/mmo.h index d6946cecc..9bcf82cc7 100644 --- a/src/common/mmo.h +++ b/src/common/mmo.h @@ -1331,7 +1331,8 @@ enum questinfo_type { QINFO_ITEM, QINFO_HOMUN_LEVEL, QINFO_HOMUN_TYPE, - QINFO_QUEST + QINFO_QUEST, + QINFO_MERCENARY_CLASS }; /* packet size constant for itemlist */ diff --git a/src/map/map.h b/src/map/map.h index d50666d4b..cb025e9c1 100644 --- a/src/map/map.h +++ b/src/map/map.h @@ -815,6 +815,7 @@ struct questinfo { struct s_homunculus homunculus; int homunculus_type; VECTOR_DECL(struct questinfo_qreq) quest_requirement; + int mercenary_class; }; diff --git a/src/map/quest.c b/src/map/quest.c index 02bf7638b..f10d6847f 100644 --- a/src/map/quest.c +++ b/src/map/quest.c @@ -30,6 +30,7 @@ #include "map/itemdb.h" #include "map/log.h" #include "map/map.h" +#include "map/mercenary.h" #include "map/mob.h" #include "map/npc.h" #include "map/party.h" @@ -719,6 +720,8 @@ static bool quest_questinfo_validate(struct map_session_data *sd, struct questin return false; if (VECTOR_LENGTH(qi->quest_requirement) > 0 && quest->questinfo_validate_quests(sd, qi) == false) return false; + if (qi->mercenary_class != 0 && quest->questinfo_validate_mercenary_class(sd, qi) == false) + return false; return true; } @@ -901,6 +904,29 @@ static bool quest_questinfo_validate_quests(struct map_session_data *sd, struct } /** + * Validate mercenary class required for the questinfo + * + * @param sd session data. + * @param qi questinfo data. + * + * @retval true if player have a mercenary with the given class. + * @retval false if player does NOT have a mercenary with the given class. + */ +static bool quest_questinfo_validate_mercenary_class(struct map_session_data *sd, struct questinfo *qi) +{ + nullpo_retr(false, sd); + nullpo_retr(false, qi); + + if (sd->md == NULL) + return false; + + if (sd->md->mercenary.class_ != qi->mercenary_class) + return false; + + return true; +} + +/** * Clears the questinfo data vector * * @param m mapindex. @@ -993,5 +1019,6 @@ void quest_defaults(void) quest->questinfo_validate_homunculus_level = quest_questinfo_validate_homunculus_level; quest->questinfo_validate_homunculus_type = quest_questinfo_validate_homunculus_type; quest->questinfo_validate_quests = quest_questinfo_validate_quests; + quest->questinfo_validate_mercenary_class = quest_questinfo_validate_mercenary_class; quest->questinfo_vector_clear = quest_questinfo_vector_clear; } diff --git a/src/map/quest.h b/src/map/quest.h index 305a48df1..206a7902f 100644 --- a/src/map/quest.h +++ b/src/map/quest.h @@ -92,6 +92,7 @@ struct quest_interface { bool (*questinfo_validate_homunculus_level) (struct map_session_data *sd, struct questinfo *qi); bool (*questinfo_validate_homunculus_type) (struct map_session_data *sd, struct questinfo *qi); bool (*questinfo_validate_quests) (struct map_session_data *sd, struct questinfo *qi); + bool (*questinfo_validate_mercenary_class) (struct map_session_data *sd, struct questinfo *qi); void (*questinfo_vector_clear) (int m); }; diff --git a/src/map/script.c b/src/map/script.c index b787d0138..70adddfe2 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -21190,6 +21190,17 @@ static BUILDIN(setquestinfo) VECTOR_PUSH(qi->quest_requirement, quest_req); break; } + case QINFO_MERCENARY_CLASS: + { + int mer_class = script_getnum(st, 3); + + if (!mercenary->class(mer_class)) { + ShowWarning("buildin_setquestinfo: invalid mercenary class given (%d).\n", mer_class); + return false; + } + qi->mercenary_class = mer_class; + break; + } default: ShowWarning("buildin_setquestinfo: invalid type given (%u).\n", type); return false; @@ -25930,6 +25941,7 @@ static void script_hardcoded_constants(void) script->set_constant("QINFO_HOMUN_LEVEL", QINFO_HOMUN_LEVEL, false, false); script->set_constant("QINFO_HOMUN_TYPE", QINFO_HOMUN_TYPE, false, false); script->set_constant("QINFO_QUEST", QINFO_QUEST, false, false); + script->set_constant("QINFO_MERCENARY_CLASS", QINFO_MERCENARY_CLASS, false, false); script->constdb_comment("function types"); script->set_constant("FUNCTION_IS_COMMAND", FUNCTION_IS_COMMAND, false, false); |