diff options
Diffstat (limited to 'src/emap/atcommand.c')
-rw-r--r-- | src/emap/atcommand.c | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/src/emap/atcommand.c b/src/emap/atcommand.c index f71698f..8c38a35 100644 --- a/src/emap/atcommand.c +++ b/src/emap/atcommand.c @@ -7,6 +7,7 @@ #include <stdlib.h> #include <string.h> +#include "common/cbasetypes.h" #include "common/HPMi.h" #include "common/memmgr.h" #include "common/mmo.h" @@ -16,6 +17,7 @@ #include "map/atcommand.h" #include "map/clif.h" #include "map/map.h" +#include "map/pet.h" #include "map/pc.h" #include "map/skill.h" @@ -289,3 +291,77 @@ ACMD1(getName) return true; } + +// TMW2 +/*========================================== + * @item command (usage: @item <name/id_of_item> <quantity>) (modified by [Yor] for pet_egg) + * @itembound command (usage: @itembound <name/id_of_item> <quantity> <bound type>) (revised by [Mhalicot]) + *------------------------------------------*/ +ACMD0(tmw2item) +{ + char item_name[100]; + int number = 0, item_id, flag = 0, bound = 0; + struct item item_tmp; + struct item_data *item_data; + int get_count, i; + + memset(item_name, '\0', sizeof(item_name)); + + if (!*message + || ( sscanf(message, "\"%99[^\"]\" %12d", item_name, &number) < 1 + && sscanf(message, "%99s %12d", item_name, &number) < 1 + )) { + clif->message(fd, msg_fd(fd,983)); // Please enter an item name or ID (usage: @item <item name/ID> <quantity>). + return false; + } + + if (number <= 0) + number = 1; + + if ((item_data = itemdb->search_name(item_name)) == NULL && + (item_data = itemdb->exists(atoi(item_name))) == NULL) + { + clif->message(fd, msg_fd(fd,19)); // Invalid item ID or name. + return false; + } + + item_id = item_data->nameid; + get_count = number; + + // TMW2: Check for restrictions + // Strange Coins ; <BronzeGift ~ SupremeGift> ; DeathPenalty + if( item_id == 828 || + (item_id >= 589 && item_id <= 593) || + item_id == 7420 ) { + clif->message(fd, msg_fd(fd,1999)); // TMW2 Restriction + return false; + } + + //Check if it's stackable. + if (!itemdb->isstackable2(item_data)) { + if( bound && (item_data->type == IT_PETEGG || item_data->type == IT_PETARMOR) ) { + clif->message(fd, msg_fd(fd,498)); // Cannot create bounded pet eggs or pet armors. + return false; + } + get_count = 1; + } + + for (i = 0; i < number; i += get_count) { + // if not pet egg + if (!pet->create_egg(sd, item_id)) { + memset(&item_tmp, 0, sizeof(item_tmp)); + item_tmp.nameid = item_id; + item_tmp.identify = 1; + item_tmp.bound = (unsigned char)bound; + + if ((flag = pc->additem(sd, &item_tmp, get_count, LOG_TYPE_COMMAND))) + clif->additem(sd, 0, 0, flag); + } + } + + if (flag == 0) + clif->message(fd, msg_fd(fd,18)); // Item created. + return true; +} + + |