… | |
… | |
183 | min_casting_level (object *caster, object *spell) |
183 | min_casting_level (object *caster, object *spell) |
184 | { |
184 | { |
185 | int new_level; |
185 | int new_level; |
186 | |
186 | |
187 | if (caster->path_denied & spell->path_attuned) |
187 | if (caster->path_denied & spell->path_attuned) |
188 | { |
|
|
189 | /* This case is not a bug, just the fact that this function is |
|
|
190 | * usually called BEFORE checking for path_deny. -AV |
|
|
191 | */ |
|
|
192 | #if 0 |
|
|
193 | LOG (llevError, "BUG: path_level_mod (arch %s, name %s): casting denied " "spell\n", caster->arch->name, caster->name); |
|
|
194 | #endif |
|
|
195 | return 1; |
188 | return 1; |
196 | } |
189 | |
197 | new_level = spell->level |
190 | new_level = spell->level |
198 | + ((caster->path_repelled & spell->path_attuned) ? +2 : 0) + ((caster->path_attuned & spell->path_attuned) ? -2 : 0); |
191 | + ((caster->path_repelled & spell->path_attuned) ? +2 : 0) + ((caster->path_attuned & spell->path_attuned) ? -2 : 0); |
|
|
192 | |
199 | return (new_level < 1) ? 1 : new_level; |
193 | return (new_level < 1) ? 1 : new_level; |
200 | } |
194 | } |
201 | |
195 | |
202 | |
196 | |
203 | /* This function returns the effective level the spell |
197 | /* This function returns the effective level the spell |
… | |
… | |
212 | { |
206 | { |
213 | int level = caster->level; |
207 | int level = caster->level; |
214 | |
208 | |
215 | /* If this is a player, try to find the matching skill */ |
209 | /* If this is a player, try to find the matching skill */ |
216 | if (caster->type == PLAYER && spell->skill) |
210 | if (caster->type == PLAYER && spell->skill) |
217 | { |
|
|
218 | int i; |
|
|
219 | |
|
|
220 | for (i = 0; i < NUM_SKILLS; i++) |
211 | for (int i = 0; i < NUM_SKILLS; i++) |
221 | if (caster->contr->last_skill_ob[i] && caster->contr->last_skill_ob[i]->skill == spell->skill) |
212 | if (caster->contr->last_skill_ob[i] && caster->contr->last_skill_ob[i]->skill == spell->skill) |
222 | { |
213 | { |
223 | level = caster->contr->last_skill_ob[i]->level; |
214 | level = caster->contr->last_skill_ob[i]->level; |
224 | break; |
215 | break; |
225 | } |
216 | } |
226 | } |
|
|
227 | |
217 | |
228 | /* if a rod is fired by a player, take the use_magic_item skill in consideration. */ |
218 | /* if a rod is fired by a player, take the use_magic_item skill in consideration. */ |
229 | if (caster->type == ROD && caster->env && caster->env->type == PLAYER) |
219 | if (caster->type == ROD && caster->env && caster->env->type == PLAYER) |
230 | { |
220 | { |
231 | object *skill = find_skill_by_number (caster->env, SK_USE_MAGIC_ITEM); |
221 | object *skill = find_skill_by_number (caster->env, SK_USE_MAGIC_ITEM); |
… | |
… | |
240 | /* Always make this at least 1. If this is zero, we get divide by zero |
230 | /* Always make this at least 1. If this is zero, we get divide by zero |
241 | * errors in various places. |
231 | * errors in various places. |
242 | */ |
232 | */ |
243 | if (level < 1) |
233 | if (level < 1) |
244 | level = 1; |
234 | level = 1; |
|
|
235 | |
245 | return level; |
236 | return level; |
246 | } |
237 | } |
247 | |
238 | |
248 | /* The following function scales the spellpoint cost of |
239 | /* The following function scales the spellpoint cost of |
249 | * a spell by it's increased effectiveness. Some of the |
240 | * a spell by it's increased effectiveness. Some of the |
… | |
… | |
598 | return 0; |
589 | return 0; |
599 | |
590 | |
600 | if (OB_TYPE_MOVE_BLOCK (tmp, GET_MAP_MOVE_BLOCK (m, x, y))) |
591 | if (OB_TYPE_MOVE_BLOCK (tmp, GET_MAP_MOVE_BLOCK (m, x, y))) |
601 | { |
592 | { |
602 | new_draw_info (NDI_UNIQUE, 0, op, "You can't cast the spell on top of a wall!\n"); |
593 | new_draw_info (NDI_UNIQUE, 0, op, "You can't cast the spell on top of a wall!\n"); |
603 | free_object (tmp); |
594 | tmp->destroy (0); |
604 | return 0; |
595 | return 0; |
605 | } |
596 | } |
606 | |
597 | |
607 | |
598 | |
608 | |
599 | |
… | |
… | |
966 | if (failure <= -20 && failure > -40) /* wonder */ |
957 | if (failure <= -20 && failure > -40) /* wonder */ |
967 | { |
958 | { |
968 | new_draw_info_format (NDI_UNIQUE, 0, op, "%s gives a sign to renew your faith.", godname); |
959 | new_draw_info_format (NDI_UNIQUE, 0, op, "%s gives a sign to renew your faith.", godname); |
969 | tmp = get_archetype (SPELL_WONDER); |
960 | tmp = get_archetype (SPELL_WONDER); |
970 | cast_cone (op, op, 0, tmp); |
961 | cast_cone (op, op, 0, tmp); |
971 | free_object (tmp); |
962 | tmp->destroy (0); |
972 | } |
963 | } |
973 | |
964 | |
974 | else if (failure <= -40 && failure > -60) /* confusion */ |
965 | else if (failure <= -40 && failure > -60) /* confusion */ |
975 | { |
966 | { |
976 | new_draw_info (NDI_UNIQUE, 0, op, "Your diety touches your mind!"); |
967 | new_draw_info (NDI_UNIQUE, 0, op, "Your diety touches your mind!"); |
… | |
… | |
1010 | if (failure <= -20 && failure > -40) /* wonder */ |
1001 | if (failure <= -20 && failure > -40) /* wonder */ |
1011 | { |
1002 | { |
1012 | new_draw_info (NDI_UNIQUE, 0, op, "Your spell causes an unexpected effect."); |
1003 | new_draw_info (NDI_UNIQUE, 0, op, "Your spell causes an unexpected effect."); |
1013 | tmp = get_archetype (SPELL_WONDER); |
1004 | tmp = get_archetype (SPELL_WONDER); |
1014 | cast_cone (op, op, 0, tmp); |
1005 | cast_cone (op, op, 0, tmp); |
1015 | free_object (tmp); |
1006 | tmp->destroy (0); |
1016 | } |
1007 | } |
1017 | |
1008 | |
1018 | else if (failure <= -40 && failure > -60) /* confusion */ |
1009 | else if (failure <= -40 && failure > -60) /* confusion */ |
1019 | { |
1010 | { |
1020 | new_draw_info (NDI_UNIQUE, 0, op, "Your magic recoils on you, making you confused!"); |
1011 | new_draw_info (NDI_UNIQUE, 0, op, "Your magic recoils on you, making you confused!"); |
… | |
… | |
1075 | /* Always cast spell on caster */ |
1066 | /* Always cast spell on caster */ |
1076 | success = cast_spell (op, caster, dir, spell, stringarg); |
1067 | success = cast_spell (op, caster, dir, spell, stringarg); |
1077 | |
1068 | |
1078 | if (caster->contr->party == NULL) |
1069 | if (caster->contr->party == NULL) |
1079 | { |
1070 | { |
1080 | remove_ob (spell); |
1071 | spell->remove (); |
1081 | return success; |
1072 | return success; |
1082 | } |
1073 | } |
1083 | for (pl = first_player; pl != NULL; pl = pl->next) |
1074 | for (pl = first_player; pl != NULL; pl = pl->next) |
1084 | if ((pl->ob->contr->party == caster->contr->party) && (on_same_map (pl->ob, caster))) |
1075 | if ((pl->ob->contr->party == caster->contr->party) && (on_same_map (pl->ob, caster))) |
1085 | { |
1076 | { |
1086 | cast_spell (pl->ob, caster, pl->ob->facing, spell, stringarg); |
1077 | cast_spell (pl->ob, caster, pl->ob->facing, spell, stringarg); |
1087 | } |
1078 | } |
1088 | remove_ob (spell); |
1079 | spell->remove (); |
1089 | return success; |
1080 | return success; |
1090 | } |
1081 | } |
1091 | |
1082 | |
1092 | /* This is where the main dispatch when someone casts a spell. |
1083 | /* This is where the main dispatch when someone casts a spell. |
1093 | * |
1084 | * |
… | |
… | |
1143 | } |
1134 | } |
1144 | |
1135 | |
1145 | /* if caster is a spell casting object, this normally shouldn't be |
1136 | /* if caster is a spell casting object, this normally shouldn't be |
1146 | * an issue, because they don't have any spellpaths set up. |
1137 | * an issue, because they don't have any spellpaths set up. |
1147 | */ |
1138 | */ |
1148 | if (caster->path_denied & spell_ob->path_attuned) |
1139 | if (caster->path_denied & spell_ob->path_attuned && !QUERY_FLAG (caster, FLAG_WIZCAST)) |
1149 | { |
1140 | { |
1150 | new_draw_info (NDI_UNIQUE, 0, op, "That spell path is denied to you."); |
1141 | new_draw_info (NDI_UNIQUE, 0, op, "That spell path is denied to you."); |
1151 | return 0; |
1142 | return 0; |
1152 | } |
1143 | } |
1153 | |
1144 | |
… | |
… | |
1692 | { |
1683 | { |
1693 | hit_player (victim, spell->stats.dam, spell, spell->attacktype, 1); |
1684 | hit_player (victim, spell->stats.dam, spell, spell->attacktype, 1); |
1694 | |
1685 | |
1695 | if (!spell->destroyed ()) |
1686 | if (!spell->destroyed ()) |
1696 | { |
1687 | { |
1697 | remove_ob (spell); |
1688 | spell->remove (); |
1698 | free_object (spell); |
1689 | spell->destroy (0); |
1699 | } |
1690 | } |
1700 | } |
1691 | } |
1701 | break; |
1692 | break; |
1702 | |
1693 | |
1703 | case SP_MOVING_BALL: |
1694 | case SP_MOVING_BALL: |