/* * Disarm a creature. * Caller must check for successful attack. */ void disarm( CHAR_DATA *ch, CHAR_DATA *victim ) { OBJ_DATA *obj; if ( ( obj = get_eq_char( victim, WEAR_WIELD ) ) == NULL ) return; if ( IS_OBJ_STAT(obj,ITEM_NOREMOVE)) { act("$S weapon won't budge!",ch,NULL,victim,TO_CHAR, 1); act("$n tries to disarm you, but your weapon won't budge!", ch,NULL,victim,TO_VICT, 0); act("$n tries to disarm $N, but fails.",ch,NULL,victim,TO_NOTVICT, 0); return; } act( "$n DISARMS you and sends your weapon flying!", ch, NULL, victim, TO_VICT, 1 ); act( "You disarm $N!", ch, NULL, victim, TO_CHAR, 1 ); act( "$n disarms $N!", ch, NULL, victim, TO_NOTVICT, 0 ); obj_from_char( obj ); if ( IS_OBJ_STAT(obj,ITEM_NODROP) || IS_OBJ_STAT(obj,ITEM_INVENTORY) ) obj_to_char( obj, victim ); else { obj_to_room( obj, victim->in_room ); if (IS_NPC(victim) && victim->wait == 0 && can_see_obj(victim,obj)) get_obj(victim,obj,NULL); } return; }
void do_equipment( CHAR_DATA* ch, const char* argument) { OBJ_DATA *obj; int iWear; bool found; set_char_color( AT_RED, ch ); send_to_char( "You are using:\r\n", ch ); found = FALSE; set_char_color( AT_OBJECT, ch ); for( iWear = 0; iWear < MAX_WEAR; iWear++ ) { for( obj = ch->first_carrying; obj; obj = obj->next_content ) if( obj->wear_loc == iWear ) { if( ( !IS_NPC( ch ) ) && ( ch->race > 0 ) && ( ch->race < MAX_PC_RACE ) ) send_to_char( race_table[ch->race]->where_name[iWear], ch ); else send_to_char( where_name[iWear], ch ); if( can_see_obj( ch, obj ) ) { send_to_char( format_obj_to_char( obj, ch, TRUE ), ch ); send_to_char( "\r\n", ch ); } else send_to_char( "something.\r\n", ch ); found = TRUE; } } if( !found ) send_to_char( "Nothing.\r\n", ch ); }
void Character::spell_locate_object (int sn, int lvl, void *vo) { std::string buf; bool found = false; ObjIter o; for (o = object_list.begin(); o != object_list.end(); o++) { Object *in_obj; if (!can_see_obj(*o) || !is_name (target_name, (*o)->name)) continue; found = true; for (in_obj = *o; in_obj->in_obj != NULL; in_obj = in_obj->in_obj) ; if (in_obj->carried_by != NULL) { buf = (*o)->short_descr + " carried by " + in_obj->carried_by->describe_to(this) + "\r\n"; } else { buf = (*o)->short_descr + " in " + (in_obj->in_room == NULL ? "somewhere" : in_obj->in_room->name.c_str()) + ".\r\n"; } buf[0] = toupper (buf[0]); send_to_char (buf); } if (!found) send_to_char ("Nothing like that in hell, earth, or heaven.\r\n"); return; }
void do_repair( CHAR_DATA * ch, char *argument ) { CHAR_DATA *keeper = NULL; OBJ_DATA *obj = NULL; char fixstr[MAX_STRING_LENGTH]; char fixstr2[MAX_STRING_LENGTH]; int maxgold = 0; if( argument[0] == '\0' ) { send_to_char( "Repair what?\r\n", ch ); return; } if( ( keeper = find_fixer( ch ) ) == NULL ) return; maxgold = keeper->top_level * 10; switch ( keeper->pIndexData->rShop->shop_type ) { default: case SHOP_FIX: sprintf( fixstr, "%s", "repair" ); sprintf( fixstr2, "%s", "repairs" ); break; case SHOP_RECHARGE: sprintf( fixstr, "%s", "recharge" ); sprintf( fixstr2, "%s", "recharges" ); break; } if( !strcmp( argument, "all" ) ) { for( obj = ch->first_carrying; obj; obj = obj->next_content ) { if( obj->wear_loc == WEAR_NONE && can_see_obj( ch, obj ) && ( obj->item_type == ITEM_ARMOR || obj->item_type == ITEM_WEAPON || obj->item_type == ITEM_DEVICE ) ) repair_one_obj( ch, keeper, obj, argument, maxgold, fixstr, fixstr2 ); } return; } if( ( obj = get_obj_carry( ch, argument ) ) == NULL ) { act( AT_TELL, "$n tells you 'You don't have that item.'", keeper, NULL, ch, TO_VICT ); ch->reply = keeper; return; } repair_one_obj( ch, keeper, obj, argument, maxgold, fixstr, fixstr2 ); }
struct gameobject *get_object_by_itemtype_and_room(int item_type, struct room_index_data *room, struct char_data *ch) { struct gameobject *instance = NULL; for (instance = room->contents; instance != NULL; instance = instance->next_content) if (instance->item_type == item_type && (ch == NULL || can_see_obj(ch, instance))) break; return instance; }
void appraise_all( CHAR_DATA * ch, CHAR_DATA * keeper, const char *fixstr ) { OBJ_DATA *obj = NULL; char buf[MAX_STRING_LENGTH], *pbuf = buf; int cost = 0, total = 0; for( obj = ch->first_carrying; obj != NULL; obj = obj->next_content ) { if( obj->wear_loc == WEAR_NONE && can_see_obj( ch, obj ) && ( obj->item_type == ITEM_ARMOR || obj->item_type == ITEM_WEAPON || obj->item_type == ITEM_DEVICE ) ) { if( !can_drop_obj( ch, obj ) ) { ch_printf( ch, "You can't let go of %s.\r\n", 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 ); } } else { 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 ); total += cost; } } } if( total > 0 ) { send_to_char( "\r\n", ch ); sprintf( buf, "$N tells you, 'It will cost %d credit%s in total.'", total, cost == 1 ? "" : "s" ); act( AT_TELL, buf, ch, NULL, keeper, TO_CHAR ); strcpy( pbuf, "$N tells you, 'Remember there is a 10% surcharge for repair all.'" ); act( AT_TELL, buf, ch, NULL, keeper, TO_CHAR ); } }
void show_char_to_char_2(struct char_data *victim, struct char_data *ch) { struct gameobject *obj; struct dynamic_skill *skill_peek; int iWear; bool found; if (can_see(victim, ch)) { if (ch == victim) { act("$n glances at $mself.", ch, NULL, NULL, TO_ROOM); } else { act("$n glances at you.", ch, NULL, victim, TO_VICT); act("$n glances at $N.", ch, NULL, victim, TO_NOTVICT); } } show_damage_display(ch, victim); found = false; for (iWear = 0; where_name[iWear].wear_loc >= 0; iWear++) { if ((obj = get_eq_char(victim, where_name[iWear].wear_loc)) != NULL && can_see_obj(ch, obj)) { if (!found) { send_to_char("\n\r", ch); act("$N is using:", ch, NULL, victim, TO_CHAR); found = true; } send_to_char(where_name[iWear].desc, ch); send_to_char("(", ch); send_to_char(format_obj_to_char(obj, ch, true), ch); send_to_char(")", ch); send_to_char("\n\r", ch); } } if (victim != ch && !IS_NPC(ch) && (skill_peek = gsp_peek) != NULL && number_percent() < get_learned_percent(ch, skill_peek)) { send_to_char("\n\rYou peek at the inventory:\n\r", ch); check_improve(ch, skill_peek, true, 4); show_list_to_char(victim->carrying, ch, true, true); } return; }
void look_equipment(struct char_data *ch) { struct gameobject *obj; int iWear; send_to_char("`& You are using: \n\r ------------------``\n\r", ch); for (iWear = 0; where_name[iWear].wear_loc >= 0; iWear++) { if ((obj = get_eq_char(ch, where_name[iWear].wear_loc)) == NULL) { if (!(IS_SET(ch->act, PLR_AUTOEQ))) continue; send_to_char("`1", ch); send_to_char(where_name[iWear].desc, ch); if (where_name[iWear].wear_loc == WEAR_THIRD) { send_to_char("`1 --Not Available--``\r\n", ch); } else { if ((where_name[iWear].wear_loc == WEAR_FINGER_L2)) { send_to_char("`1 --Not Available--``\r\n", ch); } else { if ((where_name[iWear].wear_loc == WEAR_FINGER_R2)) { send_to_char("`1 --Not Available--``\r\n", ch); } else { send_to_char("`1 --Empty--``\r\n", ch); } } } continue; } send_to_char("`7", ch); send_to_char(where_name[iWear].desc, ch); send_to_char("`&", ch); if (can_see_obj(ch, obj)) { send_to_char("`&", ch); send_to_char(format_obj_to_char(obj, ch, true), ch); send_to_char("``\n\r", ch); } else { send_to_char("`&something.\n\r", ch); } } send_to_char("`8", ch); }
void do_list( CHAR_DATA * ch, char *argument ) { char arg[MAX_INPUT_LENGTH]; CHAR_DATA *keeper = NULL; OBJ_DATA *obj = NULL; int cost = 0; int oref = 0; bool found = FALSE; one_argument( argument, arg ); if( ( keeper = find_keeper( ch ) ) == NULL ) return; for( obj = keeper->last_carrying; obj; obj = obj->prev_content ) { if( obj->wear_loc == WEAR_NONE && can_see_obj( ch, obj ) ) { oref++; if( ( cost = get_cost( ch, keeper, obj, TRUE ) ) > 0 && ( arg[0] == '\0' || nifty_is_name( arg, obj->name ) ) ) { if( !found ) { found = TRUE; send_to_char( "[Price] {ref} Item\r\n", ch ); } ch_printf( ch, "[%5d] {%3d} %s.\r\n", cost, oref, capitalize( obj->short_descr ) ); } } } if( !found ) { if( arg[0] == '\0' ) send_to_char( "You can't buy anything here.\r\n", ch ); else send_to_char( "You can't buy that here.\r\n", ch ); } }
void do_sell( CHAR_DATA *ch, char *argument ) { char buf[MAX_STRING_LENGTH]; char arg[MAX_INPUT_LENGTH]; CHAR_DATA *keeper; OBJ_DATA *obj; int cost; one_argument( argument, arg ); if ( arg[0] == '\0' ) { send_to_char( "Sell what?\n\r", ch ); return; } if ( ( keeper = find_keeper( ch ) ) == NULL ) return; if ( ( obj = get_obj_carry( ch, arg ) ) == NULL ) { act( AT_TELL, "$n tells you 'You don't have that item.'", keeper, NULL, ch, TO_VICT ); ch->reply = keeper; return; } /* Bug report and solution thanks to [email protected] */ if ( !can_see_obj( keeper, obj) ) { send_to_char("What are you trying to sell me? I don't buy thin air!\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 ( obj->timer > 0 ) { act( AT_TELL, "$n tells you, '$p is depreciating in value too quickly...'", keeper, obj, ch, TO_VICT ); return; } if ( ( cost = get_cost( ch, keeper, obj, FALSE ) ) <= 0 ) { act( AT_ACTION, "$n looks uninterested in $p.", keeper, obj, ch, TO_VICT ); return; } if ( cost > keeper->gold ) { act( AT_TELL, "$n makes a credit transaction.", keeper, obj, ch, TO_VICT ); lower_economy( ch->in_room->area, cost-keeper->gold ); } separate_obj( obj ); act( AT_ACTION, "$n sells $p.", ch, obj, NULL, TO_ROOM ); sprintf( buf, "You sell $p for %d credit%s.", cost, cost == 1 ? "" : "s" ); act( AT_ACTION, buf, ch, obj, NULL, TO_CHAR ); ch->gold += cost; keeper->gold -= cost; if ( keeper->gold < 0 ) keeper->gold = 0; if ( obj->item_type == ITEM_TRASH ) extract_obj( obj ); else if ( IS_SET( obj->extra_flags , ITEM_CONTRABAND) ) { long ch_exp; ch_exp = UMIN( obj->cost*10 , ( exp_level( ch->skill_level[SMUGGLING_ABILITY]+1) - exp_level( ch->skill_level[SMUGGLING_ABILITY]) ) / 10 ); ch_printf( ch, "You receive %ld smuggling experience for unloading your contraband.\n\r " , ch_exp ); gain_exp( ch, ch_exp , SMUGGLING_ABILITY ); if ( obj->item_type == ITEM_SPICE || obj->item_type == ITEM_RAWSPICE ) extract_obj( obj ); else { REMOVE_BIT( obj->extra_flags , ITEM_CONTRABAND ); obj_from_char( obj ); obj_to_char( obj, keeper ); } } else if ( obj->item_type == ITEM_SPICE || obj->item_type == ITEM_RAWSPICE ) extract_obj( obj ); else { obj_from_char( obj ); obj_to_char( obj, keeper ); } return; }
void do_list( CHAR_DATA *ch, char *argument ) { if ( IS_SET(ch->in_room->room_flags, ROOM_PET_SHOP) ) { ROOM_INDEX_DATA *pRoomIndexNext; CHAR_DATA *pet; bool found; pRoomIndexNext = get_room_index( ch->in_room->vnum + 1 ); if ( !pRoomIndexNext ) { bug( "Do_list: bad pet shop at vnum %d.", ch->in_room->vnum ); send_to_char( "You can't do that here.\n\r", ch ); return; } found = FALSE; for ( pet = pRoomIndexNext->first_person; pet; pet = pet->next_in_room ) { if ( IS_SET(pet->act, ACT_PET) && IS_NPC(pet) ) { if ( !found ) { found = TRUE; send_to_char( "Pets for sale:\n\r", ch ); } ch_printf( ch, "[%2d] %8d - %s\n\r", pet->top_level, 10 * pet->top_level * pet->top_level, pet->short_descr ); } } if ( !found ) send_to_char( "Sorry, we're out of pets right now.\n\r", ch ); return; } else { char arg[MAX_INPUT_LENGTH]; CHAR_DATA *keeper; OBJ_DATA *obj; int cost; int oref = 0; bool found; one_argument( argument, arg ); if ( ( keeper = find_keeper( ch ) ) == NULL ) return; found = FALSE; for ( obj = keeper->last_carrying; obj; obj = obj->prev_content ) { if ( obj->wear_loc == WEAR_NONE && can_see_obj( ch, obj ) ) { oref++; if ( ( cost = get_cost( ch, keeper, obj, TRUE ) ) > 0 && ( arg[0] == '\0' || nifty_is_name( arg, obj->name ) ) ) { if (keeper->home != NULL) cost = obj->cost; if ( !found ) { found = TRUE; ch_printf( ch, "%s[Price] {ref} Item\n\r", color_str( AT_LIST, ch) ); } ch_printf( ch, "%s[%5d] {%3d} %s%s%s.\n\r", color_str(AT_LIST, ch), cost, oref, capitalize( obj->short_descr ), color_str(AT_LIST, ch), IS_SET(obj->extra_flags, ITEM_HUTT_SIZE) ? " (hutt size)" : ( IS_SET(obj->extra_flags, ITEM_LARGE_SIZE) ? " (large)" : ( IS_SET(obj->extra_flags, ITEM_HUMAN_SIZE) ? " (medium)" : ( IS_SET(obj->extra_flags, ITEM_SMALL_SIZE) ? " (small)" : "" ) ) ) ); } } } if ( !found ) { if ( arg[0] == '\0' ) send_to_char( "You can't buy anything here.\n\r", ch ); else send_to_char( "You can't buy that here.\n\r", ch ); } return; } }
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; } }
//to calkowita obsluga ladowania artefactow //sprawdzanie czy mozna + ladowanie + ew. zakladanie void load_artefact( ROOM_INDEX_DATA *room, OBJ_DATA *obj, CHAR_DATA *ch ) { char buf[ MAX_INPUT_LENGTH ]; ARTEFACT_DATA *atmp = NULL; ARTEFACT_LOADER *ltmp = NULL; OBJ_DATA *loaded_obj; int type; int vnum = 0; if ( room != NULL ) { vnum = room->vnum;type = 0; } else if ( obj != NULL ) { vnum = obj->pIndexData->vnum;type = 1; } else if ( ch != NULL ) { vnum = ch->pIndexData->vnum;type = 2; } else return ; //gdzie for ( atmp = artefact_system;atmp;atmp = atmp->next ) { for ( ltmp = atmp->loader;ltmp;ltmp = ltmp->next ) { //jesli nie zgadza sie typ (np: obj=obj) i vnumy to wychodzimy if (!( ltmp->type == type && ltmp->vnum == vnum )) { continue; } //jesli room to sprawdzanie czy juz tam nie ma if (( type == 0 ) && ( count_obj_list( get_obj_index( atmp->avnum ), room->contents ) > 0 ) ) { sprintf( buf, "NIE LADUJE do room a (juz jest): %d do %d", atmp->avnum, room->vnum ); wiznet( buf, NULL, NULL, WIZ_ARTEFACTLOAD, 0, 39 ); continue; } //aktualizacja ilosci atmp->count = artefact_new_count( atmp ); //tera prawd. jesli mniejsze to nastepny loader if ( number_range( 1, ltmp->probup ) > ltmp->probdown ) { continue; } //juz max artefaktu, nastepny loader if ( atmp->count >= atmp->max_count ) continue; //ladujemy bo wsie warunki spelnione loaded_obj = create_object ( get_obj_index( atmp->avnum ), FALSE ); create_artefact( loaded_obj->pIndexData->vnum ); //dokad ladujemy if ( type == 0 ) //do rooma { sprintf( buf, "Artefakt [%d] za³adowany do rooma [%d].", loaded_obj->pIndexData->vnum, room->vnum ); obj_to_room( loaded_obj, room ); wiznet( buf, NULL, NULL, WIZ_ARTEFACTLOAD, 0, 39 ); } else if ( type == 1 ) //do srodka objectu { sprintf( buf, "Artefakt [%d] za³adowany do wnêtrza obiektu [%d],", loaded_obj->pIndexData->vnum, obj->pIndexData->vnum ); obj_to_obj( loaded_obj, obj ); wiznet( buf, NULL, NULL, WIZ_ARTEFACTLOAD, 0, 39 ); //okresla room if ( obj->in_room ) sprintf( buf, " w roomie [%d]", obj->in_room->vnum ); if ( obj->carried_by ) sprintf( buf, " na mobie [%d] w roomie [%d]", obj->carried_by->pIndexData->vnum, obj->carried_by->in_room->vnum ); wiznet( buf, NULL, NULL, WIZ_ARTEFACTLOAD, 0, 39 ); } else if ( type == 2 ) //mobowi { sprintf( buf, "Artefakt [%d] za³adowany mobowi [%d] roomie [%d].", loaded_obj->pIndexData->vnum, ch->pIndexData->vnum, ch->in_room->vnum ); obj_to_char( loaded_obj, ch ); wiznet( buf, NULL, NULL, WIZ_ARTEFACTLOAD, 0, 39 ); //+zakladanie jesli moze (nie sprzedawca) if ( ch->pIndexData->pShop == NULL && loaded_obj->wear_loc == WEAR_NONE && can_see_obj( ch, loaded_obj ) ) { if ( loaded_obj->item_type == ITEM_WEAPON ) { if ( !get_eq_char( ch, WEAR_WIELD ) ) wield_weapon( ch, loaded_obj, TRUE ); } else wear_obj( ch, loaded_obj, FALSE ); } } //end dokad // } //end typ=typ, vnum=vnum } //end po loaderach } //end po artefaktach }
void do_equipment( CHAR_DATA * ch, const char *argument ) { OBJ_DATA *obj; int iWear, dam; bool found; char buf[MAX_STRING_LENGTH]; set_char_color( AT_RED, ch ); send_to_char( "You are using:\r\n", ch ); found = FALSE; set_char_color( AT_OBJECT, ch ); for( iWear = 0; iWear < MAX_WEAR; iWear++ ) { for( obj = ch->first_carrying; obj; obj = obj->next_content ) if( obj->wear_loc == iWear ) { send_to_char( where_name[iWear], ch ); if( can_see_obj( ch, obj ) ) { send_to_char( format_obj_to_char( obj, ch, TRUE ), ch ); strcpy( buf, "" ); switch ( obj->item_type ) { default: break; case ITEM_BACTA: ch_printf( ch, " %d", obj->value[0] ); break; case ITEM_ARMOR: if( obj->value[1] == 0 ) obj->value[1] = obj->value[0]; if( obj->value[1] == 0 ) obj->value[1] = 1; dam = ( short )( ( obj->value[0] * 10 ) / obj->value[1] ); if( dam >= 10 ) strcat( buf, " (superb) " ); else if( dam >= 7 ) strcat( buf, " (good) " ); else if( dam >= 5 ) strcat( buf, " (worn) " ); else if( dam >= 3 ) strcat( buf, " (poor) " ); else if( dam >= 1 ) strcat( buf, " (awful) " ); else if( dam == 0 ) strcat( buf, " (broken) " ); send_to_char( buf, ch ); break; case ITEM_WEAPON: dam = INIT_WEAPON_CONDITION - obj->value[0]; if( dam < 2 ) strcat( buf, " (superb) " ); else if( dam < 4 ) strcat( buf, " (good) " ); else if( dam < 7 ) strcat( buf, " (worn) " ); else if( dam < 10 ) strcat( buf, " (poor) " ); else if( dam < 12 ) strcat( buf, " (awful) " ); else if( dam == 12 ) strcat( buf, " (broken) " ); send_to_char( buf, ch ); if( obj->value[3] == WEAPON_BLASTER ) { if( obj->blaster_setting == BLASTER_FULL ) ch_printf( ch, "FULL" ); else if( obj->blaster_setting == BLASTER_HIGH ) ch_printf( ch, "HIGH" ); else if( obj->blaster_setting == BLASTER_NORMAL ) ch_printf( ch, "NORMAL" ); else if( obj->blaster_setting == BLASTER_HALF ) ch_printf( ch, "HALF" ); else if( obj->blaster_setting == BLASTER_LOW ) ch_printf( ch, "LOW" ); else if( obj->blaster_setting == BLASTER_STUN ) ch_printf( ch, "STUN" ); ch_printf( ch, " %d", obj->value[4] ); } else if( ( obj->value[3] == WEAPON_LIGHTSABER || obj->value[3] == WEAPON_VIBRO_BLADE || obj->value[3] == WEAPON_FORCE_PIKE || obj->value[3] == WEAPON_BOWCASTER ) ) { ch_printf( ch, "%d", obj->value[4] ); } break; } send_to_char( "\r\n", ch ); } else send_to_char( "something.\r\n", ch ); found = TRUE; } } if( !found ) send_to_char( "Nothing.\r\n", ch ); return; }
//********************KONIEC PRZYTRZYMUJACYCH*******************// //to jest do_owhere() tylko zmodyfikowany na potrzeby do_astat() void awhere( CHAR_DATA *ch, char *argument ) { char buf[ MAX_INPUT_LENGTH ]; BUFFER *buffer = NULL; OBJ_DATA *obj; OBJ_DATA *in_obj; bool found; int vnum = -1; found = FALSE; buffer = new_buf(); if ( argument[ 0 ] == '\0' ) { send_to_char( "Find what?\n\r", ch ); return ; } if ( is_number( argument ) ) vnum = atoi( argument ); for ( obj = object_list; obj != NULL; obj = obj->next ) { if ( vnum > 0 ) { if ( !can_see_obj( ch, obj ) || obj->pIndexData->vnum != vnum ) continue; } else { if ( !can_see_obj( ch, obj ) || !is_name( argument, obj->name ) ) continue; } found = TRUE; for ( in_obj = obj; in_obj->in_obj != NULL; in_obj = in_obj->in_obj ); if ( in_obj->carried_by != NULL && can_see( ch, in_obj->carried_by ) && in_obj->carried_by->in_room != NULL ) sprintf( buf, " %s jest noszone przez %s [Room %d]\n\r", obj->short_descr, PERS( in_obj->carried_by, ch ), in_obj->carried_by->in_room->vnum ); else if ( in_obj->in_room != NULL && can_see_room( ch, in_obj->in_room ) ) sprintf( buf, " %s jest w %s [Room %d]\n\r", obj->short_descr, in_obj->in_room->name, in_obj->in_room->vnum ); else sprintf( buf, " %s jest gdzies\n\r", obj->short_descr ); sprintf( buf, "%s", capitalize( buf ) ); add_buf( buffer, buf ); } if ( !found ) send_to_char( " Niczego takiego nie ma aktualnie w grze.\n\r", ch ); else page_to_char( buf_string( buffer ), ch ); free_buf( buffer ); }
void do_play(CHAR_DATA *ch, char *argument) { OBJ_DATA *juke; char *str,arg[MAX_INPUT_LENGTH]; int song,i; bool global = FALSE; str = one_argument(argument,arg); for (juke = ch->in_room->contents; juke != NULL; juke = juke->next_content) if (juke->item_type == ITEM_JUKEBOX && can_see_obj(ch,juke)) break; if (argument[0] == '\0') { send_to_char("Play what?\n\r",ch); return; } if (juke == NULL) { send_to_char("You see nothing to play.\n\r",ch); return; } if (!str_cmp(arg,"list")) { BUFFER *buffer; char buf[MSL]={'\0'}; int col = 0; bool artist = FALSE, match = FALSE; buffer = new_buf(); argument = str; argument = one_argument(argument,arg); if (!str_cmp(arg,"artist")) artist = TRUE; if (argument[0] != '\0') match = TRUE; sprintf(buf,"%s has the following songs available:\n\r", juke->short_descr); add_buf(buffer,capitalize(buf)); for (i = 0; i < MAX_SONGS; i++) { if (song_table[i].name == NULL) break; if (artist && (!match || !str_prefix(argument,song_table[i].group))) sprintf(buf,"%-39s %-39s\n\r", song_table[i].group,song_table[i].name); else if (!artist && (!match || !str_prefix(argument,song_table[i].name))) sprintf(buf,"%-35s ",song_table[i].name); else continue; add_buf(buffer,buf); if (!artist && ++col % 2 == 0) add_buf(buffer,"\n\r"); } if (!artist && col % 2 != 0) add_buf(buffer,"\n\r"); page_to_char(buf_string(buffer),ch); free_buf(buffer); return; } if (!str_cmp(arg,"loud")) { argument = str; global = TRUE; } if (argument[0] == '\0') { send_to_char("Play what?\n\r",ch); return; } if ((global && channel_songs[MAX_GLOBAL] > -1) || (!global && juke->value[4] > -1)) { send_to_char("The jukebox is full up right now.\n\r",ch); return; } for (song = 0; song < MAX_SONGS; song++) { if (song_table[song].name == NULL) { send_to_char("That song isn't available.\n\r",ch); return; } if (!str_prefix(argument,song_table[song].name)) break; } if (song >= MAX_SONGS) { send_to_char("That song isn't available.\n\r",ch); return; } send_to_char("Coming right up.\n\r",ch); if (global) { for (i = 1; i <= MAX_GLOBAL; i++) if (channel_songs[i] < 0) { if (i == 1) channel_songs[0] = -1; channel_songs[i] = song; return; } } else { for (i = 1; i < 5; i++) if (juke->value[i] < 0) { if (i == 1) juke->value[0] = -1; juke->value[i] = song; return; } } }
bool spec_customs_spice(CHAR_DATA * ch) { CHAR_DATA *victim; CHAR_DATA *v_next; OBJ_DATA *obj; char buf[MAX_STRING_LENGTH]; long ch_exp; if (!IS_AWAKE(ch) || ch->position == POS_FIGHTING) return FALSE; for (victim = ch->in_room->first_person; victim; victim = v_next) { v_next = victim->next_in_room; if (IS_NPC(victim) || victim->position == POS_FIGHTING) continue; for (obj = victim->last_carrying; obj; obj = obj->prev_content) { if (obj->pIndexData->item_type == ITEM_SPICE || obj->pIndexData->item_type == ITEM_RAWSPICE) { if (victim != ch && can_see(ch, victim) && can_see_obj(ch, obj)) { sprintf(buf, "%s is illegal contraband. I'm going to have to confiscate that.", obj->short_descr); do_say(ch, buf); if (obj->wear_loc != WEAR_NONE) remove_obj(victim, obj->wear_loc, TRUE); separate_obj(obj); obj_from_char(obj); act(AT_ACTION, "$n confiscates $p from $N.", ch, obj, victim, TO_NOTVICT); act(AT_ACTION, "$n takes $p from you.", ch, obj, victim, TO_VICT); obj = obj_to_char(obj, ch); SET_BIT(obj->extra_flags, ITEM_CONTRABAND); ch_exp = UMIN(obj->cost * 10, (exp_level (victim-> skill_level [SMUGGLING_ABILITY] + 1) - exp_level(victim-> skill_level [SMUGGLING_ABILITY]))); ch_printf(victim, "You lose %ld experience. \n\r", ch_exp); gain_exp(victim, 0 - ch_exp, SMUGGLING_ABILITY); return TRUE; } else if (can_see(ch, victim) && !IS_SET(obj->extra_flags, ITEM_CONTRABAND)) { ch_exp = UMIN(obj->cost * 10, (exp_level (victim-> skill_level [SMUGGLING_ABILITY] + 1) - exp_level(victim-> skill_level [SMUGGLING_ABILITY]))); ch_printf(victim, "You receive %ld experience for smuggling %s. \n\r", ch_exp, obj->short_descr); gain_exp(victim, ch_exp, SMUGGLING_ABILITY); act(AT_ACTION, "$n looks at $N suspiciously.", ch, NULL, victim, TO_NOTVICT); act(AT_ACTION, "$n look at you suspiciously.", ch, NULL, victim, TO_VICT); SET_BIT(obj->extra_flags, ITEM_CONTRABAND); return TRUE; } else if (!IS_SET (obj->extra_flags, ITEM_CONTRABAND)) { ch_exp = UMIN(obj->cost * 10, (exp_level (victim-> skill_level [SMUGGLING_ABILITY] + 1) - exp_level(victim-> skill_level [SMUGGLING_ABILITY]))); ch_printf(victim, "You receive %ld experience for smuggling %s. \n\r", ch_exp, obj->short_descr); gain_exp(victim, ch_exp, SMUGGLING_ABILITY); SET_BIT(obj->extra_flags, ITEM_CONTRABAND); return TRUE; } } else if (obj->item_type == ITEM_CONTAINER) { OBJ_DATA *content; for (content = obj->first_content; content; content = content->next_content) { if (content->pIndexData->item_type == ITEM_SPICE && !IS_SET(content->extra_flags, ITEM_CONTRABAND)) { ch_exp = UMIN(content->cost * 10, (exp_level (victim-> skill_level [SMUGGLING_ABILITY] + 1) - exp_level(victim-> skill_level [SMUGGLING_ABILITY]))); ch_printf(victim, "You receive %ld experience for smuggling %s.\n\r ", ch_exp, content->short_descr); gain_exp(victim, ch_exp, SMUGGLING_ABILITY); SET_BIT(content->extra_flags, ITEM_CONTRABAND); return TRUE; } } } } } return FALSE; }
bool spec_customs_weapons(CHAR_DATA * ch) { CHAR_DATA *victim; CHAR_DATA *v_next; OBJ_DATA *obj; BOUNTY_DATA *bounty; char buf[MAX_STRING_LENGTH]; long ch_exp; if (!IS_AWAKE(ch) || ch->position == POS_FIGHTING) return FALSE; for (victim = ch->in_room->first_person; victim; victim = v_next) { v_next = victim->next_in_room; if (IS_NPC(victim) || victim->position == POS_FIGHTING) continue; if (victim->pcdata && victim->pcdata->clan && !str_cmp(victim->pcdata->clan->name, ch->mob_clan)) continue; for (obj = victim->last_carrying; obj; obj = obj->prev_content) { if (obj->pIndexData->item_type == ITEM_WEAPON) { if (victim != ch && can_see(ch, victim) && can_see_obj(ch, obj)) { bounty = get_disintigration(ch->name); // A large portion of text was removed because of the spammage - Gatz if (!IS_NPC(victim) && victim->pcdata->weaponl == 0) { /* act( AT_ACTION, "$n looks at $N suspiciously.", ch, NULL, victim, TO_NOTVICT ); act( AT_ACTION, "$n look at you suspiciously.", ch, NULL, victim, TO_VICT ); sprintf( buf , "Oh, you have a weapon license. Move along."); do_say( ch , buf ); */ return; } // Charm code if (!IS_NPC(victim) && victim->pcdata-> learned[gsn_negotiate]) { if (number_range(0, 5) > 3) { learn_from_success(ch, gsn_negotiate); return; } } if (victim->pcdata && victim->pcdata->clan && (!str_cmp (victim->pcdata->clan->name, "ISSP")) && !bounty) { /* act( AT_ACTION, "$n looks at $N suspiciously.", ch, NULL, victim, TO_NOTVICT ); act( AT_ACTION, "$n look at you suspiciously.", ch, NULL, victim, TO_VICT ); sprintf( buf , "Oh, you are ISSP! You are allowed to carry weapons."); do_say( ch , buf ); */ return; } if (victim->pcdata && victim->pcdata->clan && (!str_cmp (victim->pcdata->clan->name, "RBH")) && !bounty) { /* act( AT_ACTION, "$n looks at $N suspiciously.", ch, NULL, victim, TO_NOTVICT ); act( AT_ACTION, "$n look at you suspiciously.", ch, NULL, victim, TO_VICT ); sprintf( buf , "Oh, you are RBH! You are allowed to carry weapons."); do_say( ch , buf ); */ return; } /* sprintf( buf , "Weapons are not allowed for any Non ISSP or RBH, or people without a license to carry a Weapon. I'm going to have to confiscate %s.", obj->short_descr ); do_say( ch , buf ); if ( obj->wear_loc != WEAR_NONE ) remove_obj( victim, obj->wear_loc, TRUE ); separate_obj( obj ); obj_from_char( obj ); act( AT_ACTION, "$n confiscates $p from $N.", ch, obj, victim, TO_NOTVICT ); act( AT_ACTION, "$n takes $p from you.", ch, obj, victim, TO_VICT ); obj = obj_to_char( obj, ch ); SET_BIT( obj->extra_flags , ITEM_CONTRABAND); // ch_exp = UMIN( obj->cost*10 , ( exp_level( victim->skill_level[DIPLOMACY_ABILITY]+1) - exp_level( victim->skill_level[DIPLOMACY_ABILITY]) ) ); // ch_printf( victim, "You lose %ld diplomacy experience.\n\r " , ch_exp ); gain_exp( victim, 0-ch_exp , DIPLOMACY_ABILITY); return TRUE; */ } else if (can_see(ch, victim) && !IS_SET(obj->extra_flags, ITEM_CONTRABAND)) { ch_exp = UMIN(obj->cost * 10, (exp_level (victim-> skill_level [SMUGGLING_ABILITY] + 1) - exp_level(victim-> skill_level [SMUGGLING_ABILITY]))); ch_printf(victim, "You receive %ld experience for smuggling %d.\n\r ", ch_exp, obj->short_descr); gain_exp(victim, ch_exp, SMUGGLING_ABILITY); act(AT_ACTION, "$n looks at $N suspiciously.", ch, NULL, victim, TO_NOTVICT); act(AT_ACTION, "$n look at you suspiciously.", ch, NULL, victim, TO_VICT); SET_BIT(obj->extra_flags, ITEM_CONTRABAND); return TRUE; } else if (!IS_SET (obj->extra_flags, ITEM_CONTRABAND)) { ch_exp = UMIN(obj->cost * 10, (exp_level (victim-> skill_level [SMUGGLING_ABILITY] + 1) - exp_level(victim-> skill_level [SMUGGLING_ABILITY]))); ch_printf(victim, "You receive %ld experience for smuggling %s.\n\r ", ch_exp, obj->short_descr); gain_exp(victim, ch_exp, SMUGGLING_ABILITY); SET_BIT(obj->extra_flags, ITEM_CONTRABAND); return TRUE; } } else if (obj->item_type == ITEM_CONTAINER) { OBJ_DATA *content; for (content = obj->first_content; content; content = content->next_content) { if (content->pIndexData->item_type == ITEM_WEAPON && !IS_SET(content->extra_flags, ITEM_CONTRABAND)) { ch_exp = UMIN(content->cost * 10, (exp_level (victim-> skill_level [SMUGGLING_ABILITY] + 1) - exp_level(victim-> skill_level [SMUGGLING_ABILITY]))); ch_printf(victim, "You receive %ld experience for smuggling %s.\n\r ", ch_exp, content->short_descr); gain_exp(victim, ch_exp, SMUGGLING_ABILITY); SET_BIT(content->extra_flags, ITEM_CONTRABAND); return TRUE; } } } } } return FALSE; }
/* * ------------------------------------------------------------------------ * EXPAND_ARG * This is a hack of act() in comm.c. I've added some safety guards, * so that missing or invalid $-codes do not crash the server * ------------------------------------------------------------------------ */ void expand_arg( char *buf, const char *format, CHAR_DATA *mob, CHAR_DATA *ch, const void *arg1, const void *arg2, CHAR_DATA *rch ) { static char * const he_she [] = { "it", "he", "she" }; static char * const him_her [] = { "it", "him", "her" }; static char * const his_her [] = { "its", "his", "her" }; const char *someone = "someone"; const char *something = "something"; const char *someones = "someone's"; char fname[MAX_INPUT_LENGTH]; CHAR_DATA *vch = (CHAR_DATA *) arg2; OBJ_DATA *obj1 = (OBJ_DATA *) arg1; OBJ_DATA *obj2 = (OBJ_DATA *) arg2; const char *str; const char *i; char *point; /* * Discard null and zero-length messages. */ if ( format == NULL || format[0] == '\0' ) return; point = buf; str = format; while ( *str != '\0' ) { if ( *str != '$' ) { *point++ = *str++; continue; } ++str; switch ( *str ) { default: bug( "Expand_arg: bad code %d.", *str ); i = " <@@@> "; break; case 'i': one_argument( mob->name, fname ); i = fname; break; case 'I': i = mob->short_descr; break; case 'n': i = someone; if ( ch != NULL && can_see( mob, ch ) ) { one_argument( ch->name, fname ); i = capitalize(fname); } break; case 'N': i = (ch != NULL && can_see( mob, ch ) ) ? ( IS_NPC( ch ) ? ch->short_descr : ch->name ) : someone; break; case 't': i = someone; if ( vch != NULL && can_see( mob, vch ) ) { one_argument( vch->name, fname ); i = capitalize(fname); } break; case 'T': i = (vch != NULL && can_see( mob, vch )) ? ( IS_NPC( vch ) ? vch->short_descr : vch->name ) : someone; break; case 'r': if ( rch == NULL ) rch = get_random_char( mob ); i = someone; if( rch != NULL && can_see( mob, rch ) ) { one_argument( rch->name, fname ); i = capitalize(fname); } break; case 'R': if ( rch == NULL ) rch = get_random_char( mob ); i = ( rch != NULL && can_see( mob, rch ) ) ? ( IS_NPC( ch ) ? ch->short_descr : ch->name ) :someone; break; case 'q': i = someone; if ( mob->mprog_target != NULL && can_see( mob, mob->mprog_target ) ) { one_argument( mob->mprog_target->name, fname ); i = capitalize( fname ); } break; case 'Q': i = (mob->mprog_target != NULL && can_see( mob, mob->mprog_target )) ? ( IS_NPC( mob->mprog_target ) ? mob->mprog_target->short_descr : mob->mprog_target->name ) : someone; break; case 'j': i = he_she [URANGE(0, mob->sex, 2)]; break; case 'e': i = (ch != NULL && can_see( mob, ch )) ? he_she [URANGE(0, ch->sex, 2)] : someone; break; case 'E': i = (vch != NULL && can_see( mob, vch )) ? he_she [URANGE(0, vch->sex, 2)] : someone; break; case 'J': i = (rch != NULL && can_see( mob, rch )) ? he_she [URANGE(0, rch->sex, 2)] : someone; break; case 'X': i = (mob->mprog_target != NULL && can_see( mob, mob->mprog_target)) ? he_she [URANGE(0, mob->mprog_target->sex, 2)] : someone; break; case 'k': i = him_her [URANGE(0, mob->sex, 2)]; break; case 'm': i = (ch != NULL && can_see( mob, ch )) ? him_her [URANGE(0, ch ->sex, 2)] : someone; break; case 'M': i = (vch != NULL && can_see( mob, vch )) ? him_her [URANGE(0, vch ->sex, 2)] : someone; break; case 'K': if ( rch == NULL ) rch = get_random_char( mob ); i = (rch != NULL && can_see( mob, rch )) ? him_her [URANGE(0, rch ->sex, 2)] : someone; break; case 'Y': i = (mob->mprog_target != NULL && can_see( mob, mob->mprog_target )) ? him_her [URANGE(0, mob->mprog_target->sex, 2)] : someone; break; case 'l': i = his_her [URANGE(0, mob ->sex, 2)]; break; case 's': i = (ch != NULL && can_see( mob, ch )) ? his_her [URANGE(0, ch ->sex, 2)] : someones; break; case 'S': i = (vch != NULL && can_see( mob, vch )) ? his_her [URANGE(0, vch ->sex, 2)] : someones; break; case 'L': if ( rch == NULL ) rch = get_random_char( mob ); i = ( rch != NULL && can_see( mob, rch ) ) ? his_her [URANGE(0, rch ->sex, 2)] : someones; break; case 'Z': i = (mob->mprog_target != NULL && can_see( mob, mob->mprog_target )) ? his_her [URANGE(0, mob->mprog_target->sex, 2)] : someones; break; case 'o': i = something; if ( obj1 != NULL && can_see_obj( mob, obj1 ) ) { one_argument( obj1->name, fname ); i = fname; } break; case 'O': i = (obj1 != NULL && can_see_obj( mob, obj1 )) ? obj1->short_descr : something; break; case 'p': i = something; if ( obj2 != NULL && can_see_obj( mob, obj2 ) ) { one_argument( obj2->name, fname ); i = fname; } break; case 'P': i = (obj2 != NULL && can_see_obj( mob, obj2 )) ? obj2->short_descr : something; break; } ++str; while ( ( *point = *i ) != '\0' ) ++point, ++i; } *point = '\0'; return; }
/* --------------------------------------------------------------------- * CMD_EVAL * This monster evaluates an if/or/and statement * There are five kinds of statement: * 1) keyword and value (no $-code) if random 30 * 2) keyword, comparison and value if people > 2 * 3) keyword and actor if isnpc $n * 4) keyword, actor and value if carries $n sword * 5) keyword, actor, comparison and value if level $n >= 10 * *---------------------------------------------------------------------- */ int cmd_eval( sh_int vnum, char *line, int check, CHAR_DATA *mob, CHAR_DATA *ch, const void *arg1, const void *arg2, CHAR_DATA *rch ) { CHAR_DATA *lval_char = mob; CHAR_DATA *vch = (CHAR_DATA *) arg2; OBJ_DATA *obj1 = (OBJ_DATA *) arg1; OBJ_DATA *obj2 = (OBJ_DATA *) arg2; OBJ_DATA *lval_obj = NULL; char *original, buf[MAX_INPUT_LENGTH], code; int lval = 0, oper = 0, rval = -1; original = line; line = one_argument( line, buf ); if ( buf[0] == '\0' || mob == NULL ) return FALSE; /* * If this mobile has no target, let's assume our victim is the one */ if ( mob->mprog_target == NULL ) mob->mprog_target = ch; switch ( check ) { /* * Case 1: keyword and value */ case CHK_RAND: return( atoi( buf ) < number_percent() ); case CHK_MOBHERE: if ( is_number( buf ) ) return( get_mob_vnum_room( mob, atoi(buf) ) ); else return( (bool) (get_char_room( mob, buf) != NULL) ); case CHK_OBJHERE: if ( is_number( buf ) ) return( get_obj_vnum_room( mob, atoi(buf) ) ); else return( (bool) (get_obj_here( mob, buf) != NULL) ); case CHK_MOBEXISTS: return( (bool) (get_char_world( mob, buf) != NULL) ); case CHK_OBJEXISTS: return( (bool) (get_obj_world( mob, buf) != NULL) ); /* * Case 2 begins here: We sneakily use rval to indicate need * for numeric eval... */ case CHK_PEOPLE: rval = count_people_room( mob, 0 ); break; case CHK_PLAYERS: rval = count_people_room( mob, 1 ); break; case CHK_MOBS: rval = count_people_room( mob, 2 ); break; case CHK_CLONES: rval = count_people_room( mob, 3 ); break; case CHK_ORDER: rval = get_order( mob ); break; case CHK_HOUR: rval = time_info.hour; break; default:; } /* * Case 2 continued: evaluate expression */ if ( rval >= 0 ) { if ( (oper = keyword_lookup( fn_evals, buf )) < 0 ) { sprintf( buf, "Cmd_eval: prog %d syntax error(2) '%s'", vnum, original ); bug( buf, 0 ); return FALSE; } one_argument( line, buf ); lval = rval; rval = atoi( buf ); return( num_eval( lval, oper, rval ) ); } /* * Case 3,4,5: Grab actors from $* codes */ if ( buf[0] != '$' || buf[1] == '\0' ) { sprintf( buf, "Cmd_eval: prog %d syntax error(3) '%s'", vnum, original ); bug( buf, 0 ); return FALSE; } else code = buf[1]; switch( code ) { case 'i': lval_char = mob; break; case 'n': lval_char = ch; break; case 't': lval_char = vch; break; case 'r': lval_char = rch == NULL ? get_random_char( mob ) : rch ; break; case 'o': lval_obj = obj1; break; case 'p': lval_obj = obj2; break; case 'q': lval_char = mob->mprog_target; break; default: sprintf( buf, "Cmd_eval: prog %d syntax error(4) '%s'", vnum, original ); bug( buf, 0 ); return FALSE; } /* * From now on, we need an actor, so if none was found, bail out */ if ( lval_char == NULL && lval_obj == NULL ) return FALSE; /* * Case 3: Keyword, comparison and value */ switch( check ) { case CHK_ISPC: return( lval_char != NULL && !IS_NPC( lval_char ) ); case CHK_ISNPC: return( lval_char != NULL && IS_NPC( lval_char ) ); case CHK_ISGOOD: return( lval_char != NULL && IS_GOOD( lval_char ) ); case CHK_ISEVIL: return( lval_char != NULL && IS_EVIL( lval_char ) ); case CHK_ISNEUTRAL: return( lval_char != NULL && IS_NEUTRAL( lval_char ) ); case CHK_ISIMMORT: return( lval_char != NULL && IS_IMMORTAL( lval_char ) ); case CHK_ISCHARM: /* A relic from MERC 2.2 MOBprograms */ return( lval_char != NULL && IS_AFFECTED( lval_char, AFF_CHARM ) ); case CHK_ISFOLLOW: return( lval_char != NULL && lval_char->master != NULL && lval_char->master->in_room == lval_char->in_room ); case CHK_ISACTIVE: return( lval_char != NULL && lval_char->position > POS_SLEEPING ); case CHK_ISDELAY: return( lval_char != NULL && lval_char->mprog_delay > 0 ); case CHK_ISVISIBLE: switch( code ) { default : case 'i': case 'n': case 't': case 'r': case 'q': return( lval_char != NULL && can_see( mob, lval_char ) ); case 'o': case 'p': return( lval_obj != NULL && can_see_obj( mob, lval_obj ) ); } case CHK_HASTARGET: return( lval_char != NULL && lval_char->mprog_target != NULL && lval_char->in_room == lval_char->mprog_target->in_room ); case CHK_ISTARGET: return( lval_char != NULL && mob->mprog_target == lval_char ); default:; } /* * Case 4: Keyword, actor and value */ line = one_argument( line, buf ); switch( check ) { case CHK_AFFECTED: return( lval_char != NULL && IS_SET(lval_char->affected_by, flag_lookup(buf, affect_flags)) ); case CHK_ACT: return( lval_char != NULL && IS_SET(lval_char->act, flag_lookup(buf, act_flags)) ); case CHK_IMM: return( lval_char != NULL && IS_SET(lval_char->imm_flags, flag_lookup(buf, imm_flags)) ); case CHK_OFF: return( lval_char != NULL && IS_SET(lval_char->off_flags, flag_lookup(buf, off_flags)) ); case CHK_CARRIES: if ( is_number( buf ) ) return( lval_char != NULL && has_item( lval_char, atoi(buf), -1, FALSE ) ); else return( lval_char != NULL && (get_obj_carry( lval_char, buf ) != NULL) ); case CHK_WEARS: if ( is_number( buf ) ) return( lval_char != NULL && has_item( lval_char, atoi(buf), -1, TRUE ) ); else return( lval_char != NULL && (get_obj_wear( lval_char, buf ) != NULL) ); case CHK_HAS: return( lval_char != NULL && has_item( lval_char, -1, item_lookup(buf), FALSE ) ); case CHK_USES: return( lval_char != NULL && has_item( lval_char, -1, item_lookup(buf), TRUE ) ); case CHK_NAME: switch( code ) { default : case 'i': case 'n': case 't': case 'r': case 'q': return( lval_char != NULL && is_name( buf, lval_char->name ) ); case 'o': case 'p': return( lval_obj != NULL && is_name( buf, lval_obj->name ) ); } case CHK_POS: return( lval_char != NULL && lval_char->position == position_lookup( buf ) ); case CHK_CLAN: return( lval_char != NULL && lval_char->clan == clan_lookup( buf ) ); case CHK_RACE: return( lval_char != NULL && lval_char->race == race_lookup( buf ) ); case CHK_OBJTYPE: return( lval_obj != NULL && lval_obj->item_type == item_lookup( buf ) ); default:; } /* * Case 5: Keyword, actor, comparison and value */ if ( (oper = keyword_lookup( fn_evals, buf )) < 0 ) { sprintf( buf, "Cmd_eval: prog %d syntax error(5): '%s'", vnum, original ); bug( buf, 0 ); return FALSE; } one_argument( line, buf ); rval = atoi( buf ); switch( check ) { case CHK_VNUM: switch( code ) { default : case 'i': case 'n': case 't': case 'r': case 'q': if( lval_char != NULL && IS_NPC( lval_char ) ) lval = lval_char->pIndexData->vnum; break; case 'o': case 'p': if ( lval_obj != NULL ) lval = lval_obj->pIndexData->vnum; } break; case CHK_HPCNT: if ( lval_char != NULL ) lval = (lval_char->hit * 100)/(UMAX(1,lval_char->max_hit)); break; case CHK_ROOM: if ( lval_char != NULL && lval_char->in_room != NULL ) lval = lval_char->in_room->vnum; break; case CHK_SEX: if ( lval_char != NULL ) lval = lval_char->sex; break; case CHK_LEVEL: if ( lval_char != NULL ) lval = lval_char->level; break; case CHK_ALIGN: if ( lval_char != NULL ) lval = lval_char->alignment; break; case CHK_MONEY: /* Money is converted to silver... */ if ( lval_char != NULL ) lval = lval_char->gold + (lval_char->silver * 100); break; case CHK_OBJVAL0: if ( lval_obj != NULL ) lval = lval_obj->value[0]; break; case CHK_OBJVAL1: if ( lval_obj != NULL ) lval = lval_obj->value[1]; break; case CHK_OBJVAL2: if ( lval_obj != NULL ) lval = lval_obj->value[2]; break; case CHK_OBJVAL3: if ( lval_obj != NULL ) lval = lval_obj->value[3]; break; case CHK_OBJVAL4: if ( lval_obj != NULL ) lval = lval_obj->value[4]; break; case CHK_GRPSIZE: if( lval_char != NULL ) lval = count_people_room( lval_char, 4 ); break; default: return FALSE; } return( num_eval( lval, oper, rval ) ); }
void look_extras(struct char_data *ch, const char *name, const int number) { struct gameobject *obj; int count; char *pdesc; if (!validate_look(ch)) { return; } count = 0; for (obj = ch->carrying; obj != NULL; obj = obj->next_content) { if (can_see_obj(ch, obj)) { /* player can see object */ pdesc = get_extra_descr(name, obj->extra_descr); if (pdesc != NULL) { if (++count == number) { send_to_char(pdesc, ch); return; } else { continue; } } pdesc = get_extra_descr(name, obj->objprototype->extra_descr); if (pdesc != NULL) { if (++count == number) { send_to_char(pdesc, ch); return; } else { continue; } } if (is_name(name, object_name_get(obj))) { if (++count == number) { send_to_char(obj->description, ch); send_to_char("\n\r", ch); return; } } } } for (obj = ch->in_room->contents; obj != NULL; obj = obj->next_content) { if (can_see_obj(ch, obj)) { pdesc = get_extra_descr(name, obj->extra_descr); if (pdesc != NULL) { if (++count == number) { send_to_char(pdesc, ch); return; } } pdesc = get_extra_descr(name, obj->objprototype->extra_descr); if (pdesc != NULL) { if (++count == number) { send_to_char(pdesc, ch); return; } } } if (is_name(name, object_name_get(obj))) { if (++count == number) { send_to_char(obj->description, ch); send_to_char("\n\r", ch); return; } } } pdesc = get_extra_descr(name, ch->in_room->extra_descr); if (pdesc != NULL) { if (++count == number) { send_to_char(pdesc, ch); return; } } if (count == 0) { send_to_char("You don't see that here.", ch); return; } if (count > 0 && count != number) { if (count == 1) printf_to_char(ch, "You only see one %s here.\n\r", name); else printf_to_char(ch, "You only see %d of those here.\n\r", count); return; } }
void stand(struct char_data *ch, struct gameobject *on) { // TODO - need to extract can_get_obj from get_obj // Impassible positions. switch (ch->position) { case POS_STANDING: if (on == NULL || on == ch->on) { send_to_char("You are already standing.\n\r", ch); return; } break; case POS_FIGHTING: send_to_char("Maybe you should finish this fight first?\n\r", ch); return; case POS_SLEEPING: if (IS_AFFECTED(ch, AFF_SLEEP)) { send_to_char("You can't wake up!\n\r", ch); return; } break; } // Validate target object, if any. if (on != NULL) { if (!is_standupon(on)) { send_to_char("You can't seem to find a place to stand.\n\r", ch); return; } if (ch->on != on && (long)count_users(on) >= on->value[0]) { act_new("There's no room to stand on $p.", ch, on, NULL, TO_ROOM, POS_DEAD, false); return; } // TODO check if object is gettable } // stand up, possibly on something. ch->position = POS_STANDING; if (on != ch->on) { struct gameobject *old_on = ch->on; ch->on = on; if (old_on != NULL && can_see_obj(ch, old_on)) { // TODO - only if object is gettable. get_obj(ch, old_on, NULL); } } // Notify. switch (ch->position) { default: if (on == NULL) { send_to_char("You stand up.\n\r", ch); act("$n stands up.", ch, NULL, NULL, TO_ROOM); } else if (IS_SET(on->value[2], STAND_AT)) { act("You stand at $p.", ch, on, NULL, TO_CHAR); act("$n stands at $p.", ch, on, NULL, TO_ROOM); } else if (IS_SET(on->value[2], STAND_ON)) { act("You stand on $p.", ch, on, NULL, TO_CHAR); act("$n stands on $p.", ch, on, NULL, TO_ROOM); } else { act("You stand in $p.", ch, on, NULL, TO_CHAR); act("$n stands on $p.", ch, on, NULL, TO_ROOM); } break; case POS_SLEEPING: if (on == NULL) { send_to_char("You wake and stand up.\n\r", ch); act("$n wakes and stands up.", ch, NULL, NULL, TO_ROOM); } else if (IS_SET(on->value[2], STAND_AT)) { act_new("You wake and stand at $p.", ch, on, NULL, TO_CHAR, POS_DEAD, false); act("$n wakes and stands at $p.", ch, on, NULL, TO_ROOM); } else if (IS_SET(on->value[2], STAND_ON)) { act_new("You wake and stand on $p.", ch, on, NULL, TO_CHAR, POS_DEAD, false); act("$n wakes and stands on $p.", ch, on, NULL, TO_ROOM); } else { act_new("You wake and stand in $p.", ch, on, NULL, TO_CHAR, POS_DEAD, false); act("$n wakes and stands in $p.", ch, on, NULL, TO_ROOM); } look_room(ch, ch->in_room); break; } }
void do_buy( CHAR_DATA * ch, char *argument ) { char arg[MAX_INPUT_LENGTH]; int maxgold = 0; argument = one_argument( argument, arg ); if( arg[0] == '\0' ) { send_to_char( "Buy what?\r\n", ch ); return; } /* in case of different shop types */ { CHAR_DATA *keeper = NULL; OBJ_DATA *obj = NULL; int cost = 0; int noi = 1; /* Number of items */ short 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; } } obj = get_obj_carry( keeper, arg ); if( !obj && arg[0] == '#' ) { int onum = 0, oref = atoi( arg + 1 ); bool ofound = FALSE; 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; } cost = ( get_cost( ch, keeper, obj, TRUE ) * noi ); 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 ) ) { char buf[MAX_STRING_LENGTH]; snprintf( buf, MAX_STRING_LENGTH, "%s", "laugh" ); interpret( keeper, buf ); 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 ) { act( AT_TELL, "$n tells you 'You can't afford to buy $p.'", keeper, obj, ch, TO_VICT ); ch->reply = keeper; return; } if( IS_SET( obj->extra_flags, ITEM_PROTOTYPE ) && IS_IMMORTAL( ch ) ) { 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.\r\n", 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.\r\n", 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 ); } ch->gold -= cost; keeper->gold += cost; if( keeper->gold > maxgold ) { 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 = create_object( obj->pIndexData ); OBJ_DATA *bag = NULL; /* * 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 ) ); /* 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; } }
/* * Show a list to a character. * Can coalesce duplicated items. */ void show_list_to_char(struct gameobject *list, struct char_data *ch, bool fShort, bool fShowNothing) { struct gameobject *obj; char buf[13000]; char **prgpstrShow; char *pstrShow; int *prgnShow; int nShow; int iShow; unsigned int count; bool fCombine; if (ch->desc == NULL) return; /* * Alloc space for output lines. */ count = 0; for (obj = list; obj != NULL; obj = obj->next_content) count++; prgpstrShow = alloc_mem(count * (unsigned int)sizeof(char *)); prgnShow = alloc_mem(count * (unsigned int)sizeof(int)); nShow = 0; /* * Format the list of objects. */ for (obj = list; obj != NULL; obj = obj->next_content) { if (obj->wear_loc == WEAR_NONE && can_see_obj(ch, obj)) { pstrShow = format_obj_to_char(obj, ch, fShort); fCombine = false; if (IS_NPC(ch) || IS_SET(ch->comm, COMM_COMBINE)) { /* * Look for duplicates, case sensitive. * Matches tend to be near end so run loop backwords. */ for (iShow = nShow - 1; iShow >= 0; iShow--) { if (!strcmp(prgpstrShow[iShow], pstrShow)) { prgnShow[iShow]++; fCombine = true; break; } } } /* * Couldn't combine, or didn't want to. */ if (!fCombine) { prgpstrShow[nShow] = str_dup(pstrShow); prgnShow[nShow] = 1; nShow++; if (nShow > 125) { send_to_char("Tell whoever it is you are looking at to drop some crap.\n\r", ch); send_to_char("Maximum number of items in a list exceeded.\n\r", ch); return; } } } } /* * Output the formatted list. */ for (iShow = 0; iShow < nShow; iShow++) { if (prgpstrShow[iShow][0] == '\0') { free_string(prgpstrShow[iShow]); continue; } if (IS_NPC(ch) || IS_SET(ch->comm, COMM_COMBINE)) { if (prgnShow[iShow] != 1) { sprintf(buf, "(%3d) ", prgnShow[iShow]); send_to_char(buf, ch); } else { send_to_char(" ", ch); } } page_to_char(prgpstrShow[iShow], ch); send_to_char("\n\r", ch); free_string(prgpstrShow[iShow]); } if (fShowNothing && nShow == 0) { if (IS_NPC(ch) || IS_SET(ch->comm, COMM_COMBINE)) send_to_char(" ", ch); send_to_char("Nothing.\n\r", ch); } /* * Clean up. */ free_mem(prgpstrShow, count * (int)sizeof(char *)); free_mem(prgnShow, count * (int)sizeof(int)); return; }
/** * owhere <var> <value> */ void do_owhere(struct char_data *ch, const char *argument) { struct buf_type *buffer; OBJ_CMP_FN *cmp_fn; char buf[MAX_INPUT_LENGTH]; char arg[MAX_INPUT_LENGTH]; int iter; if (ch == NULL || IS_NPC(ch)) return; if (argument[0] == '\0') { send_to_char("\n\rFind what?\n\r", ch); return; } cmp_fn = NULL; one_argument(argument, arg); if (argument[0] == '?' || !str_prefix(argument, "help")) { show_help(ch->desc, "owhere", NULL); return; } buffer = new_buf(); if (!str_prefix(argument, "list")) { add_buf(buffer, "owhere: searchable property list\n\r"); for (iter = 0; obj_flags[iter].var[0] != '\0'; iter++) { sprintf(buf, "%-18.17s", obj_flags[iter].var); add_buf(buffer, buf); if ((iter % 2) == 1) add_buf(buffer, "\n\r"); } add_buf(buffer, "\n\r"); page_to_char(buf_string(buffer), ch); return; } sprintf(buf, "`#QUERY``: owhere %s\n\r\n\r", argument); add_buf(buffer, buf); for (iter = 0; obj_flags[iter].var[0] != '\0'; iter++) { if (!str_prefix(arg, obj_flags[iter].var)) { cmp_fn = (OBJ_CMP_FN *)obj_flags[iter].fn; argument = one_argument(argument, arg); break; } } if (cmp_fn == NULL) cmp_fn = obj_cmp_name; if (argument[0] == '?' || argument[0] == '\0') { clear_buf(buffer); sprintf(buf, "`#SYNTAX``:\n\r owhere %s <value>:\n\r\n\r", arg); add_buf(buffer, buf); (*cmp_fn)(object_iterator_start(&object_empty_filter), argument, buffer); page_to_char(buf_string(buffer), ch); } else { struct gameobject *obj, *opending; struct gameobject *in_obj; char *clr1; char *clr2; int number; number = 0; opending = object_iterator_start(&object_empty_filter); while ((obj = opending) != NULL) { opending = object_iterator(obj, &object_empty_filter); if (can_see_obj(ch, obj) && (*cmp_fn)(obj, argument, NULL)) { number++; if (number == 1) { sprintf(buf, "# vnum name where room\n\r"); add_buf(buffer, buf); sprintf(buf, "=== ====== =========================== ========================== =====\n\r"); add_buf(buffer, buf); } for (in_obj = obj; in_obj->in_obj != NULL; in_obj = in_obj->in_obj) continue; if (in_obj->carried_by != NULL && can_see(ch, in_obj->carried_by) && in_obj->carried_by->in_room != NULL) { clr1 = uncolor_str(obj->short_descr); clr2 = uncolor_str(PERS(in_obj->carried_by, ch)); sprintf(buf, "%-3d %-7ld %-26.26s %-25.25s %-7ld\n\r", number, obj->objprototype->vnum, clr1, clr2, in_obj->carried_by->in_room->vnum); free_string(clr1); free_string(clr2); } else if (in_obj->in_room != NULL && can_see_room(ch, in_obj->in_room)) { clr1 = uncolor_str(obj->short_descr); clr2 = uncolor_str(in_obj->in_room->name); sprintf(buf, "%-3d %-7ld %-26.26s %-25.25s %-7ld\n\r", number, obj->objprototype->vnum, clr1, clr2, in_obj->in_room->vnum); free_string(clr1); free_string(clr2); } else { clr1 = uncolor_str(obj->short_descr); sprintf(buf, "%-3d %-7ld %-26.26s\n\r", number, obj->objprototype->vnum, clr1); free_string(clr1); } buf[0] = UPPER(buf[0]); add_buf(buffer, buf); if (number >= MAX_RETURN) break; } } if (number == 0) send_to_char("Nothing like that in heaven or earth.\n\r", ch); else page_to_char(buf_string(buffer), ch); } free_buf(buffer); }
char *emote_processor( CHAR_DATA *ch, char *argument, bool fPemote, bool fSemote, CHAR_DATA *vch ) { static char buf[MAX_STRING_LENGTH]; CHAR_DATA *wch; OBJ_DATA *obj; bool fBegin = TRUE, fPoss = FALSE; char word[MAX_INPUT_LENGTH]; char *pin = argument; for ( pin = argument; *pin != '\0'; pin++ ) { if ( *pin == '@' ) { fBegin = FALSE; break; } } pin = argument; buf[0] = '\0'; /* If no @, copy emoter's short desc. */ if (fBegin) { // if (vch == ch) { // strcat(buf, (fPemote ? "your" : "you")); // } else { strcpy(buf, person(vch, ch)); if ( fPemote ) { if ( buf[strlen(buf)-1] == 's' ) strcat( buf, "'" ); else strcat( buf, "'s" ); // } // } } strcat( buf, " " ); } while ( *pin != '\0' ) { fPoss = FALSE; switch( *pin ) { default: one_emote_argument( pin, word ); strcat( buf, word ); pin = pin + (strlen( word ) - 1); break; case ' ': strcat( buf, " " ); break; case '@': if (vch == ch) { strcat(buf, (fPemote ? "your" : "you")); } else { strcat(buf, person(vch, ch)); if ( fPemote ) strcat( buf, (buf[strlen(buf)-1] == 's') ? "'" : "'s"); } break; case '%': fPoss = TRUE; case '~': one_emote_argument( &pin[1], word ); if ((obj = get_obj_here(ch, strip_punct(word))) != NULL) { if (can_see_obj(vch, obj)) { strcat( buf, obj->short_descr ); if ( fPoss ) { if ( word[strlen(word) - 1] == 's' ) strcat( buf, "'" ); else strcat( buf, "'s" ); } } else strcat( buf, (fPoss ? "something's" : "something")); } else if ((wch = get_char_room(ch, strip_punct(word))) != NULL) { if (fSemote) wch->leader = ch; if (vch == wch) { strcat(buf, (fPoss ? "your" : "you")); } else { strcat(buf, person(vch, wch)); if (fPoss) { if ( buf[strlen(buf)-1] == 's' ) strcat( buf, "'" ); else strcat( buf, "'s" ); } } } else { sprintf( buf, "%s is not here.\n\r", word ); send_to_char( buf, ch ); return NULL; } pin = pin + strlen( word ); fPoss = FALSE; break; /* %m him/her */ case '!': one_emote_argument( &pin[1], word); if ((obj = get_obj_here(ch, strip_punct(word))) != NULL) { strcat(buf, ((can_see_obj(vch, obj)) ? "it" : "something")); } else if ((wch = get_char_room(ch, strip_punct(word))) != NULL) { if (fSemote) wch->leader = ch; strcat(buf, ((vch == wch) ? "you" : him_her[wch->sex])); } else { sprintf( buf, "%s is not here.\n\r", word ); send_to_char( buf, ch ); return NULL; } pin = pin + strlen( word ); break; /* %s his/her */ case '^': one_emote_argument( &pin[1], word); if ((obj = get_obj_here(ch, strip_punct(word))) != NULL) { strcat(buf, ((can_see_obj(vch, obj)) ? "its" : "something's")); } else if ((wch = get_char_room(ch, strip_punct(word))) != NULL) { if (fSemote) wch->leader = ch; strcat(buf, ((vch == wch) ? "your" : his_her[wch->sex])); } else { sprintf( buf, "%s is not here.\n\r", word ); send_to_char( buf, ch ); return NULL; } pin = pin + strlen( word ); break; /* %s he/she */ case '#': one_emote_argument( &pin[1], word); if ((obj = get_obj_here(ch, strip_punct(word))) != NULL) { strcat(buf, ((can_see_obj(vch, obj)) ? "it" : "something")); } else if ((wch = get_char_room(ch, strip_punct(word))) != NULL) { if (fSemote) wch->leader = ch; strcat(buf, ((vch == wch) ? "you" : he_she[wch->sex])); } else { sprintf( buf, "%s is not here.\n\r", word ); send_to_char( buf, ch ); return NULL; } pin = pin + strlen( word ); break; } pin++; } strcat( strip_punct(buf), ".\n\r" ); buf[0] = UPPER( buf[0] ); return buf; }
void do_cdonate( CHAR_DATA *ch, char *arg ) { OBJ_DATA *container; OBJ_DATA *obj; OBJ_DATA *obj_next; char arg1 [ MAX_INPUT_LENGTH ]; if ( !is_clan( ch ) ) { send_to_char( "You aren't a clansman!\n\r", ch ); return; } arg = one_argument( arg, arg1 ); if ( arg1[0] == '\0' ) { send_to_char( "Donate to your clan what?\n\r", ch ); return; } for ( container = object_list; container; container = container->next ) { if ( can_see_obj( ch, container ) && container->pIndexData->vnum == ch->pcdata->clan->donation ) break; } if ( !container ) { send_to_char( "The donation pit is missing from the world.\n\r", ch ); return; } if ( str_cmp( arg1, "all" ) && str_prefix( "all.", arg1 ) ) { if ( !( obj = get_obj_carry( ch, arg1 ) ) ) { send_to_char( "You do not have that item.\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 ( get_obj_weight( obj ) + get_obj_weight( container ) > container->value[0] ) { send_to_char( "It won't fit.\n\r", ch ); return; } if ( obj->item_type == ITEM_TRASH || obj->item_type == ITEM_FOOD || obj->item_type == ITEM_KEY || obj->item_type == ITEM_PILL ) { act( "You send $p flying to the $P.", ch, obj, container, TO_CHAR ); extract_obj( obj ); return; } obj_from_char( obj ); obj_to_obj( obj, container ); act( "$n sends $p flying to the $P.", ch, obj, container, TO_ROOM ); act( "You send $p flying to the $P.", ch, obj, container, TO_CHAR ); send_to_room( "A loud clank is heard from the pit!", container->in_room ); } else { for ( obj = ch->carrying; obj; obj = obj_next ) { obj_next = obj->next_content; if ( obj->deleted ) continue; if ( ( arg1[3] == '\0' || is_name( &arg1[4], obj->name ) ) && can_see_obj( ch, obj ) && obj->wear_loc == WEAR_NONE && obj != container && can_drop_obj( ch, obj ) && get_obj_weight( obj ) + get_obj_weight( container ) <= container->value[0] ) { if ( obj->item_type == ITEM_TRASH || obj->item_type == ITEM_FOOD || obj->item_type == ITEM_KEY || obj->item_type == ITEM_PILL ) { act( "You send $p flying to the $P.", ch, obj, container, TO_CHAR ); extract_obj( obj ); continue; } obj_from_char( obj ); obj_to_obj( obj, container ); act( "$n sends $p flying to the $P.", ch, obj, container, TO_ROOM ); act( "You send $p flying to the $P.", ch, obj, container, TO_CHAR ); send_to_room( "A loud clank is heard from the pit!\n\r", container->in_room ); ch->pcdata->clan->score += 1; } } } return; }