auction.c
atd/src/auction.c · 22.0 KB
From the archive AtDv2.0.tar.gz
Download the archive « Back to the archive contents
/***************************************************************************
* 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"
DECLARE_DO_FUN( do_auction );
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;
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_AUCHN) )
{
send_to_char( "{g[{Gø{g]{w Auction: ",d->character );
send_to_char( argument, d->character );
send_to_char( "{x\n\r", d->character );
}
}
return;
}
void do_auction( CHAR_DATA *ch, char * argument )
{
long 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, "%s stops the auction. %s is confiscated.\n\r", ch->name,
auction_info.item->short_descr);
do_auchn( auction_info.high_bidder,buf );
obj_to_char( auction_info.item, ch );
sprintf(buf, "%s appears in your hands..\n\r",
capitalize(auction_info.item->short_descr) );
send_to_char( buf, ch );
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" ) )
{
long bid;
int bah;
obj = auction_info.item;
if( !obj )
{
stc( "There is no auction up for sale.\n\r", ch);
return;
}
if ( IS_SET( obj->quest, QUEST_ARTIFACT) )
{
int count;
OBJ_DATA * pObj;
if( ch->level < 3 )
{
stc ( "Only avatars may bid on artifacts.\n\r",ch);
return;
}
count = 0;
for( pObj = ch->carrying; pObj; pObj = pObj->next )
if( IS_ARTIFACT( pObj ) ) count++;
if( count > 2 )
{
stc( "You may only carry 2 artifacts.\n\r", ch);
return;
}
}
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;
}
bid = atol( arg2 );
bah = bid * 2;
if ( bah < bid ) {stc("You need to bid 2x the current bid.\n\r",ch); return; }
if ( bid <= auction_info.current_bid )
{
sprintf(buf, "You must bid above the current bid of %ld Qps.\n\r",
auction_info.current_bid );
return;
}
if ( bid < auction_info.current_bid * 2)
{ stc("You need to bid 2x 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, "%s just bid %ld qps for %s.\n\r", ch->name,
bid, auction_info.item->short_descr);
// auction_channel( buf );
do_auchn( ch,buf);
if ( auction_info.high_bidder != NULL )
{
auction_info.high_bidder->pcdata->quest += auction_info.silver_held;
}
cp = UMIN( ch->pcdata->quest, bid );
if ( cp < bid )
{
cp = bid;
}
ch->pcdata->quest -= cp;
// auction_info.gold_held = gold;
auction_info.silver_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 && strlen(obj->questowner) > 1 )
{
send_to_char("You cannot claimed items.\n\r",ch);
return;
}*/
if ( IS_OBJ_STAT( obj, ITEM_NODROP ) )
{
send_to_char("You can't let go of that item.\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,"%s has put up %s for auction. [Minimum Bid: %ldqp]\n\r", ch->name, 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 SOLD to %s for %ld QP.\n\r",
capitalize(auction_info.item->short_descr),
auction_info.high_bidder->name,
auction_info.current_bid );
// auction_channel( buf );
do_auchn( auction_info.high_bidder,buf );
auction_info.owner->pcdata->quest += auction_info.silver_held;
sprintf(temp, "%ld qps ", auction_info.silver_held );
sprintf(buf, "You receive %ld.\n\r",
auction_info.silver_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",
capitalize(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.silver_held = 0;
return;
}
if ( auction_info.status == AUCTION_LENGTH - 1 )
{
sprintf(buf, "%s - going twice at %ld qp.\n\r",
capitalize(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, "No bids on %s - item sent back to Auctioner.\n\r",
auction_info.item->short_descr);
do_auchn( auction_info.high_bidder,buf );
obj_to_char( auction_info.item, auction_info.owner );
sprintf(buf, "%s is returned to you.\n\r",
capitalize(auction_info.item->short_descr) );
send_to_char( buf, auction_info.owner );
auction_info.item = NULL;
auction_info.owner = NULL;
auction_info.current_bid = 0;
auction_info.status = 0;
return;
}
sprintf(buf, "%s - going once at %ld qps.\n\r",
capitalize(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;
sprintf( buf, "Object '%s' is type %s.\n\r",
obj->name,
flag_string( type_flags, obj->item_type) );
send_to_char(buf,ch);
sprintf( buf, "Extra Flags: %s.\n\r",
flag_string( extra_flags, obj->extra_flags ) );
send_to_char(buf,ch);
sprintf( buf, "Weight is %d, value at %d.\n\r",
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->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->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_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:
{
int wspell, spell;
ch_printf( ch, "Weapon Flags: %s\n\r",
flag_string( weap_flags, obj->weapflags ) );
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 );
wspell = obj->value[0];
spell = obj->value[4];
sprintf( buf, capitalize(obj->short_descr));
if (spell > 0 || wspell > 0 )
{
strcat( buf, " is a");
if (obj->level < 10) strcat( buf, " minor spell weapon.\n\r" );
else if (obj->level < 20) strcat( buf, " lesser spell weapon.\n\r" );
else if (obj->level < 30) strcat( buf, " average spell weapon.\n\r" );
else if (obj->level < 40) strcat( buf, " greater spell weapon.\n\r" );
else if (obj->level < 50) strcat( buf, " major spell weapon.\n\r" );
else if (obj->level > 50) strcat( buf, " ultimate spell weapon.\n\r");
else strcat( buf, " supreme spell weapon.\n\r" );
stc( buf, ch );
}
if( spell > 0 )
{
if (obj->value[4] == 4)
sprintf (buf, "This object radiates an aura of darkness.\n\r");
else if (obj->value[4] == 2)
sprintf (buf, "This item allows the wearer to see invisible things.\n\r");
else if (obj->value[4] == 3)
sprintf (buf, "This object grants the power of flight.\n\r");
else if (obj->value[4] == 1)
sprintf (buf, "This item allows the wearer to see in the dark.\n\r");
else if (obj->value[4] == 5)
sprintf (buf, "This object renders the wearer invisible to the human eye.\n\r");
else if (obj->value[4] == 6)
sprintf (buf, "This object allows the wearer to walk through solid doors.\n\r");
else if (obj->value[4] == 7)
sprintf (buf, "This holy relic protects the wearer from evil.\n\r");
else if (obj->value[4] == 8)
sprintf (buf, "This ancient relic protects the wearer in combat.\n\r");
else if (obj->value[4] == 9)
sprintf (buf, "This crafty item allows the wearer to walk in complete silence.\n\r");
else if (obj->value[4] == 10)
sprintf (buf, "This powerful item surrounds its wearer with a shield of lightning.\n\r");
else if (obj->value[4] == 11)
sprintf (buf, "This powerful item surrounds its wearer with a shield of fire.\n\r");
else if (obj->value[4] == 12)
sprintf (buf, "This powerful item surrounds its wearer with a shield of ice.\n\r");
else if (obj->value[4] == 13)
sprintf (buf, "This powerful item surrounds its wearer with a shield of acid.\n\r");
else if (obj->value[4] == 14)
sprintf (buf, "This object protects its wearer from clan DarkBlade guardians.\n\r");
else if (obj->value[4] == 15)
sprintf (buf, "This ancient item surrounds its wearer with a shield of chaos.\n\r");
else if (obj->value[4] == 16)
sprintf (buf, "This ancient item regenerates the wounds of its wearer.\n\r");
else if (obj->value[4] == 17)
sprintf (buf, "This ancient item allows its wearer to move at supernatural speed.\n\r");
else if (obj->value[4] == 18)
sprintf (buf, "This powerful item allows its wearer to shear through armour without difficulty.\n\r");
else if (obj->value[4] == 19)
sprintf (buf, "This powerful item protects its wearer from player attacks.\n\r");
else if (obj->value[4] == 20)
sprintf (buf, "This ancient item surrounds its wearer with a shield of darkness.\n\r");
else if (obj->value[4] == 21)
sprintf (buf, "This ancient item grants superior protection to its wearer.\n\r");
else if (obj->value[4] == 22)
sprintf (buf, "This ancient item grants its wearer supernatural vision.\n\r");
else if (obj->value[4] == 23)
sprintf (buf, "This ancient item makes its wearer fleet-footed.\n\r");
else if (obj->value[4] == 24)
sprintf (buf, "This ancient item conceals its wearer from sight.\n\r");
else if (obj->value[4] == 25)
sprintf (buf, "This ancient item invokes the power of the beast.\n\r");
else if (obj->value[4] == 27)
sprintf( buf, "This ancient item grants the wearear superior combat ability.\n\r");
else if (obj->value[4] == 60)
sprintf( buf, "This ancient item grants the wearer the power to see the hidden.\n\r" );
else
sprintf( buf, "This item is bugged.\n\r");
stc( buf, ch );
}
if( wspell >= 1 && wspell < MAX_SKILL )
ch_printf(ch,"This weapon has been imbued with the power of %s.\n\r",
skill_table[wspell].name );
break;
}
case ITEM_ARMOR:
sprintf( buf, "Armor class is %d.\n\r", obj->value[0] );
send_to_char( buf, ch );
if (obj->value[4] < 1)
break;
if (obj->value[4] == 4)
sprintf (buf, "This object radiates an aura of darkness.\n\r");
else if (obj->value[4] == 2)
sprintf (buf, "This item allows the wearer to see invisible things.\n\r");
else if (obj->value[4] == 3)
sprintf (buf, "This object grants the power of flight.\n\r");
else if (obj->value[4] == 1)
sprintf (buf, "This item allows the wearer to see in the dark.\n\r");
else if (obj->value[4] == 5)
sprintf (buf, "This object renders the wearer invisible to the human eye.\n\r");
else if (obj->value[4] == 6)
sprintf (buf, "This object allows the wearer to walk through solid doors.\n\r");
else if (obj->value[4] == 7)
sprintf (buf, "This holy relic protects the wearer from evil.\n\r");
else if (obj->value[4] == 8)
sprintf (buf, "This ancient relic protects the wearer in combat.\n\r");
else if (obj->value[4] == 9)
sprintf (buf, "This crafty item allows the wearer to walk in complete silence.\n\r");
else if (obj->value[4] == 10)
sprintf (buf, "This powerful item surrounds its wearer with a shield of lightning.\n\r");
else if (obj->value[4] == 11)
sprintf (buf, "This powerful item surrounds its wearer with a shield of fire.\n\r");
else if (obj->value[4] == 12)
sprintf (buf, "This powerful item surrounds its wearer with a shield of ice.\n\r");
else if (obj->value[4] == 13)
sprintf (buf, "This powerful item surrounds its wearer with a shield of acid.\n\r");
else if (obj->value[4] == 14)
sprintf (buf, "This object protects its wearer from clan DarkBlade guardians.\n\r");
else if (obj->value[4] == 15)
sprintf (buf, "This ancient item surrounds its wearer with a shield of chaos.\n\r");
else if (obj->value[4] == 16)
sprintf (buf, "This ancient item regenerates the wounds of its wearer.\n\r");
else if (obj->value[4] == 17)
sprintf (buf, "This ancient item allows its wearer to move at supernatural speed.\n\r");
else if (obj->value[4] == 18)
sprintf (buf, "This powerful item allows its wearer to shear through armour without difficulty.\n\r");
else if (obj->value[4] == 19)
sprintf (buf, "This powerful item protects its wearer from player attacks.\n\r");
else if (obj->value[4] == 20)
sprintf (buf, "This ancient item surrounds its wearer with a shield of darkness.\n\r");
else if (obj->value[4] == 21)
sprintf (buf, "This ancient item grants superior protection to its wearer.\n\r");
else if (obj->value[4] == 22)
sprintf (buf, "This ancient item grants its wearer supernatural vision.\n\r");
else if (obj->value[4] == 23)
sprintf (buf, "This ancient item makes its wearer fleet-footed.\n\r");
else if (obj->value[4] == 24)
sprintf (buf, "This ancient item conceals its wearer from sight.\n\r");
else if (obj->value[4] == 25)
sprintf (buf, "This ancient item invokes the power of the beast.\n\r");
else if (obj->value[4] == 27)
sprintf( buf, "This ancient item grants the wearear superior combat ability.\n\r");
else if (obj->value[4] == 60)
sprintf( buf, "This ancient item grants the wearer the power to see the hidden.\n\r" );
else
sprintf (buf, "This item is bugged...please report it.\n\r");
if (obj->value[4] > 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;
}