52 if (tmp->type ==
SPELL && (!skill || tmp->skill == skill))
62 if (tmp->type ==
SPELL && (!skill || tmp->skill == skill)) {
97 if (caster == op && spob->
skill)
99 else if (caster->
skill)
162 fprintf(stderr,
"Spells with no path set:\n");
212 new_level = spell->
level 215 return MAX(new_level, 1);
234 int level = caster->
level;
240 level = skill->
level;
305 return MAX(sp, grace);
311 LOG(
llevError,
"SP_level_spellpoint_cost: Unknown flags passed: %d\n", flags);
450 object *spob1 = NULL, *spob2 = NULL;
461 if (spob->type ==
SPELL) {
462 if (!strncmp(spob->name, spname, strlen(spname))) {
463 if (strlen(spname) == strlen(spob->name))
468 }
else if (!strncmp(spob->name, spname, strlen(spob->name))) {
475 LOG(
llevError,
"Found multiple spells with overlapping base names: %s, %s\n", spob2->name, spob->name);
485 if (spob1 && nummatch == 1)
541 "Something is in the way. You cast it at your feet.");
596 && (tmp->type !=
BOW)
597 && (tmp->type !=
ARROW)
598 && (tmp->type !=
GOLEM)
612 if (tmp->type == op->
type 673 if (dir < 0 || dir > 8) {
674 LOG(
llevError,
"Invalid direction %d in fire_arch_from_position for %s\n", dir, spell->
name);
682 LOG(
llevError,
"Unexpected object type %d in fire_arch_from_position for %s\n", spell->
type, spell->
name);
695 if (mflags&P_OUT_OF_MAP) {
720 LOG(
llevError,
"Unexpected object subtype %d in fire_arch_from_position for %s\n", spell->
subtype, spell->
name);
729 "You can't cast the spell on top of a wall!");
760 if (mflags&P_OUT_OF_MAP) {
894 for (inv = tmp->
inv; inv; inv = inv->
below) {
928 int owner_type = 0, mflags;
933 if (exclude != NULL) {
934 exclude =
HEAD(exclude);
935 owner_type = exclude->
type;
978 object *tmp, *head = NULL, *prev = NULL;
1046 for (i = 0; i < n; i++)
1099 const char *godname;
1103 if (!strcmp(godname,
"none"))
1104 godname =
"Your spirit";
1106 if (failure <= -20 && failure > -40) {
1108 "%s gives a sign to renew your faith.",
1113 }
else if (failure <= -40 && failure > -60) {
1115 "Your diety touches your mind!");
1117 }
else if (failure <= -60 && failure > -150) {
1119 "%s requires you to pray NOW. You comply, ignoring all else.",
1123 }
else if (failure <= -150) {
1155 if (failure <= -20 && failure > -40) {
1157 "Your spell causes an unexpected effect.");
1161 }
else if (failure <= -40 && failure > -60) {
1163 "Your magic recoils on you, making you confused!");
1165 }
else if (failure <= -60 && failure > -80) {
1167 "Your magic stuns you!");
1169 }
else if (failure <= -80) {
1175 "The magic warps and you are turned inside out!");
1179 "You lose control of the mana! The uncontrolled magic blasts you!");
1233 object *first = NULL;
1248 count =
rndm(0, count-1);
1249 for (item = first; item; item = item->
below) {
1279 "Your %s turns to a flower!",
1303 if (second >= first)
1308 "You suddenly feel really weird!");
1354 char *ingredients[10];
1374 for (i = 0; i < count; i++) {
1377 while (isdigit(*ingredients[i])) {
1378 nrof[i] = 10*nrof[i]+(*(ingredients[i])-
'0');
1383 while (*ingredients[i] ==
' ')
1389 if (check->title == NULL)
1390 name2 = check->name;
1392 snprintf(name_ob,
sizeof(name_ob),
"%s %s", check->name, check->title);
1396 if (strcmp(name2, ingredients[i]) == 0) {
1402 if (found[i] == NULL) {
1405 "Casting this spell requires %s, but you don't have any.",
1411 if (found[i]->nrof < nrof[i]) {
1414 "Casting this spell requires %d %s, but you only have %d.",
1415 nrof[i], found[i]->name_pl, found[i]->nrof);
1424 for (i = 0; i < count; i++) {
1467 int cast_spell(
object *op,
object *caster,
int dir,
object *spell_ob,
char *stringarg) {
1468 const char *godname;
1469 int success = 0, mflags, cast_level = 0;
1471 object *skill = NULL;
1472 int confusion_effect = 0;
1473 float cost_multiplier = 1.0f;
1478 LOG(
llevError,
"cast_spell: null spell object passed\n");
1482 if (!strcmp(godname,
"none"))
1483 godname =
"A random spirit";
1487 LOG(
llevError,
"cast_spell: null caster object passed\n");
1495 if (
rndm(0, 5) < 4) {
1499 "In your confused state, you're not sure of what you cast!");
1502 confusion_effect = 1;
1510 "That spell path is denied to you.");
1533 if ((mflags&P_NO_CLERIC) && spell_ob->
stats.
grace)
1535 "This ground is unholy! %s ignores you.",
1541 "Something blocks your spellcasting.");
1546 "Something blocks the magic of your item.");
1550 "Something blocks the magic of your scroll.");
1570 if (spell_ob->
skill) {
1575 "You need the skill %s to cast %s.",
1581 "You lack enough skill to cast that spell.");
1592 "You don't have enough mana.");
1600 "%s grants your prayer, though you are unworthy.",
1606 "%s ignores your prayer.",
1617 "You fumble the spell.");
1623 if (bungle->
arch != NULL) {
1626 LOG(
llevError,
"cast_spell: Could not create spell_bungle arch\n");
1629 }
else if (spell_ob->
stats.
sp) {
1635 "You bungle the spell because you have too much heavy equipment in use.");
1641 if (bungle->
arch != NULL) {
1644 LOG(
llevError,
"cast_spell: Could not create spell_bungle arch\n");
1660 op->
spell = spell_ob;
1673 "You are casting!");
1677 spell_ob = op->
spell;
1719 "You lack the skill %s to use the %s",
1720 caster->
skill, name);
1737 if (confusion_effect) {
1741 "In your confused state, you can't control the magic!");
1764 success =
write_rune(op, caster, spell_ob, dir, stringarg);
1768 success =
write_mark(op, spell_ob, stringarg);
1772 success =
fire_bolt(op, caster, dir, spell_ob);
1780 success =
cast_cone(op, caster, dir, spell_ob);
1801 if (success || op->
contr == NULL)
1828 success =
magic_wall(op, caster, dir, spell_ob);
1849 cast_level = caster->
level;
1851 cast_level = skill != NULL ? skill->
level : op->
level;
1852 success =
probe(op, caster, spell_ob, dir, cast_level);
1856 success =
cast_heal(op, caster, spell_ob, dir);
1872 success =
cast_bless(op, caster, spell_ob, dir);
1876 success =
cast_curse(op, caster, spell_ob, dir);
1882 cost_multiplier = 0.0f;
1887 success =
recharge(op, caster, spell_ob);
1897 "The spell fizzles");
1905 success =
alchemy(op, caster, spell_ob);
1928 "You lack the proper attunement to cast %s",
1936 success =
fire_swarm(op, caster, spell_ob, dir);
1945 success =
dispel_rune(op, caster, spell_ob, skill, dir);
1962 success =
cast_light(op, caster, spell_ob, dir);
2032 snprintf(dur,
sizeof(dur),
"%d", i);
2036 snprintf(dur,
sizeof(dur),
"%d", i);
2058 if (spell->
duration == atoi(key)) {
2060 "The effects of your %s are draining out.", spell->
name);
2066 if (spell->
duration == atoi(key)) {
2068 "The effects of your %s are about to expire.", spell->
name);
void draw_ext_info_format(int flags, int pri, const object *pl, uint8_t type, uint8_t subtype, const char *format,...)
object * object_find_by_type_and_name(const object *who, int type, const char *name)
void set_attr_value(living *stats, int attr, int8_t value)
int apply_manual(object *op, object *tmp, int aflag)
void drain_rod_charge(object *rod)
const char * determine_god(object *op)
archetype * find_archetype(const char *name)
object * lookup_spell_by_name(object *op, const char *spname)
#define ARCH_SPELL_BUNGLE
#define MSG_TYPE_ITEM_CHANGE
#define INS_BELOW_ORIGINATOR
int change_skill(object *who, object *new_skill, int flag)
const char * skill_names[MAX_SKILLS]
object * find_applied_skill_by_name(const object *op, const char *name)
int cast_raise_dead_spell(object *op, object *caster, object *spell, int dir, const char *arg)
struct Statistics statistics
void spell_failure(object *op, int failure, int power, object *skill)
void apply_anim_suffix(object *who, const char *suffix)
void esrv_send_item(object *pl, object *op)
sstring add_refcount(sstring str)
object * find_target_for_friendly_spell(object *op, int dir)
int cast_change_ability(object *op, object *caster, object *spell_ob, int dir, int silent)
void object_copy_owner(object *op, object *clone)
#define SP_CHANGE_MAP_LIGHT
int reflwall(mapstruct *m, int x, int y, object *sp_op)
#define SP_CHANGE_ABILITY
uint8_t spellpoint_level_depend
int cast_bless(object *op, object *caster, object *spell_ob, int dir)
void get_search_arr(int *search_arr)
int fire_arch_from_position(object *op, object *caster, int16_t x, int16_t y, int dir, object *spell)
#define MSG_TYPE_SPELL_FAILURE
int spell_find_dir(mapstruct *m, int x, int y, object *exclude)
#define SP_ANIMATE_WEAPON
int SP_level_duration_adjust(const object *caster, const object *spob)
int SP_level_range_adjust(const object *caster, const object *spob)
#define SET_ANIMATION(ob, newanim)
void esrv_update_item(int flags, object *pl, object *op)
const char * object_get_value(const object *op, const char *const key)
struct treasureliststruct * randomitems
int cast_smite_spell(object *op, object *caster, int dir, object *spell)
#define MSG_TYPE_SPELL_INFO
static int spell_consume_items(object *op, const object *spell_ob)
short freearr_x[SIZEOFFREE]
uint8_t duration_modifier
int ok_to_put_more(mapstruct *m, int16_t x, int16_t y, object *op, uint32_t immune_stop)
int16_t SP_level_spellpoint_cost(object *caster, object *spell, int flags)
int cast_word_of_recall(object *op, object *caster, object *spell_ob)
#define MSG_TYPE_SKILL_MISSING
#define PATH_TIME_MULT(op, spell)
method_ret ob_process(object *op)
#define OUT_OF_REAL_MAP(M, X, Y)
void draw_magic_map(object *pl)
int8_t get_attr_value(const living *stats, int attr)
object * check_spell_known(object *op, const char *name)
int create_bomb(object *op, object *caster, int dir, object *spell)
#define SP_CREATE_MISSILE
struct archt * other_arch
int recharge(object *op, object *caster, object *spell_ob)
void draw_ext_info(int flags, int pri, const object *pl, uint8_t type, uint8_t subtype, const char *message)
static int can_be_transmuted_to_flower(object *op)
#define MSG_TYPE_VICTIM_SPELL
#define SP_WORD_OF_RECALL
int caster_level(const object *caster, const object *spell)
int cast_cone(object *op, object *caster, int dir, object *spell)
int cast_create_food(object *op, object *caster, object *spell_ob, int dir, const char *stringarg)
void rod_adjust(object *rod)
short freearr_y[SIZEOFFREE]
void check_bullet(object *op)
void create_treasure(treasurelist *t, object *op, int flag, int difficulty, int tries)
void esrv_del_item(player *pl, object *ob)
int summon_hostile_monsters(object *op, int n, const char *monstername)
int rndm(int min, int max)
int probe(object *op, object *caster, object *spell_ob, int dir, int level)
void object_set_owner(object *op, object *owner)
int object_set_value(object *op, const char *key, const char *value, int add_key)
void object_free_drop_inventory(object *ob)
int change_abil(object *op, object *tmp)
object * object_insert_in_map_at(object *op, mapstruct *m, object *originator, int flag, int x, int y)
int cast_item_curse_or_curse(object *op, object *caster, object *spell_ob)
int cast_curse(object *op, object *caster, object *spell_ob, int dir)
int fire_swarm(object *op, object *caster, object *spell, int dir)
static void swap_random_stats(object *op)
void object_update_turn_face(object *op)
void confuse_living(object *op, object *hitter, int dam)
#define SP_ITEM_CURSE_BLESS
object * create_archetype(const char *name)
void store_spell_expiry(object *spell)
object * object_insert_in_ob(object *op, object *where)
int cast_create_town_portal(object *op, object *caster, object *spell, int dir)
EXTERN Chaos_Attacks ATTACKS[22]
static void handle_spell_confusion(object *op)
static bool IS_PLAYER(object *op)
static void transmute_item_to_flower(object *op)
#define MSG_TYPE_APPLY_ERROR
int perceive_self(object *op)
void set_spell_skill(object *op, object *caster, object *spob, object *dest)
int pets_summon_golem(object *op, object *caster, int dir, object *spob)
int cast_light(object *op, object *caster, object *spell, int dir)
int cast_create_obj(object *op, object *new_op, int dir)
#define MSG_TYPE_SPELL_ERROR
void drain_wand_charge(object *wand)
int write_mark(object *op, object *spell, const char *msg)
void regenerate_rod(object *rod)
#define OB_SPELL_TAG_MATCH(op, count)
const char *const spell_mapping[]
static int put_a_monster(object *op, const char *monstername)
object * find_random_spell_in_ob(object *ob, const char *skill)
#define OB_TYPE_MOVE_BLOCK(ob1, type)
void paralyze_living(object *op, int dam)
#define GET_MAP_MOVE_BLOCK(M, X, Y)
#define MSG_TYPE_SKILL_FAILURE
int op_on_battleground(object *op, int *x, int *y, archetype **trophy)
int cast_detection(object *op, object *caster, object *spell)
void cast_magic_storm(object *op, object *tmp, int lvl)
#define FREE_AND_CLEAR_STR(xyz)
int cast_wonder(object *op, object *caster, int dir, object *spell_ob)
#define QUERY_FLAG(xyz, p)
#define CLEAR_FLAG(xyz, p)
int cast_invisible(object *op, object *caster, object *spell_ob)
int write_rune(object *op, object *caster, object *spell, int dir, const char *runename)
void shuffle_attack(object *op, int change_face)
int cast_consecrate(object *op, object *caster, object *spell)
int cast_transfer(object *op, object *caster, object *spell, int dir)
int dimension_door(object *op, object *caster, object *spob, int dir)
int object_find_first_free_spot(const object *ob, mapstruct *m, int x, int y)
int cast_destruction(object *op, object *caster, object *spell_ob)
static const flag_definition flags[]
#define SP_DIMENSION_DOOR
int tailor_god_spell(object *spellop, object *caster)
int cast_cause_disease(object *op, object *caster, object *spell, int dir)
int cast_heal(object *op, object *caster, object *spell, int dir)
object * object_decrease_nrof(object *op, uint32_t i)
void play_sound_player_only(player *pl, int8_t sound_type, object *emitter, int dir, const char *action)
int cast_create_missile(object *op, object *caster, object *spell, int dir, const char *stringarg)
int mood_change(object *op, object *caster, object *spell)
int remove_curse(object *op, object *caster, object *spell)
int cast_earth_to_dust(object *op, object *caster, object *spell_ob)
uint64_t spell_suppressions
int fire_bolt(object *op, object *caster, int dir, object *spob)
void query_short_name(const object *op, char *buf, size_t size)
object * object_get_player_container(object *op)
#define SP_SUMMON_MONSTER
int min_casting_level(const object *caster, const object *spell)
int alchemy(object *op, object *caster, object *spell_ob)
#define GET_MAP_OB(M, X, Y)
#define FORCE_TRANSFORMED_ITEM
#define ARCH_SPELL_BLOCKED
int animate_weapon(object *op, object *caster, object *spell, int dir)
int get_map_flags(mapstruct *oldmap, mapstruct **newmap, int16_t x, int16_t y, int16_t *nx, int16_t *ny)
size_t split_string(char *str, char *array[], size_t array_size, char sep)
int get_cleric_chance(int stat)
void LOG(LogLevel logLevel, const char *format,...)
int pets_summon_object(object *op, object *caster, object *spell_ob, int dir, const char *stringarg)
#define FOR_MAP_PREPARE(map_, mx_, my_, it_)
void play_sound_map(int8_t sound_type, object *emitter, int dir, const char *action)
void check_spell_expiry(object *spell)
int can_see_monsterP(mapstruct *m, int x, int y, int dir)
int cast_change_map_lightlevel(object *op, object *caster, object *spell)
void query_name(const object *op, char *buf, size_t size)
int cast_spell(object *op, object *caster, int dir, object *spell_ob, char *stringarg)
int random_roll(int min, int max, const object *op, int goodbad)
static void prayer_failure(object *op, int failure, int power)
void spell_effect(object *spob, int x, int y, mapstruct *map, object *originator)
int SP_level_wc_adjust(const object *caster, const object *spob)
int SP_level_dam_adjust(const object *caster, const object *spob)
int hit_player(object *op, int dam, object *hitter, uint32_t type, int full_hit)
uint8_t spell_failure_effects
void fix_object(object *op)
EXTERN archetype * first_archetype
object * find_skill_by_name(object *who, const char *name)
object * arch_to_object(archetype *at)
void object_update_speed(object *op)
int cast_identify(object *op, object *caster, object *spell)
object * object_get_owner(object *op)
int dispel_rune(object *op, object *caster, object *spell, object *skill, int dir)
int create_aura(object *op, object *caster, object *spell)
#define FOR_INV_PREPARE(op_, it_)
void object_remove(object *op)
int cast_polymorph(object *op, object *caster, object *spell_ob, int dir)
int magic_wall(object *op, object *caster, int dir, object *spell_ob)
#define PATH_SP_MULT(op, spell)