1 | |
1 | |
2 | /* |
2 | /* |
3 | * static char *rcs_treasure_c = |
3 | * static char *rcs_treasure_c = |
4 | * "$Id: treasure.c,v 1.2 2006/07/11 16:50:16 elmex Exp $"; |
4 | * "$Id: treasure.c,v 1.3 2006/08/09 15:57:27 elmex Exp $"; |
5 | */ |
5 | */ |
6 | |
6 | |
7 | /* |
7 | /* |
8 | CrossFire, A Multiplayer game for X-windows |
8 | CrossFire, A Multiplayer game for X-windows |
9 | |
9 | |
… | |
… | |
478 | { 0, 0, 0, 0,100}, /*30*/ |
478 | { 0, 0, 0, 0,100}, /*30*/ |
479 | { 0, 0, 0, 0,100}, /*31*/ |
479 | { 0, 0, 0, 0,100}, /*31*/ |
480 | }; |
480 | }; |
481 | |
481 | |
482 | |
482 | |
483 | /* calculate the appropriate level for wands staves and scrolls. If |
483 | /* calculate the appropriate level for wands staves and scrolls. |
484 | * retmult is 1, return the multiplier, not the level, for computing value |
|
|
485 | * This code presumes that op has had its spell object created (in op->inv) |
484 | * This code presumes that op has had its spell object created (in op->inv) |
486 | */ |
485 | * |
|
|
486 | * elmex Wed Aug 9 17:44:59 CEST 2006: |
|
|
487 | * Removed multiplicator, too many high-level items were generated on low-difficulty maps. |
|
|
488 | */ |
487 | |
489 | |
488 | int level_for_item(const object *op, int difficulty, int retmult) |
490 | int level_for_item(const object *op, int difficulty) |
489 | { |
491 | { |
490 | int level, mult, olevel; |
492 | int mult = 0, olevel = 0; |
491 | |
493 | |
492 | mult = 0; |
|
|
493 | if (!op->inv) { |
494 | if (!op->inv) |
|
|
495 | { |
494 | LOG(llevError,"level_for_item: Object %s has no inventory!\n", op->name); |
496 | LOG(llevError,"level_for_item: Object %s has no inventory!\n", op->name); |
495 | return 0; |
497 | return 0; |
496 | } |
498 | } |
497 | level = op->inv->level; |
|
|
498 | |
499 | |
499 | /* Basically, we set mult to the lowest spell increase attribute that is |
500 | olevel = op->inv->level + (double) difficulty * (1 - drand48 () * drand48 () * 2); |
500 | * not zero - zero's mean no modification is done, so we don't want those. |
|
|
501 | * given we want non zero results, we can't just use a few MIN's here. |
|
|
502 | */ |
|
|
503 | mult = op->inv->dam_modifier; |
|
|
504 | if (op->inv->range_modifier && (op->inv->range_modifier<mult || mult == 0)) |
|
|
505 | mult = op->inv->range_modifier; |
|
|
506 | if (op->inv->duration_modifier && (op->inv->duration_modifier < mult || mult==0)) |
|
|
507 | mult = op->inv->duration_modifier; |
|
|
508 | |
501 | |
509 | if (mult == 0) |
502 | if (olevel <= 0) |
510 | mult = 5; |
503 | olevel = rndm (1, MIN (op->inv->level, 1)); |
511 | |
504 | |
512 | if (retmult) |
505 | if (olevel > MAXLEVEL) |
513 | return mult; |
506 | olevel = MAXLEVEL; |
514 | |
507 | |
515 | olevel = mult * rndm(0, difficulty) + level; |
|
|
516 | if (olevel > MAXLEVEL) olevel = MAXLEVEL; |
|
|
517 | |
|
|
518 | return olevel; |
508 | return olevel; |
519 | } |
509 | } |
520 | |
510 | |
521 | /* |
511 | /* |
522 | * Based upon the specified difficulty and upon the difftomagic_list array, |
512 | * Based upon the specified difficulty and upon the difftomagic_list array, |
523 | * a random magical bonus is returned. This is used when determine |
513 | * a random magical bonus is returned. This is used when determine |
… | |
… | |
971 | * change by level, just set the wand to the level of |
961 | * change by level, just set the wand to the level of |
972 | * the spell, and value calculation is simpler. |
962 | * the spell, and value calculation is simpler. |
973 | */ |
963 | */ |
974 | if (op->inv->duration_modifier || op->inv->dam_modifier || |
964 | if (op->inv->duration_modifier || op->inv->dam_modifier || |
975 | op->inv->range_modifier) { |
965 | op->inv->range_modifier) { |
976 | op->level = level_for_item(op, difficulty, 0); |
966 | op->level = level_for_item(op, difficulty); |
977 | op->value= op->value* op->inv->value * (op->level +50)/ |
967 | op->value= op->value* op->inv->value * (op->level +50)/ |
978 | (op->inv->level + 50); |
968 | (op->inv->level + 50); |
979 | } |
969 | } |
980 | else { |
970 | else { |
981 | op->level = op->inv->level; |
971 | op->level = op->inv->level; |
982 | op->value = op->value * op->inv->value; |
972 | op->value = op->value * op->inv->value; |
983 | } |
973 | } |
984 | break; |
974 | break; |
985 | |
975 | |
986 | case ROD: |
976 | case ROD: |
987 | op->level = level_for_item(op, difficulty, 0); |
977 | op->level = level_for_item(op, difficulty); |
988 | /* Add 50 to both level an divisor to keep prices a little more |
978 | /* Add 50 to both level an divisor to keep prices a little more |
989 | * reasonable. Otherwise, a high level version of a low level |
979 | * reasonable. Otherwise, a high level version of a low level |
990 | * spell can be worth tons a money (eg, level 20 rod, level 2 spell = |
980 | * spell can be worth tons a money (eg, level 20 rod, level 2 spell = |
991 | * 10 time multiplier). This way, the value are a bit more reasonable. |
981 | * 10 time multiplier). This way, the value are a bit more reasonable. |
992 | */ |
982 | */ |
… | |
… | |
999 | |
989 | |
1000 | op->stats.hp = op->stats.maxhp; |
990 | op->stats.hp = op->stats.maxhp; |
1001 | break; |
991 | break; |
1002 | |
992 | |
1003 | case SCROLL: |
993 | case SCROLL: |
1004 | op->level = level_for_item(op, difficulty, 0); |
994 | op->level = level_for_item(op, difficulty); |
1005 | op->value= op->value * op->inv->value * (op->level +50) / (op->inv->level + 50); |
995 | op->value= op->value * op->inv->value * (op->level +50) / (op->inv->level + 50); |
1006 | /* add exp so reading them properly gives xp */ |
996 | /* add exp so reading them properly gives xp */ |
1007 | op->stats.exp = op->value/5; |
997 | op->stats.exp = op->value/5; |
1008 | op->nrof = op->inv->nrof; |
998 | op->nrof = op->inv->nrof; |
1009 | break; |
999 | break; |