Added atcommand "setcard" (#7804)

Thanks to @aleos89 and @Lemongrass3110 !
This commit is contained in:
Atemo 2023-06-08 20:08:26 +02:00 committed by GitHub
parent 38d335a267
commit aa8f501388
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 108 additions and 0 deletions

View File

@ -1019,6 +1019,9 @@ Body:
- Command: roulette
Help: |
Opens the roulette UI.
- Command: setcard
Help: |
Adds a card or enchant to the specific slot of the equipment.
Footer:
Imports:

View File

@ -1807,5 +1807,13 @@
1525: %d: Shadow Right Accessory
1526: %d: Shadow Left Accessory
// @setcard
1527: Please enter the position, the slot number and the card ID (usage: @setcard <equip position> <slot> <card_id>).
1528: You are not wearing any equipment in this position.
1529: The item type must be a card or enchant.
1530: Invalid card ID.
1531: Invalid position.
1532: Invalid slot number.
//Custom translations
import: conf/msg_conf/import/map_msg_eng_conf.txt

View File

@ -1207,6 +1207,27 @@ Opens the enchantgrade UI.
---------------------------------------
@setcard <equip position> <slot> <card_id>
Adds a card or enchant to the specific slot of the equipment.
<equip position>:
1: Lower Headgear
2: Right Hand
4: Garment
8: Left Accessory
16: Body Armor
32: Left Hand
64: Shoes
128: Right Accessory
256: Top Headgear
512: Mid Headgear
<slot> number: 0-3.
<card_id>: Can actually be any existing card or enchant item. Put 0 to remove it.
---------------------------------------
==============================
| 5. Administrative Commands |
==============================

View File

@ -10836,6 +10836,81 @@ ACMD_FUNC( roulette ){
#endif
}
/**
* Replaces a card ID in an equip
* Usage: @setcard <equip position> <slot> <card_id>
*/
ACMD_FUNC(setcard)
{
nullpo_retr(-1, sd);
int position = 0, slot, card_id;
if (!message || !*message || sscanf(message, "%11d %11d %11d", &position, &slot, &card_id) < 3) {
memset(atcmd_output, '\0', sizeof(atcmd_output));
clif_displaymessage(fd, msg_txt(sd,1527)); // Please enter the position, the slot number and the card ID (usage: @setcard <equip position> <slot> <card_id>).
sprintf(atcmd_output, msg_txt(sd,997), EQP_HEAD_LOW); // %d: Lower Headgear
clif_displaymessage(fd, atcmd_output);
sprintf(atcmd_output, msg_txt(sd,998), EQP_HAND_R); // %d: Right Hand
clif_displaymessage(fd, atcmd_output);
sprintf(atcmd_output, msg_txt(sd,999), EQP_GARMENT); // %d: Garment
clif_displaymessage(fd, atcmd_output);
sprintf(atcmd_output, msg_txt(sd,1000), EQP_ACC_L); // %d: Left Accessory
clif_displaymessage(fd, atcmd_output);
sprintf(atcmd_output, msg_txt(sd,1001), EQP_ARMOR); // %d: Body Armor
clif_displaymessage(fd, atcmd_output);
sprintf(atcmd_output, msg_txt(sd,1002), EQP_HAND_L); // %d: Left Hand
clif_displaymessage(fd, atcmd_output);
sprintf(atcmd_output, msg_txt(sd,1003), EQP_SHOES); // %d: Shoes
clif_displaymessage(fd, atcmd_output);
sprintf(atcmd_output, msg_txt(sd,1004), EQP_ACC_R); // %d: Right Accessory
clif_displaymessage(fd, atcmd_output);
sprintf(atcmd_output, msg_txt(sd,1005), EQP_HEAD_TOP); // %d: Top Headgear
clif_displaymessage(fd, atcmd_output);
sprintf(atcmd_output, msg_txt(sd,1006), EQP_HEAD_MID); // %d: Mid Headgear
return -1;
}
if (position < EQP_HEAD_LOW || position > EQP_HEAD_MID) {
clif_displaymessage(fd, msg_txt(sd,1531)); // Invalid position.
return -1;
}
if (slot < 0 || slot >= MAX_SLOTS) {
clif_displaymessage(fd, msg_txt(sd,1532)); // Invalid slot number.
return -1;
}
if (card_id != 0) {
std::shared_ptr<item_data> item_data = item_db.find( card_id );
if (item_data == nullptr) {
clif_displaymessage(fd, msg_txt(sd,1530)); // Invalid card ID.
return -1;
}
if (item_data->type != IT_CARD) {
clif_displaymessage(fd, msg_txt(sd,1529)); // The item type must be a card or enchant.
return -1;
}
}
int16 i = pc_checkequip(sd, position);
if (i < 0) {
clif_displaymessage(fd, msg_txt(sd,1528)); // You are not wearing any equipment in this position.
return -1;
}
int current_position = sd->inventory.u.items_inventory[i].equip;
pc_unequipitem(sd, i, 3);
log_pick_pc( sd, LOG_TYPE_COMMAND, -1, &sd->inventory.u.items_inventory[i] );
sd->inventory.u.items_inventory[i].card[slot] = card_id;
log_pick_pc( sd, LOG_TYPE_COMMAND, 1, &sd->inventory.u.items_inventory[i] );
clif_delitem(sd, i, 1, 0);
clif_additem(sd, i, 1, 0);
pc_equipitem(sd, i, current_position);
return 0;
}
#include <custom/atcommand.inc>
/**
@ -11162,6 +11237,7 @@ void atcommand_basecommands(void) {
ACMD_DEF(addfame),
ACMD_DEFR(enchantgradeui, ATCMD_NOCONSOLE|ATCMD_NOAUTOTRADE),
ACMD_DEFR(roulette, ATCMD_NOCONSOLE|ATCMD_NOAUTOTRADE),
ACMD_DEF(setcard),
};
AtCommandInfo* atcommand;
int i;