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)
This commit is contained in:
JJ 2013-11-01 23:55:17 -04:00
parent aba535b589
commit b8d1838dcc
9 changed files with 162 additions and 6 deletions

View File

@ -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

View File

@ -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");
}
}
}

View File

@ -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);

View File

@ -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

View File

@ -1021,6 +1021,14 @@ void lua_clear_opcode(int op) {
ClearMappedOpcode(static_cast<EmuOpcode>(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)
];
}

View File

@ -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();

View File

@ -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;

View File

@ -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);
}

View File

@ -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