Here is my implementation (also found in the sacred codebase)

if (!str_cmp(arg, "all")) {


for (obj = ch->carrying; obj != NULL; obj = obj_next) {

obj_next = obj->next_content;

if (obj->next_content == obj) {

bugf("infinite obj loop. %s",interp_cmd);

obj_next = NULL;

}

if (can_drop_obj(ch, obj)

&& obj->wear_loc == WEAR_NONE

&& can_see_obj(keeper, obj)

&& ((cost = get_cost(keeper, obj, FALSE)) > 0)

&& (cost < (keeper->silver + 100 * keeper->gold))) {


tcostgold += cost/100;

tcostsilver += cost - (cost/100) * 100;

count++;

ch->gold += cost/100;

ch->silver += cost - (cost/100) * 100;

deduct_cost(keeper, cost);

if ( keeper->gold < 0 )

keeper->gold = 0;

if ( keeper->silver < 0)

keeper->silver = 0;


if (obj->item_type == ITEM_TRASH || IS_OBJ_STAT(obj,

ITEM_SELL_EXTRACT)) {

extract_obj(obj);

} else {

printf_to_char(ch,"Selling %s...\n\r",obj->short_descr);

obj_from_char(obj);

if (obj->timer)

SET_BIT(obj->extra_flags, ITEM_HAD_TIMER);

else

obj->timer = number_range(50, 100);

obj_to_keeper(obj, keeper);

}


} /* salable item ifcheck */


} /* for loop */

printf_to_char(ch,"You sell %d items for %d gold and %d silver.\r\n", count,
tcostgold,tcostsilver);

return;

} /* 'all' if check */

----- Original Message ----- 
From: <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Thursday, October 30, 2003 5:38 AM
Subject: Selling all.


> Ok. I know i posted this a while back, I started to comment the code, to
try and help myself out.  The reason the code didnt work for me before (i
think) is because it doesnt have silver.  When i sell all of my crystals,
(10) it gives me the exact ammount of the cost in gold.  So if someone
wouldnt mind helping a newbie, so i may learn, could ya help me add silver
into this loop.
>
> if (!str_cmp(arg, "all"))
>     {
>         for (obj = ch->carrying; obj != NULL; obj = obj_next)
>         {
>         obj_next = obj->next_content;
>
>         if (can_drop_obj(ch, obj) //if the pc can drop the obj
>         && obj->wear_loc == WEAR_NONE // if the obj is in the inventory
>         && can_see_obj(keeper, obj) // can the keeper see the object?
>         && ((cost = get_cost(keeper, obj, FALSE)) > 0)  //
>         && (cost < keeper->gold))
>
>     {
>
>         tcost += cost;
>         count++;
>         ch->gold += cost;
>         deduct_cost(keeper, cost);
>
>         if (keeper->gold < 0)
>             keeper->gold = 0;
>
>  if (obj->item_type == ITEM_TRASH || IS_OBJ_STAT(obj, ITEM_SELL_EXTRACT))
>     {
>             extract_obj(obj);
>         }
>         else
>     {
>             obj_from_char(obj);
>             if (obj->timer)
>             SET_BIT(obj->extra_flags, ITEM_HAD_TIMER);
>             else
>             obj->timer = number_range(50, 100);
>             obj_to_keeper(obj, keeper);
>         }
>
>         }           // salable item ifcheck
>
>     }           // for loop
>
>     sprintf(buf, "You sell %d items for %d gold.\r\n", count, tcost);
>     send_to_char(buf, ch);
>     return;
>     }               // 'all' if check
>
> Thank you for help, guidance, and even maybe a flame or two ;)
> Atm, of Forgotten Empire
>
> __________________________________________________________________
> McAfee VirusScan Online from the Netscape Network.
> Comprehensive protection for your entire computer. Get your free trial
today!
> http://channels.netscape.com/ns/computing/mcafee/index.jsp?promo=393397
>
> Get AOL Instant Messenger 5.1 free of charge.  Download Now!
> http://aim.aol.com/aimnew/Aim/register.adp?promo=380455
>
> -- 
> ROM mailing list
> [email protected]
> http://www.rom.org/cgi-bin/mailman/listinfo/rom
>
>



  • Selling all. ShadowFangs
    • Re: Selling all. Chris \"Winston\" Litchfield

Reply via email to