1 | /* |
1 | /* |
2 | * static char *rcsid_shop_c = |
2 | * static char *rcsid_shop_c = |
3 | * "$Id: shop.C,v 1.3 2006/08/14 07:10:47 elmex Exp $"; |
3 | * "$Id: shop.C,v 1.5 2006/08/29 07:34:00 root Exp $"; |
4 | */ |
4 | */ |
5 | |
5 | |
6 | /* |
6 | /* |
7 | CrossFire, A Multiplayer game for X-windows |
7 | CrossFire, A Multiplayer game for X-windows |
8 | |
8 | |
… | |
… | |
181 | val/=50; |
181 | val/=50; |
182 | } |
182 | } |
183 | |
183 | |
184 | /* Limit amount of money you can get for really great items. */ |
184 | /* Limit amount of money you can get for really great items. */ |
185 | if (flag==F_SELL) |
185 | if (flag==F_SELL) |
186 | val=value_limit(val, number, who, shop); |
186 | val=value_limit((uint64)val, number, who, shop); |
187 | |
187 | |
188 | // use a nonlinear price adjustment. as my predecessor said, don't change |
188 | // use a nonlinear price adjustment. as my predecessor said, don't change |
189 | // the archetypes, its work required for balancing, and we don't care. |
189 | // the archetypes, its work required for balancing, and we don't care. |
190 | //val = pow (val, 1.05); |
190 | //val = pow (val, 1.05); |
191 | |
191 | |
… | |
… | |
239 | else if (flag == F_SELL) val -= (val * diff); |
239 | else if (flag == F_SELL) val -= (val * diff); |
240 | |
240 | |
241 | // now find a price range. the less good we can judge, the larger the range is |
241 | // now find a price range. the less good we can judge, the larger the range is |
242 | // then the range is adjusted randomly around the correct value |
242 | // then the range is adjusted randomly around the correct value |
243 | if (approximate) |
243 | if (approximate) |
244 | approx_range = (val / sqrt (lev_identify * 3 + 1)); |
244 | approx_range = uint64 (val / sqrt (lev_identify * 3 + 1)); |
245 | } |
245 | } |
246 | |
246 | |
247 | /* I don't think this should really happen - if it does, it indicates and |
247 | /* I don't think this should really happen - if it does, it indicates and |
248 | * overflow of diff above. That shoudl only happen if |
248 | * overflow of diff above. That shoudl only happen if |
249 | * we are selling objects - in that case, the person just |
249 | * we are selling objects - in that case, the person just |
… | |
… | |
299 | * pointful, and could give fun with rounding. |
299 | * pointful, and could give fun with rounding. |
300 | */ |
300 | */ |
301 | if(who->map->path!=NULL && val > 50) |
301 | if(who->map->path!=NULL && val > 50) |
302 | val= (val+0.05*(sint64)val*cos(tmp->count+strlen(who->map->path))); |
302 | val= (val+0.05*(sint64)val*cos(tmp->count+strlen(who->map->path))); |
303 | } |
303 | } |
304 | return val; |
304 | return (uint64)val; |
305 | } |
305 | } |
306 | |
306 | |
307 | /* Find the coin type that is worth more the 'c'. Starts at the |
307 | /* Find the coin type that is worth more the 'c'. Starts at the |
308 | * cointype placement. |
308 | * cointype placement. |
309 | */ |
309 | */ |
… | |
… | |
576 | /* Note that the coin_objs array goes from least value to greatest value */ |
576 | /* Note that the coin_objs array goes from least value to greatest value */ |
577 | for (i=0; i<NUM_COINS; i++) |
577 | for (i=0; i<NUM_COINS; i++) |
578 | if (coin_objs[i]==NULL) { |
578 | if (coin_objs[i]==NULL) { |
579 | at = find_archetype(coins[NUM_COINS-1-i]); |
579 | at = find_archetype(coins[NUM_COINS-1-i]); |
580 | if (at==NULL) LOG(llevError, "Could not find %s archetype\n", coins[NUM_COINS-1-i]); |
580 | if (at==NULL) LOG(llevError, "Could not find %s archetype\n", coins[NUM_COINS-1-i]); |
581 | coin_objs[i] = get_object(); |
581 | coin_objs[i] = arch_to_object (at); |
582 | copy_object(&at->clone, coin_objs[i]); |
|
|
583 | coin_objs[i]->nrof = 0; |
582 | coin_objs[i]->nrof = 0; |
584 | } |
583 | } |
585 | |
584 | |
586 | for (i=0; i<NUM_COINS; i++) { |
585 | for (i=0; i<NUM_COINS; i++) { |
587 | int num_coins; |
586 | int num_coins; |
… | |
… | |
772 | if (n > 0 && (!pouch->weight_limit || pouch->carrying + w <= pouch->weight_limit)) |
771 | if (n > 0 && (!pouch->weight_limit || pouch->carrying + w <= pouch->weight_limit)) |
773 | { |
772 | { |
774 | if (pouch->weight_limit && (pouch->weight_limit - pouch->carrying) / w < n) |
773 | if (pouch->weight_limit && (pouch->weight_limit - pouch->carrying) / w < n) |
775 | n = (pouch->weight_limit - pouch->carrying) / w; |
774 | n = (pouch->weight_limit - pouch->carrying) / w; |
776 | |
775 | |
777 | tmp = get_object (); |
776 | tmp = arch_to_object (at); |
778 | copy_object (&at->clone, tmp); |
|
|
779 | tmp->nrof = n; |
777 | tmp->nrof = n; |
780 | amount -= (uint64)tmp->nrof * (uint64)tmp->value; |
778 | amount -= (uint64)tmp->nrof * (uint64)tmp->value; |
781 | tmp = insert_ob_in_ob (tmp, pouch); |
779 | tmp = insert_ob_in_ob (tmp, pouch); |
782 | esrv_send_item (pl, tmp); |
780 | esrv_send_item (pl, tmp); |
783 | esrv_send_item (pl, pouch); |
781 | esrv_send_item (pl, pouch); |
… | |
… | |
787 | } |
785 | } |
788 | } |
786 | } |
789 | |
787 | |
790 | if (amount / at->clone.value > 0) |
788 | if (amount / at->clone.value > 0) |
791 | { |
789 | { |
792 | tmp = get_object (); |
790 | tmp = arch_to_object (at); |
793 | copy_object (&at->clone, tmp); |
|
|
794 | tmp->nrof = amount / tmp->value; |
791 | tmp->nrof = amount / tmp->value; |
795 | amount -= (uint64)tmp->nrof * (uint64)tmp->value; |
792 | amount -= (uint64)tmp->nrof * (uint64)tmp->value; |
796 | tmp = insert_ob_in_ob (tmp, pl); |
793 | tmp = insert_ob_in_ob (tmp, pl); |
797 | esrv_send_item (pl, tmp); |
794 | esrv_send_item (pl, tmp); |
798 | esrv_send_item (pl, pl); |
795 | esrv_send_item (pl, pl); |
… | |
… | |
816 | if (at == NULL) |
813 | if (at == NULL) |
817 | return 0; |
814 | return 0; |
818 | |
815 | |
819 | if (amount > 0) |
816 | if (amount > 0) |
820 | { |
817 | { |
821 | tmp = get_object (); |
818 | tmp = arch_to_object (at); |
822 | copy_object (&at->clone, tmp); |
|
|
823 | tmp->nrof = amount; |
819 | tmp->nrof = amount; |
824 | tmp = insert_ob_in_ob (tmp, pl); |
820 | tmp = insert_ob_in_ob (tmp, pl); |
825 | esrv_send_item (pl, tmp); |
821 | esrv_send_item (pl, tmp); |
826 | esrv_send_item (pl, pl); |
822 | esrv_send_item (pl, pl); |
827 | } |
823 | } |