… | |
… | |
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; |
… | |
… | |
93 | // compute the attuned/repelled bonus |
93 | // compute the attuned/repelled bonus |
94 | // attuned only increases up to 2 times the original level (i.e. bonus <= level) */ |
94 | // attuned only increases up to 2 times the original level (i.e. bonus <= level) */ |
95 | // repell has no such quarrels |
95 | // repell has no such quarrels |
96 | return (caster->path_attuned & spell->path_attuned ? min (level, +ATTUNE_REPELL) : 0) |
96 | return (caster->path_attuned & spell->path_attuned ? min (level, +ATTUNE_REPELL) : 0) |
97 | + (caster->path_repelled & spell->path_attuned ? -ATTUNE_REPELL : 0); |
97 | + (caster->path_repelled & spell->path_attuned ? -ATTUNE_REPELL : 0); |
98 | } |
|
|
99 | |
|
|
100 | /* |
|
|
101 | * This function takes a caster and spell and presents the |
|
|
102 | * effective level the caster needs to be to cast the spell. |
|
|
103 | * basically, it just adjusts the spell->level with attuned/repelled |
|
|
104 | * spellpaths. Was called path_level_mod. |
|
|
105 | * |
|
|
106 | * caster is person casting the spell. |
|
|
107 | * spell is the spell object. |
|
|
108 | * Returns modified level. |
|
|
109 | */ |
|
|
110 | int |
|
|
111 | min_casting_level (object *caster, object *spell) |
|
|
112 | { |
|
|
113 | if (caster->path_denied & spell->path_attuned) |
|
|
114 | return 500; |
|
|
115 | |
|
|
116 | return max (1, spell->level + attuned_bonus (caster, spell, spell->level)); |
|
|
117 | } |
98 | } |
118 | |
99 | |
119 | /* This function returns the effective level the spell |
100 | /* This function returns the effective level the spell |
120 | * is being cast at. |
101 | * is being cast at. |
121 | */ |
102 | */ |
… | |
… | |
937 | */ |
918 | */ |
938 | int |
919 | int |
939 | cast_spell (object *op, object *caster, int dir, object *spell_ob, char *stringarg) |
920 | cast_spell (object *op, object *caster, int dir, object *spell_ob, char *stringarg) |
940 | { |
921 | { |
941 | const char *godname; |
922 | const char *godname; |
942 | int success = 0, cast_level = 0; |
923 | int success = 0; |
943 | object *skill = NULL; |
924 | object *skill = NULL; |
944 | |
925 | |
945 | if (!spell_ob) |
926 | if (!spell_ob) |
946 | { |
927 | { |
947 | LOG (llevError, "cast_spell: null spell object passed\n"); |
928 | LOG (llevError, "cast_spell: null spell object passed\n"); |
… | |
… | |
995 | |
976 | |
996 | int caster_level = skill->level; |
977 | int caster_level = skill->level; |
997 | |
978 | |
998 | if (op->path_attuned & spell_ob->path_attuned) |
979 | if (op->path_attuned & spell_ob->path_attuned) |
999 | { |
980 | { |
1000 | caster_level += min (cast_level * 2, ATTUNE_REPELL); |
981 | caster_level += min (caster_level, ATTUNE_REPELL); |
1001 | msg = " (attuned)"; |
982 | msg = " (attuned)"; |
1002 | } |
983 | } |
1003 | |
984 | |
1004 | if (op->path_repelled & spell_ob->path_attuned) |
985 | if (op->path_repelled & spell_ob->path_attuned) |
1005 | { |
986 | { |
1006 | caster_level = ATTUNE_REPELL; // negative is ok |
987 | caster_level -= ATTUNE_REPELL; // negative is ok |
1007 | msg = " (repelled)"; |
988 | msg = " (repelled)"; |
1008 | } |
989 | } |
1009 | |
990 | |
1010 | if (spell_ob->level > caster_level) |
991 | if (spell_ob->level > caster_level) |
1011 | { |
992 | { |
… | |
… | |
1472 | |
1453 | |
1473 | case SP_MAGIC_MISSILE: |
1454 | case SP_MAGIC_MISSILE: |
1474 | if (QUERY_FLAG (victim, FLAG_ALIVE)) |
1455 | if (QUERY_FLAG (victim, FLAG_ALIVE)) |
1475 | { |
1456 | { |
1476 | hit_player (victim, spell->stats.dam, spell, spell->attacktype, 1); |
1457 | hit_player (victim, spell->stats.dam, spell, spell->attacktype, 1); |
1477 | |
|
|
1478 | if (!spell->destroyed ()) |
|
|
1479 | spell->destroy (); |
1458 | spell->destroy (); |
1480 | } |
1459 | } |
1481 | break; |
1460 | break; |
1482 | |
1461 | |
1483 | case SP_MOVING_BALL: |
1462 | case SP_MOVING_BALL: |
1484 | if (QUERY_FLAG (victim, FLAG_ALIVE)) |
1463 | if (QUERY_FLAG (victim, FLAG_ALIVE)) |
1485 | hit_player (victim, spell->stats.dam, spell, spell->attacktype, 1); |
1464 | hit_player (victim, spell->stats.dam, spell, spell->attacktype, 1); |
1486 | else if (victim->materialname) |
1465 | else if (victim->materialname) |
1487 | save_throw_object (victim, spell->attacktype, spell); |
1466 | save_throw_object (victim, spell->attacktype, spell); |
1488 | break; |
|
|
1489 | } |
|
|
1490 | } |
|
|
1491 | |
1467 | |
|
|
1468 | break; |
|
|
1469 | } |
|
|
1470 | } |
|
|
1471 | |