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.59 by root, Mon Aug 27 05:10:51 2007 UTC vs.
Revision 1.60 by root, Sun Sep 2 05:18:52 2007 UTC

551 * dir: direction to fire in. 551 * dir: direction to fire in.
552 * spell: spell that is being fired. It uses other_arch for the archetype 552 * spell: spell that is being fired. It uses other_arch for the archetype
553 * to fire. 553 * to fire.
554 * returns 0 on failure, 1 on success. 554 * returns 0 on failure, 1 on success.
555 */ 555 */
556
557int 556int
558fire_arch_from_position (object *op, object *caster, sint16 x, sint16 y, int dir, object *spell) 557fire_arch_from_position (object *op, object *caster, sint16 x, sint16 y, int dir, object *spell)
559{ 558{
560 object *tmp; 559 object *tmp;
561 int mflags; 560 int mflags;
1040 */ 1039 */
1041int 1040int
1042cast_spell (object *op, object *caster, int dir, object *spell_ob, char *stringarg) 1041cast_spell (object *op, object *caster, int dir, object *spell_ob, char *stringarg)
1043{ 1042{
1044 const char *godname; 1043 const char *godname;
1045 int success = 0, mflags, cast_level = 0; 1044 int success = 0, cast_level = 0;
1046 object *skill = NULL; 1045 object *skill = NULL;
1047 1046
1048 if (!spell_ob) 1047 if (!spell_ob)
1049 { 1048 {
1050 LOG (llevError, "cast_spell: null spell object passed\n"); 1049 LOG (llevError, "cast_spell: null spell object passed\n");
1087 { 1086 {
1088 skill = find_skill_by_name (op, spell_ob->skill); 1087 skill = find_skill_by_name (op, spell_ob->skill);
1089 1088
1090 if (!skill) 1089 if (!skill)
1091 { 1090 {
1092 new_draw_info_format (NDI_UNIQUE, 0, op, "You need the skill %s to cast %s.", &spell_ob->skill, &spell_ob->name); 1091 op->failmsg (format ("You need the skill %s to cast %s!", &spell_ob->skill, &spell_ob->name));
1093 return 0; 1092 return 0;
1094 } 1093 }
1095 1094
1096 if (min_casting_level (op, spell_ob) > cast_level && !QUERY_FLAG (op, FLAG_WIZ)) 1095 if (min_casting_level (op, spell_ob) > cast_level && !QUERY_FLAG (op, FLAG_WIZ))
1097 { 1096 {
1098 new_draw_info (NDI_UNIQUE, 0, op, "You lack enough skill to cast that spell."); 1097 op->failmsg ("You lack enough skill to cast that spell!");
1099 return 0; 1098 return 0;
1100 } 1099 }
1101 } 1100 }
1102 1101
1103 /* If the caster is the wiz, they don't ever fail, and don't have 1102 /* If the caster is the wiz, they don't ever fail, and don't have
1106 if (!QUERY_FLAG (op, FLAG_WIZ)) 1105 if (!QUERY_FLAG (op, FLAG_WIZ))
1107 { 1106 {
1108 if (SP_level_spellpoint_cost (caster, spell_ob, SPELL_MANA) && 1107 if (SP_level_spellpoint_cost (caster, spell_ob, SPELL_MANA) &&
1109 SP_level_spellpoint_cost (caster, spell_ob, SPELL_MANA) > op->stats.sp) 1108 SP_level_spellpoint_cost (caster, spell_ob, SPELL_MANA) > op->stats.sp)
1110 { 1109 {
1111 new_draw_info (NDI_UNIQUE, 0, op, "You don't have enough mana."); 1110 op->failmsg ("You don't have enough mana!");
1112 return 0; 1111 return 0;
1113 } 1112 }
1114 1113
1115 if (SP_level_spellpoint_cost (caster, spell_ob, SPELL_GRACE) && 1114 if (SP_level_spellpoint_cost (caster, spell_ob, SPELL_GRACE) &&
1116 SP_level_spellpoint_cost (caster, spell_ob, SPELL_GRACE) > op->stats.grace) 1115 SP_level_spellpoint_cost (caster, spell_ob, SPELL_GRACE) > op->stats.grace)
1117 { 1116 {
1118 if (random_roll (0, op->stats.Wis - 1, op, PREFER_HIGH) + op->stats.grace - 1117 if (random_roll (0, op->stats.Wis - 1, op, PREFER_HIGH) + op->stats.grace -
1119 10 * SP_level_spellpoint_cost (caster, spell_ob, SPELL_GRACE) / op->stats.maxgrace > 0) 1118 10 * SP_level_spellpoint_cost (caster, spell_ob, SPELL_GRACE) / op->stats.maxgrace > 0)
1120 {
1121 new_draw_info_format (NDI_UNIQUE, 0, op, "%s grants your prayer, though you are unworthy.", godname); 1119 op->statusmsg (format ("%s grants your prayer, though you are unworthy.", godname));
1122 }
1123 else 1120 else
1124 { 1121 {
1125 prayer_failure (op, op->stats.grace, SP_level_spellpoint_cost (caster, spell_ob, SPELL_GRACE) - op->stats.grace); 1122 prayer_failure (op, op->stats.grace, SP_level_spellpoint_cost (caster, spell_ob, SPELL_GRACE) - op->stats.grace);
1126 new_draw_info_format (NDI_UNIQUE, 0, op, "%s ignores your prayer.", godname); 1123 op->failmsg (format ("%s ignores your prayer.", godname));
1127 return 0; 1124 return 0;
1128 } 1125 }
1129 } 1126 }
1130 1127
1131 /* player/monster is trying to cast the spell. might fumble it */ 1128 /* player/monster is trying to cast the spell. might fumble it */
1132 if (spell_ob->stats.grace && random_roll (0, 99, op, PREFER_HIGH) < 1129 if (spell_ob->stats.grace && random_roll (0, 99, op, PREFER_HIGH) <
1133 (spell_ob->level / (float) MAX (1, op->level) * cleric_chance[op->stats.Wis])) 1130 (spell_ob->level / (float) MAX (1, op->level) * cleric_chance[op->stats.Wis]))
1134 { 1131 {
1135 op->contr->play_sound (sound_find ("fumble_spell")); 1132 op->contr->play_sound (sound_find ("fumble_spell"));
1136 new_draw_info (NDI_UNIQUE, 0, op, "You fumble the prayer."); 1133 op->failmsg ("You fumble the prayer.");
1137 1134
1138 op->stats.grace -= random_roll (1, SP_level_spellpoint_cost (caster, spell_ob, SPELL_GRACE), op, PREFER_LOW); 1135 op->stats.grace -= random_roll (1, SP_level_spellpoint_cost (caster, spell_ob, SPELL_GRACE), op, PREFER_LOW);
1139 return 0; 1136 return 0;
1140 } 1137 }
1141 else if (spell_ob->stats.sp) 1138 else if (spell_ob->stats.sp)
1142 { 1139 {
1143 int failure = random_roll (0, 199, op, PREFER_HIGH) - op->contr->encumbrance + op->level - spell_ob->level + 35; 1140 int failure = random_roll (0, 199, op, PREFER_HIGH) - op->contr->encumbrance + op->level - spell_ob->level + 35;
1144 1141
1145 if (failure < 0) 1142 if (failure < 0)
1146 { 1143 {
1147 new_draw_info (NDI_UNIQUE, 0, op, "You bungle the spell because you have too much heavy equipment in use."); 1144 op->failmsg ("You bungle the spell because you have too much heavy equipment in use.");
1148 if (settings.spell_failure_effects == TRUE) 1145 if (settings.spell_failure_effects == TRUE)
1149 spell_failure (op, failure, SP_level_spellpoint_cost (caster, spell_ob, SPELL_MANA), skill); 1146 spell_failure (op, failure, SP_level_spellpoint_cost (caster, spell_ob, SPELL_MANA), skill);
1150 1147
1151 op->stats.sp -= random_roll (0, SP_level_spellpoint_cost (caster, spell_ob, SPELL_MANA), op, PREFER_LOW); 1148 op->stats.sp -= random_roll (0, SP_level_spellpoint_cost (caster, spell_ob, SPELL_MANA), op, PREFER_LOW);
1152 return 0; 1149 return 0;
1153 } 1150 }
1154 } 1151 }
1155 } 1152 }
1156 } 1153 }
1157 1154
1158 mflags = get_map_flags (op->map, NULL, op->x, op->y, NULL, NULL); 1155 int mflags = op->ms ().flags ();
1159 1156
1160 /* See if we can cast a spell here. If the caster and op are 1157 /* See if we can cast a spell here. If the caster and op are
1161 * not alive, then this would mean that the mapmaker put the 1158 * not alive, then this would mean that the mapmaker put the
1162 * objects on the space - presume that they know what they are 1159 * objects on the space - presume that they know what they are
1163 * doing. 1160 * doing.
1182 if ((mflags & P_NO_CLERIC) && spell_ob->stats.grace) 1179 if ((mflags & P_NO_CLERIC) && spell_ob->stats.grace)
1183 op->failmsg (format ("This ground is unholy! %s ignores you.", godname)); 1180 op->failmsg (format ("This ground is unholy! %s ignores you.", godname));
1184 else if (object *item = op->contr->ranged_ob) 1181 else if (object *item = op->contr->ranged_ob)
1185 { 1182 {
1186 if (item->type == SPELL) 1183 if (item->type == SPELL)
1187 new_draw_info (NDI_UNIQUE, 0, op, "Something blocks your spellcasting."); 1184 op->failmsg ("Something blocks your spellcasting.");
1188 else if (item->type == SCROLL) 1185 else if (item->type == SCROLL)
1189 new_draw_info (NDI_UNIQUE, 0, op, "Something blocks the magic of your scroll."); 1186 op->failmsg ("Something blocks the magic of your scroll.");
1190 else 1187 else
1191 new_draw_info (NDI_UNIQUE, 0, op, "Something blocks the magic of your item."); 1188 op->failmsg ("Something blocks the magic of your item.");
1192 } 1189 }
1193 else 1190 else
1194 new_draw_info (NDI_UNIQUE, 0, op, "Something blocks the spell!"); 1191 op->failmsg ("Something blocks the spell!");
1195 1192
1196 return 0; 1193 return 0;
1197 } 1194 }
1198 1195
1199 /* Take into account how long it takes to cast the spell. 1196 /* Take into account how long it takes to cast the spell.
1229 if (op != caster && !skill && caster->skill) 1226 if (op != caster && !skill && caster->skill)
1230 { 1227 {
1231 skill = find_skill_by_name (op, caster->skill); 1228 skill = find_skill_by_name (op, caster->skill);
1232 if (!skill) 1229 if (!skill)
1233 { 1230 {
1234 new_draw_info_format (NDI_UNIQUE, 0, op, "You lack the skill %s to use the %s", &caster->skill, query_name (caster)); 1231 op->failmsg (format ("You lack the skill %s to use the %s!", &caster->skill, query_name (caster)));
1235 return 0; 1232 return 0;
1236 } 1233 }
1237 1234
1238 op->change_skill (skill); /* needed for proper exp credit */ 1235 op->change_skill (skill); /* needed for proper exp credit */
1239 } 1236 }
1368#ifdef NO_POLYMORPH 1365#ifdef NO_POLYMORPH
1369 /* Not great, but at least provide feedback so if players do have 1366 /* Not great, but at least provide feedback so if players do have
1370 * polymorph (ie, find it as a preset item or left over from before 1367 * polymorph (ie, find it as a preset item or left over from before
1371 * it was disabled), they get some feedback. 1368 * it was disabled), they get some feedback.
1372 */ 1369 */
1373 new_draw_info (NDI_UNIQUE, 0, op, "The spell fizzles"); 1370 op->failmsg ("The spell fizzles!");
1374 success = 0; 1371 success = 0;
1375#else 1372#else
1376 success = cast_polymorph (op, caster, spell_ob, dir); 1373 success = cast_polymorph (op, caster, spell_ob, dir);
1377#endif 1374#endif
1378 break; 1375 break;
1398 break; 1395 break;
1399 1396
1400 case SP_MOVING_BALL: 1397 case SP_MOVING_BALL:
1401 if (spell_ob->path_repelled && (spell_ob->path_repelled & caster->path_attuned) != spell_ob->path_repelled) 1398 if (spell_ob->path_repelled && (spell_ob->path_repelled & caster->path_attuned) != spell_ob->path_repelled)
1402 { 1399 {
1403 new_draw_info_format (NDI_UNIQUE, 0, op, "You lack the proper attunement to cast %s", &spell_ob->name); 1400 op->failmsg (format ("You lack the proper attunement to cast %s!", &spell_ob->name));
1404 success = 0; 1401 success = 0;
1405 } 1402 }
1406 else 1403 else
1407 success = fire_arch_from_position (op, caster, op->x + freearr_x[dir], op->y + freearr_y[dir], dir, spell_ob); 1404 success = fire_arch_from_position (op, caster, op->x + freearr_x[dir], op->y + freearr_y[dir], dir, spell_ob);
1408 break; 1405 break;
1463 op->play_sound (success ? spell_ob->sound : sound_find ("fumble_spell")); 1460 op->play_sound (success ? spell_ob->sound : sound_find ("fumble_spell"));
1464 1461
1465 return success; 1462 return success;
1466} 1463}
1467 1464
1468
1469/* This is called from time.c/process_object(). That function 1465/* This is called from time.c/process_object(). That function
1470 * calls this for any SPELL_EFFECT type objects. This function 1466 * calls this for any SPELL_EFFECT type objects. This function
1471 * then dispatches them to the appropriate specific routines. 1467 * then dispatches them to the appropriate specific routines.
1472 */ 1468 */
1473void 1469void
1474move_spell_effect (object *op) 1470move_spell_effect (object *op)
1475{ 1471{
1566 else if (victim->materialname) 1562 else if (victim->materialname)
1567 save_throw_object (victim, spell->attacktype, spell); 1563 save_throw_object (victim, spell->attacktype, spell);
1568 break; 1564 break;
1569 } 1565 }
1570} 1566}
1567

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines