… | |
… | |
165 | sint16 x, y; |
165 | sint16 x, y; |
166 | maptile *m; |
166 | maptile *m; |
167 | |
167 | |
168 | if (--op->duration < 0) |
168 | if (--op->duration < 0) |
169 | { |
169 | { |
170 | op->destroy (); |
170 | op->drop_and_destroy (); |
171 | return; |
171 | return; |
172 | } |
172 | } |
173 | |
173 | |
174 | hit_map (op, 0, op->attacktype, 1); |
174 | hit_map (op, 0, op->attacktype, 1); |
175 | |
175 | |
… | |
… | |
307 | |
307 | |
308 | maptile *newmap; |
308 | maptile *newmap; |
309 | mflags = get_map_flags (tmp->map, &newmap, tmp->x, tmp->y, &tmp->x, &tmp->y); |
309 | mflags = get_map_flags (tmp->map, &newmap, tmp->x, tmp->y, &tmp->x, &tmp->y); |
310 | if (mflags & P_OUT_OF_MAP) |
310 | if (mflags & P_OUT_OF_MAP) |
311 | { |
311 | { |
312 | tmp->destroy (); |
312 | tmp->drop_and_destroy (); |
313 | return 0; |
313 | return 0; |
314 | } |
314 | } |
315 | |
315 | |
316 | tmp->map = newmap; |
316 | tmp->map = newmap; |
317 | |
317 | |
318 | if (OB_TYPE_MOVE_BLOCK (tmp, GET_MAP_MOVE_BLOCK (tmp->map, tmp->x, tmp->y))) |
318 | if (OB_TYPE_MOVE_BLOCK (tmp, GET_MAP_MOVE_BLOCK (tmp->map, tmp->x, tmp->y))) |
319 | { |
319 | { |
320 | if (!QUERY_FLAG (tmp, FLAG_REFLECTING)) |
320 | if (!QUERY_FLAG (tmp, FLAG_REFLECTING)) |
321 | { |
321 | { |
322 | tmp->destroy (); |
322 | tmp->drop_and_destroy (); |
323 | return 0; |
323 | return 0; |
324 | } |
324 | } |
325 | |
325 | |
326 | tmp->x = op->x; |
326 | tmp->x = op->x; |
327 | tmp->y = op->y; |
327 | tmp->y = op->y; |
… | |
… | |
393 | void |
393 | void |
394 | explode_bullet (object *op) |
394 | explode_bullet (object *op) |
395 | { |
395 | { |
396 | object *tmp, *owner; |
396 | object *tmp, *owner; |
397 | |
397 | |
398 | if (op->other_arch == NULL) |
398 | if (!op->other_arch) |
399 | { |
399 | { |
400 | LOG (llevError, "BUG: explode_bullet(): op without other_arch\n"); |
400 | LOG (llevError, "BUG: explode_bullet(): op without other_arch\n"); |
401 | op->destroy (); |
401 | op->destroy (); |
402 | return; |
402 | return; |
403 | } |
403 | } |
… | |
… | |
445 | tmp->set_owner (op); |
445 | tmp->set_owner (op); |
446 | tmp->skill = op->skill; |
446 | tmp->skill = op->skill; |
447 | |
447 | |
448 | owner = op->owner; |
448 | owner = op->owner; |
449 | |
449 | |
450 | if ((tmp->attacktype & AT_HOLYWORD || tmp->attacktype & AT_GODPOWER) && owner && !tailor_god_spell (tmp, owner)) |
450 | if ((tmp->attacktype & AT_HOLYWORD |
|
|
451 | || tmp->attacktype & AT_GODPOWER) |
|
|
452 | && owner |
|
|
453 | && !tailor_god_spell (tmp, owner)) |
451 | { |
454 | { |
452 | op->destroy (); |
455 | op->destroy (); |
453 | return; |
456 | return; |
454 | } |
457 | } |
455 | |
458 | |
… | |
… | |
521 | { |
524 | { |
522 | if (QUERY_FLAG (tmp, FLAG_ALIVE)) |
525 | if (QUERY_FLAG (tmp, FLAG_ALIVE)) |
523 | { |
526 | { |
524 | dam = hit_player (tmp, op->stats.dam, op, op->attacktype, 1); |
527 | dam = hit_player (tmp, op->stats.dam, op, op->attacktype, 1); |
525 | |
528 | |
|
|
529 | // TODO: can't understand the following if's |
526 | if (op->destroyed () || !tmp->destroyed () || (op->stats.dam -= dam) < 0) |
530 | if (op->destroyed () || !tmp->destroyed () || (op->stats.dam -= dam) < 0) |
527 | { |
531 | { |
528 | if (!QUERY_FLAG (op, FLAG_REMOVED)) |
532 | if (!QUERY_FLAG (op, FLAG_REMOVED)) |
529 | { |
533 | { |
530 | op->destroy (); |
534 | op->destroy (); |
… | |
… | |
733 | } |
737 | } |
734 | #endif |
738 | #endif |
735 | |
739 | |
736 | hit_map (op, 0, op->attacktype, 0); |
740 | hit_map (op, 0, op->attacktype, 0); |
737 | |
741 | |
|
|
742 | if (!op->is_on_map ()) |
|
|
743 | return; |
|
|
744 | |
738 | /* Check to see if we should push anything. |
745 | /* Check to see if we should push anything. |
739 | * Spell objects with weight push whatever they encounter to some |
746 | * Spell objects with weight push whatever they encounter to some |
740 | * degree. |
747 | * degree. |
741 | */ |
748 | */ |
742 | if (op->weight) |
749 | if (op->weight) |
|
|
750 | { |
743 | check_spell_knockback (op); |
751 | check_spell_knockback (op); |
744 | |
752 | |
745 | if (op->destroyed ()) |
753 | if (!op->is_on_map ()) |
746 | return; |
754 | return; |
|
|
755 | } |
747 | |
756 | |
748 | if (op->duration-- < 0) |
757 | if (op->duration-- < 0) |
749 | { |
758 | { |
750 | op->destroy (); |
759 | op->destroy (); |
751 | return; |
760 | return; |
… | |
… | |
822 | for (i = range_min; i <= range_max; i++) |
831 | for (i = range_min; i <= range_max; i++) |
823 | { |
832 | { |
824 | sint16 x, y, d; |
833 | sint16 x, y, d; |
825 | |
834 | |
826 | /* We can't use absdir here, because it never returns |
835 | /* We can't use absdir here, because it never returns |
827 | * 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 |
828 | * 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 |
829 | * to hit that person. |
838 | * to hit that person. |
830 | */ |
839 | */ |
831 | d = dir + i; |
840 | d = (dir + i) % 9; |
832 | while (d < 0) |
|
|
833 | d += 8; |
|
|
834 | while (d > 8) |
|
|
835 | d -= 8; |
|
|
836 | |
841 | |
837 | /* 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. |
838 | * In that case, we have to see - if dir is specified, |
843 | * In that case, we have to see - if dir is specified, |
839 | * turn this into direction 8. If dir is not specified (all |
844 | * turn this into direction 8. If dir is not specified (all |
840 | * direction) skip - otherwise, one line would do more damage |
845 | * direction) skip - otherwise, one line would do more damage |
… | |
… | |
860 | |
865 | |
861 | success = 1; |
866 | success = 1; |
862 | tmp = arch_to_object (spell->other_arch); |
867 | tmp = arch_to_object (spell->other_arch); |
863 | tmp->set_owner (op); |
868 | tmp->set_owner (op); |
864 | set_spell_skill (op, caster, spell, tmp); |
869 | set_spell_skill (op, caster, spell, tmp); |
865 | tmp->level = caster_level (caster, spell); |
870 | tmp->level = casting_level (caster, spell); |
866 | tmp->attacktype = spell->attacktype; |
871 | tmp->attacktype = spell->attacktype; |
867 | |
872 | |
868 | /* holy word stuff */ |
873 | /* holy word stuff */ |
869 | if ((tmp->attacktype & AT_HOLYWORD) || (tmp->attacktype & AT_GODPOWER)) |
874 | if ((tmp->attacktype & AT_HOLYWORD) || (tmp->attacktype & AT_GODPOWER)) |
870 | if (!tailor_god_spell (tmp, op)) |
875 | if (!tailor_god_spell (tmp, op)) |
… | |
… | |
999 | int mflags; |
1004 | int mflags; |
1000 | sint16 dx = op->x + freearr_x[dir], dy = op->y + freearr_y[dir]; |
1005 | sint16 dx = op->x + freearr_x[dir], dy = op->y + freearr_y[dir]; |
1001 | maptile *m; |
1006 | maptile *m; |
1002 | |
1007 | |
1003 | mflags = get_map_flags (op->map, &m, dx, dy, &dx, &dy); |
1008 | mflags = get_map_flags (op->map, &m, dx, dy, &dx, &dy); |
|
|
1009 | |
|
|
1010 | // when creating a bomb below ourself it should always work, even |
|
|
1011 | // when movement is blocked (somehow we got here, somehow we are here, |
|
|
1012 | // so we should also be able to make a bomb here). (originally added |
|
|
1013 | // to fix create bomb traps in doors, which cast with dir=0). |
|
|
1014 | if (dir) |
|
|
1015 | { |
1004 | if ((mflags & P_OUT_OF_MAP) || (GET_MAP_MOVE_BLOCK (m, dx, dy) & MOVE_WALK)) |
1016 | if ((mflags & P_OUT_OF_MAP) || (GET_MAP_MOVE_BLOCK (m, dx, dy) & MOVE_WALK)) |
1005 | { |
1017 | { |
1006 | new_draw_info (NDI_UNIQUE, 0, op, "There is something in the way."); |
1018 | new_draw_info (NDI_UNIQUE, 0, op, "There is something in the way."); |
1007 | return 0; |
1019 | return 0; |
|
|
1020 | } |
1008 | } |
1021 | } |
1009 | |
1022 | |
1010 | tmp = arch_to_object (spell->other_arch); |
1023 | tmp = arch_to_object (spell->other_arch); |
1011 | |
1024 | |
1012 | /* level dependencies for bomb */ |
1025 | /* level dependencies for bomb */ |
… | |
… | |
1098 | * interesting spell. |
1111 | * interesting spell. |
1099 | * 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 |
1100 | * can't be friendly to your god. |
1113 | * can't be friendly to your god. |
1101 | */ |
1114 | */ |
1102 | |
1115 | |
1103 | if (!target || QUERY_FLAG (target, FLAG_REFL_SPELL) |
1116 | if (!target |
|
|
1117 | || target->flag [FLAG_REFL_SPELL] |
1104 | || (!god && spell->stats.grace) |
1118 | || (!god && spell->stats.grace) |
1105 | || (target->title && god && !strcmp (target->title, god->name)) || (target->race && god && strstr (target->race, god->race))) |
1119 | || (target->title && god && target->title == god->name) |
|
|
1120 | || (target->race && god && target->race.contains (god->race))) |
1106 | { |
1121 | { |
1107 | new_draw_info (NDI_UNIQUE, 0, op, "Your request is unheeded."); |
1122 | new_draw_info (NDI_UNIQUE, 0, op, "Your request is unheeded."); |
1108 | return 0; |
1123 | return 0; |
1109 | } |
1124 | } |
1110 | |
1125 | |
… | |
… | |
1112 | effect = arch_to_object (spell->other_arch); |
1127 | effect = arch_to_object (spell->other_arch); |
1113 | else |
1128 | else |
1114 | return 0; |
1129 | return 0; |
1115 | |
1130 | |
1116 | /* tailor the effect by priest level and worshipped God */ |
1131 | /* tailor the effect by priest level and worshipped God */ |
1117 | effect->level = caster_level (caster, spell); |
1132 | effect->level = casting_level (caster, spell); |
1118 | effect->attacktype = spell->attacktype; |
1133 | effect->attacktype = spell->attacktype; |
1119 | if (effect->attacktype & (AT_HOLYWORD | AT_GODPOWER)) |
1134 | if (effect->attacktype & (AT_HOLYWORD | AT_GODPOWER)) |
1120 | { |
1135 | { |
1121 | if (tailor_god_spell (effect, op)) |
1136 | if (tailor_god_spell (effect, op)) |
1122 | 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)); |
1123 | else |
1138 | else |
1124 | { |
1139 | { |
1125 | new_draw_info (NDI_UNIQUE, 0, op, "Your request is ignored."); |
1140 | new_draw_info (NDI_UNIQUE, 0, op, "Your request is ignored."); |
1126 | return 0; |
1141 | return 0; |
1127 | } |
1142 | } |
… | |
… | |
1179 | void |
1194 | void |
1180 | move_missile (object *op) |
1195 | move_missile (object *op) |
1181 | { |
1196 | { |
1182 | if (op->range-- <= 0) |
1197 | if (op->range-- <= 0) |
1183 | { |
1198 | { |
1184 | op->destroy (); |
1199 | op->drop_and_destroy (); |
1185 | return; |
1200 | return; |
1186 | } |
1201 | } |
1187 | |
1202 | |
1188 | mapxy pos (op); |
1203 | mapxy pos (op); |
1189 | pos.move (op->direction); |
1204 | pos.move (op->direction); |
… | |
… | |
1241 | |
1256 | |
1242 | object *tmp = get_archetype (FORCE_NAME); |
1257 | object *tmp = get_archetype (FORCE_NAME); |
1243 | tmp->speed = 0.01; |
1258 | tmp->speed = 0.01; |
1244 | tmp->stats.food = time; |
1259 | tmp->stats.food = time; |
1245 | SET_FLAG (tmp, FLAG_IS_USED_UP); |
1260 | SET_FLAG (tmp, FLAG_IS_USED_UP); |
1246 | tmp->glow_radius = radius; |
|
|
1247 | if (tmp->glow_radius > MAX_LIGHT_RADII) |
|
|
1248 | tmp->glow_radius = MAX_LIGHT_RADII; |
1261 | tmp->glow_radius = min (MAX_LIGHT_RADIUS, radius); |
1249 | |
|
|
1250 | tmp = insert_ob_in_ob (tmp, op); |
1262 | tmp = insert_ob_in_ob (tmp, op); |
1251 | |
1263 | |
1252 | if (tmp->glow_radius > op->glow_radius) |
1264 | if (tmp->glow_radius > op->glow_radius) |
1253 | op->glow_radius = tmp->glow_radius; |
1265 | op->glow_radius = tmp->glow_radius; |
1254 | |
1266 | |
… | |
… | |
1256 | } |
1268 | } |
1257 | |
1269 | |
1258 | int |
1270 | int |
1259 | cast_destruction (object *op, object *caster, object *spell_ob) |
1271 | cast_destruction (object *op, object *caster, object *spell_ob) |
1260 | { |
1272 | { |
1261 | int i, j, range, mflags, friendly = 0, dam, dur; |
|
|
1262 | sint16 sx, sy; |
|
|
1263 | maptile *m; |
|
|
1264 | object *tmp; |
|
|
1265 | const char *skill; |
|
|
1266 | |
|
|
1267 | range = spell_ob->range + SP_level_range_adjust (caster, spell_ob); |
1273 | int range = spell_ob->range + SP_level_range_adjust (caster, spell_ob); |
1268 | dam = spell_ob->stats.dam + SP_level_dam_adjust (caster, spell_ob); |
1274 | int dam = spell_ob->stats.dam + SP_level_dam_adjust (caster, spell_ob); |
1269 | dur = spell_ob->duration + SP_level_duration_adjust (caster, spell_ob); |
1275 | int dur = spell_ob->duration + SP_level_duration_adjust (caster, spell_ob); |
1270 | if (QUERY_FLAG (op, FLAG_FRIENDLY) || op->type == PLAYER) |
1276 | |
1271 | friendly = 1; |
1277 | bool friendly = op->flag [FLAG_FRIENDLY] || op->is_player (); |
1272 | |
1278 | |
1273 | /* destruction doesn't use another spell object, so we need |
1279 | /* destruction doesn't use another spell object, so we need |
1274 | * update op's skill pointer so that exp is properly awarded. |
1280 | * update op's skill pointer so that exp is properly awarded. |
1275 | * We do some shortcuts here - since this is just temporary |
|
|
1276 | * and we'll reset the values back, we don't need to go through |
|
|
1277 | * the full share string/free_string route. |
|
|
1278 | */ |
1281 | */ |
1279 | skill = op->skill; |
1282 | const shstr skill = op->skill; |
|
|
1283 | |
1280 | if (caster == op) |
1284 | if (caster == op) |
1281 | op->skill = spell_ob->skill; |
1285 | op->skill = spell_ob->skill; |
1282 | else if (caster->skill) |
1286 | else if (caster->skill) |
1283 | op->skill = caster->skill; |
1287 | op->skill = caster->skill; |
1284 | else |
1288 | else |
1285 | op->skill = NULL; |
1289 | op->skill = 0; |
1286 | |
1290 | |
1287 | op->change_skill (find_skill_by_name (op, op->skill)); |
1291 | op->change_skill (find_skill_by_name (op, op->skill)); |
1288 | |
1292 | |
1289 | for (i = -range; i <= range; i++) |
1293 | unordered_mapwalk (op, -range, -range, range, range) |
1290 | { |
1294 | { |
1291 | for (j = -range; j <= range; j++) |
1295 | mapspace &ms = m->at (nx, ny); |
1292 | { |
|
|
1293 | m = op->map; |
|
|
1294 | sx = op->x + i; |
|
|
1295 | sy = op->y + j; |
|
|
1296 | |
1296 | |
1297 | mflags = get_map_flags (m, &m, sx, sy, &sx, &sy); |
|
|
1298 | if (mflags & P_OUT_OF_MAP) |
|
|
1299 | continue; |
|
|
1300 | |
|
|
1301 | if (mflags & P_IS_ALIVE) |
1297 | if (ms.flags () & P_IS_ALIVE) |
|
|
1298 | for (object *tmp = ms.bot; tmp; tmp = tmp->above) |
|
|
1299 | if (tmp->flag [FLAG_ALIVE] || tmp->is_player ()) |
1302 | { |
1300 | { |
1303 | for (tmp = GET_MAP_OB (m, sx, sy); tmp; tmp = tmp->above) |
1301 | tmp = tmp->head_ (); |
1304 | if (QUERY_FLAG (tmp, FLAG_ALIVE) || tmp->type == PLAYER) |
|
|
1305 | break; |
|
|
1306 | |
1302 | |
1307 | if (tmp) |
1303 | if ((friendly && !tmp->flag [FLAG_FRIENDLY] && !tmp->is_player ()) |
|
|
1304 | || (!friendly && (tmp->flag [FLAG_FRIENDLY] || tmp->is_player ()))) |
1308 | { |
1305 | { |
1309 | if (tmp->head) |
1306 | if (spell_ob->subtype == SP_DESTRUCTION) |
1310 | tmp = tmp->head; |
|
|
1311 | |
|
|
1312 | if ((friendly && !QUERY_FLAG (tmp, FLAG_FRIENDLY) && tmp->type != PLAYER) || |
|
|
1313 | (!friendly && (QUERY_FLAG (tmp, FLAG_FRIENDLY) || tmp->type == PLAYER))) |
|
|
1314 | { |
1307 | { |
1315 | if (spell_ob->subtype == SP_DESTRUCTION) |
|
|
1316 | { |
|
|
1317 | hit_player (tmp, dam, op, spell_ob->attacktype, 0); |
1308 | hit_player (tmp, dam, op, spell_ob->attacktype, 0); |
1318 | |
1309 | |
1319 | if (spell_ob->other_arch) |
1310 | if (spell_ob->other_arch) |
1320 | m->insert (arch_to_object (spell_ob->other_arch), sx, sy, op); |
1311 | m->insert (arch_to_object (spell_ob->other_arch), nx, ny, op); |
1321 | } |
1312 | } |
1322 | else if (spell_ob->subtype == SP_FAERY_FIRE && tmp->resist[ATNR_MAGIC] != 100) |
1313 | else if (spell_ob->subtype == SP_FAERY_FIRE && tmp->resist [ATNR_MAGIC] != 100) |
1323 | { |
1314 | { |
1324 | if (make_object_glow (tmp, 1, dur) && spell_ob->other_arch) |
1315 | if (make_object_glow (tmp, 1, dur) && spell_ob->other_arch) |
1325 | m->insert (arch_to_object (spell_ob->other_arch), sx, sy, op); |
1316 | m->insert (arch_to_object (spell_ob->other_arch), nx, ny, op); |
1326 | } |
|
|
1327 | } |
1317 | } |
1328 | } |
1318 | } |
1329 | } |
1319 | } |
1330 | } |
|
|
1331 | } |
1320 | } |
1332 | |
1321 | |
1333 | op->skill = skill; |
1322 | op->skill = skill; |
1334 | return 1; |
1323 | return 1; |
1335 | } |
1324 | } |
… | |
… | |
1442 | */ |
1431 | */ |
1443 | int |
1432 | int |
1444 | mood_change (object *op, object *caster, object *spell) |
1433 | mood_change (object *op, object *caster, object *spell) |
1445 | { |
1434 | { |
1446 | object *tmp, *god, *head; |
1435 | object *tmp, *god, *head; |
1447 | int done_one, range, mflags, level, at, best_at; |
1436 | int done_one, range, level, at, best_at; |
1448 | sint16 x, y, nx, ny; |
|
|
1449 | maptile *m; |
|
|
1450 | const char *race; |
1437 | const char *race; |
1451 | |
1438 | |
1452 | /* We precompute some values here so that we don't have to keep |
1439 | /* We precompute some values here so that we don't have to keep |
1453 | * doing it over and over again. |
1440 | * doing it over and over again. |
1454 | */ |
1441 | */ |
1455 | god = find_god (determine_god (op)); |
1442 | god = find_god (determine_god (op)); |
1456 | level = caster_level (caster, spell); |
1443 | level = casting_level (caster, spell); |
1457 | range = spell->range + SP_level_range_adjust (caster, spell); |
1444 | range = spell->range + SP_level_range_adjust (caster, spell); |
1458 | |
1445 | |
1459 | /* On the bright side, no monster should ever have a race of GOD_... |
1446 | /* On the bright side, no monster should ever have a race of GOD_... |
1460 | * 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 |
1461 | * won't ever match anything. |
1448 | * won't ever match anything. |
… | |
… | |
1467 | else if (god && !strcmp (spell->race, "GOD_FRIEND")) |
1454 | else if (god && !strcmp (spell->race, "GOD_FRIEND")) |
1468 | race = god->race; |
1455 | race = god->race; |
1469 | else |
1456 | else |
1470 | race = spell->race; |
1457 | race = spell->race; |
1471 | |
1458 | |
1472 | for (x = op->x - range; x <= op->x + range; x++) |
1459 | unordered_mapwalk (op, -range, -range, range, range) |
1473 | for (y = op->y - range; y <= op->y + range; y++) |
|
|
1474 | { |
1460 | { |
1475 | done_one = 0; |
1461 | mapspace &ms = m->at (nx, ny); |
1476 | m = op->map; |
|
|
1477 | nx = x; |
|
|
1478 | ny = y; |
|
|
1479 | mflags = get_map_flags (m, &m, x, y, &nx, &ny); |
|
|
1480 | if (mflags & P_OUT_OF_MAP) |
|
|
1481 | continue; |
|
|
1482 | |
1462 | |
1483 | /* If there is nothing living on this space, no need to go further */ |
1463 | /* If there is nothing living on this space, no need to go further */ |
1484 | if (!(mflags & P_IS_ALIVE)) |
1464 | if (!ms.flags () & P_IS_ALIVE) |
1485 | continue; |
1465 | continue; |
1486 | |
1466 | |
1487 | // players can only affect spaces that they can actually see |
1467 | // players can only affect spaces that they can actually see |
|
|
1468 | if (caster |
1488 | if (caster && caster->contr |
1469 | && caster->contr |
1489 | && caster->contr->visibility_at (m, nx, ny) < 70) |
1470 | && caster->contr->darkness_at (m, nx, ny) == LOS_BLOCKED) |
1490 | continue; |
1471 | continue; |
1491 | |
1472 | |
1492 | for (tmp = GET_MAP_TOP (m, nx, ny); tmp; tmp = tmp->below) |
1473 | for (tmp = ms.top; tmp; tmp = tmp->below) |
1493 | if (QUERY_FLAG (tmp, FLAG_MONSTER)) |
1474 | if (tmp->flag [FLAG_MONSTER]) |
1494 | break; |
1475 | break; |
1495 | |
1476 | |
1496 | /* There can be living objects that are not monsters */ |
1477 | /* There can be living objects that are not monsters */ |
1497 | if (!tmp || tmp->type == PLAYER) |
1478 | if (!tmp) |
1498 | continue; |
1479 | continue; |
1499 | |
1480 | |
1500 | /* Only the head has meaningful data, so resolve to that */ |
1481 | /* Only the head has meaningful data, so resolve to that */ |
1501 | if (tmp->head) |
|
|
1502 | head = tmp->head; |
1482 | head = tmp->head_ (); |
1503 | else |
|
|
1504 | head = tmp; |
|
|
1505 | |
1483 | |
1506 | /* Make sure the race is OK. Likewise, only effect undead if spell specifically allows it */ |
1484 | /* Make sure the race is OK. Likewise, only effect undead if spell specifically allows it */ |
1507 | if (race && head->race && !strstr (race, head->race)) |
1485 | if (race && head->race && !strstr (race, head->race)) |
1508 | continue; |
1486 | continue; |
1509 | |
1487 | |
1510 | if (QUERY_FLAG (head, FLAG_UNDEAD) && !QUERY_FLAG (spell, FLAG_UNDEAD)) |
1488 | if (QUERY_FLAG (head, FLAG_UNDEAD) && !QUERY_FLAG (spell, FLAG_UNDEAD)) |
1511 | continue; |
1489 | continue; |
1512 | |
1490 | |
1513 | /* Now do a bunch of stuff related to saving throws */ |
1491 | /* Now do a bunch of stuff related to saving throws */ |
1514 | best_at = -1; |
1492 | best_at = -1; |
1515 | if (spell->attacktype) |
1493 | if (spell->attacktype) |
1516 | { |
1494 | { |
1517 | for (at = 0; at < NROFATTACKS; at++) |
1495 | for (at = 0; at < NROFATTACKS; at++) |
1518 | if (spell->attacktype & (1 << at)) |
1496 | if (spell->attacktype & (1 << at)) |
1519 | if (best_at == -1 || head->resist[at] > head->resist[best_at]) |
1497 | if (best_at == -1 || head->resist[at] > head->resist[best_at]) |
1520 | best_at = at; |
1498 | best_at = at; |
1521 | |
1499 | |
1522 | if (best_at == -1) |
1500 | if (best_at == -1) |
1523 | at = 0; |
1501 | at = 0; |
1524 | else |
1502 | else |
1525 | { |
1503 | { |
1526 | if (head->resist[best_at] == 100) |
1504 | if (head->resist[best_at] == 100) |
1527 | continue; |
1505 | continue; |
1528 | else |
1506 | else |
1529 | at = head->resist[best_at] / 5; |
1507 | at = head->resist[best_at] / 5; |
1530 | } |
1508 | } |
|
|
1509 | |
1531 | at -= level / 5; |
1510 | at -= level / 5; |
1532 | if (did_make_save (head, head->level, at)) |
1511 | if (did_make_save (head, head->level, at)) |
1533 | continue; |
1512 | continue; |
1534 | } |
1513 | } |
1535 | else /* spell->attacktype */ |
1514 | else /* spell->attacktype */ |
1536 | { |
1515 | { |
1537 | /* |
1516 | /* |
1538 | Spell has no attacktype (charm & such), so we'll have a specific saving: |
1517 | Spell has no attacktype (charm & such), so we'll have a specific saving: |
1539 | * if spell level < monster level, no go |
1518 | * if spell level < monster level, no go |
1540 | * else, chance of effect = 20 + min( 50, 2 * ( spell level - monster level ) ) |
1519 | * else, chance of effect = 20 + min( 50, 2 * ( spell level - monster level ) ) |
1541 | |
1520 | |
1542 | The chance will then be in the range [20-70] percent, not too bad. |
1521 | The chance will then be in the range [20-70] percent, not too bad. |
1543 | |
1522 | |
1544 | This is required to fix the 'charm monster' abuse, where a player level 1 can |
1523 | This is required to fix the 'charm monster' abuse, where a player level 1 can |
1545 | charm a level 125 monster... |
1524 | charm a level 125 monster... |
1546 | |
1525 | |
1547 | Ryo, august 14th |
1526 | Ryo, august 14th |
1548 | */ |
1527 | */ |
1549 | if (head->level > level) |
1528 | if (head->level > level) |
1550 | continue; |
1529 | continue; |
1551 | |
1530 | |
1552 | if (random_roll (0, 100, caster, PREFER_LOW) >= (20 + MIN (50, 2 * (level - head->level)))) |
1531 | if (random_roll (0, 100, caster, PREFER_LOW) >= (20 + MIN (50, 2 * (level - head->level)))) |
1553 | /* Failed, no effect */ |
1532 | /* Failed, no effect */ |
1554 | continue; |
1533 | continue; |
1555 | } |
1534 | } |
1556 | |
1535 | |
1557 | /* Done with saving throw. Now start affecting the monster */ |
1536 | /* Done with saving throw. Now start affecting the monster */ |
|
|
1537 | done_one = 0; |
1558 | |
1538 | |
1559 | /* aggravation */ |
1539 | /* aggravation */ |
1560 | if (QUERY_FLAG (spell, FLAG_MONSTER)) |
1540 | if (QUERY_FLAG (spell, FLAG_MONSTER)) |
1561 | { |
1541 | { |
1562 | CLEAR_FLAG (head, FLAG_SLEEP); |
1542 | CLEAR_FLAG (head, FLAG_SLEEP); |
1563 | remove_friendly_object (head); |
1543 | remove_friendly_object (head); |
1564 | done_one = 1; |
1544 | done_one = 1; |
1565 | head->enemy = op; |
1545 | head->enemy = op; |
1566 | } |
1546 | } |
1567 | |
1547 | |
1568 | /* calm monsters */ |
1548 | /* calm monsters */ |
1569 | if (QUERY_FLAG (spell, FLAG_UNAGGRESSIVE) && !QUERY_FLAG (head, FLAG_UNAGGRESSIVE)) |
1549 | if (QUERY_FLAG (spell, FLAG_UNAGGRESSIVE) && !QUERY_FLAG (head, FLAG_UNAGGRESSIVE)) |
1570 | { |
1550 | { |
1571 | SET_FLAG (head, FLAG_UNAGGRESSIVE); |
1551 | SET_FLAG (head, FLAG_UNAGGRESSIVE); |
1572 | head->enemy = NULL; |
1552 | head->enemy = NULL; |
1573 | done_one = 1; |
1553 | done_one = 1; |
1574 | } |
1554 | } |
1575 | |
1555 | |
1576 | /* berserk monsters */ |
1556 | /* berserk monsters */ |
1577 | if (QUERY_FLAG (spell, FLAG_BERSERK) && !QUERY_FLAG (head, FLAG_BERSERK)) |
1557 | if (QUERY_FLAG (spell, FLAG_BERSERK) && !QUERY_FLAG (head, FLAG_BERSERK)) |
1578 | { |
1558 | { |
1579 | SET_FLAG (head, FLAG_BERSERK); |
1559 | SET_FLAG (head, FLAG_BERSERK); |
1580 | done_one = 1; |
1560 | done_one = 1; |
1581 | } |
1561 | } |
1582 | |
1562 | |
1583 | /* charm */ |
1563 | /* charm */ |
1584 | if (QUERY_FLAG (spell, FLAG_NO_ATTACK) && !QUERY_FLAG (head, FLAG_FRIENDLY)) |
1564 | if (QUERY_FLAG (spell, FLAG_NO_ATTACK) && !QUERY_FLAG (head, FLAG_FRIENDLY)) |
1585 | { |
1565 | { |
1586 | INVOKE_OBJECT (KILL, head, ARG_OBJECT (caster)); |
1566 | INVOKE_OBJECT (KILL, head, ARG_OBJECT (caster)); |
1587 | |
1567 | |
1588 | /* Prevent uncontrolled outbreaks of self replicating monsters. |
1568 | /* Prevent uncontrolled outbreaks of self replicating monsters. |
1589 | Typical use case is charm, go somwhere, use aggravation to make hostile. |
1569 | Typical use case is charm, go somwhere, use aggravation to make hostile. |
1590 | This could lead to fun stuff like mice outbreak in bigworld and server crawl. */ |
1570 | This could lead to fun stuff like mice outbreak in bigworld and server crawl. */ |
1591 | CLEAR_FLAG (head, FLAG_GENERATOR); |
1571 | CLEAR_FLAG (head, FLAG_GENERATOR); |
1592 | head->set_owner (op); |
1572 | head->set_owner (op); |
1593 | set_spell_skill (op, caster, spell, head); |
1573 | set_spell_skill (op, caster, spell, head); |
1594 | add_friendly_object (head); |
1574 | add_friendly_object (head); |
1595 | head->attack_movement = PETMOVE; |
1575 | head->attack_movement = PETMOVE; |
1596 | done_one = 1; |
1576 | done_one = 1; |
1597 | change_exp (op, head->stats.exp / 2, head->skill, SK_EXP_ADD_SKILL); |
1577 | change_exp (op, head->stats.exp / 2, head->skill, SK_EXP_ADD_SKILL); |
1598 | head->stats.exp = 0; |
1578 | head->stats.exp = 0; |
1599 | } |
1579 | } |
1600 | |
1580 | |
1601 | /* If a monster was effected, put an effect in */ |
1581 | /* If a monster was effected, put an effect in */ |
1602 | if (done_one && spell->other_arch) |
1582 | if (done_one && spell->other_arch) |
1603 | m->insert (arch_to_object (spell->other_arch), nx, ny, op); |
1583 | m->insert (arch_to_object (spell->other_arch), nx, ny, op); |
1604 | } /* for y */ |
1584 | } |
1605 | |
1585 | |
1606 | return 1; |
1586 | return 1; |
1607 | } |
1587 | } |
1608 | |
|
|
1609 | |
1588 | |
1610 | /* Move_ball_spell: This handles ball type spells that just sort of wander |
1589 | /* Move_ball_spell: This handles ball type spells that just sort of wander |
1611 | * about. was called move_ball_lightning, but since more than the ball |
1590 | * about. was called move_ball_lightning, but since more than the ball |
1612 | * lightning spell used it, that seemed misnamed. |
1591 | * lightning spell used it, that seemed misnamed. |
1613 | * op is the spell effect. |
1592 | * op is the spell effect. |
… | |
… | |
1639 | for (i = 1; i < 9; i++) |
1618 | for (i = 1; i < 9; i++) |
1640 | { |
1619 | { |
1641 | /* i bit 0: alters sign of offset |
1620 | /* i bit 0: alters sign of offset |
1642 | * other bits (i / 2): absolute value of offset |
1621 | * other bits (i / 2): absolute value of offset |
1643 | */ |
1622 | */ |
1644 | |
|
|
1645 | int offset = ((i ^ j) & 1) ? (i / 2) : -(i / 2); |
1623 | int offset = ((i ^ j) & 1) ? (i / 2) : -(i / 2); |
1646 | int tmpdir = absdir (op->direction + offset); |
1624 | int tmpdir = absdir (op->direction + offset); |
1647 | |
1625 | |
1648 | nx = op->x + freearr_x[tmpdir]; |
1626 | nx = op->x + freearr_x[tmpdir]; |
1649 | ny = op->y + freearr_y[tmpdir]; |
1627 | ny = op->y + freearr_y[tmpdir]; |
… | |
… | |
1651 | { |
1629 | { |
1652 | dir = tmpdir; |
1630 | dir = tmpdir; |
1653 | break; |
1631 | break; |
1654 | } |
1632 | } |
1655 | } |
1633 | } |
|
|
1634 | |
1656 | if (dir == 0) |
1635 | if (dir == 0) |
1657 | { |
1636 | { |
1658 | nx = op->x; |
1637 | nx = op->x; |
1659 | ny = op->y; |
1638 | ny = op->y; |
1660 | m = op->map; |
1639 | m = op->map; |
… | |
… | |
1739 | return; |
1718 | return; |
1740 | } |
1719 | } |
1741 | |
1720 | |
1742 | if (!op->duration || !owner->is_on_map ()) |
1721 | if (!op->duration || !owner->is_on_map ()) |
1743 | { |
1722 | { |
1744 | op->destroy (); |
1723 | op->drop_and_destroy (); |
1745 | return; |
1724 | return; |
1746 | } |
1725 | } |
1747 | |
1726 | |
1748 | op->duration--; |
1727 | op->duration--; |
1749 | |
1728 | |
… | |
… | |
1845 | return 0; |
1824 | return 0; |
1846 | |
1825 | |
1847 | object *tmp = archetype::get (SWARM_SPELL); |
1826 | object *tmp = archetype::get (SWARM_SPELL); |
1848 | |
1827 | |
1849 | set_spell_skill (op, caster, spell, tmp); |
1828 | set_spell_skill (op, caster, spell, tmp); |
1850 | tmp->level = caster_level (caster, spell); /* needed later, to get level dep. right. */ |
1829 | tmp->level = casting_level (caster, spell); /* needed later, to get level dep. right. */ |
1851 | tmp->spell = spell->other_arch->instance (); |
1830 | tmp->spell = spell->other_arch->instance (); |
1852 | tmp->attacktype = tmp->spell->attacktype; |
1831 | tmp->attacktype = tmp->spell->attacktype; |
1853 | |
1832 | |
1854 | if (tmp->attacktype & AT_HOLYWORD || tmp->attacktype & AT_GODPOWER) |
1833 | if (tmp->attacktype & AT_HOLYWORD || tmp->attacktype & AT_GODPOWER) |
1855 | if (!tailor_god_spell (tmp, op)) |
1834 | if (!tailor_god_spell (tmp, op)) |
… | |
… | |
1881 | int dam, mflags; |
1860 | int dam, mflags; |
1882 | maptile *m; |
1861 | maptile *m; |
1883 | |
1862 | |
1884 | dam = spell->stats.dam + SP_level_dam_adjust (caster, spell); |
1863 | dam = spell->stats.dam + SP_level_dam_adjust (caster, spell); |
1885 | |
1864 | |
1886 | if (!dir) |
1865 | if (dir) |
1887 | { |
|
|
1888 | new_draw_info (NDI_UNIQUE, 0, op, "In what direction?"); |
|
|
1889 | return 0; |
|
|
1890 | } |
1866 | { |
1891 | |
|
|
1892 | x = op->x + freearr_x[dir]; |
1867 | x = op->x + freearr_x[dir]; |
1893 | y = op->y + freearr_y[dir]; |
1868 | y = op->y + freearr_y[dir]; |
1894 | m = op->map; |
1869 | m = op->map; |
1895 | |
1870 | |
1896 | mflags = get_map_flags (m, &m, x, y, &x, &y); |
1871 | mflags = get_map_flags (m, &m, x, y, &x, &y); |
1897 | |
1872 | |
1898 | if (mflags & P_OUT_OF_MAP) |
1873 | if (mflags & P_OUT_OF_MAP) |
1899 | { |
1874 | { |
1900 | new_draw_info (NDI_UNIQUE, 0, op, "Nothing is there."); |
1875 | new_draw_info (NDI_UNIQUE, 0, op, "Nothing is there."); |
1901 | return 0; |
1876 | return 0; |
1902 | } |
1877 | } |
1903 | |
1878 | |
1904 | if (mflags & P_IS_ALIVE && spell->attacktype) |
1879 | if (mflags & P_IS_ALIVE && spell->attacktype) |
1905 | { |
1880 | { |
1906 | for (target = GET_MAP_OB (m, x, y); target; target = target->above) |
1881 | for (target = GET_MAP_OB (m, x, y); target; target = target->above) |
1907 | if (QUERY_FLAG (target, FLAG_MONSTER)) |
1882 | if (QUERY_FLAG (target, FLAG_MONSTER)) |
1908 | { |
1883 | { |
1909 | /* oky doky. got a target monster. Lets make a blinding attack */ |
1884 | /* oky doky. got a target monster. Lets make a blinding attack */ |
1910 | if (target->head) |
1885 | if (target->head) |
1911 | target = target->head; |
1886 | target = target->head; |
1912 | |
1887 | |
1913 | hit_player (target, dam, op, spell->attacktype, 1); |
1888 | hit_player (target, dam, op, spell->attacktype, 1); |
1914 | return 1; /* one success only! */ |
1889 | return 1; /* one success only! */ |
|
|
1890 | } |
1915 | } |
1891 | } |
1916 | } |
|
|
1917 | |
1892 | |
1918 | /* no live target, perhaps a wall is in the way? */ |
1893 | /* no live target, perhaps a wall is in the way? */ |
1919 | if (OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, x, y))) |
1894 | if (OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, x, y))) |
1920 | { |
1895 | { |
1921 | new_draw_info (NDI_UNIQUE, 0, op, "Something is in the way."); |
1896 | new_draw_info (NDI_UNIQUE, 0, op, "Something is in the way."); |
1922 | return 0; |
1897 | return 0; |
|
|
1898 | } |
1923 | } |
1899 | } |
1924 | |
1900 | |
1925 | /* ok, looks groovy to just insert a new light on the map */ |
1901 | /* ok, looks groovy to just insert a new light on the map */ |
1926 | tmp = arch_to_object (spell->other_arch); |
1902 | tmp = arch_to_object (spell->other_arch); |
1927 | if (!tmp) |
1903 | if (!tmp) |
1928 | { |
1904 | { |
1929 | LOG (llevError, "Error: spell arch for cast_light() missing.\n"); |
1905 | LOG (llevError, "Error: spell arch for cast_light() missing.\n"); |
1930 | return 0; |
1906 | return 0; |
1931 | } |
1907 | } |
|
|
1908 | |
1932 | tmp->stats.food = spell->duration + SP_level_duration_adjust (caster, spell); |
1909 | tmp->stats.food = spell->duration + SP_level_duration_adjust (caster, spell); |
|
|
1910 | |
1933 | if (tmp->glow_radius) |
1911 | if (tmp->glow_radius) |
1934 | { |
|
|
1935 | tmp->glow_radius = spell->range + SP_level_range_adjust (caster, spell); |
1912 | tmp->glow_radius = min (MAX_LIGHT_RADIUS, spell->range + SP_level_range_adjust (caster, spell)); |
1936 | if (tmp->glow_radius > MAX_LIGHT_RADII) |
|
|
1937 | tmp->glow_radius = MAX_LIGHT_RADII; |
|
|
1938 | } |
|
|
1939 | |
1913 | |
|
|
1914 | if (dir) |
1940 | m->insert (tmp, x, y, op); |
1915 | m->insert (tmp, x, y, op); |
|
|
1916 | else |
|
|
1917 | caster->outer_env ()->insert (tmp); |
|
|
1918 | |
1941 | return 1; |
1919 | return 1; |
1942 | } |
1920 | } |
1943 | |
1921 | |
1944 | /* cast_cause_disease: this spell looks along <dir> from the |
1922 | /* cast_cause_disease: this spell looks along <dir> from the |
1945 | * player and infects someone. |
1923 | * player and infects someone. |
… | |
… | |
1998 | object *disease = arch_to_object (spell->other_arch); |
1976 | object *disease = arch_to_object (spell->other_arch); |
1999 | |
1977 | |
2000 | disease->set_owner (op); |
1978 | disease->set_owner (op); |
2001 | set_spell_skill (op, caster, spell, disease); |
1979 | set_spell_skill (op, caster, spell, disease); |
2002 | disease->stats.exp = 0; |
1980 | disease->stats.exp = 0; |
2003 | disease->level = caster_level (caster, spell); |
1981 | disease->level = casting_level (caster, spell); |
2004 | |
1982 | |
2005 | /* do level adjustments */ |
1983 | /* do level adjustments */ |
2006 | if (disease->stats.wc) |
1984 | if (disease->stats.wc) |
2007 | disease->stats.wc += dur_mod / 2; |
1985 | disease->stats.wc += dur_mod / 2; |
2008 | |
1986 | |