![]() |
Crossfire Server, Trunk
1.75.0
|
#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"
Go to the source code of this file.
Functions | |
int | cast_cause_disease (object *op, object *caster, object *spell, int dir) |
Let's try to infect something. More... | |
int | cast_cone (object *op, object *caster, int dir, object *spell) |
Casts a cone spell. More... | |
int | cast_curse (object *op, object *caster, object *spell_ob, int dir) |
Curse an object, reducing its statistics. More... | |
int | cast_destruction (object *op, object *caster, object *spell_ob) |
Hit all monsters around the caster. More... | |
int | cast_light (object *op, object *caster, object *spell, int dir) |
Illuminates something on a map, or try to blind a living thing. More... | |
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. More... | |
void | check_bullet (object *op) |
Checks to see what op should do, given the space it is on (eg, explode, damage player, etc). More... | |
void | cone_drop (object *op) |
Drops an object based on what is in the cone's "other_arch". More... | |
int | create_bomb (object *op, object *caster, int dir, object *spell) |
Create a bomb. More... | |
void | explode_bullet (object *op) |
Causes an object to explode, eg, a firebullet, poison cloud ball, etc. More... | |
int | fire_bolt (object *op, object *caster, int dir, object *spob) |
Cast a bolt-like spell. More... | |
int | fire_swarm (object *op, object *caster, object *spell, int dir) |
The following routine creates a swarm of objects. More... | |
static object * | get_pointed_target (object *op, int dir, int range, int type) |
Returns the pointer to the first monster in the direction which is pointed to by op. More... | |
static int | make_object_glow (object *op, int radius, int time) |
Makes living objects glow. More... | |
int | mood_change (object *op, object *caster, object *spell) |
This covers the various spells that change the moods of monsters - makes them angry, peaceful, friendly, etc. More... | |
This file contains all the spell attack code. Grouping this code together should hopefully make it easier to find the relevant bits of code.
Definition in file spell_attack.cpp.
Let's try to infect something.
op | who is casting. |
caster | what object is casting. |
spell | spell object to cast. |
dir | cast direction. |
0 | no one caught anything. |
1 | at least one living was affected. |
Definition at line 1207 of file spell_attack.cpp.
References living::ac, ARCH_DETECT_MAGIC, arch_to_object(), caster_level(), create_archetype(), living::dam, draw_ext_info, draw_ext_info_format(), living::exp, object::facing, FLAG_MONSTER, FOR_MAP_FINISH, FOR_MAP_PREPARE, freearr_x, freearr_y, get_map_flags(), GET_MAP_MOVE_BLOCK, HEAD, living::hp, infect_object(), object::last_eat, object::last_sp, object::level, m, object::magic, object::map, living::maxgrace, living::maxhp, living::maxsp, MOVE_FLY_LOW, MSG_TYPE_SPELL, MSG_TYPE_SPELL_FAILURE, MSG_TYPE_SPELL_SUCCESS, object::name, NDI_UNIQUE, object_free_drop_inventory(), object_insert_in_map_at(), object_set_owner(), P_IS_ALIVE, P_OUT_OF_MAP, PLAYER, QUERY_FLAG, set_spell_skill(), living::sp, SP_level_dam_adjust(), SP_level_duration_adjust(), SP_level_range_adjust(), spell, object::stats, object::type, living::wc, object::x, and object::y.
Referenced by cast_spell().
Casts a cone spell.
op | person firing the object. |
caster | object casting the spell. |
dir | direction to fire in. |
spell | spell that is being fired. It uses other_arch for the archetype to fire. |
0 | couldn't cast. |
1 | successful 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, cone_drop(), object::count, d, 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, object::map, living::maxhp, MOVE_FLY_LOW, object::move_on, object::move_type, MSG_TYPE_SPELL, MSG_TYPE_SPELL_ERROR, NDI_UNIQUE, object_insert_in_map_at(), object_set_owner(), object::other_arch, P_OUT_OF_MAP, PLAYER, QUERY_FLAG, object::range, RUNE, set_spell_skill(), living::sp, SP_level_dam_adjust(), SP_level_duration_adjust(), SP_level_range_adjust(), spell, object::stats, tailor_god_spell(), object::type, living::Wis, object::x, and object::y.
Referenced by cast_spell(), cast_wonder(), prayer_failure(), and spell_failure().
Curse an object, reducing its statistics.
op | who is casting. |
caster | what object is casting. |
spell_ob | spell object to cast. |
dir | cast direction. |
0 | curse had no effect. |
1 | something was cursed. |
Definition at line 800 of file spell_attack.cpp.
References living::ac, add_refcount(), arch_to_object(), change_abil(), create_archetype(), determine_god(), object::direction, draw_ext_info, draw_ext_info_format(), object::duration, find_god(), fix_object(), FLAG_APPLIED, FOR_INV_FINISH, FOR_INV_PREPARE, FORCE, FORCE_CHANGE_ABILITY, FORCE_NAME, free_string(), get_pointed_target(), INS_ON_TOP, object::last_grace, object::map, MSG_TYPE_SPELL, MSG_TYPE_SPELL_FAILURE, MSG_TYPE_SPELL_SUCCESS, MSG_TYPE_VICTIM, MSG_TYPE_VICTIM_SPELL, object::name, object::name_pl, NDI_UNIQUE, object_insert_in_map_at(), object_insert_in_ob(), object::other_arch, object::path_denied, object::path_repelled, PLAYER, object::race, object::range, SET_FLAG, SP_level_duration_adjust(), object::speed, object::speed_left, SPELL_GRACE, object::stats, object::subtype, object::type, living::wc, object::x, and object::y.
Referenced by cast_spell().
Hit all monsters around the caster.
op | who is casting. |
caster | what object is casting. |
spell_ob | spell object to cast. |
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, friendly, get_map_flags(), HEAD, hit_player(), m, make_object_glow(), object::map, object_insert_in_map_at(), object::other_arch, P_IS_ALIVE, P_OUT_OF_MAP, PLAYER, QUERY_FLAG, object::range, object::resist, object::skill, skill, SP_DESTRUCTION, SP_FAERY_FIRE, SP_level_dam_adjust(), SP_level_duration_adjust(), SP_level_range_adjust(), object::stats, object::subtype, object::type, object::x, and object::y.
Referenced by cast_spell().
Illuminates something on a map, or try to blind a living thing.
See the spells documentation file for why this is its own function.
op | who is casting. |
caster | what object is casting. |
spell | spell object to cast. |
dir | cast direction. |
0 | no effect. |
1 | lighting successful. |
Definition at line 1136 of file spell_attack.cpp.
References arch_to_object(), draw_ext_info, FLAG_MONSTER, freearr_x, freearr_y, get_map_flags(), GET_MAP_MOVE_BLOCK, hit_player(), llevError, LOG(), m, object::map, 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(), P_IS_ALIVE, P_OUT_OF_MAP, SP_level_dam_adjust(), SP_level_duration_adjust(), SP_level_range_adjust(), spell, object::x, and object::y.
Referenced by cast_spell().
The priest points to a creature and causes a 'godly curse' to descend.
op | who is casting. |
caster | what object is casting. |
dir | cast direction. |
spell | spell object to cast. |
0 | spell had no effect. |
1 | something was affected by the spell. |
Definition at line 546 of file spell_attack.cpp.
References arch_to_object(), AT_DEATH, AT_GODPOWER, AT_HOLYWORD, object::attacktype, caster_level(), living::dam, determine_god(), draw_ext_info, draw_ext_info_format(), object::duration, find_god(), FLAG_REFL_SPELL, FLAG_UNDEAD, get_pointed_target(), living::hp, HUGE_BUF, object::level, object::map, living::maxhp, MSG_TYPE_SPELL, MSG_TYPE_SPELL_FAILURE, MSG_TYPE_SPELL_SUCCESS, object::name, NDI_UNIQUE, object_free_drop_inventory(), object_insert_in_map_at(), object_set_owner(), PREFER_LOW, QUERY_FLAG, query_name(), object::race, random_roll(), object::range, set_spell_skill(), SP_EXPLOSION, SP_level_dam_adjust(), SP_level_range_adjust(), spell, SPELL_EFFECT, SPELL_GRACE, SPELL_MANA, object::stats, object::subtype, tailor_god_spell(), object::title, object::type, object::x, and object::y.
Referenced by cast_spell().
void check_bullet | ( | object * | op | ) |
Checks to see what op should do, given the space it is on (eg, explode, damage player, etc).
op | object to check. |
Definition at line 217 of file spell_attack.cpp.
References object::attacktype, object::count, living::dam, explode_bullet(), FLAG_ALIVE, FLAG_REMOVED, FOR_MAP_FINISH, FOR_MAP_PREPARE, get_map_flags(), GET_MAP_MOVE_BLOCK, hit_player(), m, object::map, OB_TYPE_MOVE_BLOCK, object_free_drop_inventory(), object_remove(), object_was_destroyed, object::other_arch, P_IS_ALIVE, QUERY_FLAG, object::stats, object::x, and object::y.
Referenced by fire_arch_from_position(), and move_bullet().
void cone_drop | ( | object * | op | ) |
Drops an object based on what is in the cone's "other_arch".
op | what object should drop. |
Definition at line 265 of file spell_attack.cpp.
References add_refcount(), arch_to_object(), free_string(), object::level, object::map, object_get_owner(), object_insert_in_map_at(), object_set_owner(), object::other_arch, object::skill, object::x, and object::y.
Referenced by cast_cone(), and move_cone().
Create a bomb.
op | who is casting. |
caster | what object is casting. |
dir | cast direction. |
spell | spell object to cast. |
0 | no bomb was placed. |
1 | bomb 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, object::map, MOVE_WALK, MSG_TYPE_SPELL, MSG_TYPE_SPELL_ERROR, NDI_UNIQUE, object_insert_in_map_at(), object_set_owner(), P_OUT_OF_MAP, object::range, set_spell_skill(), SP_level_dam_adjust(), SP_level_duration_adjust(), SP_level_range_adjust(), spell, object::stats, object::x, and object::y.
Referenced by cast_spell().
void explode_bullet | ( | object * | op | ) |
Causes an object to explode, eg, a firebullet, poison cloud ball, etc.
op | the object to explode. |
Definition at line 121 of file spell_attack.cpp.
References add_refcount(), arch_to_object(), AT_GODPOWER, AT_HOLYWORD, AT_MAGIC, object::attacktype, object::count, living::dam, object::dam_modifier, object::direction, object::duration, object::env, env, FREE_AND_CLEAR_STR, hit_map(), living::hp, INS_NO_MERGE, INS_NO_WALK_ON, llevError, LOG(), object::map, living::maxhp, object::move_on, object_copy_owner(), object_free_drop_inventory(), object_get_env_recursive(), object_get_owner(), object_insert_in_map_at(), object_remove(), object_was_destroyed, object::other_arch, out_of_map(), object::range, object::skill, living::sp, SP_BOMB, SP_CONE, SPELL_EFFECT, object::stats, object::subtype, tailor_god_spell(), object::type, object::x, and object::y.
Referenced by animate_bomb(), check_bullet(), and move_bullet().
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.
op | who is casting the spell. |
caster | what object is casting the spell (rod, ...). |
dir | firing direction. |
spob | spell object for the bolt. |
0 | no bolt could be fired. |
1 | bolt 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, object::direction, DIRX, DIRY, object::duration, FLAG_REFLECTING, get_map_flags(), GET_MAP_MOVE_BLOCK, object::map, ob_process(), OB_TYPE_MOVE_BLOCK, object_free_drop_inventory(), object_insert_in_map_at(), object_set_owner(), object_update_turn_face(), 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, object::x, and object::y.
Referenced by cast_spell().
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.
op | who is casting. |
caster | what object is casting. |
spell | spell object to cast. |
dir | cast direction. |
0 | nothing happened. |
1 | swarm was placed on map. |
Definition at line 1088 of file spell_attack.cpp.
References arch_to_object(), AT_GODPOWER, AT_HOLYWORD, object::attacktype, caster_level(), create_archetype(), die_roll(), object::direction, object::duration, object::invisible, object::level, object::map, object_insert_in_map_at(), object_set_owner(), PREFER_HIGH, set_spell_skill(), SP_level_duration_adjust(), spell, object::spell, SWARM_SPELL, tailor_god_spell(), object::x, and object::y.
Referenced by cast_spell().
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.
op | caster - really only used for the source location. |
dir | direction to look in. |
range | how far out to look. |
type | type of spell - either SPELL_MANA or SPELL_GRACE. This info is used for blocked magic/unholy spaces. |
Definition at line 496 of file spell_attack.cpp.
References FLAG_MONSTER, freearr_x, freearr_y, get_map_flags(), GET_MAP_MOVE_BLOCK, object::map, map_find_by_flag(), MOVE_FLY_LOW, P_IS_ALIVE, P_NO_CLERIC, P_NO_MAGIC, P_OUT_OF_MAP, SPELL_GRACE, SPELL_MANA, is_valid_types_gen::type, object::x, and object::y.
Referenced by cast_curse(), and cast_smite_spell().
|
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.
op | what to make glow. |
radius | glow radius. |
time | glow duration. If 0, the object glows permanently. |
0 | nothing happened. |
1 | op is now glowing. |
Definition at line 665 of file spell_attack.cpp.
References create_archetype(), object::env, FLAG_IS_USED_UP, living::food, FORCE_NAME, object::glow_radius, llevError, LOG(), MAX_LIGHT_RADII, MIN_ACTIVE_SPEED, object::name, object_insert_in_ob(), object::path_denied, PATH_LIGHT, SET_FLAG, object::speed, object::stats, time, object::x, and object::y.
Referenced by cast_destruction().
This covers the various spells that change the moods of monsters - makes them angry, peaceful, friendly, etc.
op | who is casting. |
caster | what object is casting. |
spell | spell object to cast. |
Definition at line 904 of file spell_attack.cpp.
References add_friendly_object(), arch_to_object(), object::attack_movement, caster_level(), CLEAR_FLAG, determine_god(), did_make_save(), living::exp, find_god(), FLAG_BERSERK, FLAG_FRIENDLY, FLAG_GENERATOR, FLAG_MONSTER, FLAG_NO_ATTACK, FLAG_SLEEP, FLAG_UNAGGRESSIVE, FLAG_UNDEAD, get_map_flags(), object::level, level, llevError, LOG(), m, object::map, map_find_by_flag(), MIN, NROFATTACKS, object_get_value(), object_insert_in_map_at(), object_set_enemy(), object_set_owner(), object_set_value(), object_value_set(), P_IS_ALIVE, P_OUT_OF_MAP, PETMOVE, PLAYER, PREFER_HIGH, PREFER_LOW, QUERY_FLAG, object::race, random_roll(), remove_friendly_object(), object::resist, SET_FLAG, set_spell_skill(), share_exp(), SK_EXP_ADD_SKILL, object::skill, object::slaying, SP_level_range_adjust(), spell, object::stats, object::type, object::x, and object::y.
Referenced by cast_spell().