Exemplo n.º 1
0
Arquivo: clan.c Projeto: verias/SRMud
/* clan channels */
void do_clantalk( CHAR_DATA *ch, char *argument )
{
    char buf[MAX_STRING_LENGTH];
    DESCRIPTOR_DATA *d;

    if (!is_clan(ch))
    {
	send_to_char("You aren't in a clan.\n\r",ch);
	return;
    }
    if ( argument[0] == '\0' )
    {
      if (IS_SET(ch->comm,COMM_NOCLAN))
      {
        send_to_char("Clan channel is now ON\n\r",ch);
        REMOVE_BIT(ch->comm,COMM_NOCLAN);
      }
      else
      {
        send_to_char("Clan channel is now OFF\n\r",ch);
        SET_BIT(ch->comm,COMM_NOCLAN);
      }
      return;
    }

        if (IS_SET(ch->comm,COMM_NOCHANNELS))
        {
         send_to_char("The gods have revoked your channel priviliges.\n\r",ch);
          return;
        }

        REMOVE_BIT(ch->comm,COMM_NOCLAN);
	  if(!IS_NPC(ch) && ch->pcdata->condition[COND_DRUNK] > 10)
		  argument = makedrunk(argument,ch);

      sprintf( buf, "You clan '%s'{x\n\r", argument );
      send_to_char( buf, ch );
      sprintf( buf, "$n clans '%s'{x", argument );
    for ( d = descriptor_list; d != NULL; d = d->next )
    {
        if ( d->connected == CON_PLAYING &&
			is_same_clan(ch,d->character) &&
	     is_same_clan(ch,d->character) &&
         !IS_SET(d->character->comm,COMM_NOCLAN) &&
	     !IS_SET(d->character->comm,COMM_QUIET) )
        {
            act_new("$n clans '$t'{x",ch,argument,d->character,TO_VICT,POS_DEAD);
        }
		if(IS_SET(d->character->comm,COMM_ALLCLAN) &&
			d->connected == CON_PLAYING &&
             d->character != ch
			 && !is_same_clan(d->character, ch))
		{
			send_to_one(d->character,"[ %s ] %s clans '%s'{x",clan_table[ch->clan].name,ch->name,
				argument);
		}
    }

    return;
}
Exemplo n.º 2
0
void do_wake (CHAR_DATA * ch, char *argument)
{
    char arg[MAX_INPUT_LENGTH];
    CHAR_DATA *victim;

    one_argument (argument, arg);
    if (arg[0] == '\0')
    {
        do_function (ch, &do_stand, "");
        return;
    }

    if (!IS_AWAKE (ch))
    {
        send_to_char ("You are asleep yourself!\n\r", ch);
        return;
    }

    if ((victim = get_char_room (ch, arg)) == NULL)
    {
        send_to_char ("They aren't here.\n\r", ch);
        return;
    }

    if (IS_AWAKE (victim))
    {
        act ("$N is already awake.", ch, NULL, victim, TO_CHAR);
        return;
    }


    act_new ("$n wakes you.", ch, NULL, victim, TO_VICT, POS_SLEEPING);
    do_function (ch, &do_stand, "");
    return;
}
Exemplo n.º 3
0
Arquivo: send.c Projeto: verias/SRMud
void do_quote( CHAR_DATA *ch, char *argument )
{
    char buf[MAX_STRING_LENGTH];
    DESCRIPTOR_DATA *d;
 
    if (argument[0] == '\0' )
    {
      if (IS_SET(ch->comm,COMM_NOQUOTE))
      {
        send_to_char("{hQuote channel is now ON.{x\n\r",ch);
        REMOVE_BIT(ch->comm,COMM_NOQUOTE);
      }
      else
      {
        send_to_char("{hQuote channel is now OFF.{x\n\r",ch);
        SET_BIT(ch->comm,COMM_NOQUOTE);
      }
    }
    else  /* quote message sent, turn quote on if it isn't already */
    {
        if (IS_SET(ch->comm,COMM_QUIET))
        {
          send_to_char("You must turn off quiet mode first.\n\r",ch);
          return;
        }
 
        if (IS_SET(ch->comm,COMM_NOCHANNELS))
        {
          send_to_char("The gods have revoked your channel priviliges.\n\r",ch);
          return;
 
        }
 
      REMOVE_BIT(ch->comm,COMM_NOQUOTE);
 
	  if(!IS_NPC(ch) && ch->pcdata->condition[COND_DRUNK] > 10)
		  argument = makedrunk(argument,ch);

      sprintf( buf, "{hYou quote '{H%s{h'{x\n\r", argument );
      send_to_char( buf, ch );
      for ( d = descriptor_list; d != NULL; d = d->next )
      {
        CHAR_DATA *victim;
 
        victim = d->original ? d->original : d->character;
 
        if ( d->connected == CON_PLAYING &&
             d->character != ch &&
             !IS_SET(victim->comm,COMM_NOQUOTE) &&
             !IS_SET(victim->comm,COMM_QUIET) )
        {
          act_new( "{h$n quotes '{H$t{h'{x",
                   ch,argument, d->character, TO_VICT,POS_SLEEPING );
        }
      }
    }
}
Exemplo n.º 4
0
Arquivo: send.c Projeto: verias/SRMud
void do_immtalk( CHAR_DATA *ch, char *argument )
{
    char buf[MAX_STRING_LENGTH];
    DESCRIPTOR_DATA *d;

    if ( argument[0] == '\0' )
    {
      if (IS_SET(ch->comm,COMM_NOWIZ))
      {
	send_to_char("Immortal channel is now ON\n\r",ch);
	REMOVE_BIT(ch->comm,COMM_NOWIZ);
      }
      else
      {
	send_to_char("Immortal channel is now OFF\n\r",ch);
	SET_BIT(ch->comm,COMM_NOWIZ);
      } 
      return;
    }

    REMOVE_BIT(ch->comm,COMM_NOWIZ);

    sprintf( buf, "{i[{I$n{i]: %s{x\n\r", argument );
    act_new("{i[{I$n{i]: $t{x\n\r",ch,argument,NULL,TO_CHAR,POS_DEAD);
    for ( d = descriptor_list; d != NULL; d = d->next )
    {
	if ( d->connected == CON_PLAYING && 
	        (is_granted_name(d->character,"immtalk") ||
            is_granted_name(d->character,":")) &&
             !IS_SET(d->character->comm,COMM_NOWIZ) )
	{
	    act_new("{i[{I$n{i]: $t{x\n\r",ch,argument,d->character,TO_VICT,POS_DEAD);
	}
    }

    return;
}
Exemplo n.º 5
0
Arquivo: marry.c Projeto: Firehed/RotK
void do_spousetalk( CHAR_DATA *ch, char *argument )
{
    char buf[MAX_STRING_LENGTH];
    DESCRIPTOR_DATA *d;
 
    if (argument[0] == '\0' )
    {
     send_to_char("What do you wish to tell your other half?\n\r", ch);
     return;
    }
    else  /* message sent */
    {
       
      sprintf( buf, "You say to %s, '%s'\n\r", ch->spouse, argument );
      send_to_char( buf, ch );
      for ( d = descriptor_list; d != NULL; d = d->next )
      {
        CHAR_DATA *victim;
 
        victim = d->original ? d->original : d->character;
 
        if ( d->connected == CON_PLAYING &&
             d->character != ch &&
             d->character->name == ch->spouse)
        {
          act_new( "$n says to you, '$t'", 
		   ch, argument, d->character, TO_VICT, POS_SLEEPING );
        }
        else
        {
         send_to_char("Your spouse is not here.\n\r", ch);
         return;
        }
      }
    }
}
void get_obj(struct char_data *ch, struct gameobject *obj, struct gameobject *container)
{
    struct char_data *gch;
    int members;
    char buffer[100];

    if (!CAN_WEAR(obj, ITEM_TAKE)) {
	send_to_char("You can't take that.\n\r", ch);
	return;
    }

    if ((ch->carry_number + get_obj_number(obj)) > can_carry_n(ch)
	    && (!IS_IMMORTAL(ch))) {
	act("$d: you can't carry that many items.",
		ch, NULL, object_name_get(obj), TO_CHAR);
	return;
    }


    if ((ch->carry_weight + get_obj_weight(obj)) > can_carry_w(ch)) {
	act("$d: you can't carry that much weight.", ch, NULL, object_name_get(obj), TO_CHAR);
	return;
    }

    if (obj->in_room != NULL) {
	for (gch = obj->in_room->people; gch != NULL; gch = gch->next_in_room) {
	    if (gch->on == obj) {
		act("$N appears to be using $p.", ch, obj, gch, TO_CHAR);
		return;
	    }
	}
    }


    if (container != NULL) {
	if (container->objprototype->vnum == OBJ_VNUM_PIT
		&& get_trust(ch) < obj->level) {
	    send_to_char("You are not powerful enough to use it.\n\r", ch);
	    return;
	}

	if (container->objprototype->vnum == OBJ_VNUM_PIT
		&& !CAN_WEAR(container, ITEM_TAKE)
		&& !IS_OBJ_STAT(obj, ITEM_HAD_TIMER))
	    obj->timer = 0;
	act_new("You get $p from $P.", ch, obj, container, TO_CHAR, POS_RESTING, true);
	act_new("$n gets $p from $P.", ch, obj, container, TO_ROOM, POS_RESTING, true);
	REMOVE_BIT(obj->extra_flags, ITEM_HAD_TIMER);
	obj_from_obj(obj);
    } else {
	act_new("You get $p.", ch, obj, container, TO_CHAR, POS_RESTING, true);
	act_new("$n gets $p.", ch, obj, container, TO_ROOM, POS_RESTING, true);
	obj_from_room(obj);
    }

    if (obj->item_type == ITEM_MONEY) {
	ch->silver += obj->value[0];
	ch->gold += obj->value[1];

	if (IS_SET(ch->act, PLR_AUTOSPLIT)) {
	    members = 0;
	    for (gch = ch->in_room->people; gch != NULL; gch = gch->next_in_room)
		if (!IS_AFFECTED(gch, AFF_CHARM) && is_same_group(gch, ch))
		    members++;

	    if (members > 1 && (obj->value[0] > 1 || obj->value[1])) {
		sprintf(buffer, "%ld %ld", obj->value[0], obj->value[1]);
		do_split(ch, buffer);
	    }
	}

	extract_obj(obj);
    } else {
	obj_to_char(obj, ch);
    }

    return;
}
void stand(struct char_data *ch, struct gameobject *on)
{
    // TODO - need to extract can_get_obj from get_obj

    // Impassible positions.
    switch (ch->position) {
	case POS_STANDING:
	    if (on == NULL || on == ch->on) {
		send_to_char("You are already standing.\n\r", ch);
		return;
	    }
	    break;

	case POS_FIGHTING:
	    send_to_char("Maybe you should finish this fight first?\n\r", ch);
	    return;

	case POS_SLEEPING:
	    if (IS_AFFECTED(ch, AFF_SLEEP)) {
		send_to_char("You can't wake up!\n\r", ch);
		return;
	    }
	    break;
    }

    // Validate target object, if any.
    if (on != NULL) {
	if (!is_standupon(on)) {
	    send_to_char("You can't seem to find a place to stand.\n\r", ch);
	    return;
	}

	if (ch->on != on && (long)count_users(on) >= on->value[0]) {
	    act_new("There's no room to stand on $p.", ch, on, NULL, TO_ROOM, POS_DEAD, false);
	    return;
	}

	// TODO check if object is gettable
    }


    // stand up, possibly on something.
    ch->position = POS_STANDING;
    if (on != ch->on) {
	struct gameobject *old_on = ch->on;
	ch->on = on;
	if (old_on != NULL && can_see_obj(ch, old_on)) {
	    // TODO - only if object is gettable.
	    get_obj(ch, old_on, NULL);
	}
    }

    // Notify.

    switch (ch->position) {
	default:
	    if (on == NULL) {
		send_to_char("You stand up.\n\r", ch);
		act("$n stands up.", ch, NULL, NULL, TO_ROOM);
	    } else if (IS_SET(on->value[2], STAND_AT)) {
		act("You stand at $p.", ch, on, NULL, TO_CHAR);
		act("$n stands at $p.", ch, on, NULL, TO_ROOM);
	    } else if (IS_SET(on->value[2], STAND_ON)) {
		act("You stand on $p.", ch, on, NULL, TO_CHAR);
		act("$n stands on $p.", ch, on, NULL, TO_ROOM);
	    } else {
		act("You stand in $p.", ch, on, NULL, TO_CHAR);
		act("$n stands on $p.", ch, on, NULL, TO_ROOM);
	    }
	    break;
	case POS_SLEEPING:
	    if (on == NULL) {
		send_to_char("You wake and stand up.\n\r", ch);
		act("$n wakes and stands up.", ch, NULL, NULL, TO_ROOM);
	    } else if (IS_SET(on->value[2], STAND_AT)) {
		act_new("You wake and stand at $p.", ch, on, NULL, TO_CHAR, POS_DEAD, false);
		act("$n wakes and stands at $p.", ch, on, NULL, TO_ROOM);
	    } else if (IS_SET(on->value[2], STAND_ON)) {
		act_new("You wake and stand on $p.", ch, on, NULL, TO_CHAR, POS_DEAD, false);
		act("$n wakes and stands on $p.", ch, on, NULL, TO_ROOM);
	    } else {
		act_new("You wake and stand in $p.", ch, on, NULL, TO_CHAR, POS_DEAD, false);
		act("$n wakes and stands in $p.", ch, on, NULL, TO_ROOM);
	    }
	    look_room(ch, ch->in_room);
	    break;
    }
}
void sit(struct char_data *ch, struct gameobject *on)
{
    // TODO - it is currently possible to defeat object pickup restrictions by
    // sitting on them. Need to extract can_get_obj from get_obj and use it!

    // Impassible positions.
    switch (ch->position) {
	case POS_SITTING:
	    if (on == NULL || on == ch->on) {
		send_to_char("You are already sitting down.\n\r", ch);
		return;
	    }
	    break;

	case POS_FIGHTING:
	    send_to_char("Maybe you should finish this fight first?\n\r", ch);
	    return;

	case POS_SLEEPING:
	    if (IS_AFFECTED(ch, AFF_SLEEP)) {
		send_to_char("You can't wake up!\n\r", ch);
		return;
	    }
	    break;
    }

    // Validate target object, if any.
    if (on != NULL) {
	if (!is_situpon(on)) {
	    send_to_char("You can't sit on that.\n\r", ch);
	    return;
	}

	if (ch->position == POS_SLEEPING && on != ch->on) {
	    send_to_char("You'll need to wake up to find it.\n\r", ch);
	    return;
	}

	if (on->carried_by != NULL && on->carried_by != ch) {
	    act_new("The $p is being held by someone!", ch, on, NULL, TO_CHAR, POS_DEAD, false);
	    return;
	}

	if (on->in_obj != NULL) {
	    if (on->in_obj->in_room != ch->in_room) {
		send_to_char("What? Where?\n\r", ch);
		return;
	    }
	}

	if (ch->on != on && (long)count_users(on) >= on->value[0]) {
	    act_new("There's no more room on $p.", ch, on, NULL, TO_CHAR, POS_DEAD, false);
	    return;
	}
    }

    // Sit down, possibly on and object.
    ch->position = POS_SITTING;
    if (on != NULL) {
	ch->on = on;

	if (on->carried_by == ch) {
	    obj_from_char(on);
	    obj_to_room(on, ch->in_room);
	} else if (on->in_obj != NULL) {
	    obj_from_obj(on);
	    obj_to_room(on, ch->in_room);
	}
    }

    // Notify
    switch (ch->position) {
	default:
	    if (on == NULL) {
		send_to_char("You sit down.\n\r", ch);
		act("$n sits down on the ground.", ch, NULL, NULL, TO_ROOM);
	    } else if (IS_SET(on->value[2], SIT_AT)) {
		act("You sit down at $p.", ch, on, NULL, TO_CHAR);
		act("$n sits down at $p.", ch, on, NULL, TO_ROOM);
	    } else if (IS_SET(on->value[2], SIT_ON)) {
		act("You sit on $p.", ch, on, NULL, TO_CHAR);
		act("$n sits on $p.", ch, on, NULL, TO_ROOM);
	    } else {
		act("You sit down in $p.", ch, on, NULL, TO_CHAR);
		act("$n sits down in $p.", ch, on, NULL, TO_ROOM);
	    }
	    break;
	case POS_SLEEPING:
	    if (on == NULL) {
		send_to_char("You wake and sit up.\n\r", ch);
		act("$n wakes and sits up.", ch, NULL, NULL, TO_ROOM);
	    } else if (IS_SET(on->value[2], SIT_AT)) {
		act_new("You wake and sit at $p.", ch, on, NULL, TO_CHAR, POS_DEAD, false);
		act("$n wakes and sits at $p.", ch, on, NULL, TO_ROOM);
	    } else if (IS_SET(on->value[2], SIT_ON)) {
		act_new("You wake and sit on $p.", ch, on, NULL, TO_CHAR, POS_DEAD, false);
		act("$n wakes and sits at $p.", ch, on, NULL, TO_ROOM);
	    } else {
		act_new("You wake and sit in $p.", ch, on, NULL, TO_CHAR, POS_DEAD, false);
		act("$n wakes and sits in $p.", ch, on, NULL, TO_ROOM);
	    }
	    break;
	case POS_RESTING:
	    if (on == NULL) {
		send_to_char("You stop resting.\n\r", ch);
	    } else if (IS_SET(on->value[2], SIT_AT)) {
		act("You sit at $p.", ch, on, NULL, TO_CHAR);
		act("$n sits at $p.", ch, on, NULL, TO_ROOM);
	    } else if (IS_SET(on->value[2], SIT_ON)) {
		act("You sit on $p.", ch, on, NULL, TO_CHAR);
		act("$n sits on $p.", ch, on, NULL, TO_ROOM);
	    }
	    break;
    }
}
Exemplo n.º 9
0
void do_stand (CHAR_DATA * ch, char *argument)
{
    OBJ_DATA *obj = NULL;

    if (argument[0] != '\0')
    {
        if(ch->infight)
        {
            send_to_char ("Maybe you should finish fighting first?\n\r", ch);
            return;
        }
        obj = get_obj_list (ch, argument, ch->in_room->contents);
        if (obj == NULL)
        {
            send_to_char ("You don't see that here.\n\r", ch);
            return;
        }
        if (obj->item_type != ITEM_FURNITURE
            || (!IS_SET (obj->value[2], STAND_AT)
                && !IS_SET (obj->value[2], STAND_ON)
                && !IS_SET (obj->value[2], STAND_IN)))
        {
            send_to_char ("You can't seem to find a place to stand.\n\r", ch);
            return;
        }
        if (ch->on != obj && count_users (obj) >= obj->value[0])
        {
            act_new ("There's no room to stand on $p.",
                     ch, obj, NULL, TO_CHAR, POS_DEAD);
            return;
        }
        ch->on = obj;
    }

    switch (ch->position)
    {
        case POS_SLEEPING:

            if (obj == NULL)
            {
                send_to_char ("You wake and stand up.\n\r", ch);
                act ("$n wakes and stands up.", ch, NULL, NULL, TO_ROOM);
                ch->on = NULL;
            }
            else if (IS_SET (obj->value[2], STAND_AT))
            {
                act_new ("You wake and stand at $p.", ch, obj, NULL, TO_CHAR,
                         POS_DEAD);
                act ("$n wakes and stands at $p.", ch, obj, NULL, TO_ROOM);
            }
            else if (IS_SET (obj->value[2], STAND_ON))
            {
                act_new ("You wake and stand on $p.", ch, obj, NULL, TO_CHAR,
                         POS_DEAD);
                act ("$n wakes and stands on $p.", ch, obj, NULL, TO_ROOM);
            }
            else
            {
                act_new ("You wake and stand in $p.", ch, obj, NULL, TO_CHAR,
                         POS_DEAD);
                act ("$n wakes and stands in $p.", ch, obj, NULL, TO_ROOM);
            }
            ch->position = POS_STANDING;
            do_function (ch, &do_look, "auto");
            break;

        case POS_RESTING:
        case POS_SITTING:
            if (obj == NULL)
            {
                send_to_char ("You stand up.\n\r", ch);
                act ("$n stands up.", ch, NULL, NULL, TO_ROOM);
                ch->on = NULL;
            }
            else if (IS_SET (obj->value[2], STAND_AT))
            {
                act ("You stand at $p.", ch, obj, NULL, TO_CHAR);
                act ("$n stands at $p.", ch, obj, NULL, TO_ROOM);
            }
            else if (IS_SET (obj->value[2], STAND_ON))
            {
                act ("You stand on $p.", ch, obj, NULL, TO_CHAR);
                act ("$n stands on $p.", ch, obj, NULL, TO_ROOM);
            }
            else
            {
                act ("You stand in $p.", ch, obj, NULL, TO_CHAR);
                act ("$n stands on $p.", ch, obj, NULL, TO_ROOM);
            }
            ch->position = POS_STANDING;
            break;

        case POS_STANDING:
            send_to_char ("You are already standing.\n\r", ch);
            break;

        case POS_FIGHTING:
            send_to_char ("You are already fighting!\n\r", ch);
            break;
    }

    return;
}
Exemplo n.º 10
0
Arquivo: org.c Projeto: verias/SRMud
void do_rescind(CHAR_DATA *ch, char *argument )
{	CHAR_DATA *victim;

	char arg[MSL];

	if(IS_NPC(ch) )
		return;
	if(!HAS_ORGANIZATION(ch) )
	{	send_to_char("You aren't organized.\n\r",ch);
		return;
	}
	if( ch->pcdata->rank < RANK_PRIEST )
	{	send_to_char("You cannot rescind peoples ranks!\n\r",ch );
		return;
	}
	one_argument(argument, arg );

	if(arg[0] == '\0' )
	{	send_to_char("Syntax: rescind <person>\n\r",ch);
		return;
	}
	if(!IS_IMMORTAL(ch) )
	{	if( ( victim = get_char_room(ch, NULL, arg) )  == NULL )
		{	send_to_char("They aren't here.\n\r",ch);
			return;
		}
	}
	else
	{	if( ( victim = get_char_world(ch, arg) ) == NULL )
		{	send_to_char("They aren't here.\n\r",ch);
			return;
		}
		
	}
	if(IS_NPC(victim) )
	{	send_to_char("Not on NPC's.\n\r",ch);
		return;
	}
	if(!HAS_ORGANIZATION(victim) )
	{	send_to_char("They aren't organized.\n\r",ch);
		return;
	}
	if(!IS_SAME_ORGANIZATION(ch, victim) && ch->pcdata->rank != RANK_GOD  )
	{	send_to_char("They aren't in your organization!\n\r",ch); 
		return; 
	}

	if( ch->pcdata->rank <= victim->pcdata->rank )
	{	send_to_char("You cannot rescind their rank!\n\r", ch );
		return;
	}

	if(!IS_IMMORTAL(ch) && ch->pcdata->rank <= RANK_PRIEST && victim->pcdata->rank >= RANK_BISHOP )
	{	send_to_char("You cannot rescind their rank.\n\r",ch);
		return;
	}

	if(victim->pcdata->rank == RANK_INITIATE )
	{	send_to_char("They cannot get any lower!\n\r",ch);
		return;
	}
	--victim->pcdata->rank;
	act_new(victim->pcdata->organization->dmt_msg,ch, NULL, victim, TO_VICT, POS_SLEEPING );
	printf_to_char(ch, "You have lowered their rank to %s.\n\r", orgrank_table[victim->pcdata->rank].name );
	return;
}
Exemplo n.º 11
0
void broadcast_channel(struct char_data *sender, const CHANNEL_DEFINITION const *channel, struct char_data *target, const char *argument)
{
    if (sender != NULL) {
	if (CHAN_DENIED(sender, channel->flag)) {
	    send_to_char("You may not use that channel.", sender);
	    return;
	}

	ENABLE_CHAN(sender, channel->flag);
    }

    if (channel->broadcaster == NULL) {
	if (sender != NULL) {
	    send_to_char("Bug logged.", sender);
	}
	log_bug("No broadcaster for channel %s (%ul).", channel->name, channel->flag);
	return;
    }

    switch (channel->target_requirement)
    {
	case CHANNEL_TARGET_NONE:
	    {
		if (target != NULL) {
		    log_bug("Ignored target provided for channel %s (%ul).", channel->name, channel->flag);
		}
		channel->broadcaster(channel, sender, argument);
		return;
	    }
	case CHANNEL_TARGET_OPTIONAL:
	    {
		if (target == NULL) {
		    channel->broadcaster(channel, sender, argument);
		} else {
		    channel->targeted_broadcaster(channel, sender, target, argument);
		}
		return;
	    }
	case CHANNEL_TARGET_REQUIRED:
	    {
		if (target == NULL) {
		    if (sender != NULL) {
			send_to_char("Bug logged.", sender);
		    }
		    log_bug("Target is required and not provided for channel %s (%ul).", channel->name, channel->flag);
		    return;
		}

		if (is_ignoring(sender, target)) {
		    act_new("$N seems to be ignoring you.", sender, NULL, target, TO_CHAR, POS_DEAD, false);
		    return;
		}

		if (!(IS_IMMORTAL(sender) && sender->level > LEVEL_IMMORTAL) && !IS_AWAKE(target)) {
		    act_new("$E can't hear you.", sender, 0, target, TO_CHAR, POS_DEAD, false);
		    return;
		}

		channel->targeted_broadcaster(channel, sender, target, argument);
		return;
	    }
    }
}
Exemplo n.º 12
0
void do_sit (CHAR_DATA * ch, char *argument)
{
    OBJ_DATA *obj = NULL;

           if(ch->infight)
    {
        send_to_char ("Maybe you should finish this fight first?\n\r", ch);
        return;
    }

    /* okay, now that we know we can sit, find an object to sit on */
    if (argument[0] != '\0')
    {
        obj = get_obj_list (ch, argument, ch->in_room->contents);
        if (obj == NULL)
        {
            send_to_char ("You don't see that here.\n\r", ch);
            return;
        }
    }
    else
        obj = ch->on;

    if (obj != NULL)
    {
        if (obj->item_type != ITEM_FURNITURE
            || (!IS_SET (obj->value[2], SIT_ON)
                && !IS_SET (obj->value[2], SIT_IN)
                && !IS_SET (obj->value[2], SIT_AT)))
        {
            send_to_char ("You can't sit on that.\n\r", ch);
            return;
        }

        if (obj != NULL && ch->on != obj
            && count_users (obj) >= obj->value[0])
        {
            act_new ("There's no more room on $p.", ch, obj, NULL, TO_CHAR,
                     POS_DEAD);
            return;
        }

        ch->on = obj;
    }
    switch (ch->position)
    {
        case POS_SLEEPING:

            if (obj == NULL)
            {
                send_to_char ("You wake and sit up.\n\r", ch);
                act ("$n wakes and sits up.", ch, NULL, NULL, TO_ROOM);
            }
            else if (IS_SET (obj->value[2], SIT_AT))
            {
                act_new ("You wake and sit at $p.", ch, obj, NULL, TO_CHAR,
                         POS_DEAD);
                act ("$n wakes and sits at $p.", ch, obj, NULL, TO_ROOM);
            }
            else if (IS_SET (obj->value[2], SIT_ON))
            {
                act_new ("You wake and sit on $p.", ch, obj, NULL, TO_CHAR,
                         POS_DEAD);
                act ("$n wakes and sits at $p.", ch, obj, NULL, TO_ROOM);
            }
            else
            {
                act_new ("You wake and sit in $p.", ch, obj, NULL, TO_CHAR,
                         POS_DEAD);
                act ("$n wakes and sits in $p.", ch, obj, NULL, TO_ROOM);
            }

            ch->position = POS_SITTING;
            break;
        case POS_RESTING:
            if (obj == NULL)
                send_to_char ("You stop resting.\n\r", ch);
            else if (IS_SET (obj->value[2], SIT_AT))
            {
                act ("You sit at $p.", ch, obj, NULL, TO_CHAR);
                act ("$n sits at $p.", ch, obj, NULL, TO_ROOM);
            }

            else if (IS_SET (obj->value[2], SIT_ON))
            {
                act ("You sit on $p.", ch, obj, NULL, TO_CHAR);
                act ("$n sits on $p.", ch, obj, NULL, TO_ROOM);
            }
            ch->position = POS_SITTING;
            break;
        case POS_SITTING:
            send_to_char ("You are already sitting down.\n\r", ch);
            break;
        case POS_STANDING:
            if (obj == NULL)
            {
                send_to_char ("You sit down.\n\r", ch);
                act ("$n sits down on the ground.", ch, NULL, NULL, TO_ROOM);
            }
            else if (IS_SET (obj->value[2], SIT_AT))
            {
                act ("You sit down at $p.", ch, obj, NULL, TO_CHAR);
                act ("$n sits down at $p.", ch, obj, NULL, TO_ROOM);
            }
            else if (IS_SET (obj->value[2], SIT_ON))
            {
                act ("You sit on $p.", ch, obj, NULL, TO_CHAR);
                act ("$n sits on $p.", ch, obj, NULL, TO_ROOM);
            }
            else
            {
                act ("You sit down in $p.", ch, obj, NULL, TO_CHAR);
                act ("$n sits down in $p.", ch, obj, NULL, TO_ROOM);
            }
            ch->position = POS_SITTING;
            break;
    }
    return;
}
Exemplo n.º 13
0
Arquivo: send.c Projeto: verias/SRMud
void do_tell( CHAR_DATA *ch, char *argument )
{
    char arg[MAX_INPUT_LENGTH],buf[MAX_STRING_LENGTH];
    CHAR_DATA *victim;

    if ( IS_SET(ch->comm, COMM_NOTELL) || IS_SET(ch->comm,COMM_DEAF))
    {
	send_to_char( "Your message didn't get through.\n\r", ch );
	return;
    }

    if ( IS_SET(ch->comm, COMM_QUIET) )
    {
	send_to_char( "You must turn off quiet mode first.\n\r", ch);
	return;
    }

    if (IS_SET(ch->comm,COMM_DEAF))
    {
	send_to_char("You must turn off deaf mode first.\n\r",ch);
	return;
    }

    argument = one_argument( argument, arg );

    if ( arg[0] == '\0' || argument[0] == '\0' )
    {
	send_to_char( "Tell whom what?\n\r", ch );
	return;
    }

    /*
     * Can tell to PC's anywhere, but NPC's only in same room.
     * -- Furey
     */
    if ( ( victim = get_char_world( ch, arg ) ) == NULL
    || ( IS_NPC(victim) && victim->in_room != ch->in_room ) )
    {
	send_to_char( "They aren't here.\n\r", ch );
	return;
    }

    if ( victim->desc == NULL && !IS_NPC(victim))
    {
	act("$N seems to have misplaced $S link...try again later.",
	    ch,NULL,victim,TO_CHAR);
        sprintf(buf,"{k%s tells you '{K%s{k'{x\n\r",PERS(ch,victim),argument);
        buf[0] = UPPER(buf[0]);
        add_buf(victim->pcdata->buffer,buf);
	return;
    }

    if ( !(IS_IMMORTAL(ch) && ch->level > LEVEL_IMMORTAL) && !IS_AWAKE(victim) )
    {
	act( "$E can't hear you.", ch, 0, victim, TO_CHAR );
	return;
    }
  
    if ((IS_SET(victim->comm,COMM_QUIET) || IS_SET(victim->comm,COMM_DEAF))
    && !IS_IMMORTAL(ch))
    {
	act( "$E is not receiving tells.", ch, 0, victim, TO_CHAR );
  	return;
    }

    if (IS_SET(victim->comm,COMM_AFK))
    {
	if (IS_NPC(victim))
	{
	    act("$E is AFK, and not receiving tells.",ch,NULL,victim,TO_CHAR);
	    return;
	}

	act("$E is AFK, but your tell will go through when $E returns.",
	    ch,NULL,victim,TO_CHAR);
	sprintf(buf,"{k%s tells you '{K%s{k'{x\n\r",PERS(ch,victim),argument);
	buf[0] = UPPER(buf[0]);
	add_buf(victim->pcdata->buffer,buf);
	return;
    }

    act( "{kYou tell $N '{K$t{k'{x", ch, argument, victim, TO_CHAR );
    act_new("{k$n tells you '{K$t{k'{x",ch,argument,victim,TO_VICT,POS_DEAD);
    victim->reply	= ch;

	if (!IS_NPC(ch) && IS_NPC(victim)&& HAS_TRIGGER_MOB(victim,TRIG_SPEECH) )
		p_act_trigger( argument, victim, NULL, NULL, ch, NULL, NULL, TRIG_SPEECH);

    return;
}
Exemplo n.º 14
0
Arquivo: send.c Projeto: verias/SRMud
void do_reply( CHAR_DATA *ch, char *argument )
{
    CHAR_DATA *victim;
    char buf[MAX_STRING_LENGTH];

    if ( IS_SET(ch->comm, COMM_NOTELL) )
    {
	send_to_char( "Your message didn't get through.\n\r", ch );
	return;
    }

    if ( ( victim = ch->reply ) == NULL )
    {
	send_to_char( "They aren't here.\n\r", ch );
	return;
    }

    if ( victim->desc == NULL && !IS_NPC(victim))
    {
        act("$N seems to have misplaced $S link...try again later.",
            ch,NULL,victim,TO_CHAR);
        sprintf(buf,"{k%s tells you '{K%s{k'{x\n\r",PERS(ch,victim),argument);
        buf[0] = UPPER(buf[0]);
        add_buf(victim->pcdata->buffer,buf);
        return;
    }

    if ( !IS_IMMORTAL(ch) && !IS_AWAKE(victim) )
    {
	act( "$E can't hear you.", ch, 0, victim, TO_CHAR );
	return;
    }

    if ((IS_SET(victim->comm,COMM_QUIET) || IS_SET(victim->comm,COMM_DEAF))
    &&  !IS_IMMORTAL(ch) && !IS_IMMORTAL(victim))
    {
        act_new( "$E is not receiving tells.", ch, 0, victim, TO_CHAR,POS_DEAD);
        return;
    }

    if (!IS_IMMORTAL(victim) && !IS_AWAKE(ch))
    {
	send_to_char( "In your dreams, or what?\n\r", ch );
	return;
    }

    if (IS_SET(victim->comm,COMM_AFK))
    {
        if (IS_NPC(victim))
        {
            act_new("$E is AFK, and not receiving tells.",
		ch,NULL,victim,TO_CHAR,POS_DEAD);
            return;
        }
 
        act_new("$E is AFK, but your tell will go through when $E returns.",
            ch,NULL,victim,TO_CHAR,POS_DEAD);
        sprintf(buf,"{k%s tells you '{K%s{k'{x\n\r",PERS(ch,victim),argument);
	buf[0] = UPPER(buf[0]);
        add_buf(victim->pcdata->buffer,buf);
        return;
    }

    act_new("{kYou tell $N '{K$t{k'{x",ch,argument,victim,TO_CHAR,POS_DEAD);
    act_new("{k$n tells you '{K$t{k'{x",ch,argument,victim,TO_VICT,POS_DEAD);
    victim->reply	= ch;

    return;
}
Exemplo n.º 15
0
void song_update(void)
{
    OBJ_DATA *obj;
    CHAR_DATA *victim;
    ROOM_INDEX_DATA *room;
    DESCRIPTOR_DATA *d;
    char buf[MSL]={'\0'};
    char *line;
    int i;

    /* do the global song, if any */
    if (channel_songs[1] >= MAX_SONGS)
	channel_songs[1] = -1;

    if (channel_songs[1] > -1)
    {
        if (channel_songs[0] >= MAX_LINES
        ||  channel_songs[0] >= song_table[channel_songs[1]].lines)
        {
	    channel_songs[0] = -1;

            /* advance songs */
	    for (i = 1; i < MAX_GLOBAL; i++)
	    	channel_songs[i] = channel_songs[i+1];
	    channel_songs[MAX_GLOBAL] = -1;
	}
	else
	{
	    if (channel_songs[0] < 0)
	    {
	    	sprintf(buf,"Music: %s, %s",
		    song_table[channel_songs[1]].group,
		    song_table[channel_songs[1]].name);
	    	channel_songs[0] = 0;
	    }
	    else
	    {
		sprintf(buf,"Music: '%s'",
		    song_table[channel_songs[1]].lyrics[channel_songs[0]]);
		channel_songs[0]++;
	    }

	    for (d = descriptor_list; d != NULL; d = d->next)
	    {
		victim = d->original ? d->original : d->character;

        	if ( d->connected == CON_PLAYING &&
             	     !IS_SET(victim->comm,COMM_NOMUSIC) &&
             	     !IS_SET(victim->comm,COMM_QUIET) )
            	     act_new("$t",d->character,buf,NULL,TO_CHAR,POS_SLEEPING);
            }
	}
    }

    for (obj = object_list; obj != NULL; obj = obj->next)
    {
	if (obj->item_type != ITEM_JUKEBOX || obj->value[1] < 0)
	    continue;

 	if (obj->value[1] >= MAX_SONGS)
	{
	    obj->value[1] = -1;
	    continue;
	}

	/* find which room to play in */

	if ((room = obj->in_room) == NULL)
	{
	    if (obj->carried_by == NULL)
	    	continue;
	    else
	    	if ((room = obj->carried_by->in_room) == NULL)
		    continue;
	}

	if (obj->value[0] < 0)
	{
	    sprintf(buf,"$p starts playing %s, %s.",
		song_table[obj->value[1]].group,song_table[obj->value[1]].name);
	    if (room->people != NULL)
		act(buf,room->people,obj,NULL,TO_ALL);
	    obj->value[0] = 0;
	    continue;
	}
	else
	{
	    if (obj->value[0] >= MAX_LINES 
	    || obj->value[0] >= song_table[obj->value[1]].lines)
	    {

		obj->value[0] = -1;

		/* scroll songs forward */
		obj->value[1] = obj->value[2];
		obj->value[2] = obj->value[3];
		obj->value[3] = obj->value[4];
		obj->value[4] = -1;
		continue;
	    }

	    line = song_table[obj->value[1]].lyrics[obj->value[0]];
	    obj->value[0]++;
	}

	sprintf(buf,"$p bops: '%s'",line);
	if (room->people != NULL)
	    act(buf,room->people,obj,NULL,TO_ALL);
    }
}
Exemplo n.º 16
0
void song_update ( void )
{
	Item *obj;
	Creature *victim;
	RoomData *room;
	Socket *d;
	char buf[MAX_STRING_LENGTH];
	char *line;
	int i;

	/* do the global song, if any */
	if ( channel_songs[1] >= MAX_SONGS )
	{ channel_songs[1] = -1; }

	if ( channel_songs[1] > -1 ) {
		if ( channel_songs[0] >= MAX_LINES
				||  channel_songs[0] >= song_table[channel_songs[1]].lines ) {
			channel_songs[0] = -1;

			/* advance songs */
			for ( i = 1; i < MAX_GLOBAL; i++ )
			{ channel_songs[i] = channel_songs[i + 1]; }
			channel_songs[MAX_GLOBAL] = -1;
		} else {
			if ( channel_songs[0] < 0 ) {
				snprintf ( buf, sizeof ( buf ), "Music: %s, %s",
						   song_table[channel_songs[1]].group,
						   song_table[channel_songs[1]].name );
				channel_songs[0] = 0;
			} else {
				snprintf ( buf, sizeof ( buf ), "Music: '%s'",
						   song_table[channel_songs[1]].lyrics[channel_songs[0]] );
				channel_songs[0]++;
			}

			for ( d = socket_list; d != NULL; d = d->next ) {
				victim = d->original ? d->original : d->character;

				if ( d->connected == STATE_PLAYING &&
						!IS_SET ( victim->comm, COMM_NOMUSIC ) &&
						!IS_SET ( victim->comm, COMM_QUIET ) )
				{ act_new ( "$t", d->character, buf, NULL, TO_CHAR, POS_SLEEPING ); }
			}
		}
	}

	for ( obj = object_list; obj != NULL; obj = obj->next ) {
		if ( obj->item_type != ITEM_JUKEBOX || obj->value[1] < 0 )
		{ continue; }

		if ( obj->value[1] >= MAX_SONGS ) {
			obj->value[1] = -1;
			continue;
		}

		/* find which room to play in */

		if ( ( room = obj->in_room ) == NULL ) {
			if ( CARRIED_BY ( obj ) == NULL )
			{ continue; }
			else if ( ( room = CARRIED_BY ( obj )->in_room ) == NULL )
			{ continue; }
		}

		if ( obj->value[0] < 0 ) {
			snprintf ( buf, sizeof ( buf ), "$p starts playing %s, %s.",
					   song_table[obj->value[1]].group, song_table[obj->value[1]].name );
			if ( room->people != NULL )
			{ act ( buf, room->people, obj, NULL, TO_ALL ); }
			obj->value[0] = 0;
			continue;
		} else {
			if ( obj->value[0] >= MAX_LINES
					|| obj->value[0] >= song_table[obj->value[1]].lines ) {

				obj->value[0] = -1;

				/* scroll songs forward */
				obj->value[1] = obj->value[2];
				obj->value[2] = obj->value[3];
				obj->value[3] = obj->value[4];
				obj->value[4] = -1;
				continue;
			}

			line = song_table[obj->value[1]].lyrics[obj->value[0]];
			obj->value[0]++;
		}

		snprintf ( buf, sizeof ( buf ), "$p bops: '%s'", line );
		if ( room->people != NULL )
		{ act ( buf, room->people, obj, NULL, TO_ALL ); }
	}
}
Exemplo n.º 17
0
void do_sleep (CHAR_DATA * ch, char *argument)
{
    OBJ_DATA *obj = NULL;

    switch (ch->position)
    {
        case POS_SLEEPING:
            send_to_char ("You are already sleeping.\n\r", ch);
            break;

        case POS_RESTING:
        case POS_SITTING:
        case POS_STANDING:
            if (argument[0] == '\0' && ch->on == NULL)
            {
                send_to_char ("You go to sleep.\n\r", ch);
                act ("$n goes to sleep.", ch, NULL, NULL, TO_ROOM);
                ch->position = POS_SLEEPING;
            }
            else
            {                    /* find an object and sleep on it */

                if (argument[0] == '\0')
                    obj = ch->on;
                else
                    obj = get_obj_list (ch, argument, ch->in_room->contents);

                if (obj == NULL)
                {
                    send_to_char ("You don't see that here.\n\r", ch);
                    return;
                }
                if (obj->item_type != ITEM_FURNITURE
                    || (!IS_SET (obj->value[2], SLEEP_ON)
                        && !IS_SET (obj->value[2], SLEEP_IN)
                        && !IS_SET (obj->value[2], SLEEP_AT)))
                {
                    send_to_char ("You can't sleep on that!\n\r", ch);
                    return;
                }

                if (ch->on != obj && count_users (obj) >= obj->value[0])
                {
                    act_new ("There is no room on $p for you.",
                             ch, obj, NULL, TO_CHAR, POS_DEAD);
                    return;
                }

                ch->on = obj;
                if (IS_SET (obj->value[2], SLEEP_AT))
                {
                    act ("You go to sleep at $p.", ch, obj, NULL, TO_CHAR);
                    act ("$n goes to sleep at $p.", ch, obj, NULL, TO_ROOM);
                }
                else if (IS_SET (obj->value[2], SLEEP_ON))
                {
                    act ("You go to sleep on $p.", ch, obj, NULL, TO_CHAR);
                    act ("$n goes to sleep on $p.", ch, obj, NULL, TO_ROOM);
                }
                else
                {
                    act ("You go to sleep in $p.", ch, obj, NULL, TO_CHAR);
                    act ("$n goes to sleep in $p.", ch, obj, NULL, TO_ROOM);
                }
                ch->position = POS_SLEEPING;
            }
            break;

        case POS_FIGHTING:
            send_to_char ("You are already fighting!\n\r", ch);
            break;
    }

    return;
}
Exemplo n.º 18
0
void broadcast_shout(const CHANNEL_DEFINITION const *channel, struct char_data *sender, const char *argument)
{
    struct descriptor_iterator_filter playing_filter = { .must_playing = true, .skip_character = sender };
    struct descriptor_data *d;
    struct descriptor_data *dpending;
    struct char_data *actual;
    struct char_data *receiver;

    act_new("`1You shout '`!$T`1'``", sender, NULL, argument, TO_CHAR, POS_DEAD, channel->mob_trigger);
    dpending = descriptor_iterator_start(&playing_filter);
    while ((d = dpending) != NULL) {
	dpending = descriptor_iterator(d, &playing_filter);
	actual = CH(d);
	receiver = d->character;

	if (receiver->in_room != NULL && receiver->in_room->area == sender->in_room->area && CHAN_ENABLED(actual, channel->flag) && !CHAN_DENIED(actual, channel->flag)) {
	    act_new("`1$n shouts '`!$t`1'``", sender, argument, receiver, TO_VICT, channel->receiver_position, false);
	}
    }
}

void broadcast_global(const CHANNEL_DEFINITION const *channel, struct char_data *sender, const char *argument)
{
    static char buf[2*MAX_INPUT_LENGTH];
    struct descriptor_iterator_filter playing_filter = { .must_playing = true, .skip_character = sender };
    struct descriptor_data *dpending;
    struct descriptor_data *d;
    struct char_data *actual;

    (void)snprintf(buf, 2 * MAX_INPUT_LENGTH, "``$n %s: %s``", channel->print_name, argument);
    if (sender != NULL) {
	act_new("$n `2I`8M`2P`8:`` $t``", sender, argument, NULL, TO_CHAR, POS_DEAD, channel->mob_trigger);
    }
    dpending = descriptor_iterator_start(&playing_filter);
    while ((d = dpending) != NULL) {
	dpending = descriptor_iterator(d, &playing_filter);
	actual = CH(d);

	(void)snprintf(buf, 2 * MAX_INPUT_LENGTH, "``$t %s: %s``", channel->print_name, argument);
	if (CHAN_ENABLED(actual, channel->flag) && !CHAN_DENIED(actual, channel->flag)) {
	    act_new(buf, sender, argument, d->character, TO_VICT, channel->receiver_position, false);
	}
    }
}

void broadcast_say(const CHANNEL_DEFINITION const *channel, struct char_data *sender, const char *argument)
{
#define VERBSIZE 20
    static char buf[2*MAX_INPUT_LENGTH];
    static char verb[VERBSIZE];
    int len = strlen(argument);
    int puncpos = len - 1;
    int puncpos2 = len - 2;

    switch (puncpos)
    {
	case '!':
	    {
		if (puncpos2 >= 0) {
		    switch (argument[puncpos2])
		    {
			case '!': snprintf(verb, VERBSIZE, "%s", "shout"); break;
			case '?': snprintf(verb, VERBSIZE, "%s", "angrily demand"); break;
			default: snprintf(verb, VERBSIZE, "%s", "exclaim"); break;
		    }
		} else {
		    snprintf(verb, VERBSIZE, "%s", "exclaim");
		}
		break;
	    }
	case '?':
	    {
		if (puncpos2 >= 0) {
		    switch (argument[puncpos2])
		    {
			case '?': snprintf(verb, VERBSIZE, "%s", "in confusion, ask"); break;
			case '!': snprintf(verb, VERBSIZE, "%s", "angrily demand"); break;
			default: snprintf(verb, VERBSIZE, "%s", "ask"); break;
		    }
		} else {
		    snprintf(verb, VERBSIZE, "%s", "ask");
		}
		break;
	    }
	default: snprintf(verb, VERBSIZE, "%s", "say"); break;
    }

    (void)snprintf(buf, 2 * MAX_INPUT_LENGTH, "`7You %s '`s$T`7'``", verb);
    act_new(buf, sender, NULL, argument, TO_CHAR, POS_RESTING, channel->mob_trigger);

    (void)snprintf(buf, 2 * MAX_INPUT_LENGTH, "`7$n %ss '`s$T`7'``", verb);
    act_new(buf, sender, NULL, argument, TO_ROOM, channel->receiver_position, false);
}

void broadcast_emote(const CHANNEL_DEFINITION const *channel, struct char_data *sender, const char *argument)
{
    act_new("$n $T", sender, NULL, emote_parse(argument), TO_CHAR, POS_RESTING, channel->mob_trigger);
    act_new("$n $T", sender, NULL, emote_parse(argument), TO_ROOM, channel->receiver_position, false);
}

void broadcast_pmote(const CHANNEL_DEFINITION const *channel, struct char_data *sender, const char *argument)
{
    struct char_data *vch;
    char *letter;
    char *name;
    char last[MAX_INPUT_LENGTH];
    char temp[MAX_STRING_LENGTH];
    int matches = 0;

    act_new("$n $t", sender, argument, NULL, TO_CHAR, POS_DEAD, channel->mob_trigger);

    for (vch = sender->in_room->people; vch != NULL; vch = vch->next_in_room) {
	if (vch->desc == NULL || vch == sender)
	    continue;

	if ((letter = strstr(argument, vch->name)) == NULL) {
	    act_new("$N $t", vch, argument, sender, TO_CHAR, channel->receiver_position, false);
	    continue;
	}

	strcpy(temp, argument);
	temp[strlen(argument) - strlen(letter)] = '\0';
	last[0] = '\0';
	name = vch->name;

	for (; *letter != '\0'; letter++) {
	    if (*letter == '\'' && matches == (int)strlen(vch->name)) {
		strcat(temp, "r");
		continue;
	    }

	    if (*letter == 's' && matches == (int)strlen(vch->name)) {
		matches = 0;
		continue;
	    }

	    if (matches == (int)strlen(vch->name))
		matches = 0;

	    if (*letter == *name) {
		matches++;
		name++;
		if (matches == (int)strlen(vch->name)) {
		    strcat(temp, "you");
		    last[0] = '\0';
		    name = vch->name;
		    continue;
		}
		strncat(last, letter, 1);
		continue;
	    }

	    matches = 0;
	    strcat(temp, last);
	    strncat(temp, letter, 1);
	    last[0] = '\0';
	    name = vch->name;
	}

	act_new("$N $t", vch, temp, sender, TO_CHAR, channel->receiver_position, false);
    }
}

void broadcast_smote(const CHANNEL_DEFINITION const *channel, struct char_data *sender, const char *argument)
{
    struct char_data *vch;
    char *letter;
    char *name;
    char last[MAX_INPUT_LENGTH];
    char temp[MAX_STRING_LENGTH];
    int matches = 0;

    if (strstr(argument, sender->name) == NULL) {
	send_to_char("You must include your name in an smote.\n\r", sender);
	return;
    }

    printf_to_char(sender, "%s\n\r", argument);

    for (vch = sender->in_room->people; vch != NULL; vch = vch->next_in_room) {
	if (vch->desc == NULL || vch == sender)
	    continue;

	if ((letter = strstr(argument, vch->name)) == NULL) {
	    printf_to_char(vch, "%s\n\r", argument);
	    continue;
	}

	strcpy(temp, argument);
	temp[strlen(argument) - strlen(letter)] = '\0';
	last[0] = '\0';
	name = vch->name;

	for (; *letter != '\0'; letter++) {
	    if (*letter == '\'' && matches == (int)strlen(vch->name)) {
		strcat(temp, "r");
		continue;
	    }

	    if (*letter == 's' && matches == (int)strlen(vch->name)) {
		matches = 0;
		continue;
	    }

	    if (matches == (int)strlen(vch->name))
		matches = 0;

	    if (*letter == *name) {
		matches++;
		name++;

		if (matches == (int)strlen(vch->name)) {
		    strcat(temp, "you");
		    last[0] = '\0';
		    name = vch->name;
		    continue;
		}

		strncat(last, letter, 1);
		continue;
	    }

	    matches = 0;
	    strcat(temp, last);
	    strncat(temp, letter, 1);
	    last[0] = '\0';
	    name = vch->name;
	}

	printf_to_char(vch, "%s\n\r", temp);
    }
}

void broadcast_reply(const CHANNEL_DEFINITION const *channel, struct char_data *sender, const char *argument)
{
    struct char_data *whom;

    if ((whom = sender->reply) == NULL) {
	send_to_char("They aren't here.\n\r", sender);
	return;
    }

    if (send_tell(sender, whom, argument)) {
	whom->reply = sender;
    }

    return;
}

void broadcast_gtell(const CHANNEL_DEFINITION const *channel, struct char_data *sender, const char *argument)
{
    struct char_data *gch;

    for (gch = char_list; gch != NULL; gch = gch->next) {
	if (is_same_group(gch, sender)) {
	    printf_to_char(gch, "```5%s tells the group '```P%s```5'``\n\r", sender->name, argument);
	}
    }
}


/***
 * Targetted Broadcasters
 */

void broadcast_sayto(const CHANNEL_DEFINITION const *channel, struct char_data *sender, struct char_data *whom, const char *argument)
{
    struct descriptor_iterator_filter playing_filter = { .must_playing = true, .skip_character = sender };
    struct descriptor_data *d;
    struct descriptor_data *dpending;

    if (IS_SET(whom->comm, COMM_AFK) && IS_NPC(whom)) {
	act("$E is `!A`@F`OK``, and is unable to pay attention.", sender, NULL, whom, TO_CHAR);
	return;
    }

    printf_to_char(sender, "``You say to %s '`P%s``'\n\r", whom->name, argument);
    printf_to_char(whom, "``%s says to you '`P%s``'\n\r", sender->name, argument);

    dpending = descriptor_iterator_start(&playing_filter);
    while ((d = dpending) != NULL) {
	dpending = descriptor_iterator(d, &playing_filter);
	if (d->character->in_room == sender->in_room
		&& d->character->position != POS_SLEEPING
		&& d->character != whom) {
	    printf_to_char(d->character, "%s says to %s, '`P%s``'.\n\r", PERS(sender, d->character), PERS(whom, d->character), argument);
	}
    }
}

void broadcast_tell(const CHANNEL_DEFINITION const *channel, struct char_data *sender, struct char_data *whom, const char *argument)
{
    if (send_tell(sender, whom, argument)) {
	whom->reply = sender;
	if (!IS_NPC(sender) && IS_NPC(whom) && HAS_TRIGGER(whom, TRIG_SPEECH)) {
	    mp_act_trigger(argument, whom, sender, NULL, NULL, TRIG_SPEECH);
	}
    }
}


/***
 * Util
 */

bool is_ignoring(struct char_data *sender, struct char_data *receiver)
{
    int pos;
    bool found = false;

    if (IS_NPC(receiver)) {
	return false;
    }

    for (pos = 0; pos < MAX_IGNORE; pos++) {
	if (receiver->pcdata->ignore[pos] == NULL) {
	    break;
	}
	if (!str_cmp(sender->name, receiver->pcdata->ignore[pos])) {
	    found = true;
	    break;
	}
    }
    return found;
}

bool send_tell(struct char_data *sender, struct char_data *whom, const char* argument)
{
    static char buf[MAX_STRING_LENGTH];

    if (!IS_IMMORTAL(whom) && !IS_AWAKE(sender)) {
	send_to_char("In your dreams, or what?\n\r", sender);
	return false;
    }

    if (IS_SET(whom->comm, COMM_AFK)) {
	if (IS_NPC(whom)) {
	    act("$E is ```!A```@F```OK``, and not receiving tells.", sender, NULL, whom, TO_CHAR);
	    return false;
	}

	act("$E is ```!A```@F```OK``, but your tell will go through when $E returns.", sender, NULL, whom, TO_CHAR);
	(void)snprintf(buf, 2 * MAX_INPUT_LENGTH, "```@%s tells you '`t%s```@'``\n\r", PERS(sender, whom), argument);
	buf[0] = UPPER(buf[0]);
	add_buf(whom->pcdata->buffer, buf);
	return true;
    }

    if (whom->desc == NULL && !IS_NPC(whom)) {
	act("$N seems to have misplaced $S link...try again later.", sender, NULL, whom, TO_CHAR);
	(void)snprintf(buf, 2 * MAX_INPUT_LENGTH, "```@%s tells you '`t%s```@'``\n\r", PERS(sender, whom), argument);
	buf[0] = UPPER(buf[0]);
	add_buf(whom->pcdata->buffer, buf);
	return true;
    }


    act_new("`@You tell $N '`r$t`@'``", sender, argument, whom, TO_CHAR, POS_DEAD, false);
    act_new("`@$n tells you '`r$t`@'``", sender, argument, whom, TO_VICT, POS_DEAD, false);
    return true;
}

char *emote_parse(const char *argument)
{
    static char target[MAX_STRING_LENGTH];
    char buf[MAX_STRING_LENGTH];
    int i = 0, arg_len = 0;
    int flag = false;

    /* Reset target each time before use */
    memset(target, 0x00, sizeof(target));
    arg_len = (int)strlen(argument);
    for (i = 0; i < arg_len; i++) {
	if (argument[i] == '"' && flag == false) {
	    flag = true;
	    (void)snprintf(buf, MAX_STRING_LENGTH, "%c", argument[i]);
	    strcat(target, buf);
	    strcat(target, "`P");
	    continue;
	} else if (argument[i] == '"' && flag == true) {
	    flag = false;
	    strcat(target, "``");
	    (void)snprintf(buf, MAX_STRING_LENGTH, "%c", argument[i]);
	    strcat(target, buf);
	    continue;
	} else {
	    (void)snprintf(buf, MAX_STRING_LENGTH, "%c", argument[i]);
	    strcat(target, buf);
	}
    }
    if (flag) {
	strcat(target, "``");
	(void)snprintf(buf, MAX_STRING_LENGTH, "%c", '"');
	strcat(target, buf);
    }
    return target;
}
Exemplo n.º 19
0
Arquivo: org.c Projeto: verias/SRMud
void do_exalt(CHAR_DATA *ch, char *argument )
{	CHAR_DATA *victim;
	char arg[MSL];

	if(IS_NPC(ch) )
		return;

	if(!HAS_ORGANIZATION(ch) )
	{	send_to_char("You aren't organized.\n\r",ch);
		return;
	}
	if( ch->pcdata->rank < RANK_PRIEST )
	{	send_to_char("You cannot exalt people!\n\r",ch );
		return;
	}
	one_argument(argument, arg );

	if(arg[0] == '\0' )
	{	send_to_char("Syntax: Exalt <person>\n\r",ch);
		return;
	}
	if(!IS_IMMORTAL(ch) )
	{	if( ( victim = get_char_room(ch, NULL, arg) )  == NULL )
		{	send_to_char("They aren't here.\n\r",ch);
			return;
		}
	}
	else
	{	if( ( victim = get_char_world(ch, arg) ) == NULL )
		{	send_to_char("They aren't here.\n\r",ch);
			return;
		}
	}
	if(IS_NPC(victim) )
	{	send_to_char("Not on NPC's.\n\r",ch);
		return;
	}
	if(!HAS_ORGANIZATION(victim) )
	{	send_to_char("They aren't organized.\n\r",ch);
		return;
	}

    if(!IS_SAME_ORGANIZATION(ch, victim) && ch->pcdata->rank != RANK_GOD  )
	{	send_to_char("They aren't in your organization!\n\r",ch); 
		return; 
	}

	if( ch->pcdata->rank <= victim->pcdata->rank )
	{	send_to_char("You cannot exalt them.\n\r", ch );
		return;
	}

	if(!IS_IMMORTAL(ch) && ch->pcdata->rank <= RANK_PRIEST && victim->pcdata->rank >= RANK_BISHOP )
	{	send_to_char("You cannot exalt them.\n\r",ch);
		return;
	}

	if(victim->pcdata->rank == RANK_DEITY && ch->pcdata->rank != RANK_GOD )
	{	send_to_char("You cannot exalt to God Rank.\n\r",ch);
		return;
	}
	if(victim->pcdata->rank == RANK_GOD )
	{	send_to_char("They cannot get any higher!\n\r",ch);
		return;
	}

	victim->pcdata->rank++;
	printf_to_char(ch, "%s has been exalted to %s.\n\r", victim->name, orgrank_table[victim->pcdata->rank].name );
	act_new(victim->pcdata->organization->pmt_msg, victim, NULL, NULL, TO_CHAR, POS_SLEEPING);
	return;
}