AUCTION UPDATE FOR CIRCLEMUD 3.1 Originally done by Jake Turner ------------------------------------------------------------------------------ The commands are as follows. auction [minimum bid] - begins auction of item auction - stops the current auction, if immortal confiscates auctioned object auction - get stats on current item for 500 gold person who is selling cant find out stats bid - bids on current object, must be 10% more than current bid auctalk - replace old 'auction' function, used to speak on the auction channel. ------------------------------------------------------------------------------- Ok boneheads that dont have a freakin clue how to make an auction script (heh j/k) But anyways, open the freakin act.item.c file and paste this junk into it: -------------------------------------------- UNDER LOCAL VARIABLES -------------------------------------------- int curbid = 0; /* current bid on item being auctioned */ int aucstat = AUC_NULL_STATE; /* state of auction.. first_bid etc.. */ struct obj_data *obj_selling = NULL; /* current object for sale */ struct char_data *ch_selling = NULL; /* current character selling obj */ struct char_data *ch_buying = NULL; /* current character buying the object */ char *auctioneer[AUC_BID + 1] = { "The auctioneer auctions, '$n puts $p up for sale at %d coins.'", "The auctioneer auctions, '$p at %d coins going once!.'", "The auctioneer auctions, '$p at %d coins going twice!.'", "The auctioneer auctions, 'Last call: $p going to $n for %d coins.'", "The auctioneer auctions, 'Unfortunately $p is unsold, returning it to $n.'", "The auctioneer auctions, 'SOLD! $p to $n for %d coins!.'", "The auctioneer auctions, 'Sorry, $n has cancelled the auction.'", "The auctioneer auctions, 'Sorry, $n has left us, the auction can't go on.'", "The auctioneer auctions, 'Sorry, $p has been confiscated, shame on you $n.'", "The auctioneer tells you, '$n is selling $p for %d gold.'", "The auctioneer auctions, '$n bids %d coins on $p.'" }; -------------------------------------------- UNDER THE EXTERNAL VARIABLES -------------------------------------------- extern struct descriptor_data *descriptor_list; -------------------------------------------- THE MOTHER: PUT ALL THIS JUNK SOMEWHERE IN act.item.c -------------------------------------------- void start_auction(struct char_data * ch, struct obj_data * obj, int bid); void auc_stat(struct char_data * ch, struct obj_data *obj); void stop_auction(int type, struct char_data * ch); void check_auction(void); void auc_send_to_all(char *messg, bool buyer); char buf[MAX_STRING_LENGTH]; ACMD(do_auction); ACMD(do_bid); void start_auction(struct char_data * ch, struct obj_data * obj, int bid) { /* Take object from character and set variables */ obj_from_char(obj); obj_selling = obj; ch_selling = ch; ch_buying = NULL; curbid = bid; /* Tell th character where his item went */ sprintf(buf, "%s magic flies away from your hands to be auctioned!\r\n", obj_selling->short_description); CAP(buf); send_to_char(ch_selling, buf); /* Anounce the item is being sold */ sprintf(buf, auctioneer[AUC_NULL_STATE], curbid); auc_send_to_all(buf, FALSE); aucstat = AUC_OFFERING; } void check_auction(void) { switch (aucstat) { case AUC_NULL_STATE: return; case AUC_OFFERING: { sprintf(buf, auctioneer[AUC_OFFERING], curbid); CAP(buf); auc_send_to_all(buf, FALSE); aucstat = AUC_GOING_ONCE; return; } case AUC_GOING_ONCE: { sprintf(buf, auctioneer[AUC_GOING_ONCE], curbid); CAP(buf); auc_send_to_all(buf, FALSE); aucstat = AUC_GOING_TWICE; return; } case AUC_GOING_TWICE: { sprintf(buf, auctioneer[AUC_GOING_TWICE], curbid); CAP(buf); auc_send_to_all(buf, FALSE); aucstat = AUC_LAST_CALL; return; } case AUC_LAST_CALL: { if (ch_buying == NULL) { sprintf(buf, auctioneer[AUC_LAST_CALL]); CAP(buf); auc_send_to_all(buf, FALSE); sprintf(buf, "%s flies out the sky and into your hands.\r\n", obj_selling->short_description); CAP(buf); send_to_char(ch_selling, buf); obj_to_char(obj_selling, ch_selling); /* Reset auctioning values */ obj_selling = NULL; ch_selling = NULL; ch_buying = NULL; curbid = 0; aucstat = AUC_NULL_STATE; return; } else { sprintf(buf, auctioneer[AUC_SOLD], curbid); auc_send_to_all(buf, TRUE); /* Give the object to the buyer */ obj_to_char(obj_selling, ch_buying); sprintf(buf, "%s flies out the sky and into your hands, what a steel!\r\n", obj_selling->short_description); CAP(buf); send_to_char(ch_buying, buf); sprintf(buf, "Congrats! You have sold %s for %d coins!\r\n", obj_selling->short_description, curbid); send_to_char(ch_buying, buf); /* Give selling char the money for his stuff */ GET_GOLD(ch_selling) += curbid; /* Reset auctioning values */ obj_selling = NULL; ch_selling = NULL; ch_buying = NULL; curbid = 0; aucstat = AUC_NULL_STATE; return; } } } } ACMD(do_auction) { char arg1[MAX_INPUT_LENGTH]; char arg2[MAX_INPUT_LENGTH]; struct obj_data *obj; int bid = 0; two_arguments(argument, arg1, arg2); if (!*arg1) { send_to_char(ch, "Auction what?\r\n"); return; } else if (is_abbrev(arg1, "cancel") || is_abbrev(arg1, "stop")) { if ((ch != ch_selling && GET_LEVEL(ch) < LVL_GRGOD) || aucstat == AUC_NULL_STATE) { send_to_char(ch, "You're not even selling anything!\r\n"); return; } else if (ch == ch_selling) { stop_auction(AUC_NORMAL_CANCEL, NULL); return; } else { stop_auction(AUC_WIZ_CANCEL, ch); } } else if (is_abbrev(arg1, "stats") || is_abbrev(arg1, "identify")) { auc_stat(ch, obj_selling); return; } else if (!(obj = get_obj_in_list_vis(ch, arg1, NULL, ch->carrying))) { sprintf(buf, "You don't seem to have %s %s.\r\n", AN(arg1), arg1); send_to_char(ch, buf); return; } else if (!*arg2 && (bid = obj->obj_flags.cost) <= 0) { sprintf(buf, "What should be the minimum bid?\r\n"); send_to_char(ch, buf); return; } else if (*arg2 && (bid = atoi(arg2)) <= 0) { send_to_char(ch, "Come on? One coin at least?\r\n"); return; } else if (aucstat != AUC_NULL_STATE) { sprintf(buf, "Sorry, but %s is already auctioning %s at %d coins!\r\n", GET_NAME(ch_selling), obj_selling->short_description, bid); send_to_char(ch, buf); return; } else if (OBJ_FLAGGED(obj, ITEM_NOSELL)) { send_to_char(ch, "Sorry but you can't sell that!\r\n"); return; } else { send_to_char(ch, OK); start_auction(ch, obj, bid); return; } } ACMD(do_bid) { char arg[MAX_INPUT_LENGTH]; int bid; if(IS_NPC(ch)) return; one_argument(argument, arg); if (!*arg) { send_to_char(ch, "Bid yes, good idea, but HOW MUCH??\r\n"); return; } else if(aucstat == AUC_NULL_STATE) { send_to_char(ch, "Thats very enthusiastic of you, but nothing is being SOLD!\r\n"); return; } else if(ch == ch_selling) { send_to_char(ch, "Why bid on something your selling? You can 'cancel' the auction!\r\n"); return; } else if((bid = atoi(arg)) < ((int) curbid * 1.1 - 1) && ch_buying != NULL) { sprintf(buf, "You must bid at least 10 percent more than the current bid. (%d)\r\n", (int) (curbid * 1.1)); send_to_char(ch, buf); return; } else if(ch_buying == NULL && bid < curbid) { sprintf(buf, "You must at least bid the minimum!\r\n"); send_to_char(ch, buf); return; } else if(bid > GET_GOLD(ch)) { send_to_char(ch, "You don't have that much gold!\r\n"); return; } else { if (ch == ch_buying) GET_GOLD(ch) -= (bid - curbid); else { GET_GOLD(ch) -= bid; if(!(ch_buying == NULL)) GET_GOLD(ch_buying) += curbid; } curbid = bid; ch_buying = ch; sprintf(buf, auctioneer[AUC_BID], bid); auc_send_to_all(buf, TRUE); aucstat = AUC_OFFERING; return; } } void stop_auction(int type, struct char_data * ch) { switch (type) { case AUC_NORMAL_CANCEL: { sprintf(buf, auctioneer[AUC_NORMAL_CANCEL]); auc_send_to_all(buf, FALSE); break; } case AUC_QUIT_CANCEL: { sprintf(buf, auctioneer[AUC_QUIT_CANCEL]); auc_send_to_all(buf, FALSE); break; } case AUC_WIZ_CANCEL: { sprintf(buf, auctioneer[AUC_WIZ_CANCEL]); auc_send_to_all(buf, FALSE); break; } default: { send_to_char(ch, "Sorry, that is an unrecognised cancel command, please report."); return; } } if (type != AUC_WIZ_CANCEL) { sprintf(buf, "%s flies out the sky and into your hands.\r\n", obj_selling->short_description); CAP(buf); send_to_char(ch_selling, buf); obj_to_char(obj_selling, ch_selling); } else { sprintf(buf, "%s flies out the sky and into your hands.\r\n", obj_selling->short_description); CAP(buf); send_to_char(ch, buf); obj_to_char(obj_selling, ch); } if (!(ch_buying == NULL)) GET_GOLD(ch_buying) += curbid; obj_selling = NULL; ch_selling = NULL; ch_buying = NULL; curbid = 0; aucstat = AUC_NULL_STATE; } void auc_stat(struct char_data *ch, struct obj_data *obj) { if (aucstat == AUC_NULL_STATE) { send_to_char(ch, "Nothing is being auctioned!\r\n"); return; } else if (ch == ch_selling) { send_to_char(ch, "You should have found that out BEFORE auctioning it!\r\n"); return; } else if (GET_GOLD(ch) < 500) { send_to_char(ch, "You can't afford to find the stats on that, it costs 500 coins!\r\n"); return; } else { /* auctioneer tells the character the auction details */ sprintf(buf, auctioneer[AUC_STAT], curbid); send_to_char(ch, CCRED(ch, C_SPR)); act(buf, TRUE, ch_selling, obj, ch, TO_VICT | TO_SLEEP); send_to_char(ch, CCNRM(ch, C_SPR)); GET_GOLD(ch) -= 500; call_magic(ch, NULL, obj_selling, SPELL_IDENTIFY, 30, CAST_SPELL); } } void auc_send_to_all(char *messg, bool buyer) { struct descriptor_data *i; if (messg == NULL) return; for (i = descriptor_list; i; i = i->next) { if (PRF_FLAGGED(i->character, PRF_NOAUCT)) continue; send_to_char(i->character, CCMAG(i->character, C_SPR)); if (buyer) act(messg, TRUE, ch_buying, obj_selling, i->character, TO_VICT | TO_SLEEP); else act(messg, TRUE, ch_selling, obj_selling, i->character, TO_VICT | TO_SLEEP); send_to_char(i->character, CCNRM(i->character, C_SPR)); } } -------------------------------------------- PUT THIS JUNK IN interpreter.c (make sure it is in alphabetical order) -------------------------------------------- ACMD(do_action); ACMD(do_bid); -------------------------------------------- Search for: { "auction" , POS_SLEEPING, do_gen_comm , 0, SCMD_AUCTION }, And replace it with: { "auction" , POS_RESTING , do_auction , 0, 0 }, { "auctalk" , POS_SLEEPING, do_gen_comm , 0, SCMD_AUCTION }, Search for: { "beg" , POS_RESTING , do_action , 0, 0 }, And below it add: { "bid" , POS_RESTING , do_bid , 0, 0 }, -------------------------------------------- STICK THIS JUNK IN act.other.c -------------------------------------------- /* IN EXTERNAL VARIABLES */ extern struct char_data *ch_selling; extern struct char_data *ch_buying; /* IN EXTERNAL PROCEDURES */ void stop_auction(int type, struct char_data * ch); -------------------------------------------- Search for: send_to_char(ch, "Goodbye, friend.. Come back soon!\r\n"); And below it add: if (ch == ch_selling) stop_auction(AUC_QUIT_CANCEL, NULL); -------------------------------------------- ADD THIS JUNK TO structs.h -------------------------------------------- /* AUCTIONING STATES */ #define AUC_NULL_STATE 0 /* not doing anything */ #define AUC_OFFERING 1 /* object has been offfered */ #define AUC_GOING_ONCE 2 /* object is going once! */ #define AUC_GOING_TWICE 3 /* object is going twice! */ #define AUC_LAST_CALL 4 /* last call for the object! */ #define AUC_SOLD 5 /* AUCTION CANCEL STATES */ #define AUC_NORMAL_CANCEL 6 /* normal cancellation of auction */ #define AUC_QUIT_CANCEL 7 /* auction canclled because player quit */ #define AUC_WIZ_CANCEL 8 /* auction cancelled by a god */ /* OTHER JUNK */ #define AUC_STAT 9 #define AUC_BID 10 -------------------------------------------- Search for: #define PULSE_VIOLENCE (2 RL_SEC) Below it add: #define PULSE_AUCTION (9 RL_SEC) -------------------------------------------- ADD THIS JUNK IN comm.c -------------------------------------------- /* EXTERNAL FUNCTIONS */ void check_auction(void); -------------------------------------------- Find this junk: if (!(heart_pulse % PULSE_MOBILE)) mobile_activity(); Right below that junk, add this junk: if (!(heart_pulse % PULSE_AUCTION)) check_auction(); -------------------------------------------- Ok, now this uses color, and the stock 3.1 does not include screen.h in act.item.c So guess what we gotta add? Thats right, add this into the includes section in act.item.c: #include "screen.h" -------------------------------------------- This snippet was updated by Nicholas Sack (Rylas) nick@acresource.com --------------------------------------------