Crossfire Server  1.75.0
spell_effect.cpp File Reference

Various spell effects, non attacks. More...

#include "global.h"
#include <assert.h>
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
#include "living.h"
#include "object.h"
#include "shop.h"
#include "sounds.h"
#include "spells.h"
#include "sproto.h"
#include "assets.h"
#include "AssetsManager.h"

Go to the source code of this file.

Macros

#define _GNU_SOURCE
 
#define LARGE_NUGGET   "largenugget"
 
#define SMALL_NUGGET   "smallnugget"
 

Functions

int alchemy (object *op, object *caster, object *spell_ob)
 Change items to gold nuggets. More...
 
static void alchemy_object (float value_adj, object *obj, int *small_nuggets, int *large_nuggets, int *weight)
 Compute how many nuggets an object is worth, and remove it. More...
 
int animate_weapon (object *op, object *caster, object *spell, int dir)
 Generalization of staff_to_snake(). More...
 
int cast_bless (object *op, object *caster, object *spell_ob, int dir)
 Improve statistics of some living object. More...
 
int cast_change_ability (object *op, object *caster, object *spell_ob, int dir, int silent)
 Cast some stat-improving spell. More...
 
int cast_change_map_lightlevel (object *op, object *spell)
 This changes the light level for the entire map. More...
 
int cast_consecrate (object *op, object *caster, object *spell)
 A spell to make an altar your god's. More...
 
int cast_create_food (object *op, object *caster, object *spell_ob, int dir, const char *stringarg)
 Create food. More...
 
int cast_create_missile (object *op, object *caster, object *spell, int dir, const char *stringarg)
 Create a missile (nonmagic - magic +4). More...
 
int cast_create_town_portal (object *op, object *caster, object *spell)
 This function cast the spell of town portal for op. More...
 
int cast_detection (object *op, object *caster, object *spell)
 Detect magic or invisible items. More...
 
int cast_earth_to_dust (object *op, object *caster, object *spell_ob)
 Basically destroys earthwalls in the area. More...
 
int cast_heal (object *op, object *caster, object *spell, int dir)
 Heals something. More...
 
int cast_identify (object *op, object *caster, object *spell)
 Identifies objects in the players inventory/on the ground. More...
 
int cast_invisible (object *op, object *caster, object *spell_ob)
 Makes the player or character invisible. More...
 
int cast_item_curse_or_bless (object *op, object *spell_ob)
 This alters player's marked item's cursed or blessed status, based on the spell_ob's fields. More...
 
void cast_magic_storm (object *op, object *tmp, int lvl)
 This is really used mostly for spell fumbles and the like. More...
 
int cast_polymorph (object *op, object *caster, object *spell_ob, int dir)
 Polymorph spell casting. More...
 
int cast_transfer (object *op, object *caster, object *spell, int dir)
 This spell transfers sp from the player to another person. More...
 
int cast_wonder (object *op, object *caster, int dir, object *spell_ob)
 wonder is really just a spell that will likely cast another spell. More...
 
int cast_word_of_recall (object *op, object *caster, object *spell_ob)
 Word of recall causes the player to return 'home'. More...
 
static void charge_mana_effect (object *victim, int caster_level)
 Checks if victim has overcharged mana, and if so does some fireball. More...
 
void counterspell (object *op, int dir)
 Nullifies spell effects. More...
 
int create_aura (object *op, object *caster, object *spell)
 Create an aura spell object and put it in the player's inventory. More...
 
int dimension_door (object *op, object *caster, object *spob, int dir)
 Teleport through some doors and space. More...
 
static void food_each (archetype *arch)
 
int magic_wall (object *op, object *caster, int dir, object *spell_ob)
 This creates magic walls. More...
 
int makes_invisible_to (object *pl, object *mon)
 This checks to see if 'pl' is invisible to 'mon'. More...
 
int perceive_self (object *op)
 Living thing wants to know information. More...
 
static void place_alchemy_objects (object *op, mapstruct *m, int small_nuggets, int large_nuggets, int x, int y)
 Place gold nuggets on the map. More...
 
void polymorph (object *op, object *who, int level)
 Handles polymorphing an object, living or not. More...
 
static void polymorph_item (object *who, object *op, int level)
 Changes an item to another item of similar type. More...
 
static void polymorph_living (object *op, int level)
 Takes a living object (op) and turns it into another monster of some sort. More...
 
static void polymorph_melt (object *who, object *op)
 Destroys item from polymorph failure. More...
 
int probe (object *op, object *caster, object *spell_ob, int dir, int level)
 Try to get information about a living thing. More...
 
int recharge (object *op, object *caster, object *spell_ob)
 Recharge wands. More...
 
int remove_curse (object *op, object *caster, object *spell)
 This function removes the cursed/damned status on equipped items. More...
 
static int town_portal_destroy_existing (object *op, object *spell)
 Remove op's existing town portals. More...
 
static objecttown_portal_find_force (object *op, object *spell)
 
int write_mark (object *op, object *spell, const char *msg)
 This writes a rune that contains the appropriate message. More...
 

Variables

static archetypefood_choice
 
static int food_value_choice
 
static const char *const no_gain_msgs [NUM_STATS]
 This is used for the spells that gain stats. More...
 

Detailed Description

Various spell effects, non attacks.

Todo:
use the same parameter names/orders.

Definition in file spell_effect.cpp.

Macro Definition Documentation

◆ _GNU_SOURCE

#define _GNU_SOURCE

Definition at line 20 of file spell_effect.cpp.

◆ LARGE_NUGGET

#define LARGE_NUGGET   "largenugget"

Definition at line 2176 of file spell_effect.cpp.

Referenced by alchemy_object(), and place_alchemy_objects().

◆ SMALL_NUGGET

#define SMALL_NUGGET   "smallnugget"

Definition at line 2175 of file spell_effect.cpp.

Referenced by alchemy_object(), and place_alchemy_objects().

Function Documentation

◆ alchemy()

int alchemy ( object op,
object caster,
object spell_ob 
)

Change items to gold nuggets.

Only works for players.

Parameters
opwho is casting.
casterwhat is casting.
spell_obactual spell object.
Return values
0op isn't a player.
1op is a player.

Definition at line 2306 of file spell_effect.cpp.

References alchemy_object(), object::contr, object::duration, FLAG_ALIVE, FLAG_IS_CAULDRON, FLAG_NO_PICK, FOR_INV_FINISH, FOR_INV_PREPARE, FOR_MAP_FINISH, FOR_MAP_PREPARE, get_map_flags(), GET_MAP_MOVE_BLOCK, socket_struct::look_position, object::map, MOVE_WALK, P_NO_MAGIC, P_OUT_OF_MAP, place_alchemy_objects(), PLAYER, QUERY_FLAG, player::socket, SP_level_dam_adjust(), SP_level_duration_adjust(), object::type, object::x, and object::y.

Referenced by cast_spell().

◆ alchemy_object()

static void alchemy_object ( float  value_adj,
object obj,
int *  small_nuggets,
int *  large_nuggets,
int *  weight 
)
static

Compute how many nuggets an object is worth, and remove it.

Parameters
value_adjhow much to adjust the cost of obj.
objobject to convert.
[out]small_nuggetshow many small nuggets obj gives.
[out]large_nuggetshow many large nuggets obj gives.
[out]weightthe weight of the object.

< Value of nuggets.

Definition at line 2192 of file spell_effect.cpp.

References archetype::clone, FLAG_UNPAID, FREE_OBJ_NO_DESTROY_CALLBACK, GEM, LARGE_NUGGET, MONEY, object_free(), object_remove(), price_base(), QUERY_FLAG, rndm(), SMALL_NUGGET, try_find_archetype(), object::type, object::value, and object::weight.

Referenced by alchemy().

◆ animate_weapon()

int animate_weapon ( object op,
object caster,
object spell,
int  dir 
)

Generalization of staff_to_snake().

Makes a golem out of the caster's weapon. The golem is based on the archetype specified, modified by the caster's level and the attributes of the weapon. The weapon is inserted in the golem's inventory so that it falls to the ground when the golem dies. This code was very odd - code early on would only let players use the spell, yet the code was full of player checks. I've presumed that the code that only let players use it was correct, and removed all the other player checks. MSW 2003-01-06

Parameters
opwho is casting.
casterwhat is casting.
spellactual spell object.
dircasting direction.
Return values
0spell failure.
1spell was successful.

Definition at line 3065 of file spell_effect.cpp.

References add_friendly_object(), add_string(), object::anim_speed, object::animation, object::arch, arch_to_object(), AT_PHYSICAL, ATNR_BLIND, ATNR_CONFUSION, ATNR_DEATH, ATNR_DEPLETE, ATNR_FEAR, ATNR_PARALYZE, ATNR_PHYSICAL, ATNR_POISON, ATNR_SLOW, ATNR_TURN_UNDEAD, object::attacktype, buf, caster_level(), CLEAR_FLAG, archetype::clone, living::Con, object::contr, object::count, living::dam, living::Dex, do_skill_cb_data::dir, object::direction, draw_ext_info(), draw_ext_info_format(), object::duration, esrv_update_item(), living::exp, object::face, find_marked_object(), fix_object(), FLAG_ANIMATE, FLAG_APPLIED, FLAG_FRIENDLY, FLAG_MONSTER, FLAG_REMOVED, FLAG_UNPAID, FLAG_USE_WEAPON, free_string(), freearr_x, freearr_y, get_map_flags(), GET_MAP_MOVE_BLOCK, GOLEM, player::golem_count, living::hp, object::last_anim, llevError, LOG(), m, object::magic, object::map, object::materialname, MAX, MAX_BUF, living::maxgrace, living::maxhp, object::move_type, MSG_TYPE_SPELL, MSG_TYPE_SPELL_ERROR, object::name, archetype::name, name_to_material(), NDI_BLACK, NDI_UNIQUE, object::nrof, NROFATTACKS, object_find_free_spot(), object_insert_in_map_at(), object_insert_in_ob(), object_remove(), object_set_owner(), object_split(), object_update_speed(), object::other_arch, P_OUT_OF_MAP, pets_control_golem(), PLAYER, QUERY_FLAG, query_name(), object::race, range_golem, player::ranges, object::resist, materialtype_t::save, SET_FLAG, set_spell_skill(), player::shoottype, living::sp, SP_level_dam_adjust(), SP_level_duration_adjust(), SP_level_range_adjust(), object::speed, object::speed_left, object::state, object::stats, living::Str, object::type, UPD_NROF, living::wc, WEAPON, object::x, and object::y.

Referenced by cast_spell().

◆ cast_bless()

◆ cast_change_ability()

int cast_change_ability ( object op,
object caster,
object spell_ob,
int  dir,
int  silent 
)

◆ cast_change_map_lightlevel()

int cast_change_map_lightlevel ( object op,
object spell 
)

This changes the light level for the entire map.

Parameters
opwho is casting.
spellactual spell object.
Return values
0light not affected.
1light changed.

Definition at line 3295 of file spell_effect.cpp.

References change_map_light(), living::dam, draw_ext_info(), object::map, MSG_TYPE_SPELL, MSG_TYPE_SPELL_FAILURE, NDI_UNIQUE, and object::stats.

Referenced by cast_spell().

◆ cast_consecrate()

int cast_consecrate ( object op,
object caster,
object spell 
)

A spell to make an altar your god's.

Parameters
opwho is casting.
casterwhat is casting.
spellactual spell object.
Return values
0no consecration happened.
1an altar waas consecrated.

Definition at line 2987 of file spell_effect.cpp.

References arch_to_object(), buf, caster_level(), determine_god(), draw_ext_info(), draw_ext_info_format(), find_god(), FLAG_IS_BUILDABLE, FLAG_IS_FLOOR, FOR_BELOW_FINISH, FOR_BELOW_PREPARE, HOLY_ALTAR, INS_BELOW_ORIGINATOR, object::level, llevError, LOG(), object::map, MAX_BUF, MSG_TYPE_SPELL, MSG_TYPE_SPELL_ERROR, MSG_TYPE_SPELL_FAILURE, MSG_TYPE_SPELL_SUCCESS, object::name, NDI_UNIQUE, object_insert_in_map_at(), object_remove(), QUERY_FLAG, SET_FLAG, tolower, and try_find_archetype().

Referenced by cast_spell().

◆ cast_create_food()

int cast_create_food ( object op,
object caster,
object spell_ob,
int  dir,
const char *  stringarg 
)

Create food.

Allows the choice of what sort of food object to make. If stringarg is NULL, it will create food dependent on level –PeterM

Parameters
opwho is casting.
casterwhat is casting.
spell_obactual spell object.
dircasting direction.
stringargoptional parameter specifying what kind of items to create.
Return values
0no food created.
foodwas created.

Definition at line 627 of file spell_effect.cpp.

References archetypes_for_each(), cast_create_obj(), archetype::clone, draw_ext_info(), DRINK, find_archetype_by_object_type_name(), living::food, FOOD, food_choice, food_each(), food_value_choice, identify(), is_identified(), MSG_TYPE_SPELL, MSG_TYPE_SPELL_FAILURE, NDI_UNIQUE, object::nrof, object_copy(), object_new(), SP_level_duration_adjust(), object::stats, and object::value.

Referenced by cast_spell().

◆ cast_create_missile()

int cast_create_missile ( object op,
object caster,
object spell,
int  dir,
const char *  stringarg 
)

Create a missile (nonmagic - magic +4).

Will either create bolts or arrows based on whether a crossbow or bow is equiped. If neither, it defaults to arrows. Sets the plus based on the casters level. It is also settable with the invoke command. If the caster attempts to create missiles with too great a plus, the default is used. The # of arrows created also goes up with level, so if a 30th level mage wants LOTS of arrows, and doesn't care what the plus is he could create nonnmagic arrows, or even -1, etc...

Parameters
opwho is casting.
casterwhat is casting.
spellactual spell object.
dircasting direction.
stringargoptional parameter specifying what kind of items to create.
Return values
0no missile created.
missileswere created.

Definition at line 493 of file spell_effect.cpp.

References BOW, cast_create_obj(), object::count, create_archetype(), living::dam, draw_ext_info_format(), object::duration, find_artifactlist(), FLAG_IDENTIFIED, FREE_OBJ_NO_DESTROY_CALLBACK, give_artifact_abilities(), artifact::item, artifactlist::items, llevDebug, LOG(), object::magic, MSG_TYPE_SPELL, MSG_TYPE_SPELL_ERROR, NDI_UNIQUE, object::nrof, object_find_by_type_applied(), object_free(), object_was_destroyed, pick_up(), PLAYER, object::race, SET_FLAG, object::slaying, SP_level_dam_adjust(), SP_level_duration_adjust(), object::stats, strcasecmp(), try_find_archetype(), object::type, and object::value.

Referenced by cast_spell().

◆ cast_create_town_portal()

int cast_create_town_portal ( object op,
object caster,
object spell 
)

This function cast the spell of town portal for op.

The spell operates in two passes. During the first one a place is marked as a destination for the portal. During the second one, 2 portals are created, one in the position the player cast it and one in the destination place. The portal are synchronized and 2 forces are inserted in the player to destruct the portal next time player creates a new portal pair. This spell has a side effect that it allows people to meet each other in a permanent, private, apartments by making a town portal from it to the town or another public place. So, check if the map is unique and if so return an error

Code by Tchize (david.nosp@m..del.nosp@m.becq@.nosp@m.usa..nosp@m.net)

Parameters
opwho is casting.
casterwhat is casting.
spellactual spell object.
Return values
0spell was insuccessful for some reason.
1spell worked.

Definition at line 1241 of file spell_effect.cpp.

References add_string(), ARCH_PORTAL_FAILED, cast_create_obj(), caster_level(), object::contr, create_archetype(), Settings::create_home_portals, draw_ext_info(), EXIT_PATH, EXIT_X, EXIT_Y, FREE_AND_COPY, HUGE_BUF, mapstruct::last_reset_time, llevError, LOG(), object::map, map_path_unique(), MAP_PLAYER_UNIQUE, MSG_TYPE_SPELL, MSG_TYPE_SPELL_ERROR, MSG_TYPE_SPELL_FAILURE, MSG_TYPE_SPELL_SUCCESS, object::name, object::name_pl, NDI_NAVY, NDI_UNIQUE, object_free(), object_insert_in_map_at(), object_insert_in_ob(), object_remove(), object_set_msg(), mapstruct::path, object::race, ready_map_name(), settings, object::slaying, town_portal_destroy_existing(), town_portal_find_force(), player::transport, mapstruct::unique, object::weapontype, object::x, and object::y.

Referenced by cast_spell().

◆ cast_detection()

int cast_detection ( object op,
object caster,
object spell 
)

◆ cast_earth_to_dust()

int cast_earth_to_dust ( object op,
object caster,
object spell_ob 
)

Basically destroys earthwalls in the area.

Parameters
opwho is casting.
casterwhat is casting.
spell_obactual spell object.
Return values
0op isn't a player.
1op is a player.

Definition at line 855 of file spell_effect.cpp.

References AT_PHYSICAL, FLAG_TEAR_DOWN, FOR_MAP_FINISH, FOR_MAP_PREPARE, get_map_flags(), GET_MAP_MOVE_BLOCK, hit_player(), m, object::map, P_OUT_OF_MAP, PLAYER, QUERY_FLAG, object::range, SP_level_range_adjust(), object::type, object::x, and object::y.

Referenced by cast_spell().

◆ cast_heal()

int cast_heal ( object op,
object caster,
object spell,
int  dir 
)

◆ cast_identify()

int cast_identify ( object op,
object caster,
object spell 
)

Identifies objects in the players inventory/on the ground.

Parameters
opwho is casting.
casterwhat is casting.
spellactual spell object.
Return values
0nothing was identified.
1at least one object was identified.

Definition at line 2505 of file spell_effect.cpp.

References living::dam, draw_ext_info(), draw_ext_info_format(), esrv_update_item(), FOR_INV_FINISH, FOR_INV_PREPARE, FOR_MAP_FINISH, FOR_MAP_PREPARE, identify(), is_identified(), object::map, MAX_BUF, MSG_TYPE_ITEM, MSG_TYPE_ITEM_INFO, MSG_TYPE_SPELL, MSG_TYPE_SPELL_FAILURE, NDI_UNIQUE, ob_describe(), PLAYER, SP_level_dam_adjust(), spell_effect(), object::stats, object::type, UPD_FLAGS, UPD_NAME, object::x, and object::y.

Referenced by cast_spell().

◆ cast_invisible()

int cast_invisible ( object op,
object caster,
object spell_ob 
)

Makes the player or character invisible.

Note the spells to 'stack', but perhaps in odd ways. the duration for all is cumulative. In terms of invis undead/normal invis, it is the last one cast that will determine if you are invisible to undead or normal monsters. For improved invis, if you cast it with a one of the others, you lose the improved part of it, and the above statement about undead/ normal applies.

Parameters
opwho is casting.
casterwhat is casting.
spell_obactual spell object.
Return values
0invisibility was already in action.
1op is now invisible.

Definition at line 803 of file spell_effect.cpp.

References add_refcount(), object::contr, draw_ext_info(), object::duration, FLAG_MAKE_INVIS, FREE_AND_CLEAR_STR, player::hidden, player::invis_race, object::invisible, makes_invisible_to(), MSG_TYPE_SPELL, MSG_TYPE_SPELL_FAILURE, MSG_TYPE_SPELL_SUCCESS, NDI_UNIQUE, object_update(), PLAYER, QUERY_FLAG, object::race, SP_level_duration_adjust(), player::tmp_invis, object::type, and UP_OBJ_FACE.

Referenced by cast_spell().

◆ cast_item_curse_or_bless()

int cast_item_curse_or_bless ( object op,
object spell_ob 
)

This alters player's marked item's cursed or blessed status, based on the spell_ob's fields.

Parameters
opplayer casting the spell.
spell_obspell itself.
Returns
1 if item was changed, 0 else.

Definition at line 2454 of file spell_effect.cpp.

References CLEAR_FLAG, draw_ext_info(), draw_ext_info_format(), esrv_update_item(), find_marked_object(), FLAG_BLESSED, FLAG_CURSED, FLAG_IDENTIFIED, FLAG_KNOWN_BLESSED, FLAG_KNOWN_CURSED, FLAG_STARTEQUIP, HUGE_BUF, MSG_TYPE_SPELL, MSG_TYPE_SPELL_FAILURE, MSG_TYPE_SPELL_SUCCESS, NDI_UNIQUE, QUERY_FLAG, query_short_name(), SET_FLAG, and UPD_FLAGS.

Referenced by cast_spell().

◆ cast_magic_storm()

void cast_magic_storm ( object op,
object tmp,
int  lvl 
)

This is really used mostly for spell fumbles and the like.

Parameters
opwhat is casting this.
tmpobject to propagate.
lvlhow nasty should the propagation be.

Definition at line 49 of file spell_effect.cpp.

References object::count, living::dam, object::duration, object::level, object::map, living::maxhp, object_insert_in_map_at(), object::range, object::stats, object::x, and object::y.

Referenced by alchemy_failure_effect(), become_follower(), god_examines_priest(), pray_at_altar(), prayer_failure(), and scroll_failure().

◆ cast_polymorph()

int cast_polymorph ( object op,
object caster,
object spell_ob,
int  dir 
)

Polymorph spell casting.

Parameters
opwho is casting the spell.
casterobject used to cast spell.
spell_obspell itself.
dircasting direction. 0 won't have any effect.
Returns
Returns 0 on illegal cast, otherwise 1.

Definition at line 425 of file spell_effect.cpp.

References object::above, arch_to_object(), caster_level(), do_skill_cb_data::dir, FLAG_IS_FLOOR, living::food, FOR_OB_AND_BELOW_FINISH, FOR_OB_AND_BELOW_PREPARE, freearr_x, freearr_y, get_map_flags(), GET_MAP_MOVE_BLOCK, GET_MAP_OB, level, m, object::map, MOVE_FLY_LOW, object_insert_in_map_at(), object::other_arch, P_NO_MAGIC, P_OUT_OF_MAP, polymorph(), QUERY_FLAG, object::range, SP_level_range_adjust(), object::speed_left, object::stats, object::x, and object::y.

Referenced by cast_spell().

◆ cast_transfer()

int cast_transfer ( object op,
object caster,
object spell,
int  dir 
)

This spell transfers sp from the player to another person.

We let the target go above their normal maximum SP.

Parameters
opwho is casting.
casterwhat is casting.
spellactual spell object.
dircasting direction.
Return values
0no transfer happened.
1transfer happened.

Definition at line 2838 of file spell_effect.cpp.

References caster_level(), charge_mana_effect(), living::dam, do_skill_cb_data::dir, draw_ext_info(), FLAG_ALIVE, FOR_MAP_FINISH, FOR_MAP_PREPARE, freearr_x, freearr_y, get_map_flags(), m, object::map, MSG_TYPE_SPELL, MSG_TYPE_SPELL_FAILURE, NDI_BLACK, P_IS_ALIVE, P_OUT_OF_MAP, QUERY_FLAG, living::sp, SP_level_dam_adjust(), object::stats, object::x, and object::y.

Referenced by cast_spell().

◆ cast_wonder()

int cast_wonder ( object op,
object caster,
int  dir,
object spell_ob 
)

wonder is really just a spell that will likely cast another spell.

Parameters
opwho is casting.
casterwhat is casting.
dircasting direction.
spell_obactual spell object.
Todo:
doesn't it decrease sp without checking?

Definition at line 968 of file spell_effect.cpp.

References cast_cone(), cast_spell(), generate_treasure(), object::level, llevError, LOG(), object::name, object::randomitems, rndm(), SP_WONDER, SPELL, object::subtype, and object::type.

Referenced by cast_spell(), and scroll_failure().

◆ cast_word_of_recall()

int cast_word_of_recall ( object op,
object caster,
object spell_ob 
)

Word of recall causes the player to return 'home'.

we put a force into the player object, so that there is a time delay effect.

Parameters
opwho is casting.
casterwhat is casting.
spell_obactual spell object.
Return values
0op isn't a player.
1word of recall initiated.

Definition at line 906 of file spell_effect.cpp.

References add_string(), player::bed_x, player::bed_y, object::contr, create_archetype(), draw_ext_info(), object::duration, EXIT_PATH, EXIT_X, EXIT_Y, FORCE_NAME, llevError, LOG(), MSG_TYPE_SPELL, MSG_TYPE_SPELL_ERROR, MSG_TYPE_SPELL_SUCCESS, NDI_UNIQUE, object_find_by_type_subtype(), object_insert_in_ob(), object_update_speed(), PLAYER, player::savebed_map, SP_level_duration_adjust(), SP_WORD_OF_RECALL, object::speed, object::speed_left, SPELL_EFFECT, object::subtype, and object::type.

Referenced by cast_spell().

◆ charge_mana_effect()

static void charge_mana_effect ( object victim,
int  caster_level 
)
static

Checks if victim has overcharged mana, and if so does some fireball.

Parameters
victimwho may have overcharged.
caster_levelcaster's (skill) level whose spell did cause the overcharge.

Definition at line 2783 of file spell_effect.cpp.

References confuse_living(), create_archetype(), object::dam_modifier, draw_ext_info(), EXPLODING_FIREBALL, object::map, living::maxhp, living::maxsp, MSG_TYPE_SPELL, MSG_TYPE_SPELL_TARGET, MSG_TYPE_VICTIM, MSG_TYPE_VICTIM_SPELL, NDI_ORANGE, NDI_UNIQUE, object_insert_in_map_at(), PREFER_LOW, random_roll(), living::sp, object::stats, object::x, and object::y.

Referenced by cast_transfer().

◆ counterspell()

void counterspell ( object op,
int  dir 
)

Nullifies spell effects.

Basically, if the object has a magic attacktype, this may nullify it.

Parameters
opcounterspell object.
dirdirection it was cast in.

Definition at line 2911 of file spell_effect.cpp.

References AT_COUNTERSPELL, AT_MAGIC, object::attacktype, do_skill_cb_data::dir, FLAG_MONSTER, living::food, FOR_MAP_FINISH, FOR_MAP_PREPARE, freearr_x, freearr_y, get_map_flags(), HEAD, living::hp, object::level, m, object::map, object_free(), object_get_owner(), object_remove(), P_OUT_OF_MAP, QUERY_FLAG, rndm(), RUNE, object::speed_left, SPELL_EFFECT, object::stats, object::type, object::x, and object::y.

Referenced by hit_map().

◆ create_aura()

int create_aura ( object op,
object caster,
object spell 
)

◆ dimension_door()

int dimension_door ( object op,
object caster,
object spob,
int  dir 
)

◆ food_each()

static void food_each ( archetype arch)
static

◆ magic_wall()

◆ makes_invisible_to()

int makes_invisible_to ( object pl,
object mon 
)

This checks to see if 'pl' is invisible to 'mon'.

Does race check, undead check, etc Returns TRUE if mon can't see pl, false otherwise. This doesn't check range, walls, etc. It only checks the racial adjustments, and in fact that pl is invisible.

Parameters
plpotentially invisible object.
monwho may see pl.
Return values
0mon can see pl.
1mon can't see pl.

Definition at line 756 of file spell_effect.cpp.

References object::contr, FLAG_UNDEAD, player::invis_race, object::invisible, is_true_undead(), PLAYER, QUERY_FLAG, object::race, and object::type.

Referenced by cast_invisible(), and monster_can_see_enemy().

◆ perceive_self()

◆ place_alchemy_objects()

static void place_alchemy_objects ( object op,
mapstruct m,
int  small_nuggets,
int  large_nuggets,
int  x,
int  y 
)
static

Place gold nuggets on the map.

Parameters
opplayer who is casting the spell. Just used so nuggets are inserted below her.
mmap to insert to.
small_nuggets
large_nuggetshow many nuggets to place.
x
ywhere to place the nuggets.

Definition at line 2270 of file spell_effect.cpp.

References create_archetype(), INS_BELOW_ORIGINATOR, LARGE_NUGGET, object::map, object_insert_in_map_at(), SMALL_NUGGET, object::x, and object::y.

Referenced by alchemy().

◆ polymorph()

void polymorph ( object op,
object who,
int  level 
)

Handles polymorphing an object, living or not.

Will avoid some specific items (flying arrows and such).

Parameters
opobject being polymorphed.
whospell caster.
levelspell level.

Definition at line 371 of file spell_effect.cpp.

References object::arch, FABS, FLAG_ALIVE, FLAG_ANIMATE, FLAG_GENERATOR, FLAG_MONSTER, FLAG_NO_PICK, object::move_block, PLAYER, polymorph_item(), polymorph_living(), polymorph_melt(), QUERY_FLAG, rndm(), object::speed, TREASURE, and object::type.

Referenced by cast_polymorph().

◆ polymorph_item()

static void polymorph_item ( object who,
object op,
int  level 
)
static

◆ polymorph_living()

◆ polymorph_melt()

static void polymorph_melt ( object who,
object op 
)
static

Destroys item from polymorph failure.

Note
We should probably do something more clever ala nethack - create an iron golem or something.
Parameters
whowho cast the spell.
opspell victim.

Definition at line 252 of file spell_effect.cpp.

References draw_ext_info_format(), MAX_BUF, MSG_TYPE_SPELL, MSG_TYPE_SPELL_FAILURE, NDI_GREY, object::nrof, object_free(), object_remove(), play_sound_map(), query_name(), and SOUND_TYPE_ITEM.

Referenced by polymorph(), and polymorph_item().

◆ probe()

int probe ( object op,
object caster,
object spell_ob,
int  dir,
int  level 
)

Try to get information about a living thing.

Parameters
opwho is casting.
casterwhat is casting.
spell_obspell object being cast.
dircast direction.
levelprobe level.
Return values
0nothing probed.
1something was probed.

Definition at line 699 of file spell_effect.cpp.

References CAN_PROBE(), do_skill_cb_data::dir, draw_ext_info(), examine_monster(), FLAG_WIZCAST, FOR_MAP_FINISH, FOR_MAP_PREPARE, freearr_x, freearr_y, get_map_flags(), HEAD, m, object::map, MSG_TYPE_SPELL, MSG_TYPE_SPELL_FAILURE, MSG_TYPE_SPELL_SUCCESS, NDI_UNIQUE, P_IS_ALIVE, P_NO_MAGIC, P_OUT_OF_MAP, QUERY_FLAG, object::range, SP_level_range_adjust(), object::x, and object::y.

Referenced by cast_spell(), check_probe(), and examine_monster().

◆ recharge()

◆ remove_curse()

int remove_curse ( object op,
object caster,
object spell 
)

This function removes the cursed/damned status on equipped items.

Parameters
opwho is casting.
casterwhat is casting.
spellactual spell object.
Returns
how many items were affected.
Todo:
why is the value set to 0?

Definition at line 2406 of file spell_effect.cpp.

References caster_level(), CLEAR_FLAG, draw_ext_info(), esrv_update_item(), FLAG_APPLIED, FLAG_CURSED, FLAG_DAMNED, FLAG_KNOWN_CURSED, FOR_INV_FINISH, FOR_INV_PREPARE, MSG_TYPE_SPELL, MSG_TYPE_SPELL_FAILURE, MSG_TYPE_SPELL_SUCCESS, NDI_UNIQUE, PLAYER, QUERY_FLAG, object::type, and UPD_FLAGS.

Referenced by cast_spell().

◆ town_portal_destroy_existing()

◆ town_portal_find_force()

◆ write_mark()

int write_mark ( object op,
object spell,
const char *  msg 
)

This writes a rune that contains the appropriate message.

There really aren't any adjustments we make.

Parameters
opwho is casting.
spellactual spell cast.
msgmessage to write.
Return values
0failure.
1success.

Definition at line 3413 of file spell_effect.cpp.

References add_string(), arch_to_object(), draw_ext_info(), HUGE_BUF, INS_BELOW_ORIGINATOR, llevInfo, LOG(), object::map, MSG_TYPE_SPELL, MSG_TYPE_SPELL_ERROR, object::name, NDI_UNIQUE, object_insert_in_map_at(), object_set_msg(), object::other_arch, object::race, strcasestr_local, object::x, and object::y.

Referenced by cast_spell().

Variable Documentation

◆ food_choice

archetype* food_choice
static
Todo:
ugly :(

Definition at line 593 of file spell_effect.cpp.

Referenced by cast_create_food().

◆ food_value_choice

int food_value_choice
static

Definition at line 594 of file spell_effect.cpp.

Referenced by cast_create_food(), and food_each().

◆ no_gain_msgs

const char* const no_gain_msgs[NUM_STATS]
static
Initial value:
= {
"You grow no stronger.",
"You grow no more agile.",
"You don't feel any healthier.",
"no wis",
"You are no easier to look at.",
"no int",
"no pow"
}

This is used for the spells that gain stats.

There are no spells right now that icnrease wis/int/pow on a temp basis, so no good comments for those.

Definition at line 1873 of file spell_effect.cpp.

Referenced by cast_change_ability().