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