From b8d1838dcc0aff758eb1b6fbe37a2cb88780bfb7 Mon Sep 17 00:00:00 2001 From: JJ Date: Fri, 1 Nov 2013 23:55:17 -0400 Subject: [PATCH] Added in-game commands to enable/disable tradeskill recipes -Commands: #enablerecipe recipe_id, #disablerecipe recipe_id -Perl: quest::enablerecipe(recipe_id), quest::disablerecipe(recipe_id) -Lua: eq.enable_recipe(recipe_id), eq.disable_recipe(recipe_id) --- changelog.txt | 6 ++++++ zone/command.cpp | 48 ++++++++++++++++++++++++++++++++++++++++-- zone/command.h | 2 ++ zone/embparser_api.cpp | 41 ++++++++++++++++++++++++++++++++++-- zone/lua_general.cpp | 12 ++++++++++- zone/questmgr.cpp | 25 ++++++++++++++++++++++ zone/questmgr.h | 2 ++ zone/tradeskills.cpp | 28 ++++++++++++++++++++++++ zone/zonedb.h | 4 +++- 9 files changed, 162 insertions(+), 6 deletions(-) diff --git a/changelog.txt b/changelog.txt index ee427415e..42a113c8b 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,5 +1,11 @@ EQEMu Changelog (Started on Sept 24, 2003 15:50) ------------------------------------------------------- +== 11/01/2013 == +JJ: Added in-game commands to enable/disable tradeskill recipes +-Commands: #enablerecipe recipe_id, #disablerecipe recipe_id +-Perl: quest::enablerecipe(recipe_id), quest::disablerecipe(recipe_id) +-Lua: eq.enable_recipe(recipe_id), eq.disable_recipe(recipe_id) + == 10/31/2013 == Leere: Add the ability to disable a tradeskill recipe diff --git a/zone/command.cpp b/zone/command.cpp index 0c6793b51..93cdf6d46 100644 --- a/zone/command.cpp +++ b/zone/command.cpp @@ -24,7 +24,7 @@ 2. Add the function in this file. 3. In the command_init function you must add a call to command_add for your function. If you want an alias for your command, add - a second call to command_add with the descriptin and access args + a second call to command_add with the description and access args set to nullptr and 0 respectively since they aren't used when adding an alias. The function pointers being equal is makes it an alias. The access level you set with command_add is only a default if @@ -445,7 +445,9 @@ int command_init(void) { command_add("xtargets", "Show your targets Extended Targets and optionally set how many xtargets they can have.", 250, command_xtargets) || command_add("zopp", "Troubleshooting command - Sends a fake item packet to you. No server reference is created.", 250, command_zopp) || command_add("augmentitem", "Force augments an item. Must have the augment item window open.", 250, command_augmentitem) || - command_add("questerrors", "Shows quest errors.", 100, command_questerrors) + command_add("questerrors", "Shows quest errors.", 100, command_questerrors) || + command_add("enablerecipe", "[recipe_id] - Enables a recipe using the recipe id.", 80, command_enablerecipe) || + command_add("disablerecipe", "[recipe_id] - Disables a recipe using the recipe id.", 80, command_disablerecipe) ) { command_deinit(); @@ -11426,3 +11428,45 @@ void command_questerrors(Client *c, const Seperator *sep) ++iter; } } + +void command_enablerecipe(Client *c, const Seperator *sep) +{ + uint32 recipe_id = 0; + if (c) { + if (sep->argnum == 1) { + recipe_id = atoi(sep->arg[1]); + } + else { + c->Message(0, "Invalid number of arguments.\nUsage: #enablerecipe recipe_id"); + return; + } + if (recipe_id > 0) { + database.EnableRecipe(recipe_id); + c->Message(0, "Recipe enabled."); + } + else { + c->Message(0, "Invalid recipe id.\nUsage: #enablerecipe recipe_id"); + } + } +} + +void command_disablerecipe(Client *c, const Seperator *sep) +{ + uint32 recipe_id = 0; + if (c) { + if (sep->argnum == 1) { + recipe_id = atoi(sep->arg[1]); + } + else { + c->Message(0, "Invalid number of arguments.\nUsage: #disablerecipe recipe_id"); + return; + } + if (recipe_id > 0) { + database.DisableRecipe(recipe_id); + c->Message(0, "Recipe disabled."); + } + else { + c->Message(0, "Invalid recipe id.\nUsage: #disablerecipe recipe_id"); + } + } +} diff --git a/zone/command.h b/zone/command.h index cf4a72228..c8860b8a9 100644 --- a/zone/command.h +++ b/zone/command.h @@ -320,6 +320,8 @@ void command_xtargets(Client *c, const Seperator *sep); void command_zopp(Client *c, const Seperator *sep); void command_augmentitem(Client *c, const Seperator *sep); void command_questerrors(Client *c, const Seperator *sep); +void command_enablerecipe(Client *c, const Seperator *sep); +void command_disablerecipe(Client *c, const Seperator *sep); #ifdef EQPROFILE void command_profiledump(Client *c, const Seperator *sep); diff --git a/zone/embparser_api.cpp b/zone/embparser_api.cpp index 0e21ba6aa..5e79b52b8 100644 --- a/zone/embparser_api.cpp +++ b/zone/embparser_api.cpp @@ -2584,7 +2584,8 @@ XS(XS__istaskappropriate) quest_manager.popup(SvPV_nolen(ST(0)), SvPV_nolen(ST(1)), popupid, buttons, duration); XSRETURN_EMPTY; - } +} + XS(XS__clearspawntimers); XS(XS__clearspawntimers) { @@ -2596,6 +2597,7 @@ XS(XS__clearspawntimers) XSRETURN_EMPTY; } + XS(XS__ze); XS(XS__ze) { @@ -2625,6 +2627,7 @@ XS(XS__we) XSRETURN_EMPTY; } + XS(XS__getlevel); XS(XS__getlevel) { @@ -3310,6 +3313,38 @@ XS(XS__crosszonemessageplayerbyname) XSRETURN_EMPTY; } +XS(XS__enablerecipe); +XS(XS__enablerecipe) +{ + dXSARGS; + + if (items != 1) { + Perl_croak(aTHX_ "Usage: enablerecipe(recipe_id)"); + } + else { + uint32 recipe_id = (uint32)SvIV(ST(0)); + quest_manager.EnableRecipe(recipe_id); + } + + XSRETURN_EMPTY; +} + +XS(XS__disablerecipe); +XS(XS__disablerecipe) +{ + dXSARGS; + + if (items != 1) { + Perl_croak(aTHX_ "Usage: disablerecipe(recipe_id)"); + } + else { + uint32 recipe_id = (uint32)SvIV(ST(0)); + quest_manager.DisableRecipe(recipe_id); + } + + XSRETURN_EMPTY; +} + /* This is the callback perl will look for to setup the quest package's XSUBs @@ -3528,7 +3563,9 @@ EXTERN_C XS(boot_quest) newXS(strcpy(buf, "crosszonesignalclientbycharid"), XS__crosszonesignalclientbycharid, file); newXS(strcpy(buf, "crosszonesignalclientbyname"), XS__crosszonesignalclientbyname, file); newXS(strcpy(buf, "crosszonemessageplayerbyname"), XS__crosszonemessageplayerbyname, file); - XSRETURN_YES; + newXS(strcpy(buf, "enablerecipe"), XS__enablerecipe, file); + newXS(strcpy(buf, "disablerecipe"), XS__disablerecipe, file); + XSRETURN_YES; } #endif diff --git a/zone/lua_general.cpp b/zone/lua_general.cpp index bd5de283c..28f8df634 100644 --- a/zone/lua_general.cpp +++ b/zone/lua_general.cpp @@ -1021,6 +1021,14 @@ void lua_clear_opcode(int op) { ClearMappedOpcode(static_cast(op)); } +void lua_enable_recipe(uint32 recipe_id) { + quest_manager.EnableRecipe(recipe_id); +} + +void lua_disable_recipe(uint32 recipe_id) { + quest_manager.DisableRecipe(recipe_id); +} + luabind::scope lua_register_general() { return luabind::namespace_("eq") [ @@ -1182,7 +1190,9 @@ luabind::scope lua_register_general() { luabind::def("get_owner", &lua_get_owner), luabind::def("get_quest_item", &lua_get_quest_item), luabind::def("map_opcodes", &lua_map_opcodes), - luabind::def("clear_opcode", &lua_clear_opcode) + luabind::def("clear_opcode", &lua_clear_opcode), + luabind::def("enable_recipe", &lua_enable_recipe), + luabind::def("disable_recipe", &lua_disable_recipe) ]; } diff --git a/zone/questmgr.cpp b/zone/questmgr.cpp index c7db06831..75763a7a6 100644 --- a/zone/questmgr.cpp +++ b/zone/questmgr.cpp @@ -2096,6 +2096,7 @@ bool QuestManager::istaskactive(int task) { return false; } + bool QuestManager::istaskactivityactive(int task, int activity) { QuestManagerCurrentQuestVars(); @@ -2104,6 +2105,7 @@ bool QuestManager::istaskactivityactive(int task, int activity) { return false; } + int QuestManager::gettaskactivitydonecount(int task, int activity) { QuestManagerCurrentQuestVars(); @@ -2113,6 +2115,7 @@ int QuestManager::gettaskactivitydonecount(int task, int activity) { return 0; } + void QuestManager::updatetaskactivity(int task, int activity, int count) { QuestManagerCurrentQuestVars(); @@ -2165,6 +2168,7 @@ int QuestManager::enabledtaskcount(int taskset) { return -1; } + int QuestManager::firsttaskinset(int taskset) { QuestManagerCurrentQuestVars(); @@ -2173,6 +2177,7 @@ int QuestManager::firsttaskinset(int taskset) { return -1; } + int QuestManager::lasttaskinset(int taskset) { QuestManagerCurrentQuestVars(); @@ -2181,6 +2186,7 @@ int QuestManager::lasttaskinset(int taskset) { return -1; } + int QuestManager::nexttaskinset(int taskset, int taskid) { QuestManagerCurrentQuestVars(); @@ -2189,6 +2195,7 @@ int QuestManager::nexttaskinset(int taskset, int taskid) { return -1; } + int QuestManager::activespeaktask() { QuestManagerCurrentQuestVars(); @@ -2196,6 +2203,7 @@ int QuestManager::activespeaktask() { return initiator->ActiveSpeakTask(owner->GetNPCTypeID()); return 0; } + int QuestManager::activespeakactivity(int taskid) { QuestManagerCurrentQuestVars(); @@ -2204,6 +2212,7 @@ int QuestManager::activespeakactivity(int taskid) { return 0; } + int QuestManager::istaskcompleted(int taskid) { QuestManagerCurrentQuestVars(); @@ -2212,6 +2221,7 @@ int QuestManager::istaskcompleted(int taskid) { return -1; } + int QuestManager::activetasksinset(int taskset) { QuestManagerCurrentQuestVars(); @@ -2220,6 +2230,7 @@ int QuestManager::activetasksinset(int taskset) { return -1; } + int QuestManager::completedtasksinset(int taskset) { QuestManagerCurrentQuestVars(); @@ -2237,6 +2248,7 @@ bool QuestManager::istaskappropriate(int task) { return false; } + void QuestManager::clearspawntimers() { if(zone) { //TODO: Dec 19, 2008, replace with code updated for current spawn timers. @@ -2253,6 +2265,7 @@ void QuestManager::clearspawntimers() { } } } + void QuestManager::ze(int type, const char *str) { entity_list.Message(0, type, str); } @@ -2888,6 +2901,18 @@ void QuestManager::CrossZoneMessagePlayerByName(uint32 Type, const char *CharNam safe_delete(pack); } +void QuestManager::EnableRecipe(uint32 recipe_id) +{ + if (recipe_id > 0) + database.EnableRecipe(recipe_id); +} + +void QuestManager::DisableRecipe(uint32 recipe_id) +{ + if (recipe_id > 0) + database.DisableRecipe(recipe_id); +} + Client *QuestManager::GetInitiator() const { if(!quests_running_.empty()) { running_quest e = quests_running_.top(); diff --git a/zone/questmgr.h b/zone/questmgr.h index fbd9702fa..9873dc441 100644 --- a/zone/questmgr.h +++ b/zone/questmgr.h @@ -231,6 +231,8 @@ public: void CrossZoneSignalPlayerByCharID(int charid, uint32 data); void CrossZoneSignalPlayerByName(const char *CharName, uint32 data); void CrossZoneMessagePlayerByName(uint32 Type, const char *CharName, const char *Message); + void EnableRecipe(uint32 recipe_id); + void DisableRecipe(uint32 recipe_id); Client *GetInitiator() const; NPC *GetNPC() const; diff --git a/zone/tradeskills.cpp b/zone/tradeskills.cpp index 2534924ec..fa1e32b7c 100644 --- a/zone/tradeskills.cpp +++ b/zone/tradeskills.cpp @@ -1599,3 +1599,31 @@ bool Client::CanIncreaseTradeskill(SkillUseTypes tradeskill) { } return true; } + +void ZoneDatabase::EnableRecipe(uint32 recipe_id) +{ + char *query = 0; + uint32 qlen; + char errbuf[MYSQL_ERRMSG_SIZE]; + + qlen = MakeAnyLenString(&query, "UPDATE tradeskill_recipe SET enabled = 1 WHERE id = %u;", recipe_id); + + if (!RunQuery(query, qlen, errbuf)) { + LogFile->write(EQEMuLog::Error, "Error in EnableRecipe query '%s': %s", query, errbuf); + } + safe_delete_array(query); +} + +void ZoneDatabase::DisableRecipe(uint32 recipe_id) +{ + char *query = 0; + uint32 qlen; + char errbuf[MYSQL_ERRMSG_SIZE]; + + qlen = MakeAnyLenString(&query, "UPDATE tradeskill_recipe SET enabled = 0 WHERE id = %u;", recipe_id); + + if (!RunQuery(query, qlen, errbuf)) { + LogFile->write(EQEMuLog::Error, "Error in DisableRecipe query '%s': %s", query, errbuf); + } + safe_delete_array(query); +} diff --git a/zone/zonedb.h b/zone/zonedb.h index 42e9e52be..39941e307 100644 --- a/zone/zonedb.h +++ b/zone/zonedb.h @@ -382,9 +382,11 @@ public: */ bool GetTradeRecipe(const ItemInst* container, uint8 c_type, uint32 some_id, uint32 char_id, DBTradeskillRecipe_Struct *spec); bool GetTradeRecipe(uint32 recipe_id, uint8 c_type, uint32 some_id, uint32 char_id, DBTradeskillRecipe_Struct *spec); - uint32 GetZoneForage(uint32 ZoneID, uint8 skill); /* for foraging - BoB */ + uint32 GetZoneForage(uint32 ZoneID, uint8 skill); /* for foraging */ uint32 GetZoneFishing(uint32 ZoneID, uint8 skill, uint32 &npc_id, uint8 &npc_chance); void UpdateRecipeMadecount(uint32 recipe_id, uint32 char_id, uint32 madecount); + void EnableRecipe(uint32 recipe_id); + void DisableRecipe(uint32 recipe_id); /* * Tribute