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 (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
4 | * Copyright (©) 2005,2006,2007,2008,2009 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
5 | * Copyright (©) 2002-2003,2007 Mark Wedel & Crossfire Development Team |
5 | * Copyright (©) 2002-2003,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 |
9 | * it under the terms of the GNU General Public License as published by |
9 | * it under the terms of the GNU General Public License as published by |
… | |
… | |
828 | */ |
828 | */ |
829 | movetype = spell->other_arch->move_type; |
829 | movetype = spell->other_arch->move_type; |
830 | |
830 | |
831 | for (i = range_min; i <= range_max; i++) |
831 | for (i = range_min; i <= range_max; i++) |
832 | { |
832 | { |
833 | sint16 x, y, d; |
833 | sint16 x, y; |
834 | |
834 | |
835 | /* We can't use absdir here, because it never returns |
835 | /* We can't use absdir here, because it never returns |
836 | * 0. If this is a rune, we want to hit the person on top |
836 | * 0. If this is a rune, we want to hit the person on top |
837 | * of the trap (d==0). If it is not a rune, then we don't want |
837 | * of the trap (d==0). If it is not a rune, then we don't want |
838 | * to hit that person. |
838 | * to hit that person. |
839 | */ |
839 | */ |
840 | d = dir + i; |
840 | int d = dir ? absdir (dir + i) : i; |
841 | while (d < 0) |
|
|
842 | d += 8; |
|
|
843 | while (d > 8) |
|
|
844 | d -= 8; |
|
|
845 | |
841 | |
846 | /* If it's not a rune, we don't want to blast the caster. |
842 | /* If it's not a rune, we don't want to blast the caster. |
847 | * In that case, we have to see - if dir is specified, |
843 | * In that case, we have to see - if dir is specified, |
848 | * turn this into direction 8. If dir is not specified (all |
844 | * turn this into direction 8. If dir is not specified (all |
849 | * direction) skip - otherwise, one line would do more damage |
845 | * direction) skip - otherwise, one line would do more damage |
… | |
… | |
951 | |
947 | |
952 | object *env = op->outer_env (); |
948 | object *env = op->outer_env (); |
953 | |
949 | |
954 | if (op->env) |
950 | if (op->env) |
955 | { |
951 | { |
956 | if (env->map == NULL) |
952 | if (!env->map) |
957 | return; |
953 | return; |
958 | |
954 | |
959 | if (!(op = op->insert_at (env, op))) |
955 | if (!(op = op->insert_at (env, op))) |
960 | return; |
956 | return; |
961 | } |
957 | } |
962 | |
958 | |
963 | // elmex Tue Aug 15 17:46:51 CEST 2006: Prevent bomb from exploding |
959 | // elmex Tue Aug 15 17:46:51 CEST 2006: Prevent bomb from exploding |
964 | // on a safe map. I don't like this special casing, but it seems to be neccessary |
960 | // on a safe map. I don't like this special casing, but it seems to be neccessary |
965 | // as bombs can be carried. |
961 | // as bombs can be carried. |
966 | if (get_map_flags (op->map, NULL, op->x, op->y, NULL, NULL) & P_SAFE) |
962 | if (op->ms ().flags () & P_SAFE) |
967 | { |
963 | { |
968 | op->destroy (); |
964 | op->destroy (); |
969 | return; |
965 | return; |
970 | } |
966 | } |
971 | |
967 | |
… | |
… | |
1115 | * interesting spell. |
1111 | * interesting spell. |
1116 | * if it is a cleric spell, you need a god, and the creature |
1112 | * if it is a cleric spell, you need a god, and the creature |
1117 | * can't be friendly to your god. |
1113 | * can't be friendly to your god. |
1118 | */ |
1114 | */ |
1119 | |
1115 | |
1120 | if (!target || QUERY_FLAG (target, FLAG_REFL_SPELL) |
1116 | if (!target |
|
|
1117 | || target->flag [FLAG_REFL_SPELL] |
1121 | || (!god && spell->stats.grace) |
1118 | || (!god && spell->stats.grace) |
1122 | || (target->title && god && !strcmp (target->title, god->name)) || (target->race && god && strstr (target->race, god->race))) |
1119 | || (god && target->title == god->name) |
|
|
1120 | || (god && target->race.contains (god->race))) |
1123 | { |
1121 | { |
1124 | new_draw_info (NDI_UNIQUE, 0, op, "Your request is unheeded."); |
1122 | new_draw_info (NDI_UNIQUE, 0, op, "Your request is unheeded."); |
1125 | return 0; |
1123 | return 0; |
1126 | } |
1124 | } |
1127 | |
1125 | |
… | |
… | |
1134 | effect->level = casting_level (caster, spell); |
1132 | effect->level = casting_level (caster, spell); |
1135 | effect->attacktype = spell->attacktype; |
1133 | effect->attacktype = spell->attacktype; |
1136 | if (effect->attacktype & (AT_HOLYWORD | AT_GODPOWER)) |
1134 | if (effect->attacktype & (AT_HOLYWORD | AT_GODPOWER)) |
1137 | { |
1135 | { |
1138 | if (tailor_god_spell (effect, op)) |
1136 | if (tailor_god_spell (effect, op)) |
1139 | new_draw_info_format (NDI_UNIQUE, 0, op, "%s answers your call!", determine_god (op)); |
1137 | new_draw_info_format (NDI_UNIQUE, 0, op, "%s answers your call!", (const char *)determine_god (op)); |
1140 | else |
1138 | else |
1141 | { |
1139 | { |
1142 | new_draw_info (NDI_UNIQUE, 0, op, "Your request is ignored."); |
1140 | new_draw_info (NDI_UNIQUE, 0, op, "Your request is ignored."); |
1143 | return 0; |
1141 | return 0; |
1144 | } |
1142 | } |
… | |
… | |
1258 | |
1256 | |
1259 | object *tmp = get_archetype (FORCE_NAME); |
1257 | object *tmp = get_archetype (FORCE_NAME); |
1260 | tmp->speed = 0.01; |
1258 | tmp->speed = 0.01; |
1261 | tmp->stats.food = time; |
1259 | tmp->stats.food = time; |
1262 | SET_FLAG (tmp, FLAG_IS_USED_UP); |
1260 | SET_FLAG (tmp, FLAG_IS_USED_UP); |
1263 | tmp->glow_radius = min (MAX_LIGHT_RADIUS, radius); |
1261 | tmp->set_glow_radius (min (MAX_LIGHT_RADIUS, radius)); |
1264 | tmp = insert_ob_in_ob (tmp, op); |
1262 | tmp = insert_ob_in_ob (tmp, op); |
1265 | |
1263 | |
1266 | if (tmp->glow_radius > op->glow_radius) |
1264 | if (tmp->glow_radius > op->glow_radius) |
1267 | op->glow_radius = tmp->glow_radius; |
1265 | op->set_glow_radius (tmp->glow_radius); |
1268 | |
1266 | |
1269 | return 1; |
1267 | return 1; |
1270 | } |
1268 | } |
1271 | |
1269 | |
1272 | int |
1270 | int |
… | |
… | |
1449 | * so even if the player doesn't worship a god, if race=GOD_.., it |
1447 | * so even if the player doesn't worship a god, if race=GOD_.., it |
1450 | * won't ever match anything. |
1448 | * won't ever match anything. |
1451 | */ |
1449 | */ |
1452 | if (!spell->race) |
1450 | if (!spell->race) |
1453 | race = NULL; |
1451 | race = NULL; |
1454 | else if (god && !strcmp (spell->race, "GOD_SLAYING")) |
1452 | else if (god && spell->race == shstr_GOD_SLAYING) |
1455 | race = god->slaying; |
1453 | race = god->slaying; |
1456 | else if (god && !strcmp (spell->race, "GOD_FRIEND")) |
1454 | else if (god && spell->race == shstr_GOD_FRIEND) |
1457 | race = god->race; |
1455 | race = god->race; |
1458 | else |
1456 | else |
1459 | race = spell->race; |
1457 | race = spell->race; |
1460 | |
1458 | |
1461 | unordered_mapwalk (op, -range, -range, range, range) |
1459 | unordered_mapwalk (op, -range, -range, range, range) |
… | |
… | |
1909 | } |
1907 | } |
1910 | |
1908 | |
1911 | tmp->stats.food = spell->duration + SP_level_duration_adjust (caster, spell); |
1909 | tmp->stats.food = spell->duration + SP_level_duration_adjust (caster, spell); |
1912 | |
1910 | |
1913 | if (tmp->glow_radius) |
1911 | if (tmp->glow_radius) |
1914 | tmp->glow_radius = min (MAX_LIGHT_RADIUS, spell->range + SP_level_range_adjust (caster, spell)); |
1912 | tmp->set_glow_radius ( |
|
|
1913 | clamp (spell->range + SP_level_range_adjust (caster, spell), 1, MAX_LIGHT_RADIUS) |
|
|
1914 | ); |
1915 | |
1915 | |
1916 | if (dir) |
1916 | if (dir) |
1917 | m->insert (tmp, x, y, op); |
1917 | m->insert (tmp, x, y, op); |
1918 | else |
1918 | else |
1919 | caster->outer_env ()->insert (tmp); |
1919 | caster->outer_env ()->insert (tmp); |