예제 #1
0
파일: wear.c 프로젝트: huangleon/fy2005
int main(object me, string arg)
{
	object ob, *inv;
	int i, count;

	if( !arg ) return notify_fail("��Ҫ����ʲ�᣿\n");

	if(arg=="all") {
		inv = all_inventory(me);
		for(count=0, i=0; i<sizeof(inv); i++) {
			if( inv[i]->query("equipped") ) continue;
			if(do_wear(me, inv[i]) ) count ++;
		}
	if (!count)
		write("�ܴ��Ķ������ˡ�������\n");
		return 1;
	}

	if( !objectp(ob = present(arg, me)) )
		return notify_fail("������û������������\n");

	if( ob->query("equipped") )
		return notify_fail("���Ѿ��������ˡ�\n");

	return do_wear(me, ob);
}
예제 #2
0
int main(object me, string arg)
{
        object ob, *inv;
        int i, count;
 
        if( !arg ) return notify_fail("你要穿戴什么?\n");
        arg = lower_case(arg);
 
        if(arg=="all") {
                inv = all_inventory(me);
                for(count=0, i=0; i<sizeof(inv); i++) {
                        if( inv[i]->query("equipped") ) continue;
                        if(do_wear(me, inv[i]) ) count ++;
                }
                write("Ok.\n");
                return 1;
        }
 
        if( !objectp(ob = present(arg, me)) )
                return notify_fail("你身上没有这样东西。\n");
 
        if( ob->query("equipped") )
                return notify_fail("你已经装备着了。\n");
 
        return do_wear(me, ob);
}
예제 #3
0
void
read_pack(object *pack, FILE *fp, boolean is_rogue)
{
    object read_obj, *new_obj;

    for (;;) {
	r_read(fp, (char *) &read_obj, sizeof(object));
	if (read_obj.ichar == 0) {
	    pack->next_object = (object *) 0;
	    break;
	}
	new_obj = alloc_object();
	*new_obj = read_obj;
	if (is_rogue) {
	    if (new_obj->in_use_flags & BEING_WORN) {
		do_wear(new_obj);
	    } else if (new_obj->in_use_flags & BEING_WIELDED) {
		do_wield(new_obj);
	    } else if (new_obj->in_use_flags & (ON_EITHER_HAND)) {
		do_put_on(new_obj, ((new_obj->in_use_flags & ON_LEFT_HAND)
				    ? 1 : 0));
	    }
	}
	pack->next_object = new_obj;
	pack = new_obj;
    }
}
예제 #4
0
파일: monster.c 프로젝트: dworkin/gurbalib
void set_wearing( mixed obj ) {
    object armor;

    if( !obj )
        return;

    if( typeof(obj) == T_STRING ) {
        /* We've got to compile our own copy */
        armor = clone_object( obj );
        if( armor ) {
            armor->setup();
            armor->move( this_object() );
            if( !query_slot( armor->query_slot() ) ) {
                do_wear( armor );
            }
        }
    } else {
        obj->move( this_object() );
        if( !query_slot( obj->query_slot() ) ) {
            do_wear( obj );
        }
    }
}
예제 #5
0
파일: slims.c 프로젝트: bbailey/gurbalib
void setup(void) {
   object obj;

   set_name("slim");
   set_gender( "male" );
   add_adj("large");
   set_short("Slim shady");
   set_long("This guy is skinny, he is also kind of creepy looking.  He " +
      "reminds you of an anemic scarecrow.");

   set_race("human");
   set_level(1);
   set_hit_skill("combat/unarmed");
   set_skill("combat/unarmed", 50);
   set_skill("combat/defense", 100);
   set_aggressive(0);

   obj = clone_object(DIR + "/obj/10ghat.c");
   obj->setup();
   obj->move(this_object());
   do_wear(obj);
}
예제 #6
0
파일: act_mob.c 프로젝트: Catcheeto/ackfuss
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;

}
예제 #7
0
void do_mpjump( CHAR_DATA *ch, char *argument )
{
    char			arg[ MAX_INPUT_LENGTH ];
    char			arg2[ MAX_INPUT_LENGTH ];
    char			arg3[ MAX_INPUT_LENGTH ];
    char			thingbuf[MAX_STRING_LENGTH];
    CHAR_DATA		*victim;
    OBJ_INDEX_DATA	*pObjIndex;
    OBJ_DATA		*obj;
    int			level;

    if ( !IS_NPC( ch ) )
    {
	typo_message( ch );
	return;
    }

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

    if ( arg[0] == '\0' || arg2[0] == '\0' ||
         arg3[0] == '\0' )
    {
        sprintf( log_buf, "MpJump - no argument: vnum %d name %s short %s.",
                 ch->pIndexData->vnum, ch->name, ch->short_descr );
        bug( log_buf, -1 );
    }

    if ( !is_number( arg2 ) )
    {
        sprintf( log_buf, "Mpjump - Bad syntax: vnum %d name %s short %s.",
                ch->pIndexData->vnum, ch->name, ch->short_descr );
        bug( log_buf, -1 );
        return;
    }

    if ( ( victim = get_char_room( ch, arg ) ) == NULL )
    {
        sprintf( log_buf, "MpJump - Victim not in room: vnum %d name %s short %s .",
                 ch->pIndexData->vnum, ch->name, ch->short_descr );
        bug( log_buf, -1 );
	return;
    }

    if ( victim == ch )
    {
        sprintf( log_buf, "MpJump - Bad victim to attack: vnum %d name %s short %s.",
                 ch->pIndexData->vnum, ch->name, ch->short_descr );
        bug( log_buf, -1 );
	return;
    }

    if ( ( pObjIndex = get_obj_index( atoi( arg2 ) ) ) == NULL )
    {
        sprintf( log_buf, "Mpjump - Bad vnum arg: vnum %d name %s short %s.",
                ch->pIndexData->vnum, ch->name, ch->short_descr );
        bug( log_buf, -1 );
	return;
    }

 
    if ( arg3[0] == '\0' )
    {
    	level = pObjIndex->level;
    }
    else
    {
	/*
	 * New feature from Alander.
	 */
        if ( !is_number( arg3 ) )
        {
            sprintf( log_buf, "Mpjump - Bad syntax: vnum %d name %s short %s.",
                     ch->pIndexData->vnum, ch->name, ch->short_descr );
            bug( log_buf, -1 );
	    return;
        }
	level = atoi( arg3 );
	if ( level < 0 || level > get_trust( ch ) )
	{
            sprintf( log_buf, "Mpjump - Bad level: vnum %d name %s short %s.",
                     ch->pIndexData->vnum, ch->name, ch->short_descr );
            bug( log_buf, -1 );
	    return;
	}
    }

    obj = create_object( pObjIndex, level );
    if ( !CAN_WEAR(obj, ITEM_TAKE) )
    {
     sprintf( log_buf, "Mpjump - Bad level: vnum %d name %s short %s.",
              ch->pIndexData->vnum, ch->name, ch->short_descr );
     bug( log_buf, -1 );
     return;
    }
    else

    obj_to_char( obj, victim );
    one_argument( obj->name, thingbuf );
    do_wear( victim, thingbuf );
    return;
}