diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/ecommon/init.c | 7 | ||||
-rw-r--r-- | src/emap/atcommand.c | 76 | ||||
-rw-r--r-- | src/emap/atcommand.h | 1 | ||||
-rw-r--r-- | src/emap/init.c | 13 | ||||
-rw-r--r-- | src/emap/script_buildins.c | 203 | ||||
-rw-r--r-- | src/emap/script_buildins.h | 9 |
6 files changed, 306 insertions, 3 deletions
diff --git a/src/ecommon/init.c b/src/ecommon/init.c index c58de23..5103ffa 100644 --- a/src/ecommon/init.c +++ b/src/ecommon/init.c @@ -44,12 +44,13 @@ void commonClean(void) void common_online(void) { - checkVar(MAX_SKILL_DB, 1532); - checkVar(MAX_SKILL_ID, 20022); + checkVar(MAX_STORAGE, 500); + checkVar(MAX_SKILL_DB, 1552); + checkVar(MAX_SKILL_ID, 20042); checkVar(SC_MAX, 658); checkVar(SI_MAX, 971); checkVar(OLD_MAX_SKILL_DB, 1510); - checkVar(MAX_EVOL_SKILLS, 22); + checkVar(MAX_EVOL_SKILLS, 42); checkVar(EVOL_FIRST_SKILL, 20000); checkVar(MAX_SKILL_TREE, 110); } diff --git a/src/emap/atcommand.c b/src/emap/atcommand.c index f71698f..d3b9a99 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,1481)); // 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; +} + + diff --git a/src/emap/atcommand.h b/src/emap/atcommand.h index 50a92df..de5a880 100644 --- a/src/emap/atcommand.h +++ b/src/emap/atcommand.h @@ -42,5 +42,6 @@ ACMD1(serverExit); ACMD0(log); ACMD4(tee); ACMD4(getName); +ACMD0(tmw2item); #endif // EVOL_MAP_ATCOMMAND diff --git a/src/emap/init.c b/src/emap/init.c index 3c40f30..deabd84 100644 --- a/src/emap/init.c +++ b/src/emap/init.c @@ -110,6 +110,7 @@ HPExport void plugin_init (void) addAtcommand("tee", tee); addAtcommand("log", log); addAtcommand("getname", getName); + addAtcommand("item", tmw2item); addCPCommand("serverexit", serverExit); @@ -210,6 +211,15 @@ HPExport void plugin_init (void) addScriptCommand("setitemoptionbyindex", "iii*", setItemOptionByIndex); addScriptCommand("isinstance", "i", isInstance); + // TMW2 Custom Script Commands + addScriptCommand("getguildinfo","i",getguildinfo); + addScriptCommand("getguildlvl","i",getguildlvl); + addScriptCommand("getguildavg","i",getguildavg); + addScriptCommand("getguildexp","i",getguildexp); + addScriptCommand("getguildnxp","i",getguildnxp); + addScriptCommand("setguildrole","iiiis",setguildrole); + addScriptCommand("getguildmember","i?",getguildmember); + do_init_langs(); addPacket(0x7530, 22, map_parse_version, hpClif_Parse); @@ -335,6 +345,9 @@ HPExport void plugin_init (void) addHookPre(status, calc_pc_recover_hp, estatus_calc_pc_recover_hp_pre); addHookPre(homun, gainexp, ehomunculus_gainexp_pre); + // TMW2 Custom Pre Hooks + //addHookPre(battle, calc_weapon_attack, ebattle_calc_weapon_attack_pre); + addHookPost(battle, calc_weapon_attack, ebattle_calc_weapon_attack_post); addHookPost(battle, calc_magic_attack, ebattle_calc_weapon_attack_post); addHookPost(battle, calc_misc_attack, ebattle_calc_weapon_attack_post); diff --git a/src/emap/script_buildins.c b/src/emap/script_buildins.c index 93e9388..5e86a22 100644 --- a/src/emap/script_buildins.c +++ b/src/emap/script_buildins.c @@ -14,7 +14,9 @@ #include "map/achievement.h" #include "map/chat.h" #include "map/chrif.h" +#include "map/guild.h" #include "map/instance.h" +#include "map/mapreg.h" #include "map/npc.h" #include "map/pc.h" #include "map/script.h" @@ -2334,3 +2336,204 @@ BUILDIN(isInstance) script_pushint(st, instance->valid(instance_id) ? 1 : 0); return true; } + +/////////////////////////////////////////////////////////////////////////////// +// TMW2 Custom Commands +/////////////////////////////////////////////////////////////////////////////// + +/*========================================== + * Return the data of the @guild_id + * null if not found + *------------------------------------------*/ +BUILDIN(getguildinfo) +{ + int guild_id; + struct guild* g; + + guild_id = script_getnum(st,2); + + if( ( g = guild->search(guild_id) ) != NULL ) + { + mapreg->setreg(reference_uid(script->add_variable("$@guildinfo_lvl"), guild_id),g->guild_lv); + mapreg->setreg(reference_uid(script->add_variable("$@guildinfo_avg"), guild_id),g->average_lv); + mapreg->setreg(reference_uid(script->add_variable("$@guildinfo_exp"), guild_id),g->exp); + mapreg->setreg(reference_uid(script->add_variable("$@guildinfo_nxp"), guild_id),g->next_exp); + } + else + { + //script_pushconststr(st,"null"); + script_pushint(st,0); + } + return true; +} + +/*========================================== + * Return the level of the @guild_id + * -1 if not found + *------------------------------------------*/ +BUILDIN(getguildlvl) +{ + int guild_id; + struct guild* g; + + guild_id = script_getnum(st,2); + + if( ( g = guild->search(guild_id) ) != NULL ) + { + script_pushint(st,g->guild_lv); + } + else + { + script_pushint(st,-1); + } + return true; +} + + +/*========================================== + * Return the average player level of the @guild_id + * -1 if not found + *------------------------------------------*/ +BUILDIN(getguildavg) +{ + int guild_id; + struct guild* g; + + guild_id = script_getnum(st,2); + + if( ( g = guild->search(guild_id) ) != NULL ) + { + script_pushint(st,g->average_lv); + } + else + { + script_pushint(st,-1); + } + return true; +} + + +/*========================================== + * Return the experience of the @guild_id + * -1 if not found + *------------------------------------------*/ +BUILDIN(getguildexp) +{ + int guild_id; + struct guild* g; + + guild_id = script_getnum(st,2); + + if( ( g = guild->search(guild_id) ) != NULL ) + { + script_pushint(st,g->exp); + } + else + { + script_pushint(st,-1); + } + return true; +} + + +/*========================================== + * Return the experience to level up for the @guild_id + * -1 if not found + *------------------------------------------*/ +BUILDIN(getguildnxp) +{ + int guild_id; + struct guild* g; + + guild_id = script_getnum(st,2); + + if( ( g = guild->search(guild_id) ) != NULL ) + { + script_pushint(st,g->next_exp); + } + else + { + script_pushint(st,-1); + } + return true; +} + + +/*========================================== + * Change a position for the @guild_id + * -1 if not found + * This will be superseed by ManaPlus eventually + * and is only a quick fix until 4144 can work with GUI. + * Everyone knows C is easier than C++ >.> + * WARNING Not sanitized + *------------------------------------------*/ +BUILDIN(setguildrole) +{ + int guild_id; + int idx; + int mode; + int exp_mode; + const char *name; + struct guild* g; + + guild_id = script_getnum(st,2); + idx = script_getnum(st,3); + mode = script_getnum(st,4); + exp_mode = script_getnum(st,5); + name = script_getstr(st,6); + + if( ( g = guild->search(guild_id) ) != NULL ) + { + script_pushint(st, guild->change_position(guild_id, idx, mode, exp_mode, name)); + } + else + { + script_pushint(st,-1); + } + return true; +} + +/*========================================== + * Get the information of the members of a guild by type. + * getguildmember <guild_id>{,<type>}; + * @param guild_id: ID of guild + * @param type: + * 0 : name (default) + * 1 : character ID + * 2 : account ID + *------------------------------------------*/ +BUILDIN(getguildmember) +{ + struct guild *g = NULL; + int j = 0; + + g = guild->search(script_getnum(st,2)); + + if (g) { + int i, type = 0; + + if (script_hasdata(st,3)) + type = script_getnum(st,3); + + for ( i = 0; i < MAX_GUILD; i++ ) { + if ( g->member[i].account_id ) { + switch (type) { + case 2: + mapreg->setreg(reference_uid(script->add_variable("$@guildmemberaid"), j),g->member[i].account_id); + break; + case 1: + mapreg->setreg(reference_uid(script->add_variable("$@guildmembercid"), j), g->member[i].char_id); + break; + default: + mapreg->setregstr(reference_uid(script->add_variable("$@guildmembername$"), j), g->member[i].name); + break; + } + mapreg->setreg(reference_uid(script->add_variable("$@guildmemberpos"), j),g->member[i].position); + j++; + } + } + } + mapreg->setreg(script->add_variable("$@guildmembercount"), j); + return true; +} + diff --git a/src/emap/script_buildins.h b/src/emap/script_buildins.h index fab271e..b93b302 100644 --- a/src/emap/script_buildins.h +++ b/src/emap/script_buildins.h @@ -100,4 +100,13 @@ BUILDIN(getItemOptionParamByIndex); BUILDIN(setItemOptionByIndex); BUILDIN(isInstance); +// TMW2 Build Ins +BUILDIN(getguildinfo); +BUILDIN(getguildlvl); +BUILDIN(getguildavg); +BUILDIN(getguildexp); +BUILDIN(getguildnxp); +BUILDIN(setguildrole); +BUILDIN(getguildmember); + #endif // EVOL_MAP_SCRIPT_BUILDINS |