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.131 by root, Fri Apr 23 04:32:47 2010 UTC vs.
Revision 1.149 by root, Sat Dec 1 20:22:13 2018 UTC

1/* 1/*
2 * This file is part of Deliantra, the Roguelike Realtime MMORPG. 2 * This file is part of Deliantra, the Roguelike Realtime MMORPG.
3 * 3 *
4 * Copyright (©) 2017,2018 Marc Alexander Lehmann / the Deliantra team
4 * Copyright (©) 2005,2006,2007,2008,2009,2010 Marc Alexander Lehmann / Robin Redeker / the Deliantra team 5 * Copyright (©) 2005,2006,2007,2008,2009,2010,2011,2012,2013,2014,2015,2016 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
5 * Copyright (©) 2002 Mark Wedel & Crossfire Development Team 6 * Copyright (©) 2002 Mark Wedel & Crossfire Development Team
6 * Copyright (©) 1992 Frank Tore Johansen 7 * Copyright (©) 1992 Frank Tore Johansen
7 * 8 *
8 * Deliantra is free software: you can redistribute it and/or modify it under 9 * Deliantra is free software: you can redistribute it and/or modify it under
9 * the terms of the Affero GNU General Public License as published by the 10 * the terms of the Affero GNU General Public License as published by the
10 * Free Software Foundation, either version 3 of the License, or (at your 11 * Free Software Foundation, either version 3 of the License, or (at your
11 * option) any later version. 12 * option) any later version.
12 * 13 *
13 * This program is distributed in the hope that it will be useful, 14 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details. 17 * GNU General Public License for more details.
17 * 18 *
18 * You should have received a copy of the Affero GNU General Public License 19 * You should have received a copy of the Affero GNU General Public License
19 * and the GNU General Public License along with this program. If not, see 20 * and the GNU General Public License along with this program. If not, see
20 * <http://www.gnu.org/licenses/>. 21 * <http://www.gnu.org/licenses/>.
21 * 22 *
22 * The authors can be reached via e-mail to <support@deliantra.net> 23 * The authors can be reached via e-mail to <support@deliantra.net>
23 */ 24 */
24 25
25#include <global.h> 26#include <global.h>
26#include <object.h> 27#include <object.h>
73 if (!(random_roll (0, 3, op, PREFER_HIGH))) 74 if (!(random_roll (0, 3, op, PREFER_HIGH)))
74 { 75 {
75 op->failmsgf ("The %s vibrates violently, then explodes!", query_name (wand)); 76 op->failmsgf ("The %s vibrates violently, then explodes!", query_name (wand));
76 op->play_sound (sound_find ("ob_explode")); 77 op->play_sound (sound_find ("ob_explode"));
77 wand->destroy (); 78 wand->destroy ();
78 object *tmp = get_archetype (shstr_fireball); 79 object *tmp = archetype::get (shstr_fireball);
79 tmp->stats.dam = (spell_ob->stats.dam + SP_level_dam_adjust (caster, spell_ob)) / 10; 80 tmp->stats.dam = (spell_ob->stats.dam + SP_level_dam_adjust (caster, spell_ob)) / 10;
80 81
81 if (!tmp->stats.dam) 82 if (!tmp->stats.dam)
82 tmp->stats.dam = 1; 83 tmp->stats.dam = 1;
83 84
196 /* Can't get any money for these objects */ 197 /* Can't get any money for these objects */
197 missile->value = 0; 198 missile->value = 0;
198 199
199 missile->set_flag (FLAG_IDENTIFIED); 200 missile->set_flag (FLAG_IDENTIFIED);
200 201
201 if (!cast_create_obj (op, caster, missile, dir) && op->type == PLAYER && !missile->destroyed ()) 202 cast_create_obj (op, caster, missile, dir);
203
204 if (!dir
205 && op->type == PLAYER
206 && !missile->destroyed ())
202 pick_up (op, missile); 207 pick_up (op, missile);
203 208
204 return 1; 209 return 1;
205} 210}
206
207 211
208/* allows the choice of what sort of food object to make. 212/* allows the choice of what sort of food object to make.
209 * If spellparam is NULL, it will create food dependent on level --PeterM*/ 213 * If spellparam is NULL, it will create food dependent on level --PeterM*/
210int 214int
211cast_create_food (object *op, object *caster, object *spell_ob, int dir, const char *spellparam) 215cast_create_food (object *op, object *caster, object *spell_ob, int dir, const char *spellparam)
290 } 294 }
291 295
292 maxrange = spell_ob->range + SP_level_range_adjust (caster, spell_ob); 296 maxrange = spell_ob->range + SP_level_range_adjust (caster, spell_ob);
293 for (r = 1; r < maxrange; r++) 297 for (r = 1; r < maxrange; r++)
294 { 298 {
295 sint16 x = op->x + r * freearr_x[dir], y = op->y + r * freearr_y[dir]; 299 sint16 x = op->x + r * DIRX (dir), y = op->y + r * DIRY (dir);
296 300
297 m = op->map; 301 m = op->map;
298 mflags = get_map_flags (m, &m, x, y, &x, &y); 302 mflags = get_map_flags (m, &m, x, y, &x, &y);
299 303
300 if (mflags & P_OUT_OF_MAP) 304 if (mflags & P_OUT_OF_MAP)
389 393
390 /* Remove the switch with 90% duplicate code - just handle the differences with 394 /* Remove the switch with 90% duplicate code - just handle the differences with
391 * and if statement or two. 395 * and if statement or two.
392 */ 396 */
393 op->invisible += spell_ob->duration + SP_level_duration_adjust (caster, spell_ob); 397 op->invisible += spell_ob->duration + SP_level_duration_adjust (caster, spell_ob);
398
394 /* max duration */ 399 /* limit duration */
395 if (op->invisible > 1000) 400 min_it (op->invisible, 1000);
396 op->invisible = 1000;
397 401
398 if (op->type == PLAYER) 402 if (op->type == PLAYER)
399 { 403 {
400 op->contr->invis_race = spell_ob->race; 404 op->contr->invis_race = spell_ob->race;
401 405
402 if (spell_ob->flag [FLAG_MAKE_INVIS]) 406 if (spell_ob->flag [FLAG_MAKE_INVIS])
403 op->contr->tmp_invis = 0; 407 op->contr->tmp_invis = 0;
404 else 408 else
405 op->contr->tmp_invis = 1; 409 op->contr->tmp_invis = 1;
406
407 op->contr->hidden = 0;
408 } 410 }
409 411
410 if (makes_invisible_to (op, op)) 412 if (makes_invisible_to (op, op))
411 new_draw_info (NDI_UNIQUE, 0, op, "You can't see your hands!"); 413 new_draw_info (NDI_UNIQUE, 0, op, "You can't see your hands!");
412 else 414 else
470 472
471 op->destroy (); 473 op->destroy ();
472} 474}
473 475
474/* Word of recall causes the player to return 'home'. 476/* Word of recall causes the player to return 'home'.
475 * we put a force into the player object, so that there is a 477 * we put a force into the player object, so that there is a
476 * time delay effect. 478 * time delay effect.
477 */ 479 */
478int 480int
479cast_word_of_recall (object *op, object *caster, object *spell_ob) 481cast_word_of_recall (object *op, object *caster, object *spell_ob)
480{ 482{
485 { 487 {
486 new_draw_info (NDI_UNIQUE, 0, op, "You feel a force starting to build up inside you."); 488 new_draw_info (NDI_UNIQUE, 0, op, "You feel a force starting to build up inside you.");
487 return 1; 489 return 1;
488 } 490 }
489 491
490 object *dummy = get_archetype (FORCE_NAME); 492 object *dummy = archetype::get (FORCE_NAME);
491 493
492 int time = max (1, spell_ob->duration - SP_level_duration_adjust (caster, spell_ob)); 494 int time = max (1, spell_ob->duration - SP_level_duration_adjust (caster, spell_ob));
493 495
494 /* value of speed really doesn't make much difference, as long as it is 496 /* value of speed really doesn't make much difference, as long as it is
495 * positive. Lower value may be useful so that the problem doesn't 497 * positive. Lower value may be useful so that the problem doesn't
618 x = op->x; 620 x = op->x;
619 y = op->y; 621 y = op->y;
620 } 622 }
621 else 623 else
622 { 624 {
623 x = op->x + freearr_x[dir]; 625 x = op->x + DIRX (dir);
624 y = op->y + freearr_y[dir]; 626 y = op->y + DIRY (dir);
625 } 627 }
626 628
627 m = op->map; 629 m = op->map;
628 630
629 if ((spell_ob->move_block || x != op->x || y != op->y) && 631 if ((spell_ob->move_block || x != op->x || y != op->y) &&
704 /* If this is a spellcasting wall, need to insert the spell object */ 706 /* If this is a spellcasting wall, need to insert the spell object */
705 if (tmp->other_arch && tmp->other_arch->type == SPELL) 707 if (tmp->other_arch && tmp->other_arch->type == SPELL)
706 insert_ob_in_ob (tmp->other_arch->instance (), tmp); 708 insert_ob_in_ob (tmp->other_arch->instance (), tmp);
707 709
708 /* This code causes the wall to extend some distance in 710 /* This code causes the wall to extend some distance in
709 * each direction, or until an obstruction is encountered. 711 * each direction, or until an obstruction is encountered.
710 * posblocked and negblocked help determine how far the 712 * posblocked and negblocked help determine how far the
711 * created wall can extend, it won't go extend through 713 * created wall can extend, it won't go extend through
712 * blocked spaces. 714 * blocked spaces.
713 */ 715 */
714 maxrange = spell_ob->range + SP_level_range_adjust (caster, spell_ob); 716 maxrange = spell_ob->range + SP_level_range_adjust (caster, spell_ob);
719 { 721 {
720 int dir2; 722 int dir2;
721 723
722 dir2 = (dir < 4) ? (dir + 2) : dir - 2; 724 dir2 = (dir < 4) ? (dir + 2) : dir - 2;
723 725
724 x = tmp->x + i * freearr_x[dir2]; 726 x = tmp->x + i * DIRX (dir2);
725 y = tmp->y + i * freearr_y[dir2]; 727 y = tmp->y + i * DIRY (dir2);
726 m = tmp->map; 728 m = tmp->map;
727 729
728 if (!(get_map_flags (m, &m, x, y, &x, &y) & (P_OUT_OF_MAP | P_IS_ALIVE)) && 730 if (!(get_map_flags (m, &m, x, y, &x, &y) & (P_OUT_OF_MAP | P_IS_ALIVE)) &&
729 ((spell_ob->move_block & GET_MAP_MOVE_BLOCK (m, x, y)) != spell_ob->move_block) && !posblocked) 731 ((spell_ob->move_block & GET_MAP_MOVE_BLOCK (m, x, y)) != spell_ob->move_block) && !posblocked)
730 { 732 {
737 739
738 } 740 }
739 else 741 else
740 posblocked = 1; 742 posblocked = 1;
741 743
742 x = tmp->x - i * freearr_x[dir2]; 744 x = tmp->x - i * DIRX (dir2);
743 y = tmp->y - i * freearr_y[dir2]; 745 y = tmp->y - i * DIRY (dir2);
744 m = tmp->map; 746 m = tmp->map;
745 747
746 if (!(get_map_flags (m, &m, x, y, &x, &y) & (P_OUT_OF_MAP | P_IS_ALIVE)) && 748 if (!(get_map_flags (m, &m, x, y, &x, &y) & (P_OUT_OF_MAP | P_IS_ALIVE)) &&
747 ((spell_ob->move_block & GET_MAP_MOVE_BLOCK (m, x, y)) != spell_ob->move_block) && !negblocked) 749 ((spell_ob->move_block & GET_MAP_MOVE_BLOCK (m, x, y)) != spell_ob->move_block) && !negblocked)
748 { 750 {
794 return 0; 796 return 0;
795 } 797 }
796 798
797 for (dist = 0; dist < count; dist++) 799 for (dist = 0; dist < count; dist++)
798 { 800 {
799 mflags = get_map_flags (op->map, &m, op->x + freearr_x[dir] * (dist + 1), op->y + freearr_y[dir] * (dist + 1), &sx, &sy); 801 mflags = get_map_flags (op->map, &m, op->x + DIRX (dir) * (dist + 1), op->y + DIRY (dir) * (dist + 1), &sx, &sy);
800 802
801 if (mflags & (P_NO_MAGIC | P_OUT_OF_MAP)) 803 if (mflags & (P_NO_MAGIC | P_OUT_OF_MAP))
802 break; 804 break;
803 805
804 if ((mflags & P_BLOCKSVIEW) && OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, sx, sy))) 806 if ((mflags & P_BLOCKSVIEW) && OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, sx, sy)))
817 * by such squares). Also, there are probably treasure rooms and 819 * by such squares). Also, there are probably treasure rooms and
818 * lots of other maps that protect areas with no magic, but the 820 * lots of other maps that protect areas with no magic, but the
819 * areas themselves don't contain no magic spaces. 821 * areas themselves don't contain no magic spaces.
820 */ 822 */
821 /* This call here is really just to normalize the coordinates */ 823 /* This call here is really just to normalize the coordinates */
822 mflags = get_map_flags (op->map, &m, op->x + freearr_x[dir] * dist, op->y + freearr_y[dir] * dist, &sx, &sy); 824 mflags = get_map_flags (op->map, &m, op->x + DIRX (dir) * dist, op->y + DIRY (dir) * dist, &sx, &sy);
823 if (mflags & P_IS_ALIVE || OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, sx, sy))) 825 if (mflags & P_IS_ALIVE || OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, sx, sy)))
824 { 826 {
825 new_draw_info (NDI_UNIQUE, 0, op, "You cast your spell, but nothing happens.\n"); 827 new_draw_info (NDI_UNIQUE, 0, op, "You cast your spell, but nothing happens.\n");
826 return 1; /* Maybe the penalty should be more severe... */ 828 return 1; /* Maybe the penalty should be more severe... */
827 } 829 }
833 * spaces that blocked the players view. 835 * spaces that blocked the players view.
834 */ 836 */
835 837
836 for (dist = 0; dist < maxdist; dist++) 838 for (dist = 0; dist < maxdist; dist++)
837 { 839 {
838 mflags = get_map_flags (op->map, &m, op->x + freearr_x[dir] * (dist + 1), op->y + freearr_y[dir] * (dist + 1), &sx, &sy); 840 mflags = get_map_flags (op->map, &m, op->x + DIRX (dir) * (dist + 1), op->y + DIRY (dir) * (dist + 1), &sx, &sy);
839 841
840 if (mflags & (P_NO_MAGIC | P_OUT_OF_MAP)) 842 if (mflags & (P_NO_MAGIC | P_OUT_OF_MAP))
841 break; 843 break;
842 844
843 if ((mflags & P_BLOCKSVIEW) && OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, sx, sy))) 845 if ((mflags & P_BLOCKSVIEW) && OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, sx, sy)))
848 /* If the destination is blocked, keep backing up until we 850 /* If the destination is blocked, keep backing up until we
849 * find a place for the player. 851 * find a place for the player.
850 */ 852 */
851 for (; dist > 0; dist--) 853 for (; dist > 0; dist--)
852 { 854 {
853 if (get_map_flags (op->map, &m, op->x + freearr_x[dir] * dist, op->y + freearr_y[dir] * dist, 855 if (get_map_flags (op->map, &m, op->x + DIRX (dir) * dist, op->y + DIRY (dir) * dist,
854 &sx, &sy) & (P_OUT_OF_MAP | P_IS_ALIVE)) 856 &sx, &sy) & (P_OUT_OF_MAP | P_IS_ALIVE))
855 continue; 857 continue;
856 858
857 859
858 if (!OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, sx, sy))) 860 if (!OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, sx, sy)))
865 return 0; 867 return 0;
866 } 868 }
867 } 869 }
868 870
869 /* Actually move the player now */ 871 /* Actually move the player now */
870 if (!(op = op->map->insert (op, op->x + freearr_x[dir] * dist, op->y + freearr_y[dir] * dist, op))) 872 if (!(op = op->map->insert (op, op->x + DIRX (dir) * dist, op->y + DIRY (dir) * dist, op)))
871 return 1; 873 return 1;
872 874
873 op->speed_left = -5. * op->speed; /* Freeze them for a short while */ 875 op->speed_left = -5. * op->speed; /* Freeze them for a short while */
874 876
875 return 1; 877 return 1;
1072 1074
1073 new_draw_info_format (NDI_UNIQUE, 0, op, 1075 new_draw_info_format (NDI_UNIQUE, 0, op,
1074 "You create an aura of magical force. H<The effect will last for about %.10g seconds.>", 1076 "You create an aura of magical force. H<The effect will last for about %.10g seconds.>",
1075 TICK2TIME (duration)); 1077 TICK2TIME (duration));
1076 1078
1077 force = get_archetype (FORCE_NAME); 1079 force = archetype::get (FORCE_NAME);
1078 force->subtype = FORCE_CHANGE_ABILITY; 1080 force->subtype = FORCE_CHANGE_ABILITY;
1079 force->duration = duration; 1081 force->duration = duration;
1080 1082
1081 if (spell_ob->race) 1083 if (spell_ob->race)
1082 force->name = spell_ob->race; 1084 force->name = spell_ob->race;
1089 force->speed_left = -1.0; 1091 force->speed_left = -1.0;
1090 force->set_flag (FLAG_APPLIED); 1092 force->set_flag (FLAG_APPLIED);
1091 1093
1092 /* Now start processing the effects. First, protections */ 1094 /* Now start processing the effects. First, protections */
1093 for (i = 0; i < NROFATTACKS; i++) 1095 for (i = 0; i < NROFATTACKS; i++)
1094 {
1095 if (spell_ob->resist[i]) 1096 if (spell_ob->resist[i])
1096 {
1097 force->resist[i] = spell_ob->resist[i] + SP_level_dam_adjust (caster, spell_ob); 1097 force->resist[i] = min (100, spell_ob->resist[i] + SP_level_dam_adjust (caster, spell_ob));
1098 if (force->resist[i] > 100)
1099 force->resist[i] = 100;
1100 }
1101 }
1102 1098
1103 if (spell_ob->stats.hp) 1099 if (spell_ob->stats.hp)
1104 force->stats.hp = spell_ob->stats.hp + SP_level_dam_adjust (caster, spell_ob); 1100 force->stats.hp = spell_ob->stats.hp + SP_level_dam_adjust (caster, spell_ob);
1105 1101
1106 if (tmp->type == PLAYER) 1102 if (tmp->type == PLAYER)
1192 } 1188 }
1193 } 1189 }
1194 1190
1195 if (force == NULL) 1191 if (force == NULL)
1196 { 1192 {
1197 force = get_archetype (FORCE_NAME); 1193 force = archetype::get (FORCE_NAME);
1198 force->subtype = FORCE_CHANGE_ABILITY; 1194 force->subtype = FORCE_CHANGE_ABILITY;
1199 if (spell_ob->race) 1195 if (spell_ob->race)
1200 force->name = spell_ob->race; 1196 force->name = spell_ob->race;
1201 else 1197 else
1202 force->name = spell_ob->name; 1198 force->name = spell_ob->name;
1217 { 1213 {
1218 new_draw_info (NDI_UNIQUE, 0, op, "Recasting the spell had no effect."); 1214 new_draw_info (NDI_UNIQUE, 0, op, "Recasting the spell had no effect.");
1219 } 1215 }
1220 return 0; 1216 return 0;
1221 } 1217 }
1218
1222 force->duration = spell_ob->duration + SP_level_duration_adjust (caster, spell_ob) * 50; 1219 force->duration = spell_ob->duration + SP_level_duration_adjust (caster, spell_ob) * 50;
1223 force->speed = 1.0; 1220 force->speed = 1.0;
1224 force->speed_left = -1.0; 1221 force->speed_left = -1.0;
1225 force->set_flag (FLAG_APPLIED); 1222 force->set_flag (FLAG_APPLIED);
1226 1223
1262 1259
1263/* Alchemy code by Mark Wedel 1260/* Alchemy code by Mark Wedel
1264 * 1261 *
1265 * This code adds a new spell, called alchemy. Alchemy will turn 1262 * This code adds a new spell, called alchemy. Alchemy will turn
1266 * objects to pyrite ("false gold"), henceforth called gold nuggets. 1263 * objects to pyrite ("false gold"), henceforth called gold nuggets.
1267 * 1264 *
1268 * The value of the gold nuggets being about 90% of that of the item 1265 * The value of the gold nuggets being about 90% of that of the item
1269 * itself. It uses the value of the object before charisma adjustments, 1266 * itself. It uses the value of the object before charisma adjustments,
1270 * because the nuggets themselves will be will be adjusted by charisma 1267 * because the nuggets themselves will be will be adjusted by charisma
1271 * when sold. 1268 * when sold.
1272 * 1269 *
1374 } 1371 }
1375 1372
1376 value -= rndm (value >> 4); 1373 value -= rndm (value >> 4);
1377 value = min (value, value_max); 1374 value = min (value, value_max);
1378 1375
1379 for (int i = 0; i < sizeof (nugget) / sizeof (nugget [0]); ++i) 1376 for (int i = 0; i < ecb_array_length (nugget); ++i)
1380 if (int nrof = value / nugget [i]->value) 1377 if (int nrof = value / nugget [i]->value)
1381 { 1378 {
1382 value -= nrof * nugget[i]->value; 1379 value -= nrof * nugget[i]->value;
1383 1380
1384 object *tmp = nugget[i]->instance (); 1381 object *tmp = nugget[i]->instance ();
1402int 1399int
1403remove_curse (object *op, object *caster, object *spell) 1400remove_curse (object *op, object *caster, object *spell)
1404{ 1401{
1405 int success = 0, was_one = 0; 1402 int success = 0, was_one = 0;
1406 1403
1404 int num_uncurse = max (1, spell->stats.dam + SP_level_dam_adjust (caster, spell));
1405
1406 op->splay_marked ();
1407
1408 int typeflag = spell->last_sp ? FLAG_DAMNED : FLAG_CURSED;
1409
1407 for (object *tmp = op->inv; tmp; tmp = tmp->below) 1410 for (object *tmp = op->inv; tmp && num_uncurse; tmp = tmp->below)
1408 if (tmp->flag [FLAG_APPLIED] && 1411 if (!tmp->invisible && tmp->flag [typeflag])
1409 ((tmp->flag [FLAG_CURSED] && spell->flag [FLAG_CURSED]) ||
1410 (tmp->flag [FLAG_DAMNED] && spell->flag [FLAG_DAMNED])))
1411 { 1412 {
1412 was_one++; 1413 ++was_one;
1413 1414
1414 if (tmp->level <= casting_level (caster, spell)) 1415 if (tmp->level <= casting_level (caster, spell))
1415 { 1416 {
1416 success++; 1417 ++success;
1417 if (spell->flag [FLAG_DAMNED]) 1418 --num_uncurse;
1418 tmp->clr_flag (FLAG_DAMNED);
1419 1419
1420 tmp->clr_flag (typeflag);
1420 tmp->clr_flag (FLAG_CURSED); 1421 tmp->clr_flag (FLAG_CURSED);
1421 tmp->clr_flag (FLAG_KNOWN_CURSED); 1422 tmp->clr_flag (FLAG_KNOWN_CURSED);
1422 tmp->value = 0; /* Still can't sell it */ 1423 tmp->value = 0; /* Still can't sell it */
1423 1424
1424 if (object *pl = tmp->visible_to ()) 1425 if (object *pl = tmp->visible_to ())
1427 } 1428 }
1428 1429
1429 if (op->type == PLAYER) 1430 if (op->type == PLAYER)
1430 { 1431 {
1431 if (success) 1432 if (success)
1432 new_draw_info (NDI_UNIQUE, 0, op, "You feel like some of your items are looser now."); 1433 new_draw_info (NDI_UNIQUE, 0, op, "You realise that some of your items look shinier now. H<You successfully removed some curses.>");
1433 else 1434 else
1434 { 1435 {
1435 if (was_one) 1436 if (was_one)
1436 new_draw_info (NDI_UNIQUE, 0, op, "You failed to remove the curse."); 1437 new_draw_info (NDI_UNIQUE, 0, op, "You failed to remove any curse. H<The spell was not strong enough.>");
1437 else 1438 else
1438 new_draw_info (NDI_UNIQUE, 0, op, "You are not using any cursed items."); 1439 new_draw_info (NDI_UNIQUE, 0, op, "You are not having any cursed items. H<Epic fail.>");
1439 } 1440 }
1440 } 1441 }
1441 1442
1442 return success; 1443 return success;
1443} 1444}
1444 1445
1445/* Identifies objects in the players inventory/on the ground */ 1446/* Identifies objects in the players inventory/on the ground */
1446int 1447int
1447cast_identify (object *op, object *caster, object *spell) 1448cast_identify (object *op, object *caster, object *spell)
1448{ 1449{
1449 object *tmp;
1450 dynbuf_text &buf = msg_dynbuf; buf.clear (); 1450 dynbuf_text &buf = msg_dynbuf; buf.clear ();
1451 1451
1452 int num_ident = max (1, spell->stats.dam + SP_level_dam_adjust (caster, spell)); 1452 int num_ident = max (1, spell->stats.dam + SP_level_dam_adjust (caster, spell));
1453 1453
1454 op->splay_marked ();
1455
1454 for (tmp = op->inv; tmp; tmp = tmp->below) 1456 for (object *tmp = op->inv; tmp; tmp = tmp->below)
1455 { 1457 {
1456 if (!tmp->flag [FLAG_IDENTIFIED] && !tmp->invisible && tmp->need_identify ()) 1458 if (!tmp->flag [FLAG_IDENTIFIED] && !tmp->invisible && tmp->need_identify ())
1457 { 1459 {
1458 identify (tmp); 1460 identify (tmp);
1459 1461
1474 * stuff on the floor. Only identify stuff on the floor if the spell 1476 * stuff on the floor. Only identify stuff on the floor if the spell
1475 * was not fully used. 1477 * was not fully used.
1476 */ 1478 */
1477 if (num_ident) 1479 if (num_ident)
1478 { 1480 {
1479 for (tmp = GET_MAP_OB (op->map, op->x, op->y); tmp; tmp = tmp->above) 1481 for (object *tmp = GET_MAP_OB (op->map, op->x, op->y); tmp; tmp = tmp->above)
1480 if (!tmp->flag [FLAG_IDENTIFIED] && !tmp->invisible && tmp->need_identify ()) 1482 if (!tmp->flag [FLAG_IDENTIFIED] && !tmp->invisible && tmp->need_identify ())
1481 { 1483 {
1482 identify (tmp); 1484 identify (tmp);
1483 1485
1484 if (object *pl = tmp->visible_to ()) 1486 if (object *pl = tmp->visible_to ())
1511 1513
1512int 1514int
1513cast_detection (object *op, object *caster, object *spell, object *skill) 1515cast_detection (object *op, object *caster, object *spell, object *skill)
1514{ 1516{
1515 object *tmp, *last, *god, *detect; 1517 object *tmp, *last, *god, *detect;
1516 int done_one, range, mflags, floor, level; 1518 int done_one, range, floor, level;
1517 sint16 x, y, nx, ny; 1519 sint16 x, y, nx, ny;
1518 maptile *m; 1520 maptile *m;
1519 1521
1520 /* We precompute some values here so that we don't have to keep 1522 /* We precompute some values here so that we don't have to keep
1521 * doing it over and over again. 1523 * doing it over and over again.
1767 sint16 x, y; 1769 sint16 x, y;
1768 maptile *m; 1770 maptile *m;
1769 int mflags; 1771 int mflags;
1770 1772
1771 m = op->map; 1773 m = op->map;
1772 x = op->x + freearr_x[dir]; 1774 x = op->x + DIRX (dir);
1773 y = op->y + freearr_y[dir]; 1775 y = op->y + DIRY (dir);
1774 1776
1775 mflags = get_map_flags (m, &m, x, y, &x, &y); 1777 mflags = get_map_flags (m, &m, x, y, &x, &y);
1776 1778
1777 if (!(mflags & P_OUT_OF_MAP) && mflags & P_IS_ALIVE) 1779 if (!(mflags & P_OUT_OF_MAP) && mflags & P_IS_ALIVE)
1778 { 1780 {
1842 object *tmp, *head, *next; 1844 object *tmp, *head, *next;
1843 int mflags; 1845 int mflags;
1844 maptile *m; 1846 maptile *m;
1845 sint16 sx, sy; 1847 sint16 sx, sy;
1846 1848
1847 sx = op->x + freearr_x[dir]; 1849 sx = op->x + DIRX (dir);
1848 sy = op->y + freearr_y[dir]; 1850 sy = op->y + DIRY (dir);
1849 m = op->map; 1851 m = op->map;
1850 mflags = get_map_flags (m, &m, sx, sy, &sx, &sy); 1852 mflags = get_map_flags (m, &m, sx, sy, &sx, &sy);
1851 if (mflags & P_OUT_OF_MAP) 1853 if (mflags & P_OUT_OF_MAP)
1852 return; 1854 return;
1853 1855
1866 1868
1867 /* don't attack our own spells */ 1869 /* don't attack our own spells */
1868 if (tmp->owner && tmp->owner == op->owner) 1870 if (tmp->owner && tmp->owner == op->owner)
1869 continue; 1871 continue;
1870 1872
1871 /* Basically, if the object is magical and not counterspell, 1873 /* Basically, if the object is magical and not counterspell,
1872 * we will more or less remove the object. Don't counterspell 1874 * we will more or less remove the object. Don't counterspell
1873 * monsters either. 1875 * monsters either.
1874 */ 1876 */
1875 1877
1876 if (head->attacktype & AT_MAGIC 1878 if (head->attacktype & AT_MAGIC
1877 && !(head->attacktype & AT_COUNTERSPELL) 1879 && !(head->attacktype & AT_COUNTERSPELL)
1878 && !head->flag [FLAG_MONSTER] 1880 && !head->flag [FLAG_MONSTER]
1952 1954
1953 op->failmsg ("You are not standing over an altar!"); 1955 op->failmsg ("You are not standing over an altar!");
1954 return 0; 1956 return 0;
1955} 1957}
1956 1958
1957/* animate_weapon - 1959/* animate_weapon -
1958 * Generalization of staff_to_snake. Makes a golem out of the caster's weapon. 1960 * Generalization of staff_to_snake. Makes a golem out of the caster's weapon.
1959 * The golem is based on the archetype specified, modified by the caster's level 1961 * The golem is based on the archetype specified, modified by the caster's level
1960 * and the attributes of the weapon. The weapon is inserted in the golem's 1962 * and the attributes of the weapon. The weapon is inserted in the golem's
1961 * inventory so that it falls to the ground when the golem dies. 1963 * inventory so that it falls to the ground when the golem dies.
1962 * This code was very odd - code early on would only let players use the spell, 1964 * This code was very odd - code early on would only let players use the spell,
1963 * yet the code wass full of player checks. I've presumed that the code 1965 * yet the code wass full of player checks. I've presumed that the code
1964 * that only let players use it was correct, and removed all the other 1966 * that only let players use it was correct, and removed all the other
1965 * player checks. MSW 2003-01-06 1967 * player checks. MSW 2003-01-06
1992 /* if no direction specified, pick one */ 1994 /* if no direction specified, pick one */
1993 if (!dir) 1995 if (!dir)
1994 dir = find_free_spot (spell->other_arch, op->map, op->x, op->y, 1, 9); 1996 dir = find_free_spot (spell->other_arch, op->map, op->x, op->y, 1, 9);
1995 1997
1996 m = op->map; 1998 m = op->map;
1997 x = op->x + freearr_x[dir]; 1999 x = op->x + DIRX (dir);
1998 y = op->y + freearr_y[dir]; 2000 y = op->y + DIRY (dir);
1999 2001
2000 /* if there's no place to put the golem, abort */ 2002 /* if there's no place to put the golem, abort */
2001 if (dir < 0 || (get_map_flags (m, &m, x, y, &x, &y) & P_OUT_OF_MAP) 2003 if (dir < 0 || (get_map_flags (m, &m, x, y, &x, &y) & P_OUT_OF_MAP)
2002 || ((spell->other_arch->move_type & GET_MAP_MOVE_BLOCK (m, x, y)) == spell->other_arch->move_type)) 2004 || ((spell->other_arch->move_type & GET_MAP_MOVE_BLOCK (m, x, y)) == spell->other_arch->move_type))
2003 { 2005 {
2109 /* Improve weapon's armour value according to best save vs. physical of its material */ 2111 /* Improve weapon's armour value according to best save vs. physical of its material */
2110 2112
2111 if (a > 14) 2113 if (a > 14)
2112 a = 14; 2114 a = 14;
2113 2115
2114 tmp->resist[ATNR_PHYSICAL] = 100 - (int) ((100.0 - (float) tmp->resist[ATNR_PHYSICAL]) / (30.0 - 2.0 * a)); 2116 tmp->resist[ATNR_PHYSICAL] = 100 - (int) ((100.f - (float) tmp->resist[ATNR_PHYSICAL]) / (30.f - 2.f * a));
2115 2117
2116 /* Determine golem's speed */ 2118 /* Determine golem's speed */
2117 tmp->set_speed (min (3.33, 0.4 + 0.1 * SP_level_range_adjust (caster, spell))); 2119 tmp->set_speed (min (3.33f, 0.4f + 0.1f * SP_level_range_adjust (caster, spell)));
2118 2120
2119 if (!spell->race) 2121 if (!spell->race)
2120 { 2122 {
2121 sprintf (buf, "animated %s", &weapon->name); 2123 sprintf (buf, "animated %s", &weapon->name);
2122 tmp->name = buf; 2124 tmp->name = buf;
2203 2205
2204/* move aura function. An aura is a part of someone's inventory, 2206/* move aura function. An aura is a part of someone's inventory,
2205 * which he carries with him, but which acts on the map immediately 2207 * which he carries with him, but which acts on the map immediately
2206 * around him. 2208 * around him.
2207 * Aura parameters: 2209 * Aura parameters:
2208 * duration: duration counter. 2210 * duration: duration counter.
2209 * attacktype: aura's attacktype 2211 * attacktype: aura's attacktype
2210 * other_arch: archetype to drop where we attack 2212 * other_arch: archetype to drop where we attack
2211 */ 2213 */
2212void 2214void
2213move_aura (object *aura) 2215move_aura (object *aura)
2214{ 2216{
2215 /* auras belong in inventories */ 2217 /* auras belong in inventories */
2216 object *env = aura->env; 2218 object *env = aura->env;
2217 object *owner = aura->owner; 2219 object *owner = aura->owner;
2218 2220
2219 /* no matter what we've gotta remove the aura... 2221 /* no matter what we've gotta remove the aura...
2220 * we'll put it back if its time isn't up. 2222 * we'll put it back if its time isn't up.
2221 */ 2223 */
2222 aura->remove (); 2224 aura->remove ();
2223 2225
2224 /* exit if we're out of gas */ 2226 /* exit if we're out of gas */
2225 if (aura->duration-- < 0) 2227 if (aura->duration-- < 0)
2234 aura->destroy (); 2236 aura->destroy ();
2235 return; 2237 return;
2236 } 2238 }
2237 2239
2238 /* we need to jump out of the inventory for a bit 2240 /* we need to jump out of the inventory for a bit
2239 * in order to hit the map conveniently. 2241 * in order to hit the map conveniently.
2240 */ 2242 */
2241 aura->insert_at (env, aura); 2243 aura->insert_at (env, aura);
2242 2244
2243 for (int i = 1; i < 9; i++) 2245 for (int i = 1; i < 9; i++)
2244 { 2246 {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines