… | |
… | |
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 |
… | |
… | |
444 | if (OUT_OF_REAL_MAP (m, x, y)) |
442 | if (OUT_OF_REAL_MAP (m, x, y)) |
445 | return 0; |
443 | return 0; |
446 | for (op = GET_MAP_OB (m, x, y); op != NULL; op = op->above) |
444 | for (op = GET_MAP_OB (m, x, y); op != NULL; op = op->above) |
447 | if (QUERY_FLAG (op, FLAG_REFL_SPELL) |
445 | if (QUERY_FLAG (op, FLAG_REFL_SPELL) |
448 | && (!QUERY_FLAG (op, FLAG_ALIVE) |
446 | && (!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))) |
447 | || (rndm (0, 99)) < 90 - (sp_op->level / 10))) |
452 | return 1; |
448 | return 1; |
453 | |
449 | |
454 | return 0; |
450 | return 0; |
455 | } |
451 | } |
… | |
… | |
696 | y = op->y + freearr_y[dir]; |
692 | y = op->y + freearr_y[dir]; |
697 | |
693 | |
698 | mflags = get_map_flags (m, &m, x, y, &x, &y); |
694 | mflags = get_map_flags (m, &m, x, y, &x, &y); |
699 | |
695 | |
700 | if (mflags & P_OUT_OF_MAP) |
696 | if (mflags & P_OUT_OF_MAP) |
701 | tmp = NULL; |
697 | tmp = 0; |
702 | else |
698 | else |
703 | { |
699 | 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 | } |
700 | } |
|
|
701 | |
709 | /* didn't find a player there, look in current square for a player */ |
702 | /* didn't find a player there, look in current square for a player */ |
710 | if (tmp == NULL) |
703 | if (!tmp) |
711 | for (tmp = GET_MAP_OB (op->map, op->x, op->y); tmp != NULL; tmp = tmp->above) |
704 | tmp = op->ms ().player (); |
712 | { |
|
|
713 | if (tmp->type == PLAYER) |
|
|
714 | break; |
|
|
715 | } |
|
|
716 | |
705 | |
717 | return tmp; |
706 | return tmp; |
718 | } |
707 | } |
719 | |
708 | |
720 | |
709 | |
… | |
… | |
1070 | if (caster->contr->party == NULL) |
1059 | if (caster->contr->party == NULL) |
1071 | { |
1060 | { |
1072 | spell->remove (); |
1061 | spell->remove (); |
1073 | return success; |
1062 | return success; |
1074 | } |
1063 | } |
1075 | for (pl = first_player; pl != NULL; pl = pl->next) |
1064 | for_all_players (pl) |
1076 | if ((pl->ob->contr->party == caster->contr->party) && (on_same_map (pl->ob, caster))) |
1065 | if ((pl->ob->contr->party == caster->contr->party) && (on_same_map (pl->ob, caster))) |
1077 | { |
1066 | { |
1078 | cast_spell (pl->ob, caster, pl->ob->facing, spell, stringarg); |
1067 | cast_spell (pl->ob, caster, pl->ob->facing, spell, stringarg); |
1079 | } |
1068 | } |
1080 | spell->remove (); |
1069 | spell->remove (); |