Go to the documentation of this file.
50 if (
tmp->type ==
SPELL && (!skill ||
tmp->skill == skill))
60 if (
tmp->type ==
SPELL && (!skill ||
tmp->skill == skill)) {
95 if (caster ==
op && spob->
skill)
97 else if (caster->
skill)
122 fprintf(stderr,
"Spells with no path set:\n");
172 new_level = spell->
level
175 return MAX(new_level, 1);
265 return MAX(sp, grace);
410 object *spob1 = NULL, *spob2 = NULL;
421 if (spob->type ==
SPELL) {
422 if (!strncmp(spob->name, spname, strlen(spname))) {
423 if (strlen(spname) == strlen(spob->name))
428 }
else if (!strncmp(spob->name, spname, strlen(spob->name))) {
435 LOG(
llevError,
"Found multiple spells with overlapping base names: %s, %s\n", spob2->name, spob->name);
445 if (spob1 && nummatch == 1)
501 "Something is in the way. You cast it at your feet.");
572 if (
tmp->type ==
op->type
573 &&
tmp->subtype ==
op->subtype
575 &&
op->stats.maxhp) {
576 if ((
tmp->stats.maxhp ==
op->stats.maxhp)
587 if (
op->spell_tags &&
tmp->spell_tags) {
591 if (
op->spell_tags[i] &&
592 op->spell_tags[i] ==
tmp->spell_tags[i]) {
633 if (dir < 0 || dir > 8) {
634 LOG(
llevError,
"Invalid direction %d in fire_arch_from_position for %s\n", dir, spell->
name);
642 LOG(
llevError,
"Unexpected object type %d in fire_arch_from_position for %s\n", spell->
type, spell->
name);
674 tmp->direction = dir;
680 LOG(
llevError,
"Unexpected object subtype %d in fire_arch_from_position for %s\n", spell->
subtype, spell->
name);
689 "You can't cast the spell on top of a wall!");
697 tmp->stats.food =
tmp->duration;
707 tmp->direction = dir;
889 int owner_type = 0, mflags;
894 if (exclude != NULL) {
895 exclude =
HEAD(exclude);
896 owner_type = exclude->
type;
939 object *
tmp, *head = NULL, *prev = NULL;
1007 for (i = 0; i < n; i++)
1052 const char *godname;
1056 if (!strcmp(godname,
"none"))
1057 godname =
"Your spirit";
1059 if (failure <= -20 && failure > -40) {
1061 "%s gives a sign to renew your faith.",
1066 }
else if (failure <= -40 && failure > -60) {
1068 "Your diety touches your mind!");
1070 }
else if (failure <= -60 && failure > -150) {
1072 "%s requires you to pray NOW. You comply, ignoring all else.",
1076 }
else if (failure <= -150) {
1108 if (failure <= -20 && failure > -40) {
1110 "Your spell causes an unexpected effect.");
1114 }
else if (failure <= -40 && failure > -60) {
1116 "Your magic recoils on you, making you confused!");
1118 }
else if (failure <= -60 && failure > -80) {
1120 "Your magic stuns you!");
1122 }
else if (failure <= -80) {
1128 "The magic warps and you are turned inside out!");
1132 "You lose control of the mana! The uncontrolled magic blasts you!");
1142 tmp->stats.dam = power;
1144 tmp->stats.maxhp =
tmp->count;
1145 if (
tmp->stats.maxhp == 0)
1146 tmp->stats.maxhp = 1;
1186 object *first = NULL;
1232 "Your %s turns to a flower!",
1256 if (second >= first)
1261 "You suddenly feel really weird!");
1307 char *ingredients[10];
1327 for (i = 0; i <
count; i++) {
1330 while (isdigit(*ingredients[i])) {
1331 nrof[i] = 10*nrof[i]+(*(ingredients[i])-
'0');
1336 while (*ingredients[i] ==
' ')
1342 if (
check->title == NULL)
1343 name2 =
check->name;
1345 snprintf(name_ob,
sizeof(name_ob),
"%s %s",
check->name,
check->title);
1349 if (strcmp(name2, ingredients[i]) == 0) {
1355 if (
found[i] == NULL) {
1358 "Casting this spell requires %s, but you don't have any.",
1364 if (
found[i]->nrof < nrof[i]) {
1367 "Casting this spell requires %d %s, but you only have %d.",
1377 for (i = 0; i <
count; i++) {
1420 int cast_spell(
object *
op,
object *caster,
int dir,
object *spell_ob,
char *stringarg) {
1421 const char *godname;
1422 int success = 0, mflags, cast_level = 0;
1424 object *skill = NULL;
1425 int confusion_effect = 0;
1426 float cost_multiplier = 1.0f;
1431 LOG(
llevError,
"cast_spell: null spell object passed\n");
1435 if (!strcmp(godname,
"none"))
1436 godname =
"A random spirit";
1440 LOG(
llevError,
"cast_spell: null caster object passed\n");
1448 if (
rndm(0, 5) < 4) {
1452 "In your confused state, you're not sure of what you cast!");
1455 confusion_effect = 1;
1463 "That spell path is denied to you.");
1488 "This ground is unholy! %s ignores you.",
1491 switch (
op->contr->shoottype) {
1494 "Something blocks your spellcasting.");
1499 "Something blocks the magic of your item.");
1503 "Something blocks the magic of your scroll.");
1523 if (spell_ob->
skill) {
1528 "You need the skill %s to cast %s.",
1534 "You lack enough skill to cast that spell.");
1545 "You don't have enough mana.");
1553 "%s grants your prayer, though you are unworthy.",
1559 "%s ignores your prayer.",
1570 "You fumble the spell.");
1572 op->casting_time = -1;
1576 if (bungle->
arch != NULL) {
1579 LOG(
llevError,
"cast_spell: Could not create spell_bungle arch\n");
1582 }
else if (spell_ob->
stats.
sp) {
1588 "You bungle the spell because you have too much heavy equipment in use.");
1591 op->contr->shoottype = old_shoottype;
1594 if (bungle->
arch != NULL) {
1597 LOG(
llevError,
"cast_spell: Could not create spell_bungle arch\n");
1611 if (
op->casting_time == -1) {
1613 op->spell = spell_ob;
1621 op->spellarg = NULL;
1623 }
else if (
op->casting_time != 0) {
1626 "You are casting!");
1629 op->casting_time = -1;
1630 spell_ob =
op->spell;
1631 stringarg =
op->spellarg;
1655 op->speed_left -= 2*
FABS(
op->speed);
1672 "You lack the skill %s to use the %s",
1690 if (confusion_effect) {
1694 "In your confused state, you can't control the magic!");
1717 success =
write_rune(
op, caster, spell_ob, dir, stringarg);
1754 if (success ||
op->contr == NULL)
1761 old_shoottype =
op->contr->shoottype;
1802 cast_level = caster->
level;
1804 cast_level = skill != NULL ? skill->
level :
op->level;
1805 success =
probe(
op, caster, spell_ob, dir, cast_level);
1835 cost_multiplier = 0.0f;
1850 "The spell fizzles");
1858 success =
alchemy(
op, caster, spell_ob);
1881 "You lack the proper attunement to cast %s",
1966 op->contr->shoottype = old_shoottype;
1984 snprintf(dur,
sizeof(dur),
"%d", i);
1988 snprintf(dur,
sizeof(dur),
"%d", i);
2012 "The effects of your %s are draining out.", spell->
name);
2020 "The effects of your %s are about to expire.", spell->
name);
void paralyze_living(object *op, int dam)
#define GET_MAP_OB(M, X, Y)
int object_find_first_free_spot(const object *ob, mapstruct *m, int x, int y)
sstring add_refcount(sstring str)
int fire_bolt(object *op, object *caster, int dir, object *spob)
void object_remove(object *op)
int cast_consecrate(object *op, object *caster, object *spell)
int cast_create_food(object *op, object *caster, object *spell_ob, int dir, const char *stringarg)
void object_copy_owner(object *op, object *clone)
int fire_arch_from_position(object *op, object *caster, int16_t x, int16_t y, int dir, object *spell)
#define SP_ANIMATE_WEAPON
#define QUERY_FLAG(xyz, p)
#define ARCH_SPELL_BUNGLE
archetype * get_next_archetype(archetype *current)
int cast_identify(object *op, object *caster, object *spell)
int get_cleric_chance(int stat)
int dimension_door(object *op, object *caster, object *spob, int dir)
int cast_change_map_lightlevel(object *op, object *spell)
int perceive_self(object *op)
void confuse_living(object *op, object *hitter, int dam)
static void prayer_failure(object *op, int failure, int power)
int cast_destruction(object *op, object *caster, object *spell_ob)
int op_on_battleground(object *op, int *x, int *y, archetype **trophy)
object * find_target_for_friendly_spell(object *op, int dir)
int tailor_god_spell(object *spellop, object *caster)
int SP_level_dam_adjust(const object *caster, const object *spob)
#define OB_SPELL_TAG_MATCH(op, count)
int magic_wall(object *op, object *caster, int dir, object *spell_ob)
static void handle_spell_confusion(object *op)
void check_bullet(object *op)
int summon_hostile_monsters(object *op, int n, const char *monstername)
void spell_failure(object *op, int failure, int power, object *skill)
int cast_cause_disease(object *op, object *caster, object *spell, int dir)
#define MSG_TYPE_ATTRIBUTE
int min_casting_level(const object *caster, const object *spell)
#define SET_ANIMATION(ob, newanim)
void play_sound_player_only(player *pl, int8_t sound_type, object *emitter, int dir, const char *action)
#define MSG_TYPE_VICTIM_SPELL
int SP_level_range_adjust(const object *caster, const object *spob)
int cast_curse(object *op, object *caster, object *spell_ob, int dir)
void play_sound_map(int8_t sound_type, object *emitter, int dir, const char *action)
int change_skill(object *who, object *new_skill, int flag)
int cast_raise_dead_spell(object *op, object *caster, object *spell, int dir, const char *arg)
int write_mark(object *op, object *spell, const char *msg)
int cast_polymorph(object *op, object *caster, object *spell_ob, int dir)
#define SP_CREATE_MISSILE
static const flag_definition flags[]
int apply_manual(object *op, object *tmp, int aflag)
#define MSG_TYPE_SPELL_INFO
void create_treasure(treasurelist *t, object *op, int flag, int difficulty, int tries)
struct treasureliststruct * randomitems
method_ret ob_process(object *op)
short freearr_x[SIZEOFFREE]
short freearr_y[SIZEOFFREE]
object * find_applied_skill_by_name(const object *op, const char *name)
uint8_t duration_modifier
int cast_detection(object *op, object *caster, object *spell)
void cast_magic_storm(object *op, object *tmp, int lvl)
object * find_random_spell_in_ob(object *ob, const char *skill)
int pets_summon_object(object *op, object *caster, object *spell_ob, int dir, const char *stringarg)
int cast_light(object *op, object *caster, object *spell, int dir)
void esrv_send_item(object *pl, object *op)
int SP_level_wc_adjust(const object *caster, const object *spob)
const char * object_get_value(const object *op, const char *const key)
#define SP_SUMMON_MONSTER
static event_registration m
static int can_be_transmuted_to_flower(object *op)
#define PATH_SP_MULT(op, spell)
int cast_heal(object *op, object *caster, object *spell, int dir)
#define SP_ITEM_CURSE_BLESS
int spell_find_dir(mapstruct *m, int x, int y, object *exclude)
const char * determine_god(object *op)
int remove_curse(object *op, object *caster, object *spell)
int mood_change(object *op, object *caster, object *spell)
#define MSG_TYPE_ATTRIBUTE_PROTECTION_GAIN
void query_name(const object *op, char *buf, size_t size)
void object_update_turn_face(object *op)
#define SP_DIMENSION_DOOR
EXTERN Chaos_Attacks ATTACKS[22]
int create_bomb(object *op, object *caster, int dir, object *spell)
void shuffle_attack(object *op)
int SP_level_duration_adjust(const object *caster, const object *spob)
void query_short_name(const object *op, char *buf, size_t size)
int reflwall(mapstruct *m, int x, int y, object *sp_op)
void regenerate_rod(object *rod)
#define FORCE_TRANSFORMED_ITEM
int cast_create_town_portal(object *op, object *caster, object *spell)
void fix_object(object *op)
void draw_magic_map(object *pl)
int cast_spell(object *op, object *caster, int dir, object *spell_ob, char *stringarg)
#define GET_MAP_MOVE_BLOCK(M, X, Y)
struct archt * other_arch
int create_aura(object *op, object *caster, object *spell)
#define INS_BELOW_ORIGINATOR
#define MSG_TYPE_SKILL_MISSING
int object_set_value(object *op, const char *key, const char *value, int add_key)
const typedef char * sstring
int rndm(int min, int max)
int cast_create_obj(object *op, object *new_op, int dir)
void drain_wand_charge(object *wand)
int cast_item_curse_or_curse(object *op, object *spell_ob)
#define SP_CHANGE_MAP_LIGHT
void object_set_owner(object *op, object *owner)
object * find_skill_by_name(object *who, const char *name)
size_t split_string(char *str, char *array[], size_t array_size, char sep)
int cast_bless(object *op, object *caster, object *spell_ob, int dir)
uint64_t spell_suppressions
void esrv_del_item(player *pl, object *ob)
object * create_archetype(const char *name)
object * check_spell_known(object *op, const char *name)
static bool IS_PLAYER(object *op)
struct Statistics statistics
#define FREE_AND_CLEAR_STR(xyz)
int probe(object *op, object *caster, object *spell_ob, int dir, int level)
int random_roll(int min, int max, const object *op, int goodbad)
static void transmute_item_to_flower(object *op)
uint8_t spell_failure_effects
#define FOR_MAP_PREPARE(map_, mx_, my_, it_)
#define OUT_OF_REAL_MAP(M, X, Y)
void set_spell_skill(object *op, object *caster, object *spob, object *dest)
static void swap_random_stats(object *op)
void check_spell_expiry(object *spell)
#define MSG_TYPE_SKILL_FAILURE
int alchemy(object *op, object *caster, object *spell_ob)
int animate_weapon(object *op, object *caster, object *spell, int dir)
#define MSG_TYPE_SPELL_FAILURE
#define SP_CHANGE_ABILITY
uint8_t spellpoint_level_depend
void apply_anim_suffix(object *who, const char *suffix)
#define PATH_TIME_MULT(op, spell)
void LOG(LogLevel logLevel, const char *format,...)
#define ARCH_SPELL_BLOCKED
#define MSG_TYPE_SPELL_ERROR
int pets_summon_golem(object *op, object *caster, int dir, object *spob)
void esrv_update_item(int flags, object *pl, object *op)
int dispel_rune(object *op, object *skill, int dir)
int hit_player(object *op, int dam, object *hitter, uint32_t type, int full_hit)
static int spell_consume_items(object *op, const object *spell_ob)
int ok_to_put_more(mapstruct *m, int16_t x, int16_t y, object *op, uint32_t immune_stop)
#define CLEAR_FLAG(xyz, p)
int caster_level(const object *caster, const object *spell)
void set_attr_value(living *stats, int attr, int8_t value)
void rod_adjust(object *rod)
object * object_insert_in_ob(object *op, object *where)
int cast_wonder(object *op, object *caster, int dir, object *spell_ob)
void object_update_speed(object *op)
static int put_a_monster(object *op, const char *monstername)
object * arch_to_object(archetype *at)
object * object_insert_in_map_at(object *op, mapstruct *m, object *originator, int flag, int x, int y)
void draw_ext_info(int flags, int pri, const object *pl, uint8_t type, uint8_t subtype, const char *message)
int8_t get_attr_value(const living *stats, int attr)
void object_free_drop_inventory(object *ob)
int fire_swarm(object *op, object *caster, object *spell, int dir)
archetype * try_find_archetype(const char *name)
int cast_change_ability(object *op, object *caster, object *spell_ob, int dir, int silent)
object * object_decrease_nrof(object *op, uint32_t i)
#define OB_TYPE_MOVE_BLOCK(ob1, type)
#define MSG_TYPE_ITEM_CHANGE
int cast_word_of_recall(object *op, object *caster, object *spell_ob)
int write_rune(object *op, object *caster, object *spell, int dir, const char *runename)
object * object_find_by_type_and_name(const object *who, int type, const char *name)
int cast_create_missile(object *op, object *caster, object *spell, int dir, const char *stringarg)
int cast_transfer(object *op, object *caster, object *spell, int dir)
void spell_effect(object *spob, int x, int y, mapstruct *map, object *originator)
int get_map_flags(mapstruct *oldmap, mapstruct **newmap, int16_t x, int16_t y, int16_t *nx, int16_t *ny)
object * object_get_player_container(object *op)
void get_search_arr(int *search_arr)
int change_abil(object *op, object *tmp)
int cast_smite_spell(object *op, object *caster, int dir, object *spell)
int cast_earth_to_dust(object *op, object *caster, object *spell_ob)
int recharge(object *op, object *caster, object *spell_ob)
#define MSG_TYPE_APPLY_ERROR
void drain_rod_charge(object *rod)
object * lookup_spell_by_name(object *op, const char *spname)
void store_spell_expiry(object *spell)
#define FOR_INV_PREPARE(op_, it_)
int can_see_monsterP(mapstruct *m, int x, int y, int dir)
void draw_ext_info_format(int flags, int pri, const object *pl, uint8_t type, uint8_t subtype, const char *format,...)
int cast_invisible(object *op, object *caster, object *spell_ob)
#define SP_WORD_OF_RECALL
int cast_cone(object *op, object *caster, int dir, object *spell)
int16_t SP_level_spellpoint_cost(object *caster, object *spell, int flags)
object * object_get_owner(object *op)