Last active
August 14, 2018 15:48
-
-
Save miou-gh/d6d4d72e62abb2d43533c4dbb39d2f4c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/mseoserv/commands/debug.cpp b/mseoserv/commands/debug.cpp | |
index 5bebb40..38026f9 100644 | |
--- a/mseoserv/commands/debug.cpp | |
+++ b/mseoserv/commands/debug.cpp | |
@@ -28,6 +28,66 @@ | |
namespace Commands | |
{ | |
+void GiveItem(const std::vector<std::string>& arguments, Character* from) | |
+{ | |
+ Character *victim = from->world->GetCharacter(arguments[0]); | |
+ | |
+ if (!victim) | |
+ { | |
+ from->ServerMsg(from->world->i18n.Format("character_not_found")); | |
+ } | |
+ else | |
+ { | |
+ int id = util::to_int(arguments[1]); | |
+ int amount = (arguments.size() >= 3) ? util::to_int(arguments[2]) : 1; | |
+ | |
+ if (victim->AddItem(id, amount)) | |
+ { | |
+ PacketBuilder reply(PACKET_ITEM, PACKET_GET, 9); | |
+ reply.AddShort(0); // UID | |
+ reply.AddShort(id); | |
+ reply.AddThree(amount); | |
+ reply.AddChar(static_cast<unsigned char>(victim->weight)); | |
+ reply.AddChar(static_cast<unsigned char>(victim->maxweight)); | |
+ victim->Send(reply); | |
+ from->StatusMsg("You have given " + util::to_string(amount) + " " + from->world->eif->Get(id).name + " to " + victim->SourceName().c_str() + "."); | |
+ } | |
+ } | |
+} | |
+ | |
+void TakeItem(const std::vector<std::string>& arguments, Character* from) | |
+{ | |
+ int id = util::to_int(arguments[1]); | |
+ int amount = (arguments.size() >= 3) ? util::to_int(arguments[2]) : 1; | |
+ | |
+ if (amount <= 0) | |
+ return; | |
+ | |
+ Character *victim = from->world->GetCharacter(arguments[0]); | |
+ | |
+ if (!victim) | |
+ { | |
+ from->ServerMsg(from->world->i18n.Format("character_not_found")); | |
+ } | |
+ else | |
+ { | |
+ if (victim->trading) | |
+ return; | |
+ | |
+ if (victim->HasItem(id) >= amount) | |
+ { | |
+ victim->DelItem(id, amount); | |
+ | |
+ PacketBuilder reply(PACKET_ITEM, PACKET_JUNK, 11); | |
+ reply.AddShort(id); | |
+ reply.AddThree(amount); | |
+ reply.AddInt(victim->HasItem(id)); | |
+ reply.AddChar(static_cast<unsigned char>(victim->weight)); | |
+ reply.AddChar(static_cast<unsigned char>(victim->maxweight)); | |
+ victim->Send(reply); | |
+ from->StatusMsg("You have taken " + util::to_string(amount) + " " + from->world->eif->Get(id).name + " away from " + victim->SourceName().c_str() + "."); | |
+ } | |
+ } | |
+} | |
+ | |
void SpawnItem(const std::vector<std::string>& arguments, Character* from) | |
{ | |
int id = util::to_int(arguments[0]); | |
@@ -198,12 +258,16 @@ void QuestState(const std::vector<std::string>& arguments, Character* from) | |
} | |
COMMAND_HANDLER_REGISTER(debug) | |
+ RegisterCharacter({"give", {"victim"}, {"item", "amount"}, 2}, GiveItem, CMD_FLAG_DUTY_RESTRICT); | |
+ RegisterCharacter({"take", {"victim"}, {"item", "amount"}, 2}, TakeItem, CMD_FLAG_DUTY_RESTRICT); | |
RegisterCharacter({"sitem", {"item"}, {"amount"}, 2}, SpawnItem, CMD_FLAG_DUTY_RESTRICT); | |
RegisterCharacter({"ditem", {"item"}, {"amount", "x", "y"}, 2}, DropItem, CMD_FLAG_DUTY_RESTRICT); | |
RegisterCharacter({"snpc", {"npc"}, {"amount", "speed", "direction"}, 2}, SpawnNPC, CMD_FLAG_DUTY_RESTRICT); | |
RegisterCharacter({"dnpc", {}, {}, 2}, DespawnNPC, CMD_FLAG_DUTY_RESTRICT); | |
RegisterCharacter({"learn", {"skill"}, {"level"}}, Learn, CMD_FLAG_DUTY_RESTRICT); | |
RegisterCharacter({"qstate", {"quest", "state"}}, QuestState, CMD_FLAG_DUTY_RESTRICT); | |
+ RegisterAlias("ti", "take"); | |
+ RegisterAlias("gi", "give"); | |
RegisterAlias("si", "sitem"); | |
RegisterAlias("di", "ditem"); | |
RegisterAlias("sn", "snpc"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment