New Group System, Room Events, and Event System Efficiency Upgrade... and a couple bug fixes.

This commit is contained in:
Vatiken
2013-02-15 03:54:25 +00:00
parent 82da0e8063
commit a2aaab144f
32 changed files with 612 additions and 322 deletions

View File

@@ -35,9 +35,8 @@
/* Local defined utility functions */
/* do_group utility functions */
static int perform_group(struct char_data *ch, struct char_data *vict);
static void print_group(struct char_data *ch);
static void display_group_list(struct char_data * ch);
ACMD(do_quit)
{
@@ -319,185 +318,172 @@ ACMD(do_title)
}
}
static int perform_group(struct char_data *ch, struct char_data *vict)
{
if (AFF_FLAGGED(vict, AFF_GROUP) || !CAN_SEE(ch, vict))
return (0);
SET_BIT_AR(AFF_FLAGS(vict), AFF_GROUP);
if (ch != vict)
act("$N is now a member of your group.", FALSE, ch, 0, vict, TO_CHAR);
act("You are now a member of $n's group.", FALSE, ch, 0, vict, TO_VICT);
act("$N is now a member of $n's group.", FALSE, ch, 0, vict, TO_NOTVICT);
return (1);
}
static void print_group(struct char_data *ch)
{
struct char_data *k;
struct follow_type *f;
struct char_data * k;
if (!AFF_FLAGGED(ch, AFF_GROUP))
send_to_char(ch, "But you are not the member of a group!\r\n");
else {
char buf[MAX_STRING_LENGTH];
send_to_char(ch, "Your group consists of:\r\n");
send_to_char(ch, "Your group consists of:\r\n");
k = (ch->master ? ch->master : ch);
if (AFF_FLAGGED(k, AFF_GROUP)) {
snprintf(buf, sizeof(buf), " [%3dH %3dM %3dV] [%2d %s] $N (Head of group)",
GET_HIT(k), GET_MANA(k), GET_MOVE(k), GET_LEVEL(k), CLASS_ABBR(k));
act(buf, FALSE, ch, 0, k, TO_CHAR);
}
for (f = k->followers; f; f = f->next) {
if (!AFF_FLAGGED(f->follower, AFF_GROUP))
continue;
snprintf(buf, sizeof(buf), " [%3dH %3dM %3dV] [%2d %s] $N", GET_HIT(f->follower),
GET_MANA(f->follower), GET_MOVE(f->follower),
GET_LEVEL(f->follower), CLASS_ABBR(f->follower));
act(buf, FALSE, ch, 0, f->follower, TO_CHAR);
}
}
while ((k = (struct char_data *) simple_list(ch->group->members)) != NULL)
send_to_char(ch, "%-*s: %s[%4d/%-4d]H [%4d/%-4d]M [%4d/%-4d]V%s\r\n",
count_color_chars(GET_NAME(k))+22, GET_NAME(k),
GROUP_LEADER(GROUP(ch)) == k ? CBGRN(ch, C_NRM) : CCGRN(ch, C_NRM),
GET_HIT(k), GET_MAX_HIT(k),
GET_MANA(k), GET_MAX_MANA(k),
GET_MOVE(k), GET_MAX_MOVE(k),
CCNRM(ch, C_NRM));
}
static void display_group_list(struct char_data * ch)
{
struct group_data * group;
int count = 0;
if (group_list->iSize) {
send_to_char(ch, "# Group Leader # of Members In Zone\r\n"
"---------------------------------------------------\r\n");
while ((group = (struct group_data *) simple_list(group_list)) != NULL) {
if (IS_SET(GROUP_FLAGS(group), GROUP_NPC))
continue;
if (GROUP_LEADER(group) && !IS_SET(GROUP_FLAGS(group), GROUP_ANON))
send_to_char(ch, "%-2d) %s%-12s %-2d %s%s\r\n",
++count,
IS_SET(GROUP_FLAGS(group), GROUP_OPEN) ? CCGRN(ch, C_NRM) : CCRED(ch, C_NRM),
GET_NAME(GROUP_LEADER(group)), group->members->iSize, zone_table[world[IN_ROOM(GROUP_LEADER(group))].zone].name,
CCNRM(ch, C_NRM));
else
send_to_char(ch, "%-2d) Hidden\r\n", ++count);
}
}
if (count)
send_to_char(ch, "\r\n"
"%sSeeking Members%s\r\n"
"%sClosed%s\r\n",
CCGRN(ch, C_NRM), CCNRM(ch, C_NRM),
CCRED(ch, C_NRM), CCNRM(ch, C_NRM));
else
send_to_char(ch, "\r\n"
"Currently no groups formed.\r\n");
}
/* Vatiken's Group System: Version 1.1 */
ACMD(do_group)
{
char buf[MAX_STRING_LENGTH];
struct char_data *vict;
struct follow_type *f;
int found;
one_argument(argument, buf);
argument = one_argument(argument, buf);
if (!*buf) {
print_group(ch);
if (GROUP(ch))
print_group(ch);
else
send_to_char(ch, "You must specify a group option, or type HELP GROUP for more info.\r\n");
return;
}
if (ch->master) {
act("You cannot enroll group members without being head of a group.",
FALSE, ch, 0, 0, TO_CHAR);
return;
}
if (!str_cmp(buf, "all")) {
perform_group(ch, ch);
for (found = 0, f = ch->followers; f; f = f->next)
found += perform_group(ch, f->follower);
if (!found)
send_to_char(ch, "Everyone following you is already in your group.\r\n");
return;
}
if (!(vict = get_char_vis(ch, buf, NULL, FIND_CHAR_ROOM)))
send_to_char(ch, "%s", CONFIG_NOPERSON);
else if ((vict->master != ch) && (vict != ch))
act("$N must follow you to enter your group.", FALSE, ch, 0, vict, TO_CHAR);
else {
if (!AFF_FLAGGED(vict, AFF_GROUP))
perform_group(ch, vict);
else {
if (ch != vict)
act("$N is no longer a member of your group.", FALSE, ch, 0, vict, TO_CHAR);
act("You have been kicked out of $n's group!", FALSE, ch, 0, vict, TO_VICT);
act("$N has been kicked out of $n's group!", FALSE, ch, 0, vict, TO_NOTVICT);
REMOVE_BIT_AR(AFF_FLAGS(vict), AFF_GROUP);
}
}
}
ACMD(do_ungroup)
{
char buf[MAX_INPUT_LENGTH];
struct follow_type *f, *next_fol;
struct char_data *tch;
one_argument(argument, buf);
if (!*buf) {
if (ch->master || !(AFF_FLAGGED(ch, AFF_GROUP))) {
send_to_char(ch, "But you lead no group!\r\n");
if (is_abbrev(buf, "new")) {
if (GROUP(ch))
send_to_char(ch, "You are already in a group.\r\n");
else
create_group(ch);
} else if (is_abbrev(buf, "list"))
display_group_list(ch);
else if (is_abbrev(buf, "join")) {
skip_spaces(&argument);
if (!(vict = get_char_vis(ch, argument, NULL, FIND_CHAR_ROOM))) {
send_to_char(ch, "Join who?\r\n");
return;
} else if (vict == ch) {
send_to_char(ch, "That would be one lonely grouping.\r\n");
return;
} else if (GROUP(ch)) {
send_to_char(ch, "But you are already part of a group.\r\n");
return;
} else if (!GROUP(vict)) {
send_to_char(ch, "They are not a part of a group!\r\n");
return;
} else if (!IS_SET(GROUP_FLAGS(GROUP(vict)), GROUP_OPEN)) {
send_to_char(ch, "That group isn't accepting members.\r\n");
return;
}
join_group(ch, GROUP(vict));
} else if (is_abbrev(buf, "kick")) {
skip_spaces(&argument);
if (!(vict = get_char_vis(ch, argument, NULL, FIND_CHAR_ROOM))) {
send_to_char(ch, "Kick out who?\r\n");
return;
} else if (vict == ch) {
send_to_char(ch, "There are easier ways to leave the group.\r\n");
return;
} else if (!GROUP(ch) ) {
send_to_char(ch, "But you are not part of a group.\r\n");
return;
} else if (GROUP_LEADER(GROUP(ch)) != ch ) {
send_to_char(ch, "Only the group's leader can kick members out.\r\n");
return;
} else if (GROUP(vict) != GROUP(ch)) {
send_to_char(ch, "They are not a member of your group!\r\n");
return;
}
send_to_char(ch, "You have kicked %s out of the group.\r\n", GET_NAME(vict));
send_to_char(vict, "You have been kicked out of the group.\r\n");
leave_group(vict);
} else if (is_abbrev(buf, "leave")) {
if (!GROUP(ch)) {
send_to_char(ch, "But you aren't apart of a group!\r\n");
return;
}
for (f = ch->followers; f; f = next_fol) {
next_fol = f->next;
if (AFF_FLAGGED(f->follower, AFF_GROUP)) {
REMOVE_BIT_AR(AFF_FLAGS(f->follower), AFF_GROUP);
act("$N has disbanded the group.", TRUE, f->follower, NULL, ch, TO_CHAR);
if (!AFF_FLAGGED(f->follower, AFF_CHARM))
stop_follower(f->follower);
}
leave_group(ch);
} else if (is_abbrev(buf, "option")) {
skip_spaces(&argument);
if (!GROUP(ch)) {
send_to_char(ch, "But you aren't part of a group!\r\n");
return;
} else if (GROUP_LEADER(GROUP(ch)) != ch) {
send_to_char(ch, "Only the group leader can adjust the group flags.\r\n");
return;
}
REMOVE_BIT_AR(AFF_FLAGS(ch), AFF_GROUP);
send_to_char(ch, "You disband the group.\r\n");
return;
}
if (!(tch = get_char_vis(ch, buf, NULL, FIND_CHAR_ROOM))) {
send_to_char(ch, "There is no such person!\r\n");
return;
}
if (tch->master != ch) {
send_to_char(ch, "That person is not following you!\r\n");
return;
if (is_abbrev(argument, "open")) {
TOGGLE_BIT(GROUP_FLAGS(GROUP(ch)), GROUP_OPEN);
send_to_char(ch, "The group is now %s to new members.\r\n", IS_SET(GROUP_FLAGS(GROUP(ch)), GROUP_OPEN) ? "open" : "closed");
} else if (is_abbrev(argument, "anonymous")) {
TOGGLE_BIT(GROUP_FLAGS(GROUP(ch)), GROUP_ANON);
send_to_char(ch, "The group location is now %s to other players.\r\n", IS_SET(GROUP_FLAGS(GROUP(ch)), GROUP_ANON) ? "invisible" : "visible");
} else
send_to_char(ch, "The flag options are: Open, Anonymous\r\n");
} else {
send_to_char(ch, "You must specify a group option, or type HELP GROUP for more info.\r\n");
}
if (!AFF_FLAGGED(tch, AFF_GROUP)) {
send_to_char(ch, "That person isn't in your group.\r\n");
return;
}
REMOVE_BIT_AR(AFF_FLAGS(tch), AFF_GROUP);
act("$N is no longer a member of your group.", FALSE, ch, 0, tch, TO_CHAR);
act("You have been kicked out of $n's group!", FALSE, ch, 0, tch, TO_VICT);
act("$N has been kicked out of $n's group!", FALSE, ch, 0, tch, TO_NOTVICT);
if (!AFF_FLAGGED(tch, AFF_CHARM))
stop_follower(tch);
}
ACMD(do_report)
{
char buf[MAX_STRING_LENGTH];
struct char_data *k;
struct follow_type *f;
struct group_data *group;
if (!AFF_FLAGGED(ch, AFF_GROUP)) {
if ((group = GROUP(ch)) == NULL) {
send_to_char(ch, "But you are not a member of any group!\r\n");
return;
}
snprintf(buf, sizeof(buf), "$n reports: %d/%dH, %d/%dM, %d/%dV\r\n",
send_to_group(NULL, group, "%s reports: %d/%dH, %d/%dM, %d/%dV\r\n",
GET_NAME(ch),
GET_HIT(ch), GET_MAX_HIT(ch),
GET_MANA(ch), GET_MAX_MANA(ch),
GET_MOVE(ch), GET_MAX_MOVE(ch));
k = (ch->master ? ch->master : ch);
for (f = k->followers; f; f = f->next)
if (AFF_FLAGGED(f->follower, AFF_GROUP) && f->follower != ch)
act(buf, TRUE, ch, NULL, f->follower, TO_VICT);
if (k != ch)
act(buf, TRUE, ch, NULL, k, TO_VICT);
send_to_char(ch, "You report to the group.\r\n");
}
ACMD(do_split)
{
char buf[MAX_INPUT_LENGTH];
int amount, num, share, rest;
int amount, num = 0, share, rest;
size_t len;
struct char_data *k;
struct follow_type *f;
if (IS_NPC(ch))
return;
@@ -513,20 +499,13 @@ ACMD(do_split)
send_to_char(ch, "You don't seem to have that much gold to split.\r\n");
return;
}
k = (ch->master ? ch->master : ch);
if (GROUP(ch))
while ((k = (struct char_data *) simple_list(GROUP(ch)->members)) != NULL)
if (IN_ROOM(ch) == IN_ROOM(k) && !IS_NPC(k))
num++;
if (AFF_FLAGGED(k, AFF_GROUP) && (IN_ROOM(k) == IN_ROOM(ch)))
num = 1;
else
num = 0;
for (f = k->followers; f; f = f->next)
if (AFF_FLAGGED(f->follower, AFF_GROUP) &&
(!IS_NPC(f->follower)) &&
(IN_ROOM(f->follower) == IN_ROOM(ch)))
num++;
if (num && AFF_FLAGGED(ch, AFF_GROUP)) {
if (num && GROUP(ch)) {
share = amount / num;
rest = amount % num;
} else {
@@ -544,22 +523,13 @@ ACMD(do_split)
"%d coin%s %s not splitable, so %s keeps the money.\r\n", rest,
(rest == 1) ? "" : "s", (rest == 1) ? "was" : "were", GET_NAME(ch));
}
if (AFF_FLAGGED(k, AFF_GROUP) && IN_ROOM(k) == IN_ROOM(ch) &&
!IS_NPC(k) && k != ch) {
increase_gold(k, share);
send_to_char(k, "%s", buf);
}
for (f = k->followers; f; f = f->next) {
if (AFF_FLAGGED(f->follower, AFF_GROUP) &&
(!IS_NPC(f->follower)) &&
(IN_ROOM(f->follower) == IN_ROOM(ch)) &&
f->follower != ch) {
while ((k = (struct char_data *) simple_list(GROUP(ch)->members)) != NULL)
if (k != ch && IN_ROOM(ch) == IN_ROOM(k) && !IS_NPC(k)) {
increase_gold(k, share);
send_to_char(k, "%s", buf);
}
increase_gold(f->follower, share);
send_to_char(f->follower, "%s", buf);
}
}
send_to_char(ch, "You split %d coins among %d members -- %d coins each.\r\n",
amount, num, share);