Crossfire Server, Branches 1.12  R18729
spell_attack.c File Reference
#include <global.h>
#include <object.h>
#include <living.h>
#include <sproto.h>
#include <spells.h>
#include <sounds.h>
+ Include dependency graph for spell_attack.c:

Go to the source code of this file.

Functions

int cast_cause_disease (object *op, object *caster, object *spell, int dir)
 
int cast_cone (object *op, object *caster, int dir, object *spell)
 
int cast_curse (object *op, object *caster, object *spell_ob, int dir)
 
int cast_destruction (object *op, object *caster, object *spell_ob)
 
int cast_light (object *op, object *caster, object *spell, int dir)
 
int cast_smite_spell (object *op, object *caster, int dir, object *spell)
 
void check_bullet (object *op)
 
void cone_drop (object *op)
 
int create_bomb (object *op, object *caster, int dir, object *spell)
 
void explode_bullet (object *op)
 
int fire_bolt (object *op, object *caster, int dir, object *spob, object *skill)
 
int fire_bullet (object *op, object *caster, int dir, object *spob)
 
int fire_swarm (object *op, object *caster, object *spell, int dir)
 
static objectget_pointed_target (object *op, int dir, int range, int type)
 
static int make_object_glow (object *op, int radius, int time)
 
int mood_change (object *op, object *caster, object *spell)
 

Detailed Description

This file contains all the spell attack code. Grouping this code together should hopefully make it easier to find the relevent bits of code.

Todo:
put parameters in the same order, use same name.

Definition in file spell_attack.c.

Function Documentation

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

Let's try to infect something.

Parameters
opwho is casting.
casterwhat object is casting.
spellspell object to cast.
dircast direction.
Return values
0no one caught anything.
1at least one living was affected.

Definition at line 1310 of file spell_attack.c.

References obj::above, liv::ac, ARCH_DETECT_MAGIC, arch_to_object(), caster_level(), create_archetype(), liv::dam, draw_ext_info(), draw_ext_info_format(), liv::exp, obj::facing, FLAG_MONSTER, free_object(), freearr_x, freearr_y, get_map_flags(), GET_MAP_MOVE_BLOCK, GET_MAP_OB, obj::head, liv::hp, infect_object(), insert_ob_in_map(), obj::last_eat, obj::last_sp, obj::level, obj::magic, obj::map, liv::maxgrace, liv::maxhp, liv::maxsp, MOVE_FLY_LOW, MSG_TYPE_SPELL, MSG_TYPE_SPELL_FAILURE, MSG_TYPE_SPELL_SUCCESS, obj::name, NDI_UNIQUE, obj::other_arch, P_IS_ALIVE, P_OUT_OF_MAP, PLAYER, QUERY_FLAG, obj::range, set_owner(), set_spell_skill(), liv::sp, SP_level_dam_adjust(), SP_level_duration_adjust(), SP_level_range_adjust(), obj::stats, obj::type, liv::wc, obj::x, and obj::y.

Referenced by cast_spell().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Casts a cone spell.

Parameters
opperson firing the object.
casterobject casting the spell.
dirdirection to fire in.
spellspell that is being fired. It uses other_arch for the archetype to fire.
Return values
0couldn't cast.
1successful cast.

Definition at line 403 of file spell_attack.c.

References arch_to_object(), AT_FEAR, AT_GODPOWER, AT_HOLYWORD, AT_TURN_UNDEAD, obj::attacktype, caster_level(), liv::Cha, archt::clone, cone_drop(), obj::count, liv::dam, draw_ext_info(), obj::duration, fear_bonus, FLAG_UNDEAD, freearr_x, freearr_y, get_map_flags(), GET_MAP_MOVE_BLOCK, insert_ob_in_map(), obj::level, llevDebug, LOG(), obj::map, liv::maxhp, MOVE_FLY_LOW, obj::move_on, obj::move_type, MSG_TYPE_SPELL, MSG_TYPE_SPELL_ERROR, archt::name, NDI_UNIQUE, obj::other_arch, P_OUT_OF_MAP, PLAYER, QUERY_FLAG, obj::range, RUNE, set_owner(), set_spell_skill(), liv::sp, SP_level_dam_adjust(), SP_level_duration_adjust(), SP_level_range_adjust(), obj::stats, tailor_god_spell(), turn_bonus, obj::type, liv::Wis, obj::x, and obj::y.

Referenced by cast_spell(), cast_wonder(), prayer_failure(), and spell_failure().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Curse an object, reducing its statistics.

Parameters
opwho is casting.
casterwhat object is casting.
spell_obspell object to cast.
dircast direction.
Return values
0curse had no effect.
1something was cursed.

Definition at line 914 of file spell_attack.c.

References liv::ac, add_refcount(), obj::below, change_abil(), create_archetype(), determine_god(), obj::direction, draw_ext_info(), draw_ext_info_format(), obj::duration, find_god(), fix_object(), FLAG_APPLIED, FORCE, FORCE_CHANGE_ABILITY, FORCE_NAME, free_string(), get_pointed_target(), insert_ob_in_ob(), obj::inv, obj::last_grace, MSG_TYPE_SPELL, MSG_TYPE_SPELL_FAILURE, MSG_TYPE_SPELL_SUCCESS, MSG_TYPE_VICTIM, MSG_TYPE_VICTIM_SPELL, obj::name, obj::name_pl, NDI_UNIQUE, obj::path_denied, obj::path_repelled, PLAYER, obj::race, obj::range, SET_FLAG, SP_level_duration_adjust(), obj::speed, obj::speed_left, SPELL_GRACE, obj::stats, obj::subtype, obj::type, and liv::wc.

Referenced by cast_spell().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Hit all monsters around the caster.

Parameters
opwho is casting.
casterwhat object is casting.
spell_obspell object to cast.
Returns
1.

Definition at line 819 of file spell_attack.c.

References obj::above, arch_to_object(), ATNR_MAGIC, obj::attacktype, change_skill(), liv::dam, obj::duration, find_skill_by_name(), FLAG_ALIVE, FLAG_FRIENDLY, get_map_flags(), GET_MAP_OB, obj::head, hit_player(), insert_ob_in_map(), make_object_glow(), obj::map, obj::other_arch, P_IS_ALIVE, P_OUT_OF_MAP, PLAYER, QUERY_FLAG, obj::range, obj::resist, obj::skill, SP_DESTRUCTION, SP_FAERY_FIRE, SP_level_dam_adjust(), SP_level_duration_adjust(), SP_level_range_adjust(), obj::stats, obj::subtype, obj::type, obj::x, and obj::y.

Referenced by cast_spell().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Illuminates something on a map, or try to blind a living thing.

See the spells documentation file for why this is its own function.

Parameters
opwho is casting.
casterwhat object is casting.
spellspell object to cast.
dircast direction.
Return values
0no effect.
1lighting successful.

Definition at line 1235 of file spell_attack.c.

References obj::above, arch_to_object(), obj::attacktype, liv::dam, draw_ext_info(), obj::duration, FLAG_MONSTER, freearr_x, freearr_y, get_map_flags(), GET_MAP_MOVE_BLOCK, GET_MAP_OB, obj::head, hit_player(), insert_ob_in_map(), llevError, LOG(), obj::map, MAX_LIGHT_RADII, MSG_TYPE_SPELL, MSG_TYPE_SPELL_ERROR, MSG_TYPE_SPELL_FAILURE, NDI_UNIQUE, OB_TYPE_MOVE_BLOCK, obj::other_arch, P_IS_ALIVE, P_OUT_OF_MAP, QUERY_FLAG, obj::range, SP_level_dam_adjust(), SP_level_duration_adjust(), SP_level_range_adjust(), obj::stats, obj::x, and obj::y.

Referenced by cast_spell().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

The priest points to a creature and causes a 'godly curse' to descend.

Parameters
opwho is casting.
casterwhat object is casting.
dircast direction.
spellspell object to cast.
Return values
0spell had no effect.
1something was affected by the spell.

Definition at line 655 of file spell_attack.c.

References arch_to_object(), AT_DEATH, AT_GODPOWER, AT_HOLYWORD, obj::attacktype, caster_level(), obj::count, liv::dam, determine_god(), draw_ext_info(), draw_ext_info_format(), obj::duration, find_god(), FLAG_REFL_SPELL, FLAG_UNDEAD, free_object(), get_pointed_target(), liv::grace, liv::hp, HUGE_BUF, insert_ob_in_map(), obj::level, obj::map, liv::maxhp, MSG_TYPE_SPELL, MSG_TYPE_SPELL_FAILURE, MSG_TYPE_SPELL_SUCCESS, obj::name, NDI_UNIQUE, obj::other_arch, PREFER_LOW, QUERY_FLAG, query_name(), obj::race, random_roll(), obj::range, set_owner(), set_spell_skill(), SP_EXPLOSION, SP_level_dam_adjust(), SP_level_range_adjust(), SPELL_EFFECT, SPELL_GRACE, SPELL_MANA, obj::stats, obj::subtype, tailor_god_spell(), obj::title, obj::type, obj::x, and obj::y.

Referenced by cast_spell().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void check_bullet ( object op)

Checks to see what op should do, given the space it is on (eg, explode, damage player, etc).

Parameters
opobject to check.

Definition at line 242 of file spell_attack.c.

References obj::above, obj::attacktype, obj::count, liv::dam, explode_bullet(), FLAG_ALIVE, FLAG_REMOVED, free_object(), get_map_flags(), GET_MAP_MOVE_BLOCK, GET_MAP_OB, hit_player(), obj::map, OB_TYPE_MOVE_BLOCK, obj::other_arch, P_IS_ALIVE, QUERY_FLAG, remove_ob(), obj::stats, was_destroyed, obj::x, and obj::y.

Referenced by fire_bullet(), and move_bullet().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void cone_drop ( object op)

Drops an object based on what is in the cone's "other_arch".

Parameters
opwhat object should drop.

Definition at line 369 of file spell_attack.c.

References add_refcount(), arch_to_object(), free_string(), insert_ob_in_map(), obj::level, obj::map, obj::other_arch, obj::owner, set_owner(), obj::skill, obj::x, and obj::y.

Referenced by cast_cone(), and move_cone().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Create a bomb.

Parameters
opwho is casting.
casterwhat object is casting.
dircast direction.
spellspell object to cast.
Return values
0no bomb was placed.
1bomb was placed on map.

Definition at line 552 of file spell_attack.c.

References arch_to_object(), obj::attacktype, liv::dam, draw_ext_info(), obj::duration, freearr_x, freearr_y, get_map_flags(), GET_MAP_MOVE_BLOCK, insert_ob_in_map(), obj::map, MOVE_WALK, MSG_TYPE_SPELL, MSG_TYPE_SPELL_ERROR, NDI_UNIQUE, obj::other_arch, P_OUT_OF_MAP, obj::range, set_owner(), set_spell_skill(), SP_level_dam_adjust(), SP_level_duration_adjust(), SP_level_range_adjust(), obj::stats, obj::x, and obj::y.

Referenced by cast_spell().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void explode_bullet ( object op)
int fire_bolt ( object op,
object caster,
int  dir,
object spob,
object skill 
)

Cast a bolt-like spell.

We remove the magic flag - that can be derived from spob->attacktype. This function sets up the appropriate owner and skill pointers.

Parameters
opwho is casting the spell.
casterwhat object is casting the spell (rod, ...).
dirfiring direction.
spobspell object for the bolt.
skillskill to credit kill experience to.
Return values
0no bolt could be fired.
1bolt was fired (but may have been destroyed already).

Definition at line 78 of file spell_attack.c.

References absdir(), add_refcount(), arch_to_object(), obj::attacktype, liv::Con, liv::dam, liv::Dex, obj::direction, DIRX, DIRY, obj::duration, FLAG_IS_TURNABLE, FLAG_REFLECTING, free_object(), get_map_flags(), GET_MAP_MOVE_BLOCK, insert_ob_in_map(), obj::map, ob_process(), OB_TYPE_MOVE_BLOCK, obj::other_arch, P_OUT_OF_MAP, QUERY_FLAG, obj::range, SET_ANIMATION, set_owner(), set_spell_skill(), obj::slaying, SP_level_dam_adjust(), SP_level_duration_adjust(), SP_level_range_adjust(), obj::stats, obj::x, and obj::y.

Referenced by cast_spell().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Casts a bullet-like spell.

We remove the magic flag - that can be derived from spob->attacktype. This function sets up the appropriate owner and skill pointers.

Parameters
opwho is casting.
casterwhat object is really casting.
dircasting direction.
spobspell object for the bullet.
Return values
0no bullet could be fired.
1bullet was fired (but may have been destroyed already).

Definition at line 301 of file spell_attack.c.

References absdir(), add_refcount(), arch_to_object(), obj::attacktype, check_bullet(), liv::dam, obj::dam_modifier, obj::direction, obj::duration, FLAG_IS_TURNABLE, FLAG_REFLECTING, liv::food, free_object(), freearr_x, freearr_y, get_map_flags(), GET_MAP_MOVE_BLOCK, liv::hp, insert_ob_in_map(), obj::map, liv::maxhp, OB_TYPE_MOVE_BLOCK, obj::other_arch, P_OUT_OF_MAP, QUERY_FLAG, obj::range, SET_ANIMATION, set_owner(), set_spell_skill(), obj::slaying, SP_level_dam_adjust(), SP_level_duration_adjust(), SP_level_range_adjust(), obj::stats, obj::x, and obj::y.

Referenced by cast_spell(), and move_swarm_spell().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

The following routine creates a swarm of objects. It actually sets up a specific swarm object, which then fires off all the parts of the swarm.

Parameters
opwho is casting.
casterwhat object is casting.
spellspell object to cast.
dircast direction.
Return values
0nothing happened.
1swarm was placed on map.

Definition at line 1185 of file spell_attack.c.

References arch_to_object(), AT_GODPOWER, AT_HOLYWORD, obj::attacktype, caster_level(), create_archetype(), die_roll(), obj::direction, obj::duration, insert_ob_in_map(), obj::invisible, obj::level, obj::map, obj::other_arch, PREFER_HIGH, set_owner(), set_spell_skill(), SP_level_duration_adjust(), obj::spell, SWARM_SPELL, tailor_god_spell(), obj::x, and obj::y.

Referenced by cast_spell().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static object* get_pointed_target ( object op,
int  dir,
int  range,
int  type 
)
static

Returns the pointer to the first monster in the direction which is pointed to by op.

This is used by finger of death and the 'smite' spells.

Author
b.t.
Parameters
opcaster - really only used for the source location.
dirdirection to look in.
rangehow far out to look.
typetype of spell - either SPELL_MANA or SPELL_GRACE. This info is used for blocked magic/unholy spaces.
Returns
suitable victim, or NULL if none was found.

Definition at line 603 of file spell_attack.c.

References obj::above, FLAG_MONSTER, freearr_x, freearr_y, get_map_flags(), GET_MAP_MOVE_BLOCK, GET_MAP_OB, obj::head, obj::map, MOVE_FLY_LOW, P_IS_ALIVE, P_NO_CLERIC, P_NO_MAGIC, P_OUT_OF_MAP, QUERY_FLAG, SPELL_GRACE, SPELL_MANA, obj::x, and obj::y.

Referenced by cast_curse(), and cast_smite_spell().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int make_object_glow ( object op,
int  radius,
int  time 
)
static

Makes living objects glow. We do this by creating a force and inserting it in the object.

Creatures denied the path of light are unaffected.

Parameters
opwhat to make glow.
radiusglow radius.
timeglow duration. If 0, the object glows permanently.
Return values
0nothing happened.
1op is now glowing.
Author
b.t.

Definition at line 777 of file spell_attack.c.

References create_archetype(), obj::env, FLAG_IS_USED_UP, liv::food, FORCE_NAME, obj::glow_radius, insert_ob_in_ob(), llevError, LOG(), MAX_LIGHT_RADII, MIN_ACTIVE_SPEED, obj::name, obj::path_denied, PATH_LIGHT, SET_FLAG, obj::speed, obj::stats, obj::x, and obj::y.

Referenced by cast_destruction().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

This covers the various spells that change the moods of monsters - makes them angry, peacful, friendly, etc.

Parameters
opwho is casting.
casterwhat object is casting.
spellspell object to cast.
Returns
1.

Definition at line 1014 of file spell_attack.c.

References obj::above, add_friendly_object(), arch_to_object(), obj::attack_movement, obj::attacktype, caster_level(), CLEAR_FLAG, determine_god(), did_make_save(), obj::enemy, liv::exp, find_god(), FLAG_BERSERK, FLAG_FRIENDLY, FLAG_GENERATOR, FLAG_MONSTER, FLAG_NO_ATTACK, FLAG_SLEEP, FLAG_UNAGGRESSIVE, FLAG_UNDEAD, get_map_flags(), GET_MAP_OB, obj::head, insert_ob_in_map(), obj::level, obj::map, MIN, NROFATTACKS, obj::other_arch, P_IS_ALIVE, P_OUT_OF_MAP, PETMOVE, PLAYER, PREFER_LOW, QUERY_FLAG, obj::race, random_roll(), obj::range, remove_friendly_object(), obj::resist, SET_FLAG, set_owner(), set_spell_skill(), share_exp(), SK_EXP_ADD_SKILL, obj::skill, obj::slaying, SP_level_range_adjust(), obj::stats, obj::type, obj::x, and obj::y.

Referenced by cast_spell().

+ Here is the call graph for this function:

+ Here is the caller graph for this function: