diff options
author | Haru <haru@dotalux.com> | 2018-10-22 00:34:15 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-22 00:34:15 +0200 |
commit | fb5ed0bce2316853c903c4269aad1224cba6a623 (patch) | |
tree | b60f0aebd45e006afbca2010c037e163b6f1500b /src/map | |
parent | 9deff52b5b081307107e0eafdf1cc771c8cd63a6 (diff) | |
parent | 0e38fa59227ec3892fdeb0a9dfdd1037c9225e4d (diff) | |
download | hercules-fb5ed0bce2316853c903c4269aad1224cba6a623.tar.gz hercules-fb5ed0bce2316853c903c4269aad1224cba6a623.tar.bz2 hercules-fb5ed0bce2316853c903c4269aad1224cba6a623.tar.xz hercules-fb5ed0bce2316853c903c4269aad1224cba6a623.zip |
Merge pull request #2251 from Asheraf/pr3
Add new type for mercenary class to setquestinfo()
Diffstat (limited to 'src/map')
-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 |
4 files changed, 41 insertions, 0 deletions
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 e89d36be4..212c11687 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -21177,6 +21177,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; @@ -25938,6 +25949,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); |