immtake

Posted by Ithildin on Thu 20 May 2004 07:22 AM — 3 posts, 14,664 views.

USA #0
ok, i'm making a new command for high level imms. this command is like steal, but only it takes an item from the player without them seeing it. i'm wanting this command to be able to take from the character's get_obj_wear list as well. here's my code so far:


void do_immtake( CHAR_DATA *ch, char *argument )
{
   // char buf  [MAX_STRING_LENGTH];
    char arg1 [MAX_INPUT_LENGTH];
    char arg2 [MAX_INPUT_LENGTH];
  //  CHAR_DATA *victim, *mst;
	CHAR_DATA *victim;
    OBJ_DATA *obj;
 //   int percent;

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

    

    if ( arg1[0] == '\0' || arg2[0] == '\0' )
    {
	send_to_char( "Take what from whom?\n\r", ch );
	return;
    }

    if ( ms_find_obj(ch) )
	return;

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

    if ( victim == ch )
    {
	send_to_char( "That's pointless.\n\r", ch );
	return;
    }

    if ( !str_cmp( arg1, "coin"  )
    ||   !str_cmp( arg1, "coins" )
    ||   !str_cmp( arg1, "gold"  ) )
    {
	int amount;

	amount = (int) (victim->gold * number_range(1, 10) / 100);
	if ( amount <= 0 )
	{
	    send_to_char( "You couldn't get any gold.\n\r", ch );
	    
	    return;
	}

	ch->gold     += amount;
	victim->gold -= amount;
	ch_printf( ch, "Aha!  You got %d gold coins.\n\r", amount );
	
	return;
    }

    if ( ( obj = get_obj_carry( victim, arg1 ) ) == NULL )<-this is the problem i think. 
    {
	send_to_char( "You can't seem to find it.\n\r", ch );
	
	return;
    }

    separate_obj( obj );
    obj_from_char( obj );
    obj_to_char( obj, ch );
    send_to_char( "Ok.\n\r", ch );
    return;
}


i'm figuring that i need to somehow fit the
obj = get_obj_wear
in there somewhere. but i'm not sure really how to code it. any thoughts or ideas?
USA #1
figured it out. for those of you who want to put this in your mud here ya go:


void do_immtake( CHAR_DATA *ch, char *argument )
{
   // char buf  [MAX_STRING_LENGTH];
    char arg1 [MAX_INPUT_LENGTH];
    char arg2 [MAX_INPUT_LENGTH];
  //  CHAR_DATA *victim, *mst;
	CHAR_DATA *victim;
    OBJ_DATA *obj;
 //   int percent;

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

    

    if ( arg1[0] == '\0' || arg2[0] == '\0' )
    {
	send_to_char( "Take what from whom?\n\r", ch );
	return;
    }

    if ( ms_find_obj(ch) )
	return;

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

    if ( victim == ch )
    {
	send_to_char( "That's pointless.\n\r", ch );
	return;
    }

    if ( !str_cmp( arg1, "coin"  )
    ||   !str_cmp( arg1, "coins" )
    ||   !str_cmp( arg1, "gold"  ) )
    {
	int amount;

	amount = (int) (victim->gold * number_range(1, 10) / 100);
	if ( amount <= 0 )
	{
	    send_to_char( "You couldn't get any gold.\n\r", ch );
	    
	    return;
	}

	ch->gold     += amount;
	victim->gold -= amount;
	ch_printf( ch, "You took %d gold coins.\n\r", amount );
	
	return;
    }

    if ( ( obj = get_obj_carry( victim, arg1 ) ) == NULL
		&& (obj = get_obj_wear( victim, arg1 ) ) == NULL )
    {
	send_to_char( "You can't seem to find it.\n\r", ch );

	return;
	}

    separate_obj( obj );
    obj_from_char( obj );
    obj_to_char( obj, ch );
    sprintf(log_buf, "%s is taking an item from %s\n\r",   ch->name, victim->name ); 
	log_string_plus(log_buf, LOG_NORMAL, get_trust(ch));
    send_to_char( "&CYou took the item.\n\r", ch );
    return;
}


this is for when someone might stack a little player too high or the player cheats to get his eq, you can take it away without causing too much of a fuss. i think it's a nifty little command
Amended on Thu 20 May 2004 07:49 AM by Ithildin
USA #2
here's an immgive as well. if you don't want them to see you give it back. or just give them something in general. this could be useful later on for a thief to "place" something on a character. they could get caught like a steal type thing as well. i remember someone asking about this a while back. anyways...here's immgive:


void do_immgive( CHAR_DATA *ch, char *argument )
{
    char arg1 [MAX_INPUT_LENGTH];
    char arg2 [MAX_INPUT_LENGTH];
    char buf  [MAX_INPUT_LENGTH];
    CHAR_DATA *victim;
    OBJ_DATA  *obj;

    argument = one_argument( argument, arg1 );
    argument = one_argument( argument, arg2 );
    if ( !str_cmp( arg2, "to" ) && argument[0] != '\0' )
	argument = one_argument( argument, arg2 );

    if ( arg1[0] == '\0' || arg2[0] == '\0' )
    {
	send_to_char( "Give what to whom?\n\r", ch );
	return;
    }

    if ( ms_find_obj(ch) )
	return;

    if ( is_number( arg1 ) )
    {
	/* 'give NNNN coins victim' */
	int amount;

	amount   = atoi(arg1);
	if ( amount <= 0
	|| ( str_cmp( arg2, "coins" ) && str_cmp( arg2, "coin" ) ) )
	{
	    send_to_char( "Sorry, you can't do that.\n\r", ch );
	    return;
	}

	argument = one_argument( argument, arg2 );
	if ( !str_cmp( arg2, "to" ) && argument[0] != '\0' )
	    argument = one_argument( argument, arg2 );
	if ( arg2[0] == '\0' )
	{
	    send_to_char( "Give what to whom?\n\r", ch );
	    return;
	}

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

	if ( ch->gold < amount )
	{
	    send_to_char( "Very generous of you, but you haven't got that much gold.\n\r", ch );
	    return;
	}

	ch->gold     -= amount;
	victim->gold += amount;
        strcpy(buf, "$n gives you ");
        strcat(buf, arg1 );
        strcat(buf, (amount > 1) ? " coins." : " coin.");

	act( AT_ACTION, buf, ch, NULL, victim, TO_VICT    );
	act( AT_ACTION, "$n gives $N some gold.",  ch, NULL, victim, TO_NOTVICT );
	act( AT_ACTION, "You give $N some gold.",  ch, NULL, victim, TO_CHAR    );
	mprog_bribe_trigger( victim, ch, amount );
	if ( IS_SET( sysdata.save_flags, SV_GIVE ) && !char_died(ch) )
	    save_char_obj(ch);
	if ( IS_SET( sysdata.save_flags, SV_RECEIVE ) && !char_died(victim) )
	    save_char_obj(victim);
	return;
    }

    if ( ( obj = get_obj_carry( ch, arg1 ) ) == NULL )
    {
	send_to_char( "You do not have that item.\n\r", ch );
	return;
    }

    if ( obj->wear_loc != WEAR_NONE )
    {
	send_to_char( "You must remove it first.\n\r", ch );
	return;
    }

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

    if ( !can_drop_obj( ch, obj ) )
    {
	send_to_char( "You can't let go of it.\n\r", ch );
	return;
    }

    if ( victim->carry_number + (get_obj_number(obj)/obj->count) > can_carry_n( victim ) )
    {
	act( AT_PLAIN, "$N has $S hands full.", ch, NULL, victim, TO_CHAR );
	return;
    }

    if ( victim->carry_weight + (get_obj_weight(obj)/obj->count) > can_carry_w( victim ) )
    {
	act( AT_PLAIN, "$N can't carry that much weight.", ch, NULL, victim, TO_CHAR );
	return;
    }

    if ( !can_see_obj( victim, obj ) )
    {
	act( AT_PLAIN, "$N can't see it.", ch, NULL, victim, TO_CHAR );
	return;
    }

    if (IS_OBJ_STAT( obj, ITEM_PROTOTYPE ) && !can_take_proto( victim ) )
    {
	act( AT_PLAIN, "You cannot give that to $N!", ch, NULL, victim, TO_CHAR );
	return;
    }

    separate_obj(obj);
    obj_from_char(obj);
	act(AT_ACTION, "You give $p to $N.", ch, obj, victim, TO_CHAR   );
    obj = obj_to_char(obj, victim);
	sprintf(log_buf, "%s is giving an item to %s\n\r", ch->name, victim->name ); 
	log_string_plus(log_buf, LOG_NORMAL, get_trust(ch));
    if ( IS_SET(sysdata.save_flags, SV_GIVE) && !char_died(ch) )
	save_char_obj(ch);
    if ( IS_SET(sysdata.save_flags, SV_RECEIVE) && !char_died(victim) )
	save_char_obj(victim);
    return;
}


i didn't mess with the money giving, because i don't plan on giving money to players, so that doesn't really matter. so i didn't mess with it.