… | |
… | |
74 | if (!(random_roll (0, 3, op, PREFER_HIGH))) |
74 | if (!(random_roll (0, 3, op, PREFER_HIGH))) |
75 | { |
75 | { |
76 | new_draw_info_format (NDI_UNIQUE, 0, op, "The %s vibrates violently, then explodes!", query_name (wand)); |
76 | new_draw_info_format (NDI_UNIQUE, 0, op, "The %s vibrates violently, then explodes!", query_name (wand)); |
77 | play_sound_map (op->map, op->x, op->y, SOUND_OB_EXPLODE); |
77 | play_sound_map (op->map, op->x, op->y, SOUND_OB_EXPLODE); |
78 | esrv_del_item (op->contr, wand->count); |
78 | esrv_del_item (op->contr, wand->count); |
79 | remove_ob (wand); |
79 | wand->destroy (); |
80 | free_object (wand); |
|
|
81 | tmp = get_archetype ("fireball"); |
80 | tmp = get_archetype ("fireball"); |
82 | tmp->stats.dam = (spell_ob->stats.dam + SP_level_dam_adjust (caster, spell_ob)) / 10; |
81 | tmp->stats.dam = (spell_ob->stats.dam + SP_level_dam_adjust (caster, spell_ob)) / 10; |
83 | if (!tmp->stats.dam) |
82 | if (!tmp->stats.dam) |
84 | tmp->stats.dam = 1; |
83 | tmp->stats.dam = 1; |
85 | tmp->stats.hp = tmp->stats.dam / 2; |
84 | tmp->stats.hp = tmp->stats.dam / 2; |
… | |
… | |
158 | if (!strcasecmp (al->item->name, stringarg)) |
157 | if (!strcasecmp (al->item->name, stringarg)) |
159 | break; |
158 | break; |
160 | |
159 | |
161 | if (!al) |
160 | if (!al) |
162 | { |
161 | { |
163 | free_object (missile); |
162 | missile->destroy (); |
164 | new_draw_info_format (NDI_UNIQUE, 0, op, "No such object %ss of %s", missile_name, stringarg); |
163 | new_draw_info_format (NDI_UNIQUE, 0, op, "No such object %ss of %s", missile_name, stringarg); |
165 | return 0; |
164 | return 0; |
166 | } |
165 | } |
167 | |
166 | |
168 | if (al->item->slaying) |
167 | if (al->item->slaying) |
169 | { |
168 | { |
170 | free_object (missile); |
169 | missile->destroy (); |
171 | new_draw_info_format (NDI_UNIQUE, 0, op, "You are not allowed to create %ss of %s", missile_name, stringarg); |
170 | new_draw_info_format (NDI_UNIQUE, 0, op, "You are not allowed to create %ss of %s", missile_name, stringarg); |
172 | return 0; |
171 | return 0; |
173 | } |
172 | } |
174 | |
173 | |
175 | give_artifact_abilities (missile, al->item); |
174 | give_artifact_abilities (missile, al->item); |
… | |
… | |
461 | |
460 | |
462 | while (op != NULL && op->type != PLAYER) |
461 | while (op != NULL && op->type != PLAYER) |
463 | op = op->env; |
462 | op = op->env; |
464 | |
463 | |
465 | if (op != NULL && op->map) |
464 | if (op != NULL && op->map) |
466 | { |
|
|
467 | if ((get_map_flags (op->map, NULL, op->x, op->y, NULL, NULL) & P_NO_CLERIC) && (!QUERY_FLAG (op, FLAG_WIZCAST))) |
465 | if ((get_map_flags (op->map, NULL, op->x, op->y, NULL, NULL) & P_NO_CLERIC) && (!QUERY_FLAG (op, FLAG_WIZCAST))) |
468 | new_draw_info (NDI_UNIQUE, 0, op, "You feel something fizzle inside you."); |
466 | new_draw_info (NDI_UNIQUE, 0, op, "You feel something fizzle inside you."); |
469 | else |
467 | else |
470 | enter_exit (op, wor); |
468 | enter_exit (op, wor); |
471 | } |
469 | |
472 | remove_ob (wor); |
470 | wor->destroy (); |
473 | free_object (wor); |
|
|
474 | } |
471 | } |
475 | |
472 | |
476 | /* Word of recall causes the player to return 'home'. |
473 | /* Word of recall causes the player to return 'home'. |
477 | * we put a force into the player object, so that there is a |
474 | * we put a force into the player object, so that there is a |
478 | * time delay effect. |
475 | * time delay effect. |
… | |
… | |
662 | */ |
659 | */ |
663 | dummy = arch_to_object (spell->other_arch); |
660 | dummy = arch_to_object (spell->other_arch); |
664 | if (dummy == NULL) |
661 | if (dummy == NULL) |
665 | { |
662 | { |
666 | new_draw_info (NDI_UNIQUE, 0, op, "Oops, program error!"); |
663 | new_draw_info (NDI_UNIQUE, 0, op, "Oops, program error!"); |
667 | LOG (llevError, "get_object failed (force in cast_create_town_portal for %s!\n", &op->name); |
664 | LOG (llevError, "object::create failed (force in cast_create_town_portal for %s!\n", &op->name); |
668 | return 0; |
665 | return 0; |
669 | } |
666 | } |
|
|
667 | |
670 | force = check_inv_recursive (op, dummy); |
668 | force = check_inv_recursive (op, dummy); |
671 | |
669 | |
672 | if (force == NULL) |
670 | if (force == NULL) |
673 | { |
671 | { |
674 | /* Here we know there is no destination marked up. |
672 | /* Here we know there is no destination marked up. |
… | |
… | |
681 | EXIT_Y (dummy) = op->y; |
679 | EXIT_Y (dummy) = op->y; |
682 | insert_ob_in_ob (dummy, op); |
680 | insert_ob_in_ob (dummy, op); |
683 | new_draw_info (NDI_UNIQUE | NDI_NAVY, 0, op, "You fix this place in your mind.\nYou feel you are able to come here from anywhere."); |
681 | new_draw_info (NDI_UNIQUE | NDI_NAVY, 0, op, "You fix this place in your mind.\nYou feel you are able to come here from anywhere."); |
684 | return 1; |
682 | return 1; |
685 | } |
683 | } |
686 | free_object (dummy); |
684 | |
|
|
685 | dummy->destroy (); |
687 | |
686 | |
688 | /* Here we know where the town portal should go to |
687 | /* Here we know where the town portal should go to |
689 | * We should kill any existing portal associated with the player. |
688 | * We should kill any existing portal associated with the player. |
690 | * Than we should create the 2 portals. |
689 | * Than we should create the 2 portals. |
691 | * For each of them, we need: |
690 | * For each of them, we need: |
… | |
… | |
704 | /* First step: killing existing town portals */ |
703 | /* First step: killing existing town portals */ |
705 | dummy = get_archetype (spell->race); |
704 | dummy = get_archetype (spell->race); |
706 | if (dummy == NULL) |
705 | if (dummy == NULL) |
707 | { |
706 | { |
708 | new_draw_info (NDI_UNIQUE, 0, op, "Oops, program error!"); |
707 | new_draw_info (NDI_UNIQUE, 0, op, "Oops, program error!"); |
709 | LOG (llevError, "get_object failed (force) in cast_create_town_portal for %s!\n", &op->name); |
708 | LOG (llevError, "object::create failed (force) in cast_create_town_portal for %s!\n", &op->name); |
710 | return 0; |
709 | return 0; |
711 | } |
710 | } |
|
|
711 | |
712 | perm_portal = archetype::find (spell->slaying); |
712 | perm_portal = archetype::find (spell->slaying); |
713 | |
713 | |
714 | /* To kill a town portal, we go trough the player's inventory, |
714 | /* To kill a town portal, we go trough the player's inventory, |
715 | * for each marked portal in player's inventory, |
715 | * for each marked portal in player's inventory, |
716 | * -We try load the associated map (if impossible, consider the portal destructed) |
716 | * -We try load the associated map (if impossible, consider the portal destructed) |
… | |
… | |
734 | tmp = present_arch (perm_portal, exitmap, exitx, exity); |
734 | tmp = present_arch (perm_portal, exitmap, exitx, exity); |
735 | while (tmp) |
735 | while (tmp) |
736 | { |
736 | { |
737 | if (tmp->name == old_force->name) |
737 | if (tmp->name == old_force->name) |
738 | { |
738 | { |
739 | remove_ob (tmp); |
739 | tmp->destroy (); |
740 | free_object (tmp); |
|
|
741 | break; |
740 | break; |
742 | } |
741 | } |
743 | else |
742 | |
744 | { |
|
|
745 | tmp = tmp->above; |
743 | tmp = tmp->above; |
746 | } |
|
|
747 | } |
744 | } |
748 | } |
745 | } |
749 | remove_ob (old_force); |
746 | |
750 | free_object (old_force); |
747 | old_force->destroy (); |
751 | LOG (llevDebug, "\n"); |
748 | LOG (llevDebug, "\n"); |
752 | } |
749 | } |
753 | free_object (dummy); |
750 | |
|
|
751 | dummy->destroy (); |
754 | |
752 | |
755 | /* Creating the portals. |
753 | /* Creating the portals. |
756 | * The very first thing to do is to ensure |
754 | * The very first thing to do is to ensure |
757 | * access to the destination map. |
755 | * access to the destination map. |
758 | * If we can't, don't fizzle. Simply warn player. |
756 | * If we can't, don't fizzle. Simply warn player. |
… | |
… | |
770 | |
768 | |
771 | /* If we were unable to load (ex. random map deleted), warn player */ |
769 | /* If we were unable to load (ex. random map deleted), warn player */ |
772 | if (exitmap == NULL) |
770 | if (exitmap == NULL) |
773 | { |
771 | { |
774 | new_draw_info (NDI_UNIQUE | NDI_NAVY, 0, op, "Something strange happens.\nYou can't remember where to go!?"); |
772 | new_draw_info (NDI_UNIQUE | NDI_NAVY, 0, op, "Something strange happens.\nYou can't remember where to go!?"); |
775 | remove_ob (force); |
773 | force->destroy (); |
776 | free_object (force); |
|
|
777 | return 1; |
774 | return 1; |
778 | } |
775 | } |
779 | |
776 | |
780 | op_level = caster_level (caster, spell); |
777 | op_level = caster_level (caster, spell); |
781 | if (op_level < 15) |
778 | if (op_level < 15) |
… | |
… | |
799 | snprintf (portal_name, 1024, "%s's portal to %s", &op->name, &force->name); |
796 | snprintf (portal_name, 1024, "%s's portal to %s", &op->name, &force->name); |
800 | dummy = get_archetype (spell->slaying); /*The portal */ |
797 | dummy = get_archetype (spell->slaying); /*The portal */ |
801 | if (dummy == NULL) |
798 | if (dummy == NULL) |
802 | { |
799 | { |
803 | new_draw_info (NDI_UNIQUE, 0, op, "Oops, program error!"); |
800 | new_draw_info (NDI_UNIQUE, 0, op, "Oops, program error!"); |
804 | LOG (llevError, "get_object failed (perm_magic_portal) in cast_create_town_portal for %s!\n", &op->name); |
801 | LOG (llevError, "object::create failed (perm_magic_portal) in cast_create_town_portal for %s!\n", &op->name); |
805 | return 0; |
802 | return 0; |
806 | } |
803 | } |
|
|
804 | |
807 | EXIT_PATH (dummy) = force->name; |
805 | EXIT_PATH (dummy) = force->name; |
808 | EXIT_X (dummy) = EXIT_X (force); |
806 | EXIT_X (dummy) = EXIT_X (force); |
809 | EXIT_Y (dummy) = EXIT_Y (force); |
807 | EXIT_Y (dummy) = EXIT_Y (force); |
810 | dummy->name = dummy->name_pl = portal_name; |
808 | dummy->name = dummy->name_pl = portal_name; |
811 | dummy->msg = portal_message; |
809 | dummy->msg = portal_message; |
… | |
… | |
818 | */ |
816 | */ |
819 | tmp = get_archetype (spell->race); |
817 | tmp = get_archetype (spell->race); |
820 | if (tmp == NULL) |
818 | if (tmp == NULL) |
821 | { |
819 | { |
822 | new_draw_info (NDI_UNIQUE, 0, op, "Oops, program error!"); |
820 | new_draw_info (NDI_UNIQUE, 0, op, "Oops, program error!"); |
823 | LOG (llevError, "get_object failed (force) in cast_create_town_portal for %s!\n", &op->name); |
821 | LOG (llevError, "object::create failed (force) in cast_create_town_portal for %s!\n", &op->name); |
824 | return 0; |
822 | return 0; |
825 | } |
823 | } |
|
|
824 | |
826 | tmp->race = op->map->path; |
825 | tmp->race = op->map->path; |
827 | tmp->name = portal_name; |
826 | tmp->name = portal_name; |
828 | EXIT_X (tmp) = dummy->x; |
827 | EXIT_X (tmp) = dummy->x; |
829 | EXIT_Y (tmp) = dummy->y; |
828 | EXIT_Y (tmp) = dummy->y; |
830 | insert_ob_in_ob (tmp, op); |
829 | insert_ob_in_ob (tmp, op); |
… | |
… | |
838 | snprintf (portal_name, 1024, "%s's portal to %s", &op->name, op->map->path); |
837 | snprintf (portal_name, 1024, "%s's portal to %s", &op->name, op->map->path); |
839 | dummy = get_archetype (spell->slaying); /*The portal */ |
838 | dummy = get_archetype (spell->slaying); /*The portal */ |
840 | if (dummy == NULL) |
839 | if (dummy == NULL) |
841 | { |
840 | { |
842 | new_draw_info (NDI_UNIQUE, 0, op, "Oops, program error!"); |
841 | new_draw_info (NDI_UNIQUE, 0, op, "Oops, program error!"); |
843 | LOG (llevError, "get_object failed (perm_magic_portal) in cast_create_town_portal for %s!\n", &op->name); |
842 | LOG (llevError, "object::create failed (perm_magic_portal) in cast_create_town_portal for %s!\n", &op->name); |
844 | return 0; |
843 | return 0; |
845 | } |
844 | } |
|
|
845 | |
846 | EXIT_PATH (dummy) = op->map->path; |
846 | EXIT_PATH (dummy) = op->map->path; |
847 | EXIT_X (dummy) = op->x; |
847 | EXIT_X (dummy) = op->x; |
848 | EXIT_Y (dummy) = op->y; |
848 | EXIT_Y (dummy) = op->y; |
849 | dummy->name = dummy->name_pl = portal_name; |
849 | dummy->name = dummy->name_pl = portal_name; |
850 | dummy->msg = portal_message; |
850 | dummy->msg = portal_message; |
… | |
… | |
858 | */ |
858 | */ |
859 | tmp = get_archetype (spell->race); |
859 | tmp = get_archetype (spell->race); |
860 | if (tmp == NULL) |
860 | if (tmp == NULL) |
861 | { |
861 | { |
862 | new_draw_info (NDI_UNIQUE, 0, op, "Oops, program error!"); |
862 | new_draw_info (NDI_UNIQUE, 0, op, "Oops, program error!"); |
863 | LOG (llevError, "get_object failed (force) in cast_create_town_portal for %s!\n", &op->name); |
863 | LOG (llevError, "object::create failed (force) in cast_create_town_portal for %s!\n", &op->name); |
864 | return 0; |
864 | return 0; |
865 | } |
865 | } |
|
|
866 | |
866 | tmp->race = force->name; |
867 | tmp->race = force->name; |
867 | tmp->name = portal_name; |
868 | tmp->name = portal_name; |
868 | EXIT_X (tmp) = dummy->x; |
869 | EXIT_X (tmp) = dummy->x; |
869 | EXIT_Y (tmp) = dummy->y; |
870 | EXIT_Y (tmp) = dummy->y; |
870 | insert_ob_in_ob (tmp, op); |
871 | insert_ob_in_ob (tmp, op); |
871 | |
872 | |
872 | /* Describe the player what happened |
873 | /* Describe the player what happened |
873 | */ |
874 | */ |
874 | new_draw_info (NDI_UNIQUE | NDI_NAVY, 0, op, "You see air moving and showing you the way home."); |
875 | new_draw_info (NDI_UNIQUE | NDI_NAVY, 0, op, "You see air moving and showing you the way home."); |
875 | remove_ob (force); /* Delete the force inside the player */ |
876 | force->destroy (); |
876 | free_object (force); |
877 | |
877 | return 1; |
878 | return 1; |
878 | } |
879 | } |
879 | |
880 | |
880 | |
881 | |
881 | /* This creates magic walls. Really, it can create most any object, |
882 | /* This creates magic walls. Really, it can create most any object, |
… | |
… | |
945 | } |
946 | } |
946 | else if (QUERY_FLAG (tmp, FLAG_ALIVE)) |
947 | else if (QUERY_FLAG (tmp, FLAG_ALIVE)) |
947 | { |
948 | { |
948 | tmp->stats.hp = spell_ob->duration + SP_level_duration_adjust (caster, spell_ob); |
949 | tmp->stats.hp = spell_ob->duration + SP_level_duration_adjust (caster, spell_ob); |
949 | tmp->stats.maxhp = tmp->stats.hp; |
950 | tmp->stats.maxhp = tmp->stats.hp; |
950 | set_owner (tmp, op); |
951 | tmp->set_owner (op); |
951 | set_spell_skill (op, caster, spell_ob, tmp); |
952 | set_spell_skill (op, caster, spell_ob, tmp); |
952 | } |
953 | } |
953 | if (QUERY_FLAG (spell_ob, FLAG_IS_USED_UP) || QUERY_FLAG (tmp, FLAG_IS_USED_UP)) |
954 | if (QUERY_FLAG (spell_ob, FLAG_IS_USED_UP) || QUERY_FLAG (tmp, FLAG_IS_USED_UP)) |
954 | { |
955 | { |
955 | tmp->stats.food = spell_ob->duration + SP_level_duration_adjust (caster, spell_ob); |
956 | tmp->stats.food = spell_ob->duration + SP_level_duration_adjust (caster, spell_ob); |
… | |
… | |
964 | } |
965 | } |
965 | |
966 | |
966 | /* This can't really hurt - if the object doesn't kill anything, |
967 | /* This can't really hurt - if the object doesn't kill anything, |
967 | * these fields just won't be used. |
968 | * these fields just won't be used. |
968 | */ |
969 | */ |
969 | set_owner (tmp, op); |
970 | tmp->set_owner (op); |
970 | set_spell_skill (op, caster, spell_ob, tmp); |
971 | set_spell_skill (op, caster, spell_ob, tmp); |
971 | tmp->x = x; |
972 | tmp->x = x; |
972 | tmp->y = y; |
973 | tmp->y = y; |
973 | tmp->level = caster_level (caster, spell_ob) / 2; |
974 | tmp->level = caster_level (caster, spell_ob) / 2; |
974 | |
975 | |
… | |
… | |
1003 | m = tmp->map; |
1004 | m = tmp->map; |
1004 | |
1005 | |
1005 | if (!(get_map_flags (m, &m, x, y, &x, &y) & (P_OUT_OF_MAP | P_IS_ALIVE)) && |
1006 | if (!(get_map_flags (m, &m, x, y, &x, &y) & (P_OUT_OF_MAP | P_IS_ALIVE)) && |
1006 | ((spell_ob->move_block & GET_MAP_MOVE_BLOCK (m, x, y)) != spell_ob->move_block) && !posblocked) |
1007 | ((spell_ob->move_block & GET_MAP_MOVE_BLOCK (m, x, y)) != spell_ob->move_block) && !posblocked) |
1007 | { |
1008 | { |
1008 | tmp2 = get_object (); |
1009 | tmp2 = tmp->clone (); |
1009 | copy_object (tmp, tmp2); |
|
|
1010 | tmp2->x = x; |
1010 | tmp2->x = x; |
1011 | tmp2->y = y; |
1011 | tmp2->y = y; |
1012 | insert_ob_in_map (tmp2, m, op, 0); |
1012 | insert_ob_in_map (tmp2, m, op, 0); |
1013 | /* If this is a spellcasting wall, need to insert the spell object */ |
1013 | /* If this is a spellcasting wall, need to insert the spell object */ |
1014 | if (tmp2->other_arch && tmp2->other_arch->clone.type == SPELL) |
1014 | if (tmp2->other_arch && tmp2->other_arch->clone.type == SPELL) |
… | |
… | |
1023 | m = tmp->map; |
1023 | m = tmp->map; |
1024 | |
1024 | |
1025 | if (!(get_map_flags (m, &m, x, y, &x, &y) & (P_OUT_OF_MAP | P_IS_ALIVE)) && |
1025 | if (!(get_map_flags (m, &m, x, y, &x, &y) & (P_OUT_OF_MAP | P_IS_ALIVE)) && |
1026 | ((spell_ob->move_block & GET_MAP_MOVE_BLOCK (m, x, y)) != spell_ob->move_block) && !negblocked) |
1026 | ((spell_ob->move_block & GET_MAP_MOVE_BLOCK (m, x, y)) != spell_ob->move_block) && !negblocked) |
1027 | { |
1027 | { |
1028 | tmp2 = get_object (); |
1028 | tmp2 = tmp->clone (); |
1029 | copy_object (tmp, tmp2); |
|
|
1030 | tmp2->x = x; |
1029 | tmp2->x = x; |
1031 | tmp2->y = y; |
1030 | tmp2->y = y; |
1032 | insert_ob_in_map (tmp2, m, op, 0); |
1031 | insert_ob_in_map (tmp2, m, op, 0); |
1033 | if (tmp2->other_arch && tmp2->other_arch->clone.type == SPELL) |
1032 | if (tmp2->other_arch && tmp2->other_arch->clone.type == SPELL) |
1034 | insert_ob_in_ob (arch_to_object (tmp2->other_arch), tmp2); |
1033 | insert_ob_in_ob (arch_to_object (tmp2->other_arch), tmp2); |
… | |
… | |
1146 | return 0; |
1145 | return 0; |
1147 | } |
1146 | } |
1148 | } |
1147 | } |
1149 | |
1148 | |
1150 | /* Actually move the player now */ |
1149 | /* Actually move the player now */ |
1151 | remove_ob (op); |
1150 | op->remove (); |
1152 | op->x += freearr_x[dir] * dist; |
1151 | op->x += freearr_x[dir] * dist; |
1153 | op->y += freearr_y[dir] * dist; |
1152 | op->y += freearr_y[dir] * dist; |
1154 | if ((op = insert_ob_in_map (op, op->map, op, 0)) == NULL) |
1153 | if ((op = insert_ob_in_map (op, op->map, op, 0)) == NULL) |
1155 | return 1; |
1154 | return 1; |
1156 | |
1155 | |
… | |
… | |
1622 | *small_nuggets -= large->value / small->value; |
1621 | *small_nuggets -= large->value / small->value; |
1623 | if (*small_nuggets && large->value % small->value) |
1622 | if (*small_nuggets && large->value % small->value) |
1624 | (*small_nuggets)--; |
1623 | (*small_nuggets)--; |
1625 | } |
1624 | } |
1626 | weight += obj->weight; |
1625 | weight += obj->weight; |
1627 | remove_ob (obj); |
1626 | obj->destroy (); |
1628 | free_object (obj); |
|
|
1629 | } |
1627 | } |
1630 | |
1628 | |
1631 | static void |
1629 | static void |
1632 | update_map (object *op, maptile *m, int small_nuggets, int large_nuggets, int x, int y) |
1630 | update_map (object *op, maptile *m, int small_nuggets, int large_nuggets, int x, int y) |
1633 | { |
1631 | { |
… | |
… | |
1640 | if (x == op->x && y == op->y && op->map == m) |
1638 | if (x == op->x && y == op->y && op->map == m) |
1641 | flag = INS_BELOW_ORIGINATOR; |
1639 | flag = INS_BELOW_ORIGINATOR; |
1642 | |
1640 | |
1643 | if (small_nuggets) |
1641 | if (small_nuggets) |
1644 | { |
1642 | { |
1645 | tmp = get_object (); |
1643 | tmp = small->clone (); |
1646 | copy_object (small, tmp); |
|
|
1647 | tmp->nrof = small_nuggets; |
1644 | tmp->nrof = small_nuggets; |
1648 | tmp->x = x; |
1645 | tmp->x = x; |
1649 | tmp->y = y; |
1646 | tmp->y = y; |
1650 | insert_ob_in_map (tmp, m, op, flag); |
1647 | insert_ob_in_map (tmp, m, op, flag); |
1651 | } |
1648 | } |
|
|
1649 | |
1652 | if (large_nuggets) |
1650 | if (large_nuggets) |
1653 | { |
1651 | { |
1654 | tmp = get_object (); |
1652 | tmp = large->clone (); |
1655 | copy_object (large, tmp); |
|
|
1656 | tmp->nrof = large_nuggets; |
1653 | tmp->nrof = large_nuggets; |
1657 | tmp->x = x; |
1654 | tmp->x = x; |
1658 | tmp->y = y; |
1655 | tmp->y = y; |
1659 | insert_ob_in_map (tmp, m, op, flag); |
1656 | insert_ob_in_map (tmp, m, op, flag); |
1660 | } |
1657 | } |
… | |
… | |
1725 | alchemy_object (tmp, &small_nuggets, &large_nuggets, &weight); |
1722 | alchemy_object (tmp, &small_nuggets, &large_nuggets, &weight); |
1726 | |
1723 | |
1727 | if (weight > weight_max) |
1724 | if (weight > weight_max) |
1728 | { |
1725 | { |
1729 | update_map (op, mp, small_nuggets, large_nuggets, nx, ny); |
1726 | update_map (op, mp, small_nuggets, large_nuggets, nx, ny); |
1730 | free_object (large); |
1727 | large->destroy (); |
1731 | free_object (small); |
1728 | small->destroy (); |
1732 | return 1; |
1729 | return 1; |
1733 | } |
1730 | } |
1734 | } /* is alchemable object */ |
1731 | } /* is alchemable object */ |
1735 | } /* process all objects on this space */ |
1732 | } /* process all objects on this space */ |
1736 | |
1733 | |
… | |
… | |
1739 | * with this spell. |
1736 | * with this spell. |
1740 | */ |
1737 | */ |
1741 | update_map (op, mp, small_nuggets, large_nuggets, nx, ny); |
1738 | update_map (op, mp, small_nuggets, large_nuggets, nx, ny); |
1742 | } |
1739 | } |
1743 | } |
1740 | } |
1744 | free_object (large); |
1741 | |
1745 | free_object (small); |
1742 | large->destroy (); |
|
|
1743 | small->destroy (); |
1746 | /* reset this so that if player standing on a big pile of stuff, |
1744 | /* reset this so that if player standing on a big pile of stuff, |
1747 | * it is redrawn properly. |
1745 | * it is redrawn properly. |
1748 | */ |
1746 | */ |
1749 | op->contr->socket.look_position = 0; |
1747 | op->contr->socket->look_position = 0; |
1750 | return 1; |
1748 | return 1; |
1751 | } |
1749 | } |
1752 | |
1750 | |
1753 | |
1751 | |
1754 | /* This function removes the cursed/damned status on equipped |
1752 | /* This function removes the cursed/damned status on equipped |
… | |
… | |
1763 | for (tmp = op->inv; tmp; tmp = tmp->below) |
1761 | for (tmp = op->inv; tmp; tmp = tmp->below) |
1764 | if (QUERY_FLAG (tmp, FLAG_APPLIED) && |
1762 | if (QUERY_FLAG (tmp, FLAG_APPLIED) && |
1765 | ((QUERY_FLAG (tmp, FLAG_CURSED) && QUERY_FLAG (spell, FLAG_CURSED)) || |
1763 | ((QUERY_FLAG (tmp, FLAG_CURSED) && QUERY_FLAG (spell, FLAG_CURSED)) || |
1766 | (QUERY_FLAG (tmp, FLAG_DAMNED) && QUERY_FLAG (spell, FLAG_DAMNED)))) |
1764 | (QUERY_FLAG (tmp, FLAG_DAMNED) && QUERY_FLAG (spell, FLAG_DAMNED)))) |
1767 | { |
1765 | { |
1768 | |
|
|
1769 | was_one++; |
1766 | was_one++; |
1770 | if (tmp->level <= caster_level (caster, spell)) |
1767 | if (tmp->level <= caster_level (caster, spell)) |
1771 | { |
1768 | { |
1772 | success++; |
1769 | success++; |
1773 | if (QUERY_FLAG (spell, FLAG_DAMNED)) |
1770 | if (QUERY_FLAG (spell, FLAG_DAMNED)) |
… | |
… | |
1793 | new_draw_info (NDI_UNIQUE, 0, op, "You failed to remove the curse."); |
1790 | new_draw_info (NDI_UNIQUE, 0, op, "You failed to remove the curse."); |
1794 | else |
1791 | else |
1795 | new_draw_info (NDI_UNIQUE, 0, op, "You are not using any cursed items."); |
1792 | new_draw_info (NDI_UNIQUE, 0, op, "You are not using any cursed items."); |
1796 | } |
1793 | } |
1797 | } |
1794 | } |
|
|
1795 | |
1798 | return success; |
1796 | return success; |
1799 | } |
1797 | } |
1800 | |
1798 | |
1801 | /* Identifies objects in the players inventory/on the ground */ |
1799 | /* Identifies objects in the players inventory/on the ground */ |
1802 | |
1800 | |
… | |
… | |
1809 | num_ident = spell->stats.dam + SP_level_dam_adjust (caster, spell); |
1807 | num_ident = spell->stats.dam + SP_level_dam_adjust (caster, spell); |
1810 | |
1808 | |
1811 | if (num_ident < 1) |
1809 | if (num_ident < 1) |
1812 | num_ident = 1; |
1810 | num_ident = 1; |
1813 | |
1811 | |
1814 | |
|
|
1815 | for (tmp = op->inv; tmp; tmp = tmp->below) |
1812 | for (tmp = op->inv; tmp; tmp = tmp->below) |
1816 | { |
1813 | { |
1817 | if (!QUERY_FLAG (tmp, FLAG_IDENTIFIED) && !tmp->invisible && need_identify (tmp)) |
1814 | if (!QUERY_FLAG (tmp, FLAG_IDENTIFIED) && !tmp->invisible && need_identify (tmp)) |
1818 | { |
1815 | { |
1819 | identify (tmp); |
1816 | identify (tmp); |
|
|
1817 | |
1820 | if (op->type == PLAYER) |
1818 | if (op->type == PLAYER) |
1821 | { |
1819 | { |
1822 | new_draw_info_format (NDI_UNIQUE, 0, op, "You have %s.", long_desc (tmp, op)); |
1820 | new_draw_info_format (NDI_UNIQUE, 0, op, "You have %s.", long_desc (tmp, op)); |
|
|
1821 | |
1823 | if (tmp->msg) |
1822 | if (tmp->msg) |
1824 | { |
1823 | { |
1825 | new_draw_info (NDI_UNIQUE, 0, op, "The item has a story:"); |
1824 | new_draw_info (NDI_UNIQUE, 0, op, "The item has a story:"); |
1826 | new_draw_info (NDI_UNIQUE, 0, op, tmp->msg); |
1825 | new_draw_info (NDI_UNIQUE, 0, op, tmp->msg); |
1827 | } |
1826 | } |
1828 | } |
1827 | } |
|
|
1828 | |
1829 | num_ident--; |
1829 | num_ident--; |
1830 | success = 1; |
1830 | success = 1; |
1831 | if (!num_ident) |
1831 | if (!num_ident) |
1832 | break; |
1832 | break; |
1833 | } |
1833 | } |
1834 | } |
1834 | } |
|
|
1835 | |
1835 | /* If all the power of the spell has been used up, don't go and identify |
1836 | /* If all the power of the spell has been used up, don't go and identify |
1836 | * stuff on the floor. Only identify stuff on the floor if the spell |
1837 | * stuff on the floor. Only identify stuff on the floor if the spell |
1837 | * was not fully used. |
1838 | * was not fully used. |
1838 | */ |
1839 | */ |
1839 | if (num_ident) |
1840 | if (num_ident) |
1840 | { |
1841 | { |
1841 | for (tmp = get_map_ob (op->map, op->x, op->y); tmp != NULL; tmp = tmp->above) |
1842 | for (tmp = get_map_ob (op->map, op->x, op->y); tmp != NULL; tmp = tmp->above) |
1842 | if (!QUERY_FLAG (tmp, FLAG_IDENTIFIED) && !tmp->invisible && need_identify (tmp)) |
1843 | if (!QUERY_FLAG (tmp, FLAG_IDENTIFIED) && !tmp->invisible && need_identify (tmp)) |
1843 | { |
1844 | { |
1844 | |
|
|
1845 | identify (tmp); |
1845 | identify (tmp); |
|
|
1846 | |
1846 | if (op->type == PLAYER) |
1847 | if (op->type == PLAYER) |
1847 | { |
1848 | { |
1848 | new_draw_info_format (NDI_UNIQUE, 0, op, "On the ground is %s.", long_desc (tmp, op)); |
1849 | new_draw_info_format (NDI_UNIQUE, 0, op, "On the ground is %s.", long_desc (tmp, op)); |
|
|
1850 | |
1849 | if (tmp->msg) |
1851 | if (tmp->msg) |
1850 | { |
1852 | { |
1851 | new_draw_info (NDI_UNIQUE, 0, op, "The item has a story:"); |
1853 | new_draw_info (NDI_UNIQUE, 0, op, "The item has a story:"); |
1852 | new_draw_info (NDI_UNIQUE, 0, op, tmp->msg); |
1854 | new_draw_info (NDI_UNIQUE, 0, op, tmp->msg); |
1853 | } |
1855 | } |
|
|
1856 | |
1854 | esrv_send_item (op, tmp); |
1857 | esrv_send_item (op, tmp); |
1855 | } |
1858 | } |
|
|
1859 | |
1856 | num_ident--; |
1860 | num_ident--; |
1857 | success = 1; |
1861 | success = 1; |
1858 | if (!num_ident) |
1862 | if (!num_ident) |
1859 | break; |
1863 | break; |
1860 | } |
1864 | } |
1861 | } |
1865 | } |
|
|
1866 | |
1862 | if (!success) |
1867 | if (!success) |
1863 | new_draw_info (NDI_UNIQUE, 0, op, "You can't reach anything unidentified."); |
1868 | new_draw_info (NDI_UNIQUE, 0, op, "You can't reach anything unidentified."); |
1864 | else |
1869 | else |
1865 | { |
|
|
1866 | spell_effect (spell, op->x, op->y, op->map, op); |
1870 | spell_effect (spell, op->x, op->y, op->map, op); |
1867 | } |
1871 | |
1868 | return success; |
1872 | return success; |
1869 | } |
1873 | } |
1870 | |
|
|
1871 | |
1874 | |
1872 | int |
1875 | int |
1873 | cast_detection (object *op, object *caster, object *spell, object *skill) |
1876 | cast_detection (object *op, object *caster, object *spell, object *skill) |
1874 | { |
1877 | { |
1875 | object *tmp, *last, *god, *detect; |
1878 | object *tmp, *last, *god, *detect; |
… | |
… | |
1888 | skill = caster; |
1891 | skill = caster; |
1889 | |
1892 | |
1890 | for (x = op->x - range; x <= op->x + range; x++) |
1893 | for (x = op->x - range; x <= op->x + range; x++) |
1891 | for (y = op->y - range; y <= op->y + range; y++) |
1894 | for (y = op->y - range; y <= op->y + range; y++) |
1892 | { |
1895 | { |
1893 | |
|
|
1894 | m = op->map; |
1896 | m = op->map; |
1895 | mflags = get_map_flags (m, &m, x, y, &nx, &ny); |
1897 | mflags = get_map_flags (m, &m, x, y, &nx, &ny); |
1896 | if (mflags & P_OUT_OF_MAP) |
1898 | if (mflags & P_OUT_OF_MAP) |
1897 | continue; |
1899 | continue; |
1898 | |
1900 | |
… | |
… | |
1902 | * down - that is easier than working up. |
1904 | * down - that is easier than working up. |
1903 | */ |
1905 | */ |
1904 | |
1906 | |
1905 | for (last = NULL, tmp = get_map_ob (m, nx, ny); tmp; tmp = tmp->above) |
1907 | for (last = NULL, tmp = get_map_ob (m, nx, ny); tmp; tmp = tmp->above) |
1906 | last = tmp; |
1908 | last = tmp; |
|
|
1909 | |
1907 | /* Shouldn't happen, but if there are no objects on a space, this |
1910 | /* Shouldn't happen, but if there are no objects on a space, this |
1908 | * would happen. |
1911 | * would happen. |
1909 | */ |
1912 | */ |
1910 | if (!last) |
1913 | if (!last) |
1911 | continue; |
1914 | continue; |
… | |
… | |
1913 | done_one = 0; |
1916 | done_one = 0; |
1914 | floor = 0; |
1917 | floor = 0; |
1915 | detect = NULL; |
1918 | detect = NULL; |
1916 | for (tmp = last; tmp; tmp = tmp->below) |
1919 | for (tmp = last; tmp; tmp = tmp->below) |
1917 | { |
1920 | { |
1918 | |
|
|
1919 | /* show invisible */ |
1921 | /* show invisible */ |
1920 | if (QUERY_FLAG (spell, FLAG_MAKE_INVIS) && |
1922 | if (QUERY_FLAG (spell, FLAG_MAKE_INVIS) && |
1921 | /* Might there be other objects that we can make visibile? */ |
1923 | /* Might there be other objects that we can make visible? */ |
1922 | (tmp->invisible && (QUERY_FLAG (tmp, FLAG_MONSTER) || |
1924 | (tmp->invisible && (QUERY_FLAG (tmp, FLAG_MONSTER) || |
1923 | (tmp->type == PLAYER && !QUERY_FLAG (tmp, FLAG_WIZ)) || |
1925 | (tmp->type == PLAYER && !QUERY_FLAG (tmp, FLAG_WIZ)) || |
1924 | tmp->type == CF_HANDLE || |
1926 | tmp->type == CF_HANDLE || |
1925 | tmp->type == TRAPDOOR || tmp->type == EXIT || tmp->type == HOLE || |
1927 | tmp->type == TRAPDOOR || tmp->type == EXIT || tmp->type == HOLE || |
1926 | tmp->type == BUTTON || tmp->type == TELEPORTER || |
1928 | tmp->type == BUTTON || tmp->type == TELEPORTER || |
… | |
… | |
1933 | { |
1935 | { |
1934 | tmp->invisible = 0; |
1936 | tmp->invisible = 0; |
1935 | done_one = 1; |
1937 | done_one = 1; |
1936 | } |
1938 | } |
1937 | } |
1939 | } |
|
|
1940 | |
1938 | if (QUERY_FLAG (tmp, FLAG_IS_FLOOR)) |
1941 | if (QUERY_FLAG (tmp, FLAG_IS_FLOOR)) |
1939 | floor = 1; |
1942 | floor = 1; |
1940 | |
1943 | |
1941 | /* All detections below this point don't descend beneath the floor, |
1944 | /* All detections below this point don't descend beneath the floor, |
1942 | * so just continue on. We could be clever and look at the type of |
1945 | * so just continue on. We could be clever and look at the type of |
… | |
… | |
2211 | * monsters either. |
2214 | * monsters either. |
2212 | */ |
2215 | */ |
2213 | |
2216 | |
2214 | if (head->attacktype & AT_MAGIC && |
2217 | if (head->attacktype & AT_MAGIC && |
2215 | !(head->attacktype & AT_COUNTERSPELL) && !QUERY_FLAG (head, FLAG_MONSTER) && (op->level > head->level)) |
2218 | !(head->attacktype & AT_COUNTERSPELL) && !QUERY_FLAG (head, FLAG_MONSTER) && (op->level > head->level)) |
2216 | { |
2219 | head->destroy (); |
2217 | remove_ob (head); |
|
|
2218 | free_object (head); |
|
|
2219 | } |
|
|
2220 | else |
2220 | else |
2221 | switch (head->type) |
2221 | switch (head->type) |
2222 | { |
2222 | { |
2223 | case SPELL_EFFECT: |
2223 | case SPELL_EFFECT: |
2224 | if (op->level > head->level) |
2224 | if (op->level > head->level) |
2225 | { |
2225 | head->destroy (); |
2226 | remove_ob (head); |
2226 | |
2227 | free_object (head); |
|
|
2228 | } |
|
|
2229 | break; |
2227 | break; |
2230 | |
2228 | |
2231 | /* I really don't get this rune code that much - that |
2229 | /* I really don't get this rune code that much - that |
2232 | * random chance seems really low. |
2230 | * random chance seems really low. |
2233 | */ |
2231 | */ |
2234 | case RUNE: |
2232 | case RUNE: |
2235 | if (rndm (0, 149) == 0) |
2233 | if (rndm (0, 149) == 0) |
2236 | { |
2234 | { |
2237 | head->stats.hp--; /* weaken the rune */ |
2235 | head->stats.hp--; /* weaken the rune */ |
2238 | if (!head->stats.hp) |
2236 | if (!head->stats.hp) |
2239 | { |
2237 | head->destroy (); |
2240 | remove_ob (head); |
|
|
2241 | free_object (head); |
|
|
2242 | } |
|
|
2243 | } |
2238 | } |
2244 | break; |
2239 | break; |
2245 | } |
2240 | } |
2246 | } |
2241 | } |
2247 | } |
2242 | } |
… | |
… | |
2322 | /* exit if it's not a player using this spell. */ |
2317 | /* exit if it's not a player using this spell. */ |
2323 | if (op->type != PLAYER) |
2318 | if (op->type != PLAYER) |
2324 | return 0; |
2319 | return 0; |
2325 | |
2320 | |
2326 | /* if player already has a golem, abort */ |
2321 | /* if player already has a golem, abort */ |
2327 | if (op->contr->ranges[range_golem] != NULL && op->contr->golem_count == op->contr->ranges[range_golem]->count) |
2322 | if (op->contr->ranges[range_golem]) |
2328 | { |
2323 | { |
2329 | control_golem (op->contr->ranges[range_golem], dir); |
2324 | control_golem (op->contr->ranges[range_golem], dir); |
2330 | return 0; |
2325 | return 0; |
2331 | } |
2326 | } |
2332 | |
2327 | |
… | |
… | |
2384 | CLEAR_FLAG (tmp, FLAG_MONSTER); |
2379 | CLEAR_FLAG (tmp, FLAG_MONSTER); |
2385 | SET_FLAG (tmp, FLAG_FRIENDLY); |
2380 | SET_FLAG (tmp, FLAG_FRIENDLY); |
2386 | tmp->stats.exp = 0; |
2381 | tmp->stats.exp = 0; |
2387 | add_friendly_object (tmp); |
2382 | add_friendly_object (tmp); |
2388 | tmp->type = GOLEM; |
2383 | tmp->type = GOLEM; |
2389 | set_owner (tmp, op); |
2384 | tmp->set_owner (op); |
2390 | set_spell_skill (op, caster, spell, tmp); |
2385 | set_spell_skill (op, caster, spell, tmp); |
2391 | op->contr->ranges[range_golem] = tmp; |
2386 | op->contr->ranges[range_golem] = tmp; |
2392 | op->contr->shoottype = range_golem; |
2387 | op->contr->shoottype = range_golem; |
2393 | op->contr->golem_count = tmp->count; |
|
|
2394 | |
2388 | |
2395 | /* Give the weapon to the golem now. A bit of a hack to check the |
2389 | /* Give the weapon to the golem now. A bit of a hack to check the |
2396 | * removed flag - it should only be set if get_split_object was |
2390 | * removed flag - it should only be set if get_split_object was |
2397 | * used above. |
2391 | * used above. |
2398 | */ |
2392 | */ |
2399 | if (!QUERY_FLAG (weapon, FLAG_REMOVED)) |
2393 | if (!QUERY_FLAG (weapon, FLAG_REMOVED)) |
2400 | remove_ob (weapon); |
2394 | weapon->remove (); |
2401 | insert_ob_in_ob (weapon, tmp); |
2395 | insert_ob_in_ob (weapon, tmp); |
2402 | esrv_send_item (op, weapon); |
2396 | esrv_send_item (op, weapon); |
2403 | /* To do everything necessary to let a golem use the weapon is a pain, |
2397 | /* To do everything necessary to let a golem use the weapon is a pain, |
2404 | * so instead, just set it as equipped (otherwise, we need to update |
2398 | * so instead, just set it as equipped (otherwise, we need to update |
2405 | * body_info, skills, etc) |
2399 | * body_info, skills, etc) |
… | |
… | |
2552 | |
2546 | |
2553 | new_aura->duration = spell->duration + 10 * SP_level_duration_adjust (caster, spell); |
2547 | new_aura->duration = spell->duration + 10 * SP_level_duration_adjust (caster, spell); |
2554 | |
2548 | |
2555 | new_aura->stats.dam = spell->stats.dam + SP_level_dam_adjust (caster, spell); |
2549 | new_aura->stats.dam = spell->stats.dam + SP_level_dam_adjust (caster, spell); |
2556 | |
2550 | |
2557 | set_owner (new_aura, op); |
2551 | new_aura->set_owner (op); |
2558 | set_spell_skill (op, caster, spell, new_aura); |
2552 | set_spell_skill (op, caster, spell, new_aura); |
2559 | new_aura->attacktype = spell->attacktype; |
2553 | new_aura->attacktype = spell->attacktype; |
2560 | |
2554 | |
2561 | new_aura->level = caster_level (caster, spell); |
2555 | new_aura->level = caster_level (caster, spell); |
2562 | if (refresh) |
2556 | if (refresh) |
… | |
… | |
2588 | env = aura->env; |
2582 | env = aura->env; |
2589 | |
2583 | |
2590 | /* no matter what we've gotta remove the aura... |
2584 | /* no matter what we've gotta remove the aura... |
2591 | * we'll put it back if its time isn't up. |
2585 | * we'll put it back if its time isn't up. |
2592 | */ |
2586 | */ |
2593 | remove_ob (aura); |
2587 | aura->remove (); |
2594 | |
2588 | |
2595 | /* exit if we're out of gas */ |
2589 | /* exit if we're out of gas */ |
2596 | if (aura->duration-- < 0) |
2590 | if (aura->duration-- < 0) |
2597 | { |
2591 | { |
2598 | free_object (aura); |
2592 | aura->destroy (); |
2599 | return; |
2593 | return; |
2600 | } |
2594 | } |
2601 | |
2595 | |
2602 | /* auras only exist in inventories */ |
2596 | /* auras only exist in inventories */ |
2603 | if (env == NULL || env->map == NULL) |
2597 | if (env == NULL || env->map == NULL) |
2604 | { |
2598 | { |
2605 | free_object (aura); |
2599 | aura->destroy (); |
2606 | return; |
2600 | return; |
2607 | } |
2601 | } |
|
|
2602 | |
2608 | aura->x = env->x; |
2603 | aura->x = env->x; |
2609 | aura->y = env->y; |
2604 | aura->y = env->y; |
2610 | |
2605 | |
2611 | /* we need to jump out of the inventory for a bit |
2606 | /* we need to jump out of the inventory for a bit |
2612 | * in order to hit the map conveniently. |
2607 | * in order to hit the map conveniently. |
… | |
… | |
2639 | insert_ob_in_map (new_ob, m, aura, 0); |
2634 | insert_ob_in_map (new_ob, m, aura, 0); |
2640 | } |
2635 | } |
2641 | } |
2636 | } |
2642 | } |
2637 | } |
2643 | /* put the aura back in the player's inventory */ |
2638 | /* put the aura back in the player's inventory */ |
2644 | remove_ob (aura); |
2639 | aura->remove (); |
2645 | insert_ob_in_ob (aura, env); |
2640 | insert_ob_in_ob (aura, env); |
2646 | } |
2641 | } |
2647 | |
2642 | |
2648 | /* moves the peacemaker spell. |
2643 | /* moves the peacemaker spell. |
2649 | * op is the piece object. |
2644 | * op is the piece object. |
… | |
… | |
2673 | |
2668 | |
2674 | if (rndm (0, atk_lev - 1) > def_lev) |
2669 | if (rndm (0, atk_lev - 1) > def_lev) |
2675 | { |
2670 | { |
2676 | /* make this sucker peaceful. */ |
2671 | /* make this sucker peaceful. */ |
2677 | |
2672 | |
2678 | change_exp (get_owner (op), victim->stats.exp, op->skill, 0); |
2673 | change_exp (op->owner, victim->stats.exp, op->skill, 0); |
2679 | victim->stats.exp = 0; |
2674 | victim->stats.exp = 0; |
2680 | #if 0 |
2675 | #if 0 |
2681 | /* No idea why these were all set to zero - if something |
2676 | /* No idea why these were all set to zero - if something |
2682 | * makes this creature agressive, he should still do damage. |
2677 | * makes this creature agressive, he should still do damage. |
2683 | */ |
2678 | */ |