… | |
… | |
108 | ***************************************************************************/ |
108 | ***************************************************************************/ |
109 | |
109 | |
110 | /* Causes op to fork. op is the original bolt, tmp |
110 | /* Causes op to fork. op is the original bolt, tmp |
111 | * is the first piece of the fork. |
111 | * is the first piece of the fork. |
112 | */ |
112 | */ |
113 | void |
113 | static void |
114 | forklightning (object *op, object *tmp) |
114 | forklightning (object *op, object *tmp) |
115 | { |
115 | { |
116 | int new_dir = 1; /* direction or -1 for left, +1 for right 0 if no new bolt */ |
116 | int new_dir = 1; /* direction or -1 for left, +1 for right 0 if no new bolt */ |
117 | int t_dir; /* stores temporary dir calculation */ |
117 | int t_dir; /* stores temporary dir calculation */ |
118 | maptile *m; |
118 | maptile *m; |
… | |
… | |
277 | int mflags; |
277 | int mflags; |
278 | |
278 | |
279 | if (!spob->other_arch) |
279 | if (!spob->other_arch) |
280 | return 0; |
280 | return 0; |
281 | |
281 | |
282 | tmp = arch_to_object (spob->other_arch); |
282 | tmp = spob->other_arch->instance (); |
283 | if (tmp == NULL) |
283 | if (tmp == NULL) |
284 | return 0; |
284 | return 0; |
285 | |
285 | |
286 | /* peterm: level dependency for bolts */ |
286 | /* peterm: level dependency for bolts */ |
287 | tmp->stats.dam = spob->stats.dam + SP_level_dam_adjust (caster, spob); |
287 | tmp->stats.dam = spob->stats.dam + SP_level_dam_adjust (caster, spob); |
… | |
… | |
439 | if (op->destroyed ()) |
439 | if (op->destroyed ()) |
440 | return; |
440 | return; |
441 | } |
441 | } |
442 | |
442 | |
443 | /* other_arch contains what this explodes into */ |
443 | /* other_arch contains what this explodes into */ |
444 | tmp = arch_to_object (op->other_arch); |
444 | tmp = op->other_arch->instance (); |
445 | |
445 | |
446 | tmp->set_owner (op); |
446 | tmp->set_owner (op); |
447 | tmp->skill = op->skill; |
447 | tmp->skill = op->skill; |
448 | |
448 | |
449 | owner = op->owner; |
449 | owner = op->owner; |
… | |
… | |
660 | return 0; |
660 | return 0; |
661 | } |
661 | } |
662 | |
662 | |
663 | tmp->map = newmap; |
663 | tmp->map = newmap; |
664 | |
664 | |
|
|
665 | // in case the bullet has direction 0 we explode it in place. |
|
|
666 | // direction 0 is possible for instance when a poison cloud trap springs. |
|
|
667 | if (tmp->direction == 0) |
|
|
668 | { |
|
|
669 | if (tmp->other_arch |
|
|
670 | && (tmp = tmp->insert_at (tmp, op))) // insert before explode cleanly |
|
|
671 | explode_bullet (tmp); // explode object will/should remove tmp |
|
|
672 | else |
|
|
673 | tmp->destroy (); |
|
|
674 | |
|
|
675 | return 0; |
|
|
676 | } |
|
|
677 | |
665 | if (OB_TYPE_MOVE_BLOCK (tmp, GET_MAP_MOVE_BLOCK (tmp->map, tmp->x, tmp->y))) |
678 | if (OB_TYPE_MOVE_BLOCK (tmp, GET_MAP_MOVE_BLOCK (tmp->map, tmp->x, tmp->y))) |
666 | { |
679 | { |
667 | if (!QUERY_FLAG (tmp, FLAG_REFLECTING)) |
680 | if (!QUERY_FLAG (tmp, FLAG_REFLECTING)) |
668 | { |
681 | { |
669 | tmp->destroy (); |
682 | tmp->destroy (); |
… | |
… | |
690 | |
703 | |
691 | /* drops an object based on what is in the cone's "other_arch" */ |
704 | /* drops an object based on what is in the cone's "other_arch" */ |
692 | static void |
705 | static void |
693 | cone_drop (object *op) |
706 | cone_drop (object *op) |
694 | { |
707 | { |
695 | object *new_ob = arch_to_object (op->other_arch); |
708 | object *new_ob = op->other_arch->instance (); |
696 | |
709 | |
697 | new_ob->level = op->level; |
710 | new_ob->level = op->level; |
698 | new_ob->set_owner (op->owner); |
711 | new_ob->set_owner (op->owner); |
699 | |
712 | |
700 | /* preserve skill ownership */ |
713 | /* preserve skill ownership */ |
… | |
… | |
861 | |
874 | |
862 | if ((movetype & GET_MAP_MOVE_BLOCK (m, sx, sy)) == movetype) |
875 | if ((movetype & GET_MAP_MOVE_BLOCK (m, sx, sy)) == movetype) |
863 | continue; |
876 | continue; |
864 | |
877 | |
865 | success = 1; |
878 | success = 1; |
866 | tmp = arch_to_object (spell->other_arch); |
879 | tmp = spell->other_arch->instance (); |
867 | tmp->set_owner (op); |
880 | tmp->set_owner (op); |
868 | set_spell_skill (op, caster, spell, tmp); |
881 | set_spell_skill (op, caster, spell, tmp); |
869 | tmp->level = casting_level (caster, spell); |
882 | tmp->level = casting_level (caster, spell); |
870 | tmp->attacktype = spell->attacktype; |
883 | tmp->attacktype = spell->attacktype; |
871 | |
884 | |
… | |
… | |
973 | for (int i = 1; i < 9; i++) |
986 | for (int i = 1; i < 9; i++) |
974 | { |
987 | { |
975 | if (out_of_map (op->map, op->x + freearr_x[i], op->y + freearr_x[i])) |
988 | if (out_of_map (op->map, op->x + freearr_x[i], op->y + freearr_x[i])) |
976 | continue; |
989 | continue; |
977 | |
990 | |
978 | object *tmp = arch_to_object (at); |
991 | object *tmp = at->instance (); |
979 | tmp->direction = i; |
992 | tmp->direction = i; |
980 | tmp->range = op->range; |
993 | tmp->range = op->range; |
981 | tmp->stats.dam = op->stats.dam; |
994 | tmp->stats.dam = op->stats.dam; |
982 | tmp->duration = op->duration; |
995 | tmp->duration = op->duration; |
983 | tmp->attacktype = op->attacktype; |
996 | tmp->attacktype = op->attacktype; |
… | |
… | |
1017 | new_draw_info (NDI_UNIQUE, 0, op, "There is something in the way."); |
1030 | new_draw_info (NDI_UNIQUE, 0, op, "There is something in the way."); |
1018 | return 0; |
1031 | return 0; |
1019 | } |
1032 | } |
1020 | } |
1033 | } |
1021 | |
1034 | |
1022 | tmp = arch_to_object (spell->other_arch); |
1035 | tmp = spell->other_arch->instance (); |
1023 | |
1036 | |
1024 | /* level dependencies for bomb */ |
1037 | /* level dependencies for bomb */ |
1025 | tmp->range = spell->range + SP_level_range_adjust (caster, spell); |
1038 | tmp->range = spell->range + SP_level_range_adjust (caster, spell); |
1026 | tmp->stats.dam = spell->stats.dam + SP_level_dam_adjust (caster, spell); |
1039 | tmp->stats.dam = spell->stats.dam + SP_level_dam_adjust (caster, spell); |
1027 | tmp->duration = spell->duration + SP_level_duration_adjust (caster, spell); |
1040 | tmp->duration = spell->duration + SP_level_duration_adjust (caster, spell); |
… | |
… | |
1047 | * dir is the direction to look in. |
1060 | * dir is the direction to look in. |
1048 | * range is how far out to look. |
1061 | * range is how far out to look. |
1049 | * type is the type of spell - either SPELL_MANA or SPELL_GRACE. |
1062 | * type is the type of spell - either SPELL_MANA or SPELL_GRACE. |
1050 | * this info is used for blocked magic/unholy spaces. |
1063 | * this info is used for blocked magic/unholy spaces. |
1051 | */ |
1064 | */ |
1052 | object * |
1065 | static object * |
1053 | get_pointed_target (object *op, int dir, int range, int type) |
1066 | get_pointed_target (object *op, int dir, int range, int type) |
1054 | { |
1067 | { |
1055 | object *target; |
1068 | object *target; |
1056 | sint16 x, y; |
1069 | sint16 x, y; |
1057 | int dist, mflags; |
1070 | int dist, mflags; |
… | |
… | |
1121 | new_draw_info (NDI_UNIQUE, 0, op, "Your request is unheeded."); |
1134 | new_draw_info (NDI_UNIQUE, 0, op, "Your request is unheeded."); |
1122 | return 0; |
1135 | return 0; |
1123 | } |
1136 | } |
1124 | |
1137 | |
1125 | if (spell->other_arch) |
1138 | if (spell->other_arch) |
1126 | effect = arch_to_object (spell->other_arch); |
1139 | effect = spell->other_arch->instance (); |
1127 | else |
1140 | else |
1128 | return 0; |
1141 | return 0; |
1129 | |
1142 | |
1130 | /* tailor the effect by priest level and worshipped God */ |
1143 | /* tailor the effect by priest level and worshipped God */ |
1131 | effect->level = casting_level (caster, spell); |
1144 | effect->level = casting_level (caster, spell); |
… | |
… | |
1244 | * we do this by creating a force and inserting it in the |
1257 | * we do this by creating a force and inserting it in the |
1245 | * object. if time is 0, the object glows permanently. To truely |
1258 | * object. if time is 0, the object glows permanently. To truely |
1246 | * make this work for non-living objects, we would have to |
1259 | * make this work for non-living objects, we would have to |
1247 | * give them the capability to have an inventory. b.t. |
1260 | * give them the capability to have an inventory. b.t. |
1248 | */ |
1261 | */ |
1249 | int |
1262 | static int |
1250 | make_object_glow (object *op, int radius, int time) |
1263 | make_object_glow (object *op, int radius, int time) |
1251 | { |
1264 | { |
1252 | /* some things are unaffected... */ |
1265 | /* some things are unaffected... */ |
1253 | if (op->path_denied & PATH_LIGHT) |
1266 | if (op->path_denied & PATH_LIGHT) |
1254 | return 0; |
1267 | return 0; |
… | |
… | |
1292 | unordered_mapwalk (op, -range, -range, range, range) |
1305 | unordered_mapwalk (op, -range, -range, range, range) |
1293 | { |
1306 | { |
1294 | mapspace &ms = m->at (nx, ny); |
1307 | mapspace &ms = m->at (nx, ny); |
1295 | |
1308 | |
1296 | if (ms.flags () & P_IS_ALIVE) |
1309 | if (ms.flags () & P_IS_ALIVE) |
1297 | for (object *tmp = ms.bot; tmp; tmp = tmp->above) |
1310 | for (object *next, *tmp = ms.bot; tmp; tmp = next) |
|
|
1311 | { |
|
|
1312 | next = tmp->above; |
|
|
1313 | |
1298 | if (tmp->flag [FLAG_ALIVE] || tmp->is_player ()) |
1314 | if (tmp->flag [FLAG_ALIVE] || tmp->is_player ()) |
1299 | { |
1315 | { |
1300 | tmp = tmp->head_ (); |
1316 | tmp = tmp->head_ (); |
1301 | |
1317 | |
1302 | if ((friendly && !tmp->flag [FLAG_FRIENDLY] && !tmp->is_player ()) |
1318 | if ((friendly && !tmp->flag [FLAG_FRIENDLY] && !tmp->is_player ()) |
1303 | || (!friendly && (tmp->flag [FLAG_FRIENDLY] || tmp->is_player ()))) |
1319 | || (!friendly && (tmp->flag [FLAG_FRIENDLY] || tmp->is_player ()))) |
1304 | { |
1320 | { |
1305 | if (spell_ob->subtype == SP_DESTRUCTION) |
1321 | if (spell_ob->subtype == SP_DESTRUCTION) |
1306 | { |
1322 | { |
1307 | hit_player (tmp, dam, op, spell_ob->attacktype, 0); |
1323 | hit_player (tmp, dam, op, spell_ob->attacktype, 0); |
1308 | |
1324 | |
1309 | if (spell_ob->other_arch) |
1325 | if (spell_ob->other_arch) |
1310 | m->insert (arch_to_object (spell_ob->other_arch), nx, ny, op); |
1326 | m->insert (spell_ob->other_arch->instance (), nx, ny, op); |
1311 | } |
1327 | } |
1312 | else if (spell_ob->subtype == SP_FAERY_FIRE && tmp->resist [ATNR_MAGIC] != 100) |
1328 | else if (spell_ob->subtype == SP_FAERY_FIRE && tmp->resist [ATNR_MAGIC] != 100) |
1313 | { |
1329 | { |
1314 | if (make_object_glow (tmp, 1, dur) && spell_ob->other_arch) |
1330 | if (make_object_glow (tmp, 1, dur) && spell_ob->other_arch) |
1315 | m->insert (arch_to_object (spell_ob->other_arch), nx, ny, op); |
1331 | m->insert (spell_ob->other_arch->instance (), nx, ny, op); |
1316 | } |
1332 | } |
1317 | } |
1333 | } |
1318 | } |
1334 | } |
|
|
1335 | } |
1319 | } |
1336 | } |
1320 | |
1337 | |
1321 | op->skill = skill; |
1338 | op->skill = skill; |
1322 | return 1; |
1339 | return 1; |
1323 | } |
1340 | } |
… | |
… | |
1325 | /*************************************************************************** |
1342 | /*************************************************************************** |
1326 | * |
1343 | * |
1327 | * CURSE |
1344 | * CURSE |
1328 | * |
1345 | * |
1329 | ***************************************************************************/ |
1346 | ***************************************************************************/ |
1330 | |
|
|
1331 | int |
1347 | int |
1332 | cast_curse (object *op, object *caster, object *spell_ob, int dir) |
1348 | cast_curse (object *op, object *caster, object *spell_ob, int dir) |
1333 | { |
1349 | { |
1334 | object *god = find_god (determine_god (op)); |
1350 | object *god = find_god (determine_god (op)); |
1335 | object *tmp, *force; |
1351 | object *tmp, *force; |
… | |
… | |
1413 | force->stats.wc = spell_ob->stats.wc; |
1429 | force->stats.wc = spell_ob->stats.wc; |
1414 | |
1430 | |
1415 | change_abil (tmp, force); /* Mostly to display any messages */ |
1431 | change_abil (tmp, force); /* Mostly to display any messages */ |
1416 | insert_ob_in_ob (force, tmp); |
1432 | insert_ob_in_ob (force, tmp); |
1417 | tmp->update_stats (); |
1433 | tmp->update_stats (); |
|
|
1434 | |
1418 | return 1; |
1435 | return 1; |
1419 | |
|
|
1420 | } |
1436 | } |
1421 | |
1437 | |
1422 | /********************************************************************** |
1438 | /********************************************************************** |
1423 | * mood change |
1439 | * mood change |
1424 | * Arguably, this may or may not be an attack spell. But since it |
1440 | * Arguably, this may or may not be an attack spell. But since it |
… | |
… | |
1525 | Ryo, august 14th |
1541 | Ryo, august 14th |
1526 | */ |
1542 | */ |
1527 | if (head->level > level) |
1543 | if (head->level > level) |
1528 | continue; |
1544 | continue; |
1529 | |
1545 | |
1530 | if (random_roll (0, 100, caster, PREFER_LOW) >= (20 + MIN (50, 2 * (level - head->level)))) |
1546 | if (random_roll (0, 100, caster, PREFER_LOW) >= (20 + min (50, 2 * (level - head->level)))) |
1531 | /* Failed, no effect */ |
1547 | /* Failed, no effect */ |
1532 | continue; |
1548 | continue; |
1533 | } |
1549 | } |
1534 | |
1550 | |
1535 | /* Done with saving throw. Now start affecting the monster */ |
1551 | /* Done with saving throw. Now start affecting the monster */ |
… | |
… | |
1577 | head->stats.exp = 0; |
1593 | head->stats.exp = 0; |
1578 | } |
1594 | } |
1579 | |
1595 | |
1580 | /* If a monster was effected, put an effect in */ |
1596 | /* If a monster was effected, put an effect in */ |
1581 | if (done_one && spell->other_arch) |
1597 | if (done_one && spell->other_arch) |
1582 | m->insert (arch_to_object (spell->other_arch), nx, ny, op); |
1598 | m->insert (spell->other_arch->instance (), nx, ny, op); |
1583 | } |
1599 | } |
1584 | |
1600 | |
1585 | return 1; |
1601 | return 1; |
1586 | } |
1602 | } |
1587 | |
1603 | |
… | |
… | |
1670 | hit_map (op, j, op->attacktype, 1); |
1686 | hit_map (op, j, op->attacktype, 1); |
1671 | } |
1687 | } |
1672 | |
1688 | |
1673 | /* insert the other arch */ |
1689 | /* insert the other arch */ |
1674 | if (op->other_arch && !(OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, hx, hy)))) |
1690 | if (op->other_arch && !(OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, hx, hy)))) |
1675 | m->insert (arch_to_object (op->other_arch), hx, hy, op); |
1691 | m->insert (op->other_arch->instance (), hx, hy, op); |
1676 | } |
1692 | } |
1677 | |
1693 | |
1678 | /* restore to the center location and damage */ |
1694 | /* restore to the center location and damage */ |
1679 | op->stats.dam = dam_save; |
1695 | op->stats.dam = dam_save; |
1680 | |
1696 | |
… | |
… | |
1896 | return 0; |
1912 | return 0; |
1897 | } |
1913 | } |
1898 | } |
1914 | } |
1899 | |
1915 | |
1900 | /* ok, looks groovy to just insert a new light on the map */ |
1916 | /* ok, looks groovy to just insert a new light on the map */ |
1901 | tmp = arch_to_object (spell->other_arch); |
1917 | tmp = spell->other_arch->instance (); |
1902 | if (!tmp) |
1918 | if (!tmp) |
1903 | { |
1919 | { |
1904 | LOG (llevError, "Error: spell arch for cast_light() missing.\n"); |
1920 | LOG (llevError, "Error: spell arch for cast_light() missing.\n"); |
1905 | return 0; |
1921 | return 0; |
1906 | } |
1922 | } |
… | |
… | |
1972 | { |
1988 | { |
1973 | /* search this square for a victim */ |
1989 | /* search this square for a victim */ |
1974 | for (walk = GET_MAP_OB (m, x, y); walk; walk = walk->above) |
1990 | for (walk = GET_MAP_OB (m, x, y); walk; walk = walk->above) |
1975 | if (QUERY_FLAG (walk, FLAG_MONSTER) || (walk->type == PLAYER)) |
1991 | if (QUERY_FLAG (walk, FLAG_MONSTER) || (walk->type == PLAYER)) |
1976 | { /* found a victim */ |
1992 | { /* found a victim */ |
1977 | object *disease = arch_to_object (spell->other_arch); |
1993 | object *disease = spell->other_arch->instance (); |
1978 | |
1994 | |
1979 | disease->set_owner (op); |
1995 | disease->set_owner (op); |
1980 | set_spell_skill (op, caster, spell, disease); |
1996 | set_spell_skill (op, caster, spell, disease); |
1981 | disease->stats.exp = 0; |
1997 | disease->stats.exp = 0; |
1982 | disease->level = casting_level (caster, spell); |
1998 | disease->level = casting_level (caster, spell); |
… | |
… | |
2032 | if (infect_object (walk, disease, 1)) |
2048 | if (infect_object (walk, disease, 1)) |
2033 | { |
2049 | { |
2034 | new_draw_info_format (NDI_UNIQUE, 0, op, "You inflict %s on %s!", &disease->name, &walk->name); |
2050 | new_draw_info_format (NDI_UNIQUE, 0, op, "You inflict %s on %s!", &disease->name, &walk->name); |
2035 | |
2051 | |
2036 | disease->destroy (); /* don't need this one anymore */ |
2052 | disease->destroy (); /* don't need this one anymore */ |
2037 | walk->map->insert (get_archetype ("detect_magic"), x, y, op); |
2053 | walk->map->insert (get_archetype (shstr_detect_magic), x, y, op); |
2038 | return 1; |
2054 | return 1; |
2039 | } |
2055 | } |
2040 | |
2056 | |
2041 | disease->destroy (); |
2057 | disease->destroy (); |
2042 | } |
2058 | } |