ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/server/spell_util.C
(Generate patch)

Comparing deliantra/server/server/spell_util.C (file contents):
Revision 1.39 by pippijn, Thu Mar 1 12:28:16 2007 UTC vs.
Revision 1.42 by root, Mon Apr 30 04:25:30 2007 UTC

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
736void 743void
737put_a_monster (object *op, const char *monstername) 744put_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 {
861AT_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
1059 * 1043 *
1060 * 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),
1061 * this function will decrease the mana/grace appropriately. For other 1045 * this function will decrease the mana/grace appropriately. For other
1062 * objects, the caller should do what it considers appropriate. 1046 * objects, the caller should do what it considers appropriate.
1063 */ 1047 */
1064
1065int 1048int
1066cast_spell (object *op, object *caster, int dir, object *spell_ob, char *stringarg) 1049cast_spell (object *op, object *caster, int dir, object *spell_ob, char *stringarg)
1067{ 1050{
1068 const char *godname; 1051 const char *godname;
1069 int success = 0, mflags, cast_level = 0, old_shoottype; 1052 int success = 0, mflags, cast_level = 0;
1070 object *skill = NULL; 1053 object *skill = NULL;
1071
1072 old_shoottype = op->contr ? op->contr->shoottype : 0;
1073 1054
1074 if (!spell_ob) 1055 if (!spell_ob)
1075 { 1056 {
1076 LOG (llevError, "cast_spell: null spell object passed\n"); 1057 LOG (llevError, "cast_spell: null spell object passed\n");
1077 return 0; 1058 return 0;
1170 if (failure < 0) 1151 if (failure < 0)
1171 { 1152 {
1172 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.");
1173 if (settings.spell_failure_effects == TRUE) 1154 if (settings.spell_failure_effects == TRUE)
1174 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);
1175 op->contr->shoottype = (rangetype) old_shoottype; 1156
1176 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);
1177 return 0; 1158 return 0;
1178 } 1159 }
1179 } 1160 }
1180 } 1161 }
1203 { 1184 {
1204 if (op->type != PLAYER) 1185 if (op->type != PLAYER)
1205 return 0; 1186 return 0;
1206 1187
1207 if ((mflags & P_NO_CLERIC) && spell_ob->stats.grace) 1188 if ((mflags & P_NO_CLERIC) && spell_ob->stats.grace)
1208 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);
1209 else 1190 else
1210 switch (op->contr->shoottype)
1211 {
1212 case range_magic:
1213 new_draw_info (NDI_UNIQUE, 0, op, "Something blocks your spellcasting."); 1191 new_draw_info (NDI_UNIQUE, 0, op, "Something blocks the spell!");
1214 break; 1192
1215 case range_misc:
1216 new_draw_info (NDI_UNIQUE, 0, op, "Something blocks the magic of your item.");
1217 break;
1218 case range_golem:
1219 new_draw_info (NDI_UNIQUE, 0, op, "Something blocks the magic of your scroll.");
1220 break;
1221 default:
1222 break;
1223 }
1224 return 0; 1193 return 0;
1225 } 1194 }
1226 1195
1227 if (caster == op && settings.casting_time == TRUE && spell_ob->type == SPELL) 1196 if (caster == op && settings.casting_time == TRUE && spell_ob->type == SPELL)
1228 { 1197 {
1346 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);
1347 break; 1316 break;
1348 1317
1349 case SP_SUMMON_GOLEM: 1318 case SP_SUMMON_GOLEM:
1350 success = summon_golem (op, caster, dir, spell_ob); 1319 success = summon_golem (op, caster, dir, spell_ob);
1351 old_shoottype = range_golem;
1352 break; 1320 break;
1353 1321
1354 case SP_DIMENSION_DOOR: 1322 case SP_DIMENSION_DOOR:
1355 /* dimension door needs the actual caster, because that is what is 1323 /* dimension door needs the actual caster, because that is what is
1356 * moved. 1324 * moved.
1489 success = cast_consecrate (op, caster, spell_ob); 1457 success = cast_consecrate (op, caster, spell_ob);
1490 break; 1458 break;
1491 1459
1492 case SP_ANIMATE_WEAPON: 1460 case SP_ANIMATE_WEAPON:
1493 success = animate_weapon (op, caster, spell_ob, dir); 1461 success = animate_weapon (op, caster, spell_ob, dir);
1494 old_shoottype = range_golem;
1495 break; 1462 break;
1496 1463
1497 case SP_LIGHT: 1464 case SP_LIGHT:
1498 success = cast_light (op, caster, spell_ob, dir); 1465 success = cast_light (op, caster, spell_ob, dir);
1499 break; 1466 break;
1534 1501
1535 /* free the spell arg */ 1502 /* free the spell arg */
1536 if (settings.casting_time == TRUE && stringarg) 1503 if (settings.casting_time == TRUE && stringarg)
1537 { 1504 {
1538 free (stringarg); 1505 free (stringarg);
1539 stringarg = NULL; 1506 stringarg = 0;
1540 } 1507 }
1541 /* perhaps a bit of a hack, but if using a wand, it has to change the skill
1542 * to something like use_magic_item, but you really want to be able to fire
1543 * it again.
1544 */
1545 if (op->contr)
1546 op->contr->shoottype = (rangetype) old_shoottype;
1547 1508
1548 return success; 1509 return success;
1549} 1510}
1550 1511
1551 1512

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines