Go to the documentation of this file.
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)
112 if (at->clone.type ==
SPELL) {
113 fprintf(stderr,
"%s:%s:%s:%s:%d\n", at->clone.name ? at->clone.name :
"null",
114 at->name, at->clone.other_arch ? at->clone.other_arch->name :
"null",
115 at->clone.skill ? at->clone.skill :
"null", at->clone.level);
120 if (at->clone.type ==
SPELL && at->clone.path_attuned == 0) {
123 fprintf(stderr,
"Spells with no path set:\n");
126 fprintf(stderr,
"- %s\n", at->clone.name ? at->clone.name :
"null");
173 new_level = spell->
level
176 return MAX(new_level, 1);
266 return MAX(sp, grace);
411 object *spob1 = NULL, *spob2 = NULL;
422 if (spob->type ==
SPELL) {
423 if (!strncmp(spob->name, spname, strlen(spname))) {
424 if (strlen(spname) == strlen(spob->name))
429 }
else if (!strncmp(spob->name, spname, strlen(spob->name))) {
436 LOG(
llevError,
"Found multiple spells with overlapping base names: %s, %s\n", spob2->name, spob->name);
446 if (spob1 && nummatch == 1)
502 "Something is in the way. You cast it at your feet.");
573 if (
tmp->type ==
op->type
574 &&
tmp->subtype ==
op->subtype
576 &&
op->stats.maxhp) {
577 if ((
tmp->stats.maxhp ==
op->stats.maxhp)
588 if (
op->spell_tags &&
tmp->spell_tags) {
592 if (
op->spell_tags[i] &&
593 op->spell_tags[i] ==
tmp->spell_tags[i]) {
634 if (dir < 0 || dir > 8) {
635 LOG(
llevError,
"Invalid direction %d in fire_arch_from_position for %s\n", dir, spell->
name);
643 LOG(
llevError,
"Unexpected object type %d in fire_arch_from_position for %s\n", spell->
type, spell->
name);
675 tmp->direction = dir;
681 LOG(
llevError,
"Unexpected object subtype %d in fire_arch_from_position for %s\n", spell->
subtype, spell->
name);
690 "You can't cast the spell on top of a wall!");
698 tmp->stats.food =
tmp->duration;
708 tmp->direction = dir;
890 int owner_type = 0, mflags;
895 if (exclude != NULL) {
896 exclude =
HEAD(exclude);
897 owner_type = exclude->
type;
940 object *
tmp, *head = NULL, *prev = NULL;
1008 for (i = 0; i < n; i++)
1053 const char *godname;
1057 if (!strcmp(godname,
"none"))
1058 godname =
"Your spirit";
1060 if (failure <= -20 && failure > -40) {
1062 "%s gives a sign to renew your faith.",
1067 }
else if (failure <= -40 && failure > -60) {
1069 "Your diety touches your mind!");
1071 }
else if (failure <= -60 && failure > -150) {
1073 "%s requires you to pray NOW. You comply, ignoring all else.",
1077 }
else if (failure <= -150) {
1109 if (failure <= -20 && failure > -40) {
1111 "Your spell causes an unexpected effect.");
1115 }
else if (failure <= -40 && failure > -60) {
1117 "Your magic recoils on you, making you confused!");
1119 }
else if (failure <= -60 && failure > -80) {
1121 "Your magic stuns you!");
1123 }
else if (failure <= -80) {
1129 "The magic warps and you are turned inside out!");
1133 "You lose control of the mana! The uncontrolled magic blasts you!");
1143 tmp->stats.dam = power;
1145 tmp->stats.maxhp =
tmp->count;
1146 if (
tmp->stats.maxhp == 0)
1147 tmp->stats.maxhp = 1;
1187 object *first = NULL;
1236 "Your %s turns to a flower!",
1260 if (second >= first)
1265 "You suddenly feel really weird!");
1311 char *ingredients[10];
1331 for (i = 0; i <
count; i++) {
1334 while (isdigit(*ingredients[i])) {
1335 nrof[i] = 10*nrof[i]+(*(ingredients[i])-
'0');
1340 while (*ingredients[i] ==
' ')
1346 if (
check->title == NULL)
1347 name2 =
check->name;
1349 snprintf(name_ob,
sizeof(name_ob),
"%s %s",
check->name,
check->title);
1353 if (strcmp(name2, ingredients[i]) == 0) {
1359 if (
found[i] == NULL) {
1362 "Casting this spell requires %s, but you don't have any.",
1368 if (
found[i]->nrof < nrof[i]) {
1371 "Casting this spell requires %d %s, but you only have %d.",
1381 for (i = 0; i <
count; i++) {
1424 int cast_spell(
object *
op,
object *caster,
int dir,
object *spell_ob,
char *stringarg) {
1425 const char *godname;
1426 int success = 0, mflags, cast_level = 0;
1428 object *skill = NULL;
1429 int confusion_effect = 0;
1430 float cost_multiplier = 1.0f;
1435 LOG(
llevError,
"cast_spell: null spell object passed\n");
1439 if (!strcmp(godname,
"none"))
1440 godname =
"A random spirit";
1444 LOG(
llevError,
"cast_spell: null caster object passed\n");
1452 if (
rndm(0, 5) < 4) {
1456 "In your confused state, you're not sure of what you cast!");
1459 confusion_effect = 1;
1467 "That spell path is denied to you.");
1492 "This ground is unholy! %s ignores you.",
1495 switch (
op->contr->shoottype) {
1498 "Something blocks your spellcasting.");
1503 "Something blocks the magic of your item.");
1507 "Something blocks the magic of your scroll.");
1527 if (spell_ob->
skill) {
1532 "You need the skill %s to cast %s.",
1538 "You lack enough skill to cast that spell.");
1549 "You don't have enough mana.");
1557 "%s grants your prayer, though you are unworthy.",
1563 "%s ignores your prayer.",
1574 "You fumble the spell.");
1576 op->casting_time = -1;
1580 if (bungle->
arch != NULL) {
1583 LOG(
llevError,
"cast_spell: Could not create spell_bungle arch\n");
1586 }
else if (spell_ob->
stats.
sp) {
1592 "You bungle the spell because you have too much heavy equipment in use.");
1595 op->contr->shoottype = old_shoottype;
1598 if (bungle->
arch != NULL) {
1601 LOG(
llevError,
"cast_spell: Could not create spell_bungle arch\n");
1615 if (
op->casting_time == -1) {
1617 op->spell = spell_ob;
1625 op->spellarg = NULL;
1627 }
else if (
op->casting_time != 0) {
1630 "You are casting!");
1633 op->casting_time = -1;
1634 spell_ob =
op->spell;
1635 stringarg =
op->spellarg;
1659 op->speed_left -= 2*
FABS(
op->speed);
1676 "You lack the skill %s to use the %s",
1694 if (confusion_effect) {
1698 "In your confused state, you can't control the magic!");
1721 success =
write_rune(
op, caster, spell_ob, dir, stringarg);
1758 if (success ||
op->contr == NULL)
1765 old_shoottype =
op->contr->shoottype;
1806 cast_level = caster->
level;
1808 cast_level = skill != NULL ? skill->
level :
op->level;
1809 success =
probe(
op, caster, spell_ob, dir, cast_level);
1839 cost_multiplier = 0.0f;
1854 "The spell fizzles");
1862 success =
alchemy(
op, caster, spell_ob);
1885 "You lack the proper attunement to cast %s",
1970 op->contr->shoottype = old_shoottype;
1988 snprintf(dur,
sizeof(dur),
"%d", i);
1992 snprintf(dur,
sizeof(dur),
"%d", i);
2016 "The effects of your %s are draining out.", spell->
name);
2024 "The effects of your %s are about to expire.", spell->
name);
void paralyze_living(object *op, int dam)
static void swap_random_stats(object *op)
#define GET_MAP_OB(M, X, Y)
object * object_get_owner(object *op)
object * find_target_for_friendly_spell(object *op, int dir)
void drain_wand_charge(object *wand)
int fire_bolt(object *op, object *caster, int dir, object *spob)
void object_update_turn_face(object *op)
object * find_applied_skill_by_name(const object *op, const char *name)
struct Statistics statistics
int cast_consecrate(object *op, object *caster, object *spell)
void drain_rod_charge(object *rod)
int cast_create_food(object *op, object *caster, object *spell_ob, int dir, const char *stringarg)
void LOG(LogLevel logLevel, const char *format,...)
#define SP_ANIMATE_WEAPON
void shuffle_attack(object *op)
#define QUERY_FLAG(xyz, p)
#define ARCH_SPELL_BUNGLE
int cast_identify(object *op, object *caster, object *spell)
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)
int get_cleric_chance(int stat)
void confuse_living(object *op, object *hitter, int dam)
int cast_destruction(object *op, object *caster, object *spell_ob)
int op_on_battleground(object *op, int *x, int *y, archetype **trophy)
int tailor_god_spell(object *spellop, object *caster)
int caster_level(const object *caster, const object *spell)
#define OB_SPELL_TAG_MATCH(op, count)
int magic_wall(object *op, object *caster, int dir, object *spell_ob)
void check_bullet(object *op)
void spell_failure(object *op, int failure, int power, object *skill)
static int can_be_transmuted_to_flower(object *op)
int cast_cause_disease(object *op, object *caster, object *spell, int dir)
int object_find_first_free_spot(const object *ob, mapstruct *m, int x, int y)
void object_set_owner(object *op, object *owner)
#define MSG_TYPE_ATTRIBUTE
#define SET_ANIMATION(ob, newanim)
void draw_ext_info_format(int flags, int pri, const object *pl, uint8_t type, uint8_t subtype, const char *format,...) PRINTF_ARGS(6
void play_sound_player_only(player *pl, int8_t sound_type, object *emitter, int dir, const char *action)
#define MSG_TYPE_VICTIM_SPELL
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)
static const flag_definition flags[]
int change_skill(object *who, object *new_skill, int flag)
void fix_object(object *op)
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 SP_level_wc_adjust(const object *caster, const object *spob)
int cast_polymorph(object *op, object *caster, object *spell_ob, int dir)
object * lookup_spell_by_name(object *op, const char *spname)
void set_spell_skill(object *op, object *caster, object *spob, object *dest)
#define SP_CREATE_MISSILE
int rndm(int min, int max)
static void handle_spell_confusion(object *op)
int apply_manual(object *op, object *tmp, int aflag)
#define MSG_TYPE_SPELL_INFO
const char * object_get_value(const object *op, const char *const key)
void create_treasure(treasurelist *t, object *op, int flag, int difficulty, int tries)
int summon_hostile_monsters(object *op, int n, const char *monstername)
AssetsManager * getManager()
object * object_insert_in_ob(object *op, object *where)
int cast_spell(object *op, object *caster, int dir, object *spell_ob, char *stringarg)
int min_casting_level(const object *caster, const object *spell)
int cast_detection(object *op, object *caster, object *spell)
void cast_magic_storm(object *op, object *tmp, int lvl)
int pets_summon_object(object *op, object *caster, object *spell_ob, int dir, const char *stringarg)
int reflwall(mapstruct *m, int x, int y, object *sp_op)
int cast_light(object *op, object *caster, object *spell, int dir)
void esrv_send_item(object *pl, object *op)
#define SP_SUMMON_MONSTER
static event_registration m
#define PATH_SP_MULT(op, spell)
void object_free_drop_inventory(object *ob)
int cast_heal(object *op, object *caster, object *spell, int dir)
#define SP_ITEM_CURSE_BLESS
sstring add_refcount(sstring str)
const char * determine_god(object *op)
short freearr_y[SIZEOFFREE]
int remove_curse(object *op, object *caster, object *spell)
int mood_change(object *op, object *caster, object *spell)
void query_name(const object *op, char *buf, size_t size)
#define MSG_TYPE_ATTRIBUTE_PROTECTION_GAIN
int can_see_monsterP(mapstruct *m, int x, int y, int dir)
int ok_to_put_more(mapstruct *m, int16_t x, int16_t y, object *op, uint32_t immune_stop)
#define SP_DIMENSION_DOOR
size_t split_string(char *str, char *array[], size_t array_size, char sep)
void apply_anim_suffix(object *who, const char *suffix)
int SP_level_duration_adjust(const object *caster, const object *spob)
int16_t SP_level_spellpoint_cost(object *caster, object *spell, int flags)
int create_bomb(object *op, object *caster, int dir, object *spell)
object * object_find_by_type_and_name(const object *who, int type, const char *name)
void query_short_name(const object *op, char *buf, size_t size)
void set_attr_value(living *stats, int attr, int8_t value)
void rod_adjust(object *rod)
void object_update_speed(object *op)
#define FORCE_TRANSFORMED_ITEM
int cast_create_town_portal(object *op, object *caster, object *spell)
void draw_magic_map(object *pl)
void store_spell_expiry(object *spell)
#define GET_MAP_MOVE_BLOCK(M, X, Y)
int create_aura(object *op, object *caster, object *spell)
#define INS_BELOW_ORIGINATOR
#define MSG_TYPE_SKILL_MISSING
void each(std::function< void(T *)> op)
int random_roll(int min, int max, const object *op, int goodbad)
void regenerate_rod(object *rod)
#define SP_CHANGE_MAP_LIGHT
object * object_insert_in_map_at(object *op, mapstruct *m, object *originator, int flag, int x, int y)
Chaos_Attacks ATTACKS[22]
struct archetype * other_arch
int fire_arch_from_position(object *op, object *caster, int16_t x, int16_t y, int dir, object *spell)
object * find_skill_by_name(object *who, const char *name)
Archetypes * archetypes()
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)
int spell_find_dir(mapstruct *m, int x, int y, object *exclude)
static bool IS_PLAYER(object *op)
#define FREE_AND_CLEAR_STR(xyz)
int probe(object *op, object *caster, object *spell_ob, int dir, int level)
uint8_t spell_failure_effects
#define FOR_MAP_PREPARE(map_, mx_, my_, it_)
int change_abil(object *op, object *tmp)
static int spell_consume_items(object *op, const object *spell_ob)
#define OUT_OF_REAL_MAP(M, X, Y)
void get_search_arr(int *search_arr)
object * object_decrease_nrof(object *op, uint32_t i)
uint8_t duration_modifier
method_ret ob_process(object *op)
#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
int get_map_flags(mapstruct *oldmap, mapstruct **newmap, int16_t x, int16_t y, int16_t *nx, int16_t *ny)
#define PATH_TIME_MULT(op, spell)
const typedef char * sstring
object * find_random_spell_in_ob(object *ob, const char *skill)
#define ARCH_SPELL_BLOCKED
int SP_level_range_adjust(const object *caster, const object *spob)
#define MSG_TYPE_SPELL_ERROR
void spell_effect(object *spob, int x, int y, mapstruct *map, object *originator)
int cast_create_obj(object *op, object *new_op, int dir)
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)
#define CLEAR_FLAG(xyz, p)
int cast_wonder(object *op, object *caster, int dir, object *spell_ob)
object * arch_to_object(archetype *at)
int SP_level_dam_adjust(const object *caster, const object *spob)
struct treasurelist * randomitems
static void prayer_failure(object *op, int failure, int power)
void draw_ext_info(int flags, int pri, const object *pl, uint8_t type, uint8_t subtype, const char *message)
object * check_spell_known(object *op, const char *name)
int fire_swarm(object *op, object *caster, object *spell, int dir)
static int put_a_monster(object *op, const char *monstername)
void object_remove(object *op)
archetype * try_find_archetype(const char *name)
int cast_change_ability(object *op, object *caster, object *spell_ob, int dir, int silent)
#define OB_TYPE_MOVE_BLOCK(ob1, type)
#define MSG_TYPE_ITEM_CHANGE
int cast_word_of_recall(object *op, object *caster, object *spell_ob)
void object_copy_owner(object *op, object *clone)
int write_rune(object *op, object *caster, object *spell, int dir, const char *runename)
int object_set_value(object *op, const char *key, const char *value, int add_key)
int8_t get_attr_value(const living *stats, int attr)
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)
short freearr_x[SIZEOFFREE]
int cast_item_curse_or_bless(object *op, object *spell_ob)
void check_spell_expiry(object *spell)
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
object * object_get_player_container(object *op)
#define FOR_INV_PREPARE(op_, it_)
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)
static void transmute_item_to_flower(object *op)