From 78e6f86c33b8606d7fda5ed811c3979228d3e40a Mon Sep 17 00:00:00 2001 From: Kinglykrab Date: Mon, 10 Oct 2022 19:31:40 -0400 Subject: [PATCH] [Quest API] Add IsRaining() and IsSnowing() to Perl/Lua. - Add quest::IsRaining() to Perl. - Add quest::IsSnowing() to Perl. - Add eq.is_raining() to Lua. - Add eq.is_snowing() to Lua. This will allow server operators to tell if a zone is currently raining, snowing, or neither. --- zone/embparser_api.cpp | 12 ++++++++++++ zone/lua_general.cpp | 18 ++++++++++++++++++ zone/questmgr.cpp | 16 ++++++++++++++++ zone/questmgr.h | 2 ++ zone/zone.h | 3 +++ 5 files changed, 51 insertions(+) diff --git a/zone/embparser_api.cpp b/zone/embparser_api.cpp index 0b31ca871..d0dbafa4f 100644 --- a/zone/embparser_api.cpp +++ b/zone/embparser_api.cpp @@ -3706,6 +3706,16 @@ bool Perl__hasrecipelearned(uint32 recipe_id) return quest_manager.HasRecipeLearned(recipe_id); } +bool Perl__IsRaining() +{ + return quest_manager.IsRaining(); +} + +bool Perl__IsSnowing() +{ + return quest_manager.IsSnowing(); +} + void perl_register_quest() { perl::interpreter perl(PERL_GET_THX); @@ -3752,6 +3762,8 @@ void perl_register_quest() package.add("delete_data", &Perl__delete_data); package.add("IsBeneficialSpell", &Perl__IsBeneficialSpell); package.add("IsEffectInSpell", &Perl__IsEffectInSpell); + package.add("IsRaining", &Perl__IsRaining); + package.add("IsSnowing", &Perl__IsSnowing); package.add("IsRunning", &Perl__IsRunning); package.add("LearnRecipe", &Perl__LearnRecipe); package.add("MerchantCountItem", &Perl__MerchantCountItem); diff --git a/zone/lua_general.cpp b/zone/lua_general.cpp index dd91b183e..3bc53eb55 100644 --- a/zone/lua_general.cpp +++ b/zone/lua_general.cpp @@ -3427,6 +3427,22 @@ bool lua_has_recipe_learned(uint32 recipe_id) { return quest_manager.HasRecipeLearned(recipe_id); } +bool lua_is_raining() { + if (!zone) { + return false; + } + + return zone->IsRaining(); +} + +bool lua_is_snowing() { + if (!zone) { + return false; + } + + return zone->IsSnowing(); +} + #define LuaCreateNPCParse(name, c_type, default_value) do { \ cur = table[#name]; \ if(luabind::type(cur) != LUA_TNIL) { \ @@ -3891,6 +3907,8 @@ luabind::scope lua_register_general() { luabind::def("get_recipe_made_count", &lua_get_recipe_made_count), luabind::def("get_recipe_name", &lua_get_recipe_name), luabind::def("has_recipe_learned", &lua_has_recipe_learned), + luabind::def("is_raining", &lua_is_raining), + luabind::def("is_snowing", &lua_is_snowing), /* Cross Zone diff --git a/zone/questmgr.cpp b/zone/questmgr.cpp index e72c527ef..6a92b025f 100644 --- a/zone/questmgr.cpp +++ b/zone/questmgr.cpp @@ -3723,3 +3723,19 @@ void QuestManager::LearnRecipe(uint32 recipe_id) { initiator->LearnRecipe(recipe_id); } + +bool QuestManager::IsRaining() { + if (!zone) { + return false; + } + + return zone->IsRaining(); +} + +bool QuestManager::IsSnowing() { + if (!zone) { + return false; + } + + return zone->IsSnowing(); +} diff --git a/zone/questmgr.h b/zone/questmgr.h index 17e94f171..8069535d1 100644 --- a/zone/questmgr.h +++ b/zone/questmgr.h @@ -340,6 +340,8 @@ public: int GetRecipeMadeCount(uint32 recipe_id); std::string GetRecipeName(uint32 recipe_id); bool HasRecipeLearned(uint32 recipe_id); + bool IsRaining(); + bool IsSnowing(); Client *GetInitiator() const; NPC *GetNPC() const; diff --git a/zone/zone.h b/zone/zone.h index 566cacf76..caf140fc4 100755 --- a/zone/zone.h +++ b/zone/zone.h @@ -249,6 +249,9 @@ public: uint32 GetCurrencyID(uint32 item_id); uint32 GetCurrencyItemID(uint32 currency_id); + inline bool IsRaining() { return zone_weather == 1; } + inline bool IsSnowing() { return zone_weather == 2; } + std::string GetZoneDescription(); void SendReloadMessage(std::string reload_type);