SPEC_RET spec_thief( CHAR_DATA *ch ) { CHAR_DATA *victim; CHAR_DATA *v_next; int gold; int maxgold; if ( ch->position != POSITION_STAND ) return FALSE; for ( victim = ch->in_room->first_person; victim; victim = v_next ) { v_next = victim->next_in_room; if ( IS_MOB(victim) ) continue; if ( IS_ADMIN(victim) ) continue; if ( number_bits(2) != 0 ) continue; if ( !can_see(ch, victim) ) continue; if ( is_awake(victim) && number_range(0, get_level(ch)/2) == 0 ) { act( AT_ACTION, "$n mi sta derubando! Dannato ladro!", ch, NULL, victim, TO_VICT ); if ( get_curr_sense(ch, SENSE_SIXTH) > 75 ) { act( AT_ACTION, "Mi accorgo che $n sta frugando nel suo sacco di monete di $N!", ch, NULL, victim, TO_NOVICT ); } } else { maxgold = get_level(ch)/2 * get_level(ch)/2 * 1000; gold = victim->gold * number_range( 1, URANGE(2, get_level(ch)/8, 10) ) / 100; ch->gold += 9 * gold / 10; victim->gold -= gold; if ( ch->gold > maxgold ) { boost_economy( ch->in_room->area, ch->gold - maxgold/2 ); ch->gold = maxgold/2; } } return TRUE; } /* chiude il for */ return FALSE; }
bool spec_thief( CHAR_DATA *ch ) { CHAR_DATA *victim; CHAR_DATA *v_next; int gold, maxgold; if ( ch->position != POS_STANDING ) return FALSE; for ( victim = ch->in_room->first_person; victim; victim = v_next ) { v_next = victim->next_in_room; if ( IS_NPC(victim) || victim->level >= LEVEL_IMMORTAL || number_bits( 2 ) != 0 || !can_see( ch, victim ) ) /* Thx Glop */ continue; if ( IS_AWAKE(victim) && number_range( 0, ch->level ) == 0 ) { act( AT_ACTION, "You discover $n's hands in your sack of gold!", ch, NULL, victim, TO_VICT ); act( AT_ACTION, "$N discovers $n's hands in $S sack of gold!", ch, NULL, victim, TO_NOTVICT ); return TRUE; } else { maxgold = ch->level * ch->level * 1000; gold = victim->gold * number_range( 1, URANGE(2, ch->level/4, 10) ) / 100; ch->gold += 9 * gold / 10; victim->gold -= gold; if ( ch->gold > maxgold ) { boost_economy( ch->in_room->area, ch->gold - maxgold/2 ); ch->gold = maxgold/2; } return TRUE; } } return FALSE; }
/* * Repair a single object. Used when handling "repair all" - Gorog */ void repair_one_obj( CHAR_DATA *ch, CHAR_DATA *keeper, OBJ_DATA *obj, char *arg, int maxgold, char *fixstr, char*fixstr2 ) { char buf[MAX_STRING_LENGTH]; int cost; if ( !can_drop_obj( ch, obj ) ) ch_printf( ch, "You can't let go of %s.\n\r", obj->name ); else if ( ( cost = get_repaircost( keeper, obj ) ) < 0 ) { if (cost != -2) act( AT_TELL, "$n tells you, 'Sorry, I can't do anything with $p.'", keeper, obj, ch, TO_VICT ); else act( AT_TELL, "$n tells you, '$p looks fine to me!'", keeper, obj, ch, TO_VICT ); } /* "repair all" gets a 10% surcharge - Gorog */ else if ( (cost = strcmp("all",arg) ? cost : 11*cost/10) > ch->gold ) { sprintf( buf, "$N tells you, 'It will cost %d credit%s to %s %s...'", cost, cost == 1 ? "" : "s", fixstr, obj->name ); act( AT_TELL, buf, ch, NULL, keeper, TO_CHAR ); act( AT_TELL, "$N tells you, 'Which I see you can't afford.'", ch, NULL, keeper, TO_CHAR ); } else { sprintf( buf, "$n gives $p to $N, who quickly %s it.", fixstr2 ); act( AT_ACTION, buf, ch, obj, keeper, TO_ROOM ); sprintf( buf, "$N charges you %d credit%s to %s $p.", cost, cost == 1 ? "" : "s", fixstr ); act( AT_ACTION, buf, ch, obj, keeper, TO_CHAR ); ch->gold -= cost; keeper->gold += cost; if ( keeper->gold < 0 ) keeper->gold = 0; else if ( keeper->gold > maxgold ) { boost_economy( keeper->in_room->area, keeper->gold - maxgold/2 ); keeper->gold = maxgold/2; act( AT_ACTION, "$n puts some credits into a large safe.", keeper, NULL, NULL, TO_ROOM ); } switch ( obj->item_type ) { default: send_to_char( "For some reason, you think you got ripped off...\n\r", ch); break; case ITEM_ARMOR: obj->value[0] = obj->value[1]; break; case ITEM_WEAPON: obj->value[0] = INIT_WEAPON_CONDITION; break; case ITEM_DEVICE: obj->value[2] = obj->value[1]; break; } oprog_repair_trigger( ch, obj ); } }
void do_buy( CHAR_DATA *ch, char *argument ) { char arg[MAX_INPUT_LENGTH]; int maxgold; bool debit; OBJ_DATA *obj; argument = one_argument( argument, arg ); if ( arg[0] == '\0' ) { send_to_char( "Buy what?\n\r", ch ); return; } if ( IS_SET(ch->in_room->room_flags, ROOM_PET_SHOP) ) { char buf[MAX_STRING_LENGTH]; CHAR_DATA *pet; ROOM_INDEX_DATA *pRoomIndexNext; ROOM_INDEX_DATA *in_room; if ( argument[0] == '\0' ) debit = FALSE; else if ( !str_cmp( "atm", argument ) || !str_cmp( "debit", argument ) ) { bool has_card = FALSE; for ( obj = ch->last_carrying; obj; obj = obj->prev_content ) { if ( obj->item_type == ITEM_DEBIT_CARD ) has_card = TRUE; } if ( has_card == TRUE ) debit = TRUE; else { send_to_char( "You don't even have your card with you!\n\r", ch ); return; } } if ( IS_NPC(ch) ) return; pRoomIndexNext = get_room_index( ch->in_room->vnum + 1 ); if ( !pRoomIndexNext ) { bug( "Do_buy: bad pet shop at vnum %d.", ch->in_room->vnum ); send_to_char( "Sorry, you can't buy that here.\n\r", ch ); return; } in_room = ch->in_room; ch->in_room = pRoomIndexNext; pet = get_char_room( ch, arg ); ch->in_room = in_room; if ( pet == NULL || !IS_NPC( pet ) || !IS_SET(pet->act, ACT_PET) ) { send_to_char( "Sorry, you can't buy that here.\n\r", ch ); return; } if (( ch->gold < 10 * pet->top_level * pet->top_level ) && debit == FALSE) { send_to_char( "You can't afford it.\n\r", ch ); return; } else if ( (ch->pcdata->bank < 10 * pet->top_level * pet->top_level) && debit == TRUE ) { send_to_char( "You dont have enough money in your bank account for it.\n\r", ch ); return; } maxgold = 10 * pet->top_level * pet->top_level; if ( debit == FALSE ) ch->gold -= maxgold; /* this was already here, btw */ else ch->pcdata->bank -= maxgold; boost_economy( ch->in_room->area, maxgold ); pet = create_mobile( pet->pIndexData ); SET_BIT(pet->act, ACT_PET); SET_BIT(pet->affected_by, AFF_CHARM); argument = one_argument( argument, arg ); if ( arg[0] != '\0' ) { sprintf( buf, "%s %s", pet->name, arg ); STRFREE( pet->name ); pet->name = STRALLOC( buf ); } sprintf( buf, "%sA neck tag says 'I belong to %s'.\n\r", pet->description, ch->name ); STRFREE( pet->description ); pet->description = STRALLOC( buf ); char_to_room( pet, ch->in_room ); add_follower( pet, ch ); send_to_char( "Enjoy your pet.\n\r", ch ); act( AT_ACTION, "$n bought $N as a pet.", ch, NULL, pet, TO_ROOM ); return; } else { CHAR_DATA *keeper; int cost; int noi = 1; /* Number of items */ sh_int mnoi = 20; /* Max number of items to be bought at once */ if ( ( keeper = find_keeper( ch ) ) == NULL ) return; maxgold = keeper->top_level * 10; if ( is_number( arg ) ) { noi = atoi( arg ); argument = one_argument( argument, arg ); if ( noi > mnoi ) { act( AT_TELL, "$n tells you 'I don't sell that many items at" " once.'", keeper, NULL, ch, TO_VICT ); ch->reply = keeper; return; } } if ( argument[0] == '\0' ) debit = FALSE; else if ( !str_cmp( "atm", argument ) || !str_cmp( "debit", argument ) ) { bool has_card = FALSE; for ( obj = ch->last_carrying; obj; obj = obj->prev_content ) { if ( obj->item_type == ITEM_DEBIT_CARD ) has_card = TRUE; } if ( has_card == TRUE ) debit = TRUE; else { send_to_char( "You don't even have your card with you!\n\r", ch ); return; } } obj = get_obj_carry( keeper, arg ); if ( !obj && arg[0] == '#' ) { int onum, oref; bool ofound = FALSE; onum =0; oref = atoi(arg+1); for ( obj = keeper->last_carrying; obj; obj = obj->prev_content ) { if ( obj->wear_loc == WEAR_NONE && can_see_obj( ch, obj ) ) onum++; if ( onum == oref ) { ofound = TRUE; break; } else if ( onum > oref ) break; } if (!ofound) obj = NULL; } if (keeper->home != NULL && obj->cost > 0) cost= obj->cost; cost = ( get_cost( ch, keeper, obj, TRUE ) * noi ); if( !IS_NPC(ch) && ch->pcdata->learned[gsn_bargain] > 0 && ch->pcdata->learned[gsn_bargain] > number_percent()) { ch_printf(ch,"You are able to bargain from %d credits to %d credits!\n\r", cost, (cost/3)+(cost/2)); cost = (cost/3) + (cost/2); if(number_percent() > 50) learn_from_success(ch, gsn_bargain); } if ( cost <= 0 || !can_see_obj( ch, obj ) ) { act( AT_TELL, "$n tells you 'I don't sell that -- try 'list'.'", keeper, NULL, ch, TO_VICT ); ch->reply = keeper; return; } if ( !IS_OBJ_STAT( obj, ITEM_INVENTORY ) && ( noi > 1 ) ) { interpret( keeper, "laugh" ); act( AT_TELL, "$n tells you 'I don't have enough of those in stock" " to sell more than one at a time.'", keeper, NULL, ch, TO_VICT ); ch->reply = keeper; return; } if ( ch->gold < cost && debit == FALSE) { act( AT_TELL, "$n tells you 'You can't afford to buy $p.'", keeper, obj, ch, TO_VICT ); ch->reply = keeper; return; } if ( ch->pcdata->bank < cost && debit == TRUE) { send_to_char( "You are almost slide your card through, but you remember you don't have enough money!\n\r", ch ); return; } if ( IS_SET(obj->extra_flags, ITEM_PROTOTYPE) && get_trust( ch ) < LEVEL_IMMORTAL ) { act( AT_TELL, "$n tells you 'This is a only a prototype! I can't sell you that...'", keeper, NULL, ch, TO_VICT ); ch->reply = keeper; return; } if ( ch->carry_number + get_obj_number( obj ) > can_carry_n( ch ) ) { send_to_char( "You can't carry that many items.\n\r", ch ); return; } if ( ch->carry_weight + ( get_obj_weight( obj ) * noi ) + (noi > 1 ? 2 : 0) > can_carry_w( ch ) ) { send_to_char( "You can't carry that much weight.\n\r", ch ); return; } if ( noi == 1 ) { if ( !IS_OBJ_STAT( obj, ITEM_INVENTORY ) ) separate_obj( obj ); act( AT_ACTION, "$n buys $p.", ch, obj, NULL, TO_ROOM ); act( AT_ACTION, "You buy $p.", ch, obj, NULL, TO_CHAR ); } else { sprintf( arg, "$n buys %d $p%s.", noi, ( obj->short_descr[strlen(obj->short_descr)-1] == 's' ? "" : "s" ) ); act( AT_ACTION, arg, ch, obj, NULL, TO_ROOM ); sprintf( arg, "You buy %d $p%s.", noi, ( obj->short_descr[strlen(obj->short_descr)-1] == 's' ? "" : "s" ) ); act( AT_ACTION, arg, ch, obj, NULL, TO_CHAR ); act( AT_ACTION, "$N puts them into a bag and hands it to you.", ch, NULL, keeper, TO_CHAR ); } if ( debit == FALSE ) ch->gold -= cost; /* this line was already here, btw */ else if ( debit == TRUE ) ch->pcdata->bank -= cost; keeper->gold += cost; if ( keeper->gold > maxgold ) { boost_economy( keeper->in_room->area, keeper->gold - maxgold/2 ); keeper->gold = maxgold/2; act( AT_ACTION, "$n puts some credits into a large safe.", keeper, NULL, NULL, TO_ROOM ); } if ( IS_OBJ_STAT( obj, ITEM_INVENTORY ) ) { OBJ_DATA *buy_obj, *bag; buy_obj = create_object( obj->pIndexData, obj->level ); /* * Due to grouped objects and carry limitations in SMAUG * The shopkeeper gives you a bag with multiple-buy, * and also, only one object needs be created with a count * set to the number bought. -Thoric */ if ( noi > 1 ) { bag = create_object( get_obj_index( OBJ_VNUM_SHOPPING_BAG ), 1 ); /* perfect size bag ;) */ bag->value[0] = bag->weight + (buy_obj->weight * noi); buy_obj->count = noi; obj->pIndexData->count += (noi - 1); numobjsloaded += (noi - 1); obj_to_obj( buy_obj, bag ); obj_to_char( bag, ch ); } else obj_to_char( buy_obj, ch ); } else { obj_from_char( obj ); obj_to_char( obj, ch ); } return; } }