void shopping_buy(char *arg, struct char_data *ch, struct char_data *keeper, int shop_nr) { char tempstr[200], buf[MAX_STRING_LENGTH]; struct obj_data *obj, *last_obj = NULL; int goldamt = 0, buynum, bought = 0; if (!(is_ok(keeper, ch, shop_nr))) return; if (SHOP_SORT(shop_nr) < IS_CARRYING_N(keeper)) sort_keeper_objs(keeper, shop_nr); if ((buynum = transaction_amt(arg)) < 0) { sprintf(buf, "%s A negative amount? Try selling me something.", GET_NAME(ch)); do_tell(keeper, buf, cmd_tell, 0); return; } if (!(*arg) || !(buynum)) { sprintf(buf, "%s What do you want to buy??", GET_NAME(ch)); do_tell(keeper, buf, cmd_tell, 0); return; } if (!(obj = get_purchase_obj(ch, arg, keeper, shop_nr, TRUE))) return; if ((buy_price(ch, obj, shop_nr) > GET_GOLD(ch)) && !IS_GOD(ch)) { sprintf(buf, shop_index[shop_nr].missing_cash2, GET_NAME(ch)); do_tell(keeper, buf, cmd_tell, 0); switch (SHOP_BROKE_TEMPER(shop_nr)) { case 0: do_action(keeper, GET_NAME(ch), cmd_puke, 0); return; case 1: do_echo(keeper, "smokes on his joint.", cmd_emote, SCMD_EMOTE); return; default: return; } } if ((IS_CARRYING_N(ch) + 1 > CAN_CARRY_N(ch))) { sprintf(buf, "%s: You can't carry any more items.\n\r", fname(obj->name)); send_to_char(buf, ch); return; } if ((IS_CARRYING_W(ch) + GET_OBJ_WEIGHT(obj)) > CAN_CARRY_W(ch)) { sprintf(buf, "%s: You can't carry that much weight.\n\r", fname(obj->name)); send_to_char(buf, ch); return; } while ((obj) && ((GET_GOLD(ch) >= buy_price(ch, obj, shop_nr)) || IS_GOD(ch)) && (IS_CARRYING_N(ch) < CAN_CARRY_N(ch)) && (bought < buynum) && (IS_CARRYING_W(ch) + GET_OBJ_WEIGHT(obj) <= CAN_CARRY_W(ch))) { bought++; /* Test if producing shop ! */ if (shop_producing(obj, shop_nr)) obj = read_object(GET_OBJ_RNUM(obj), REAL); else { obj_from_char(obj); SHOP_SORT(shop_nr)--; } obj_to_char(obj, ch); goldamt += buy_price(ch, obj, shop_nr); if (!IS_GOD(ch)) GET_GOLD(ch) -= buy_price(ch, obj, shop_nr); last_obj = obj; obj = get_purchase_obj(ch, arg, keeper, shop_nr, FALSE); if (!same_obj(obj, last_obj)) break; } if (bought < buynum) { if (!obj || !same_obj(last_obj, obj)) sprintf(buf, "%s I only have %d to sell you.", GET_NAME(ch), bought); else if (GET_GOLD(ch) < buy_price(ch, obj, shop_nr)) sprintf(buf, "%s You can only afford %d.", GET_NAME(ch), bought); else if (IS_CARRYING_N(ch) >= CAN_CARRY_N(ch)) sprintf(buf, "%s You can only hold %d.", GET_NAME(ch), bought); else if (IS_CARRYING_W(ch) + GET_OBJ_WEIGHT(obj) > CAN_CARRY_W(ch)) sprintf(buf, "%s You can only carry %d.", GET_NAME(ch), bought); else sprintf(buf, "%s Something screwy only gave you %d.", GET_NAME(ch), bought); do_tell(keeper, buf, cmd_tell, 0); } if (!IS_GOD(ch)) GET_GOLD(keeper) += goldamt; sprintf(tempstr, "%s", times_message(ch->carrying, 0, bought)); sprintf(buf, "$n buys %s.", tempstr); act(buf, FALSE, ch, obj, 0, TO_ROOM); sprintf(buf, shop_index[shop_nr].message_buy, GET_NAME(ch), goldamt); do_tell(keeper, buf, cmd_tell, 0); sprintf(buf, "You now have %s.\n\r", tempstr); send_to_char(buf, ch); if (SHOP_USES_BANK(shop_nr)) if (GET_GOLD(keeper) > MAX_OUTSIDE_BANK) { SHOP_BANK(shop_nr) += (GET_GOLD(keeper) - MAX_OUTSIDE_BANK); GET_GOLD(keeper) = MAX_OUTSIDE_BANK; } }
void shopping_buy( const char *arg, struct char_data *ch, struct char_data *keeper, int shop_nr) { char argm[100], buf[MAX_STRING_LENGTH], newarg[100]; int num = 1; struct obj_data *temp1; int i; float mult = 0; if(!(is_ok(keeper,ch,shop_nr))) return; if(keeper->generic != 0) for(i = 0; i <= MAX_TRADE; i++) { if(keeper->generic == FAMINE) if(shop_index[shop_nr].type[i] == ITEM_FOOD) { mult = shop_multiplier; /* we're in a famine, we sell food, so we */ break; /* our prices to hell ;-) -DM */ } if(keeper->generic == DWARVES_STRIKE) if((shop_index[shop_nr].type[i] == ITEM_ARMOR) || (shop_index[shop_nr].type[i] == ITEM_WEAPON)) { mult = shop_multiplier; break; } } only_argument(arg, argm); if(!(*argm)) { sprintf(buf, "%s what do you want to buy??" ,GET_NAME(ch)); do_tell(keeper,buf,19); return; }; if( ( num = getabunch( argm, newarg ) ) != 0 ) { strcpy(argm,newarg); } if (num == 0) num = 1; if(!( temp1 = get_obj_in_list_vis(ch,argm,keeper->carrying))) { sprintf(buf, shop_index[shop_nr].no_such_item1 ,GET_NAME(ch)); do_tell(keeper,buf,19); return; } if(temp1->obj_flags.cost <= 0) { sprintf(buf, shop_index[shop_nr].no_such_item1 ,GET_NAME(ch)); do_tell(keeper,buf,19); extract_obj(temp1); return; } if( GET_GOLD(ch) < (int) (num*(temp1->obj_flags.cost* shop_index[shop_nr].profit_buy - ((chr_apply[ (int)GET_CHR(ch) ].reaction*temp1->obj_flags.cost)/100) + (mult * temp1->obj_flags.cost))) && GetMaxLevel(ch)<DEMIGOD) { sprintf(buf, shop_index[shop_nr].missing_cash2, GET_NAME(ch)); do_tell(keeper,buf,19); switch(shop_index[shop_nr].temper1) { case 0: do_action(keeper,GET_NAME(ch),30); return; case 1: do_emote(keeper,"grins happily",36); return; default: return; } } if ((IS_CARRYING_N(ch) + num) > (CAN_CARRY_N(ch))) { sprintf(buf,"%s : You can't carry that many items.\n\r", fname(temp1->name)); send_to_char(buf, ch); return; } if ((IS_CARRYING_W(ch) + (num * temp1->obj_flags.weight)) > CAN_CARRY_W(ch)) { sprintf(buf,"%s : You can't carry that much weight.\n\r", fname(temp1->name)); send_to_char(buf, ch); return; } act("$n buys $p.", FALSE, ch, temp1, 0, TO_ROOM); sprintf(buf, shop_index[shop_nr].message_buy, GET_NAME(ch), (int) (num * (temp1->obj_flags.cost* shop_index[shop_nr].profit_buy - ((chr_apply[ (int)GET_CHR(ch)].reaction*temp1->obj_flags.cost)/100) + (mult * temp1->obj_flags.cost)))); do_tell(keeper,buf,19); sprintf(buf,"You now have %s (*%d).\n\r", temp1->short_description,num); send_to_char(buf,ch); while (num-- > 0) { if (GetMaxLevel(ch)<DEMIGOD) GET_GOLD(ch) -= (int)(temp1->obj_flags.cost* shop_index[shop_nr].profit_buy - ((chr_apply[ (int)GET_CHR(ch) ].reaction*temp1->obj_flags.cost)/100)+ (mult * temp1->obj_flags.cost)); GET_GOLD(keeper) += (int)(temp1->obj_flags.cost* shop_index[shop_nr].profit_buy - ((chr_apply[(int)GET_CHR(ch)].reaction*temp1->obj_flags.cost)/100)+ (mult * temp1->obj_flags.cost)); /* Test if producing shop ! */ if (shop_producing(temp1,shop_nr)) temp1 = read_object(temp1->item_number, REAL); else { obj_from_char(temp1); if (temp1 == NULL) { send_to_char("Sorry, I just ran out of those.\n\r",ch); GET_GOLD(ch) += (int)(temp1->obj_flags.cost* shop_index[shop_nr].profit_buy - ((chr_apply[ (int)GET_CHR(ch) ].reaction * temp1->obj_flags.cost)/100)+ (mult * temp1->obj_flags.cost)); return; } } obj_to_char(temp1,ch); } return; }
void shopping_buy( char *arg, struct char_data *ch, struct char_data *keeper, int shop_nr) { char argm[100], buf[MAX_STRING_LENGTH]; struct obj_data *temp1; struct char_data *temp_char; if(!(is_ok(keeper,ch,shop_nr))) return; one_argument(arg, argm); if(!(*argm)) { sprintf(buf, "%s what do you want to buy??" ,GET_NAME(ch)); do_tell(keeper,buf,19); return; }; if(!( temp1 = get_obj_in_list_vis(ch,argm,keeper->carrying))) { sprintf(buf, shop_index[shop_nr].no_such_item1 ,GET_NAME(ch)); do_tell(keeper,buf,19); return; } if(temp1->obj_flags.cost <= 0) { sprintf(buf, shop_index[shop_nr].no_such_item1 ,GET_NAME(ch)); do_tell(keeper,buf,19); extract_obj(temp1); return; } if(GET_GOLD(ch) < (int) (temp1->obj_flags.cost* shop_index[shop_nr].profit_buy) && GET_LEVEL(ch)<22) { sprintf(buf, shop_index[shop_nr].missing_cash2, GET_NAME(ch)); do_tell(keeper,buf,19); switch(shop_index[shop_nr].temper1) { case 0: do_action(keeper,GET_NAME(ch),30); return; case 1: do_emote(keeper,"smokes on his joint",36); return; default: return; } } if ((IS_CARRYING_N(ch) + 1 > CAN_CARRY_N(ch))) { sprintf(buf,"%s : You can't carry that many items.\n\r", fname(temp1->name)); send_to_char(buf, ch); return; } if ((IS_CARRYING_W(ch) + temp1->obj_flags.weight) > CAN_CARRY_W(ch)) { sprintf(buf,"%s : You can't carry that much weight.\n\r", fname(temp1->name)); send_to_char(buf, ch); return; } act("$n buys $p.", FALSE, ch, temp1, 0, TO_ROOM); sprintf(buf, shop_index[shop_nr].message_buy, GET_NAME(ch), (int) (temp1->obj_flags.cost* shop_index[shop_nr].profit_buy)); do_tell(keeper,buf,19); sprintf(buf,"You now have %s.\n\r", temp1->short_description); send_to_char(buf,ch); if(GET_LEVEL(ch)<22) GET_GOLD(ch) -= (int)(temp1->obj_flags.cost* shop_index[shop_nr].profit_buy); GET_GOLD(keeper) += (int)(temp1->obj_flags.cost* shop_index[shop_nr].profit_buy); /* Test if producing shop ! */ if(shop_producing(temp1,shop_nr)) temp1 = read_object(temp1->item_number, REAL); else obj_from_char(temp1); obj_to_char(temp1,ch); return; }
/* do_simple_move assumes * 1. That there is no master and no followers. * 2. That the direction exists. * * Returns : * 1 : If succes. * 0 : If fail */ int do_simple_move(struct char_data *ch, int dir, int need_specials_check) { room_rnum was_in; struct char_data *i; /* * Check for special routines (North is 1 in command list, but 0 here) Note * -- only check if following; this avoids 'double spec-proc' bug */ if (need_specials_check && special(ch, dir + 1, "")) { return (0); } /* charmed? */ if (AFF_FLAGGED(ch, AFF_CHARM) && ch->master && ch->in_room == ch->master->in_room) { send_to_char("The thought of leaving your master makes you weep.\r\n", ch); act("$n bursts into tears.", FALSE, ch, 0, 0, TO_ROOM); return (0); } /* if this room or the one we're going to needs a boat, check for one */ if ((SECT(ch->in_room) == SECT_WATER_NOSWIM) || (SECT(EXIT(ch, dir)->to_room) == SECT_WATER_NOSWIM)) { if (!has_boat(ch)) { send_to_char("You need a boat to go there.\r\n", ch); return (0); } } if((IS_CARRYING_W(ch) > (CAN_CARRY_W(ch) * 2) && GET_LEVEL(ch) < LVL_GOD && !IS_NPC(ch))) { send_to_char("You are to heavy to move! Drop something!\r\n", ch); return (0); } if(IS_NPC_FISH(ch)) { if(SECT(EXIT(ch, dir)->to_room) != SECT_BRIDGE && SECT(EXIT(ch, dir)->to_room) != SECT_WATER_SWIM && SECT(EXIT(ch, dir)->to_room) != SECT_WATER_NOSWIM) { // sprintf(buf, "%s %d", dirs[dir], SECT(EXIT(ch, dir)->to_room)); // mobsay(ch, buf); return FALSE; } if(GET_MOB_VNUM(ch) < 1500 && ROOM_FLAGGED(EXIT(ch, dir)->to_room, ROOM_SALT_FISH)) { return FALSE; } } if (SECT(EXIT(ch, dir)->to_room) != SECT_FOREST) { if (IS_NPC_WOLF(ch) || IS_NPC_CRAB(ch) || IS_NPC_SKELETON(ch)) { return (0); } } /* move points needed is avg. move loss for src and destination sect type */ if (ROOM_FLAGGED(EXIT(ch, dir)->to_room, ROOM_TUNNEL) && num_pc_in_room(&(world[EXIT(ch, dir)->to_room])) > 1) { send_to_char("There isn't enough room there for more than one person!\r\n", ch); return (0); } /* Mortals and low level gods cannot enter greater god rooms. */ if (ROOM_FLAGGED(EXIT(ch, dir)->to_room, ROOM_GODROOM) && GET_LEVEL(ch) < LVL_GRGOD) { send_to_char("You aren't godly enough to use that room!\r\n", ch); return (0); } /* Now we know we're allow to go into the room. */ if(AFF_FLAGGED(ch, AFF_FISHING) || GET_FISHON(ch)) { REMOVE_BIT(AFF_FLAGS(ch), AFF_FISHING); GET_FISHON(ch) = 0; GET_REELIN(ch) = 0; send_to_char("You stop fishing.\r\n", ch); act("$n stops fishing.", FALSE, ch, 0, 0, TO_ROOM); } if (!AFF_FLAGGED(ch, AFF_SNEAK) && !AFF_FLAGGED(ch, AFF_INVISIBLE)) { if(IS_NPC(ch)) { switch(GET_RACE(ch)) { case RACE_NPC_MAMMAL: case RACE_NPC_HIGHHUMAN: case RACE_NPC_GOBLIN: case RACE_NPC_PIG: case RACE_NPC_WOLF: case RACE_NPC_CHICKEN: sprintf(buf2, "$n walks %s.", dirs[dir]); break; case RACE_NPC_AVIAN: sprintf(buf2, "$n flits %s.", dirs[dir]); break; case RACE_NPC_SHEEP: case RACE_NPC_GOAT: sprintf(buf2, "$n walks %s.", dirs[dir]); break; case RACE_NPC_SKELETON: sprintf(buf2, "$n shambles %s.", dirs[dir]); break; case RACE_NPC_COW: sprintf(buf2, "$n walks %s.", dirs[dir]); break; case RACE_NPC_CRAB: sprintf(buf2, "$n scurries %s.", dirs[dir]); break; case RACE_NPC_FISH: sprintf(buf2, "$n swims %s.", dirs[dir]); break; case RACE_NPC_INSECT: sprintf(buf2, "$n buzzes %s.", dirs[dir]); break; default: sprintf(buf2, "$n leaves %s.", dirs[dir]); break; } } else { sprintf(buf2, "$n leaves %s.", dirs[dir]); } if(SECT(ch->in_room) == SECT_WATER_SWIM && !IS_NPC_FISH(ch)) { sprintf(buf2, "$n splashes through the water, heading %s.", dirs[dir]); } act(buf2, FALSE, ch, 0, 0, TO_ROOM); } was_in = ch->in_room; char_from_room(ch); char_to_room(ch, world[was_in].dir_option[dir]->to_room); if (!AFF_FLAGGED(ch, AFF_SNEAK)) { if(!AFF_FLAGGED(ch, AFF_INVISIBLE)) { act("$n has arrived.", FALSE, ch, 0, 0, TO_ROOM); } } if (ch->desc != NULL) look_at_room(ch, 0); if(IS_NPC_CRAB(ch) || IS_NPC_LIVESTOCK(ch)) { for (i = world[ch->in_room].people; i; i = i->next_in_room) { if(IS_NPC_WOLF(i) && IS_NPC_CRAB(ch)) { sprintf(buf, "%s sees %s and tries to run!\r\n", GET_NAME(ch), GET_NAME(i)); send_to_room(buf, ch->in_room); if(!number(0, 2)) { do_flee(ch, NULL, 0, 0); } if(i->in_room == ch->in_room && !number(0, 2)) { hit(i, ch, TYPE_UNDEFINED); } } if((IS_NPC_SKELETON(i) || IS_NPC_WOLF(i)) && IS_NPC_LIVESTOCK(ch)) { if(ch->master) { sprintf(buf, "%s sees %s and %s in absolute terror!\r\n", GET_NAME(ch), GET_NAME(i), livestock_afraid_vocals[(int)GET_RACE(ch)]); send_to_room(buf, ch->in_room); if(!number(0, 2)) { do_flee(ch, NULL, 0, 0); } if(i->in_room == ch->in_room && !number(0, 2)) { hit(i, ch, TYPE_UNDEFINED); } } } } return (1); } if (ROOM_FLAGGED(ch->in_room, ROOM_DEATH) && GET_LEVEL(ch) < LVL_IMMORT) { log_death_trap(ch); death_cry(ch); extract_char(ch); return (0); } return (1); }
void auction_update(void) { long clanid, tax; if (auction.ticks == AUC_NONE) /* No auction */ return; /* Seller left! */ if (!get_ch_by_id_desc(auction.seller) && !get_ch_by_id(auction.seller)) { if (auction.obj) extract_obj(auction.obj); auction_reset(); return; } /* If there is an auction but it's not sold yet */ if (auction.ticks >= AUC_BID && auction.ticks <= AUC_SOLD) { struct char_data *bidder = get_ch_by_id(auction.bidder); struct char_data *seller = get_ch_by_id(auction.seller); /* If there is a bidder and it's not sold yet */ if (bidder && (auction.ticks < AUC_SOLD)) { /* Non colored message */ sprintf(buf, "%s all'asta %s%s%s a %s per %ld coin%s.", auction.obj->short_description, auction.ticks == AUC_BID ? "uno" : "", auction.ticks == AUC_ONCE ? "due" : "", auction.ticks == AUC_TWICE ? "ultima chiamata" : "", GET_NAME(bidder), auction.bid, auction.bid != 1 ? "" : " "); /* Colored message */ sprintf(buf2, "\x1B[1;37m%s\x1B[35m all'asta \x1B[1;37m%s%s%s\x1B[35m a \x1B[1;37m%s\x1B[35m per \x1B[1;37m%ld\x1B[35m coin%s.", auction.obj->short_description, auction.ticks == AUC_BID ? "uno" : "", auction.ticks == AUC_ONCE ? "due" : "", auction.ticks == AUC_TWICE ? "ultima chiamata" : "", GET_NAME(bidder), auction.bid, auction.bid != 1 ? "" : " "); /* send the output */ auction_output(buf2, buf); /* Increment timer */ auction.ticks++; return; } /* If there is no bidder and we ARE in the sold state */ if (!bidder && (auction.ticks == AUC_SOLD)) { /* Colored message */ sprintf(buf2, "\x1B[1;37m%s\x1B[35m VENDUTO\x1B[35m a \x1B[1;37mnessuno\x1B[35m per \x1B[1;37m%ld\x1B[35m coin%s.", auction.obj->short_description, auction.bid, auction.bid != 1 ? " " : " "); /* No color message */ sprintf(buf, "%s e' VENDUTO a nessuno per %ld coin%s.", auction.obj->short_description, auction.bid, auction.bid != 1 ? "s" : " "); /* Send the output away */ auction_output(buf2, buf); /* Give the poor fellow his unsold goods back */ if (seller) if ((IS_CARRYING_W(seller) + GET_OBJ_WEIGHT(auction.obj)) <= CAN_CARRY_W(seller)) { act("Nessuno ha comprato $p.", FALSE, seller, auction.obj, 0, TO_CHAR); obj_to_char(auction.obj, seller); } else { /* Cosi' si evitano le aste per diminuire il peso */ act("Nessuno ha comprato $p, ma hai troppo peso e lo devi lasciare per terra.", FALSE, seller, auction.obj, 0, TO_CHAR); obj_to_room(auction.obj, IN_ROOM(seller)); } /* He's not around to get it back, destroy the object */ else extract_obj(auction.obj); /* Reset the auction for next time */ auction_reset(); return; } /* If there is no bidder and we are not in the sold state */ if (!bidder && (auction.ticks < AUC_SOLD)) { /* Colored output message */ sprintf(buf2, "\x1B[1;37m%s\x1B[35m all'asta \x1B[1;37m%s%s%s\x1B[35m a \x1B[1;37mnessuno\x1B[35m per \x1B[1;37m%ld\x1B[35m coin%s.", auction.obj->short_description, auction.ticks == AUC_BID ? "uno" : "", auction.ticks == AUC_ONCE ? "due" : "", auction.ticks == AUC_TWICE ? "ultima chiamata" : "", auction.bid, auction.bid != 1 ? "s" : ""); /* No color output message */ sprintf(buf, "%s all'asta %s%s%s a nessuno per %ld coin%s.", auction.obj->short_description, auction.ticks == AUC_BID ? "uno" : "", auction.ticks == AUC_ONCE ? "due" : "", auction.ticks == AUC_TWICE ? "ultima chiamata" : "", auction.bid, auction.bid != 1 ? "s" : ""); /* Send output away */ auction_output(buf2, buf); /* Increment timer */ auction.ticks++; return; } /* Sold */ if (bidder && (auction.ticks >= AUC_SOLD)) { /* Colored output */ sprintf(buf2, "\x1B[1;37m%s\x1B[35m VENDUTO\x1B[35m a \x1B[1;37m%s\x1B[35m per \x1B[1;37m%ld\x1B[35m coin%s.", auction.obj->short_description ? auction.obj->short_description : "qualcosa", bidder->player.name ? bidder->player.name : "qualcuno", auction.bid, auction.bid != 1 ? " " : ""); /* Non color output */ sprintf(buf, "%s VENDUTO a %s per %ld coin%s.", auction.obj->short_description ? auction.obj->short_description : "something", bidder->player.name ? bidder->player.name : "someone", auction.bid, auction.bid != 1 ? "s" : ""); /* Send the output */ auction_output(buf2, buf); /* If the seller is still around we give him the money */ if (seller) { act("Congrats! Hai venduto $p!", FALSE, seller, auction.obj, 0, TO_CHAR); if ((clanid = find_clan_by_id(GET_CLAN(seller)))>=0) { tax = auction.bid * PERC_TAS_AUC/100; GET_GOLD(seller) += MAX(0,auction.bid - (auction.bid*PERC_TAS_AUC/100)); clan[clanid].economy.treasure += MAX(0,(auction.bid*PERC_TAS_AUC/100)); clan[clanid].economy.current_entrate += MAX(0,(auction.bid*PERC_TAS_AUC/100)); sprintf(buf,"Paghi %ld di tasse al tuo regno per la vendita.", tax); act(buf, FALSE, seller, auction.obj, 0, TO_CHAR); } else GET_GOLD(seller) += auction.bid; } /* If the bidder is here he gets the object */ if (bidder) { obj_to_char(auction.obj, bidder); act("Congrats! Ora hai $p!", FALSE, bidder, auction.obj, 0, TO_CHAR); } /* Restore the status of the auction */ auction_reset(); return; } } return; }