From 65f8dea0dae4b492007c73ea6a859f7542fc369d Mon Sep 17 00:00:00 2001 From: Martin Michelsen Date: Mon, 25 Sep 2023 09:44:57 -0700 Subject: [PATCH] add $call command --- README.md | 1 + src/ChatCommands.cc | 22 ++++++++++++++++++++++ system/config.example.json | 2 +- 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index ced614b7..fd89bafa 100644 --- a/README.md +++ b/README.md @@ -267,6 +267,7 @@ Some commands only work on the game server and not on the proxy server. The chat * Debugging commands * `$debug` (game server only): Enable or disable debug. You need the DEBUG permission in your user license to use this command. When debug is enabled, you'll see in-game messages from the server when you take certain actions. You'll also be placed into the highest available slot in lobbies and games instead of the lowest, which is useful for finding commands for which newserv doesn't handle client IDs properly. This setting also disables certain safeguards and allows you to do some things that might crash your client. + * `$call `: Call a quest function on your client. * `$gc` (game server only): Send your own Guild Card to yourself. * `$persist` (game server only): Enable or disable persistence for the current lobby or game. This determines whether the lobby/game is deleted when the last player leaves. You need the DEBUG permission in your user license to use this command because there are no game state checks when you do this. For example, if you make a game persistent, start a quest, then leave the game, the game can't be joined by anyone but also can't be deleted. * `$sc `: Send a command to yourself. diff --git a/src/ChatCommands.cc b/src/ChatCommands.cc index dccf307b..3548814a 100644 --- a/src/ChatCommands.cc +++ b/src/ChatCommands.cc @@ -383,6 +383,27 @@ static void proxy_command_exit(shared_ptr ses, const } } +static void server_command_call(shared_ptr c, const std::u16string& args) { + auto l = c->require_lobby(); + if (l->is_game() && l->quest) { + S_ConfirmQuestStatistic_V3_BB_AB cmd; + cmd.function_id = stoul(encode_sjis(args), nullptr, 0); + send_command_t(c, 0xAB, 0x00, cmd); + } else { + send_text_message(c, u"$C6You must be in\nquest to use this\ncommand"); + } +} + +static void proxy_command_call(shared_ptr ses, const std::u16string& args) { + if (ses->is_in_game && ses->is_in_quest) { + S_ConfirmQuestStatistic_V3_BB_AB cmd; + cmd.function_id = stoul(encode_sjis(args), nullptr, 0); + ses->client_channel.send(0xAB, 0x00, &cmd, sizeof(cmd)); + } else { + send_text_message(ses->client_channel, u"$C6You must be in\nquest to use this\ncommand"); + } +} + static void server_command_get_self_card(shared_ptr c, const std::u16string&) { send_guild_card(c, c); } @@ -1488,6 +1509,7 @@ static const unordered_map chat_commands({ {u"$ax", {server_command_ax, nullptr}}, {u"$ban", {server_command_ban, nullptr}}, {u"$bbchar", {server_command_convert_char_to_bb, nullptr}}, + {u"$call", {server_command_call, proxy_command_call}}, {u"$cheat", {server_command_cheat, nullptr}}, {u"$debug", {server_command_debug, nullptr}}, {u"$defrange", {server_command_ep3_set_def_dice_range, nullptr}}, diff --git a/system/config.example.json b/system/config.example.json index f9fe96ca..f84f1808 100644 --- a/system/config.example.json +++ b/system/config.example.json @@ -242,7 +242,7 @@ ["Ep3 commands", "Show commands used\nin Episode 3 games", "These commands can be used in Episode 3 games.\n\n$C8Before battle begins:$C7\n$C6%sinftime$C7: Disable all battle time limits, regardless\n of limits set in battle rules\n$C6%sdefrange -$C7: Set the DEF dice range for\n the next battle\n\n$C8During battle:$C7\n$C6%sspec$C7: Allow or forbid spectators\n$C6%sstat $C7: Show a live statistic\n$C6%ssurrender$C7: Immediately lose the current battle\n\n$C8In game after battle:$C7\n$C6%ssaverec $C7: Save recording of the last battle"], ["Cheat commands", "Show commands used\nfor cheating", "These commands can be used to cheat.\n\n$C8In a game:$C7\n$C6%scheat$C7: Enable or disable cheat mode\n\n$C8When cheat mode is enabled:$C7\n$C6%sinfhp$C7 / $C6%sinftp$C7: Enable or disable infinite HP or TP\n$C6%swarpme $C7: Warp yourself to the given area\n$C6%swarpall $C7: Warp everyone to the given area\n$C6%snext$C7: Warp yourself to the next area\n$C6%sswa$C7: Enable or disable switch assist\n$C6%si $C7 / $C6%si $C7: Create an item\n\n$C8Episode 3 only:$C7\n$C6%sunset $C7: Remove one of your set cards from\n the field"], ["Admin commands", "Show commands used\nfor setting server\noptions", "These commands provide administration functions.\n\n$C6%sevent $C7: Set the holiday in the current lobby\n$C6%sallevent $C7: Set the holiday in all lobbies\n$C6%sann $C7: Send an announcement message to\n all players\n$C6%sax $C7: Send a message to the server\n$C6%ssilence $C7: Silence or unsilence a player\n$C6%skick $C7: Disconnect a player\n$C6%sban $C7: Ban a player"], - ["Debug commands", "Show commands used\nfor debugging", "These commands are used for debugging.\n\n$C6%sdebug$C7: Enable or disable debug messages\n$C6%sgc$C7: Send your own Guild Card to yourself\n$C6%spersist$C7: Cause game to not close when last player\n leaves\n$C6%ssc $C7: Send a command to yourself\n\n$C8Proxy only:$C7\n$C6%sss $C7: Send a command to the remote server"], + ["Debug commands", "Show commands used\nfor debugging", "These commands are used for debugging.\n\n$C6%sdebug$C7: Enable or disable debug messages\n$C6%scall $C7: Call a quest function\n$C6%sgc$C7: Send your own Guild Card to yourself\n$C6%spersist$C7: Cause game to not close when last player\n leaves\n$C6%ssc $C7: Send a command to yourself\n\n$C8Proxy only:$C7\n$C6%sss $C7: Send a command to the remote server"], ["Using $i", "$C7Show how to use\nthe %si command", "The %si command is used to create items.\nUse it like this (for example):\n\n$C6%si Double Cannon +10 0/0/20/15/35$C7\n$C6%si Hell Pallasch$C7\n$C6%si Black Ring +5DEF$C7\n$C6%si Knight/Power++$C7\n$C6%si Sato 5/50/10.5/50 120% 200IQ$C7\n$C6%si Trimate x3$C7\n$C6%si 1000 Meseta$C7\n\nYou can also use a hex code instead of a name\n(this is the same as the Sato example above):\n\n$C6%si 023F7300F40188131A04881378C80000$C7"], ["Using $edit", "$C7Show how to use\nthe %sedit command", "%sedit is used in PSOBB to change character stats.\nUse one of the following subcommands:\n\n$C6%sedit ATP $C7\n$C6%sedit MST $C7\n$C6%sedit EVP $C7\n$C6%sedit HP $C7\n$C6%sedit DFP $C7\n$C6%sedit ATA $C7\n$C6%sedit LCK $C7\n$C6%sedit MESETA $C7\n$C6%sedit EXP $C7\n$C6%sedit LEVEL $C7\n$C6%sedit NAMECOLOR $C7\n$C6%sedit SECID
$C7\n$C6%sedit NAME $C7\n$C6%sedit NPC $C7\n$C6%sedit TECH $C7\n\nNPC names: none, ninja, rico, sonic, knuckles,\n flowen, elly\n\nTechnique names: foie, gifoie, rafoie, barta,\n gibarta, rabarta, zonde, gizonde, razonde,\n grants, deband, jellen, zalure, shifta, ryuker,\n resta, anti, reverser, megid, all"], ["Using $bbchar", "$C7Show how to use\nthe %sbbchar command", "%sbbchar is used to convert a character from an\nolder version of PSO to Blue Burst format and save\nit on this server. Use the command like this:\n\n$C6%sbbchar $C7\n\nIf the username and password are correct, the\ncharacter that you're currently playing as will be\nconverted to PSOBB format and saved under that\naccount, in the specified character slot (1-4)."],