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.103 by elmex, Mon Jun 8 08:57:34 2009 UTC vs.
Revision 1.117 by root, Sat Jan 30 23:30:26 2010 UTC

3 * 3 *
4 * Copyright (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team 4 * Copyright (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
5 * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team 5 * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team
6 * Copyright (©) 1992,2007 Frank Tore Johansen 6 * Copyright (©) 1992,2007 Frank Tore Johansen
7 * 7 *
8 * Deliantra is free software: you can redistribute it and/or modify 8 * Deliantra is free software: you can redistribute it and/or modify it under
9 * it under the terms of the GNU General Public License as published by 9 * the terms of the Affero GNU General Public License as published by the
10 * the Free Software Foundation, either version 3 of the License, or 10 * Free Software Foundation, either version 3 of the License, or (at your
11 * (at your option) any later version. 11 * option) any later version.
12 * 12 *
13 * This program is distributed in the hope that it will be useful, 13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 * 17 *
18 * You should have received a copy of the GNU General Public License 18 * You should have received a copy of the Affero GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>. 19 * and the GNU General Public License along with this program. If not, see
20 * <http://www.gnu.org/licenses/>.
20 * 21 *
21 * The authors can be reached via e-mail to <support@deliantra.net> 22 * The authors can be reached via e-mail to <support@deliantra.net>
22 */ 23 */
23 24
24#include <global.h> 25#include <global.h>
71 if (!(random_roll (0, 3, op, PREFER_HIGH))) 72 if (!(random_roll (0, 3, op, PREFER_HIGH)))
72 { 73 {
73 new_draw_info_format (NDI_UNIQUE, 0, op, "The %s vibrates violently, then explodes!", query_name (wand)); 74 new_draw_info_format (NDI_UNIQUE, 0, op, "The %s vibrates violently, then explodes!", query_name (wand));
74 op->play_sound (sound_find ("ob_explode")); 75 op->play_sound (sound_find ("ob_explode"));
75 wand->destroy (); 76 wand->destroy ();
76 tmp = get_archetype ("fireball"); 77 tmp = get_archetype (shstr_fireball);
77 tmp->stats.dam = (spell_ob->stats.dam + SP_level_dam_adjust (caster, spell_ob)) / 10; 78 tmp->stats.dam = (spell_ob->stats.dam + SP_level_dam_adjust (caster, spell_ob)) / 10;
78 79
79 if (!tmp->stats.dam) 80 if (!tmp->stats.dam)
80 tmp->stats.dam = 1; 81 tmp->stats.dam = 1;
81 82
122 * The # of arrows created also goes up with level, so if a 30th level mage 123 * The # of arrows created also goes up with level, so if a 30th level mage
123 * wants LOTS of arrows, and doesn't care what the plus is he could 124 * wants LOTS of arrows, and doesn't care what the plus is he could
124 * create nonnmagic arrows, or even -1, etc... 125 * create nonnmagic arrows, or even -1, etc...
125 */ 126 */
126int 127int
127cast_create_missile (object *op, object *caster, object *spell, int dir, const char *stringarg) 128cast_create_missile (object *op, object *caster, object *spell, int dir, const char *spellparam)
128{ 129{
129 int bonus_plus = 0; 130 int bonus_plus = 0;
130 const char *missile_name = "arrow"; 131 const char *missile_name = "arrow";
131 132
132 for (object *tmp = op->inv; tmp; tmp = tmp->below) 133 for (object *tmp = op->inv; tmp; tmp = tmp->below)
143 return 0; 144 return 0;
144 } 145 }
145 146
146 object *missile = missile_arch->instance (); 147 object *missile = missile_arch->instance ();
147 148
148 if (stringarg) 149 if (spellparam)
149 { 150 {
150 /* If it starts with a letter, presume it is a description */ 151 /* If it starts with a letter, presume it is a description */
151 if (isalpha (*stringarg)) 152 if (isalpha (*spellparam))
152 { 153 {
153 artifact *al = find_artifactlist (missile->type)->items; 154 artifact *al = find_artifactlist (missile->type)->items;
154 155
155 for (; al; al = al->next) 156 for (; al; al = al->next)
156 if (!strcasecmp (al->item->name, stringarg)) 157 if (!strcasecmp (al->item->name, spellparam))
157 break; 158 break;
158 159
159 if (!al) 160 if (!al)
160 { 161 {
161 missile->destroy (); 162 missile->destroy ();
162 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, spellparam);
163 return 0; 164 return 0;
164 } 165 }
165 166
166 if (al->item->slaying) 167 if (al->item->slaying)
167 { 168 {
168 missile->destroy (); 169 missile->destroy ();
169 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, spellparam);
170 return 0; 171 return 0;
171 } 172 }
172 173
173 give_artifact_abilities (missile, al->item); 174 give_artifact_abilities (missile, al->item);
174 /* These special arrows cost something extra. Don't have them also be magical - 175 /* These special arrows cost something extra. Don't have them also be magical -
176 * the parsing of having to do both plus and type. 177 * the parsing of having to do both plus and type.
177 */ 178 */
178 bonus_plus = 1 + (al->item->value / 5); 179 bonus_plus = 1 + (al->item->value / 5);
179 missile_plus = 0; 180 missile_plus = 0;
180 } 181 }
181 else if (atoi (stringarg) < missile_plus) 182 else if (atoi (spellparam) < missile_plus)
182 missile_plus = atoi (stringarg); 183 missile_plus = atoi (spellparam);
183 } 184 }
184 185
185 missile_plus = clamp (missile_plus, -4, 4); 186 missile_plus = clamp (missile_plus, -4, 4);
186 187
187 missile->nrof = spell->duration + SP_level_duration_adjust (caster, spell); 188 missile->nrof = spell->duration + SP_level_duration_adjust (caster, spell);
202 return 1; 203 return 1;
203} 204}
204 205
205 206
206/* allows the choice of what sort of food object to make. 207/* allows the choice of what sort of food object to make.
207 * If stringarg is NULL, it will create food dependent on level --PeterM*/ 208 * If spellparam is NULL, it will create food dependent on level --PeterM*/
208int 209int
209cast_create_food (object *op, object *caster, object *spell_ob, int dir, const char *stringarg) 210cast_create_food (object *op, object *caster, object *spell_ob, int dir, const char *spellparam)
210{ 211{
211 int food_value; 212 int food_value;
212 archetype *at = NULL; 213 archetype *at = NULL;
213 object *new_op; 214 object *new_op;
214 215
215 food_value = spell_ob->stats.food + 50 * SP_level_duration_adjust (caster, spell_ob); 216 food_value = spell_ob->stats.food + 50 * SP_level_duration_adjust (caster, spell_ob);
216 217
217 if (stringarg) 218 if (spellparam)
218 { 219 {
219 at = find_archetype_by_object_type_name (FOOD, stringarg); 220 at = find_archetype_by_object_type_name (FOOD, spellparam);
220 if (at == NULL) 221 if (at == NULL)
221 at = find_archetype_by_object_type_name (DRINK, stringarg); 222 at = find_archetype_by_object_type_name (DRINK, spellparam);
222 if (at == NULL || at->stats.food > food_value) 223 if (at == NULL || at->stats.food > food_value)
223 stringarg = NULL; 224 spellparam = NULL;
224 } 225 }
225 226
226 if (!stringarg) 227 if (!spellparam)
227 { 228 {
228 archetype *at_tmp; 229 archetype *at_tmp;
229 230
230 /* We try to find the archetype with the maximum food value. 231 /* We try to find the archetype with the maximum food value.
231 * This removes the dependancy of hard coded food values in this 232 * This removes the dependancy of hard coded food values in this
261 new_draw_info (NDI_UNIQUE, 0, op, "You don't have enough experience to create any food."); 262 new_draw_info (NDI_UNIQUE, 0, op, "You don't have enough experience to create any food.");
262 return 0; 263 return 0;
263 } 264 }
264 265
265 food_value /= at->stats.food; 266 food_value /= at->stats.food;
266 new_op = arch_to_object (at); 267 new_op = at->instance ();
267 new_op->nrof = food_value; 268 new_op->nrof = food_value;
268 269
269 new_op->value = 0; 270 new_op->value = 0;
270 if (new_op->nrof < 1) 271 if (new_op->nrof < 1)
271 new_op->nrof = 1; 272 new_op->nrof = 1;
564 565
565int 566int
566perceive_self (object *op) 567perceive_self (object *op)
567{ 568{
568 const char *cp = describe_item (op, op); 569 const char *cp = describe_item (op, op);
569 archetype *at = archetype::find (ARCH_DEPLETION); 570 archetype *at = archetype::find (shstr_depletion);
570 571
571 dynbuf_text &buf = msg_dynbuf; buf.clear (); 572 dynbuf_text &buf = msg_dynbuf; buf.clear ();
572 573
573 if (!op->is_player ()) 574 if (!op->is_player ())
574 return 0; 575 return 0;
593 for (int i = 0; i < NUM_STATS; i++) 594 for (int i = 0; i < NUM_STATS; i++)
594 if (tmp->stats.stat (i) < 0) 595 if (tmp->stats.stat (i) < 0)
595 buf.printf (" - Your %s is depleted by %d.\n", statname[i], -tmp->stats.stat (i)); 596 buf.printf (" - Your %s is depleted by %d.\n", statname[i], -tmp->stats.stat (i));
596 } 597 }
597 598
598 if (is_dragon_pl (op)) 599 if (op->is_dragon ())
599 /* now grab the 'dragon_ability'-force from the player's inventory */ 600 /* now grab the 'dragon_ability'-force from the player's inventory */
600 for (tmp = op->inv; tmp; tmp = tmp->below) 601 for (tmp = op->inv; tmp; tmp = tmp->below)
601 { 602 {
602 if (tmp->type == FORCE && tmp->arch->archname == shstr_dragon_ability_force) 603 if (tmp->type == FORCE && tmp->arch->archname == shstr_dragon_ability_force)
603 { 604 {
649 new_draw_info (NDI_UNIQUE, 0, op, "Something is in the way."); 650 new_draw_info (NDI_UNIQUE, 0, op, "Something is in the way.");
650 return 0; 651 return 0;
651 } 652 }
652 653
653 if (spell_ob->other_arch) 654 if (spell_ob->other_arch)
654 tmp = arch_to_object (spell_ob->other_arch); 655 tmp = spell_ob->other_arch->instance ();
655 else if (spell_ob->race) 656 else if (spell_ob->race)
656 { 657 {
657 char buf1[MAX_BUF]; 658 char buf1[MAX_BUF];
658 659
659 sprintf (buf1, spell_ob->race, dir); 660 sprintf (buf1, spell_ob->race, dir);
663 LOG (llevError, "summon_wall: Unable to find archetype %s\n", buf1); 664 LOG (llevError, "summon_wall: Unable to find archetype %s\n", buf1);
664 new_draw_info (NDI_UNIQUE, 0, op, "This spell is broken."); 665 new_draw_info (NDI_UNIQUE, 0, op, "This spell is broken.");
665 return 0; 666 return 0;
666 } 667 }
667 668
668 tmp = arch_to_object (at); 669 tmp = at->instance ();
669 } 670 }
670 else 671 else
671 { 672 {
672 LOG (llevError, "magic_wall: spell %s lacks other_arch\n", &spell_ob->name); 673 LOG (llevError, "magic_wall: spell %s lacks other_arch\n", &spell_ob->name);
673 return 0; 674 return 0;
717 return 0; 718 return 0;
718 } 719 }
719 720
720 /* If this is a spellcasting wall, need to insert the spell object */ 721 /* If this is a spellcasting wall, need to insert the spell object */
721 if (tmp->other_arch && tmp->other_arch->type == SPELL) 722 if (tmp->other_arch && tmp->other_arch->type == SPELL)
722 insert_ob_in_ob (arch_to_object (tmp->other_arch), tmp); 723 insert_ob_in_ob (tmp->other_arch->instance (), tmp);
723 724
724 /* This code causes the wall to extend some distance in 725 /* This code causes the wall to extend some distance in
725 * each direction, or until an obstruction is encountered. 726 * each direction, or until an obstruction is encountered.
726 * posblocked and negblocked help determine how far the 727 * posblocked and negblocked help determine how far the
727 * created wall can extend, it won't go extend through 728 * created wall can extend, it won't go extend through
747 object *tmp2 = tmp->clone (); 748 object *tmp2 = tmp->clone ();
748 m->insert (tmp2, x, y, op); 749 m->insert (tmp2, x, y, op);
749 750
750 /* If this is a spellcasting wall, need to insert the spell object */ 751 /* If this is a spellcasting wall, need to insert the spell object */
751 if (tmp2->other_arch && tmp2->other_arch->type == SPELL) 752 if (tmp2->other_arch && tmp2->other_arch->type == SPELL)
752 tmp2->insert (arch_to_object (tmp2->other_arch)); 753 tmp2->insert (tmp2->other_arch->instance ());
753 754
754 } 755 }
755 else 756 else
756 posblocked = 1; 757 posblocked = 1;
757 758
764 { 765 {
765 object *tmp2 = tmp->clone (); 766 object *tmp2 = tmp->clone ();
766 m->insert (tmp2, x, y, op); 767 m->insert (tmp2, x, y, op);
767 768
768 if (tmp2->other_arch && tmp2->other_arch->type == SPELL) 769 if (tmp2->other_arch && tmp2->other_arch->type == SPELL)
769 tmp2->insert (arch_to_object (tmp2->other_arch)); 770 tmp2->insert (tmp2->other_arch->instance ());
770 } 771 }
771 else 772 else
772 negblocked = 1; 773 negblocked = 1;
773 } 774 }
774 775
777 778
778 return 1; 779 return 1;
779} 780}
780 781
781int 782int
782dimension_door (object *op, object *caster, object *spob, int dir) 783dimension_door (object *op, object *caster, object *spob, int dir, const char *spellparam)
783{ 784{
784 uint32 dist, maxdist; 785 uint32 dist, maxdist;
785 int mflags; 786 int mflags;
786 maptile *m; 787 maptile *m;
787 sint16 sx, sy; 788 sint16 sx, sy;
798 /* Given the new outdoor maps, can't let players dimension door for 799 /* Given the new outdoor maps, can't let players dimension door for
799 * ever, so put limits in. 800 * ever, so put limits in.
800 */ 801 */
801 maxdist = spob->range + SP_level_range_adjust (caster, spob); 802 maxdist = spob->range + SP_level_range_adjust (caster, spob);
802 803
803 if (op->contr->count) 804 if (spellparam)
804 { 805 {
806 int count = atoi (spellparam);
807
805 if (op->contr->count > maxdist) 808 if (count > maxdist)
806 { 809 {
807 new_draw_info (NDI_UNIQUE, 0, op, "You can't dimension door that far!"); 810 new_draw_info (NDI_UNIQUE, 0, op, "You can't dimension door that far!");
808 return 0; 811 return 0;
809 } 812 }
810 813
811 for (dist = 0; dist < op->contr->count; dist++) 814 for (dist = 0; dist < count; dist++)
812 { 815 {
813 mflags = get_map_flags (op->map, &m, op->x + freearr_x[dir] * (dist + 1), op->y + freearr_y[dir] * (dist + 1), &sx, &sy); 816 mflags = get_map_flags (op->map, &m, op->x + freearr_x[dir] * (dist + 1), op->y + freearr_y[dir] * (dist + 1), &sx, &sy);
814 817
815 if (mflags & (P_NO_MAGIC | P_OUT_OF_MAP)) 818 if (mflags & (P_NO_MAGIC | P_OUT_OF_MAP))
816 break; 819 break;
817 820
818 if ((mflags & P_BLOCKSVIEW) && OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, sx, sy))) 821 if ((mflags & P_BLOCKSVIEW) && OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, sx, sy)))
819 break; 822 break;
820 } 823 }
821 824
822 if (dist < op->contr->count) 825 if (dist < count)
823 { 826 {
824 new_draw_info (NDI_UNIQUE, 0, op, "Something blocks the magic of the spell.\n"); 827 new_draw_info (NDI_UNIQUE, 0, op, "Something blocks the magic of the spell.\n");
825 op->contr->count = 0;
826 return 0; 828 return 0;
827 } 829 }
828
829 op->contr->count = 0;
830 830
831 /* Remove code that puts player on random space on maps. IMO, 831 /* Remove code that puts player on random space on maps. IMO,
832 * a lot of maps probably have areas the player should not get to, 832 * a lot of maps probably have areas the player should not get to,
833 * but may not be marked as NO_MAGIC (as they may be bounded 833 * but may not be marked as NO_MAGIC (as they may be bounded
834 * by such squares). Also, there are probably treasure rooms and 834 * by such squares). Also, there are probably treasure rooms and
885 885
886 /* Actually move the player now */ 886 /* Actually move the player now */
887 if (!(op = op->map->insert (op, op->x + freearr_x[dir] * dist, op->y + freearr_y[dir] * dist, op))) 887 if (!(op = op->map->insert (op, op->x + freearr_x[dir] * dist, op->y + freearr_y[dir] * dist, op)))
888 return 1; 888 return 1;
889 889
890 op->speed_left = -FABS (op->speed) * 5; /* Freeze them for a short while */ 890 op->speed_left = -5. * op->speed; /* Freeze them for a short while */
891
891 return 1; 892 return 1;
892} 893}
893 894
894/* cast_heal: Heals something. 895/* cast_heal: Heals something.
895 * op is the caster. 896 * op is the caster.
950 if (cure_disease (tmp, op, spell)) 951 if (cure_disease (tmp, op, spell))
951 success = 1; 952 success = 1;
952 953
953 if (spell->attacktype & AT_POISON) 954 if (spell->attacktype & AT_POISON)
954 { 955 {
955 at = archetype::find ("poisoning"); 956 at = archetype::find (shstr_poisoning);
956 poison = present_arch_in_ob (at, tmp); 957 poison = present_arch_in_ob (at, tmp);
957 if (poison) 958 if (poison)
958 { 959 {
959 success = 1; 960 success = 1;
960 new_draw_info (NDI_UNIQUE, 0, tmp, "Your body feels cleansed"); 961 new_draw_info (NDI_UNIQUE, 0, tmp, "Your body feels cleansed");
962 } 963 }
963 } 964 }
964 965
965 if (spell->attacktype & AT_CONFUSION) 966 if (spell->attacktype & AT_CONFUSION)
966 { 967 {
967 poison = present_in_ob_by_name (FORCE, "confusion", tmp); 968 poison = present_in_ob_by_name (FORCE, shstr_confusion, tmp);
968 if (poison) 969 if (poison)
969 { 970 {
970 success = 1; 971 success = 1;
971 new_draw_info (NDI_UNIQUE, 0, tmp, "Your mind feels clearer"); 972 new_draw_info (NDI_UNIQUE, 0, tmp, "Your mind feels clearer");
972 poison->duration = 1; 973 poison->duration = 1;
973 } 974 }
974 } 975 }
975 976
976 if (spell->attacktype & AT_BLIND) 977 if (spell->attacktype & AT_BLIND)
977 { 978 {
978 at = archetype::find ("blindness"); 979 at = archetype::find (shstr_blindness);
979 poison = present_arch_in_ob (at, tmp); 980 poison = present_arch_in_ob (at, tmp);
980 if (poison) 981 if (poison)
981 { 982 {
982 success = 1; 983 success = 1;
983 new_draw_info (NDI_UNIQUE, 0, tmp, "Your vision begins to return."); 984 new_draw_info (NDI_UNIQUE, 0, tmp, "Your vision begins to return.");
1031 "You don't feel any more powerful." 1032 "You don't feel any more powerful."
1032 "You are no easier to look at.", 1033 "You are no easier to look at.",
1033}; 1034};
1034 1035
1035int 1036int
1037change_ability_duration (object *spell, object *caster)
1038{
1039 return spell->duration + SP_level_duration_adjust (caster, spell) * 50;
1040}
1041
1042int
1036cast_change_ability (object *op, object *caster, object *spell_ob, int dir, int silent) 1043cast_change_ability (object *op, object *caster, object *spell_ob, int dir, int silent)
1037{ 1044{
1038 object *force = 0; 1045 object *force = 0;
1039 int i; 1046 int i;
1040 1047
1057 break; 1064 break;
1058 } 1065 }
1059 else if (spell_ob->race && spell_ob->race == tmp2->name) 1066 else if (spell_ob->race && spell_ob->race == tmp2->name)
1060 { 1067 {
1061 if (!silent) 1068 if (!silent)
1062 new_draw_info_format (NDI_UNIQUE, 0, op, "You can not cast %s while %s is in effect", &spell_ob->name, &tmp2->name_pl); 1069 new_draw_info_format (NDI_UNIQUE, 0, op,
1070 "You can not cast %s while %s is in effect",
1071 &spell_ob->name, &tmp2->name_pl);
1063 1072
1064 return 0; 1073 return 0;
1065 } 1074 }
1066 } 1075 }
1067 } 1076 }
1068 1077
1078 int duration = change_ability_duration (spell_ob, caster);
1079
1069 if (!force) 1080 if (force)
1070 {
1071 force = get_archetype (FORCE_NAME);
1072 force->subtype = FORCE_CHANGE_ABILITY;
1073
1074 if (spell_ob->race)
1075 force->name = spell_ob->race;
1076 else
1077 force->name = spell_ob->name;
1078
1079 force->name_pl = spell_ob->name;
1080 new_draw_info (NDI_UNIQUE, 0, op, "You create an aura of magical force.");
1081
1082 } 1081 {
1083 else
1084 {
1085 int duration;
1086
1087 duration = spell_ob->duration + SP_level_duration_adjust (caster, spell_ob) * 50;
1088 if (duration > force->duration) 1082 if (duration > force->duration)
1089 { 1083 {
1090 force->duration = duration; 1084 force->duration = duration;
1091 new_draw_info (NDI_UNIQUE, 0, op, "You recast the spell while in effect."); 1085 new_draw_info (NDI_UNIQUE, 0, op, "You recast the spell while in effect.");
1092 } 1086 }
1094 new_draw_info (NDI_UNIQUE, 0, op, "Recasting the spell had no effect."); 1088 new_draw_info (NDI_UNIQUE, 0, op, "Recasting the spell had no effect.");
1095 1089
1096 return 1; 1090 return 1;
1097 } 1091 }
1098 1092
1099 force->duration = spell_ob->duration + SP_level_duration_adjust (caster, spell_ob) * 50; 1093 new_draw_info_format (NDI_UNIQUE, 0, op,
1094 "You create an aura of magical force. H<The effect will last for about %.10g seconds.>",
1095 TICK2TIME (duration));
1096
1097 force = get_archetype (FORCE_NAME);
1098 force->subtype = FORCE_CHANGE_ABILITY;
1099 force->duration = duration;
1100
1101 if (spell_ob->race)
1102 force->name = spell_ob->race;
1103 else
1104 force->name = spell_ob->name;
1105
1106 force->name_pl = spell_ob->name;
1107
1100 force->speed = 1.0; 1108 force->speed = 1.0;
1101 force->speed_left = -1.0; 1109 force->speed_left = -1.0;
1102 SET_FLAG (force, FLAG_APPLIED); 1110 SET_FLAG (force, FLAG_APPLIED);
1103 1111
1104 /* Now start processing the effects. First, protections */ 1112 /* Now start processing the effects. First, protections */
1242 } 1250 }
1243 else 1251 else
1244 { 1252 {
1245 /* Only give out good benefits, and put a max on it */ 1253 /* Only give out good benefits, and put a max on it */
1246 for (i = 0; i < NROFATTACKS; i++) 1254 for (i = 0; i < NROFATTACKS; i++)
1247 {
1248 if (god->resist[i] > 0) 1255 if (god->resist[i] > 0)
1249 {
1250 force->resist[i] = MIN (god->resist[i], spell_ob->resist[ATNR_GODPOWER]); 1256 force->resist[i] = min (god->resist[i], spell_ob->resist[ATNR_GODPOWER]);
1251 } 1257
1252 }
1253 force->path_attuned |= god->path_attuned; 1258 force->path_attuned |= god->path_attuned;
1254 1259
1255 if (spell_ob->attacktype) 1260 if (spell_ob->attacktype)
1256 force->slaying = god->slaying; 1261 force->slaying = god->slaying;
1257 1262
1322 if (op->type != PLAYER) 1327 if (op->type != PLAYER)
1323 return 0; 1328 return 0;
1324 1329
1325 archetype *nugget[3]; 1330 archetype *nugget[3];
1326 1331
1327 nugget[0] = archetype::find ("pyrite3"); 1332 nugget[0] = archetype::find (shstr_pyrite3);
1328 nugget[1] = archetype::find ("pyrite2"); 1333 nugget[1] = archetype::find (shstr_pyrite2);
1329 nugget[2] = archetype::find ("pyrite"); 1334 nugget[2] = archetype::find (shstr_pyrite);
1330 1335
1331 /* Put a maximum weight of items that can be alchemised. Limits the power 1336 /* Put a maximum weight of items that can be alchemised. Limits the power
1332 * some, and also prevents people from alchemising every table/chair/clock 1337 * some, and also prevents people from alchemising every table/chair/clock
1333 * in sight 1338 * in sight
1334 */ 1339 */
1394 for (int i = 0; i < sizeof (nugget) / sizeof (nugget [0]); ++i) 1399 for (int i = 0; i < sizeof (nugget) / sizeof (nugget [0]); ++i)
1395 if (int nrof = value / nugget [i]->value) 1400 if (int nrof = value / nugget [i]->value)
1396 { 1401 {
1397 value -= nrof * nugget[i]->value; 1402 value -= nrof * nugget[i]->value;
1398 1403
1399 object *tmp = arch_to_object (nugget[i]); 1404 object *tmp = nugget[i]->instance ();
1400 tmp->nrof = nrof; 1405 tmp->nrof = nrof;
1401 tmp->flag [FLAG_IDENTIFIED] = true; 1406 tmp->flag [FLAG_IDENTIFIED] = true;
1402 op->map->insert (tmp, x, y, op, 0); 1407 op->map->insert (tmp, x, y, op, 0);
1403 } 1408 }
1404 1409
1415 * items. 1420 * items.
1416 */ 1421 */
1417int 1422int
1418remove_curse (object *op, object *caster, object *spell) 1423remove_curse (object *op, object *caster, object *spell)
1419{ 1424{
1420 object *tmp;
1421 int success = 0, was_one = 0; 1425 int success = 0, was_one = 0;
1422 1426
1423 for (tmp = op->inv; tmp; tmp = tmp->below) 1427 for (object *tmp = op->inv; tmp; tmp = tmp->below)
1424 if (QUERY_FLAG (tmp, FLAG_APPLIED) && 1428 if (QUERY_FLAG (tmp, FLAG_APPLIED) &&
1425 ((QUERY_FLAG (tmp, FLAG_CURSED) && QUERY_FLAG (spell, FLAG_CURSED)) || 1429 ((QUERY_FLAG (tmp, FLAG_CURSED) && QUERY_FLAG (spell, FLAG_CURSED)) ||
1426 (QUERY_FLAG (tmp, FLAG_DAMNED) && QUERY_FLAG (spell, FLAG_DAMNED)))) 1430 (QUERY_FLAG (tmp, FLAG_DAMNED) && QUERY_FLAG (spell, FLAG_DAMNED))))
1427 { 1431 {
1428 was_one++; 1432 was_one++;
1568 /* show invisible */ 1572 /* show invisible */
1569 if (QUERY_FLAG (spell, FLAG_MAKE_INVIS) && 1573 if (QUERY_FLAG (spell, FLAG_MAKE_INVIS) &&
1570 /* Might there be other objects that we can make visible? */ 1574 /* Might there be other objects that we can make visible? */
1571 (tmp->invisible && (QUERY_FLAG (tmp, FLAG_MONSTER) 1575 (tmp->invisible && (QUERY_FLAG (tmp, FLAG_MONSTER)
1572 || (tmp->type == PLAYER && !QUERY_FLAG (tmp, FLAG_WIZ)) 1576 || (tmp->type == PLAYER && !QUERY_FLAG (tmp, FLAG_WIZ))
1573 || tmp->type == CF_HANDLE 1577 || tmp->type == T_HANDLE
1574 || tmp->type == TRAPDOOR 1578 || tmp->type == TRAPDOOR
1575 || tmp->type == EXIT 1579 || tmp->type == EXIT
1576 || tmp->type == HOLE 1580 || tmp->type == HOLE
1577 || tmp->type == BUTTON 1581 || tmp->type == BUTTON
1578 || tmp->type == TELEPORTER 1582 || tmp->type == TELEPORTER
1659 /* Code here puts an effect of the spell on the space, so you can see 1663 /* Code here puts an effect of the spell on the space, so you can see
1660 * where the magic is. 1664 * where the magic is.
1661 */ 1665 */
1662 if (done_one) 1666 if (done_one)
1663 { 1667 {
1664 object *detect_ob = arch_to_object (spell->other_arch); 1668 object *detect_ob = spell->other_arch->instance ();
1665 1669
1666 /* if this is set, we want to copy the face */ 1670 /* if this is set, we want to copy the face */
1667 if (done_one == 2 && detect) 1671 if (done_one == 2 && detect)
1668 { 1672 {
1669 detect_ob->face = detect->face; 1673 detect_ob->face = detect->face;
2026 } 2030 }
2027 2031
2028 weapon = weapon->split (); 2032 weapon = weapon->split ();
2029 2033
2030 /* create the golem object */ 2034 /* create the golem object */
2031 tmp = arch_to_object (spell->other_arch); 2035 tmp = spell->other_arch->instance ();
2032 2036
2033 /* if animated by a player, give the player control of the golem */ 2037 /* if animated by a player, give the player control of the golem */
2034 CLEAR_FLAG (tmp, FLAG_MONSTER); 2038 CLEAR_FLAG (tmp, FLAG_MONSTER);
2035 tmp->stats.exp = 0; 2039 tmp->stats.exp = 0;
2036 add_friendly_object (tmp); 2040 add_friendly_object (tmp);
2081 2085
2082 /* attacktype */ 2086 /* attacktype */
2083 if (!tmp->attacktype) 2087 if (!tmp->attacktype)
2084 tmp->attacktype = AT_PHYSICAL; 2088 tmp->attacktype = AT_PHYSICAL;
2085 2089
2086 if (materialtype_t *mt = name_to_material (op->materialname))
2087 {
2088 for (i = 0; i < NROFATTACKS; i++) 2090 for (i = 0; i < NROFATTACKS; i++)
2089 tmp->resist[i] = 50 - (mt->save[i] * 5); 2091 tmp->resist[i] = 50 - (op->material->save[i] * 5);
2090 a = mt->save[0]; 2092
2091 } 2093 a = op->material->save[0];
2092 else
2093 {
2094 for (i = 0; i < NROFATTACKS; i++)
2095 tmp->resist[i] = 5;
2096 a = 10;
2097 }
2098 2094
2099 /* Set weapon's immunity */ 2095 /* Set weapon's immunity */
2100 tmp->resist[ATNR_CONFUSION] = 100; 2096 tmp->resist[ATNR_CONFUSION] = 100;
2101 tmp->resist[ATNR_POISON] = 100; 2097 tmp->resist[ATNR_POISON] = 100;
2102 tmp->resist[ATNR_SLOW] = 100; 2098 tmp->resist[ATNR_SLOW] = 100;
2129 tmp->state = weapon->state; 2125 tmp->state = weapon->state;
2130 tmp->flag [FLAG_ANIMATE] = weapon->flag [FLAG_ANIMATE]; 2126 tmp->flag [FLAG_ANIMATE] = weapon->flag [FLAG_ANIMATE];
2131 } 2127 }
2132 2128
2133 /* make experience increase in proportion to the strength of the summoned creature. */ 2129 /* make experience increase in proportion to the strength of the summoned creature. */
2134 tmp->stats.exp *= 1 + (MAX (spell->stats.maxgrace, spell->stats.sp) / casting_level (caster, spell)); 2130 tmp->stats.exp *= 1 + (max (spell->stats.maxgrace, spell->stats.sp) / casting_level (caster, spell));
2135 2131
2136 tmp->speed_left = -1; 2132 tmp->speed_left = -1;
2137 tmp->direction = dir; 2133 tmp->direction = dir;
2138 2134
2139 m->insert (tmp, x, y, op); 2135 m->insert (tmp, x, y, op);
2178 2174
2179 new_aura = present_arch_in_ob (spell->other_arch, op); 2175 new_aura = present_arch_in_ob (spell->other_arch, op);
2180 if (new_aura) 2176 if (new_aura)
2181 refresh = 1; 2177 refresh = 1;
2182 else 2178 else
2183 new_aura = arch_to_object (spell->other_arch); 2179 new_aura = spell->other_arch->instance ();
2184 2180
2185 new_aura->duration = spell->duration + 10 * SP_level_duration_adjust (caster, spell); 2181 new_aura->duration = spell->duration + 10 * SP_level_duration_adjust (caster, spell);
2186 2182
2187 new_aura->stats.dam = spell->stats.dam + SP_level_dam_adjust (caster, spell); 2183 new_aura->stats.dam = spell->stats.dam + SP_level_dam_adjust (caster, spell);
2188 2184
2253 if (pos.normalise () && !(OB_TYPE_MOVE_BLOCK (env, pos->move_block))) 2249 if (pos.normalise () && !(OB_TYPE_MOVE_BLOCK (env, pos->move_block)))
2254 { 2250 {
2255 hit_map (aura, i, aura->attacktype, 0); 2251 hit_map (aura, i, aura->attacktype, 0);
2256 2252
2257 if (aura->other_arch) 2253 if (aura->other_arch)
2258 pos.insert (arch_to_object (aura->other_arch), aura); 2254 pos.insert (aura->other_arch->instance (), aura);
2259 } 2255 }
2260 } 2256 }
2261 2257
2262 /* put the aura back in the player's inventory */ 2258 /* put the aura back in the player's inventory */
2263 env->insert (aura); 2259 env->insert (aura);
2282 continue; 2278 continue;
2283 2279
2284 if (victim->stats.exp == 0) 2280 if (victim->stats.exp == 0)
2285 continue; 2281 continue;
2286 2282
2287 def_lev = MAX (1, victim->level); 2283 def_lev = max (1, victim->level);
2288 atk_lev = MAX (1, op->level); 2284 atk_lev = max (1, op->level);
2289 2285
2290 if (rndm (0, atk_lev - 1) > def_lev) 2286 if (rndm (0, atk_lev - 1) > def_lev)
2291 { 2287 {
2292 /* make this sucker peaceful. */ 2288 /* make this sucker peaceful. */
2293 2289
2325 { 2321 {
2326 new_draw_info (NDI_UNIQUE, 0, op, "Write what?"); 2322 new_draw_info (NDI_UNIQUE, 0, op, "Write what?");
2327 return 0; 2323 return 0;
2328 } 2324 }
2329 2325
2330 if (strcasestr_local (msg, "endmsg")) 2326 if (!msg_is_safe (msg))
2331 { 2327 {
2332 new_draw_info (NDI_UNIQUE, 0, op, "Trying to cheat are we?"); 2328 new_draw_info (NDI_UNIQUE, 0, op, "Trying to cheat are we?");
2333 LOG (llevInfo, "write_rune: player %s tried to write bogus rune %s\n", &op->name, msg); 2329 LOG (llevInfo, "write_mark: player %s tried to write bogus rune %s\n", &op->name, msg);
2334 return 0; 2330 return 0;
2335 } 2331 }
2336 2332
2337 if (!spell->other_arch) 2333 if (!spell->other_arch)
2338 return 0; 2334 return 0;
2339 2335
2340 object *tmp = arch_to_object (spell->other_arch); 2336 object *tmp = spell->other_arch->instance ();
2341 2337
2342 tmp->race = op->name; /*Save the owner of the rune */ 2338 tmp->race = op->name; /*Save the owner of the rune */
2343 tmp->msg = msg; 2339 tmp->msg = msg;
2344 2340
2345 tmp->insert_at (op, op, INS_BELOW_ORIGINATOR); 2341 tmp->insert_at (op, op, INS_BELOW_ORIGINATOR);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines