diff options
author | MadCamel <madcamel@gmail.com> | 2009-09-30 13:53:33 -0400 |
---|---|---|
committer | MadCamel <madcamel@gmail.com> | 2009-09-30 13:53:33 -0400 |
commit | 3fc3d83aa0be31e6d51afac54ff76b447f99f711 (patch) | |
tree | 2deac15b3e34382f11a27090e3f1a8ef3049618b /src/map/atcommand.c | |
parent | 5967577d8bf92a9912cd153b20597f0d13a19456 (diff) | |
parent | 48d96bc41a4791b6cb0bc2cf514a6cc1f06c4dd8 (diff) | |
download | tmwa-3fc3d83aa0be31e6d51afac54ff76b447f99f711.tar.gz tmwa-3fc3d83aa0be31e6d51afac54ff76b447f99f711.tar.bz2 tmwa-3fc3d83aa0be31e6d51afac54ff76b447f99f711.tar.xz tmwa-3fc3d83aa0be31e6d51afac54ff76b447f99f711.zip |
Merge branch 'master' of git://gitorious.org/tmw-eathena/mainline
Diffstat (limited to 'src/map/atcommand.c')
-rw-r--r-- | src/map/atcommand.c | 163 |
1 files changed, 159 insertions, 4 deletions
diff --git a/src/map/atcommand.c b/src/map/atcommand.c index ed213b2..510026b 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -201,8 +201,13 @@ ATCOMMAND_FUNC(log); // [Fate] ATCOMMAND_FUNC(tee); // [Fate] ATCOMMAND_FUNC(invisible); // [Fate] ATCOMMAND_FUNC(visible); // [Fate] +ATCOMMAND_FUNC(list_nearby); // [Fate] ATCOMMAND_FUNC(iterate_forward_over_players); // [Fate] ATCOMMAND_FUNC(iterate_backwards_over_players); // [Fate] +ATCOMMAND_FUNC(skillpool_info); // [Fate] +ATCOMMAND_FUNC(skillpool_focus); // [Fate] +ATCOMMAND_FUNC(skillpool_unfocus); // [Fate] +ATCOMMAND_FUNC(skill_learn); // [Fate] ATCOMMAND_FUNC(wgm); /*========================================== @@ -334,6 +339,7 @@ static AtCommandInfo atcommand_info[] = { { AtCommand_Disablenpc, "@disablenpc", 80, atcommand_disablenpc }, // [] { AtCommand_ServerTime, "@servertime", 0, atcommand_servertime }, // by Yor { AtCommand_CharDelItem, "@chardelitem", 60, atcommand_chardelitem }, // by Yor + { AtCommand_ListNearby, "@listnearby", 40, atcommand_list_nearby }, // by Yor { AtCommand_Jail, "@jail", 60, atcommand_jail }, // by Yor { AtCommand_UnJail, "@unjail", 60, atcommand_unjail }, // by Yor { AtCommand_Disguise, "@disguise", 20, atcommand_disguise }, // [Valaris] @@ -391,6 +397,10 @@ static AtCommandInfo atcommand_info[] = { { AtCommand_Visible, "@visible", 60, atcommand_visible }, // [Fate] { AtCommand_IterateForward, "@hugo", 60, atcommand_iterate_forward_over_players }, // [Fate] { AtCommand_IterateBackward, "@linus", 60, atcommand_iterate_backwards_over_players }, // [Fate] + { AtCommand_IterateBackward, "@sp-info", 40, atcommand_skillpool_info }, // [Fate] + { AtCommand_IterateBackward, "@sp-focus", 80, atcommand_skillpool_focus }, // [Fate] + { AtCommand_IterateBackward, "@sp-unfocus", 80, atcommand_skillpool_unfocus }, // [Fate] + { AtCommand_IterateBackward, "@skill-learn", 80, atcommand_skill_learn }, // [Fate] { AtCommand_Wgm, "@wgm", 0, atcommand_wgm }, // add new commands before this line @@ -2606,6 +2616,37 @@ int atcommand_killmonster( return 0; } + +/*========================================== + * + *------------------------------------------ + */ +static int atlist_nearby_sub(struct block_list *bl, va_list ap) { + char buf[32]; + int fd = va_arg(ap, int); + nullpo_retr(0, bl); + + sprintf (buf, " - \"%s\"", ((struct map_session_data *)bl)->status.name); + clif_displaymessage(fd, buf); + + return 0; +} + +/*========================================== + * + *------------------------------------------ + */ +int atcommand_list_nearby( + const int fd, struct map_session_data* sd, + const char* command, const char* message) +{ + clif_displaymessage(fd, "Nearby players:"); + map_foreachinarea(atlist_nearby_sub, sd->bl.m, sd->bl.x-1, sd->bl.y-1, sd->bl.x+1, sd->bl.x+1, BL_PC, fd); + + return 0; +} + + /*========================================== * *------------------------------------------ @@ -4055,7 +4096,7 @@ int atcommand_lostskill( if (skill_get_inf2(skill_id) & 0x01) { if (pc_checkskill(sd, skill_id) > 0) { sd->status.skill[skill_id].lv = 0; - sd->status.skill[skill_id].flag = 0; + sd->status.skill[skill_id].flags = 0; clif_skillinfoblock(sd); clif_displaymessage(fd, msg_table[71]); // You have forgotten the skill. } else { @@ -4098,7 +4139,7 @@ int atcommand_charlostskill( if ((pl_sd = map_nick2sd(character)) != NULL) { if (pc_checkskill(pl_sd, skill_id) > 0) { pl_sd->status.skill[skill_id].lv = 0; - pl_sd->status.skill[skill_id].flag = 0; + pl_sd->status.skill[skill_id].flags = 0; clif_skillinfoblock(pl_sd); clif_displaymessage(fd, msg_table[202]); // This player has forgotten the skill. } else { @@ -6969,7 +7010,7 @@ atcommand_magic_info(const int fd, struct map_session_data* sd, memset(character, '\0', sizeof(character)); - if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) { + if (!message || !*message || sscanf(message, "%99s", character) < 1) { clif_displaymessage(fd, "Usage: @magicinfo <char_name>"); return -1; } @@ -6998,7 +7039,6 @@ set_skill(struct map_session_data* sd, int i, int level) { sd->status.skill[i].id = level? i : 0; sd->status.skill[i].lv = level; - sd->status.skill[i].flag = 0; } int @@ -7161,3 +7201,118 @@ int atcommand_wgm( return 0; } + +int atcommand_skillpool_info( + const int fd, struct map_session_data* sd, + const char* command, const char* message) +{ + char character[100]; + struct map_session_data *pl_sd; + + if (!message || !*message || sscanf(message, "%99s", character) < 1) { + clif_displaymessage(fd, "Usage: @sp-info <char_name>"); + return -1; + } + + if ((pl_sd = map_nick2sd(character)) != NULL) { + char buf[200]; + int pool_skills[MAX_SKILL_POOL]; + int pool_skills_nr = skill_pool(pl_sd, pool_skills); + int i; + + sprintf(buf, "Active skills %d out of %d for %s:", pool_skills_nr, skill_pool_max(pl_sd), character); + clif_displaymessage(fd, buf); + for (i = 0; i < pool_skills_nr; ++i) { + sprintf(buf, " - %s [%d]: power %d", skill_name(pool_skills[i]), pool_skills[i], skill_power(pl_sd, pool_skills[i])); + clif_displaymessage(fd, buf); + } + + sprintf(buf, "Learned skills out of %d for %s:", skill_pool_skills_size, character); + clif_displaymessage(fd, buf); + + for (i = 0; i < skill_pool_skills_size; ++i) { + char *name = skill_name(skill_pool_skills[i]); + int lvl = pl_sd->status.skill[skill_pool_skills[i]].lv; + + if (lvl) { + sprintf(buf, " - %s [%d]: lvl %d", name, skill_pool_skills[i], lvl); + clif_displaymessage(fd, buf); + } + } + + } else + clif_displaymessage(fd, "Character not found."); + + + return 0; +} + +int atcommand_skillpool_focus( + const int fd, struct map_session_data* sd, + const char* command, const char* message) +{ + char character[100]; + int skill; + struct map_session_data *pl_sd; + + if (!message || !*message || sscanf(message, "%d %99[^\n]", &skill, character) < 1) { + clif_displaymessage(fd, "Usage: @sp-focus <skill-nr> <char_name>"); + return -1; + } + + if ((pl_sd = map_nick2sd(character)) != NULL) { + if (skill_pool_activate(pl_sd, skill)) + clif_displaymessage(fd, "Activation failed."); + else + clif_displaymessage(fd, "Activation successful."); + } else + clif_displaymessage(fd, "Character not found."); + + return 0; +} + +int atcommand_skillpool_unfocus( + const int fd, struct map_session_data* sd, + const char* command, const char* message) +{ + char character[100]; + int skill; + struct map_session_data *pl_sd; + + if (!message || !*message || sscanf(message, "%d %99[^\n]", &skill, character) < 1) { + clif_displaymessage(fd, "Usage: @sp-unfocus <skill-nr> <char_name>"); + return -1; + } + + if ((pl_sd = map_nick2sd(character)) != NULL) { + if (skill_pool_deactivate(pl_sd, skill)) + clif_displaymessage(fd, "Deactivation failed."); + else + clif_displaymessage(fd, "Deactivation successful."); + } else + clif_displaymessage(fd, "Character not found."); + + return 0; +} + +int atcommand_skill_learn( + const int fd, struct map_session_data* sd, + const char* command, const char* message) +{ + char character[100]; + int skill, level; + struct map_session_data *pl_sd; + + if (!message || !*message || sscanf(message, "%d %d %99[^\n]", &skill, &level, character) < 1) { + clif_displaymessage(fd, "Usage: @skill-learn <skill-nr> <level> <char_name>"); + return -1; + } + + if ((pl_sd = map_nick2sd(character)) != NULL) { + set_skill(pl_sd, skill, level); + clif_skillinfoblock(pl_sd); + } else + clif_displaymessage(fd, "Character not found."); + + return 0; +} |