… | |
… | |
351 | maptile *m = op->map; |
351 | maptile *m = op->map; |
352 | int i; |
352 | int i; |
353 | |
353 | |
354 | if (--op->duration < 0) |
354 | if (--op->duration < 0) |
355 | { |
355 | { |
356 | op->destroy (true); |
356 | op->destroy (); |
357 | return; |
357 | return; |
358 | } |
358 | } |
359 | |
359 | |
360 | hit_map (op, 0, op->attacktype, 0); |
360 | hit_map (op, 0, op->attacktype, 0); |
361 | |
361 | |
… | |
… | |
396 | object *tmp, *owner; |
396 | object *tmp, *owner; |
397 | |
397 | |
398 | if (!op->other_arch) |
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 (true); |
401 | op->destroy (); |
402 | return; |
402 | return; |
403 | } |
403 | } |
404 | |
404 | |
405 | if (op->env) |
405 | if (op->env) |
406 | { |
406 | { |
407 | object *env = op->outer_env (); |
407 | object *env = op->outer_env (); |
408 | |
408 | |
409 | if (!env->map || out_of_map (env->map, env->x, env->y)) |
409 | if (!env->map || out_of_map (env->map, env->x, env->y)) |
410 | { |
410 | { |
411 | LOG (llevError, "BUG: explode_bullet(): env out of map\n"); |
411 | LOG (llevError, "BUG: explode_bullet(): env out of map\n"); |
412 | op->destroy (true); |
412 | op->destroy (); |
413 | return; |
413 | return; |
414 | } |
414 | } |
415 | |
415 | |
416 | op->insert_at (env, op, INS_NO_MERGE | INS_NO_WALK_ON); |
416 | op->insert_at (env, op, INS_NO_MERGE | INS_NO_WALK_ON); |
417 | } |
417 | } |
418 | else if (out_of_map (op->map, op->x, op->y)) |
418 | else if (out_of_map (op->map, op->x, op->y)) |
419 | { |
419 | { |
420 | LOG (llevError, "BUG: explode_bullet(): op out of map\n"); |
420 | LOG (llevError, "BUG: explode_bullet(): op out of map\n"); |
421 | op->destroy (true); |
421 | op->destroy (); |
422 | return; |
422 | return; |
423 | } |
423 | } |
424 | |
424 | |
425 | // elmex Tue Aug 15 17:46:51 CEST 2006: Prevent explosions of any kind on safe maps |
425 | // elmex Tue Aug 15 17:46:51 CEST 2006: Prevent explosions of any kind on safe maps |
426 | // NOTE: If this breaks something important: remove this. I can't think of anything |
426 | // NOTE: If this breaks something important: remove this. I can't think of anything |
427 | // bad at the moment that might happen from this. |
427 | // bad at the moment that might happen from this. |
428 | if (get_map_flags (op->map, NULL, op->x, op->y, NULL, NULL) & P_SAFE) |
428 | if (get_map_flags (op->map, NULL, op->x, op->y, NULL, NULL) & P_SAFE) |
429 | { |
429 | { |
430 | op->destroy (true); |
430 | op->destroy (); |
431 | return; |
431 | return; |
432 | } |
432 | } |
433 | |
433 | |
434 | if (op->attacktype) |
434 | if (op->attacktype) |
435 | { |
435 | { |
… | |
… | |
450 | if ((tmp->attacktype & AT_HOLYWORD |
450 | if ((tmp->attacktype & AT_HOLYWORD |
451 | || tmp->attacktype & AT_GODPOWER) |
451 | || tmp->attacktype & AT_GODPOWER) |
452 | && owner |
452 | && owner |
453 | && !tailor_god_spell (tmp, owner)) |
453 | && !tailor_god_spell (tmp, owner)) |
454 | { |
454 | { |
455 | op->destroy (true); |
455 | op->destroy (); |
456 | return; |
456 | return; |
457 | } |
457 | } |
458 | |
458 | |
459 | /* special for bombs - it actually has sane values for these */ |
459 | /* special for bombs - it actually has sane values for these */ |
460 | if (op->type == SPELL_EFFECT && op->subtype == SP_BOMB) |
460 | if (op->type == SPELL_EFFECT && op->subtype == SP_BOMB) |
… | |
… | |
488 | |
488 | |
489 | tmp->insert_at (op, op); |
489 | tmp->insert_at (op, op); |
490 | tmp->play_sound (tmp->sound); |
490 | tmp->play_sound (tmp->sound); |
491 | |
491 | |
492 | /* remove the firebullet */ |
492 | /* remove the firebullet */ |
493 | op->destroy (true); |
493 | op->destroy (); |
494 | } |
494 | } |
495 | |
495 | |
496 | /* checks to see what op should do, given the space it is on |
496 | /* checks to see what op should do, given the space it is on |
497 | * (eg, explode, damage player, etc) |
497 | * (eg, explode, damage player, etc) |
498 | */ |
498 | */ |
… | |
… | |
529 | // TODO: can't understand the following if's |
529 | // TODO: can't understand the following if's |
530 | if (op->destroyed () || !tmp->destroyed () || (op->stats.dam -= dam) < 0) |
530 | if (op->destroyed () || !tmp->destroyed () || (op->stats.dam -= dam) < 0) |
531 | { |
531 | { |
532 | if (!QUERY_FLAG (op, FLAG_REMOVED)) |
532 | if (!QUERY_FLAG (op, FLAG_REMOVED)) |
533 | { |
533 | { |
534 | op->destroy (true); |
534 | op->destroy (); |
535 | return; |
535 | return; |
536 | } |
536 | } |
537 | } |
537 | } |
538 | } |
538 | } |
539 | } |
539 | } |
… | |
… | |
568 | if (--op->range <= 0) |
568 | if (--op->range <= 0) |
569 | { |
569 | { |
570 | if (op->other_arch) |
570 | if (op->other_arch) |
571 | explode_bullet (op); |
571 | explode_bullet (op); |
572 | else |
572 | else |
573 | op->destroy (true); |
573 | op->destroy (); |
574 | |
574 | |
575 | return; |
575 | return; |
576 | } |
576 | } |
577 | |
577 | |
578 | new_x = op->x + DIRX (op); |
578 | new_x = op->x + DIRX (op); |
… | |
… | |
580 | m = op->map; |
580 | m = op->map; |
581 | mflags = get_map_flags (m, &m, new_x, new_y, &new_x, &new_y); |
581 | mflags = get_map_flags (m, &m, new_x, new_y, &new_x, &new_y); |
582 | |
582 | |
583 | if (mflags & P_OUT_OF_MAP) |
583 | if (mflags & P_OUT_OF_MAP) |
584 | { |
584 | { |
585 | op->destroy (true); |
585 | op->destroy (); |
586 | return; |
586 | return; |
587 | } |
587 | } |
588 | |
588 | |
589 | if (!op->direction || OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, new_x, new_y))) |
589 | if (!op->direction || OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, new_x, new_y))) |
590 | { |
590 | { |
591 | if (op->other_arch) |
591 | if (op->other_arch) |
592 | explode_bullet (op); |
592 | explode_bullet (op); |
593 | else |
593 | else |
594 | op->destroy (true); |
594 | op->destroy (); |
595 | |
595 | |
596 | return; |
596 | return; |
597 | } |
597 | } |
598 | |
598 | |
599 | if (!(op = m->insert (op, new_x, new_y, op))) |
599 | if (!(op = m->insert (op, new_x, new_y, op))) |
… | |
… | |
655 | |
655 | |
656 | maptile *newmap; |
656 | maptile *newmap; |
657 | mflags = get_map_flags (tmp->map, &newmap, tmp->x, tmp->y, &tmp->x, &tmp->y); |
657 | mflags = get_map_flags (tmp->map, &newmap, tmp->x, tmp->y, &tmp->x, &tmp->y); |
658 | if (mflags & P_OUT_OF_MAP) |
658 | if (mflags & P_OUT_OF_MAP) |
659 | { |
659 | { |
660 | tmp->destroy (true); |
660 | tmp->destroy (); |
661 | return 0; |
661 | return 0; |
662 | } |
662 | } |
663 | |
663 | |
664 | tmp->map = newmap; |
664 | tmp->map = newmap; |
665 | |
665 | |
666 | if (OB_TYPE_MOVE_BLOCK (tmp, GET_MAP_MOVE_BLOCK (tmp->map, tmp->x, tmp->y))) |
666 | if (OB_TYPE_MOVE_BLOCK (tmp, GET_MAP_MOVE_BLOCK (tmp->map, tmp->x, tmp->y))) |
667 | { |
667 | { |
668 | if (!QUERY_FLAG (tmp, FLAG_REFLECTING)) |
668 | if (!QUERY_FLAG (tmp, FLAG_REFLECTING)) |
669 | { |
669 | { |
670 | tmp->destroy (true); |
670 | tmp->destroy (); |
671 | return 0; |
671 | return 0; |
672 | } |
672 | } |
673 | |
673 | |
674 | tmp->x = op->x; |
674 | tmp->x = op->x; |
675 | tmp->y = op->y; |
675 | tmp->y = op->y; |
… | |
… | |
730 | * when their cone dies when they die. |
730 | * when their cone dies when they die. |
731 | */ |
731 | */ |
732 | /* If no owner left, the spell dies out. */ |
732 | /* If no owner left, the spell dies out. */ |
733 | if (op->owner == NULL) |
733 | if (op->owner == NULL) |
734 | { |
734 | { |
735 | op->destroy (true); |
735 | op->destroy (); |
736 | return; |
736 | return; |
737 | } |
737 | } |
738 | #endif |
738 | #endif |
739 | |
739 | |
740 | hit_map (op, 0, op->attacktype, 0); |
740 | hit_map (op, 0, op->attacktype, 0); |
|
|
741 | |
|
|
742 | if (!op->is_on_map ()) |
|
|
743 | return; |
741 | |
744 | |
742 | /* Check to see if we should push anything. |
745 | /* Check to see if we should push anything. |
743 | * Spell objects with weight push whatever they encounter to some |
746 | * Spell objects with weight push whatever they encounter to some |
744 | * degree. |
747 | * degree. |
745 | */ |
748 | */ |
746 | if (op->weight) |
749 | if (op->weight) |
|
|
750 | { |
747 | check_spell_knockback (op); |
751 | check_spell_knockback (op); |
748 | |
752 | |
749 | if (op->destroyed ()) |
753 | if (!op->is_on_map ()) |
750 | return; |
754 | return; |
|
|
755 | } |
751 | |
756 | |
752 | if (op->duration-- < 0) |
757 | if (op->duration-- < 0) |
753 | { |
758 | { |
754 | op->destroy (true); |
759 | op->destroy (); |
755 | return; |
760 | return; |
756 | } |
761 | } |
757 | /* Object has hit maximum range, so don't have it move |
762 | /* Object has hit maximum range, so don't have it move |
758 | * any further. When the duration above expires, |
763 | * any further. When the duration above expires, |
759 | * then the object will get removed. |
764 | * then the object will get removed. |
… | |
… | |
958 | // elmex Tue Aug 15 17:46:51 CEST 2006: Prevent bomb from exploding |
963 | // elmex Tue Aug 15 17:46:51 CEST 2006: Prevent bomb from exploding |
959 | // on a safe map. I don't like this special casing, but it seems to be neccessary |
964 | // on a safe map. I don't like this special casing, but it seems to be neccessary |
960 | // as bombs can be carried. |
965 | // as bombs can be carried. |
961 | if (get_map_flags (op->map, NULL, op->x, op->y, NULL, NULL) & P_SAFE) |
966 | if (get_map_flags (op->map, NULL, op->x, op->y, NULL, NULL) & P_SAFE) |
962 | { |
967 | { |
963 | op->destroy (true); |
968 | op->destroy (); |
964 | return; |
969 | return; |
965 | } |
970 | } |
966 | |
971 | |
967 | /* This copies a lot of the code from the fire bullet, |
972 | /* This copies a lot of the code from the fire bullet, |
968 | * but using the cast_bullet isn't really feasible, |
973 | * but using the cast_bullet isn't really feasible, |
… | |
… | |
1150 | } |
1155 | } |
1151 | else |
1156 | else |
1152 | { |
1157 | { |
1153 | new_draw_info_format (NDI_UNIQUE, 0, op, "The %s looks stronger!", query_name (target)); |
1158 | new_draw_info_format (NDI_UNIQUE, 0, op, "The %s looks stronger!", query_name (target)); |
1154 | target->stats.hp = target->stats.maxhp * 2; |
1159 | target->stats.hp = target->stats.maxhp * 2; |
1155 | effect->destroy (true); |
1160 | effect->destroy (); |
1156 | return 0; |
1161 | return 0; |
1157 | } |
1162 | } |
1158 | } |
1163 | } |
1159 | } |
1164 | } |
1160 | else |
1165 | else |
… | |
… | |
1192 | mapxy pos (op); |
1197 | mapxy pos (op); |
1193 | pos.move (op->direction); |
1198 | pos.move (op->direction); |
1194 | |
1199 | |
1195 | if (!pos.normalise ()) |
1200 | if (!pos.normalise ()) |
1196 | { |
1201 | { |
1197 | op->destroy (true); |
1202 | op->destroy (); |
1198 | return; |
1203 | return; |
1199 | } |
1204 | } |
1200 | |
1205 | |
1201 | mapspace &ms = pos.ms (); |
1206 | mapspace &ms = pos.ms (); |
1202 | |
1207 | |
… | |
… | |
1204 | { |
1209 | { |
1205 | hit_map (op, op->direction, AT_MAGIC, 1); |
1210 | hit_map (op, op->direction, AT_MAGIC, 1); |
1206 | /* Basically, missile only hits one thing then goes away. |
1211 | /* Basically, missile only hits one thing then goes away. |
1207 | * we need to remove it if someone hasn't already done so. |
1212 | * we need to remove it if someone hasn't already done so. |
1208 | */ |
1213 | */ |
1209 | op->destroy (true); |
1214 | op->destroy (); |
1210 | return; |
1215 | return; |
1211 | } |
1216 | } |
1212 | |
1217 | |
1213 | if (!op->direction) |
1218 | if (!op->direction) |
1214 | { |
1219 | { |
1215 | op->destroy (true); |
1220 | op->destroy (); |
1216 | return; |
1221 | return; |
1217 | } |
1222 | } |
1218 | |
1223 | |
1219 | int i = spell_find_dir (pos.m, pos.x, pos.y, op->owner); |
1224 | int i = spell_find_dir (pos.m, pos.x, pos.y, op->owner); |
1220 | if (i > 0 && i != op->direction) |
1225 | if (i > 0 && i != op->direction) |
… | |
… | |
1245 | |
1250 | |
1246 | object *tmp = get_archetype (FORCE_NAME); |
1251 | object *tmp = get_archetype (FORCE_NAME); |
1247 | tmp->speed = 0.01; |
1252 | tmp->speed = 0.01; |
1248 | tmp->stats.food = time; |
1253 | tmp->stats.food = time; |
1249 | SET_FLAG (tmp, FLAG_IS_USED_UP); |
1254 | SET_FLAG (tmp, FLAG_IS_USED_UP); |
1250 | tmp->glow_radius = radius; |
|
|
1251 | if (tmp->glow_radius > MAX_LIGHT_RADII) |
|
|
1252 | tmp->glow_radius = MAX_LIGHT_RADII; |
1255 | tmp->glow_radius = min (MAX_LIGHT_RADIUS, radius); |
1253 | |
|
|
1254 | tmp = insert_ob_in_ob (tmp, op); |
1256 | tmp = insert_ob_in_ob (tmp, op); |
1255 | |
1257 | |
1256 | if (tmp->glow_radius > op->glow_radius) |
1258 | if (tmp->glow_radius > op->glow_radius) |
1257 | op->glow_radius = tmp->glow_radius; |
1259 | op->glow_radius = tmp->glow_radius; |
1258 | |
1260 | |
… | |
… | |
1737 | object *owner = op->env; |
1739 | object *owner = op->env; |
1738 | |
1740 | |
1739 | if (!owner) // MUST not happen, remove when true TODO |
1741 | if (!owner) // MUST not happen, remove when true TODO |
1740 | { |
1742 | { |
1741 | LOG (llevError, "swarm spell found outside inventory: %s\n", op->debug_desc ()); |
1743 | LOG (llevError, "swarm spell found outside inventory: %s\n", op->debug_desc ()); |
1742 | op->destroy (true); |
1744 | op->destroy (); |
1743 | return; |
1745 | return; |
1744 | } |
1746 | } |
1745 | |
1747 | |
1746 | if (!op->duration || !owner->is_on_map ()) |
1748 | if (!op->duration || !owner->is_on_map ()) |
1747 | { |
1749 | { |
… | |
… | |
1885 | int dam, mflags; |
1887 | int dam, mflags; |
1886 | maptile *m; |
1888 | maptile *m; |
1887 | |
1889 | |
1888 | dam = spell->stats.dam + SP_level_dam_adjust (caster, spell); |
1890 | dam = spell->stats.dam + SP_level_dam_adjust (caster, spell); |
1889 | |
1891 | |
1890 | if (!dir) |
1892 | if (dir) |
1891 | { |
|
|
1892 | new_draw_info (NDI_UNIQUE, 0, op, "In what direction?"); |
|
|
1893 | return 0; |
|
|
1894 | } |
1893 | { |
1895 | |
|
|
1896 | x = op->x + freearr_x[dir]; |
1894 | x = op->x + freearr_x[dir]; |
1897 | y = op->y + freearr_y[dir]; |
1895 | y = op->y + freearr_y[dir]; |
1898 | m = op->map; |
1896 | m = op->map; |
1899 | |
1897 | |
1900 | mflags = get_map_flags (m, &m, x, y, &x, &y); |
1898 | mflags = get_map_flags (m, &m, x, y, &x, &y); |
1901 | |
1899 | |
1902 | if (mflags & P_OUT_OF_MAP) |
1900 | if (mflags & P_OUT_OF_MAP) |
1903 | { |
1901 | { |
1904 | new_draw_info (NDI_UNIQUE, 0, op, "Nothing is there."); |
1902 | new_draw_info (NDI_UNIQUE, 0, op, "Nothing is there."); |
1905 | return 0; |
1903 | return 0; |
1906 | } |
1904 | } |
1907 | |
1905 | |
1908 | if (mflags & P_IS_ALIVE && spell->attacktype) |
1906 | if (mflags & P_IS_ALIVE && spell->attacktype) |
1909 | { |
1907 | { |
1910 | for (target = GET_MAP_OB (m, x, y); target; target = target->above) |
1908 | for (target = GET_MAP_OB (m, x, y); target; target = target->above) |
1911 | if (QUERY_FLAG (target, FLAG_MONSTER)) |
1909 | if (QUERY_FLAG (target, FLAG_MONSTER)) |
1912 | { |
1910 | { |
1913 | /* oky doky. got a target monster. Lets make a blinding attack */ |
1911 | /* oky doky. got a target monster. Lets make a blinding attack */ |
1914 | if (target->head) |
1912 | if (target->head) |
1915 | target = target->head; |
1913 | target = target->head; |
1916 | |
1914 | |
1917 | hit_player (target, dam, op, spell->attacktype, 1); |
1915 | hit_player (target, dam, op, spell->attacktype, 1); |
1918 | return 1; /* one success only! */ |
1916 | return 1; /* one success only! */ |
|
|
1917 | } |
1919 | } |
1918 | } |
1920 | } |
|
|
1921 | |
1919 | |
1922 | /* no live target, perhaps a wall is in the way? */ |
1920 | /* no live target, perhaps a wall is in the way? */ |
1923 | if (OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, x, y))) |
1921 | if (OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, x, y))) |
1924 | { |
1922 | { |
1925 | new_draw_info (NDI_UNIQUE, 0, op, "Something is in the way."); |
1923 | new_draw_info (NDI_UNIQUE, 0, op, "Something is in the way."); |
1926 | return 0; |
1924 | return 0; |
|
|
1925 | } |
1927 | } |
1926 | } |
1928 | |
1927 | |
1929 | /* ok, looks groovy to just insert a new light on the map */ |
1928 | /* ok, looks groovy to just insert a new light on the map */ |
1930 | tmp = arch_to_object (spell->other_arch); |
1929 | tmp = arch_to_object (spell->other_arch); |
1931 | if (!tmp) |
1930 | if (!tmp) |
1932 | { |
1931 | { |
1933 | LOG (llevError, "Error: spell arch for cast_light() missing.\n"); |
1932 | LOG (llevError, "Error: spell arch for cast_light() missing.\n"); |
1934 | return 0; |
1933 | return 0; |
1935 | } |
1934 | } |
|
|
1935 | |
1936 | tmp->stats.food = spell->duration + SP_level_duration_adjust (caster, spell); |
1936 | tmp->stats.food = spell->duration + SP_level_duration_adjust (caster, spell); |
|
|
1937 | |
1937 | if (tmp->glow_radius) |
1938 | if (tmp->glow_radius) |
1938 | { |
|
|
1939 | tmp->glow_radius = spell->range + SP_level_range_adjust (caster, spell); |
1939 | tmp->glow_radius = min (MAX_LIGHT_RADIUS, spell->range + SP_level_range_adjust (caster, spell)); |
1940 | if (tmp->glow_radius > MAX_LIGHT_RADII) |
|
|
1941 | tmp->glow_radius = MAX_LIGHT_RADII; |
|
|
1942 | } |
|
|
1943 | |
1940 | |
|
|
1941 | if (dir) |
1944 | m->insert (tmp, x, y, op); |
1942 | m->insert (tmp, x, y, op); |
|
|
1943 | else |
|
|
1944 | caster->outer_env ()->insert (tmp); |
|
|
1945 | |
1945 | return 1; |
1946 | return 1; |
1946 | } |
1947 | } |
1947 | |
1948 | |
1948 | /* cast_cause_disease: this spell looks along <dir> from the |
1949 | /* cast_cause_disease: this spell looks along <dir> from the |
1949 | * player and infects someone. |
1950 | * player and infects someone. |
… | |
… | |
2056 | |
2057 | |
2057 | if (infect_object (walk, disease, 1)) |
2058 | if (infect_object (walk, disease, 1)) |
2058 | { |
2059 | { |
2059 | new_draw_info_format (NDI_UNIQUE, 0, op, "You inflict %s on %s!", &disease->name, &walk->name); |
2060 | new_draw_info_format (NDI_UNIQUE, 0, op, "You inflict %s on %s!", &disease->name, &walk->name); |
2060 | |
2061 | |
2061 | disease->destroy (true); /* don't need this one anymore */ |
2062 | disease->destroy (); /* don't need this one anymore */ |
2062 | walk->map->insert (get_archetype ("detect_magic"), x, y, op); |
2063 | walk->map->insert (get_archetype ("detect_magic"), x, y, op); |
2063 | return 1; |
2064 | return 1; |
2064 | } |
2065 | } |
2065 | |
2066 | |
2066 | disease->destroy (true); |
2067 | disease->destroy (); |
2067 | } |
2068 | } |
2068 | } /* if living creature */ |
2069 | } /* if living creature */ |
2069 | } /* for range of spaces */ |
2070 | } /* for range of spaces */ |
2070 | |
2071 | |
2071 | new_draw_info (NDI_UNIQUE, 0, op, "No one caught anything!"); |
2072 | new_draw_info (NDI_UNIQUE, 0, op, "No one caught anything!"); |