Crossfire Server, Trunk
spell_attack.cpp File Reference
#include "global.h"
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include "object.h"
#include "living.h"
#include "sproto.h"
#include "spells.h"
#include "sounds.h"
+ Include dependency graph for spell_attack.cpp:

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)
 
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 relevant bits of code.

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

Definition in file spell_attack.cpp.

Function Documentation

◆ cast_cause_disease()

◆ cast_cone()

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 297 of file spell_attack.cpp.

References arch_to_object(), AT_FEAR, AT_GODPOWER, AT_HOLYWORD, AT_TURN_UNDEAD, object::attacktype, caster_level(), living::Cha, archetype::clone, cone_drop(), living::dam, draw_ext_info(), object::duration, FLAG_UNDEAD, freearr_x, freearr_y, get_fear_bonus(), get_map_flags(), GET_MAP_MOVE_BLOCK, get_turn_bonus(), object::level, llevDebug, LOG(), m, MOVE_FLY_LOW, object::move_type, MSG_TYPE_SPELL, MSG_TYPE_SPELL_ERROR, archetype::name, NDI_UNIQUE, object_insert_in_map_at(), object_set_owner(), give::op, object::other_arch, P_OUT_OF_MAP, PLAYER, QUERY_FLAG, object::range, RUNE, set_spell_skill(), SP_level_dam_adjust(), SP_level_duration_adjust(), SP_level_range_adjust(), object::stats, tailor_god_spell(), Ice::tmp, object::type, living::Wis, diamondslots::x, and diamondslots::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:

◆ cast_curse()

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

◆ cast_destruction()

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 707 of file spell_attack.cpp.

References arch_to_object(), ATNR_MAGIC, object::attacktype, change_skill(), living::dam, object::duration, find_skill_by_name(), FLAG_ALIVE, FLAG_FRIENDLY, FOR_MAP_FINISH, FOR_MAP_PREPARE, get_map_flags(), HEAD, hit_player(), commongive::inv, m, make_object_glow(), object_insert_in_map_at(), give::op, object::other_arch, P_IS_ALIVE, P_OUT_OF_MAP, PLAYER, QUERY_FLAG, object::range, object::skill, SP_DESTRUCTION, SP_FAERY_FIRE, SP_level_dam_adjust(), SP_level_duration_adjust(), SP_level_range_adjust(), object::stats, object::subtype, and Ice::tmp.

Referenced by cast_spell().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cast_light()

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 1136 of file spell_attack.cpp.

References arch_to_object(), object::attacktype, living::dam, draw_ext_info(), object::duration, FLAG_MONSTER, freearr_x, freearr_y, get_map_flags(), GET_MAP_MOVE_BLOCK, hit_player(), llevError, LOG(), m, map_find_by_flag(), MAX_LIGHT_RADII, MSG_TYPE_SPELL, MSG_TYPE_SPELL_ERROR, MSG_TYPE_SPELL_FAILURE, NDI_UNIQUE, OB_TYPE_MOVE_BLOCK, object_insert_in_map_at(), give::op, object::other_arch, P_IS_ALIVE, P_OUT_OF_MAP, object::range, SP_level_dam_adjust(), SP_level_duration_adjust(), SP_level_range_adjust(), object::stats, Ice::tmp, nlohmann::detail::void(), diamondslots::x, and diamondslots::y.

Referenced by cast_spell().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cast_smite_spell()

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

◆ check_bullet()

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 217 of file spell_attack.cpp.

References explode_bullet(), FLAG_ALIVE, FLAG_REMOVED, FOR_MAP_FINISH, FOR_MAP_PREPARE, get_map_flags(), GET_MAP_MOVE_BLOCK, hit_player(), m, OB_TYPE_MOVE_BLOCK, object_free_drop_inventory(), object_remove(), object_was_destroyed, give::op, P_IS_ALIVE, QUERY_FLAG, and Ice::tmp.

Referenced by fire_arch_from_position(), and move_bullet().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cone_drop()

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 265 of file spell_attack.cpp.

References add_refcount(), arch_to_object(), free_string(), object::level, object_get_owner(), object_insert_in_map_at(), object_set_owner(), give::op, and object::skill.

Referenced by cast_cone(), and move_cone().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ create_bomb()

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 447 of file spell_attack.cpp.

References arch_to_object(), object::attacktype, living::dam, draw_ext_info(), object::duration, freearr_x, freearr_y, get_map_flags(), GET_MAP_MOVE_BLOCK, m, MOVE_WALK, MSG_TYPE_SPELL, MSG_TYPE_SPELL_ERROR, NDI_UNIQUE, object_insert_in_map_at(), object_set_owner(), give::op, object::other_arch, P_OUT_OF_MAP, object::range, set_spell_skill(), SP_level_dam_adjust(), SP_level_duration_adjust(), SP_level_range_adjust(), object::stats, and Ice::tmp.

Referenced by cast_spell().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ explode_bullet()

void explode_bullet ( object op)

Causes an object to explode, eg, a firebullet, poison cloud ball, etc.

Parameters
opthe object to explode.

Definition at line 121 of file spell_attack.cpp.

References add_refcount(), arch_to_object(), AT_GODPOWER, AT_HOLYWORD, AT_MAGIC, env, FREE_AND_CLEAR_STR, hit_map(), INS_NO_MERGE, INS_NO_WALK_ON, llevError, LOG(), object_copy_owner(), object_free_drop_inventory(), object_get_env_recursive(), object_get_owner(), object_insert_in_map_at(), object_remove(), object_was_destroyed, give::op, out_of_map(), SP_BOMB, SP_CONE, SPELL_EFFECT, tailor_god_spell(), and Ice::tmp.

Referenced by animate_bomb(), check_bullet(), and move_bullet().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fire_bolt()

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

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.
Return values
0no bolt could be fired.
1bolt was fired (but may have been destroyed already).

Definition at line 61 of file spell_attack.cpp.

References absdir(), add_refcount(), arch_to_object(), object::attacktype, living::Con, living::dam, living::Dex, DIRX, DIRY, object::duration, FLAG_REFLECTING, get_map_flags(), GET_MAP_MOVE_BLOCK, ob_process(), OB_TYPE_MOVE_BLOCK, object_free_drop_inventory(), object_insert_in_map_at(), object_set_owner(), object_update_turn_face(), give::op, object::other_arch, P_OUT_OF_MAP, QUERY_FLAG, object::range, set_spell_skill(), object::slaying, SP_level_dam_adjust(), SP_level_duration_adjust(), SP_level_range_adjust(), object::stats, and Ice::tmp.

Referenced by cast_spell().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fire_swarm()

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 1088 of file spell_attack.cpp.

References arch_to_object(), AT_GODPOWER, AT_HOLYWORD, caster_level(), create_archetype(), die_roll(), object::duration, object_insert_in_map_at(), object_set_owner(), give::op, object::other_arch, PREFER_HIGH, set_spell_skill(), SP_level_duration_adjust(), SWARM_SPELL, tailor_god_spell(), and Ice::tmp.

Referenced by cast_spell().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ get_pointed_target()

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 496 of file spell_attack.cpp.

References FLAG_MONSTER, freearr_x, freearr_y, get_map_flags(), GET_MAP_MOVE_BLOCK, map_find_by_flag(), MOVE_FLY_LOW, give::op, P_IS_ALIVE, P_NO_CLERIC, P_NO_MAGIC, P_OUT_OF_MAP, SPELL_GRACE, SPELL_MANA, is_valid_types_gen::type, diamondslots::x, and diamondslots::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:

◆ make_object_glow()

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 665 of file spell_attack.cpp.

References create_archetype(), FLAG_IS_USED_UP, FORCE_NAME, llevError, LOG(), MAX_LIGHT_RADII, MIN_ACTIVE_SPEED, object_insert_in_ob(), give::op, PATH_LIGHT, SET_FLAG, and Ice::tmp.

Referenced by cast_destruction().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mood_change()