… | |
… | |
24 | |
24 | |
25 | #include <global.h> |
25 | #include <global.h> |
26 | #include <spells.h> |
26 | #include <spells.h> |
27 | #include <object.h> |
27 | #include <object.h> |
28 | #include <errno.h> |
28 | #include <errno.h> |
29 | #ifndef __CEXTRACT__ |
|
|
30 | # include <sproto.h> |
29 | #include <sproto.h> |
31 | #endif |
|
|
32 | #include <sounds.h> |
30 | #include <sounds.h> |
33 | |
31 | |
34 | extern char *spell_mapping[]; |
32 | extern char *spell_mapping[]; |
35 | |
33 | |
36 | /* This returns a random spell from 'ob'. If skill is set, then |
34 | /* This returns a random spell from 'ob'. If skill is set, then |
… | |
… | |
151 | } |
149 | } |
152 | |
150 | |
153 | /* pretty basic function - basically just takes |
151 | /* pretty basic function - basically just takes |
154 | * an object, sets the x,y, and calls insert_ob_in_map |
152 | * an object, sets the x,y, and calls insert_ob_in_map |
155 | */ |
153 | */ |
156 | |
|
|
157 | void |
154 | void |
158 | spell_effect (object *spob, int x, int y, maptile *map, object *originator) |
155 | spell_effect (object *spob, int x, int y, maptile *map, object *originator) |
159 | { |
156 | { |
160 | |
|
|
161 | if (spob->other_arch != NULL) |
157 | if (spob->other_arch) |
162 | { |
158 | map->insert (arch_to_object (spob->other_arch), x, y, originator); |
163 | object *effect = arch_to_object (spob->other_arch); |
|
|
164 | |
|
|
165 | effect->x = x; |
|
|
166 | effect->y = y; |
|
|
167 | |
|
|
168 | insert_ob_in_map (effect, map, originator, 0); |
|
|
169 | } |
|
|
170 | } |
159 | } |
171 | |
160 | |
172 | /* |
161 | /* |
173 | * This function takes a caster and spell and presents the |
162 | * This function takes a caster and spell and presents the |
174 | * effective level the caster needs to be to cast the spell. |
163 | * effective level the caster needs to be to cast the spell. |
… | |
… | |
444 | if (OUT_OF_REAL_MAP (m, x, y)) |
433 | if (OUT_OF_REAL_MAP (m, x, y)) |
445 | return 0; |
434 | return 0; |
446 | for (op = GET_MAP_OB (m, x, y); op != NULL; op = op->above) |
435 | for (op = GET_MAP_OB (m, x, y); op != NULL; op = op->above) |
447 | if (QUERY_FLAG (op, FLAG_REFL_SPELL) |
436 | if (QUERY_FLAG (op, FLAG_REFL_SPELL) |
448 | && (!QUERY_FLAG (op, FLAG_ALIVE) |
437 | && (!QUERY_FLAG (op, FLAG_ALIVE) |
449 | || sp_op->type == LIGHTNING // XXX: elmex: why is LIGHTNING special cased here? |
|
|
450 | // most spells use subtypes for bolts today... |
|
|
451 | || (rndm (0, 99)) < 90 - (sp_op->level / 10))) |
438 | || (rndm (0, 99)) < 90 - (sp_op->level / 10))) |
452 | return 1; |
439 | return 1; |
453 | |
440 | |
454 | return 0; |
441 | return 0; |
455 | } |
442 | } |
… | |
… | |
473 | { |
460 | { |
474 | new_draw_info (NDI_UNIQUE, 0, op, "Something is in the way."); |
461 | new_draw_info (NDI_UNIQUE, 0, op, "Something is in the way."); |
475 | new_draw_info (NDI_UNIQUE, 0, op, "You cast it at your feet."); |
462 | new_draw_info (NDI_UNIQUE, 0, op, "You cast it at your feet."); |
476 | dir = 0; |
463 | dir = 0; |
477 | } |
464 | } |
478 | new_op->x = op->x + freearr_x[dir]; |
465 | |
479 | new_op->y = op->y + freearr_y[dir]; |
466 | op->map->insert (new_op, |
480 | if (dir == 0) |
467 | op->x + freearr_x[dir], op->y + freearr_y[dir], |
481 | insert_ob_in_map (new_op, op->map, op, INS_BELOW_ORIGINATOR); |
468 | op, |
482 | else |
469 | dir ? 0 : INS_BELOW_ORIGINATOR); |
483 | insert_ob_in_map (new_op, op->map, op, 0); |
470 | |
484 | return dir; |
471 | return dir; |
485 | } |
472 | } |
486 | |
473 | |
487 | /* Returns true if it is ok to put spell *op on the space/may provided. |
474 | /* Returns true if it is ok to put spell *op on the space/may provided. |
488 | * immune_stop is basically the attacktype of the spell (why |
475 | * immune_stop is basically the attacktype of the spell (why |
… | |
… | |
621 | return 0; |
608 | return 0; |
622 | } |
609 | } |
623 | if (QUERY_FLAG (tmp, FLAG_IS_TURNABLE)) |
610 | if (QUERY_FLAG (tmp, FLAG_IS_TURNABLE)) |
624 | SET_ANIMATION (tmp, dir); |
611 | SET_ANIMATION (tmp, dir); |
625 | |
612 | |
626 | if ((tmp = insert_ob_in_map (tmp, m, op, 0)) == NULL) |
613 | if ((tmp = insert_ob_in_map (tmp, m, op, 0))) |
627 | return 1; |
|
|
628 | |
|
|
629 | move_spell_effect (tmp); |
614 | move_spell_effect (tmp); |
630 | |
615 | |
631 | return 1; |
616 | return 1; |
632 | } |
617 | } |
633 | |
|
|
634 | |
|
|
635 | |
618 | |
636 | /***************************************************************************** |
619 | /***************************************************************************** |
637 | * |
620 | * |
638 | * Code related to rods - perhaps better located in another file? |
621 | * Code related to rods - perhaps better located in another file? |
639 | * |
622 | * |
640 | ****************************************************************************/ |
623 | ****************************************************************************/ |
641 | |
|
|
642 | void |
624 | void |
643 | regenerate_rod (object *rod) |
625 | regenerate_rod (object *rod) |
644 | { |
626 | { |
645 | if (rod->stats.hp < rod->stats.maxhp) |
627 | if (rod->stats.hp < rod->stats.maxhp) |
646 | { |
628 | { |
… | |
… | |
696 | y = op->y + freearr_y[dir]; |
678 | y = op->y + freearr_y[dir]; |
697 | |
679 | |
698 | mflags = get_map_flags (m, &m, x, y, &x, &y); |
680 | mflags = get_map_flags (m, &m, x, y, &x, &y); |
699 | |
681 | |
700 | if (mflags & P_OUT_OF_MAP) |
682 | if (mflags & P_OUT_OF_MAP) |
701 | tmp = NULL; |
683 | tmp = 0; |
702 | else |
684 | else |
703 | { |
685 | tmp = m->at (x, y).player (); |
704 | for (tmp = GET_MAP_OB (m, x, y); tmp != NULL; tmp = tmp->above) |
|
|
705 | if (tmp->type == PLAYER) |
|
|
706 | break; |
|
|
707 | } |
|
|
708 | } |
686 | } |
|
|
687 | |
709 | /* didn't find a player there, look in current square for a player */ |
688 | /* didn't find a player there, look in current square for a player */ |
710 | if (tmp == NULL) |
689 | if (!tmp) |
711 | for (tmp = GET_MAP_OB (op->map, op->x, op->y); tmp != NULL; tmp = tmp->above) |
690 | tmp = op->ms ().player (); |
712 | { |
|
|
713 | if (tmp->type == PLAYER) |
|
|
714 | break; |
|
|
715 | } |
|
|
716 | |
691 | |
717 | return tmp; |
692 | return tmp; |
718 | } |
693 | } |
719 | |
694 | |
720 | |
695 | |
… | |
… | |
817 | create_treasure (head->randomitems, head, GT_INVISIBLE, op->map->difficulty, 0); |
792 | create_treasure (head->randomitems, head, GT_INVISIBLE, op->map->difficulty, 0); |
818 | |
793 | |
819 | insert_ob_in_map (head, op->map, op, 0); |
794 | insert_ob_in_map (head, op->map, op, 0); |
820 | |
795 | |
821 | /* thought it'd be cool to insert a burnout, too. */ |
796 | /* thought it'd be cool to insert a burnout, too. */ |
822 | tmp = get_archetype ("burnout"); |
797 | op->map->insert (get_archetype ("burnout"), op->x + freearr_x[dir], op->y + freearr_y[dir], op); |
823 | tmp->map = op->map; |
|
|
824 | tmp->x = op->x + freearr_x[dir]; |
|
|
825 | tmp->y = op->y + freearr_y[dir]; |
|
|
826 | insert_ob_in_map (tmp, op->map, op, 0); |
|
|
827 | } |
798 | } |
828 | } |
799 | } |
829 | |
800 | |
830 | /* peterm: function which summons hostile monsters and |
801 | /* peterm: function which summons hostile monsters and |
831 | * places them in nearby squares. |
802 | * places them in nearby squares. |
… | |
… | |
1031 | else |
1002 | else |
1032 | { |
1003 | { |
1033 | new_draw_info (NDI_UNIQUE, 0, op, "You lose control of the mana! The uncontrolled magic blasts you!"); |
1004 | new_draw_info (NDI_UNIQUE, 0, op, "You lose control of the mana! The uncontrolled magic blasts you!"); |
1034 | tmp = get_archetype (LOOSE_MANA); |
1005 | tmp = get_archetype (LOOSE_MANA); |
1035 | tmp->level = skill->level; |
1006 | tmp->level = skill->level; |
1036 | tmp->x = op->x; |
|
|
1037 | tmp->y = op->y; |
|
|
1038 | |
1007 | |
1039 | /* increase the area of destruction a little for more powerful spells */ |
1008 | /* increase the area of destruction a little for more powerful spells */ |
1040 | tmp->range += isqrt (power); |
1009 | tmp->range += isqrt (power); |
1041 | |
1010 | |
1042 | if (power > 25) |
1011 | if (power > 25) |
1043 | tmp->stats.dam = 25 + isqrt (power); |
1012 | tmp->stats.dam = 25 + isqrt (power); |
1044 | else |
1013 | else |
1045 | tmp->stats.dam = power; /* nasty recoils! */ |
1014 | tmp->stats.dam = power; /* nasty recoils! */ |
1046 | |
1015 | |
1047 | tmp->stats.maxhp = tmp->count; |
1016 | tmp->stats.maxhp = tmp->count; |
1048 | insert_ob_in_map (tmp, op->map, NULL, 0); |
1017 | |
|
|
1018 | tmp->insert_at (op); |
1049 | } |
1019 | } |
1050 | } |
1020 | } |
1051 | } |
1021 | } |
1052 | |
1022 | |
1053 | int |
1023 | int |
… | |
… | |
1070 | if (caster->contr->party == NULL) |
1040 | if (caster->contr->party == NULL) |
1071 | { |
1041 | { |
1072 | spell->remove (); |
1042 | spell->remove (); |
1073 | return success; |
1043 | return success; |
1074 | } |
1044 | } |
1075 | for (pl = first_player; pl != NULL; pl = pl->next) |
1045 | for_all_players (pl) |
1076 | if ((pl->ob->contr->party == caster->contr->party) && (on_same_map (pl->ob, caster))) |
1046 | if ((pl->ob->contr->party == caster->contr->party) && (on_same_map (pl->ob, caster))) |
1077 | { |
1047 | { |
1078 | cast_spell (pl->ob, caster, pl->ob->facing, spell, stringarg); |
1048 | cast_spell (pl->ob, caster, pl->ob->facing, spell, stringarg); |
1079 | } |
1049 | } |
1080 | spell->remove (); |
1050 | spell->remove (); |