… | |
… | |
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); |
… | |
… | |
466 | 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))) |
467 | 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."); |
468 | else |
467 | else |
469 | enter_exit (op, wor); |
468 | enter_exit (op, wor); |
470 | |
469 | |
471 | remove_ob (wor); |
470 | wor->destroy (); |
472 | free_object (wor); |
|
|
473 | } |
471 | } |
474 | |
472 | |
475 | /* Word of recall causes the player to return 'home'. |
473 | /* Word of recall causes the player to return 'home'. |
476 | * 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 |
477 | * time delay effect. |
475 | * time delay effect. |
… | |
… | |
661 | */ |
659 | */ |
662 | dummy = arch_to_object (spell->other_arch); |
660 | dummy = arch_to_object (spell->other_arch); |
663 | if (dummy == NULL) |
661 | if (dummy == NULL) |
664 | { |
662 | { |
665 | new_draw_info (NDI_UNIQUE, 0, op, "Oops, program error!"); |
663 | new_draw_info (NDI_UNIQUE, 0, op, "Oops, program error!"); |
666 | 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); |
667 | return 0; |
665 | return 0; |
668 | } |
666 | } |
|
|
667 | |
669 | force = check_inv_recursive (op, dummy); |
668 | force = check_inv_recursive (op, dummy); |
670 | |
669 | |
671 | if (force == NULL) |
670 | if (force == NULL) |
672 | { |
671 | { |
673 | /* Here we know there is no destination marked up. |
672 | /* Here we know there is no destination marked up. |
… | |
… | |
680 | EXIT_Y (dummy) = op->y; |
679 | EXIT_Y (dummy) = op->y; |
681 | insert_ob_in_ob (dummy, op); |
680 | insert_ob_in_ob (dummy, op); |
682 | 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."); |
683 | return 1; |
682 | return 1; |
684 | } |
683 | } |
685 | free_object (dummy); |
684 | |
|
|
685 | dummy->destroy (); |
686 | |
686 | |
687 | /* Here we know where the town portal should go to |
687 | /* Here we know where the town portal should go to |
688 | * We should kill any existing portal associated with the player. |
688 | * We should kill any existing portal associated with the player. |
689 | * Than we should create the 2 portals. |
689 | * Than we should create the 2 portals. |
690 | * For each of them, we need: |
690 | * For each of them, we need: |
… | |
… | |
703 | /* First step: killing existing town portals */ |
703 | /* First step: killing existing town portals */ |
704 | dummy = get_archetype (spell->race); |
704 | dummy = get_archetype (spell->race); |
705 | if (dummy == NULL) |
705 | if (dummy == NULL) |
706 | { |
706 | { |
707 | new_draw_info (NDI_UNIQUE, 0, op, "Oops, program error!"); |
707 | new_draw_info (NDI_UNIQUE, 0, op, "Oops, program error!"); |
708 | 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); |
709 | return 0; |
709 | return 0; |
710 | } |
710 | } |
|
|
711 | |
711 | perm_portal = archetype::find (spell->slaying); |
712 | perm_portal = archetype::find (spell->slaying); |
712 | |
713 | |
713 | /* 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, |
714 | * for each marked portal in player's inventory, |
715 | * for each marked portal in player's inventory, |
715 | * -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) |
… | |
… | |
733 | tmp = present_arch (perm_portal, exitmap, exitx, exity); |
734 | tmp = present_arch (perm_portal, exitmap, exitx, exity); |
734 | while (tmp) |
735 | while (tmp) |
735 | { |
736 | { |
736 | if (tmp->name == old_force->name) |
737 | if (tmp->name == old_force->name) |
737 | { |
738 | { |
738 | remove_ob (tmp); |
739 | tmp->destroy (); |
739 | free_object (tmp); |
|
|
740 | break; |
740 | break; |
741 | } |
741 | } |
742 | else |
742 | |
743 | { |
|
|
744 | tmp = tmp->above; |
743 | tmp = tmp->above; |
745 | } |
|
|
746 | } |
744 | } |
747 | } |
745 | } |
748 | remove_ob (old_force); |
746 | |
749 | free_object (old_force); |
747 | old_force->destroy (); |
750 | LOG (llevDebug, "\n"); |
748 | LOG (llevDebug, "\n"); |
751 | } |
749 | } |
752 | free_object (dummy); |
750 | |
|
|
751 | dummy->destroy (); |
753 | |
752 | |
754 | /* Creating the portals. |
753 | /* Creating the portals. |
755 | * The very first thing to do is to ensure |
754 | * The very first thing to do is to ensure |
756 | * access to the destination map. |
755 | * access to the destination map. |
757 | * If we can't, don't fizzle. Simply warn player. |
756 | * If we can't, don't fizzle. Simply warn player. |
… | |
… | |
769 | |
768 | |
770 | /* 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 */ |
771 | if (exitmap == NULL) |
770 | if (exitmap == NULL) |
772 | { |
771 | { |
773 | 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!?"); |
774 | remove_ob (force); |
773 | force->destroy (); |
775 | free_object (force); |
|
|
776 | return 1; |
774 | return 1; |
777 | } |
775 | } |
778 | |
776 | |
779 | op_level = caster_level (caster, spell); |
777 | op_level = caster_level (caster, spell); |
780 | if (op_level < 15) |
778 | if (op_level < 15) |
… | |
… | |
798 | 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); |
799 | dummy = get_archetype (spell->slaying); /*The portal */ |
797 | dummy = get_archetype (spell->slaying); /*The portal */ |
800 | if (dummy == NULL) |
798 | if (dummy == NULL) |
801 | { |
799 | { |
802 | new_draw_info (NDI_UNIQUE, 0, op, "Oops, program error!"); |
800 | new_draw_info (NDI_UNIQUE, 0, op, "Oops, program error!"); |
803 | 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); |
804 | return 0; |
802 | return 0; |
805 | } |
803 | } |
|
|
804 | |
806 | EXIT_PATH (dummy) = force->name; |
805 | EXIT_PATH (dummy) = force->name; |
807 | EXIT_X (dummy) = EXIT_X (force); |
806 | EXIT_X (dummy) = EXIT_X (force); |
808 | EXIT_Y (dummy) = EXIT_Y (force); |
807 | EXIT_Y (dummy) = EXIT_Y (force); |
809 | dummy->name = dummy->name_pl = portal_name; |
808 | dummy->name = dummy->name_pl = portal_name; |
810 | dummy->msg = portal_message; |
809 | dummy->msg = portal_message; |
… | |
… | |
817 | */ |
816 | */ |
818 | tmp = get_archetype (spell->race); |
817 | tmp = get_archetype (spell->race); |
819 | if (tmp == NULL) |
818 | if (tmp == NULL) |
820 | { |
819 | { |
821 | new_draw_info (NDI_UNIQUE, 0, op, "Oops, program error!"); |
820 | new_draw_info (NDI_UNIQUE, 0, op, "Oops, program error!"); |
822 | 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); |
823 | return 0; |
822 | return 0; |
824 | } |
823 | } |
|
|
824 | |
825 | tmp->race = op->map->path; |
825 | tmp->race = op->map->path; |
826 | tmp->name = portal_name; |
826 | tmp->name = portal_name; |
827 | EXIT_X (tmp) = dummy->x; |
827 | EXIT_X (tmp) = dummy->x; |
828 | EXIT_Y (tmp) = dummy->y; |
828 | EXIT_Y (tmp) = dummy->y; |
829 | insert_ob_in_ob (tmp, op); |
829 | insert_ob_in_ob (tmp, op); |
… | |
… | |
837 | 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); |
838 | dummy = get_archetype (spell->slaying); /*The portal */ |
838 | dummy = get_archetype (spell->slaying); /*The portal */ |
839 | if (dummy == NULL) |
839 | if (dummy == NULL) |
840 | { |
840 | { |
841 | new_draw_info (NDI_UNIQUE, 0, op, "Oops, program error!"); |
841 | new_draw_info (NDI_UNIQUE, 0, op, "Oops, program error!"); |
842 | 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); |
843 | return 0; |
843 | return 0; |
844 | } |
844 | } |
|
|
845 | |
845 | EXIT_PATH (dummy) = op->map->path; |
846 | EXIT_PATH (dummy) = op->map->path; |
846 | EXIT_X (dummy) = op->x; |
847 | EXIT_X (dummy) = op->x; |
847 | EXIT_Y (dummy) = op->y; |
848 | EXIT_Y (dummy) = op->y; |
848 | dummy->name = dummy->name_pl = portal_name; |
849 | dummy->name = dummy->name_pl = portal_name; |
849 | dummy->msg = portal_message; |
850 | dummy->msg = portal_message; |
… | |
… | |
857 | */ |
858 | */ |
858 | tmp = get_archetype (spell->race); |
859 | tmp = get_archetype (spell->race); |
859 | if (tmp == NULL) |
860 | if (tmp == NULL) |
860 | { |
861 | { |
861 | new_draw_info (NDI_UNIQUE, 0, op, "Oops, program error!"); |
862 | new_draw_info (NDI_UNIQUE, 0, op, "Oops, program error!"); |
862 | 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); |
863 | return 0; |
864 | return 0; |
864 | } |
865 | } |
|
|
866 | |
865 | tmp->race = force->name; |
867 | tmp->race = force->name; |
866 | tmp->name = portal_name; |
868 | tmp->name = portal_name; |
867 | EXIT_X (tmp) = dummy->x; |
869 | EXIT_X (tmp) = dummy->x; |
868 | EXIT_Y (tmp) = dummy->y; |
870 | EXIT_Y (tmp) = dummy->y; |
869 | insert_ob_in_ob (tmp, op); |
871 | insert_ob_in_ob (tmp, op); |
870 | |
872 | |
871 | /* Describe the player what happened |
873 | /* Describe the player what happened |
872 | */ |
874 | */ |
873 | 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."); |
874 | remove_ob (force); /* Delete the force inside the player */ |
876 | force->destroy (); |
875 | free_object (force); |
877 | |
876 | return 1; |
878 | return 1; |
877 | } |
879 | } |
878 | |
880 | |
879 | |
881 | |
880 | /* This creates magic walls. Really, it can create most any object, |
882 | /* This creates magic walls. Really, it can create most any object, |
… | |
… | |
944 | } |
946 | } |
945 | else if (QUERY_FLAG (tmp, FLAG_ALIVE)) |
947 | else if (QUERY_FLAG (tmp, FLAG_ALIVE)) |
946 | { |
948 | { |
947 | 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); |
948 | tmp->stats.maxhp = tmp->stats.hp; |
950 | tmp->stats.maxhp = tmp->stats.hp; |
949 | set_owner (tmp, op); |
951 | tmp->set_owner (op); |
950 | set_spell_skill (op, caster, spell_ob, tmp); |
952 | set_spell_skill (op, caster, spell_ob, tmp); |
951 | } |
953 | } |
952 | 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)) |
953 | { |
955 | { |
954 | 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); |
… | |
… | |
963 | } |
965 | } |
964 | |
966 | |
965 | /* 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, |
966 | * these fields just won't be used. |
968 | * these fields just won't be used. |
967 | */ |
969 | */ |
968 | set_owner (tmp, op); |
970 | tmp->set_owner (op); |
969 | set_spell_skill (op, caster, spell_ob, tmp); |
971 | set_spell_skill (op, caster, spell_ob, tmp); |
970 | tmp->x = x; |
972 | tmp->x = x; |
971 | tmp->y = y; |
973 | tmp->y = y; |
972 | tmp->level = caster_level (caster, spell_ob) / 2; |
974 | tmp->level = caster_level (caster, spell_ob) / 2; |
973 | |
975 | |
… | |
… | |
1002 | m = tmp->map; |
1004 | m = tmp->map; |
1003 | |
1005 | |
1004 | 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)) && |
1005 | ((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) |
1006 | { |
1008 | { |
1007 | tmp2 = get_object (); |
1009 | tmp2 = tmp->clone (); |
1008 | copy_object (tmp, tmp2); |
|
|
1009 | tmp2->x = x; |
1010 | tmp2->x = x; |
1010 | tmp2->y = y; |
1011 | tmp2->y = y; |
1011 | insert_ob_in_map (tmp2, m, op, 0); |
1012 | insert_ob_in_map (tmp2, m, op, 0); |
1012 | /* 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 */ |
1013 | if (tmp2->other_arch && tmp2->other_arch->clone.type == SPELL) |
1014 | if (tmp2->other_arch && tmp2->other_arch->clone.type == SPELL) |
… | |
… | |
1022 | m = tmp->map; |
1023 | m = tmp->map; |
1023 | |
1024 | |
1024 | 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)) && |
1025 | ((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) |
1026 | { |
1027 | { |
1027 | tmp2 = get_object (); |
1028 | tmp2 = tmp->clone (); |
1028 | copy_object (tmp, tmp2); |
|
|
1029 | tmp2->x = x; |
1029 | tmp2->x = x; |
1030 | tmp2->y = y; |
1030 | tmp2->y = y; |
1031 | insert_ob_in_map (tmp2, m, op, 0); |
1031 | insert_ob_in_map (tmp2, m, op, 0); |
1032 | if (tmp2->other_arch && tmp2->other_arch->clone.type == SPELL) |
1032 | if (tmp2->other_arch && tmp2->other_arch->clone.type == SPELL) |
1033 | insert_ob_in_ob (arch_to_object (tmp2->other_arch), tmp2); |
1033 | insert_ob_in_ob (arch_to_object (tmp2->other_arch), tmp2); |
… | |
… | |
1145 | return 0; |
1145 | return 0; |
1146 | } |
1146 | } |
1147 | } |
1147 | } |
1148 | |
1148 | |
1149 | /* Actually move the player now */ |
1149 | /* Actually move the player now */ |
1150 | remove_ob (op); |
1150 | op->remove (); |
1151 | op->x += freearr_x[dir] * dist; |
1151 | op->x += freearr_x[dir] * dist; |
1152 | op->y += freearr_y[dir] * dist; |
1152 | op->y += freearr_y[dir] * dist; |
1153 | 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) |
1154 | return 1; |
1154 | return 1; |
1155 | |
1155 | |
… | |
… | |
1621 | *small_nuggets -= large->value / small->value; |
1621 | *small_nuggets -= large->value / small->value; |
1622 | if (*small_nuggets && large->value % small->value) |
1622 | if (*small_nuggets && large->value % small->value) |
1623 | (*small_nuggets)--; |
1623 | (*small_nuggets)--; |
1624 | } |
1624 | } |
1625 | weight += obj->weight; |
1625 | weight += obj->weight; |
1626 | remove_ob (obj); |
1626 | obj->destroy (); |
1627 | free_object (obj); |
|
|
1628 | } |
1627 | } |
1629 | |
1628 | |
1630 | static void |
1629 | static void |
1631 | 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) |
1632 | { |
1631 | { |
… | |
… | |
1639 | if (x == op->x && y == op->y && op->map == m) |
1638 | if (x == op->x && y == op->y && op->map == m) |
1640 | flag = INS_BELOW_ORIGINATOR; |
1639 | flag = INS_BELOW_ORIGINATOR; |
1641 | |
1640 | |
1642 | if (small_nuggets) |
1641 | if (small_nuggets) |
1643 | { |
1642 | { |
1644 | tmp = get_object (); |
1643 | tmp = small->clone (); |
1645 | copy_object (small, tmp); |
|
|
1646 | tmp->nrof = small_nuggets; |
1644 | tmp->nrof = small_nuggets; |
1647 | tmp->x = x; |
1645 | tmp->x = x; |
1648 | tmp->y = y; |
1646 | tmp->y = y; |
1649 | insert_ob_in_map (tmp, m, op, flag); |
1647 | insert_ob_in_map (tmp, m, op, flag); |
1650 | } |
1648 | } |
|
|
1649 | |
1651 | if (large_nuggets) |
1650 | if (large_nuggets) |
1652 | { |
1651 | { |
1653 | tmp = get_object (); |
1652 | tmp = large->clone (); |
1654 | copy_object (large, tmp); |
|
|
1655 | tmp->nrof = large_nuggets; |
1653 | tmp->nrof = large_nuggets; |
1656 | tmp->x = x; |
1654 | tmp->x = x; |
1657 | tmp->y = y; |
1655 | tmp->y = y; |
1658 | insert_ob_in_map (tmp, m, op, flag); |
1656 | insert_ob_in_map (tmp, m, op, flag); |
1659 | } |
1657 | } |
… | |
… | |
1724 | alchemy_object (tmp, &small_nuggets, &large_nuggets, &weight); |
1722 | alchemy_object (tmp, &small_nuggets, &large_nuggets, &weight); |
1725 | |
1723 | |
1726 | if (weight > weight_max) |
1724 | if (weight > weight_max) |
1727 | { |
1725 | { |
1728 | update_map (op, mp, small_nuggets, large_nuggets, nx, ny); |
1726 | update_map (op, mp, small_nuggets, large_nuggets, nx, ny); |
1729 | free_object (large); |
1727 | large->destroy (); |
1730 | free_object (small); |
1728 | small->destroy (); |
1731 | return 1; |
1729 | return 1; |
1732 | } |
1730 | } |
1733 | } /* is alchemable object */ |
1731 | } /* is alchemable object */ |
1734 | } /* process all objects on this space */ |
1732 | } /* process all objects on this space */ |
1735 | |
1733 | |
… | |
… | |
1738 | * with this spell. |
1736 | * with this spell. |
1739 | */ |
1737 | */ |
1740 | update_map (op, mp, small_nuggets, large_nuggets, nx, ny); |
1738 | update_map (op, mp, small_nuggets, large_nuggets, nx, ny); |
1741 | } |
1739 | } |
1742 | } |
1740 | } |
1743 | free_object (large); |
1741 | |
1744 | free_object (small); |
1742 | large->destroy (); |
|
|
1743 | small->destroy (); |
1745 | /* 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, |
1746 | * it is redrawn properly. |
1745 | * it is redrawn properly. |
1747 | */ |
1746 | */ |
1748 | op->contr->socket.look_position = 0; |
1747 | op->contr->socket->look_position = 0; |
1749 | return 1; |
1748 | return 1; |
1750 | } |
1749 | } |
1751 | |
1750 | |
1752 | |
1751 | |
1753 | /* This function removes the cursed/damned status on equipped |
1752 | /* This function removes the cursed/damned status on equipped |
… | |
… | |
2210 | * monsters either. |
2209 | * monsters either. |
2211 | */ |
2210 | */ |
2212 | |
2211 | |
2213 | if (head->attacktype & AT_MAGIC && |
2212 | if (head->attacktype & AT_MAGIC && |
2214 | !(head->attacktype & AT_COUNTERSPELL) && !QUERY_FLAG (head, FLAG_MONSTER) && (op->level > head->level)) |
2213 | !(head->attacktype & AT_COUNTERSPELL) && !QUERY_FLAG (head, FLAG_MONSTER) && (op->level > head->level)) |
2215 | { |
2214 | head->destroy (); |
2216 | remove_ob (head); |
|
|
2217 | free_object (head); |
|
|
2218 | } |
|
|
2219 | else |
2215 | else |
2220 | switch (head->type) |
2216 | switch (head->type) |
2221 | { |
2217 | { |
2222 | case SPELL_EFFECT: |
2218 | case SPELL_EFFECT: |
2223 | if (op->level > head->level) |
2219 | if (op->level > head->level) |
2224 | { |
2220 | head->destroy (); |
2225 | remove_ob (head); |
2221 | |
2226 | free_object (head); |
|
|
2227 | } |
|
|
2228 | break; |
2222 | break; |
2229 | |
2223 | |
2230 | /* I really don't get this rune code that much - that |
2224 | /* I really don't get this rune code that much - that |
2231 | * random chance seems really low. |
2225 | * random chance seems really low. |
2232 | */ |
2226 | */ |
2233 | case RUNE: |
2227 | case RUNE: |
2234 | if (rndm (0, 149) == 0) |
2228 | if (rndm (0, 149) == 0) |
2235 | { |
2229 | { |
2236 | head->stats.hp--; /* weaken the rune */ |
2230 | head->stats.hp--; /* weaken the rune */ |
2237 | if (!head->stats.hp) |
2231 | if (!head->stats.hp) |
2238 | { |
2232 | head->destroy (); |
2239 | remove_ob (head); |
|
|
2240 | free_object (head); |
|
|
2241 | } |
|
|
2242 | } |
2233 | } |
2243 | break; |
2234 | break; |
2244 | } |
2235 | } |
2245 | } |
2236 | } |
2246 | } |
2237 | } |
… | |
… | |
2321 | /* exit if it's not a player using this spell. */ |
2312 | /* exit if it's not a player using this spell. */ |
2322 | if (op->type != PLAYER) |
2313 | if (op->type != PLAYER) |
2323 | return 0; |
2314 | return 0; |
2324 | |
2315 | |
2325 | /* if player already has a golem, abort */ |
2316 | /* if player already has a golem, abort */ |
2326 | if (op->contr->ranges[range_golem] != NULL && op->contr->golem_count == op->contr->ranges[range_golem]->count) |
2317 | if (op->contr->ranges[range_golem]) |
2327 | { |
2318 | { |
2328 | control_golem (op->contr->ranges[range_golem], dir); |
2319 | control_golem (op->contr->ranges[range_golem], dir); |
2329 | return 0; |
2320 | return 0; |
2330 | } |
2321 | } |
2331 | |
2322 | |
… | |
… | |
2383 | CLEAR_FLAG (tmp, FLAG_MONSTER); |
2374 | CLEAR_FLAG (tmp, FLAG_MONSTER); |
2384 | SET_FLAG (tmp, FLAG_FRIENDLY); |
2375 | SET_FLAG (tmp, FLAG_FRIENDLY); |
2385 | tmp->stats.exp = 0; |
2376 | tmp->stats.exp = 0; |
2386 | add_friendly_object (tmp); |
2377 | add_friendly_object (tmp); |
2387 | tmp->type = GOLEM; |
2378 | tmp->type = GOLEM; |
2388 | set_owner (tmp, op); |
2379 | tmp->set_owner (op); |
2389 | set_spell_skill (op, caster, spell, tmp); |
2380 | set_spell_skill (op, caster, spell, tmp); |
2390 | op->contr->ranges[range_golem] = tmp; |
2381 | op->contr->ranges[range_golem] = tmp; |
2391 | op->contr->shoottype = range_golem; |
2382 | op->contr->shoottype = range_golem; |
2392 | op->contr->golem_count = tmp->count; |
|
|
2393 | |
2383 | |
2394 | /* Give the weapon to the golem now. A bit of a hack to check the |
2384 | /* Give the weapon to the golem now. A bit of a hack to check the |
2395 | * removed flag - it should only be set if get_split_object was |
2385 | * removed flag - it should only be set if get_split_object was |
2396 | * used above. |
2386 | * used above. |
2397 | */ |
2387 | */ |
2398 | if (!QUERY_FLAG (weapon, FLAG_REMOVED)) |
2388 | if (!QUERY_FLAG (weapon, FLAG_REMOVED)) |
2399 | remove_ob (weapon); |
2389 | weapon->remove (); |
2400 | insert_ob_in_ob (weapon, tmp); |
2390 | insert_ob_in_ob (weapon, tmp); |
2401 | esrv_send_item (op, weapon); |
2391 | esrv_send_item (op, weapon); |
2402 | /* To do everything necessary to let a golem use the weapon is a pain, |
2392 | /* To do everything necessary to let a golem use the weapon is a pain, |
2403 | * so instead, just set it as equipped (otherwise, we need to update |
2393 | * so instead, just set it as equipped (otherwise, we need to update |
2404 | * body_info, skills, etc) |
2394 | * body_info, skills, etc) |
… | |
… | |
2551 | |
2541 | |
2552 | new_aura->duration = spell->duration + 10 * SP_level_duration_adjust (caster, spell); |
2542 | new_aura->duration = spell->duration + 10 * SP_level_duration_adjust (caster, spell); |
2553 | |
2543 | |
2554 | new_aura->stats.dam = spell->stats.dam + SP_level_dam_adjust (caster, spell); |
2544 | new_aura->stats.dam = spell->stats.dam + SP_level_dam_adjust (caster, spell); |
2555 | |
2545 | |
2556 | set_owner (new_aura, op); |
2546 | new_aura->set_owner (op); |
2557 | set_spell_skill (op, caster, spell, new_aura); |
2547 | set_spell_skill (op, caster, spell, new_aura); |
2558 | new_aura->attacktype = spell->attacktype; |
2548 | new_aura->attacktype = spell->attacktype; |
2559 | |
2549 | |
2560 | new_aura->level = caster_level (caster, spell); |
2550 | new_aura->level = caster_level (caster, spell); |
2561 | if (refresh) |
2551 | if (refresh) |
… | |
… | |
2587 | env = aura->env; |
2577 | env = aura->env; |
2588 | |
2578 | |
2589 | /* no matter what we've gotta remove the aura... |
2579 | /* no matter what we've gotta remove the aura... |
2590 | * we'll put it back if its time isn't up. |
2580 | * we'll put it back if its time isn't up. |
2591 | */ |
2581 | */ |
2592 | remove_ob (aura); |
2582 | aura->remove (); |
2593 | |
2583 | |
2594 | /* exit if we're out of gas */ |
2584 | /* exit if we're out of gas */ |
2595 | if (aura->duration-- < 0) |
2585 | if (aura->duration-- < 0) |
2596 | { |
2586 | { |
2597 | free_object (aura); |
2587 | aura->destroy (); |
2598 | return; |
2588 | return; |
2599 | } |
2589 | } |
2600 | |
2590 | |
2601 | /* auras only exist in inventories */ |
2591 | /* auras only exist in inventories */ |
2602 | if (env == NULL || env->map == NULL) |
2592 | if (env == NULL || env->map == NULL) |
2603 | { |
2593 | { |
2604 | free_object (aura); |
2594 | aura->destroy (); |
2605 | return; |
2595 | return; |
2606 | } |
2596 | } |
|
|
2597 | |
2607 | aura->x = env->x; |
2598 | aura->x = env->x; |
2608 | aura->y = env->y; |
2599 | aura->y = env->y; |
2609 | |
2600 | |
2610 | /* we need to jump out of the inventory for a bit |
2601 | /* we need to jump out of the inventory for a bit |
2611 | * in order to hit the map conveniently. |
2602 | * in order to hit the map conveniently. |
… | |
… | |
2638 | insert_ob_in_map (new_ob, m, aura, 0); |
2629 | insert_ob_in_map (new_ob, m, aura, 0); |
2639 | } |
2630 | } |
2640 | } |
2631 | } |
2641 | } |
2632 | } |
2642 | /* put the aura back in the player's inventory */ |
2633 | /* put the aura back in the player's inventory */ |
2643 | remove_ob (aura); |
2634 | aura->remove (); |
2644 | insert_ob_in_ob (aura, env); |
2635 | insert_ob_in_ob (aura, env); |
2645 | } |
2636 | } |
2646 | |
2637 | |
2647 | /* moves the peacemaker spell. |
2638 | /* moves the peacemaker spell. |
2648 | * op is the piece object. |
2639 | * op is the piece object. |
… | |
… | |
2672 | |
2663 | |
2673 | if (rndm (0, atk_lev - 1) > def_lev) |
2664 | if (rndm (0, atk_lev - 1) > def_lev) |
2674 | { |
2665 | { |
2675 | /* make this sucker peaceful. */ |
2666 | /* make this sucker peaceful. */ |
2676 | |
2667 | |
2677 | change_exp (get_owner (op), victim->stats.exp, op->skill, 0); |
2668 | change_exp (op->owner, victim->stats.exp, op->skill, 0); |
2678 | victim->stats.exp = 0; |
2669 | victim->stats.exp = 0; |
2679 | #if 0 |
2670 | #if 0 |
2680 | /* No idea why these were all set to zero - if something |
2671 | /* No idea why these were all set to zero - if something |
2681 | * makes this creature agressive, he should still do damage. |
2672 | * makes this creature agressive, he should still do damage. |
2682 | */ |
2673 | */ |