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.16 by root, Tue Dec 12 20:53:03 2006 UTC vs.
Revision 1.17 by root, Tue Dec 12 21:39:57 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 wand->remove ();
80 wand->destroy (0); 79 wand->destroy ();
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 missile->destroy (0); 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 missile->destroy (0); 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 wor->remove ();
472 wor->destroy (0); 470 wor->destroy ();
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 }
669 force = check_inv_recursive (op, dummy); 667 force = check_inv_recursive (op, dummy);
670 668
671 if (force == NULL) 669 if (force == NULL)
680 EXIT_Y (dummy) = op->y; 678 EXIT_Y (dummy) = op->y;
681 insert_ob_in_ob (dummy, op); 679 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."); 680 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; 681 return 1;
684 } 682 }
683
685 dummy->destroy (0); 684 dummy->destroy ();
686 685
687 /* Here we know where the town portal should go to 686 /* Here we know where the town portal should go to
688 * We should kill any existing portal associated with the player. 687 * We should kill any existing portal associated with the player.
689 * Than we should create the 2 portals. 688 * Than we should create the 2 portals.
690 * For each of them, we need: 689 * For each of them, we need:
703 /* First step: killing existing town portals */ 702 /* First step: killing existing town portals */
704 dummy = get_archetype (spell->race); 703 dummy = get_archetype (spell->race);
705 if (dummy == NULL) 704 if (dummy == NULL)
706 { 705 {
707 new_draw_info (NDI_UNIQUE, 0, op, "Oops, program error!"); 706 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); 707 LOG (llevError, "object::create failed (force) in cast_create_town_portal for %s!\n", &op->name);
709 return 0; 708 return 0;
710 } 709 }
711 perm_portal = archetype::find (spell->slaying); 710 perm_portal = archetype::find (spell->slaying);
712 711
713 /* 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,
733 tmp = present_arch (perm_portal, exitmap, exitx, exity); 732 tmp = present_arch (perm_portal, exitmap, exitx, exity);
734 while (tmp) 733 while (tmp)
735 { 734 {
736 if (tmp->name == old_force->name) 735 if (tmp->name == old_force->name)
737 { 736 {
738 tmp->remove ();
739 tmp->destroy (0); 737 tmp->destroy ();
740 break; 738 break;
741 } 739 }
742 else 740
743 {
744 tmp = tmp->above; 741 tmp = tmp->above;
745 }
746 } 742 }
747 } 743 }
748 old_force->remove (); 744
749 old_force->destroy (0); 745 old_force->destroy ();
750 LOG (llevDebug, "\n"); 746 LOG (llevDebug, "\n");
751 } 747 }
748
752 dummy->destroy (0); 749 dummy->destroy ();
753 750
754 /* Creating the portals. 751 /* Creating the portals.
755 * The very first thing to do is to ensure 752 * The very first thing to do is to ensure
756 * access to the destination map. 753 * access to the destination map.
757 * If we can't, don't fizzle. Simply warn player. 754 * If we can't, don't fizzle. Simply warn player.
769 766
770 /* 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 */
771 if (exitmap == NULL) 768 if (exitmap == NULL)
772 { 769 {
773 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!?");
774 force->remove ();
775 force->destroy (0); 771 force->destroy ();
776 return 1; 772 return 1;
777 } 773 }
778 774
779 op_level = caster_level (caster, spell); 775 op_level = caster_level (caster, spell);
780 if (op_level < 15) 776 if (op_level < 15)
798 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);
799 dummy = get_archetype (spell->slaying); /*The portal */ 795 dummy = get_archetype (spell->slaying); /*The portal */
800 if (dummy == NULL) 796 if (dummy == NULL)
801 { 797 {
802 new_draw_info (NDI_UNIQUE, 0, op, "Oops, program error!"); 798 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); 799 LOG (llevError, "object::create failed (perm_magic_portal) in cast_create_town_portal for %s!\n", &op->name);
804 return 0; 800 return 0;
805 } 801 }
806 EXIT_PATH (dummy) = force->name; 802 EXIT_PATH (dummy) = force->name;
807 EXIT_X (dummy) = EXIT_X (force); 803 EXIT_X (dummy) = EXIT_X (force);
808 EXIT_Y (dummy) = EXIT_Y (force); 804 EXIT_Y (dummy) = EXIT_Y (force);
817 */ 813 */
818 tmp = get_archetype (spell->race); 814 tmp = get_archetype (spell->race);
819 if (tmp == NULL) 815 if (tmp == NULL)
820 { 816 {
821 new_draw_info (NDI_UNIQUE, 0, op, "Oops, program error!"); 817 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); 818 LOG (llevError, "object::create failed (force) in cast_create_town_portal for %s!\n", &op->name);
823 return 0; 819 return 0;
824 } 820 }
825 tmp->race = op->map->path; 821 tmp->race = op->map->path;
826 tmp->name = portal_name; 822 tmp->name = portal_name;
827 EXIT_X (tmp) = dummy->x; 823 EXIT_X (tmp) = dummy->x;
837 snprintf (portal_name, 1024, "%s's portal to %s", &op->name, op->map->path); 833 snprintf (portal_name, 1024, "%s's portal to %s", &op->name, op->map->path);
838 dummy = get_archetype (spell->slaying); /*The portal */ 834 dummy = get_archetype (spell->slaying); /*The portal */
839 if (dummy == NULL) 835 if (dummy == NULL)
840 { 836 {
841 new_draw_info (NDI_UNIQUE, 0, op, "Oops, program error!"); 837 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); 838 LOG (llevError, "object::create failed (perm_magic_portal) in cast_create_town_portal for %s!\n", &op->name);
843 return 0; 839 return 0;
844 } 840 }
845 EXIT_PATH (dummy) = op->map->path; 841 EXIT_PATH (dummy) = op->map->path;
846 EXIT_X (dummy) = op->x; 842 EXIT_X (dummy) = op->x;
847 EXIT_Y (dummy) = op->y; 843 EXIT_Y (dummy) = op->y;
857 */ 853 */
858 tmp = get_archetype (spell->race); 854 tmp = get_archetype (spell->race);
859 if (tmp == NULL) 855 if (tmp == NULL)
860 { 856 {
861 new_draw_info (NDI_UNIQUE, 0, op, "Oops, program error!"); 857 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); 858 LOG (llevError, "object::create failed (force) in cast_create_town_portal for %s!\n", &op->name);
863 return 0; 859 return 0;
864 } 860 }
865 tmp->race = force->name; 861 tmp->race = force->name;
866 tmp->name = portal_name; 862 tmp->name = portal_name;
867 EXIT_X (tmp) = dummy->x; 863 EXIT_X (tmp) = dummy->x;
869 insert_ob_in_ob (tmp, op); 865 insert_ob_in_ob (tmp, op);
870 866
871 /* Describe the player what happened 867 /* Describe the player what happened
872 */ 868 */
873 new_draw_info (NDI_UNIQUE | NDI_NAVY, 0, op, "You see air moving and showing you the way home."); 869 new_draw_info (NDI_UNIQUE | NDI_NAVY, 0, op, "You see air moving and showing you the way home.");
874 force->remove (); /* Delete the force inside the player */
875 force->destroy (0); 870 force->destroy ();
871
876 return 1; 872 return 1;
877} 873}
878 874
879 875
880/* This creates magic walls. Really, it can create most any object, 876/* This creates magic walls. Really, it can create most any object,
1002 m = tmp->map; 998 m = tmp->map;
1003 999
1004 if (!(get_map_flags (m, &m, x, y, &x, &y) & (P_OUT_OF_MAP | P_IS_ALIVE)) && 1000 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) 1001 ((spell_ob->move_block & GET_MAP_MOVE_BLOCK (m, x, y)) != spell_ob->move_block) && !posblocked)
1006 { 1002 {
1007 tmp2 = get_object (); 1003 tmp2 = object::create ();
1008 copy_object (tmp, tmp2); 1004 tmp->copy_to (tmp2);
1009 tmp2->x = x; 1005 tmp2->x = x;
1010 tmp2->y = y; 1006 tmp2->y = y;
1011 insert_ob_in_map (tmp2, m, op, 0); 1007 insert_ob_in_map (tmp2, m, op, 0);
1012 /* If this is a spellcasting wall, need to insert the spell object */ 1008 /* If this is a spellcasting wall, need to insert the spell object */
1013 if (tmp2->other_arch && tmp2->other_arch->clone.type == SPELL) 1009 if (tmp2->other_arch && tmp2->other_arch->clone.type == SPELL)
1022 m = tmp->map; 1018 m = tmp->map;
1023 1019
1024 if (!(get_map_flags (m, &m, x, y, &x, &y) & (P_OUT_OF_MAP | P_IS_ALIVE)) && 1020 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) 1021 ((spell_ob->move_block & GET_MAP_MOVE_BLOCK (m, x, y)) != spell_ob->move_block) && !negblocked)
1026 { 1022 {
1027 tmp2 = get_object (); 1023 tmp2 = object::create ();
1028 copy_object (tmp, tmp2); 1024 tmp->copy_to (tmp2);
1029 tmp2->x = x; 1025 tmp2->x = x;
1030 tmp2->y = y; 1026 tmp2->y = y;
1031 insert_ob_in_map (tmp2, m, op, 0); 1027 insert_ob_in_map (tmp2, m, op, 0);
1032 if (tmp2->other_arch && tmp2->other_arch->clone.type == SPELL) 1028 if (tmp2->other_arch && tmp2->other_arch->clone.type == SPELL)
1033 insert_ob_in_ob (arch_to_object (tmp2->other_arch), tmp2); 1029 insert_ob_in_ob (arch_to_object (tmp2->other_arch), tmp2);
1621 *small_nuggets -= large->value / small->value; 1617 *small_nuggets -= large->value / small->value;
1622 if (*small_nuggets && large->value % small->value) 1618 if (*small_nuggets && large->value % small->value)
1623 (*small_nuggets)--; 1619 (*small_nuggets)--;
1624 } 1620 }
1625 weight += obj->weight; 1621 weight += obj->weight;
1626 obj->remove ();
1627 obj->destroy (0); 1622 obj->destroy ();
1628} 1623}
1629 1624
1630static void 1625static void
1631update_map (object *op, maptile *m, int small_nuggets, int large_nuggets, int x, int y) 1626update_map (object *op, maptile *m, int small_nuggets, int large_nuggets, int x, int y)
1632{ 1627{
1639 if (x == op->x && y == op->y && op->map == m) 1634 if (x == op->x && y == op->y && op->map == m)
1640 flag = INS_BELOW_ORIGINATOR; 1635 flag = INS_BELOW_ORIGINATOR;
1641 1636
1642 if (small_nuggets) 1637 if (small_nuggets)
1643 { 1638 {
1644 tmp = get_object (); 1639 tmp = object::create ();
1645 copy_object (small, tmp); 1640 small->copy_to (tmp);
1646 tmp->nrof = small_nuggets; 1641 tmp->nrof = small_nuggets;
1647 tmp->x = x; 1642 tmp->x = x;
1648 tmp->y = y; 1643 tmp->y = y;
1649 insert_ob_in_map (tmp, m, op, flag); 1644 insert_ob_in_map (tmp, m, op, flag);
1650 } 1645 }
1651 if (large_nuggets) 1646 if (large_nuggets)
1652 { 1647 {
1653 tmp = get_object (); 1648 tmp = object::create ();
1654 copy_object (large, tmp); 1649 large->copy_to (tmp);
1655 tmp->nrof = large_nuggets; 1650 tmp->nrof = large_nuggets;
1656 tmp->x = x; 1651 tmp->x = x;
1657 tmp->y = y; 1652 tmp->y = y;
1658 insert_ob_in_map (tmp, m, op, flag); 1653 insert_ob_in_map (tmp, m, op, flag);
1659 } 1654 }
1724 alchemy_object (tmp, &small_nuggets, &large_nuggets, &weight); 1719 alchemy_object (tmp, &small_nuggets, &large_nuggets, &weight);
1725 1720
1726 if (weight > weight_max) 1721 if (weight > weight_max)
1727 { 1722 {
1728 update_map (op, mp, small_nuggets, large_nuggets, nx, ny); 1723 update_map (op, mp, small_nuggets, large_nuggets, nx, ny);
1729 large->destroy (0); 1724 large->destroy ();
1730 small->destroy (0); 1725 small->destroy ();
1731 return 1; 1726 return 1;
1732 } 1727 }
1733 } /* is alchemable object */ 1728 } /* is alchemable object */
1734 } /* process all objects on this space */ 1729 } /* process all objects on this space */
1735 1730
1738 * with this spell. 1733 * with this spell.
1739 */ 1734 */
1740 update_map (op, mp, small_nuggets, large_nuggets, nx, ny); 1735 update_map (op, mp, small_nuggets, large_nuggets, nx, ny);
1741 } 1736 }
1742 } 1737 }
1738
1743 large->destroy (0); 1739 large->destroy ();
1744 small->destroy (0); 1740 small->destroy ();
1745 /* reset this so that if player standing on a big pile of stuff, 1741 /* reset this so that if player standing on a big pile of stuff,
1746 * it is redrawn properly. 1742 * it is redrawn properly.
1747 */ 1743 */
1748 op->contr->socket.look_position = 0; 1744 op->contr->socket.look_position = 0;
1749 return 1; 1745 return 1;
2210 * monsters either. 2206 * monsters either.
2211 */ 2207 */
2212 2208
2213 if (head->attacktype & AT_MAGIC && 2209 if (head->attacktype & AT_MAGIC &&
2214 !(head->attacktype & AT_COUNTERSPELL) && !QUERY_FLAG (head, FLAG_MONSTER) && (op->level > head->level)) 2210 !(head->attacktype & AT_COUNTERSPELL) && !QUERY_FLAG (head, FLAG_MONSTER) && (op->level > head->level))
2215 {
2216 head->remove ();
2217 head->destroy (0); 2211 head->destroy ();
2218 }
2219 else 2212 else
2220 switch (head->type) 2213 switch (head->type)
2221 { 2214 {
2222 case SPELL_EFFECT: 2215 case SPELL_EFFECT:
2223 if (op->level > head->level) 2216 if (op->level > head->level)
2224 {
2225 head->remove ();
2226 head->destroy (0); 2217 head->destroy ();
2227 } 2218
2228 break; 2219 break;
2229 2220
2230 /* I really don't get this rune code that much - that 2221 /* I really don't get this rune code that much - that
2231 * random chance seems really low. 2222 * random chance seems really low.
2232 */ 2223 */
2233 case RUNE: 2224 case RUNE:
2234 if (rndm (0, 149) == 0) 2225 if (rndm (0, 149) == 0)
2235 { 2226 {
2236 head->stats.hp--; /* weaken the rune */ 2227 head->stats.hp--; /* weaken the rune */
2237 if (!head->stats.hp) 2228 if (!head->stats.hp)
2238 {
2239 head->remove ();
2240 head->destroy (0); 2229 head->destroy ();
2241 }
2242 } 2230 }
2243 break; 2231 break;
2244 } 2232 }
2245 } 2233 }
2246} 2234}
2591 aura->remove (); 2579 aura->remove ();
2592 2580
2593 /* exit if we're out of gas */ 2581 /* exit if we're out of gas */
2594 if (aura->duration-- < 0) 2582 if (aura->duration-- < 0)
2595 { 2583 {
2596 aura->destroy (0); 2584 aura->destroy ();
2597 return; 2585 return;
2598 } 2586 }
2599 2587
2600 /* auras only exist in inventories */ 2588 /* auras only exist in inventories */
2601 if (env == NULL || env->map == NULL) 2589 if (env == NULL || env->map == NULL)
2602 { 2590 {
2603 aura->destroy (0); 2591 aura->destroy ();
2604 return; 2592 return;
2605 } 2593 }
2594
2606 aura->x = env->x; 2595 aura->x = env->x;
2607 aura->y = env->y; 2596 aura->y = env->y;
2608 2597
2609 /* we need to jump out of the inventory for a bit 2598 /* we need to jump out of the inventory for a bit
2610 * in order to hit the map conveniently. 2599 * in order to hit the map conveniently.

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines