… | |
… | |
45 | |
45 | |
46 | /* No spells, no need to progess further */ |
46 | /* No spells, no need to progess further */ |
47 | if (!k) |
47 | if (!k) |
48 | return NULL; |
48 | return NULL; |
49 | |
49 | |
50 | s = RANDOM () % k; |
50 | s = rndm (k); |
51 | |
51 | |
52 | for (object *tmp = ob->inv; tmp; tmp = tmp->below) |
52 | for (object *tmp = ob->inv; tmp; tmp = tmp->below) |
53 | if (tmp->type == SPELL && (!skill || tmp->skill == skill)) |
53 | if (tmp->type == SPELL && (!skill || tmp->skill == skill)) |
54 | if (!s) |
54 | if (!s) |
55 | return tmp; |
55 | return tmp; |
… | |
… | |
745 | { |
745 | { |
746 | SET_ANIMATION (op, ATTACKS[i].face); |
746 | SET_ANIMATION (op, ATTACKS[i].face); |
747 | } |
747 | } |
748 | } |
748 | } |
749 | |
749 | |
750 | |
|
|
751 | /* prayer_failure: This is called when a player fails |
750 | /* prayer_failure: This is called when a player fails |
752 | * at casting a prayer. |
751 | * at casting a prayer. |
753 | * op is the player. |
752 | * op is the player. |
754 | * failure is basically how much grace they had. |
753 | * failure is basically how much grace they had. |
755 | * power is how much grace the spell would normally take to cast. |
754 | * power is how much grace the spell would normally take to cast. |
756 | */ |
755 | */ |
757 | |
|
|
758 | void |
756 | void |
759 | prayer_failure (object *op, int failure, int power) |
757 | prayer_failure (object *op, int failure, int power) |
760 | { |
758 | { |
761 | const char *godname; |
759 | const char *godname; |
762 | object *tmp; |
760 | object *tmp; |
… | |
… | |
918 | */ |
916 | */ |
919 | int |
917 | int |
920 | cast_spell (object *op, object *caster, int dir, object *spell_ob, char *stringarg) |
918 | cast_spell (object *op, object *caster, int dir, object *spell_ob, char *stringarg) |
921 | { |
919 | { |
922 | const char *godname; |
920 | const char *godname; |
923 | int success = 0, cast_level = 0; |
921 | int success = 0; |
924 | object *skill = NULL; |
922 | object *skill = NULL; |
925 | |
923 | |
926 | if (!spell_ob) |
924 | if (!spell_ob) |
927 | { |
925 | { |
928 | LOG (llevError, "cast_spell: null spell object passed\n"); |
926 | LOG (llevError, "cast_spell: null spell object passed\n"); |
… | |
… | |
976 | |
974 | |
977 | int caster_level = skill->level; |
975 | int caster_level = skill->level; |
978 | |
976 | |
979 | if (op->path_attuned & spell_ob->path_attuned) |
977 | if (op->path_attuned & spell_ob->path_attuned) |
980 | { |
978 | { |
981 | caster_level += min (cast_level * 2, ATTUNE_REPELL); |
979 | caster_level += min (caster_level, ATTUNE_REPELL); |
982 | msg = " (attuned)"; |
980 | msg = " (attuned)"; |
983 | } |
981 | } |
984 | |
982 | |
985 | if (op->path_repelled & spell_ob->path_attuned) |
983 | if (op->path_repelled & spell_ob->path_attuned) |
986 | { |
984 | { |
987 | caster_level = ATTUNE_REPELL; // negative is ok |
985 | caster_level -= ATTUNE_REPELL; // negative is ok |
988 | msg = " (repelled)"; |
986 | msg = " (repelled)"; |
989 | } |
987 | } |
990 | |
988 | |
991 | if (spell_ob->level > caster_level) |
989 | if (spell_ob->level > caster_level) |
992 | { |
990 | { |
… | |
… | |
999 | } |
997 | } |
1000 | |
998 | |
1001 | /* If the caster is the wiz, they don't ever fail, and don't have |
999 | /* If the caster is the wiz, they don't ever fail, and don't have |
1002 | * to have sufficient grace/mana. |
1000 | * to have sufficient grace/mana. |
1003 | */ |
1001 | */ |
1004 | if (!QUERY_FLAG (op, FLAG_WIZ)) |
1002 | if (!QUERY_FLAG (op, FLAG_WIZCAST)) |
1005 | { |
1003 | { |
1006 | if (SP_level_spellpoint_cost (caster, spell_ob, SPELL_MANA) && |
1004 | if (SP_level_spellpoint_cost (caster, spell_ob, SPELL_MANA) && |
1007 | SP_level_spellpoint_cost (caster, spell_ob, SPELL_MANA) > op->stats.sp) |
1005 | SP_level_spellpoint_cost (caster, spell_ob, SPELL_MANA) > op->stats.sp) |
1008 | { |
1006 | { |
1009 | op->failmsg ("You don't have enough mana!"); |
1007 | op->failmsg ("You don't have enough mana!"); |