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> |
… | |
… | |
628 | ****************************************************************************/ |
627 | ****************************************************************************/ |
629 | void |
628 | void |
630 | regenerate_rod (object *rod) |
629 | regenerate_rod (object *rod) |
631 | { |
630 | { |
632 | if (rod->stats.hp < rod->stats.maxhp) |
631 | if (rod->stats.hp < rod->stats.maxhp) |
633 | { |
632 | rod->stats.hp = min (rod->stats.maxhp, rod->stats.hp + 1 + rod->stats.maxhp / 10); |
634 | rod->stats.hp += 1 + rod->stats.maxhp / 10; |
|
|
635 | |
|
|
636 | if (rod->stats.hp > rod->stats.maxhp) |
|
|
637 | rod->stats.hp = rod->stats.maxhp; |
|
|
638 | } |
|
|
639 | } |
633 | } |
640 | |
|
|
641 | |
634 | |
642 | void |
635 | void |
643 | drain_rod_charge (object *rod) |
636 | drain_rod_charge (object *rod) |
644 | { |
637 | { |
645 | rod->stats.hp -= SP_level_spellpoint_cost (rod, rod->inv, SPELL_HIGHEST); |
638 | rod->stats.hp -= SP_level_spellpoint_cost (rod, rod->inv, SPELL_HIGHEST); |
… | |
… | |
735 | return freedir[i]; |
728 | return freedir[i]; |
736 | } |
729 | } |
737 | return -1; /* flag for "keep going the way you were" */ |
730 | return -1; /* flag for "keep going the way you were" */ |
738 | } |
731 | } |
739 | |
732 | |
740 | |
|
|
741 | |
|
|
742 | /* put_a_monster: puts a monster named monstername near by |
733 | /* put_a_monster: puts a monster named monstername near by |
743 | * op. This creates the treasures for the monsters, and |
734 | * op. This creates the treasures for the monsters, and |
744 | * also deals with multipart monsters properly. |
735 | * also deals with multipart monsters properly. |
745 | */ |
736 | */ |
746 | |
|
|
747 | void |
737 | void |
748 | put_a_monster (object *op, const char *monstername) |
738 | put_a_monster (object *op, const char *monstername) |
749 | { |
739 | { |
750 | object *tmp, *head = NULL, *prev = NULL; |
740 | object *tmp, *head = NULL, *prev = NULL; |
751 | archetype *at; |
741 | archetype *at; |
… | |
… | |
824 | { |
814 | { |
825 | int attacktype; |
815 | int attacktype; |
826 | int face; |
816 | int face; |
827 | } ATTACKS[22] = |
817 | } ATTACKS[22] = |
828 | { |
818 | { |
829 | { |
|
|
830 | AT_PHYSICAL, 0}, |
819 | { AT_PHYSICAL, 0}, |
831 | { |
|
|
832 | AT_PHYSICAL, 0}, /*face = explosion */ |
820 | { AT_PHYSICAL, 0}, /*face = explosion */ |
833 | { |
|
|
834 | AT_PHYSICAL, 0}, |
821 | { AT_PHYSICAL, 0}, |
835 | { |
|
|
836 | AT_MAGIC, 1}, |
822 | { AT_MAGIC, 1}, |
837 | { |
|
|
838 | AT_MAGIC, 1}, /* face = last-burnout */ |
823 | { AT_MAGIC, 1}, /* face = last-burnout */ |
839 | { |
|
|
840 | AT_MAGIC, 1}, |
824 | { AT_MAGIC, 1}, |
841 | { |
|
|
842 | AT_FIRE, 2}, |
825 | { AT_FIRE, 2}, |
843 | { |
|
|
844 | AT_FIRE, 2}, /* face = fire.... */ |
826 | { AT_FIRE, 2}, /* face = fire.... */ |
845 | { |
|
|
846 | AT_FIRE, 2}, |
827 | { AT_FIRE, 2}, |
847 | { |
|
|
848 | AT_ELECTRICITY, 3}, |
828 | { AT_ELECTRICITY, 3}, |
849 | { |
|
|
850 | AT_ELECTRICITY, 3}, /* ball_lightning */ |
829 | { AT_ELECTRICITY, 3}, /* ball_lightning */ |
851 | { |
|
|
852 | AT_ELECTRICITY, 3}, |
830 | { AT_ELECTRICITY, 3}, |
853 | { |
|
|
854 | AT_COLD, 4}, |
831 | { AT_COLD, 4}, |
855 | { |
|
|
856 | AT_COLD, 4}, /* face=icestorm */ |
832 | { AT_COLD, 4}, /* face=icestorm */ |
857 | { |
|
|
858 | AT_COLD, 4}, |
833 | { AT_COLD, 4}, |
859 | { |
|
|
860 | AT_CONFUSION, 5}, |
834 | { AT_CONFUSION, 5}, |
861 | { |
|
|
862 | AT_POISON, 7}, |
835 | { AT_POISON, 7}, |
863 | { |
|
|
864 | AT_POISON, 7}, /* face = acid sphere. generator */ |
836 | { AT_POISON, 7}, /* face = acid sphere. generator */ |
865 | { |
|
|
866 | AT_POISON, 7}, /* poisoncloud face */ |
837 | { AT_POISON, 7}, /* poisoncloud face */ |
867 | { |
|
|
868 | AT_SLOW, 8}, |
838 | { AT_SLOW, 8}, |
869 | { |
|
|
870 | AT_PARALYZE, 9}, |
839 | { AT_PARALYZE, 9}, |
871 | { |
|
|
872 | AT_FEAR, 10}}; |
840 | { AT_FEAR, 10}, |
873 | |
841 | }; |
874 | |
|
|
875 | |
842 | |
876 | /* shuffle_attack: peterm |
843 | /* shuffle_attack: peterm |
877 | * This routine shuffles the attack of op to one of the |
844 | * This routine shuffles the attack of op to one of the |
878 | * ones in the list. It does this at random. It also |
845 | * ones in the list. It does this at random. It also |
879 | * chooses a face appropriate to the attack that is |
846 | * chooses a face appropriate to the attack that is |
… | |
… | |
1070 | * |
1037 | * |
1071 | * if it is a player casting the spell (op->type == PLAYER, op == caster), |
1038 | * if it is a player casting the spell (op->type == PLAYER, op == caster), |
1072 | * this function will decrease the mana/grace appropriately. For other |
1039 | * this function will decrease the mana/grace appropriately. For other |
1073 | * objects, the caller should do what it considers appropriate. |
1040 | * objects, the caller should do what it considers appropriate. |
1074 | */ |
1041 | */ |
1075 | |
|
|
1076 | int |
1042 | int |
1077 | cast_spell (object *op, object *caster, int dir, object *spell_ob, char *stringarg) |
1043 | cast_spell (object *op, object *caster, int dir, object *spell_ob, char *stringarg) |
1078 | { |
1044 | { |
1079 | const char *godname; |
1045 | const char *godname; |
1080 | int success = 0, mflags, cast_level = 0, old_shoottype; |
1046 | int success = 0, mflags, cast_level = 0; |
1081 | object *skill = NULL; |
1047 | object *skill = NULL; |
1082 | |
|
|
1083 | old_shoottype = op->contr ? op->contr->shoottype : 0; |
|
|
1084 | |
1048 | |
1085 | if (!spell_ob) |
1049 | if (!spell_ob) |
1086 | { |
1050 | { |
1087 | LOG (llevError, "cast_spell: null spell object passed\n"); |
1051 | LOG (llevError, "cast_spell: null spell object passed\n"); |
1088 | return 0; |
1052 | return 0; |
… | |
… | |
1181 | if (failure < 0) |
1145 | if (failure < 0) |
1182 | { |
1146 | { |
1183 | new_draw_info (NDI_UNIQUE, 0, op, "You bungle the spell because you have too much heavy equipment in use."); |
1147 | 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) |
1148 | if (settings.spell_failure_effects == TRUE) |
1185 | spell_failure (op, failure, SP_level_spellpoint_cost (caster, spell_ob, SPELL_MANA), skill); |
1149 | spell_failure (op, failure, SP_level_spellpoint_cost (caster, spell_ob, SPELL_MANA), skill); |
1186 | op->contr->shoottype = (rangetype) old_shoottype; |
1150 | |
1187 | op->stats.sp -= random_roll (0, SP_level_spellpoint_cost (caster, spell_ob, SPELL_MANA), op, PREFER_LOW); |
1151 | op->stats.sp -= random_roll (0, SP_level_spellpoint_cost (caster, spell_ob, SPELL_MANA), op, PREFER_LOW); |
1188 | return 0; |
1152 | return 0; |
1189 | } |
1153 | } |
1190 | } |
1154 | } |
1191 | } |
1155 | } |
… | |
… | |
1214 | { |
1178 | { |
1215 | if (op->type != PLAYER) |
1179 | if (op->type != PLAYER) |
1216 | return 0; |
1180 | return 0; |
1217 | |
1181 | |
1218 | if ((mflags & P_NO_CLERIC) && spell_ob->stats.grace) |
1182 | 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); |
1183 | new_draw_info_format (NDI_UNIQUE, 0, op, "This ground is unholy! %s ignores you.", godname); |
|
|
1184 | else if (object *item = op->contr->ranged_ob) |
|
|
1185 | { |
|
|
1186 | if (item->type == SPELL) |
|
|
1187 | new_draw_info (NDI_UNIQUE, 0, op, "Something blocks your spellcasting."); |
|
|
1188 | else if (item->type == SCROLL) |
|
|
1189 | new_draw_info (NDI_UNIQUE, 0, op, "Something blocks the magic of your scroll."); |
|
|
1190 | else |
|
|
1191 | new_draw_info (NDI_UNIQUE, 0, op, "Something blocks the magic of your item."); |
|
|
1192 | } |
1220 | else |
1193 | else |
1221 | switch (op->contr->shoottype) |
|
|
1222 | { |
|
|
1223 | case range_magic: |
|
|
1224 | new_draw_info (NDI_UNIQUE, 0, op, "Something blocks your spellcasting."); |
1194 | new_draw_info (NDI_UNIQUE, 0, op, "Something blocks the spell!"); |
1225 | break; |
1195 | |
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; |
1196 | return 0; |
1236 | } |
1197 | } |
1237 | |
1198 | |
1238 | if (caster == op && settings.casting_time == TRUE && spell_ob->type == SPELL) |
1199 | if (caster == op && settings.casting_time == TRUE && spell_ob->type == SPELL) |
1239 | { |
1200 | { |
… | |
… | |
1357 | success = fire_arch_from_position (op, caster, op->x + freearr_x[dir], op->y + freearr_y[dir], dir, spell_ob); |
1318 | success = fire_arch_from_position (op, caster, op->x + freearr_x[dir], op->y + freearr_y[dir], dir, spell_ob); |
1358 | break; |
1319 | break; |
1359 | |
1320 | |
1360 | case SP_SUMMON_GOLEM: |
1321 | case SP_SUMMON_GOLEM: |
1361 | success = summon_golem (op, caster, dir, spell_ob); |
1322 | success = summon_golem (op, caster, dir, spell_ob); |
1362 | old_shoottype = range_golem; |
|
|
1363 | break; |
1323 | break; |
1364 | |
1324 | |
1365 | case SP_DIMENSION_DOOR: |
1325 | case SP_DIMENSION_DOOR: |
1366 | /* dimension door needs the actual caster, because that is what is |
1326 | /* dimension door needs the actual caster, because that is what is |
1367 | * moved. |
1327 | * moved. |
… | |
… | |
1500 | success = cast_consecrate (op, caster, spell_ob); |
1460 | success = cast_consecrate (op, caster, spell_ob); |
1501 | break; |
1461 | break; |
1502 | |
1462 | |
1503 | case SP_ANIMATE_WEAPON: |
1463 | case SP_ANIMATE_WEAPON: |
1504 | success = animate_weapon (op, caster, spell_ob, dir); |
1464 | success = animate_weapon (op, caster, spell_ob, dir); |
1505 | old_shoottype = range_golem; |
|
|
1506 | break; |
1465 | break; |
1507 | |
1466 | |
1508 | case SP_LIGHT: |
1467 | case SP_LIGHT: |
1509 | success = cast_light (op, caster, spell_ob, dir); |
1468 | success = cast_light (op, caster, spell_ob, dir); |
1510 | break; |
1469 | break; |
… | |
… | |
1545 | |
1504 | |
1546 | /* free the spell arg */ |
1505 | /* free the spell arg */ |
1547 | if (settings.casting_time == TRUE && stringarg) |
1506 | if (settings.casting_time == TRUE && stringarg) |
1548 | { |
1507 | { |
1549 | free (stringarg); |
1508 | free (stringarg); |
1550 | stringarg = NULL; |
1509 | stringarg = 0; |
1551 | } |
1510 | } |
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 | |
1511 | |
1559 | return success; |
1512 | return success; |
1560 | } |
1513 | } |
1561 | |
1514 | |
1562 | |
1515 | |