ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/common/treasure.c
(Generate patch)

Comparing deliantra/server/common/treasure.c (file contents):
Revision 1.3 by elmex, Wed Aug 9 15:57:27 2006 UTC vs.
Revision 1.3.2.2 by elmex, Thu Aug 10 19:09:02 2006 UTC

1 1
2/* 2/*
3 * static char *rcs_treasure_c = 3 * static char *rcs_treasure_c =
4 * "$Id: treasure.c,v 1.3 2006/08/09 15:57:27 elmex Exp $"; 4 * "$Id: treasure.c,v 1.3.2.2 2006/08/10 19:09:02 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
331 331
332 332
333 if((int)t->chance >= 100 || (RANDOM()%100 + 1) < (int) t->chance) { 333 if((int)t->chance >= 100 || (RANDOM()%100 + 1) < (int) t->chance) {
334 if (t->name) { 334 if (t->name) {
335 if (strcmp(t->name,"NONE") && difficulty>=t->magic) 335 if (strcmp(t->name,"NONE") && difficulty>=t->magic)
336 {
336 create_treasure(find_treasurelist(t->name), op, flag, difficulty, tries); 337 create_treasure(find_treasurelist(t->name), op, flag, difficulty, tries);
338 }
337 } 339 }
338 else { 340 else {
339 if(t->item->clone.invisible != 0 || ! (flag & GT_INVISIBLE)) { 341 if(t->item->clone.invisible != 0 || ! (flag & GT_INVISIBLE)) {
340 tmp=arch_to_object(t->item); 342 tmp=arch_to_object(t->item);
341 if(t->nrof&&tmp->nrof<=1) 343 if(t->nrof&&tmp->nrof<=1)
485 * 487 *
486 * elmex Wed Aug 9 17:44:59 CEST 2006: 488 * elmex Wed Aug 9 17:44:59 CEST 2006:
487 * Removed multiplicator, too many high-level items were generated on low-difficulty maps. 489 * Removed multiplicator, too many high-level items were generated on low-difficulty maps.
488 */ 490 */
489 491
490int level_for_item(const object *op, int difficulty) 492int level_for_item (const object *op, int difficulty)
491{ 493{
492 int mult = 0, olevel = 0; 494 int mult = 0, olevel = 0;
493 495
494 if (!op->inv) 496 if (!op->inv)
495 { 497 {
510 512
511/* 513/*
512 * Based upon the specified difficulty and upon the difftomagic_list array, 514 * Based upon the specified difficulty and upon the difftomagic_list array,
513 * a random magical bonus is returned. This is used when determine 515 * a random magical bonus is returned. This is used when determine
514 * the magical bonus created on specific maps. 516 * the magical bonus created on specific maps.
517 *
518 * elmex Thu Aug 10 18:45:44 CEST 2006:
519 * Scaling difficulty by max_level, as difficulty is a level and not some
520 * weird integer between 1-31.
521 *
515 */ 522 */
516 523
517int magic_from_difficulty(int difficulty) 524int magic_from_difficulty(int difficulty)
518{ 525{
519 int percent,loop; 526 int percent = 0, magic = 0;
527 int scaled_diff = ((double) difficulty / settings.max_level) * DIFFLEVELS;
520 528
521 difficulty--; 529 scaled_diff--;
522 if(difficulty<0)
523 difficulty=0;
524 530
531 if(scaled_diff < 0)
532 scaled_diff = 0;
533
525 if (difficulty>=DIFFLEVELS) 534 if (scaled_diff >= DIFFLEVELS)
526 difficulty=DIFFLEVELS-1; 535 scaled_diff = DIFFLEVELS-1;
527 536
528 percent = RANDOM()%100; 537 percent = RANDOM()%100;
529 538
530 for(loop=0;loop<(MAXMAGIC+1);++loop) { 539 for(magic = 0; magic < (MAXMAGIC + 1); magic++)
540 {
531 percent -= difftomagic_list[difficulty][loop]; 541 percent -= difftomagic_list[scaled_diff][magic];
542
532 if (percent<0) 543 if (percent < 0)
533 break; 544 break;
534 } 545 }
535 if (loop==(MAXMAGIC+1)) { 546
547 if (magic == (MAXMAGIC + 1))
548 {
536 LOG(llevError,"Warning, table for difficulty %d bad.\n",difficulty); 549 LOG(llevError,"Warning, table for difficulty (scaled %d) %d bad.\n", scaled_diff, difficulty);
537 loop=0; 550 magic = 0;
538 } 551 }
552
553 magic = (RANDOM() % 3) ? magic : -magic;
554
539/* LOG(llevDebug, "Chose magic %d for difficulty %d\n", loop, difficulty);*/ 555 /* LOG(llevDebug, "Chose magic %d for difficulty (scaled %d) %d\n", magic, scaled_diff, difficulty); */
540 return (RANDOM()%3)?loop:-loop; 556
557 return magic;
541} 558}
542 559
543/* 560/*
544 * Sets magical bonus in an object, and recalculates the effect on 561 * Sets magical bonus in an object, and recalculates the effect on
545 * the armour variable, and the effect on speed of armour. 562 * the armour variable, and the effect on speed of armour.
745 * value. 762 * value.
746 * GT_MINIMAL: Does minimal processing on the object - just enough to make it 763 * GT_MINIMAL: Does minimal processing on the object - just enough to make it
747 * a working object - don't change magic, value, etc, but set it material 764 * a working object - don't change magic, value, etc, but set it material
748 * type as appropriate, for objects that need spell objects, set those, etc 765 * type as appropriate, for objects that need spell objects, set those, etc
749 */ 766 */
767
750void fix_generated_item (object *op, object *creator, int difficulty, 768void fix_generated_item (object * op, object * creator, int difficulty,
751 int max_magic, int flags) 769 int max_magic, int flags)
752{ 770{
753 int was_magic = op->magic, num_enchantments=0, save_item_power; 771 int was_magic = op->magic, num_enchantments = 0, save_item_power = 0;
754 772
755 if(!creator||creator->type==op->type) creator=op; /*safety & to prevent polymorphed 773 if (!creator || creator->type == op->type)
756 * objects giving attributes */ 774 creator = op; /*safety & to prevent polymorphed objects giving attributes */
757 775
758 /* If we make an artifact, this information will be destroyed */ 776 /* If we make an artifact, this information will be destroyed */
759 save_item_power = op->item_power; 777 save_item_power = op->item_power;
760 op->item_power = 0; 778 op->item_power = 0;
761 779
762 if (op->randomitems && op->type != SPELL) { 780 if (op->randomitems && op->type != SPELL)
781 {
763 create_treasure(op->randomitems, op,flags ,difficulty, 0); 782 create_treasure (op->randomitems, op, flags, difficulty, 0);
764 if (!op->inv) LOG(llevDebug,"fix_generated_item: Unable to generate treasure for %s\n", 783 if (!op->inv)
765 op->name); 784 LOG (llevDebug,
785 "fix_generated_item: Unable to generate treasure for %s\n",
786 op->name);
787
766 /* So the treasure doesn't get created again */ 788 /* So the treasure doesn't get created again */
767 op->randomitems = NULL; 789 op->randomitems = NULL;
768 } 790 }
769 791
770 if (difficulty<1) difficulty=1; 792 if (difficulty < 1)
793 difficulty = 1;
794
771 if (!(flags & GT_MINIMAL)) { 795 if (!(flags & GT_MINIMAL))
796 {
772 if (op->arch == crown_arch) { 797 if (op->arch == crown_arch)
798 {
773 set_magic(difficulty>25?30:difficulty+5, op, max_magic, flags); 799 set_magic (difficulty, op, max_magic, flags);
774 num_enchantments = calc_item_power(op, 1); 800 num_enchantments = calc_item_power (op, 1);
775 generate_artifact(op,difficulty); 801 generate_artifact (op, difficulty);
776 } else { 802 }
803 else
804 {
777 if(!op->magic && max_magic) 805 if (!op->magic && max_magic)
778 set_magic(difficulty,op,max_magic, flags); 806 set_magic (difficulty, op, max_magic, flags);
807
779 num_enchantments = calc_item_power(op, 1); 808 num_enchantments = calc_item_power (op, 1);
809
780 if ((!was_magic && !(RANDOM()%CHANCE_FOR_ARTIFACT)) || op->type == HORN || 810 if ((!was_magic && !(RANDOM () % CHANCE_FOR_ARTIFACT))
781 difficulty >= 999 ) 811 || op->type == HORN)
782 generate_artifact(op, difficulty); 812 generate_artifact (op, difficulty);
783 } 813 }
784 814
785 /* Object was made an artifact. Calculate its item_power rating. 815 /* Object was made an artifact. Calculate its item_power rating.
786 * the item_power in the object is what the artfiact adds. 816 * the item_power in the object is what the artfiact adds.
787 */ 817 */
788 if (op->title) { 818 if (op->title)
819 {
789 /* if save_item_power is set, then most likely we started with an 820 /* if save_item_power is set, then most likely we started with an
790 * artifact and have added new abilities to it - this is rare, but 821 * artifact and have added new abilities to it - this is rare, but
791 * but I have seen things like 'strange rings of fire'. So just figure 822 * but I have seen things like 'strange rings of fire'. So just figure
792 * out the power from the base power plus what this one adds. Note 823 * out the power from the base power plus what this one adds. Note
793 * that since item_power is not quite linear, this actually ends up 824 * that since item_power is not quite linear, this actually ends up
794 * being somewhat of a bonus 825 * being somewhat of a bonus
795 */ 826 */
796 if (save_item_power) { 827 if (save_item_power)
828 op->item_power =
797 op->item_power = save_item_power + get_power_from_ench(op->item_power); 829 save_item_power + get_power_from_ench (op->item_power);
798 } else { 830 else
831 op->item_power =
799 op->item_power = get_power_from_ench(op->item_power + num_enchantments); 832 get_power_from_ench (op->item_power + num_enchantments);
800 } 833 }
801 } else if (save_item_power) { 834 else if (save_item_power)
835 {
802 /* restore the item_power field to the object if we haven't changed it. 836 /* restore the item_power field to the object if we haven't changed it.
803 * we don't care about num_enchantments - that will basically just 837 * we don't care about num_enchantments - that will basically just
804 * have calculated some value from the base attributes of the archetype. 838 * have calculated some value from the base attributes of the archetype.
805 */ 839 */
806 op->item_power = save_item_power; 840 op->item_power = save_item_power;
807 } 841 }
808 } 842 }
809 843
810 /* materialtype modifications. Note we allow this on artifacts. */ 844 /* materialtype modifications. Note we allow this on artifacts. */
811
812 set_materialname(op, difficulty, NULL); 845 set_materialname (op, difficulty, NULL);
813 846
814 if (flags & GT_MINIMAL) { 847 if (flags & GT_MINIMAL)
848 {
815 if (op->type == POTION) 849 if (op->type == POTION)
816 /* Handle healing and magic power potions */ 850 /* Handle healing and magic power potions */
817 if (op->stats.sp && !op->randomitems) { 851 if (op->stats.sp && !op->randomitems)
818 object *tmp; 852 {
853 object *tmp;
819 854
820 tmp = get_archetype(spell_mapping[op->stats.sp]); 855 tmp = get_archetype (spell_mapping[op->stats.sp]);
821 insert_ob_in_ob(tmp, op); 856 insert_ob_in_ob (tmp, op);
822 op->stats.sp=0; 857 op->stats.sp = 0;
858 }
823 } 859 }
824 }
825 else if (!op->title) /* Only modify object if not special */ 860 else if (!op->title) /* Only modify object if not special */
826 switch(op->type) { 861 switch (op->type)
862 {
827 case WEAPON: 863 case WEAPON:
828 case ARMOUR: 864 case ARMOUR:
829 case SHIELD: 865 case SHIELD:
830 case HELMET: 866 case HELMET:
831 case CLOAK: 867 case CLOAK:
832 if (QUERY_FLAG(op, FLAG_CURSED) && !(RANDOM()%4)) 868 if (QUERY_FLAG (op, FLAG_CURSED) && !(RANDOM () % 4))
833 set_ring_bonus(op, -DICE2); 869 set_ring_bonus (op, -DICE2);
834 break; 870 break;
835 871
836 case BRACERS: 872 case BRACERS:
837 if (!(RANDOM()%(QUERY_FLAG(op, FLAG_CURSED)?5:20))) { 873 if (!(RANDOM () % (QUERY_FLAG (op, FLAG_CURSED) ? 5 : 20)))
874 {
838 set_ring_bonus(op,QUERY_FLAG(op, FLAG_CURSED)?-DICE2:DICE2); 875 set_ring_bonus (op, QUERY_FLAG (op, FLAG_CURSED) ? -DICE2 : DICE2);
839 if (!QUERY_FLAG(op, FLAG_CURSED)) 876 if (!QUERY_FLAG (op, FLAG_CURSED))
840 op->value*=3; 877 op->value *= 3;
841 } 878 }
842 break; 879 break;
843 880
844 case POTION: { 881 case POTION:
882 {
845 int too_many_tries=0,is_special=0; 883 int too_many_tries = 0, is_special = 0;
846 884
847 /* Handle healing and magic power potions */ 885 /* Handle healing and magic power potions */
848 if (op->stats.sp && !op->randomitems) { 886 if (op->stats.sp && !op->randomitems)
849 object *tmp; 887 {
888 object *tmp;
850 889
851 tmp = get_archetype(spell_mapping[op->stats.sp]); 890 tmp = get_archetype (spell_mapping[op->stats.sp]);
852 insert_ob_in_ob(tmp, op); 891 insert_ob_in_ob (tmp, op);
853 op->stats.sp=0; 892 op->stats.sp = 0;
854 } 893 }
855 894
856 while(!(is_special=special_potion(op)) && !op->inv) { 895 while (!(is_special = special_potion (op)) && !op->inv)
896 {
857 generate_artifact(op,difficulty); 897 generate_artifact (op, difficulty);
858 if(too_many_tries++ > 10) break; 898 if (too_many_tries++ > 10)
859 } 899 break;
900 }
901
860 /* don't want to change value for healing/magic power potions, 902 /* don't want to change value for healing/magic power potions,
861 * since the value set on those is already correct. 903 * since the value set on those is already correct.
862 */ 904 */
863 if (op->inv && op->randomitems) { 905 if (op->inv && op->randomitems)
906 {
864 /* value multiplier is same as for scrolls */ 907 /* value multiplier is same as for scrolls */
865 op->value=(op->value*op->inv->value); 908 op->value = (op->value * op->inv->value);
866 op->level = op->inv->level/2+ RANDOM()%difficulty + RANDOM()%difficulty; 909 op->level =
867 } else { 910 op->inv->level / 2 + RANDOM () % difficulty
911 + RANDOM () % difficulty;
912 }
913 else
914 {
868 FREE_AND_COPY(op->name, "potion"); 915 FREE_AND_COPY (op->name, "potion");
869 FREE_AND_COPY(op->name_pl, "potions"); 916 FREE_AND_COPY (op->name_pl, "potions");
870 } 917 }
871 if ( ! (flags & GT_ONLY_GOOD) && RANDOM() % 2) 918 if (!(flags & GT_ONLY_GOOD) && RANDOM () % 2)
872 SET_FLAG(op, FLAG_CURSED); 919 SET_FLAG (op, FLAG_CURSED);
873 break; 920 break;
874 } 921 }
875 922
876 case AMULET: 923 case AMULET:
877 if(op->arch==amulet_arch) 924 if (op->arch == amulet_arch)
878 op->value*=5; /* Since it's not just decoration */ 925 op->value *= 5; /* Since it's not just decoration */
879 926
880 case RING: 927 case RING:
881 if(op->arch==NULL) { 928 if (op->arch == NULL)
929 {
882 remove_ob(op); 930 remove_ob (op);
883 free_object(op); 931 free_object (op);
884 op=NULL; 932 op = NULL;
885 break; 933 break;
886 } 934 }
935
887 if(op->arch!=ring_arch&&op->arch!=amulet_arch) /* It's a special artifact!*/ 936 if (op->arch != ring_arch && op->arch != amulet_arch) /* It's a special artifact! */
888 break; 937 break;
889 938
890 if ( ! (flags & GT_ONLY_GOOD) && ! (RANDOM() % 3)) 939 if (!(flags & GT_ONLY_GOOD) && !(RANDOM () % 3))
891 SET_FLAG(op, FLAG_CURSED); 940 SET_FLAG (op, FLAG_CURSED);
941
892 set_ring_bonus(op,QUERY_FLAG(op, FLAG_CURSED)?-DICE2:DICE2); 942 set_ring_bonus (op, QUERY_FLAG (op, FLAG_CURSED) ? -DICE2 : DICE2);
943
893 if(op->type!=RING) /* Amulets have only one ability */ 944 if (op->type != RING) /* Amulets have only one ability */
894 break; 945 break;
895 if(!(RANDOM()%4)) { 946
896 int d=(RANDOM()%2 || QUERY_FLAG(op, FLAG_CURSED))?-DICE2:DICE2; 947 if (!(RANDOM () % 4))
897 if(d>0) 948 {
898 op->value*=3; 949 int d = (RANDOM () % 2
950 || QUERY_FLAG (op, FLAG_CURSED)) ? -DICE2 : DICE2;
951
952 if (d > 0)
953 op->value *= 3;
954
899 set_ring_bonus(op,d); 955 set_ring_bonus (op, d);
900 if(!(RANDOM()%4)) { 956
901 int d=(RANDOM()%3 || QUERY_FLAG(op, FLAG_CURSED))?-DICE2:DICE2; 957 if (!(RANDOM () % 4))
902 if(d>0) 958 {
903 op->value*=5; 959 int d = (RANDOM () % 3
904 set_ring_bonus(op,d); 960 || QUERY_FLAG (op, FLAG_CURSED)) ? -DICE2 : DICE2;
905 } 961 if (d > 0)
906 } 962 op->value *= 5;
963 set_ring_bonus (op, d);
964 }
965 }
966
907 if(GET_ANIM_ID(op)) 967 if (GET_ANIM_ID (op))
908 SET_ANIMATION(op, RANDOM()%((int) NUM_ANIMATIONS(op))); 968 SET_ANIMATION (op, RANDOM () % ((int) NUM_ANIMATIONS (op)));
909 break;
910 969
970 break;
971
911 case BOOK: 972 case BOOK:
912 /* Is it an empty book?, if yes lets make a special 973 /* Is it an empty book?, if yes lets make a special
913 * msg for it, and tailor its properties based on the 974 * msg for it, and tailor its properties based on the
914 * creator and/or map level we found it on. 975 * creator and/or map level we found it on.
915 */ 976 */
916 if(!op->msg&&RANDOM()%10) { 977 if (!op->msg && RANDOM () % 10)
978 {
917 /* set the book level properly */ 979 /* set the book level properly */
918 if(creator->level==0 || QUERY_FLAG(creator,FLAG_ALIVE)) { 980 if (creator->level == 0 || QUERY_FLAG (creator, FLAG_ALIVE))
919 if(op->map&&op->map->difficulty) 981 {
920 op->level=RANDOM()%(op->map->difficulty)+RANDOM()%10+1; 982 if (op->map && op->map->difficulty)
921 else 983 op->level =
922 op->level=RANDOM()%20+1; 984 RANDOM () % (op->map->difficulty) + RANDOM () % 10 + 1;
923 } else 985 else
986 op->level = RANDOM () % 20 + 1;
987 }
988 else
924 op->level=RANDOM()%creator->level; 989 op->level = RANDOM () % creator->level;
925 990
926 tailor_readable_ob(op,(creator&&creator->stats.sp)?creator->stats.sp:-1); 991 tailor_readable_ob (op,
992 (creator
993 && creator->stats.sp) ? creator->stats.
994 sp : -1);
927 /* books w/ info are worth more! */ 995 /* books w/ info are worth more! */
928 op->value*=((op->level>10?op->level:(op->level+1)/2)*((strlen(op->msg)/250)+1)); 996 op->value *=
997 ((op->level >
998 10 ? op->level : (op->level +
999 1) / 2) * ((strlen (op->msg) / 250) + 1));
929 /* creator related stuff */ 1000 /* creator related stuff */
930 1001
931 /* for library, chained books. Note that some monsters have no_pick 1002 /* for library, chained books. Note that some monsters have no_pick
932 * set - we don't want to set no pick in that case. 1003 * set - we don't want to set no pick in that case.
933 */ 1004 */
934 if(QUERY_FLAG(creator,FLAG_NO_PICK) && 1005 if (QUERY_FLAG (creator, FLAG_NO_PICK) &&
935 !QUERY_FLAG(creator, FLAG_MONSTER)) 1006 !QUERY_FLAG (creator, FLAG_MONSTER))
936 SET_FLAG(op,FLAG_NO_PICK); 1007 SET_FLAG (op, FLAG_NO_PICK);
937 if(creator->slaying&&!op->slaying) /* for check_inv floors */ 1008 if (creator->slaying && !op->slaying) /* for check_inv floors */
938 op->slaying = add_string(creator->slaying); 1009 op->slaying = add_string (creator->slaying);
939 1010
940 /* add exp so reading it gives xp (once)*/ 1011 /* add exp so reading it gives xp (once) */
941 op->stats.exp = op->value>10000?op->value/5:op->value/10; 1012 op->stats.exp =
942 } 1013 op->value > 10000 ? op->value / 5 : op->value / 10;
943 break; 1014 }
1015 break;
944 1016
945 case SPELLBOOK: 1017 case SPELLBOOK:
946 op->value=op->value* op->inv->value;
947 /* add exp so learning gives xp */
948 op->level = op->inv->level;
949 op->stats.exp = op->value;
950 break;
951
952 case WAND:
953 /* nrof in the treasure list is number of charges,
954 * not number of wands. So copy that into food (charges),
955 * and reset nrof.
956 */
957 op->stats.food=op->inv->nrof;
958 op->nrof=1;
959 /* If the spell changes by level, choose a random level
960 * for it, and adjust price. If the spell doesn't
961 * change by level, just set the wand to the level of
962 * the spell, and value calculation is simpler.
963 */
964 if (op->inv->duration_modifier || op->inv->dam_modifier ||
965 op->inv->range_modifier) {
966 op->level = level_for_item(op, difficulty);
967 op->value= op->value* op->inv->value * (op->level +50)/
968 (op->inv->level + 50);
969 }
970 else {
971 op->level = op->inv->level;
972 op->value = op->value * op->inv->value; 1018 op->value = op->value * op->inv->value;
973 } 1019 /* add exp so learning gives xp */
974 break; 1020 op->level = op->inv->level;
1021 op->stats.exp = op->value;
1022 break;
975 1023
1024 case WAND:
1025 /* nrof in the treasure list is number of charges,
1026 * not number of wands. So copy that into food (charges),
1027 * and reset nrof.
1028 */
1029 op->stats.food = op->inv->nrof;
1030 op->nrof = 1;
1031 /* If the spell changes by level, choose a random level
1032 * for it, and adjust price. If the spell doesn't
1033 * change by level, just set the wand to the level of
1034 * the spell, and value calculation is simpler.
1035 */
1036 if (op->inv->duration_modifier || op->inv->dam_modifier ||
1037 op->inv->range_modifier)
1038 {
1039 op->level = level_for_item (op, difficulty);
1040 op->value = op->value * op->inv->value * (op->level + 50) /
1041 (op->inv->level + 50);
1042 }
1043 else
1044 {
1045 op->level = op->inv->level;
1046 op->value = op->value * op->inv->value;
1047 }
1048 break;
1049
976 case ROD: 1050 case ROD:
977 op->level = level_for_item(op, difficulty); 1051 op->level = level_for_item (op, difficulty);
978 /* Add 50 to both level an divisor to keep prices a little more 1052 /* Add 50 to both level an divisor to keep prices a little more
979 * reasonable. Otherwise, a high level version of a low level 1053 * reasonable. Otherwise, a high level version of a low level
980 * spell can be worth tons a money (eg, level 20 rod, level 2 spell = 1054 * spell can be worth tons a money (eg, level 20 rod, level 2 spell =
981 * 10 time multiplier). This way, the value are a bit more reasonable. 1055 * 10 time multiplier). This way, the value are a bit more reasonable.
982 */ 1056 */
1057 op->value =
983 op->value= op->value * op->inv->value * (op->level +50) / (op->inv->level + 50); 1058 op->value * op->inv->value * (op->level + 50) / (op->inv->level +
1059 50);
984 /* maxhp is used to denote how many 'charges' the rod holds before */ 1060 /* maxhp is used to denote how many 'charges' the rod holds before */
985 if (op->stats.maxhp) 1061 if (op->stats.maxhp)
986 op->stats.maxhp *= MAX(op->inv->stats.sp, op->inv->stats.grace); 1062 op->stats.maxhp *= MAX (op->inv->stats.sp, op->inv->stats.grace);
987 else 1063 else
988 op->stats.maxhp = 2 * MAX(op->inv->stats.sp, op->inv->stats.grace); 1064 op->stats.maxhp = 2 * MAX (op->inv->stats.sp, op->inv->stats.grace);
989 1065
990 op->stats.hp = op->stats.maxhp; 1066 op->stats.hp = op->stats.maxhp;
991 break; 1067 break;
992 1068
993 case SCROLL: 1069 case SCROLL:
994 op->level = level_for_item(op, difficulty); 1070 op->level = level_for_item (op, difficulty);
995 op->value= op->value * op->inv->value * (op->level +50) / (op->inv->level + 50); 1071 op->value =
1072 op->value * op->inv->value
1073 * (op->level + 50) / (op->inv->level + 50);
1074
996 /* add exp so reading them properly gives xp */ 1075 /* add exp so reading them properly gives xp */
997 op->stats.exp = op->value/5; 1076 op->stats.exp = op->value / 5;
998 op->nrof = op->inv->nrof; 1077 op->nrof = op->inv->nrof;
999 break; 1078 break;
1000 1079
1001 case RUNE: 1080 case RUNE:
1002 trap_adjust(op,difficulty); 1081 trap_adjust (op, difficulty);
1003 break; 1082 break;
1004 1083
1005 case TRAP: 1084 case TRAP:
1006 trap_adjust(op,difficulty); 1085 trap_adjust (op, difficulty);
1007 break; 1086 break;
1008 } /* switch type */ 1087 } /* switch type */
1009 1088
1010 if (flags & GT_STARTEQUIP) { 1089 if (flags & GT_STARTEQUIP)
1090 {
1011 if (op->nrof < 2 && op->type != CONTAINER 1091 if (op->nrof < 2 && op->type != CONTAINER
1012 && op->type != MONEY && ! QUERY_FLAG (op, FLAG_IS_THROWN)) 1092 && op->type != MONEY && !QUERY_FLAG (op, FLAG_IS_THROWN))
1013 SET_FLAG (op, FLAG_STARTEQUIP); 1093 SET_FLAG (op, FLAG_STARTEQUIP);
1014 else if (op->type != MONEY) 1094 else if (op->type != MONEY)
1015 op->value = 0; 1095 op->value = 0;
1016 } 1096 }
1017 1097
1018 if ( ! (flags & GT_ENVIRONMENT)) 1098 if (!(flags & GT_ENVIRONMENT))
1019 fix_flesh_item (op, creator); 1099 fix_flesh_item (op, creator);
1020} 1100}
1021 1101
1022/* 1102/*
1023 * 1103 *
1024 * 1104 *

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines