ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/server/spell_effect.C
(Generate patch)

Comparing deliantra/server/server/spell_effect.C (file contents):
Revision 1.12 by root, Thu Sep 14 23:13:49 2006 UTC vs.
Revision 1.25 by root, Sat Dec 23 09:58:23 2006 UTC

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);
277int 276int
278probe (object *op, object *caster, object *spell_ob, int dir) 277probe (object *op, object *caster, object *spell_ob, int dir)
279{ 278{
280 int r, mflags, maxrange; 279 int r, mflags, maxrange;
281 object *tmp; 280 object *tmp;
282 mapstruct *m; 281 maptile *m;
283 282
284 283
285 if (!dir) 284 if (!dir)
286 { 285 {
287 examine_monster (op, op); 286 examine_monster (op, op);
303 new_draw_info (NDI_UNIQUE, 0, op, "Something blocks your magic."); 302 new_draw_info (NDI_UNIQUE, 0, op, "Something blocks your magic.");
304 return 0; 303 return 0;
305 } 304 }
306 if (mflags & P_IS_ALIVE) 305 if (mflags & P_IS_ALIVE)
307 { 306 {
308 for (tmp = get_map_ob (m, x, y); tmp != NULL; tmp = tmp->above) 307 for (tmp = GET_MAP_OB (m, x, y); tmp != NULL; tmp = tmp->above)
309 if (QUERY_FLAG (tmp, FLAG_ALIVE) && (tmp->type == PLAYER || QUERY_FLAG (tmp, FLAG_MONSTER))) 308 if (QUERY_FLAG (tmp, FLAG_ALIVE) && (tmp->type == PLAYER || QUERY_FLAG (tmp, FLAG_MONSTER)))
310 { 309 {
311 new_draw_info (NDI_UNIQUE, 0, op, "You detect something."); 310 new_draw_info (NDI_UNIQUE, 0, op, "You detect something.");
312 if (tmp->head != NULL) 311 if (tmp->head != NULL)
313 tmp = tmp->head; 312 tmp = tmp->head;
422cast_earth_to_dust (object *op, object *caster, object *spell_ob) 421cast_earth_to_dust (object *op, object *caster, object *spell_ob)
423{ 422{
424 object *tmp, *next; 423 object *tmp, *next;
425 int range, i, j, mflags; 424 int range, i, j, mflags;
426 sint16 sx, sy; 425 sint16 sx, sy;
427 mapstruct *m; 426 maptile *m;
428 427
429 if (op->type != PLAYER) 428 if (op->type != PLAYER)
430 return 0; 429 return 0;
431 430
432 range = spell_ob->range + SP_level_range_adjust (caster, spell_ob); 431 range = spell_ob->range + SP_level_range_adjust (caster, spell_ob);
441 440
442 if (mflags & P_OUT_OF_MAP) 441 if (mflags & P_OUT_OF_MAP)
443 continue; 442 continue;
444 443
445 // earth to dust tears down everything that can be teared down 444 // earth to dust tears down everything that can be teared down
446 for (tmp = get_map_ob (m, sx, sy); tmp != NULL; tmp = next) 445 for (tmp = GET_MAP_OB (m, sx, sy); tmp != NULL; tmp = next)
447 { 446 {
448 next = tmp->above; 447 next = tmp->above;
449 if (QUERY_FLAG (tmp, FLAG_TEAR_DOWN)) 448 if (QUERY_FLAG (tmp, FLAG_TEAR_DOWN))
450 hit_player (tmp, 9998, op, AT_PHYSICAL, 0); 449 hit_player (tmp, 9998, op, AT_PHYSICAL, 0);
451 } 450 }
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.
558 } 555 }
559 return cast_spell (op, caster, dir, newspell, NULL); 556 return cast_spell (op, caster, dir, newspell, NULL);
560 } 557 }
561 return 1; 558 return 1;
562} 559}
563
564 560
565int 561int
566perceive_self (object *op) 562perceive_self (object *op)
567{ 563{
568 char *cp = describe_item (op, op), buf[MAX_BUF]; 564 char *cp = describe_item (op, op), buf[MAX_BUF];
641{ 637{
642 object *dummy, *force, *old_force, *tmp; 638 object *dummy, *force, *old_force, *tmp;
643 archetype *perm_portal; 639 archetype *perm_portal;
644 char portal_name[1024], portal_message[1024]; 640 char portal_name[1024], portal_message[1024];
645 sint16 exitx, exity; 641 sint16 exitx, exity;
646 mapstruct *exitmap; 642 maptile *exitmap;
647 int op_level; 643 int op_level;
648
649 644
650 /* Check to see if the map the player is currently on is a per player unique 645 /* Check to see if the map the player is currently on is a per player unique
651 * map. This can be determined in that per player unique maps have the 646 * map. This can be determined in that per player unique maps have the
652 * full pathname listed. 647 * full pathname listed.
653 */ 648 */
662 */ 657 */
663 dummy = arch_to_object (spell->other_arch); 658 dummy = arch_to_object (spell->other_arch);
664 if (dummy == NULL) 659 if (dummy == NULL)
665 { 660 {
666 new_draw_info (NDI_UNIQUE, 0, op, "Oops, program error!"); 661 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); 662 LOG (llevError, "object::create failed (force in cast_create_town_portal for %s!\n", &op->name);
668 return 0; 663 return 0;
669 } 664 }
665
670 force = check_inv_recursive (op, dummy); 666 force = check_inv_recursive (op, dummy);
671 667
672 if (force == NULL) 668 if (force == NULL)
673 { 669 {
674 /* Here we know there is no destination marked up. 670 /* Here we know there is no destination marked up.
681 EXIT_Y (dummy) = op->y; 677 EXIT_Y (dummy) = op->y;
682 insert_ob_in_ob (dummy, op); 678 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."); 679 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; 680 return 1;
685 } 681 }
686 free_object (dummy); 682
683 dummy->destroy ();
687 684
688 /* Here we know where the town portal should go to 685 /* Here we know where the town portal should go to
689 * We should kill any existing portal associated with the player. 686 * We should kill any existing portal associated with the player.
690 * Than we should create the 2 portals. 687 * Than we should create the 2 portals.
691 * For each of them, we need: 688 * For each of them, we need:
704 /* First step: killing existing town portals */ 701 /* First step: killing existing town portals */
705 dummy = get_archetype (spell->race); 702 dummy = get_archetype (spell->race);
706 if (dummy == NULL) 703 if (dummy == NULL)
707 { 704 {
708 new_draw_info (NDI_UNIQUE, 0, op, "Oops, program error!"); 705 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); 706 LOG (llevError, "object::create failed (force) in cast_create_town_portal for %s!\n", &op->name);
710 return 0; 707 return 0;
711 } 708 }
709
712 perm_portal = archetype::find (spell->slaying); 710 perm_portal = archetype::find (spell->slaying);
713 711
714 /* To kill a town portal, we go trough the player's inventory, 712 /* To kill a town portal, we go trough the player's inventory,
715 * for each marked portal in player's inventory, 713 * for each marked portal in player's inventory,
716 * -We try load the associated map (if impossible, consider the portal destructed) 714 * -We try load the associated map (if impossible, consider the portal destructed)
734 tmp = present_arch (perm_portal, exitmap, exitx, exity); 732 tmp = present_arch (perm_portal, exitmap, exitx, exity);
735 while (tmp) 733 while (tmp)
736 { 734 {
737 if (tmp->name == old_force->name) 735 if (tmp->name == old_force->name)
738 { 736 {
739 remove_ob (tmp); 737 tmp->destroy ();
740 free_object (tmp);
741 break; 738 break;
742 } 739 }
743 else 740
744 {
745 tmp = tmp->above; 741 tmp = tmp->above;
746 }
747 } 742 }
748 } 743 }
749 remove_ob (old_force); 744
750 free_object (old_force); 745 old_force->destroy ();
751 LOG (llevDebug, "\n"); 746 LOG (llevDebug, "\n");
752 } 747 }
753 free_object (dummy); 748
749 dummy->destroy ();
754 750
755 /* Creating the portals. 751 /* Creating the portals.
756 * The very first thing to do is to ensure 752 * The very first thing to do is to ensure
757 * access to the destination map. 753 * access to the destination map.
758 * If we can't, don't fizzle. Simply warn player. 754 * If we can't, don't fizzle. Simply warn player.
770 766
771 /* If we were unable to load (ex. random map deleted), warn player */ 767 /* If we were unable to load (ex. random map deleted), warn player */
772 if (exitmap == NULL) 768 if (exitmap == NULL)
773 { 769 {
774 new_draw_info (NDI_UNIQUE | NDI_NAVY, 0, op, "Something strange happens.\nYou can't remember where to go!?"); 770 new_draw_info (NDI_UNIQUE | NDI_NAVY, 0, op, "Something strange happens.\nYou can't remember where to go!?");
775 remove_ob (force); 771 force->destroy ();
776 free_object (force);
777 return 1; 772 return 1;
778 } 773 }
779 774
780 op_level = caster_level (caster, spell); 775 op_level = caster_level (caster, spell);
781 if (op_level < 15) 776 if (op_level < 15)
799 snprintf (portal_name, 1024, "%s's portal to %s", &op->name, &force->name); 794 snprintf (portal_name, 1024, "%s's portal to %s", &op->name, &force->name);
800 dummy = get_archetype (spell->slaying); /*The portal */ 795 dummy = get_archetype (spell->slaying); /*The portal */
801 if (dummy == NULL) 796 if (dummy == NULL)
802 { 797 {
803 new_draw_info (NDI_UNIQUE, 0, op, "Oops, program error!"); 798 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); 799 LOG (llevError, "object::create failed (perm_magic_portal) in cast_create_town_portal for %s!\n", &op->name);
805 return 0; 800 return 0;
806 } 801 }
802
807 EXIT_PATH (dummy) = force->name; 803 EXIT_PATH (dummy) = force->name;
808 EXIT_X (dummy) = EXIT_X (force); 804 EXIT_X (dummy) = EXIT_X (force);
809 EXIT_Y (dummy) = EXIT_Y (force); 805 EXIT_Y (dummy) = EXIT_Y (force);
810 dummy->name = dummy->name_pl = portal_name; 806 dummy->name = dummy->name_pl = portal_name;
811 dummy->msg = portal_message; 807 dummy->msg = portal_message;
818 */ 814 */
819 tmp = get_archetype (spell->race); 815 tmp = get_archetype (spell->race);
820 if (tmp == NULL) 816 if (tmp == NULL)
821 { 817 {
822 new_draw_info (NDI_UNIQUE, 0, op, "Oops, program error!"); 818 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); 819 LOG (llevError, "object::create failed (force) in cast_create_town_portal for %s!\n", &op->name);
824 return 0; 820 return 0;
825 } 821 }
822
826 tmp->race = op->map->path; 823 tmp->race = op->map->path;
827 tmp->name = portal_name; 824 tmp->name = portal_name;
828 EXIT_X (tmp) = dummy->x; 825 EXIT_X (tmp) = dummy->x;
829 EXIT_Y (tmp) = dummy->y; 826 EXIT_Y (tmp) = dummy->y;
830 insert_ob_in_ob (tmp, op); 827 insert_ob_in_ob (tmp, op);
838 snprintf (portal_name, 1024, "%s's portal to %s", &op->name, op->map->path); 835 snprintf (portal_name, 1024, "%s's portal to %s", &op->name, op->map->path);
839 dummy = get_archetype (spell->slaying); /*The portal */ 836 dummy = get_archetype (spell->slaying); /*The portal */
840 if (dummy == NULL) 837 if (dummy == NULL)
841 { 838 {
842 new_draw_info (NDI_UNIQUE, 0, op, "Oops, program error!"); 839 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); 840 LOG (llevError, "object::create failed (perm_magic_portal) in cast_create_town_portal for %s!\n", &op->name);
844 return 0; 841 return 0;
845 } 842 }
843
846 EXIT_PATH (dummy) = op->map->path; 844 EXIT_PATH (dummy) = op->map->path;
847 EXIT_X (dummy) = op->x; 845 EXIT_X (dummy) = op->x;
848 EXIT_Y (dummy) = op->y; 846 EXIT_Y (dummy) = op->y;
849 dummy->name = dummy->name_pl = portal_name; 847 dummy->name = dummy->name_pl = portal_name;
850 dummy->msg = portal_message; 848 dummy->msg = portal_message;
858 */ 856 */
859 tmp = get_archetype (spell->race); 857 tmp = get_archetype (spell->race);
860 if (tmp == NULL) 858 if (tmp == NULL)
861 { 859 {
862 new_draw_info (NDI_UNIQUE, 0, op, "Oops, program error!"); 860 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); 861 LOG (llevError, "object::create failed (force) in cast_create_town_portal for %s!\n", &op->name);
864 return 0; 862 return 0;
865 } 863 }
864
866 tmp->race = force->name; 865 tmp->race = force->name;
867 tmp->name = portal_name; 866 tmp->name = portal_name;
868 EXIT_X (tmp) = dummy->x; 867 EXIT_X (tmp) = dummy->x;
869 EXIT_Y (tmp) = dummy->y; 868 EXIT_Y (tmp) = dummy->y;
870 insert_ob_in_ob (tmp, op); 869 insert_ob_in_ob (tmp, op);
871 870
872 /* Describe the player what happened 871 /* Describe the player what happened
873 */ 872 */
874 new_draw_info (NDI_UNIQUE | NDI_NAVY, 0, op, "You see air moving and showing you the way home."); 873 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 */ 874 force->destroy ();
876 free_object (force); 875
877 return 1; 876 return 1;
878} 877}
879
880 878
881/* This creates magic walls. Really, it can create most any object, 879/* This creates magic walls. Really, it can create most any object,
882 * within some reason. 880 * within some reason.
883 */ 881 */
884
885int 882int
886magic_wall (object *op, object *caster, int dir, object *spell_ob) 883magic_wall (object *op, object *caster, int dir, object *spell_ob)
887{ 884{
888 object *tmp, *tmp2; 885 object *tmp, *tmp2;
889 int i, posblocked, negblocked, maxrange; 886 int i, posblocked, negblocked, maxrange;
890 sint16 x, y; 887 sint16 x, y;
891 mapstruct *m; 888 maptile *m;
892 const char *name; 889 const char *name;
893 archetype *at; 890 archetype *at;
894 891
895 if (!dir) 892 if (!dir)
896 { 893 {
901 else 898 else
902 { 899 {
903 x = op->x + freearr_x[dir]; 900 x = op->x + freearr_x[dir];
904 y = op->y + freearr_y[dir]; 901 y = op->y + freearr_y[dir];
905 } 902 }
903
906 m = op->map; 904 m = op->map;
907 905
908 if ((spell_ob->move_block || x != op->x || y != op->y) && 906 if ((spell_ob->move_block || x != op->x || y != op->y) &&
909 (get_map_flags (m, &m, x, y, &x, &y) & (P_OUT_OF_MAP | P_IS_ALIVE) || 907 (get_map_flags (m, &m, x, y, &x, &y) & (P_OUT_OF_MAP | P_IS_ALIVE) ||
910 ((spell_ob->move_block & GET_MAP_MOVE_BLOCK (m, x, y)) == spell_ob->move_block))) 908 ((spell_ob->move_block & GET_MAP_MOVE_BLOCK (m, x, y)) == spell_ob->move_block)))
911 { 909 {
912 new_draw_info (NDI_UNIQUE, 0, op, "Something is in the way."); 910 new_draw_info (NDI_UNIQUE, 0, op, "Something is in the way.");
913 return 0; 911 return 0;
914 } 912 }
913
915 if (spell_ob->other_arch) 914 if (spell_ob->other_arch)
916 {
917 tmp = arch_to_object (spell_ob->other_arch); 915 tmp = arch_to_object (spell_ob->other_arch);
918 }
919 else if (spell_ob->race) 916 else if (spell_ob->race)
920 { 917 {
921 char buf1[MAX_BUF]; 918 char buf1[MAX_BUF];
922 919
923 sprintf (buf1, spell_ob->race, dir); 920 sprintf (buf1, spell_ob->race, dir);
945 } 942 }
946 else if (QUERY_FLAG (tmp, FLAG_ALIVE)) 943 else if (QUERY_FLAG (tmp, FLAG_ALIVE))
947 { 944 {
948 tmp->stats.hp = spell_ob->duration + SP_level_duration_adjust (caster, spell_ob); 945 tmp->stats.hp = spell_ob->duration + SP_level_duration_adjust (caster, spell_ob);
949 tmp->stats.maxhp = tmp->stats.hp; 946 tmp->stats.maxhp = tmp->stats.hp;
950 set_owner (tmp, op);
951 set_spell_skill (op, caster, spell_ob, tmp);
952 } 947 }
948
953 if (QUERY_FLAG (spell_ob, FLAG_IS_USED_UP) || QUERY_FLAG (tmp, FLAG_IS_USED_UP)) 949 if (QUERY_FLAG (spell_ob, FLAG_IS_USED_UP) || QUERY_FLAG (tmp, FLAG_IS_USED_UP))
954 { 950 {
955 tmp->stats.food = spell_ob->duration + SP_level_duration_adjust (caster, spell_ob); 951 tmp->stats.food = spell_ob->duration + SP_level_duration_adjust (caster, spell_ob);
956 SET_FLAG (tmp, FLAG_IS_USED_UP); 952 SET_FLAG (tmp, FLAG_IS_USED_UP);
957 } 953 }
954
958 if (QUERY_FLAG (spell_ob, FLAG_TEAR_DOWN)) 955 if (QUERY_FLAG (spell_ob, FLAG_TEAR_DOWN))
959 { 956 {
960 tmp->stats.hp = spell_ob->stats.dam + SP_level_dam_adjust (caster, spell_ob); 957 tmp->stats.hp = spell_ob->stats.dam + SP_level_dam_adjust (caster, spell_ob);
961 tmp->stats.maxhp = tmp->stats.hp; 958 tmp->stats.maxhp = tmp->stats.hp;
962 SET_FLAG (tmp, FLAG_TEAR_DOWN); 959 SET_FLAG (tmp, FLAG_TEAR_DOWN);
963 SET_FLAG (tmp, FLAG_ALIVE); 960 SET_FLAG (tmp, FLAG_ALIVE);
964 } 961 }
965 962
966 /* This can't really hurt - if the object doesn't kill anything, 963 /* This can't really hurt - if the object doesn't kill anything,
967 * these fields just won't be used. 964 * these fields just won't be used. Do not set the owner for
965 * earthwalls, though, so they survive restarts.
968 */ 966 */
969 set_owner (tmp, op); 967 if (tmp->type != EARTHWALL) //TODO
968 tmp->set_owner (op);
969
970 set_spell_skill (op, caster, spell_ob, tmp); 970 set_spell_skill (op, caster, spell_ob, tmp);
971 tmp->x = x; 971 tmp->x = x;
972 tmp->y = y; 972 tmp->y = y;
973 tmp->level = caster_level (caster, spell_ob) / 2; 973 tmp->level = caster_level (caster, spell_ob) / 2;
974 974
976 if ((tmp = insert_ob_in_map (tmp, m, op, 0)) == NULL) 976 if ((tmp = insert_ob_in_map (tmp, m, op, 0)) == NULL)
977 { 977 {
978 new_draw_info_format (NDI_UNIQUE, 0, op, "Something destroys your %s", name); 978 new_draw_info_format (NDI_UNIQUE, 0, op, "Something destroys your %s", name);
979 return 0; 979 return 0;
980 } 980 }
981
981 /* If this is a spellcasting wall, need to insert the spell object */ 982 /* If this is a spellcasting wall, need to insert the spell object */
982 if (tmp->other_arch && tmp->other_arch->clone.type == SPELL) 983 if (tmp->other_arch && tmp->other_arch->clone.type == SPELL)
983 insert_ob_in_ob (arch_to_object (tmp->other_arch), tmp); 984 insert_ob_in_ob (arch_to_object (tmp->other_arch), tmp);
984 985
985 /* This code causes the wall to extend some distance in 986 /* This code causes the wall to extend some distance in
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);
1046int 1045int
1047dimension_door (object *op, object *caster, object *spob, int dir) 1046dimension_door (object *op, object *caster, object *spob, int dir)
1048{ 1047{
1049 uint32 dist, maxdist; 1048 uint32 dist, maxdist;
1050 int mflags; 1049 int mflags;
1051 mapstruct *m; 1050 maptile *m;
1052 sint16 sx, sy; 1051 sint16 sx, sy;
1053 1052
1054 if (op->type != PLAYER) 1053 if (op->type != PLAYER)
1055 return 0; 1054 return 0;
1056 1055
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
1433 force->stats.ac = spell_ob->stats.ac; 1432 force->stats.ac = spell_ob->stats.ac;
1434 force->attacktype = spell_ob->attacktype; 1433 force->attacktype = spell_ob->attacktype;
1435 1434
1436 insert_ob_in_ob (force, tmp); 1435 insert_ob_in_ob (force, tmp);
1437 change_abil (tmp, force); /* Mostly to display any messages */ 1436 change_abil (tmp, force); /* Mostly to display any messages */
1438 fix_player (tmp); 1437 tmp->update_stats ();
1439 return 1; 1438 return 1;
1440} 1439}
1441 1440
1442/* This used to be part of cast_change_ability, but it really didn't make 1441/* This used to be part of cast_change_ability, but it really didn't make
1443 * a lot of sense, since most of the values it derives are from the god 1442 * a lot of sense, since most of the values it derives are from the god
1542 force->stats.wc = spell_ob->stats.wc; 1541 force->stats.wc = spell_ob->stats.wc;
1543 force->stats.ac = spell_ob->stats.ac; 1542 force->stats.ac = spell_ob->stats.ac;
1544 1543
1545 change_abil (tmp, force); /* Mostly to display any messages */ 1544 change_abil (tmp, force); /* Mostly to display any messages */
1546 insert_ob_in_ob (force, tmp); 1545 insert_ob_in_ob (force, tmp);
1547 fix_player (tmp); 1546 tmp->update_stats ();
1548 return 1; 1547 return 1;
1549} 1548}
1550 1549
1551 1550
1552 1551
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
1631static void 1629static void
1632update_map (object *op, mapstruct *m, int small_nuggets, int large_nuggets, int x, int y) 1630update_map (object *op, maptile *m, int small_nuggets, int large_nuggets, int x, int y)
1633{ 1631{
1634 object *tmp; 1632 object *tmp;
1635 int flag = 0; 1633 int flag = 0;
1636 1634
1637 /* Put any nuggets below the player, but we can only pass this 1635 /* Put any nuggets below the player, but we can only pass this
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 }
1664alchemy (object *op, object *caster, object *spell_ob) 1661alchemy (object *op, object *caster, object *spell_ob)
1665{ 1662{
1666 int x, y, weight = 0, weight_max, large_nuggets, small_nuggets, mflags; 1663 int x, y, weight = 0, weight_max, large_nuggets, small_nuggets, mflags;
1667 sint16 nx, ny; 1664 sint16 nx, ny;
1668 object *next, *tmp; 1665 object *next, *tmp;
1669 mapstruct *mp; 1666 maptile *mp;
1670 1667
1671 if (op->type != PLAYER) 1668 if (op->type != PLAYER)
1672 return 0; 1669 return 0;
1673 1670
1674 /* Put a maximum weight of items that can be alchemied. Limits the power 1671 /* Put a maximum weight of items that can be alchemied. Limits the power
1701 continue; 1698 continue;
1702 1699
1703 small_nuggets = 0; 1700 small_nuggets = 0;
1704 large_nuggets = 0; 1701 large_nuggets = 0;
1705 1702
1706 for (tmp = get_map_ob (mp, nx, ny); tmp != NULL; tmp = next) 1703 for (tmp = GET_MAP_OB (mp, nx, ny); tmp != NULL; tmp = next)
1707 { 1704 {
1708 next = tmp->above; 1705 next = tmp->above;
1709 if (tmp->weight > 0 && !QUERY_FLAG (tmp, FLAG_NO_PICK) && 1706 if (tmp->weight > 0 && !QUERY_FLAG (tmp, FLAG_NO_PICK) &&
1710 !QUERY_FLAG (tmp, FLAG_ALIVE) && !QUERY_FLAG (tmp, FLAG_IS_CAULDRON)) 1707 !QUERY_FLAG (tmp, FLAG_ALIVE) && !QUERY_FLAG (tmp, FLAG_IS_CAULDRON))
1711 { 1708 {
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->ns->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
1872int 1875int
1873cast_detection (object *op, object *caster, object *spell, object *skill) 1876cast_detection (object *op, object *caster, object *spell, object *skill)
1874{ 1877{
1875 object *tmp, *last, *god, *detect; 1878 object *tmp, *last, *god, *detect;
1876 int done_one, range, mflags, floor, level; 1879 int done_one, range, mflags, floor, level;
1877 sint16 x, y, nx, ny; 1880 sint16 x, y, nx, ny;
1878 mapstruct *m; 1881 maptile *m;
1879 1882
1880 /* We precompute some values here so that we don't have to keep 1883 /* We precompute some values here so that we don't have to keep
1881 * doing it over and over again. 1884 * doing it over and over again.
1882 */ 1885 */
1883 god = find_god (determine_god (op)); 1886 god = find_god (determine_god (op));
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
1900 * floor. But this is not true for show invisible. 1902 * floor. But this is not true for show invisible.
1901 * Basically, we just go and find the top object and work 1903 * Basically, we just go and find the top object and work
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
2101int 2104int
2102cast_transfer (object *op, object *caster, object *spell, int dir) 2105cast_transfer (object *op, object *caster, object *spell, int dir)
2103{ 2106{
2104 object *plyr = NULL; 2107 object *plyr = NULL;
2105 sint16 x, y; 2108 sint16 x, y;
2106 mapstruct *m; 2109 maptile *m;
2107 int mflags; 2110 int mflags;
2108 2111
2109 m = op->map; 2112 m = op->map;
2110 x = op->x + freearr_x[dir]; 2113 x = op->x + freearr_x[dir];
2111 y = op->y + freearr_y[dir]; 2114 y = op->y + freearr_y[dir];
2112 2115
2113 mflags = get_map_flags (m, &m, x, y, &x, &y); 2116 mflags = get_map_flags (m, &m, x, y, &x, &y);
2114 2117
2115 if (!(mflags & P_OUT_OF_MAP) && mflags & P_IS_ALIVE) 2118 if (!(mflags & P_OUT_OF_MAP) && mflags & P_IS_ALIVE)
2116 { 2119 {
2117 for (plyr = get_map_ob (m, x, y); plyr != NULL; plyr = plyr->above) 2120 for (plyr = GET_MAP_OB (m, x, y); plyr != NULL; plyr = plyr->above)
2118 if (plyr != op && QUERY_FLAG (plyr, FLAG_ALIVE)) 2121 if (plyr != op && QUERY_FLAG (plyr, FLAG_ALIVE))
2119 break; 2122 break;
2120 } 2123 }
2121 2124
2122 2125
2123 /* If we did not find a player in the specified direction, transfer 2126 /* If we did not find a player in the specified direction, transfer
2124 * to anyone on top of us. This is used for the rune of transference mostly. 2127 * to anyone on top of us. This is used for the rune of transference mostly.
2125 */ 2128 */
2126 if (plyr == NULL) 2129 if (plyr == NULL)
2127 for (plyr = get_map_ob (op->map, op->x, op->y); plyr != NULL; plyr = plyr->above) 2130 for (plyr = GET_MAP_OB (op->map, op->x, op->y); plyr != NULL; plyr = plyr->above)
2128 if (plyr != op && QUERY_FLAG (plyr, FLAG_ALIVE)) 2131 if (plyr != op && QUERY_FLAG (plyr, FLAG_ALIVE))
2129 break; 2132 break;
2130 2133
2131 if (!plyr) 2134 if (!plyr)
2132 { 2135 {
2177void 2180void
2178counterspell (object *op, int dir) 2181counterspell (object *op, int dir)
2179{ 2182{
2180 object *tmp, *head, *next; 2183 object *tmp, *head, *next;
2181 int mflags; 2184 int mflags;
2182 mapstruct *m; 2185 maptile *m;
2183 sint16 sx, sy; 2186 sint16 sx, sy;
2184 2187
2185 sx = op->x + freearr_x[dir]; 2188 sx = op->x + freearr_x[dir];
2186 sy = op->y + freearr_y[dir]; 2189 sy = op->y + freearr_y[dir];
2187 m = op->map; 2190 m = op->map;
2188 mflags = get_map_flags (m, &m, sx, sy, &sx, &sy); 2191 mflags = get_map_flags (m, &m, sx, sy, &sx, &sy);
2189 if (mflags & P_OUT_OF_MAP) 2192 if (mflags & P_OUT_OF_MAP)
2190 return; 2193 return;
2191 2194
2192 for (tmp = get_map_ob (m, sx, sy); tmp != NULL; tmp = next) 2195 for (tmp = GET_MAP_OB (m, sx, sy); tmp != NULL; tmp = next)
2193 { 2196 {
2194 next = tmp->above; 2197 next = tmp->above;
2195 2198
2196 /* Need to look at the head object - otherwise, if tmp 2199 /* Need to look at the head object - otherwise, if tmp
2197 * points to a monster, we don't have all the necessary 2200 * points to a monster, we don't have all the necessary
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}
2308{ 2303{
2309 object *weapon, *tmp; 2304 object *weapon, *tmp;
2310 char buf[MAX_BUF]; 2305 char buf[MAX_BUF];
2311 int a, i; 2306 int a, i;
2312 sint16 x, y; 2307 sint16 x, y;
2313 mapstruct *m; 2308 maptile *m;
2314 materialtype_t *mt; 2309 materialtype_t *mt;
2315 2310
2316 if (!spell->other_arch) 2311 if (!spell->other_arch)
2317 { 2312 {
2318 new_draw_info (NDI_UNIQUE, 0, op, "Oops, program error!"); 2313 new_draw_info (NDI_UNIQUE, 0, op, "Oops, program error!");
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)
2406 */ 2400 */
2407 SET_FLAG (tmp, FLAG_USE_WEAPON); 2401 SET_FLAG (tmp, FLAG_USE_WEAPON);
2408 SET_FLAG (weapon, FLAG_APPLIED); 2402 SET_FLAG (weapon, FLAG_APPLIED);
2409 fix_player (tmp); 2403 tmp->update_stats ();
2410 2404
2411 /* There used to be 'odd' code that basically seemed to take the absolute 2405 /* There used to be 'odd' code that basically seemed to take the absolute
2412 * value of the weapon->magic an use that. IMO, that doesn't make sense - 2406 * value of the weapon->magic an use that. IMO, that doesn't make sense -
2413 * if you're using a crappy weapon, it shouldn't be as good. 2407 * if you're using a crappy weapon, it shouldn't be as good.
2414 */ 2408 */
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)
2580void 2574void
2581move_aura (object *aura) 2575move_aura (object *aura)
2582{ 2576{
2583 int i, mflags; 2577 int i, mflags;
2584 object *env; 2578 object *env;
2585 mapstruct *m; 2579 maptile *m;
2586 2580
2587 /* auras belong in inventories */ 2581 /* auras belong in inventories */
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.
2652void 2647void
2653move_peacemaker (object *op) 2648move_peacemaker (object *op)
2654{ 2649{
2655 object *tmp; 2650 object *tmp;
2656 2651
2657 for (tmp = get_map_ob (op->map, op->x, op->y); tmp != NULL; tmp = tmp->above) 2652 for (tmp = GET_MAP_OB (op->map, op->x, op->y); tmp != NULL; tmp = tmp->above)
2658 { 2653 {
2659 int atk_lev, def_lev; 2654 int atk_lev, def_lev;
2660 object *victim = tmp; 2655 object *victim = tmp;
2661 2656
2662 if (tmp->head) 2657 if (tmp->head)
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 */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines