The head of the group can add their charmie/follower to the group, however if another player is in the group their charmie cannot be added since the charmie is following the player and not the head of the group.
Is there a way to remedy this to prevent xp loss and allow groups to use group heal etc on other charmies and everyone can be in the same group?
Code:
int perform_group(struct char_data *ch, struct char_data *vict)
{
if ((IS_NPC(ch)) && (AFF_FLAGGED(ch, AFF_CHARM))) {
act("$n looks puzzled.", FALSE, ch, 0, 0, TO_ROOM);
return (0);
}
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);
}
void print_group(struct char_data *ch)
{
struct char_data *k;
struct follow_type *f;
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");
k = (ch->master ? ch->master : ch);
if (AFF_FLAGGED(k, AFF_GROUP)) {
snprintf(buf, sizeof(buf), " @w[@r%3d@w/@R%3dH @g%3d@w/@G%3dM @y%3d@w/@Y%3dV@w] [%2d %s] $N (Head of group)@n",
GET_HIT(k), GET_MAX_HIT(k), GET_MANA(k), GET_MAX_MANA(k), GET_MOVE(k), GET_MAX_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), " @w[@r%3d@w/@R%3dH @g%3d@w/@G%3dM @y%3d@w/@Y%3dV@w] [%2d %s] $N@n",
GET_HIT(f->follower), GET_MAX_HIT(f->follower), GET_MANA(f->follower), GET_MAX_MANA(f->follower),
GET_MOVE(f->follower), GET_MAX_MOVE(f->follower), GET_LEVEL(f->follower), CLASS_ABBR(f->follower));
act(buf, FALSE, ch, 0, f->follower, TO_CHAR);
}
}
}
ACMD(do_group)
{
char buf[MAX_STRING_LENGTH];
struct char_data *vict;
struct follow_type *f;
int found;
one_argument(argument, buf);
if (!*buf) {
print_group(ch);
return;
}
if (ch->master) {
act("You can not 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_room_vis(ch, buf)))
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");
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);
}
}
REMOVE_BIT_AR(AFF_FLAGS(ch), AFF_GROUP);
send_to_char(ch, "You disband the group.\r\n");
return;
}
if (!(tch = get_char_room_vis(ch, buf))) {
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 (!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);
}