Beispiel #1
0
void do_group( CHAR_DATA *ch, char *argument )
{
    char buf[MAX_STRING_LENGTH];
    char arg[MAX_INPUT_LENGTH];
    CHAR_DATA *victim;

    one_argument( argument, arg );

    if ( arg[0] == '\0' )
    {
	CHAR_DATA *gch;
	CHAR_DATA *leader;

	leader = (ch->leader != NULL) ? ch->leader : ch;
	sprintf( buf, "%s's group:\n\r", person( ch, leader ) );
	send_to_char( buf, ch );

	for ( gch = char_list; gch != NULL; gch = gch->next )
	{
	    if ( is_same_group( gch, ch ) )
	    {
		sprintf( buf, "%-16s\n\r", person( ch, gch) );
		send_to_char( buf, ch );
	    }
	}
	return;
    }

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

    if ( ch->master != NULL || ( ch->leader != NULL && ch->leader != ch ) )
    {
	send_to_char( "But you are following someone else!\n\r", ch );
	return;
    }

    if ( victim->master != ch && ch != victim )
    {
	act( "$N isn't following you.", ch, victim, NULL, NULL, NULL, TO_CHAR, SENSE_SIXTH );
	return;
    }

    if ( is_same_group( victim, ch ) && ch != victim )
    {
	victim->leader = NULL;
	act( "$n removes you from $s group.",  ch, victim, NULL, NULL, NULL, TO_VICT, SENSE_SIXTH );
	act( "You remove $N from your group.", ch, victim, NULL, NULL, NULL, TO_CHAR, SENSE_SIXTH );
	return;
    }

    victim->leader = ch;
    act( "You join $n's group.", ch, victim, NULL, NULL, NULL, TO_VICT, SENSE_SIXTH );
    act( "$N joins your group.", ch, victim, NULL, NULL, NULL, TO_CHAR, SENSE_SIXTH );
    return;
}
Beispiel #2
0
/*
 * Lets the mobile force a group something. Must be mortal level.
 *
 * Syntax: mob gforce [victim] [commands]
 */
void do_mpgforce(CHAR_DATA * ch, char *argument)
{
    char arg[MAX_INPUT_LENGTH];
    CHAR_DATA *victim, *vch, *vch_next;

    argument = one_argument(argument, arg);

    if (arg[0] == '\0' || argument[0] == '\0') {
	bug("MpGforce - Bad syntax from vnum %d.",
	    IS_NPC(ch) ? ch->pIndexData->vnum : 0);
	return;
    }
    if ((victim = get_char_room(ch, arg)) == NULL)
	return;

    if (victim == ch)
	return;

    for (vch = victim->in_room->people; vch != NULL; vch = vch_next) {
	vch_next = vch->next_in_room;

	if (is_same_group(victim, vch)) {
	    interpret(vch, argument);
	}
    }
    return;
}
static void
find_matching_se(struct sched_entity **se, struct sched_entity **pse)
{
	int se_depth, pse_depth;

	/*
	 * preemption test can be made between sibling entities who are in the
	 * same cfs_rq i.e who have a common parent. Walk up the hierarchy of
	 * both tasks until we find their ancestors who are siblings of common
	 * parent.
	 */

	/* First walk up until both entities are at same depth */
	se_depth = depth_se(*se);
	pse_depth = depth_se(*pse);

	while (se_depth > pse_depth) {
		se_depth--;
		*se = parent_entity(*se);
	}

	while (pse_depth > se_depth) {
		pse_depth--;
		*pse = parent_entity(*pse);
	}

	while (!is_same_group(*se, *pse)) {
		*se = parent_entity(*se);
		*pse = parent_entity(*pse);
	}
}
Beispiel #4
0
/*
 * Lets the mobile transfer all chars in same group as the victim.
 *
 * Syntax: mob gtransfer [victim] [location]
 */
void do_mpgtransfer(CHAR_DATA * ch, char *argument)
{
    char arg1[MAX_INPUT_LENGTH];
    char arg2[MAX_INPUT_LENGTH];
    char buf[MAX_STRING_LENGTH];
    CHAR_DATA *who, *victim, *victim_next;

    argument = one_argument(argument, arg1);
    argument = one_argument(argument, arg2);

    if (arg1[0] == '\0') {
	bug("Mpgtransfer - Bad syntax from vnum %d.",
	    IS_NPC(ch) ? ch->pIndexData->vnum : 0);
	return;
    }
    if ((who = get_char_room(ch, arg1)) == NULL)
	return;

    for (victim = ch->in_room->people; victim; victim = victim_next) {
	victim_next = victim->next_in_room;
	if (is_same_group(who, victim)) {
	    sprintf(buf, "%s %s", victim->name, arg2);
	    do_mptransfer(ch, buf);
	}
    }
    return;
}
Beispiel #5
0
void do_gtell( CHAR_DATA * ch, char * argument ) {
  CHAR_DATA * gch;
  char        buf[ MAX_STRING_LENGTH ];

  if ( argument[ 0 ] == '\0' ) {
    send_to_char( AT_GREEN, "Tell your group what?\n\r", ch );
    return;
  }

  if ( CHECK_BIT( ch->act, PLR_NO_TELL ) ) {
    send_to_char( AT_GREEN, "Your message didn't get through!\n\r", ch );
    return;
  }

  /*
   * Note use of send_to_char, so gtell works on sleepers.
   */
  sprintf( buf, "%s tells the group '%s'.\n\r", ch->name, argument );

  for ( gch = char_list; gch; gch = gch->next ) {
    if ( gch->deleted ) {
      continue;
    }

    if ( is_same_group( gch, ch ) ) {
      send_to_char( AT_GREEN, buf, gch );
    }
  }

  return;
}
Beispiel #6
0
void do_gtell( CHAR_DATA *ch, char *argument )
{
    char buf[MAX_STRING_LENGTH];
    CHAR_DATA *gch;

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

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

    /*
     * Note use of send_to_char, so gtell works on sleepers.
     */
    sprintf( buf, "%s tells the group '%s'.\n\r", ch->name, argument );
    for ( gch = char_list; gch != NULL; gch = gch->next )
    {
	if ( is_same_group( gch, ch ) )
	    send_to_char( buf, gch );
    }

    return;
}
Beispiel #7
0
bool join_fight( char_data* victim, char_data* ch, char_data* rch )
{
  if( rch == ch )
    return FALSE;

  if( rch == victim )
    return TRUE;

  if( rch->pcdata != NULL ) {
    if( is_set( rch->pcdata->pfile->flags, PLR_AUTO_ASSIST ) 
      && is_same_group( rch, victim ) && !is_same_group( rch, ch )
      && can_kill( rch, ch ) )
      return TRUE;
    return FALSE;
    }
 
  if( is_set( &rch->status, STAT_PET ) ) {
    if( rch->leader == victim && ( victim->pcdata == NULL
      || is_set( victim->pcdata->pfile->flags, PLR_PET_ASSIST ) ) )
      return TRUE;
    return FALSE;
    }

  if( rch->species != NULL && victim->species != NULL 
    && is_set( &rch->species->act_flags, ACT_ASSIST_GROUP )
    && !is_set( &victim->status, STAT_PET ) ) {
    if( victim->species->nation != NATION_NONE
      && rch->species->nation == victim->species->nation )
      return TRUE;
    if( victim->species->group != GROUP_NONE
      && victim->species->group == rch->species->group )
      return TRUE;
    }

  return FALSE;
}  
Beispiel #8
0
/* 
 * How many other players / mobs are there in the room
 * iFlag: 0: all, 1: players, 2: mobiles 3: mobs w/ same vnum 4: same group
 */
int count_people_room( CHAR_DATA *mob, int iFlag )
{
    CHAR_DATA *vch;
    int count;
    for ( count = 0, vch = mob->in_room->people; vch; vch = vch->next_in_room )
	if ( mob != vch 
	&&   (iFlag == 0
	  || (iFlag == 1 && !IS_NPC( vch )) 
	  || (iFlag == 2 && IS_NPC( vch ))
	  || (iFlag == 3 && IS_NPC( mob ) && IS_NPC( vch ) 
	     && mob->pIndexData->vnum == vch->pIndexData->vnum )
	  || (iFlag == 4 && is_same_group( mob, vch )) )
	&& can_see( mob, vch ) ) 
	    count++;
    return ( count );
}
Beispiel #9
0
	bool unite(int x, int y){
		if(is_same_group(x, y))
			return false;

		x = root(x);
		y = root(y);

		if(_rank[x] < _rank[y]){
			_root[x] = y;
		}else{
			_root[y] = x;
			if(_rank[x] == _rank[y])
				_rank[x]++;
		}
		return true;
	}
Beispiel #10
0
// Clone of mpgainxp
void do_mpgainqp(CHAR_DATA* ch, char* argument)
{
    char       arg1[ MAX_INPUT_LENGTH ];
    char       arg2[ MAX_INPUT_LENGTH ];
    CHAR_DATA *victim;

    if ( !IS_NPC( ch ) )
    {
       send_to_char(C_DEFAULT, "Huh?\n\r", ch );
       return;
    }

    if ( IS_AFFECTED( ch, AFF_CHARM ) )
    {
        return;
    }

    argument = one_argument( argument, arg1 );
    argument = one_argument( argument, arg2 );

    if ( arg1[0] == '\0' || arg2[0]=='\0' )
    {
       bug( "Mpgainqp - No argument:  vnum %d.",
	   ch->pIndexData->vnum );
       return;
    }

    if ( !( victim = get_char_room( ch, arg1 ) ) )
    {
      return;
    } else
    {
       CHAR_DATA* gch;

       for ( gch = victim->in_room->people; gch; gch = gch->next_in_room )
       {
          if ( is_same_group( gch, victim ) )
          {
	     gch->questpoints += atoi(arg2);
             if (gch->questpoints < 0) { gch->questpoints = 0; };
          }
       }

    }
}
Beispiel #11
0
bool spell_coldwave_master(int sn, int level, CHAR_DATA *ch, void *vo, OBJ_DATA *obj)
{
    bool success = FALSE, success2 = FALSE;
    CHAR_DATA *gch;

    success = coldwave_cooldown(ch, ch, 5);

    for (gch = ch->in_room->first_person; gch != NULL; gch = gch->next_in_room) {
        if (!is_same_group(ch, gch))
            continue;

        success2 = coldwave_cooldown(ch, gch, 2);
        if (success2)
            success = success2;
    }

    return success;
}
Beispiel #12
0
bool spell_tranquility_master(int sn, int level, CHAR_DATA *ch, void *vo, OBJ_DATA *obj)
{
    CHAR_DATA *gch;

    if (ch->pcdata->safetimer > 0 || ch->pcdata->fighttimer > 0 || ch->pcdata->in_arena || find_duel(ch))
        return FALSE;

    for (gch = ch->in_room->first_person; gch != NULL; gch = gch->next_in_room) {
        if (!is_same_group(ch, gch) || IS_NPC(gch) || gch->pcdata->safetimer > 0 || gch->pcdata->fighttimer > 0 || gch->fighting != NULL)
            continue;

        act("$n suddenly feels great calm and tranquility.", gch, NULL, NULL, TO_ROOM);
        send_to_char("You feel great calm and tranquility.\n\r", gch);
        gch->pcdata->safetimer = current_time + 300;
    }

    return TRUE;
}
Beispiel #13
0
bool is_same_gspell( CHAR_DATA * ch, CHAR_DATA * victim ) {
  if ( !is_same_group( ch, victim ) ) {
    return FALSE;
  }

  if ( !ch->gspell || !victim->gspell ) {
    return FALSE;
  }

  if ( ch->gspell->sn != victim->gspell->sn ) {
    return FALSE;
  }

  if ( ch->gspell->victim != victim->gspell->victim ) {
    return FALSE;
  }

  return TRUE;
}
Beispiel #14
0
void add_gspell( CHAR_DATA * ch, int sn, int level, void * vo ) {
  CHAR_DATA * gch;
  GSPELL_DATA gsp;

  for ( gch = ch->in_room->people; gch; gch = gch->next_in_room ) {
    if ( gch == ch || !gch->gspell || gch->gspell->timer <= 0 ) {
      continue;
    }

    if ( is_same_group( ch, gch ) && gch->gspell->sn == sn ) {
      switch ( skill_table[ sn ].target ) {
        case TAR_GROUP_DEFENSIVE:
        case TAR_GROUP_OFFENSIVE:
        case TAR_GROUP_OBJ:
        case TAR_GROUP_IGNORE:

          if ( gch->gspell->victim != vo ) {
            continue;
          }

          break;
      }

      break;
    }
  }

  sn         = skill_table[ sn ].slot;
  gsp.sn     = sn;
  gsp.victim = vo;
  gsp.level  = level;

  if ( !gch || !gch->gspell ) {
    gsp.timer = gskill_table[ gslot_lookup( sn ) ].wait;
  } else {
    gsp.timer = gch->gspell->timer;
  }

  set_gspell( ch, &gsp );
  check_gcast( ch );
  return;
}
Beispiel #15
0
void Character::spell_mass_invis (int sn, int lvl, void *vo)
{
  Affect af;

  CharIter gch;
  for (gch = in_room->people.begin(); gch != in_room->people.end(); gch++) {
    if (!is_same_group (*gch, this) || (*gch)->is_affected (AFF_INVISIBLE))
      continue;
    (*gch)->act ("$n slowly fades out of existence.", NULL, NULL, TO_ROOM);
    (*gch)->send_to_char ("You slowly fade out of existence.\r\n");
    af.type = sn;
    af.duration = 24;
    af.location = APPLY_NONE;
    af.modifier = 0;
    af.bitvector = AFF_INVISIBLE;
    (*gch)->affect_to_char(&af);
  }
  send_to_char ("Ok.\r\n");

  return;
}
Beispiel #16
0
bool Player_Data :: Accept_Msg( char_data* ch )
{
  if( msg_type == MSG_STANDARD )
    return TRUE;

  int level = level_setting( &pcdata->mess_settings, msg_type );

  if( level == 3 )
    return TRUE;

  if( level == 0 ) 
    return FALSE;

  if( Befriended( ch ) )
    return TRUE;

  if( level == 1 )
    return FALSE;

  return is_same_group( this, ch );
}
Beispiel #17
0
void do_group( CHAR_DATA * ch, char * argument ) {
  CHAR_DATA * victim;
  char        buf[ MAX_STRING_LENGTH ];
  char        arg[ MAX_INPUT_LENGTH  ];

  one_argument( argument, arg );

  if ( arg[ 0 ] == '\0' ) {
    CHAR_DATA * gch;
    CHAR_DATA * leader;

    leader = ( ch->leader ) ? ch->leader : ch;
    sprintf( buf, "%s's group:\n\r", visible_name( leader, ch, TRUE ) );
    send_to_char( AT_DGREEN, buf, ch );

    for ( gch = char_list; gch; gch = gch->next ) {
      if ( gch->deleted ) {
        continue;
      }

      if ( is_same_group( gch, ch ) ) {
        sprintf( buf,
                 "[&R%2d %s&G] %-12s &Y%4d/%4d &Ghp &C%4d/%4d &Gmana &P%4d/%4d &Gmv &R%5d &Gxp\n\r",
                 gch->level,
                 IS_NPC( gch ) ? "Mob"
                 : class_table[ prime_class( gch ) ].who_name,
                 capitalize( visible_name( gch, ch, TRUE ) ),
                 gch->hit,   MAX_HIT( gch ),
                 gch->mana,  MAX_MANA( gch ),
                 gch->move,  MAX_MOVE( gch ),
                 gch->exp );

        if ( gch->gspell && gch->gspell->timer > 0 ) {
          send_to_char( AT_YELLOW, buf, ch );
        } else {
          send_to_char( AT_GREEN, buf, ch );
        }
      }
    }

    return;
  }

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

  if ( ch->master || ( ch->leader && ch->leader != ch ) ) {
    send_to_char( AT_DGREEN, "But you are following someone else!\n\r", ch );
    return;
  }

  if ( victim->master != ch && ch != victim ) {
    act( AT_DGREEN, "$N isn't following you.", ch, NULL, victim, TO_CHAR );
    return;
  }

  if ( is_same_group( victim, ch ) && ch != victim ) {
    victim->leader = NULL;
    act( AT_GREEN, "You remove $N from your group.", ch, NULL, victim, TO_CHAR );
    act( AT_GREEN, "$n removes you from $s group.",  ch, NULL, victim, TO_VICT );
    act( AT_GREEN, "$n removes $N from $s group.",   ch, NULL, victim, TO_NOTVICT );
    return;
  }

  if (   ch->level - victim->level < -8
         || ch->level - victim->level >  8 ) {
    act( AT_DGREEN, "$N cannot join your group.",  ch, NULL, victim, TO_CHAR );
    act( AT_DGREEN, "You cannot join $n's group.", ch, NULL, victim, TO_VICT );
    act( AT_DGREEN, "$N cannot join $n's group.",  ch, NULL, victim, TO_NOTVICT );
    return;
  }

  victim->leader = ch;
  act( AT_GREEN, "$N joins your group.", ch, NULL, victim, TO_CHAR );
  act( AT_GREEN, "You join $n's group.", ch, NULL, victim, TO_VICT );
  act( AT_GREEN, "$N joins $n's group.", ch, NULL, victim, TO_NOTVICT );
  return;
}
Beispiel #18
0
void select_target( CHAR_DATA * ch )
{
    /*
     * Find a new target for the group to go after
     */
    int average_level;
//   int        tmp   = 0;
    CHAR_DATA *vch;
    CHAR_DATA *victim = NULL;
    list<CHAR_DATA *>::iterator li;
    char buf[MAX_STRING_LENGTH];
    int force_index = 0;
    bool alone = TRUE;
    bool mob_is_leader = FALSE;
    short attempts;

    /*
     * mobs were doing ethereal travel too much... i've now lowered it to
     * * 15% of the time and only if they are not hunting
     */

    mob_is_leader = is_group_leader( ch );
    if ( ( number_percent(  ) < 15 ) && ( ch->hunting == NULL ) && ( ch->in_room->vnum != ROOM_VNUM_ETHEREAL_PLANE ) )

        /* was victim == NULL, that's always true at this point.. Zen */

    {
        if ( mob_is_leader == TRUE )
        {
            for ( vch = ch->in_room->first_person; vch != NULL; vch = vch->next_in_room )
            {
                if ( ( is_same_group( ch, vch ) ) == TRUE )
                {
                    if ( vch->mana < mana_cost( vch, skill_lookup( "ethereal travel" ) ) )
                    {
                        return;
                    }
                }
            }
        }
        if ( ch->mana < mana_cost( ch, skill_lookup( "ethereal travel" ) ) )
            return;

        do_say( ch, "This place is boring! I am gonna go somewhere else!" );
        for ( vch = ch->in_room->first_person; vch != NULL; vch = vch->next_in_room )
        {
            if ( ( is_same_group( vch, ch ) ) && ( ch != vch ) )
            {
                do_say( vch, "Yeah, it is--we're outta here!" );
                do_cast( vch, "ethereal" );
            }
        }
        do_cast( ch, "ethereal" );
    }
    else
    {
        /*
         * keeps checking until you've found a valid target
         */
        attempts = 0;
        while ( ( victim == NULL ) && ( attempts < 15 ) )
        {
// ZEN FIX set average level based on level of ngroup
            attempts++;
            average_level = ch->get_level("psuedo");

            force_index = number_range( 1, mob_index_list.size() );

            for ( li = char_list.begin(); li != char_list.end(); li++ )
            {
                vch = *li;
                if ( victim != NULL )
                    break;
                force_index--;
                if ( force_index > 0 )
                    continue;

                if ( valid_target( ch, vch, average_level ) )
                {
                    /*
                     * Trick used in  something else...
                     */
                    if ( number_range( 0, 1 ) == 0 )
                    {
                        victim = vch;
                    }
                    if ( victim == NULL ) /* screwed up somehow */
                    {
                        continue;
                    }
                    if ( !IS_NPC( victim ) )
                    {
                        for ( vch = ch->in_room->first_person; vch != NULL; vch = vch->next_in_room )
                        {
                            if ( is_same_group( ch, vch ) )
                            {
                                alone = FALSE;
                                break;
                            }
                        }
                        if ( alone == FALSE )
                        {
                            snprintf( buf, MSL, "%s We're coming for you!", victim->name.c_str() );
                            do_tell( ch, buf );
                        }
                        else
                        {
                            snprintf( buf, MSL, "%s I'm coming for you!", victim->name.c_str() );
                            do_tell( ch, buf );
                        }
                    }
                }
            }
        }

        if ( set_hunt( ch, NULL, victim, NULL, HUNT_WORLD | HUNT_PICKDOOR | HUNT_CR, HUNT_MERC ) )
        {
            snprintf( buf, MSL, "Right!  %s is our new target!!", victim->get_name() );
            do_say( ch, buf );
        }

        return;
    }
    return;

}
Beispiel #19
0
/**
 * dzielenie siê pieniêdzmi
 */
void money_split( CHAR_DATA *ch, long int amount, int nomination, bool show_message, bool is_split_all, bool is_autosplit )
{
    int multiplier = RATTING_NONE;
    CHAR_DATA *gch;
    long int members = 0, share, extra;
    char buf[ MAX_INPUT_LENGTH ];
    char buf_amount[ MAX_INPUT_LENGTH ];

    switch ( nomination )
    {
        case NOMINATION_COPPER:
            if ( ch->copper < amount )
            {
                if ( show_message || is_autosplit )
                {
                    send_to_char( "Nie masz tylu miedzianych monet.\n\r", ch );
                }
                return;
            }
            break;
        case NOMINATION_SILVER:
            if ( ch->silver < amount )
            {
                if ( show_message || is_autosplit )
                {
                    send_to_char( "Nie masz tylu srebrnych monet.\n\r", ch );
                }
                return;
            }
            break;
        case NOMINATION_GOLD:
            if ( ch->gold < amount )
            {
                if ( show_message || is_autosplit )
                {
                    send_to_char( "Nie masz tylu zlotych monet.\n\r", ch );
                }
                return;
            }
            break;
        case NOMINATION_MITHRIL:
            if ( ch->mithril < amount )
            {
                if ( show_message || is_autosplit )
                {
                    send_to_char( "Nie masz tylu mithrilowych monet.\n\r", ch );
                }
                return;
            }
            break;
    } 

    for ( gch = ch->in_room->people; gch != NULL; gch = gch->next_in_room )
    {
        if ( can_see( ch, gch ) && is_same_group( gch, ch ) && !IS_AFFECTED( gch, AFF_CHARM ) )
        {
            members++;
        }
    }

    if ( members < 2 )
    {
        if ( show_message && ! is_autosplit )
        {
            send_to_char( "Dzielisz siê piêniedzmi sam ze sob±.\n\r", ch );
        }
        return;
    }

    if ( amount < members )
    {
        if ( show_message && ! is_split_all && ! is_autosplit )
        {
            send_to_char( "Nawet siê nie trud¼ <&sk±pcu/sk±pa kobieto/sk±pirad³o>.\n\r", ch );
        }
        return;
    }

    share = amount;
    share /= members;
    if ( share < 1 )
    {
        share = 0;
    }

    extra = amount;
    extra %= members;
    if ( extra < 1 )
    {
        extra = 0;
    }

    if ( share < 1 )
    {
        if ( show_message && ! is_split_all && ! is_autosplit )
        {
            send_to_char( "Nawet siê nie trud¼ <&sk±pcu/sk±pa kobieto/sk±pirad³o>.\n\r", ch );
        }
        return;
    }

    append_file_format_daily
        (
         ch,
         MONEY_LOG_FILE,
         "-> S: before split /%d/%d/%d/%d/",
         ch->copper,
         ch->silver,
         ch->gold,
         ch->mithril
        );

    switch ( nomination )
    {
        case NOMINATION_COPPER:
            ch->copper += share + extra - amount;
            multiplier = RATTING_COPPER;
            break;
        case NOMINATION_SILVER:
            ch->silver += share + extra - amount;
            multiplier = RATTING_SILVER;
            break;
        case NOMINATION_GOLD:
            ch->gold += share + extra - amount;
            multiplier = RATTING_GOLD;
            break;
        case NOMINATION_MITHRIL:
            ch->mithril += share + extra - amount;
            multiplier = RATTING_MITHRIL;
            break;
    } 

    append_file_format_daily
        (
         ch,
         MONEY_LOG_FILE,
         "-> S: %ld %ld (%ld) - splitn±³ kasê w wysoko¶ci %s (%d/%d) nominal: %d /%d/%d/%d/%d/",
         money_count_copper( ch ) + ( extra + share - amount ) * multiplier,
         money_count_copper( ch ),
         ( share + extra - amount ) * multiplier,
         money_string_simple( amount, nomination, FALSE ),
         share,
         extra,
         nomination,
         ch->copper,
         ch->silver,
         ch->gold,
         ch->mithril
        );

    if ( show_message || is_autosplit )
    {
        sprintf ( buf_amount, "%s", money_string_simple ( amount, nomination, TRUE ) );
        sprintf( buf, "Rozdzielasz %s. Dostajesz %s.\n\r", buf_amount,  money_string_simple ( share + extra, nomination, TRUE ) );
        send_to_char( buf, ch );
        sprintf ( buf, "%s rozdziela %s. Dostajesz swoj± czê¶æ, %s.\n\r", ch->name, buf_amount, money_string_simple ( share, nomination, TRUE) );
    }

    for ( gch = ch->in_room->people; gch != NULL; gch = gch->next_in_room )
    {
        if ( gch != ch && can_see( ch, gch ) && is_same_group( gch, ch ) && !IS_AFFECTED( gch, AFF_CHARM ) )
        {
            if ( show_message || is_autosplit )
            {
                /* act( buf, ch, NULL, gch, TO_VICT );*/
                send_to_char( buf, gch );
            }
            append_file_format_daily
                (
                 gch,
                 MONEY_LOG_FILE,
                 "-> S: %ld %ld (%ld) - dosta³ kasê ze splita od %s",
                 money_count_copper( gch ) - share * multiplier,
                 money_count_copper( gch ),
                 share * multiplier,
                 ch->name
                );
            switch ( nomination )
            {
                case NOMINATION_COPPER:
                    gch->copper += share;
                    break;
                case NOMINATION_SILVER:
                    gch->silver += share;
                    break;
                case NOMINATION_GOLD:
                    gch->gold += share;
                    break;
                case NOMINATION_MITHRIL:
                    gch->mithril += share;
                    break;
            }
        }
    }
}
Beispiel #20
0
bool valid_target( CHAR_DATA * ch, CHAR_DATA * victim, int l )
{
    /*
     * Return TRUE if victim is a valid target for ch to kill.
     */

    /*
     * don't hunt people you can't even see
     */
    if ( !can_see( ch, victim ) )
        return FALSE;

    /*
     * Don't attack group members or self!
     */
    if ( is_same_group( ch, victim ) )
        return FALSE;

    /*
     * Don't attack other int mobs!
     */
    if ( IS_NPC( victim ) && AI_MOB(victim) )
        return FALSE;

    /*
     * Don't attack players.... except for have spec_vamp_hunter
     */
    if ( ( !IS_NPC( victim ) ) && ( !IS_NPC(ch) && ( ch->npcdata->spec_fun != spec_lookup( "spec_vamp_hunter" ) ) ) )
        return FALSE;

    /*
     * don't attack fairy godmother
     */
    if ( IS_NPC( victim ) )
        if ( victim->npcdata->pIndexData->vnum == 1026 )
            return FALSE;


    /*
     * if IS vamp_hunter, make sure target is a player vamp
     */

    if ( ( IS_VAMP( victim ) ) && ( !IS_NPC( victim ) ) && ( !IS_NPC(ch) && ( ch->npcdata->spec_fun != spec_lookup( "spec_vamp_hunter" ) ) ) )
        return FALSE;

    /*
     * don't attack NPC VAMPS (they can't die )
     */
    if ( ( IS_VAMP( victim ) ) && ( IS_NPC( victim ) ) )
        return FALSE;

    /*
     * Only kill victims of similar level
     */
    if ( ( ( victim->get_level("psuedo") - ch->get_level("psuedo") ) > -7 )
            || ( ( ch->get_level("psuedo") - victim->get_level("psuedo") ) > 12 ) )
        return FALSE;

//   if ( ( IS_GOOD( ch )    && IS_GOOD( victim    ) )
//   || (   IS_EVIL( ch )    && IS_EVIL( victim    ) )
//   || (   IS_NEUTRAL( ch ) && IS_NEUTRAL( victim ) ) )
//      return FALSE;

    if ( ( !IS_NPC(ch) && ( ch->npcdata->spec_fun == spec_lookup( "spec_vamp_hunter" ) ) ) && ( IS_NPC( victim ) ) && ( number_percent(  ) < 20 ) )
        return FALSE;

    if ( victim->in_room->room_flags.test(RFLAG_SAFE) || victim->act.test(ACT_SOLO) )
        /*
         * || ( IS_SET( victim->in_room->room_flags, ROOM_JAIL_CELL ) )
         */
        return FALSE;

    return TRUE;
}
/* for auto assisting */
void check_assist(CHAR_DATA *ch,CHAR_DATA *victim)
{
    CHAR_DATA *rch, *rch_next;

    for (rch = ch->in_room->people; rch != NULL; rch = rch_next)
    {
	rch_next = rch->next_in_room;
	
	if (IS_AWAKE(rch) && rch->fighting == NULL
		&& SAME_PLANE(ch,victim))
	{

	    if (!IS_NPC(ch) || IS_AFFECTED(ch,AFF_CHARM))
	    {
		if ( IS_AFFECTED(rch,AFF_CHARM)
		&&   is_same_group(ch,rch) )
		    multi_hit (rch,victim,TYPE_UNDEFINED);
		
		continue;
	    }

            /* quick check for ASSIST_PLAYER */
            if (!IS_NPC(ch) && IS_NPC(rch)
            && IS_SET(rch->off_flags,ASSIST_PLAYERS))
            {
                do_function(rch, &do_emote,"screams and attacks!");
                multi_hit(rch,victim,TYPE_UNDEFINED);
                continue;
            }
  	
	    /* now check the NPC cases */
	    
 	    if (IS_NPC(ch) && !IS_AFFECTED(ch,AFF_CHARM))
	
	    {
		if ( (IS_NPC(rch) && IS_SET(rch->off_flags,ASSIST_ALL))

		||   (IS_NPC(rch) && rch->group && rch->group == ch->group)

		||   (IS_NPC(rch) && rch->race == ch->race 
		   && (rch->race != victim->race))

                ||   (rch->pIndexData == ch->pIndexData
                   && IS_SET(rch->off_flags,ASSIST_VNUM)))

	   	{
		    CHAR_DATA *vch;
		    CHAR_DATA *target;
		    int number;

		    if (number_bits(1) == 0)
			continue;
		
		    target = NULL;
		    number = 0;
		    for (vch = ch->in_room->people; vch; vch = vch->next)
		    {
			if (can_see(rch,vch)
			&&  is_same_group(vch,victim)
			&&  number_range(0,number) == 0)
			{
			    target = vch;
			    number++;
			}
		    }

		    if (target != NULL)
		    {
			do_function(rch, &do_emote,"leaps into the fray!");
			multi_hit(rch,target,TYPE_UNDEFINED);
		    }
		}	
	    }
	}
    }
}
Beispiel #22
0
void mob_group_follow( CHAR_DATA * ch, CHAR_DATA * target )
{
    char buf[MAX_STRING_LENGTH];
    CHAR_DATA *vch;
    int num;


    if ( ( ch == NULL ) || ( target == NULL ) )
    {
        snprintf( buf, MSL, "%s", "Null ch and/or target in mob_group_follow, exiting." );
        monitor_chan( buf, MONITOR_MOB );
        return;
    }
    snprintf( buf, MSL, "Ok guys, let's all follow %s.", target->get_name() );
    do_say( ch, buf );

    for ( vch = ch->in_room->first_person; vch != NULL; vch = vch->next_in_room )
    {
        if ( ( ch != vch ) && ( AI_MOB( vch ) ) && ( is_same_group( ch, vch ) ) )
        {
            if ( vch->position != POS_STANDING )
                do_stand( vch, "" );

            num = number_percent(  );

//  WAIT_STATE( vch, 275 );

            if ( num > 85 )
                do_say( vch, "Ok boss.  Whatever you say." );
            else if ( num > 70 )
                do_say( vch, "Alright!  More people, more power!" );
            else if ( num > 55 )
                do_say( vch, "Whoo Hooo!" );
            else if ( num > 35 )
                do_say( vch, "Sure thing." );
            else if ( num > 29 )
            {
                if ( num > 32 )
                    snprintf( buf, MSL, "Man I don't want to join %s's group!", target->get_name() );
                else
                    snprintf( buf, MSL, "I hate big groups." );
                do_say( vch, buf );
                do_follow( vch, const_cast<char *>(vch->name.c_str()) );
                do_say( vch, "I'm outta here." );
                do_recall( vch, "" );
                continue;
            }

            if ( !can_see( vch, target ) )
            {
                vch->master = target;
                vch->leader = NULL;
            }
            else
            {
                do_follow( vch, const_cast<char *>(target->name.c_str()) );
            }
            do_group( target, "all" );

        }
    }
    return;
}
Beispiel #23
0
/*
 * 'Split' originally by Gnort, God of Chaos.
 */
void do_split( CHAR_DATA * ch, char * argument ) {
  CHAR_DATA * gch;
  char        buf[ MAX_STRING_LENGTH ];
  char        arg[ MAX_INPUT_LENGTH  ];
  int         members;
  int         amount = 0;
  int         share  = 0;
  int         extra  = 0;
  MONEY_DATA  amt;
  char        arg2[ MAX_STRING_LENGTH ];

  argument = one_argument( argument, arg );
  argument = one_argument( argument, arg2 );

  if ( arg[ 0 ] == '\0' ) {
    send_to_char( AT_YELLOW, "Split how much?\n\r", ch );
    return;
  }

  /* split 5 copper,gold,silver */

  amount   = is_number( arg ) ? atoi( arg ) : 0;
  amt.gold = amt.silver = amt.copper = 0;

  if ( !str_cmp( arg2, "gold" ) ) {
    amt.gold = amount;
  } else if ( !str_cmp( arg2, "silver" ) ) {
    amt.silver = amount;
  } else if ( !str_cmp( arg2, "copper" ) ) {
    amt.copper = amount;
  } else {
    send_to_char( AT_WHITE, "&WSyntax: &Rsplit <amount> <currency type>\n\r",
                  ch );
    return;
  }

  if ( ( amt.gold < 0 ) || ( amt.silver < 0 )
       || ( amt.copper < 0 ) ) {
    send_to_char( AT_YELLOW, "Your group wouldn't like that.\n\r", ch );
    return;
  }

  if ( ( amt.gold == 0 ) && ( amt.silver == 0 )
       && ( amt.copper == 0 ) ) {
    send_to_char( AT_YELLOW, "You hand out zero coins, but no one notices.\n\r",
                  ch );
    return;
  }

  if ( ( ch->money.gold < amt.gold ) || ( ch->money.silver < amt.silver )
       || ( ch->money.copper < amt.copper ) ) {
    sprintf( buf, "You don't have that many %s coins.\n\r", arg2 );
    send_to_char( AT_YELLOW, buf, ch );
    return;
  }

  members = 0;

  for ( gch = ch->in_room->people; gch; gch = gch->next_in_room ) {
    if ( gch->deleted ) {
      continue;
    }

    if ( is_same_group( gch, ch ) ) {
      members++;
    }
  }

  if ( members < 2 ) {
    return;
  }

  share = amount / members;
  extra = amount % members;

  if ( share == 0 ) {
    send_to_char( AT_YELLOW, "Don't even bother, cheapskate.\n\r", ch );
    return;
  }

  if ( !str_cmp( arg2, "gold" ) ) {
    ch->money.gold -= amount;
    ch->money.gold += share + extra;
  } else if ( !str_cmp( arg2, "silver" ) ) {
    ch->money.silver -= amount;
    ch->money.silver += share + extra;
  } else if ( !str_cmp( arg2, "copper" ) ) {
    ch->money.copper -= amount;
    ch->money.silver += share + extra;
  }

  sprintf( buf,
           "You split %s  Your share is %d %s coins.\n\r",
           money_string( &amt ), share + extra, arg2 );
  send_to_char( AT_YELLOW, buf, ch );

  sprintf( buf, "$n splits %s  Your share is %d %s coins.",
           money_string( &amt ), share, arg2 );

  for ( gch = ch->in_room->people; gch; gch = gch->next_in_room ) {
    if ( gch->deleted ) {
      continue;
    }

    if ( gch != ch && is_same_group( gch, ch ) ) {
      act( C_DEFAULT, buf, ch, NULL, gch, TO_VICT );
      gch->money.gold += ( !str_cmp( arg2, "gold" ) ) ?
                         share : 0;
      gch->money.silver += ( !str_cmp( arg2, "silver" ) ) ?
                           share : 0;
      gch->money.copper += ( !str_cmp( arg2, "copper" ) ) ?
                           share : 0;
    }
  }

  return;
}
Beispiel #24
0
void get_mob_group( CHAR_DATA * ch, CHAR_DATA * target )
{
    CHAR_DATA *vch;
    bool ch_is_leader = FALSE;
    bool tar_is_leader = FALSE;
    bool is_hunting = FALSE;
    bool ch_is_higher = FALSE;
    char buf[MAX_STRING_LENGTH];
    int number_of_tar_group = 1;
    int number_of_ch_group = 1;

    ch_is_leader = is_group_leader( ch );
    tar_is_leader = is_group_leader( target );

    if ( tar_is_leader == TRUE )
    {
        for ( vch = ch->in_room->first_person; vch != NULL; vch = vch->next_in_room )
        {
            if ( !AI_MOB( vch ) )
            {
                continue;
            }
            if ( vch != target && is_same_group( vch, target ) )
            {
                number_of_tar_group = number_of_tar_group + 1;
                continue;
            }
            if ( vch != ch && is_same_group( ch, vch ) )
            {
                number_of_ch_group = number_of_ch_group + 1;
                continue;
            }
        }
    }

    do_say( ch, "Hello there.  What are you up to?" );

//   WAIT_STATE( target, 560 );

    if ( target->hunting != NULL )
    {
        is_hunting = TRUE;
        if ( tar_is_leader == TRUE )
        {
            snprintf( buf, MSL, "We're planning on killing %s.", target->hunting->get_name() );
        }
        else
        {
            snprintf( buf, MSL, "I'm planning on killing %s.", target->hunting->get_name() );
        }
        do_say( target, buf );
    }
    else
    {
        do_say( target, "Nothing.  Just hanging around." );
    }

    WAIT_STATE( ch, 275 );

    /*
     * check to see which of the two is higher. the higher mob will lead
     */
    if ( ch->get_level("psuedo") >= target->get_level("psuedo") )
        ch_is_higher = TRUE;

    /*
     * if ch is higher in levels and victim is hunting, then say
     * * appropriate line.
     */
    if ( ( ch_is_higher == FALSE ) && ( is_hunting == TRUE ) )
    {
        do_say( ch, "Oh really?  Cool!  Need any help?" );
    }
    else if ( ( ch_is_higher == FALSE ) && ( is_hunting == FALSE ) )
    {
        do_say( ch, "Great!  Since you're not doing anything, wanna group?" );
    }
    else if ( ( ch_is_higher == TRUE ) && ( is_hunting == TRUE ) )
    {
        if ( ch_is_leader == TRUE )
        {
            snprintf( buf, MSL, "Want to help us kill %s instead?", ch->hunting->get_name() );
            do_say( ch, buf );
        }
        else if ( ch_is_leader == FALSE )
        {
            snprintf( buf, MSL, "Want to help me kill %s instead?", ch->hunting->get_name() );
            do_say( ch, buf );
        }
    }
    else if ( ( ch_is_higher == TRUE ) && ( ch->hunting == FALSE ) )
    {
        do_say( ch, "Want to group?" );
    }
    WAIT_STATE( target, 275 );

    if ( ch_is_higher == TRUE )
    {
        do_say( target, "Ok sure!  Thanks for asking." );

        if ( tar_is_leader == TRUE )
        {
            mob_group_follow( target, ch );
        }
        do_follow( target, const_cast<char *>(ch->name.c_str()) );
        do_group( ch, const_cast<char *>(target->name.c_str()) );
    }
    else
    {
        do_say( target, "Ok, why not!?  Follow me." );

        WAIT_STATE( ch, 275 );

        do_say( ch, "Cool!" );

        if ( ch_is_leader == TRUE )
        {
            mob_group_follow( ch, target );
        }
        do_follow( ch, const_cast<char *>(target->name.c_str()) );
        do_group( target, const_cast<char *>(target->name.c_str()) );
    }
    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;
}
Beispiel #26
0
/* checks to see if mob needs to stand up for any reason, if so then stand. */
void need_to_stand( CHAR_DATA * ch )
{
    int current_state;
    CHAR_DATA *vch;

    current_state = ch->position;

    /*
     * if someone in your group is fighting, get up
     */
    for ( vch = ch->in_room->first_person; vch != NULL; vch = vch->next_in_room )
    {
        if ( ( is_same_group( ch, vch ) ) && ( vch->position == POS_FIGHTING ) )
        {
            get_up( ch, current_state );
            return;
        }
    }

    /*
     * if your leader is up and ready to move, get up
     */
    if ( ( ch->leader != NULL )
            && ( ch->in_room == ch->leader->in_room )
            && ( ch->leader->position == POS_STANDING )
            && ( ch->leader->hit >= ch->leader->max_hit * 85 / 100 ) && ( ch->leader->mana >= ch->leader->max_mana * 85 / 100 ) )
    {
        get_up( ch, current_state );
        return;
    }


    /*
     * Do you need heal? if so, can you heal?
     */
    if ( ch->hit < ch->max_hit * 85 / 100 )
    {
        if ( ( ch->mana >= mana_cost( ch, skill_lookup( "heal" ) ) )
                || ( ch->mana >= mana_cost( ch, skill_lookup( "cure critical" ) ) )
                || ( ch->mana >= mana_cost( ch, skill_lookup( "cure serious" ) ) ) )
        {
            get_up( ch, current_state );
            return;
        }

    }

    /*
     * if there is an int mob in the room stand so that you can group with
     * * it
     */
    if ( ch->leader == NULL )
    {
        for ( vch = ch->in_room->first_person; vch != NULL; vch = vch->next_in_room )
        {
            if ( ( AI_MOB( vch ) )
                    && ( vch->leader == NULL )
                    && ( !is_same_group( vch, ch ) )
                    && ( AI_MOB(vch) )
                    && ( vch != ch )
                    && ( ( vch->get_level("psuedo") - ch->get_level("psuedo") <= 20 )
                         && ( vch->get_level("psuedo") - ch->get_level("psuedo") >= -20 ) ) )
            {
                get_up( ch, current_state );
                return;
            }
        }
    }

    /*
     * if you're ready to move, stand
     */
    if ( ( ch->hit >= ch->max_hit * 85 / 100 ) && ( ch->mana >= ch->max_mana * 85 / 100 ) )
        get_up( ch, current_state );

    return;
}
Beispiel #27
0
void mob_is_fighting( CHAR_DATA * ch )
{
    CHAR_DATA *vch;
    CHAR_DATA *target = NULL;
    bool is_being_attacked = FALSE;
    bool need_flee = FALSE;

    /*
     * check to see if you are the one being attacked
     */
    for ( vch = ch->in_room->first_person; vch != NULL; vch = vch->next_in_room )
    {
        if ( vch->fighting == ch )
        {
            is_being_attacked = TRUE;
            break;
        }
    }

    /*
     * if you have a leader and he/she is present, they should rescue you if
     * * you are being attacked, else you should check on them in case they
     * * need heals
     */
    if ( ( ch->leader != NULL ) && ( ch->leader->in_room == ch->in_room ) )

    {
        target = ch->leader;

        if ( is_being_attacked == TRUE && target != ch )
        {
            do_rescue( target, const_cast<char *>(ch->name.c_str()) );
        }
        else if ( target->hit < target->max_hit * 50 / 100 )
            mob_regen_check( ch, target, need_flee );
        else
        {
            for ( vch = ch->in_room->first_person; vch != NULL; vch = vch->next_in_room )
            {
                if ( ( is_same_group( ch, vch ) ) && ( vch->hit < vch->max_hit * 20 / 100 ) )
                {
                    mob_regen_check( ch, vch, need_flee );
                    return;
                }
            }
        }

        return;
    }


    /*
     * if flow reaches here, you are the tank
     */
    /*
     * either heal yourself or flee
     */
    if ( ch->hit < ch->max_hit * 50 / 100 )
    {
        if ( ch->hit < ch->max_hit * 20 / 100 )
            need_flee = TRUE;
        mob_regen_check( ch, target, need_flee );
    }

    return;
}
Beispiel #28
0
void mob_is_standing( CHAR_DATA * ch )
{
    short dir;
    CHAR_DATA *vch;
    CHAR_DATA *tch;
    list<CHAR_DATA *>::iterator li;
    bool ready = TRUE;
    bool prey_still_exist = FALSE;
    int number_got_up = 0;
    int number_of_group = 1;
    int number_of_other_group = 1;

    /*
     * get a light source
     */
    if ( ch->in_room->light <= 0 )
    {
        if ( ch->mana >= mana_cost( ch, skill_lookup( "continual light" ) ) )
        {
            do_cast( ch, "'continual light'" );
            do_get( ch, "all" );
            do_wear( ch, "all" );
            return;
        }
    }

    if ( ( IS_AFFECTED( ch, AFF_POISON ) ) || ( IS_AFFECTED( ch, AFF_BLIND ) ) )
    {
        if ( IS_AFFECTED( ch, AFF_POISON ) )
            if ( ch->mana >= mana_cost( ch, skill_lookup( "cure poison" ) ) )
                do_cast( ch, "'cure poison'" );
        if ( IS_AFFECTED( ch, AFF_BLIND ) )
            if ( ch->mana >= mana_cost( ch, skill_lookup( "cure blindness" ) ) )
                do_cast( ch, "'cure blindness'" );
        return;
    }

    /*
     * is anyone in group being attacked? if so, assist!
     */
    /*
     * -leaders will be forced to rescue in the 'mob_is_fighting' function
     * * already so no need to check for it here
     */
    for ( vch = ch->in_room->first_person; vch != NULL; vch = vch->next_in_room )
    {
        if ( ( is_same_group( ch, vch ) ) && ( vch->fighting != NULL ) && ( vch != ch ) )
        {
            do_assist( ch, "" );
            return;
        }
    }
    if ( ch->leader == NULL )
    {
        for ( vch = ch->in_room->first_person; vch != NULL; vch = vch->next_in_room )
        {
            if ( is_same_group( ch, vch ) && ( ch != vch ) )
            {
                number_of_group = number_of_group + 1;
            }
        }
        if ( number_of_group < 4 )
        {
            for ( vch = ch->in_room->first_person; vch != NULL; vch = vch->next_in_room )
            {
                if ( vch->leader != NULL )
                    continue;

                if ( ( vch != ch ) && ( IS_NPC( vch ) )
                        && ( AI_MOB(vch) )
                        && ( !is_same_group( ch, vch ) )
                        && ( vch->position == POS_STANDING )
                        && ( ( vch->get_level("psuedo") - ch->get_level("psuedo") <= 20
                               && vch->get_level("psuedo") - ch->get_level("psuedo") >= -20 )
                             || ( ch->get_level("psuedo") - vch->get_level("psuedo") <= 20
                                  && ch->get_level("psuedo") - vch->get_level("psuedo") >= -20 ) )
                        && ( can_see( vch, ch ) ) && ( can_see( ch, vch ) ) )

                {
                    if ( vch->leader == NULL )
                    {
                        for ( tch = vch->in_room->first_person; tch != NULL; tch = tch->next_in_room )
                        {
                            if ( is_same_group( tch, vch ) && ( tch != vch ) )
                            {
                                number_of_other_group = number_of_other_group + 1;
                            }
                        }
                    }

                    if ( number_of_group + number_of_other_group <= 4 )
                    {
                        get_mob_group( ch, vch );
                        return;
                    }
                }
            }
        }
    }

    /*
     * do you need to heal?
     */
    if ( ch->hit < ch->max_hit * 85 / 100 )
    {
        if ( ( ch->mana >= mana_cost( ch, skill_lookup( "heal" ) ) )
                || ( ch->mana >= mana_cost( ch, skill_lookup( "cure critical" ) ) )
                || ( ch->mana >= mana_cost( ch, skill_lookup( "cure serious" ) ) ) )

            mob_regen_check( ch, NULL, FALSE );

        /*
         * if leader is ready to move, just keep standing
         */
        if ( ( ch->leader != NULL )
                && ( ch->leader->in_room == ch->in_room )
                && ( ch->leader->position == POS_STANDING )
                && ( ch->leader->mana >= ch->leader->max_mana * 85 / 100 )
                && ( ch->leader->hit >= ch->leader->max_hit * 85 / 100 ) )
            return;
        else
        {
            if ( ch->mana >= ch->max_mana * 75 / 100 )
                ready = ready_heal_room( ch );

            if ( ready == TRUE )
                do_sleep( ch, "" );

            return;
        }
    }


    if ( ch->mana < ch->max_mana * 85 / 100 )
    {
        do_sleep( ch, "" );
        return;
    }


    /*
     * do you need to level? if you have a group leader, have the leader
     * * find a the trainer. if you are the leader just go and find the
     * * trainer
     */

// ZEN FIX Have them recall then hunt the room

    if ( able_to_level( ch ) )
    {
        char_from_room( ch );
        char_to_room( ch, get_room_index( 3758 ) );
        gain_level( ch );
        return;
        /*
              dir = h_find_dir ( get_room_index(ch->in_room->vnum),
                     get_room_index(ROOM_VNUM_INT_HEAL),
                     ch->hunt_flags );

              if (  dir == -1  )
             gain_level ( ch );
              else
              {
             if (  ( ch->leader != NULL )
                && ( ch->leader->in_room == ch->in_room )  )
             {
                hunt_move ( ch->leader, dir );
                end_hunt ( ch->leader );
                return;
             }
             else
             {
                hunt_move ( ch, dir );
                return;
             }
              }  */
    }

    /*
     * if you're leader and you don't need to gain level, does anyone else
     * * in the group?
     */
    /*
     * actually, the above function will force the leader to find a trainer
     * * already.  but since i don't want the leader to select a new target
     * * until the group gains the needed level, i'll put this check here
     */
    for ( vch = ch->in_room->first_person; vch != NULL; vch = vch->next_in_room )
    {
        if ( ( is_same_group( vch, ch ) )
                && ( vch->in_room == ch->in_room ) && ( vch->leader == ch ) && ( able_to_level( vch ) ) )
        {
            dir = h_find_dir( get_room_index( ch->in_room->vnum ), get_room_index( ROOM_VNUM_INT_HEAL ), ch->hunt_flags );
            hunt_move( ch, dir );
            return;
        }
    }

    /*
     * if noone needs to heal or gain level, then let's hunt!
     */
    /*
     * by the way, only leaders will hunt. followers will just follow and
     * * assist when needed
     */
    if ( ( ch->leader != NULL ) && ( ch->leader->in_room == ch->in_room ) && ( ch->hunting != NULL ) )
    {
        end_hunt( ch );
    }
    else if ( ( ch->leader != NULL ) && ( ch->leader->in_room == ch->in_room ) && ( ch->hunting == NULL ) )
    {
        return;
    }
    else if ( is_group_leader( ch ) )
    {
        for ( vch = ch->in_room->first_person; vch != NULL; vch = vch->next_in_room )
        {
            if ( ( vch != ch ) && ( is_same_group( vch, ch ) ) && ( vch->position != POS_STANDING ) )
            {
                get_up( vch, vch->position );
                number_got_up = number_got_up + 1;
            }
        }
        if ( number_got_up != 0 )
            return;
    }
    else
    {
        if ( ch->hunting != NULL )
        {
            for ( li = char_list.begin(); li != char_list.end(); li++ )
            {
                vch = *li;
                if ( vch == ch->hunting )
                {
                    prey_still_exist = TRUE;
                    return;
                }
            }

            if ( prey_still_exist == FALSE )
            {
                ch->hunting = NULL;
            }
        }
        if ( ch->hunting == NULL && ch->leader == NULL )
        {
            select_target( ch );
            return;
        }
    }

    /*
     * power_up_mob ( ch );
     */

    /*
     * if (  ch->leader != NULL
     * && ch->in_room != ch->leader->in_room )
     * {
     * do_follow( ch, ch->name );
     * }
     */

    return;

}
Beispiel #29
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;
}
Beispiel #30
0
void do_crusade(CHAR_DATA *ch, char *argument)
{
    DESCRIPTOR_DATA* d;
    CHAR_DATA *questman;
    CHAR_DATA *boss;
    char buf  [MAX_STRING_LENGTH];
    char arg1 [MAX_INPUT_LENGTH];
    char arg2 [MAX_INPUT_LENGTH];

    argument = one_argument(argument, arg1);
    argument = one_argument(argument, arg2);

    if (arg1[0] == '\0')
    {
        send_to_char(AT_WHITE, "CRUSADE commands: POINTS INFO TIME REQUEST COMPLETE LIST BUY ADVANCE.\n\r",ch);
        send_to_char(AT_WHITE, "For more information, type 'HELP CRUSADE'.\n\r",ch);
        return;
    }

    if (!str_cmp(arg1, "time"))
    {
	if (IS_SET(ch->act2, PLR_RELQUEST))
	{
		sprintf(buf, "You have %d minutes left on your crusade!\n\r", ch->rcountdown);
	} else
	{
		if (ch->rnextquest > 0)
		{
			sprintf(buf, "You have %d minutes left before your next crusade!\n\r", ch->rnextquest);
		} else
		{
			strcpy(buf, "You are free to do a crusade right now!\n\r");
		}
	}
	send_to_char(AT_WHITE, buf, ch);
	return;
    } else if (!str_cmp(arg1, "points"))
    {
	sprintf(buf, "You have %d relgion points.\n\r", ch->rquestpoints);
	send_to_char(AT_WHITE, buf, ch);
	return;
    } else if (!str_cmp(arg1, "info"))
    {
	OBJ_INDEX_DATA* oinfo;
	MOB_INDEX_DATA* minfo;

	if (!IS_SET(ch->act2, PLR_RELQUEST))
	{
		send_to_char(AT_WHITE, "You are not on a crusade!\n\r", ch);
		return;
	}

	if (ch->rquestobj[ch->relquest_level]==0 && ch->rquestmob[ch->relquest_level]==0)
	{
		if (ch->in_room->vnum <= REL_VNUM_UPPER && ch->in_room->vnum >= REL_VNUM_LOWER)
		{
			send_to_char(AT_WHITE, "You are almost finished your crusade.\n\rFind the portal to the next level!\n\r", ch);
			return;
		} else
		{
			send_to_char(AT_WHITE, "You are almost finished your crusade!\n\rFind your DEITY and COMPLETE you quest!\n\r",ch);
			return;
		}
	} 

	if (ch->rquestmob[ch->relquest_level])
	{
		if (ch->rquestmob[ch->relquest_level] == -1)
		{
			send_to_char(AT_WHITE, "You are almost done your crusade!\n\rFind the boss and ADVANCE!\n\r", ch);
			return;
		} else
		{
			minfo = get_mob_index( ch->rquestmob[ch->relquest_level] );
			sprintf(buf, "You are on a crusade to slay the dreaded %s!\n\r", minfo->short_descr);
		}
   	} else
	{
		oinfo = get_obj_index( ch->rquestobj[ch->relquest_level] );
		sprintf(buf, "You are on a crusade to retrieve the fabled %s!\n\r", oinfo->short_descr);
	}
	send_to_char(AT_WHITE, buf, ch);
	return; 
    }

    for ( questman = ch->in_room->people; questman != NULL; questman = questman->next_in_room)
    {
        if (!IS_NPC(questman)) continue;
        if (IS_SET(questman->act, ACT_IS_DEITY)) break;
    }

    for (boss = ch->in_room->people; boss; boss = boss->next_in_room)
    {
	if (!IS_NPC(boss)) continue;
	if (IS_SET(boss->act, ACT_RELBOSS)) break;
    }


    if (!str_cmp(arg1, "request"))
    {
        int member_count = 0;
	CHAR_DATA* group[MAX_GROUP];

  	if (questman==NULL)
        {
   		send_to_char(AT_WHITE, "Your deity is not here!\n\r", ch);
    	  	return;
        }


        if (IS_SET(ch->act2, PLR_RELQUEST))
	{
		send_to_char(AT_WHITE, "You are already ON a crusade!\n\r",ch);
		return;
	}
	if (relquest)
	{
		send_to_char(AT_WHITE, "The gods have already set a crusade to be finished!\n\r",ch);
		return;
	}
	if (ch->master)
	{
	    send_to_char(AT_WHITE, "Only your group leader can ask for a crusade!\n\r", ch);
	    return;
	}
	if (ch->alignment > -500 && ch->alignment < 500) /* || (ch->religion == TIME_AND_FATE */
	{
	    send_to_char(AT_WHITE, "You are neutral. You cannot go upon a crusade!\n\r",ch);
	    return;
	}
	if (ch->leader)
	{
	    send_to_char(AT_WHITE, "Only the leader of your group can request a crusade!\n\r", ch);
	    return;
	}
	for ( d = descriptor_list; d; d = d->next )
        {
	    RELIGION_DATA* rd = NULL;
	    CHAR_DATA* gch = NULL;

	    if ( d->connected != CON_PLAYING )
        	continue;

	    gch = d->character;

	    if ( !is_same_group(gch , ch ) )
                continue;

	    if ( gch->in_room != ch->in_room )
	    {
		send_to_char(AT_WHITE, "Your must gather your party before venturing forth!\n\r", ch);
		return;
	    }

	    if ( gch->rnextquest > 0 )
	    {
		sprintf(buf, "%s must wait before doing another crusade!\n\r", gch->name);
		send_to_char(AT_WHITE, "You must wait before your next Crusade!\n\r", gch);
		send_to_char(AT_WHITE, buf, ch);
		return;
	    }
          
	    if ( gch->level < REL_QUEST_MIN )
	    {
		sprintf(buf, "%s is not high enough level to do a Crusade!\n\r", gch->name);
		send_to_char(AT_WHITE, "You are not high enough level to complete a Crusade!\n\r", gch);
		send_to_char(AT_WHITE, buf, ch);
		return;
	    }

	    rd = get_religion_index( ch->religion );
/*
Quest Restriction to Deities
Out for debug
	    if (!strstr(questman->short_descr, rd->deity ) )
	    {
	        sprintf(buf, "%s would not appreciate you devoting your crusades to %s!\n\rFind your own Deity!\n\r", rd->deity, questman->short_descr);
		send_to_char(AT_WHITE, buf, ch);
		return;
	    }
*/
	    group[member_count] = gch;
	    member_count++;
	    if (ch->alignment >= 500)
	    {
		if (gch->alignment <= -500) /* || gch->religion == EVIL */
		{
		    sprintf(buf, "Your deity will not accept %s upon your crusade!\n\r", gch->name);
		    send_to_char(AT_WHITE, buf, ch);
		    return;
		}
	    } else if (ch->alignment <= -500)
	    {
		if (gch->alignment >= 500) /* || gch->religion == GOOD */
		{
		    sprintf(buf, "Your deity will not accept %s upon your crusade!\n\r", gch->name);
		    send_to_char(AT_WHITE, buf, ch);
		    return;
		}
	    }
        }
        if (member_count < 2)
	{
	    send_to_char(AT_WHITE, "You need 2 or more heroes for a crusade!\n\r", ch);
	    return;
	}
        if (ch->alignment >= 500)
        {
 	    int levels = (((((ch->level > LEVEL_DEMIGOD) ? LEVEL_DEMIGOD : ch->level )) - REL_QUEST_MIN)/(14))+1;
	    if(rel_quest_gen(ch, ALIGN_GOOD, levels))
            {
		int qtime = number_range(15, 45);
		int curmemb;
		relquest=TRUE;
		/* Made it... let's go! */

		rel_quest_goals(ch, levels, ALIGN_GOOD);
		for ( curmemb = 0; curmemb < member_count; curmemb++)
        	{
		    int i;
		    for (i = 0; i < levels; i++)
		    {
			group[curmemb]->rquestobj[i] = ch->rquestobj[i];
			group[curmemb]->rquestmob[i] = ch->rquestmob[i];
		    }
		    group[curmemb]->relquest_level = 0;
		    group[curmemb]->rcountdown = qtime;
	    	    SET_BIT(group[curmemb]->act2, PLR_RELQUEST);
		    char_from_room(group[curmemb]);
		    char_to_room  (group[curmemb], get_room_index( REL_VNUM_UPPER ) );
		    send_to_char( AT_WHITE, "The smell of honey and sweet perfume fills your nose!\n\r", group[curmemb]);
		    interpret( group[curmemb], "look" );
		    interpret( group[curmemb], "crusade info" );
		}
	        return;

	    } else
	    {
		bug("rel_quest_gen: Failed to create quest!",0);
	    }                
	} else if (ch->alignment <= -500)
	{
	    int levels = (((((ch->level > LEVEL_DEMIGOD) ? LEVEL_DEMIGOD : ch->level )) - REL_QUEST_MIN)/( 14 ))+1;
	    if(rel_quest_gen(ch, ALIGN_EVIL, levels))
     	    {
		int qtime = number_range(15, 45);
		int curmemb;
		relquest=TRUE;

		/* Made it... let's go! */
		rel_quest_goals(ch, levels, ALIGN_EVIL);
		for ( curmemb=0; curmemb < member_count; curmemb++)
        	{
		    int i;
		    for (i = 0; i < levels; i++)
		    {
			group[curmemb]->rquestobj[i] = ch->rquestobj[i];
			group[curmemb]->rquestmob[i] = ch->rquestmob[i];
		    }
		    group[curmemb]->relquest_level = 0;
		    group[curmemb]->rcountdown = qtime;
	    	    SET_BIT(group[curmemb]->act2, PLR_RELQUEST);
		    char_from_room(group[curmemb]);
		    char_to_room  (group[curmemb], get_room_index( REL_VNUM_LOWER ) );
		    send_to_char( AT_RED, "The flames of hell singe your armor!\n\r", group[curmemb]);
		    interpret( group[curmemb], "look" );
	   	    interpret( group[curmemb], "crusade info" );
		}
	        return;
	    } else
	    {
		bug("rel_quest_gen: Failed to create quest!",0);
	    }                

	}
    } else if (!str_cmp(arg1,"complete"))
    {
    	if (questman==NULL)
    	{
   		send_to_char(AT_WHITE, "Your deity is not here!\n\r", ch);
    		return;
        }

	if (IS_SET(ch->act2, PLR_RELQUEST) && ch->rcountdown > 0)
        {
	    CHAR_DATA* gch = NULL;
	    int qp;
	    qp = number_range( ch->level/4, ch->level/2);
	    if (ch->leader || ch->master)
	    {
		send_to_char(AT_WHITE, "Only the group leader can complete a crusade!\n\r", ch);
		return;
	    }
	    for (d=descriptor_list; d; d = d->next)
	    {     
	    	if ( d->connected != CON_PLAYING )
        		continue;
		if (is_same_group(d->character, ch))
		{
			if (d->character->in_room != ch->in_room)
			{
				send_to_char(AT_WHITE, "You must gather your party before completing a crusade!\n\r", ch);
				return;
			}
		}	    	
	    }
	    // the whole party is in the room
	    for (gch=ch->in_room->people; gch; gch=gch->next_in_room)
	    {
	    	if (is_same_group(ch, gch))
		{
			int gqp = number_fuzzy(qp);
			sprintf(buf, "You have gained %d religion points for your service!\n\r", gqp);
			send_to_char(AT_WHITE, "YAY! You completed your crusade!\n\r",gch);
			gch->rquestpoints += gqp;
    			gch->rnextquest = number_range(10, 30);
    			gch->rcountdown = 0;
			send_to_char(AT_WHITE, buf, gch);
	    		REMOVE_BIT(gch->act2, PLR_RELQUEST);
		}
	    }

	    relquest=FALSE; 
	    return;
        } else
	{
	    send_to_char(AT_WHITE, "You are not on a religious crusade!\n\r",ch);
	    return;
	}
    } else if(!str_cmp(arg1, "list"))
    {
    	if (questman==NULL)
    	{
   		send_to_char(AT_WHITE, "Your deity is not here!\n\r", ch);
    		return;
    	}

	send_to_char(AT_WHITE, "Nothing to list yet.\n\r", ch);
	return;
    } else if(!str_cmp(arg1, "buy"))
    {
    	if (questman==NULL)
    	{
   		send_to_char(AT_WHITE, "Your deity is not here!\n\r", ch);
    		return;
	}

	send_to_char(AT_WHITE, "Nothing to buy quite yet.\n\r", ch);
	return;
    } else if(!str_cmp(arg1, "advance"))
    {
	DESCRIPTOR_DATA* d;

	if(!IS_SET(ch->act2, PLR_RELQUEST))
	{
		send_to_char(AT_WHITE, "You cannot advance a crusade if you are not on one!\n\r", ch);
		return;
	}
	if(ch->leader || ch->master)
	{
		send_to_char(AT_WHITE, "Only the group leader can advance a crusade!\n\r", ch);
		return;
	}
	
	if (!boss)
	{
		send_to_char(AT_WHITE, "You need to find the boss of this level before you can advance!\n\r", ch);
		return;
	}

	if (ch->rquestmob[ch->relquest_level] > 0 && ch->rcountdown > 0)
	{
		send_to_char(AT_WHITE, "You have not completed this section of your crusade!\n\r", ch);
		return;
	} else if (ch->rquestobj[ch->relquest_level] > 0 && ch->rcountdown > 0)
	{
		bool found = FALSE;
		OBJ_DATA* obj;
		for (obj = ch->carrying; obj; obj = obj->next)
		{
			if (obj->pIndexData->vnum == ch->rquestobj[ch->relquest_level])
			{
				found = TRUE;
				extract_obj(obj);
			}
		}
		if (!found)
		{
			send_to_char(AT_WHITE, "You have not completed this section of your crusade!\n\r", ch);
			return;
		}
	} 
	ch->rquestobj[ch->relquest_level]=0;
	ch->rquestmob[ch->relquest_level]=0;
	for (d=descriptor_list; d; d = d->next)
        {
                if ( d->connected != CON_PLAYING )
                        continue;
                if (is_same_group(d->character, ch))
                {
			d->character->rquestmob[ch->relquest_level] = 0;
			d->character->rquestobj[ch->relquest_level] = 0;
			send_to_char(AT_WHITE, "You feel free to pursue the next part of your crusade!\n\r", d->character);
		}
	} 
    } else
    {
        send_to_char(AT_WHITE, "CRUSADE commands: POINTS INFO TIME REQUEST COMPLETE LIST BUY ADVANCE.\n\r",ch);
        send_to_char(AT_WHITE, "For more information, type 'HELP CRUSADE'.\n\r",ch);
        return;
    }
}