Addition to /modify quest Command
Posted: Wed Jan 08, 2020 1:38 pm
[mention]Jabantiz[/mention]
I've copied the functionality from the lua function SetStepComplete and put it under the Command_ModifyQuest in the Commands.cpp file on my test server.
It's very nice for quest debugging purposes as I've had to restart a quest many many times to get one step functioning correctly.
Here's the full Command_ModifyQuest for location reference:
If this looks up to standard for the project, I would like to have it added to the project to make it easier to script and verify quests.
I've copied the functionality from the lua function SetStepComplete and put it under the Command_ModifyQuest in the Commands.cpp file on my test server.
It's very nice for quest debugging purposes as I've had to restart a quest many many times to get one step functioning correctly.
Code: Select all
else if (strcmp(sep->arg[0], "advance") == 0)
{
int32 quest_id = 0;
int32 step = 0;
if (sep && sep->arg[1] && sep->IsNumber(1))
{
quest_id = atoul(sep->arg[1]);
Quest* quest = client->GetPlayer()->player_quests[quest_id];
if (sep && sep->arg[2] && sep->IsNumber(1))
{
step = atoul(sep->arg[2]);
if (quest_id > 0 && step > 0)
{
if (player && player->IsPlayer() && quest_id > 0 && step > 0 && (player->player_quests.count(quest_id) > 0))
{
if (client)
{
client->AddPendingQuestUpdate(quest_id, step);
client->Message(CHANNEL_COLOR_YELLOW, "The quest %s has been advanced one step.", quest->GetName());
LogWrite(COMMAND__INFO, 0, "GM Command", "%s advanced the quest %s one step", client->GetPlayer()->GetName(), quest->GetName());
}
}
}
else
{
client->Message(CHANNEL_COLOR_RED, "Quest ID and Step Number must be greater than 0!");
}
}
else
{
client->Message(CHANNEL_COLOR_RED, "Step Number must be a number!");
}
}
else
{
client->Message(CHANNEL_COLOR_RED, "Quest ID must be a number!");
}
} Here's the full Command_ModifyQuest for location reference:
Code: Select all
void Commands::Command_ModifyQuest(Client* client, Seperator* sep)
{
PrintSep(sep, "COMMAND_MODIFY");
int64 value = 0;
Player* player = client->GetPlayer();
if (player->HasTarget() && player->GetTarget()->IsPlayer())
player = (Player*)player->GetTarget();
// need at least 2 args for a valid command
if( sep && sep->arg[1] )
{
if (strcmp(sep->arg[0], "list") == 0)
{
map<int32, Quest*>* quests = player->GetPlayerQuests();
map<int32, Quest*>::iterator itr;
client->Message(CHANNEL_COLOR_YELLOW, "%s's Quest List:.", client->GetPlayer()->GetName());
if (quests->size() == 0)
client->Message(CHANNEL_COLOR_YELLOW, "%s has no quests.", client->GetPlayer()->GetName());
else
{
for( itr = quests->begin(); itr != quests->end(); itr++ )
{
Quest* quest = itr->second;
client->Message(CHANNEL_COLOR_YELLOW, "%u) %s", itr->first, quest->GetName());
}
}
}
else if (strcmp(sep->arg[0], "completed") == 0)
{
map<int32, Quest*>* quests = player->GetCompletedPlayerQuests();
map<int32, Quest*>::iterator itr;
client->Message(CHANNEL_COLOR_YELLOW, "%s's Completed Quest List:.", client->GetPlayer()->GetName());
if (quests->size() == 0)
client->Message(CHANNEL_COLOR_YELLOW, "%s has no completed quests.", client->GetPlayer()->GetName());
else
{
for( itr = quests->begin(); itr != quests->end(); itr++ )
{
Quest* quest = itr->second;
client->Message(CHANNEL_COLOR_YELLOW, "%u) %s", itr->first, quest->GetName());
}
}
}
// Add in a progress step, and a LogWrite() for tracking GM Commands.
// LogWrite(LUA__DEBUG, 0, "LUA", "Quest: %s, function: %s", quest->GetName(), function);
else if (strcmp(sep->arg[0], "remove") == 0)
{
int32 quest_id = 0;
if (sep && sep->arg[1] && sep->IsNumber(1))
quest_id = atoul(sep->arg[1]);
if (quest_id > 0)
{
if (lua_interface && client->GetPlayer()->player_quests.count(quest_id) > 0)
{
Quest* quest = client->GetPlayer()->player_quests[quest_id];
if (quest)
if (client->GetPlayer() == player)
{
client->Message(CHANNEL_COLOR_YELLOW, "The quest %s has been removed from your journal", quest->GetName());
}
else
{
client->Message(CHANNEL_COLOR_YELLOW, "You have removed the quest %s from %s's journal", quest->GetName(), player->GetName());
client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s has removed the quest %s from your journal", client->GetPlayer()->GetName(), quest->GetName());
}
LogWrite(COMMAND__INFO, 0, "GM Command", "%s removed the quest %s from %s", client->GetPlayer()->GetName(), quest->GetName(), player->GetName());
lua_interface->CallQuestFunction(quest, "Deleted", client->GetPlayer());
}
client->RemovePlayerQuest(quest_id);
client->GetCurrentZone()->SendQuestUpdates(client);
}
}
else if (strcmp(sep->arg[0], "advance") == 0)
{
int32 quest_id = 0;
int32 step = 0;
if (sep && sep->arg[1] && sep->IsNumber(1))
{
quest_id = atoul(sep->arg[1]);
Quest* quest = client->GetPlayer()->player_quests[quest_id];
if (sep && sep->arg[2] && sep->IsNumber(1))
{
step = atoul(sep->arg[2]);
if (quest_id > 0 && step > 0)
{
if (player && player->IsPlayer() && quest_id > 0 && step > 0 && (player->player_quests.count(quest_id) > 0))
{
if (client)
{
client->AddPendingQuestUpdate(quest_id, step);
client->Message(CHANNEL_COLOR_YELLOW, "The quest %s has been advanced one step.", quest->GetName());
LogWrite(COMMAND__INFO, 0, "GM Command", "%s advanced the quest %s one step", client->GetPlayer()->GetName(), quest->GetName());
}
}
}
else
{
client->Message(CHANNEL_COLOR_RED, "Quest ID and Step Number must be greater than 0!");
}
}
else
{
client->Message(CHANNEL_COLOR_RED, "Step Number must be a number!");
}
}
else
{
client->Message(CHANNEL_COLOR_RED, "Quest ID must be a number!");
}
}
else
{
Command_Modify(client);
}
}
else
{
client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify quest [action] [quest id] [step number]");
client->SimpleMessage(CHANNEL_COLOR_RED, "Actions: list, completed, remove, advance");
client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify quest list");
client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify quest remove 156");
client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify quest advance 50 1");
}
}