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 | * |
… | |
… | |
19 | * along with this program; if not, write to the Free Software |
19 | * along with this program; if not, write to the Free Software |
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 | |
|
|
25 | |
24 | |
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> |
… | |
… | |
735 | return freedir[i]; |
734 | return freedir[i]; |
736 | } |
735 | } |
737 | return -1; /* flag for "keep going the way you were" */ |
736 | return -1; /* flag for "keep going the way you were" */ |
738 | } |
737 | } |
739 | |
738 | |
740 | |
|
|
741 | |
|
|
742 | /* put_a_monster: puts a monster named monstername near by |
739 | /* put_a_monster: puts a monster named monstername near by |
743 | * op. This creates the treasures for the monsters, and |
740 | * op. This creates the treasures for the monsters, and |
744 | * also deals with multipart monsters properly. |
741 | * also deals with multipart monsters properly. |
745 | */ |
742 | */ |
746 | |
|
|
747 | void |
743 | void |
748 | put_a_monster (object *op, const char *monstername) |
744 | put_a_monster (object *op, const char *monstername) |
749 | { |
745 | { |
750 | object *tmp, *head = NULL, *prev = NULL; |
746 | object *tmp, *head = NULL, *prev = NULL; |
751 | archetype *at; |
747 | archetype *at; |
… | |
… | |
824 | { |
820 | { |
825 | int attacktype; |
821 | int attacktype; |
826 | int face; |
822 | int face; |
827 | } ATTACKS[22] = |
823 | } ATTACKS[22] = |
828 | { |
824 | { |
829 | { |
|
|
830 | AT_PHYSICAL, 0}, |
825 | { AT_PHYSICAL, 0}, |
831 | { |
|
|
832 | AT_PHYSICAL, 0}, /*face = explosion */ |
826 | { AT_PHYSICAL, 0}, /*face = explosion */ |
833 | { |
|
|
834 | AT_PHYSICAL, 0}, |
827 | { AT_PHYSICAL, 0}, |
835 | { |
|
|
836 | AT_MAGIC, 1}, |
828 | { AT_MAGIC, 1}, |
837 | { |
|
|
838 | AT_MAGIC, 1}, /* face = last-burnout */ |
829 | { AT_MAGIC, 1}, /* face = last-burnout */ |
839 | { |
|
|
840 | AT_MAGIC, 1}, |
830 | { AT_MAGIC, 1}, |
841 | { |
|
|
842 | AT_FIRE, 2}, |
831 | { AT_FIRE, 2}, |
843 | { |
|
|
844 | AT_FIRE, 2}, /* face = fire.... */ |
832 | { AT_FIRE, 2}, /* face = fire.... */ |
845 | { |
|
|
846 | AT_FIRE, 2}, |
833 | { AT_FIRE, 2}, |
847 | { |
|
|
848 | AT_ELECTRICITY, 3}, |
834 | { AT_ELECTRICITY, 3}, |
849 | { |
|
|
850 | AT_ELECTRICITY, 3}, /* ball_lightning */ |
835 | { AT_ELECTRICITY, 3}, /* ball_lightning */ |
851 | { |
|
|
852 | AT_ELECTRICITY, 3}, |
836 | { AT_ELECTRICITY, 3}, |
853 | { |
|
|
854 | AT_COLD, 4}, |
837 | { AT_COLD, 4}, |
855 | { |
|
|
856 | AT_COLD, 4}, /* face=icestorm */ |
838 | { AT_COLD, 4}, /* face=icestorm */ |
857 | { |
|
|
858 | AT_COLD, 4}, |
839 | { AT_COLD, 4}, |
859 | { |
|
|
860 | AT_CONFUSION, 5}, |
840 | { AT_CONFUSION, 5}, |
861 | { |
|
|
862 | AT_POISON, 7}, |
841 | { AT_POISON, 7}, |
863 | { |
|
|
864 | AT_POISON, 7}, /* face = acid sphere. generator */ |
842 | { AT_POISON, 7}, /* face = acid sphere. generator */ |
865 | { |
|
|
866 | AT_POISON, 7}, /* poisoncloud face */ |
843 | { AT_POISON, 7}, /* poisoncloud face */ |
867 | { |
|
|
868 | AT_SLOW, 8}, |
844 | { AT_SLOW, 8}, |
869 | { |
|
|
870 | AT_PARALYZE, 9}, |
845 | { AT_PARALYZE, 9}, |
871 | { |
|
|
872 | AT_FEAR, 10}}; |
846 | { AT_FEAR, 10}, |
873 | |
847 | }; |
874 | |
|
|
875 | |
848 | |
876 | /* shuffle_attack: peterm |
849 | /* shuffle_attack: peterm |
877 | * This routine shuffles the attack of op to one of the |
850 | * This routine shuffles the attack of op to one of the |
878 | * ones in the list. It does this at random. It also |
851 | * ones in the list. It does this at random. It also |
879 | * chooses a face appropriate to the attack that is |
852 | * chooses a face appropriate to the attack that is |
… | |
… | |
1070 | * |
1043 | * |
1071 | * 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), |
1072 | * this function will decrease the mana/grace appropriately. For other |
1045 | * this function will decrease the mana/grace appropriately. For other |
1073 | * objects, the caller should do what it considers appropriate. |
1046 | * objects, the caller should do what it considers appropriate. |
1074 | */ |
1047 | */ |
1075 | |
|
|
1076 | int |
1048 | int |
1077 | 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) |
1078 | { |
1050 | { |
1079 | const char *godname; |
1051 | const char *godname; |
1080 | int success = 0, mflags, cast_level = 0, old_shoottype; |
1052 | int success = 0, mflags, cast_level = 0; |
1081 | object *skill = NULL; |
1053 | object *skill = NULL; |
1082 | |
|
|
1083 | old_shoottype = op->contr ? op->contr->shoottype : 0; |
|
|
1084 | |
1054 | |
1085 | if (!spell_ob) |
1055 | if (!spell_ob) |
1086 | { |
1056 | { |
1087 | LOG (llevError, "cast_spell: null spell object passed\n"); |
1057 | LOG (llevError, "cast_spell: null spell object passed\n"); |
1088 | return 0; |
1058 | return 0; |
… | |
… | |
1181 | if (failure < 0) |
1151 | if (failure < 0) |
1182 | { |
1152 | { |
1183 | 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."); |
1184 | if (settings.spell_failure_effects == TRUE) |
1154 | if (settings.spell_failure_effects == TRUE) |
1185 | 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); |
1186 | op->contr->shoottype = (rangetype) old_shoottype; |
1156 | |
1187 | 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); |
1188 | return 0; |
1158 | return 0; |
1189 | } |
1159 | } |
1190 | } |
1160 | } |
1191 | } |
1161 | } |
… | |
… | |
1214 | { |
1184 | { |
1215 | if (op->type != PLAYER) |
1185 | if (op->type != PLAYER) |
1216 | return 0; |
1186 | return 0; |
1217 | |
1187 | |
1218 | if ((mflags & P_NO_CLERIC) && spell_ob->stats.grace) |
1188 | if ((mflags & P_NO_CLERIC) && spell_ob->stats.grace) |
1219 | 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); |
1220 | else |
1190 | else |
1221 | switch (op->contr->shoottype) |
|
|
1222 | { |
|
|
1223 | case range_magic: |
|
|
1224 | new_draw_info (NDI_UNIQUE, 0, op, "Something blocks your spellcasting."); |
1191 | new_draw_info (NDI_UNIQUE, 0, op, "Something blocks the spell!"); |
1225 | break; |
1192 | |
1226 | case range_misc: |
|
|
1227 | new_draw_info (NDI_UNIQUE, 0, op, "Something blocks the magic of your item."); |
|
|
1228 | break; |
|
|
1229 | case range_golem: |
|
|
1230 | new_draw_info (NDI_UNIQUE, 0, op, "Something blocks the magic of your scroll."); |
|
|
1231 | break; |
|
|
1232 | default: |
|
|
1233 | break; |
|
|
1234 | } |
|
|
1235 | return 0; |
1193 | return 0; |
1236 | } |
1194 | } |
1237 | |
1195 | |
1238 | if (caster == op && settings.casting_time == TRUE && spell_ob->type == SPELL) |
1196 | if (caster == op && settings.casting_time == TRUE && spell_ob->type == SPELL) |
1239 | { |
1197 | { |
… | |
… | |
1357 | 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); |
1358 | break; |
1316 | break; |
1359 | |
1317 | |
1360 | case SP_SUMMON_GOLEM: |
1318 | case SP_SUMMON_GOLEM: |
1361 | success = summon_golem (op, caster, dir, spell_ob); |
1319 | success = summon_golem (op, caster, dir, spell_ob); |
1362 | old_shoottype = range_golem; |
|
|
1363 | break; |
1320 | break; |
1364 | |
1321 | |
1365 | case SP_DIMENSION_DOOR: |
1322 | case SP_DIMENSION_DOOR: |
1366 | /* dimension door needs the actual caster, because that is what is |
1323 | /* dimension door needs the actual caster, because that is what is |
1367 | * moved. |
1324 | * moved. |
… | |
… | |
1500 | success = cast_consecrate (op, caster, spell_ob); |
1457 | success = cast_consecrate (op, caster, spell_ob); |
1501 | break; |
1458 | break; |
1502 | |
1459 | |
1503 | case SP_ANIMATE_WEAPON: |
1460 | case SP_ANIMATE_WEAPON: |
1504 | success = animate_weapon (op, caster, spell_ob, dir); |
1461 | success = animate_weapon (op, caster, spell_ob, dir); |
1505 | old_shoottype = range_golem; |
|
|
1506 | break; |
1462 | break; |
1507 | |
1463 | |
1508 | case SP_LIGHT: |
1464 | case SP_LIGHT: |
1509 | success = cast_light (op, caster, spell_ob, dir); |
1465 | success = cast_light (op, caster, spell_ob, dir); |
1510 | break; |
1466 | break; |
… | |
… | |
1545 | |
1501 | |
1546 | /* free the spell arg */ |
1502 | /* free the spell arg */ |
1547 | if (settings.casting_time == TRUE && stringarg) |
1503 | if (settings.casting_time == TRUE && stringarg) |
1548 | { |
1504 | { |
1549 | free (stringarg); |
1505 | free (stringarg); |
1550 | stringarg = NULL; |
1506 | stringarg = 0; |
1551 | } |
1507 | } |
1552 | /* perhaps a bit of a hack, but if using a wand, it has to change the skill |
|
|
1553 | * to something like use_magic_item, but you really want to be able to fire |
|
|
1554 | * it again. |
|
|
1555 | */ |
|
|
1556 | if (op->contr) |
|
|
1557 | op->contr->shoottype = (rangetype) old_shoottype; |
|
|
1558 | |
1508 | |
1559 | return success; |
1509 | return success; |
1560 | } |
1510 | } |
1561 | |
1511 | |
1562 | |
1512 | |