1 | /* |
1 | /* |
2 | * CrossFire, A Multiplayer game for X-windows |
2 | * CrossFire, A Multiplayer game |
3 | * |
3 | * |
4 | * Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team |
4 | * Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team |
5 | * Copyright (C) 2001 Mark Wedel & Crossfire Development Team |
5 | * Copyright (C) 2001 Mark Wedel & Crossfire Development Team |
6 | * Copyright (C) 1992 Frank Tore Johansen |
6 | * Copyright (C) 1992 Frank Tore Johansen |
7 | * |
7 | * |
… | |
… | |
20 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
20 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
21 | * |
21 | * |
22 | * The authors can be reached via e-mail at <crossfire@schmorp.de> |
22 | * The authors can be reached via e-mail at <crossfire@schmorp.de> |
23 | */ |
23 | */ |
24 | |
24 | |
25 | |
|
|
26 | #include <global.h> |
25 | #include <global.h> |
27 | #include <spells.h> |
26 | #include <spells.h> |
28 | #include <object.h> |
27 | #include <object.h> |
29 | #include <errno.h> |
28 | #include <errno.h> |
30 | #include <sproto.h> |
29 | #include <sproto.h> |
… | |
… | |
497 | * resources, and may not work as well if a player is standing |
496 | * resources, and may not work as well if a player is standing |
498 | * on top of a counterwall spell (may hit the player before being |
497 | * on top of a counterwall spell (may hit the player before being |
499 | * removed.) On the other hand, it may be more dramatic for the |
498 | * removed.) On the other hand, it may be more dramatic for the |
500 | * spell to actually hit the counterwall and be sucked up. |
499 | * spell to actually hit the counterwall and be sucked up. |
501 | */ |
500 | */ |
502 | if ((tmp->attacktype & AT_COUNTERSPELL) && |
501 | if ((tmp->attacktype & AT_COUNTERSPELL) |
503 | (tmp->type != PLAYER) && !QUERY_FLAG (tmp, FLAG_MONSTER) && |
502 | && !QUERY_FLAG (tmp, FLAG_MONSTER) |
504 | (tmp->type != WEAPON) && (tmp->type != BOW) && (tmp->type != ARROW) && (tmp->type != GOLEM) && (immune_stop & AT_MAGIC)) |
503 | && (tmp->type != PLAYER) |
|
|
504 | && (tmp->type != WEAPON) |
|
|
505 | && (tmp->type != BOW) |
|
|
506 | && (tmp->type != ARROW) |
|
|
507 | && (tmp->type != GOLEM) |
|
|
508 | && !QUERY_FLAG (tmp, FLAG_IS_FLOOR) // XXX: |
|
|
509 | // we special case floor here because there |
|
|
510 | // are sometimes spell effect floors |
|
|
511 | // which are used to inflict damage |
|
|
512 | // (and those shouldn't go away from |
|
|
513 | // sanctuary) see also: permanent lava |
|
|
514 | && (immune_stop & AT_MAGIC)) |
505 | return 0; |
515 | return 0; |
506 | |
516 | |
507 | /* This is to prevent 'out of control' spells. Basically, this |
517 | /* This is to prevent 'out of control' spells. Basically, this |
508 | * limits one spell effect per space per spell. This is definately |
518 | * limits one spell effect per space per spell. This is definately |
509 | * needed for performance reasons, and just for playability I believe. |
519 | * needed for performance reasons, and just for playability I believe. |
… | |
… | |
724 | return freedir[i]; |
734 | return freedir[i]; |
725 | } |
735 | } |
726 | return -1; /* flag for "keep going the way you were" */ |
736 | return -1; /* flag for "keep going the way you were" */ |
727 | } |
737 | } |
728 | |
738 | |
729 | |
|
|
730 | |
|
|
731 | /* put_a_monster: puts a monster named monstername near by |
739 | /* put_a_monster: puts a monster named monstername near by |
732 | * op. This creates the treasures for the monsters, and |
740 | * op. This creates the treasures for the monsters, and |
733 | * also deals with multipart monsters properly. |
741 | * also deals with multipart monsters properly. |
734 | */ |
742 | */ |
735 | |
|
|
736 | void |
743 | void |
737 | put_a_monster (object *op, const char *monstername) |
744 | put_a_monster (object *op, const char *monstername) |
738 | { |
745 | { |
739 | object *tmp, *head = NULL, *prev = NULL; |
746 | object *tmp, *head = NULL, *prev = NULL; |
740 | archetype *at; |
747 | archetype *at; |
… | |
… | |
813 | { |
820 | { |
814 | int attacktype; |
821 | int attacktype; |
815 | int face; |
822 | int face; |
816 | } ATTACKS[22] = |
823 | } ATTACKS[22] = |
817 | { |
824 | { |
818 | { |
|
|
819 | AT_PHYSICAL, 0}, |
825 | { AT_PHYSICAL, 0}, |
820 | { |
|
|
821 | AT_PHYSICAL, 0}, /*face = explosion */ |
826 | { AT_PHYSICAL, 0}, /*face = explosion */ |
822 | { |
|
|
823 | AT_PHYSICAL, 0}, |
827 | { AT_PHYSICAL, 0}, |
824 | { |
|
|
825 | AT_MAGIC, 1}, |
828 | { AT_MAGIC, 1}, |
826 | { |
|
|
827 | AT_MAGIC, 1}, /* face = last-burnout */ |
829 | { AT_MAGIC, 1}, /* face = last-burnout */ |
828 | { |
|
|
829 | AT_MAGIC, 1}, |
830 | { AT_MAGIC, 1}, |
830 | { |
|
|
831 | AT_FIRE, 2}, |
831 | { AT_FIRE, 2}, |
832 | { |
|
|
833 | AT_FIRE, 2}, /* face = fire.... */ |
832 | { AT_FIRE, 2}, /* face = fire.... */ |
834 | { |
|
|
835 | AT_FIRE, 2}, |
833 | { AT_FIRE, 2}, |
836 | { |
|
|
837 | AT_ELECTRICITY, 3}, |
834 | { AT_ELECTRICITY, 3}, |
838 | { |
|
|
839 | AT_ELECTRICITY, 3}, /* ball_lightning */ |
835 | { AT_ELECTRICITY, 3}, /* ball_lightning */ |
840 | { |
|
|
841 | AT_ELECTRICITY, 3}, |
836 | { AT_ELECTRICITY, 3}, |
842 | { |
|
|
843 | AT_COLD, 4}, |
837 | { AT_COLD, 4}, |
844 | { |
|
|
845 | AT_COLD, 4}, /* face=icestorm */ |
838 | { AT_COLD, 4}, /* face=icestorm */ |
846 | { |
|
|
847 | AT_COLD, 4}, |
839 | { AT_COLD, 4}, |
848 | { |
|
|
849 | AT_CONFUSION, 5}, |
840 | { AT_CONFUSION, 5}, |
850 | { |
|
|
851 | AT_POISON, 7}, |
841 | { AT_POISON, 7}, |
852 | { |
|
|
853 | AT_POISON, 7}, /* face = acid sphere. generator */ |
842 | { AT_POISON, 7}, /* face = acid sphere. generator */ |
854 | { |
|
|
855 | AT_POISON, 7}, /* poisoncloud face */ |
843 | { AT_POISON, 7}, /* poisoncloud face */ |
856 | { |
|
|
857 | AT_SLOW, 8}, |
844 | { AT_SLOW, 8}, |
858 | { |
|
|
859 | AT_PARALYZE, 9}, |
845 | { AT_PARALYZE, 9}, |
860 | { |
|
|
861 | AT_FEAR, 10}}; |
846 | { AT_FEAR, 10}, |
862 | |
847 | }; |
863 | |
|
|
864 | |
848 | |
865 | /* shuffle_attack: peterm |
849 | /* shuffle_attack: peterm |
866 | * This routine shuffles the attack of op to one of the |
850 | * This routine shuffles the attack of op to one of the |
867 | * ones in the list. It does this at random. It also |
851 | * ones in the list. It does this at random. It also |
868 | * chooses a face appropriate to the attack that is |
852 | * chooses a face appropriate to the attack that is |
… | |
… | |
1006 | |
990 | |
1007 | int |
991 | int |
1008 | cast_party_spell (object *op, object *caster, int dir, object *spell_ob, char *stringarg) |
992 | cast_party_spell (object *op, object *caster, int dir, object *spell_ob, char *stringarg) |
1009 | { |
993 | { |
1010 | int success; |
994 | int success; |
1011 | player *pl; |
|
|
1012 | object *spell; |
995 | object *spell; |
1013 | |
996 | |
1014 | if (!spell_ob->other_arch) |
997 | if (!spell_ob->other_arch) |
1015 | { |
998 | { |
1016 | LOG (llevError, "cast_party_spell: empty other arch\n"); |
999 | LOG (llevError, "cast_party_spell: empty other arch\n"); |
… | |
… | |
1060 | * |
1043 | * |
1061 | * if it is a player casting the spell (op->type == PLAYER, op == caster), |
1044 | * if it is a player casting the spell (op->type == PLAYER, op == caster), |
1062 | * this function will decrease the mana/grace appropriately. For other |
1045 | * this function will decrease the mana/grace appropriately. For other |
1063 | * objects, the caller should do what it considers appropriate. |
1046 | * objects, the caller should do what it considers appropriate. |
1064 | */ |
1047 | */ |
1065 | |
|
|
1066 | int |
1048 | int |
1067 | cast_spell (object *op, object *caster, int dir, object *spell_ob, char *stringarg) |
1049 | cast_spell (object *op, object *caster, int dir, object *spell_ob, char *stringarg) |
1068 | { |
1050 | { |
1069 | const char *godname; |
1051 | const char *godname; |
1070 | int success = 0, mflags, cast_level = 0, old_shoottype; |
1052 | int success = 0, mflags, cast_level = 0; |
1071 | object *skill = NULL; |
1053 | object *skill = NULL; |
1072 | |
|
|
1073 | old_shoottype = op->contr ? op->contr->shoottype : 0; |
|
|
1074 | |
1054 | |
1075 | if (!spell_ob) |
1055 | if (!spell_ob) |
1076 | { |
1056 | { |
1077 | LOG (llevError, "cast_spell: null spell object passed\n"); |
1057 | LOG (llevError, "cast_spell: null spell object passed\n"); |
1078 | return 0; |
1058 | return 0; |
… | |
… | |
1171 | if (failure < 0) |
1151 | if (failure < 0) |
1172 | { |
1152 | { |
1173 | new_draw_info (NDI_UNIQUE, 0, op, "You bungle the spell because you have too much heavy equipment in use."); |
1153 | new_draw_info (NDI_UNIQUE, 0, op, "You bungle the spell because you have too much heavy equipment in use."); |
1174 | if (settings.spell_failure_effects == TRUE) |
1154 | if (settings.spell_failure_effects == TRUE) |
1175 | spell_failure (op, failure, SP_level_spellpoint_cost (caster, spell_ob, SPELL_MANA), skill); |
1155 | spell_failure (op, failure, SP_level_spellpoint_cost (caster, spell_ob, SPELL_MANA), skill); |
1176 | op->contr->shoottype = (rangetype) old_shoottype; |
1156 | |
1177 | op->stats.sp -= random_roll (0, SP_level_spellpoint_cost (caster, spell_ob, SPELL_MANA), op, PREFER_LOW); |
1157 | op->stats.sp -= random_roll (0, SP_level_spellpoint_cost (caster, spell_ob, SPELL_MANA), op, PREFER_LOW); |
1178 | return 0; |
1158 | return 0; |
1179 | } |
1159 | } |
1180 | } |
1160 | } |
1181 | } |
1161 | } |
… | |
… | |
1204 | { |
1184 | { |
1205 | if (op->type != PLAYER) |
1185 | if (op->type != PLAYER) |
1206 | return 0; |
1186 | return 0; |
1207 | |
1187 | |
1208 | if ((mflags & P_NO_CLERIC) && spell_ob->stats.grace) |
1188 | if ((mflags & P_NO_CLERIC) && spell_ob->stats.grace) |
1209 | new_draw_info_format (NDI_UNIQUE, 0, op, "This ground is unholy! %s ignores you.", godname); |
1189 | new_draw_info_format (NDI_UNIQUE, 0, op, "This ground is unholy! %s ignores you.", godname); |
1210 | else |
1190 | else |
1211 | switch (op->contr->shoottype) |
|
|
1212 | { |
|
|
1213 | case range_magic: |
|
|
1214 | new_draw_info (NDI_UNIQUE, 0, op, "Something blocks your spellcasting."); |
1191 | new_draw_info (NDI_UNIQUE, 0, op, "Something blocks the spell!"); |
1215 | break; |
1192 | |
1216 | case range_misc: |
|
|
1217 | new_draw_info (NDI_UNIQUE, 0, op, "Something blocks the magic of your item."); |
|
|
1218 | break; |
|
|
1219 | case range_golem: |
|
|
1220 | new_draw_info (NDI_UNIQUE, 0, op, "Something blocks the magic of your scroll."); |
|
|
1221 | break; |
|
|
1222 | default: |
|
|
1223 | break; |
|
|
1224 | } |
|
|
1225 | return 0; |
1193 | return 0; |
1226 | } |
1194 | } |
1227 | |
1195 | |
1228 | if (caster == op && settings.casting_time == TRUE && spell_ob->type == SPELL) |
1196 | if (caster == op && settings.casting_time == TRUE && spell_ob->type == SPELL) |
1229 | { |
1197 | { |
… | |
… | |
1347 | success = fire_arch_from_position (op, caster, op->x + freearr_x[dir], op->y + freearr_y[dir], dir, spell_ob); |
1315 | success = fire_arch_from_position (op, caster, op->x + freearr_x[dir], op->y + freearr_y[dir], dir, spell_ob); |
1348 | break; |
1316 | break; |
1349 | |
1317 | |
1350 | case SP_SUMMON_GOLEM: |
1318 | case SP_SUMMON_GOLEM: |
1351 | success = summon_golem (op, caster, dir, spell_ob); |
1319 | success = summon_golem (op, caster, dir, spell_ob); |
1352 | old_shoottype = range_golem; |
|
|
1353 | break; |
1320 | break; |
1354 | |
1321 | |
1355 | case SP_DIMENSION_DOOR: |
1322 | case SP_DIMENSION_DOOR: |
1356 | /* dimension door needs the actual caster, because that is what is |
1323 | /* dimension door needs the actual caster, because that is what is |
1357 | * moved. |
1324 | * moved. |
… | |
… | |
1490 | success = cast_consecrate (op, caster, spell_ob); |
1457 | success = cast_consecrate (op, caster, spell_ob); |
1491 | break; |
1458 | break; |
1492 | |
1459 | |
1493 | case SP_ANIMATE_WEAPON: |
1460 | case SP_ANIMATE_WEAPON: |
1494 | success = animate_weapon (op, caster, spell_ob, dir); |
1461 | success = animate_weapon (op, caster, spell_ob, dir); |
1495 | old_shoottype = range_golem; |
|
|
1496 | break; |
1462 | break; |
1497 | |
1463 | |
1498 | case SP_LIGHT: |
1464 | case SP_LIGHT: |
1499 | success = cast_light (op, caster, spell_ob, dir); |
1465 | success = cast_light (op, caster, spell_ob, dir); |
1500 | break; |
1466 | break; |
… | |
… | |
1535 | |
1501 | |
1536 | /* free the spell arg */ |
1502 | /* free the spell arg */ |
1537 | if (settings.casting_time == TRUE && stringarg) |
1503 | if (settings.casting_time == TRUE && stringarg) |
1538 | { |
1504 | { |
1539 | free (stringarg); |
1505 | free (stringarg); |
1540 | stringarg = NULL; |
1506 | stringarg = 0; |
1541 | } |
1507 | } |
1542 | /* perhaps a bit of a hack, but if using a wand, it has to change the skill |
|
|
1543 | * to something like use_magic_item, but you really want to be able to fire |
|
|
1544 | * it again. |
|
|
1545 | */ |
|
|
1546 | if (op->contr) |
|
|
1547 | op->contr->shoottype = (rangetype) old_shoottype; |
|
|
1548 | |
1508 | |
1549 | return success; |
1509 | return success; |
1550 | } |
1510 | } |
1551 | |
1511 | |
1552 | |
1512 | |