/*************************************************************************** * This file contains auction code developed by Brian Babey, and any * * communication regarding it should be sent to [bbabey@iname.com] * * Web Address: http://www.erols.com/bribe/ * * * * Much time and thought has gone into this software and you are * * benefitting. We hope that you share your changes too. What goes * * around, comes around. * ***************************************************************************/ /*************************************************************************** * ROM 2.4 is copyright 1993-1995 Russ Taylor * * ROM has been brought to you by the ROM consortium * * Russ Taylor (rtaylor@pacinfo.com) * * Gabrielle Taylor (gtaylor@pacinfo.com) * * Brian Moore (rom@rom.efn.org) * * By using this code, you have agreed to follow the terms of the * * ROM license, in the file Rom24/doc/rom.license * ***************************************************************************/ #if defined(macintosh) #include <types.h> #else #include <sys/types.h> #endif #include <stdlib.h> #include <time.h> #include <stdio.h> #include <string.h> #include "merc.h" void show_obj_stats( CHAR_DATA *ch, OBJ_DATA *obj ); char * flag_string args( ( const struct flag_type *table, int bit ) ); void do_auchn( CHAR_DATA *ch, char *argument ) { DESCRIPTOR_DATA *d; char buf[MAX_STRING_LENGTH]; if ( argument[0] == '\0' ) { return; } for ( d = descriptor_list; d != NULL; d = d->next ) { if ( d->connected == CON_PLAYING && !IS_SET(d->character->deaf, CHANNEL_AUCTION) ) { sprintf(buf,"#l[#0%s#l]#C Auction: ",ch->pcdata->switchname); send_to_char( buf,d->character ); send_to_char( argument, d->character ); send_to_char( "#n\n\r", d->character ); } } return; } void do_auction( CHAR_DATA *ch, char * argument ) { int cp=0; OBJ_DATA * obj; char arg1[MAX_INPUT_LENGTH], buf[MAX_STRING_LENGTH]; char arg2[MAX_INPUT_LENGTH]; argument = one_argument( argument, arg1 ); argument = one_argument( argument, arg2 ); if ( ch == NULL || IS_NPC(ch) ) return; if ( arg1[0] == '\0') { do_auction(ch,"info"); return; } if ( !str_cmp( arg1, "stop" ) && IS_IMMORTAL(ch)) { if (auction_info.item == NULL) {stc("Nothing on auction.\n\r",ch); return; } sprintf(buf, "#R%s stops the auction. %s is confiscated.#n\n\r", ch->pcdata->switchname, auction_info.item->short_descr); do_auchn( ch,buf ); obj_to_char( auction_info.item, ch ); sprintf(buf, "%s appears in your hands..\n\r", auction_info.item->short_descr ); send_to_char( buf, ch ); if (auction_info.high_bidder != NULL) auction_info.high_bidder->pcdata->quest += auction_info.current_bid; auction_info.item->questowner = str_dup(ch->pcdata->switchname); auction_info.high_bidder = NULL; auction_info.item = NULL; auction_info.owner = NULL; auction_info.current_bid = 0; auction_info.status = 0; return; } if ( !str_cmp( arg1, "info" ) ) { obj = auction_info.item; if ( !obj ) { send_to_char("There is nothing up for auction right now.\n\r",ch); return; } if ( auction_info.owner == ch ) { sprintf( buf, "\n\rYou are currently auctioning %s.\n\r", obj->short_descr ); send_to_char( buf, ch ); return; } else show_obj_stats( ch, obj ); return; } if ( !str_cmp( arg1, "bid" ) ) { int bid; int bah; obj = auction_info.item; if ( !obj ) { send_to_char("There is nothing up for auction right now.\n\r",ch); return; } if ( arg2[0] == '\0' ) { send_to_char("You must enter an amount to bid.\n\r",ch); return; } if ( auction_info.owner == ch ) { send_to_char("You cannot bid on your own item.\n\r",ch); return; } bid = atol( arg2 ); bah = bid + 500; if ( bah < bid ) {stc("You need to bid at least 500 more than the current bid.\n\r",ch); return; } if ( bid <= auction_info.current_bid ) { sprintf(buf, "You must bid above the current bid of %d qps.\n\r", auction_info.current_bid ); return; } if ( bid < auction_info.current_bid + 500) { stc("You need to bid 500 more than the current bid.\n\r",ch); return; } if ( bid < auction_info.minbid ) { sprintf( buf, "That's below the minimum bid.\r"); send_to_char(buf,ch); return; } if (ch->pcdata->quest < bid ) { send_to_char("You can't cover that bid.\n\r",ch); return; } sprintf(buf, "#G%s #0just bidded #y%d #0qps for#n %s.#n\n\r", ch->pcdata->switchname, bid, auction_info.item->short_descr); do_auchn( ch,buf); if ( auction_info.high_bidder != NULL ) { auction_info.high_bidder->pcdata->quest += auction_info.bones_held; } cp = UMIN( ch->pcdata->quest, bid ); if ( cp < bid ) { cp = bid; } ch->pcdata->quest -= cp; auction_info.bones_held = cp; auction_info.high_bidder = ch; auction_info.current_bid = bid; auction_info.status = 0; return; } if ( arg2[0] == '\0') { stc("Syntax: auction <object> <min bid>",ch); return; } if ( auction_info.item != NULL ) { send_to_char("There is already another item up for bid.\n\r",ch); return; } if ( (obj = get_obj_carry( ch, arg1)) == NULL ) { send_to_char("You aren't carrying that item.\n\r",ch); return; } if(obj->questowner == NULL || str_cmp(ch->pcdata->switchname,obj->questowner)) { send_to_char("You can only auction objects that you own.\n\r", ch); return; } if (IS_SET(obj->quest, QUEST_ARTIFACT)) { stc("You can't auction artifacts.\n\r",ch); return; } /* if (IS_SET(obj->quest, QUEST_RELIC)) { stc("You can't auction a relic.\n\r",ch); return; } */ if (atoi(arg2) < 1) { send_to_char("Please enter a positive number to start the bidding at.\n\r",ch); return; } auction_info.owner = ch; auction_info.item = obj; auction_info.current_bid = 0; auction_info.status = 0; auction_info.minbid = atoi(arg2); obj->questowner = NULL; sprintf(buf,"#G%s #0has put up#n %s #0for auction. #y[#CMinimum Bid: #R%d #Cqps#y]#n\n\r", ch->pcdata->switchname, obj->short_descr, auction_info.minbid); do_auchn( ch,buf ); obj_from_char( obj ); return; } void auction_update( ) { char buf[MAX_STRING_LENGTH], temp[MAX_STRING_LENGTH]; if ( auction_info.item == NULL ) return; auction_info.status++; if ( auction_info.status == AUCTION_LENGTH ) { sprintf(buf,"%s #RSOLD#n #0to #G%s #0for #R%d #0QPs.#n\n\r", auction_info.item->short_descr, auction_info.high_bidder->name, auction_info.current_bid ); do_auchn( auction_info.high_bidder,buf ); auction_info.owner->pcdata->quest += auction_info.bones_held; auction_info.item->questowner = str_dup(auction_info.high_bidder->pcdata->switchname); sprintf(temp, "%d qps ", auction_info.bones_held ); sprintf(buf, "You receive %d qps.\n\r", auction_info.bones_held); send_to_char( buf, auction_info.owner ); obj_to_char( auction_info.item, auction_info.high_bidder ); sprintf(buf, "%s appears in your hands.\n\r", auction_info.item->short_descr ); send_to_char( buf, auction_info.high_bidder ); auction_info.item = NULL; auction_info.owner = NULL; auction_info.high_bidder = NULL; auction_info.current_bid = 0; auction_info.status = 0; auction_info.bones_held = 0; return; } if ( auction_info.status == AUCTION_LENGTH - 1 ) { sprintf(buf, "%s #0- going #GTWICE#0 at #R%d #0QPs.\n\r", auction_info.item->short_descr, auction_info.current_bid ); do_auchn( auction_info.high_bidder,buf ); return; } if ( auction_info.status == AUCTION_LENGTH - 2 ) { if ( auction_info.current_bid == 0 ) { sprintf(buf, "#0No bids on #n%s #0- item sent back to Auctioner.#n\n\r", auction_info.item->short_descr); do_auchn( auction_info.owner,buf ); obj_to_char( auction_info.item, auction_info.owner ); sprintf(buf, "%s is returned to you.\n\r", auction_info.item->short_descr ); send_to_char( buf, auction_info.owner ); auction_info.item->questowner = str_dup(auction_info.owner->pcdata->switchname); auction_info.item = NULL; auction_info.owner = NULL; auction_info.current_bid = 0; auction_info.status = 0; return; } sprintf(buf, "%s #0- going #GONCE#0 at #R%d#0 QPs.#n\n\r", auction_info.item->short_descr, auction_info.current_bid ); do_auchn( auction_info.high_bidder,buf ); return; } return; } /* * Show_obj_stats: code taken from stock identify spell (-Brian) */ void show_obj_stats( CHAR_DATA *ch, OBJ_DATA *obj ) { char buf[MAX_STRING_LENGTH]; AFFECT_DATA *paf; int itemtype; sprintf(buf,"%s.\n\r",obj->short_descr); send_to_char(buf,ch); sprintf( buf, "Object '%s' is type %s, extra flags %s.\n\rWeight is %d, value is %d.\n\r", obj->name, item_type_name( obj ), extra_bit_name( obj->extra_flags ), obj->weight, obj->cost ); send_to_char( buf, ch ); if (obj->points > 0 && obj->item_type != ITEM_QUEST && obj->item_type != ITEM_PAGE) { sprintf( buf, "Quest point value is %d.\n\r", obj->points ); send_to_char( buf, ch ); } if (obj->questmaker != NULL && strlen(obj->questmaker) > 1 && obj->questowner != NULL && strlen(obj->questowner) > 1) { sprintf( buf, "This object was created by %s, and is owned by %s.\n\r", obj->questmaker,obj->questowner ); send_to_char( buf, ch ); } else if (obj->questmaker != NULL && strlen(obj->questmaker) > 1) { sprintf( buf, "This object was created by %s.\n\r", obj->questmaker ); send_to_char( buf, ch ); } else if (obj->questowner != NULL && strlen(obj->questowner) > 1) { sprintf( buf, "This object is owned by %s.\n\r", obj->questowner ); send_to_char( buf, ch ); } if (IS_SET(obj->spectype, SITEM_COPPER)) send_to_char("This item is forged with copper.\n\r",ch); if (IS_SET(obj->spectype, SITEM_IRON)) send_to_char("This item is forged with iron.\n\r",ch); if (IS_SET(obj->spectype, SITEM_STEEL)) send_to_char("This item is forged with steel.\n\r",ch); if (IS_SET(obj->spectype, SITEM_ADAMANTITE)) send_to_char("This item is forged with adamantite.\n\r",ch); if (IS_SET(obj->spectype, SITEM_TITANIUM)) send_to_char("This item is forged with titanium.\n\r",ch); if (IS_SET(obj->spectype, SITEM_MITHRIL)) send_to_char("This item is forged with mithril.\n\r",ch); if (IS_SET(obj->quest, QUEST_BLOODA)) send_to_char( "This weapon is dripping with kindred blood.\n\r",ch); if (IS_SET(obj->quest, QUEST_ENCHANTED)) send_to_char( "This item has been enchanted.\n\r", ch ); if (IS_SET(obj->quest, QUEST_SPELLPROOF)) send_to_char( "This item is resistant to offensive spells.\n\r", ch ); if( IS_SET(obj->extra_flags, ITEM_MENCHANT)) stc( "This weapon is indeed perfect.\n\r", ch); if (IS_SET(obj->spectype, SITEM_DEMONIC)) send_to_char( "This item is crafted from demonsteel.\n\r", ch ); else if (IS_SET(obj->spectype, SITEM_SILVER)) send_to_char( "This item is crafted from gleaming silver.\n\r", ch ); switch ( obj->item_type ) { case ITEM_PILL: case ITEM_SCROLL: case ITEM_POTION: sprintf( buf, "Level %d spells of:", obj->value[0] ); send_to_char( buf, ch ); if ( obj->value[1] >= 0 && obj->value[1] < MAX_SKILL ) { send_to_char( " '", ch ); send_to_char( skill_table[obj->value[1]].name, ch ); send_to_char( "'", ch ); } if ( obj->value[2] >= 0 && obj->value[2] < MAX_SKILL ) { send_to_char( " '", ch ); send_to_char( skill_table[obj->value[2]].name, ch ); send_to_char( "'", ch ); } if ( obj->value[3] >= 0 && obj->value[3] < MAX_SKILL ) { send_to_char( " '", ch ); send_to_char( skill_table[obj->value[3]].name, ch ); send_to_char( "'", ch ); } send_to_char( ".\n\r", ch ); break; case ITEM_QUEST: sprintf( buf, "Quest point value is %d.\n\r", obj->value[0] ); send_to_char( buf, ch ); break; case ITEM_XPTOKEN: sprintf( buf, "Exp value is : %d.\n\r", (obj->value[1] * 1000000000 + obj->value[0])); send_to_char(buf,ch); break; case ITEM_QUESTCARD: sprintf( buf, "Quest completion reward is %d quest points.\n\r", obj->level ); send_to_char( buf, ch ); break; case ITEM_WAND: case ITEM_STAFF: sprintf( buf, "Has %d(%d) charges of level %d", obj->value[1], obj->value[2], obj->value[0] ); send_to_char( buf, ch ); if ( obj->value[3] >= 0 && obj->value[3] < MAX_SKILL ) { send_to_char( " '", ch ); send_to_char( skill_table[obj->value[3]].name, ch ); send_to_char( "'", ch ); } send_to_char( ".\n\r", ch ); break; case ITEM_WEAPON: sprintf( buf, "Damage is %d to %d (average %d).\n\r", obj->value[1], obj->value[2], ( obj->value[1] + obj->value[2] ) / 2 ); send_to_char( buf, ch ); if (obj->value[0] >= 1000) itemtype = obj->value[0] - ((obj->value[0] / 1000) * 1000); else itemtype = obj->value[0]; if (itemtype > 0) { if (obj->level < 10) sprintf(buf,"%s is a minor spell weapon.\n\r",capitalize(obj->short_descr)); else if (obj->level < 20) sprintf(buf,"%s is a lesser spell weapon.\n\r",capitalize(obj->short_descr)); else if (obj->level < 30) sprintf(buf,"%s is an average spell weapon.\n\r",capitalize(obj->short_descr)); else if (obj->level < 40) sprintf(buf,"%s is a greater spell weapon.\n\r",capitalize(obj->short_descr)); else if (obj->level < 50) sprintf(buf,"%s is a major spell weapon.\n\r",capitalize(obj->short_descr)); else if (obj->level > 50) sprintf(buf,"%s is an ultimate spell weapon.\n\r",capitalize(obj->short_descr)); else sprintf(buf,"%s is a supreme spell weapon.\n\r",capitalize(obj->short_descr)); send_to_char(buf,ch); } if (itemtype == 1) sprintf (buf, "This weapon is dripping with corrosive acid.\n\r"); else if (itemtype == 4) sprintf (buf, "This weapon radiates an aura of darkness.\n\r"); else if (itemtype == 30) sprintf (buf, "This ancient relic is the bane of all evil.\n\r"); else if (itemtype == 34) sprintf (buf, "This vampiric weapon drinks the souls of its victims.\n\r"); else if (itemtype == 37) sprintf (buf, "This weapon has been tempered in hellfire.\n\r"); else if (itemtype == 48) sprintf (buf, "This weapon crackles with sparks of lightning.\n\r"); else if (itemtype == 53) sprintf (buf, "This weapon is dripping with a dark poison.\n\r"); else if (itemtype > 0) sprintf (buf, "This weapon has been imbued with the power of %s.\n\r",skill_table[itemtype].name); if (itemtype > 0) send_to_char( buf, ch ); if (obj->value[0] >= 1000) itemtype = obj->value[0] / 1000; else break; if (itemtype == 4) sprintf (buf, "This weapon radiates an aura of darkness.\n\r"); else if (itemtype == 27 || itemtype == 2) sprintf (buf, "This weapon allows the wielder to see invisible things.\n\r"); else if (itemtype == 39 || itemtype == 3) sprintf (buf, "This weapon grants the power of flight.\n\r"); else if (itemtype == 45 || itemtype == 1) sprintf (buf, "This weapon allows the wielder to see in the dark.\n\r"); else if (itemtype == 46 || itemtype == 5) sprintf (buf, "This weapon renders the wielder invisible to the human eye.\n\r"); else if (itemtype == 52 || itemtype == 6) sprintf (buf, "This weapon allows the wielder to walk through solid doors.\n\r"); else if (itemtype == 54 || itemtype == 7) sprintf (buf, "This holy weapon protects the wielder from evil.\n\r"); else if (itemtype == 139) sprintf (buf, "This unholy weapon protects the wielder from good.\n\r"); else if (itemtype == 57 || itemtype == 8) sprintf (buf, "This ancient weapon protects the wielder in combat.\n\r"); else if (itemtype == 9) sprintf (buf, "This crafty weapon allows the wielder to walk in complete silence.\n\r"); else if (itemtype == 10) sprintf (buf, "This powerful weapon surrounds its wielder with a shield of lightning.\n\r"); else if (itemtype == 11) sprintf (buf, "This powerful weapon surrounds its wielder with a shield of fire.\n\r"); else if (itemtype == 12) sprintf (buf, "This powerful weapon surrounds its wielder with a shield of ice.\n\r"); else if (itemtype == 13) sprintf (buf, "This powerful weapon surrounds its wielder with a shield of acid.\n\r"); else if (itemtype == 14) sprintf (buf, "This weapon protects its wielder from clan DarkBlade guardians.\n\r"); else if (itemtype == 15) sprintf (buf, "This ancient weapon surrounds its wielder with a shield of chaos.\n\r"); else if (itemtype == 16) sprintf (buf, "This ancient weapon regenerates the wounds of its wielder.\n\r"); else if (itemtype == 26) sprintf (buf, "This ancient weapon gives the power of mantis 3.\n\r"); else if (itemtype == 17) sprintf (buf, "This ancient weapon allows its wielder to move at supernatural speed.\n\r"); else if (itemtype == 18) sprintf (buf, "This razor sharp weapon can slice through armour without difficulty.\n\r"); else if (itemtype == 19) sprintf (buf, "This ancient weapon protects its wearer from player attacks.\n\r"); else if (itemtype == 20) sprintf (buf, "This ancient weapon surrounds its wielder with a shield of darkness.\n\r"); else if (itemtype == 21) sprintf (buf, "This ancient weapon grants superior protection to its wielder.\n\r"); else if (itemtype == 22) sprintf (buf, "This ancient weapon grants its wielder supernatural vision.\n\r"); else if (itemtype == 23) sprintf (buf, "This ancient weapon unleashes the true rage of the wielder.\n\r"); else if (itemtype == 24) sprintf (buf, "This ancient weapon conceals its wielder from sight.\n\r"); else if (itemtype == 25) sprintf (buf, "This ancient weapon invokes the power of the beast.\n\r"); else if (itemtype == 28) sprintf (buf, "This ancient weapon increases the level of your spells by 20.\n\r"); else sprintf (buf, "This item is bugged...please report it.\n\r"); if (itemtype > 0) send_to_char( buf, ch ); break; case ITEM_ARMOR: sprintf( buf, "Armor class is %d.\n\r", obj->value[0] ); send_to_char( buf, ch ); if (obj->value[3] < 1) break; if (obj->value[3] == 4) sprintf (buf, "This object radiates an aura of darkness.\n\r"); else if (obj->value[3] == 27 || obj->value[3] == 2) sprintf (buf, "This item allows the wearer to see invisible things.\n\r"); else if (obj->value[3] == 39 || obj->value[3] == 3) sprintf (buf, "This object grants the power of flight.\n\r"); else if (obj->value[3] == 45 || obj->value[3] == 1) sprintf (buf, "This item allows the wearer to see in the dark.\n\r"); else if (obj->value[3] == 46 || obj->value[3] == 5) sprintf (buf, "This object renders the wearer invisible to the human eye.\n\r"); else if (obj->value[3] == 52 || obj->value[3] == 6) sprintf (buf, "This object allows the wearer to walk through solid doors.\n\r"); else if (obj->value[3] == 54 || obj->value[3] == 7) sprintf (buf, "This holy relic protects the wearer from evil.\n\r"); else if (obj->value[3] == 139) sprintf (buf, "This unholy relic protects the wearer from good.\n\r"); else if (obj->value[3] == 57 || obj->value[3] == 8) sprintf (buf, "This ancient relic protects the wearer in combat.\n\r"); else if (obj->value[3] == 9) sprintf (buf, "This crafty item allows the wearer to walk in complete silence.\n\r"); else if (obj->value[3] == 10) sprintf (buf, "This powerful item surrounds its wearer with a shield of lightning.\n\r"); else if (obj->value[3] == 11) sprintf (buf, "This powerful item surrounds its wearer with a shield of fire.\n\r"); else if (obj->value[3] == 12) sprintf (buf, "This powerful item surrounds its wearer with a shield of ice.\n\r"); else if (obj->value[3] == 13) sprintf (buf, "This powerful item surrounds its wearer with a shield of acid.\n\r"); else if (obj->value[3] == 14) sprintf (buf, "This object channels the power of god into its wearer.\n\r"); else if (obj->value[3] == 15) sprintf (buf, "This ancient item surrounds its wearer with a shield of chaos.\n\r"); else if (obj->value[3] == 16) sprintf (buf, "This ancient item regenerates the wounds of its wearer.\n\r"); else if (obj->value[3] == 17) sprintf (buf, "This ancient item allows its wearer to move at supernatural speed.\n\r"); else if (obj->value[3] == 18) sprintf (buf, "This powerful item allows its wearer to shear through armour without difficulty.\n\r"); else if (obj->value[3] == 19) sprintf (buf, "This powerful item protects its wearer from player attacks.\n\r"); else if (obj->value[3] == 20) sprintf (buf, "This ancient item surrounds its wearer with a shield of darkness.\n\r"); else if (obj->value[3] == 21) sprintf (buf, "This ancient item grants superior protection to its wearer.\n\r"); else if (obj->value[3] == 22) sprintf (buf, "This ancient item grants its wearer supernatural vision.\n\r"); else if (obj->value[3] == 23) sprintf (buf, "This ancient weapon unleashes the true rage of the wielder.\n\r"); else if (obj->value[3] == 24) sprintf (buf, "This ancient item conceals its wearer from sight.\n\r"); else if (obj->value[3] == 25) sprintf (buf, "This ancient item invokes the power of the beast.\n\r"); else if (obj->value[3] == 28) sprintf (buf, "This ancient item invokes the power of ancient magic.\n\r"); else if (obj->value[3] == 29) sprintf (buf, "This ancient artifact grants its wearer the power of the third eye.\n\r"); else if (obj->value[3] == 30) sprintf (buf, "This great bird grants the power of talons.\n\r"); else sprintf (buf, "This item is bugged...please report it.\n\r"); if (obj->value[3] > 0) send_to_char( buf, ch ); break; } for ( paf = obj->pIndexData->affected; paf != NULL; paf = paf->next ) { if ( paf->location != APPLY_NONE && paf->modifier != 0 ) { sprintf( buf, "Affects %s by %d.\n\r", affect_loc_name( paf->location ), paf->modifier ); send_to_char( buf, ch ); } } for ( paf = obj->affected; paf != NULL; paf = paf->next ) { if ( paf->location != APPLY_NONE && paf->modifier != 0 ) { sprintf( buf, "Affects %s by %d.\n\r", affect_loc_name( paf->location ), paf->modifier ); send_to_char( buf, ch ); } } return; }