Atrinik Server 2.5
Functions | Variables
server/spell_util.c File Reference
#include <global.h>

Go to the source code of this file.

Functions

void init_spells ()
void dump_spells ()
int insert_spell_effect (char *archname, mapstruct *m, int x, int y)
spell_structfind_spell (int spelltype)
int check_spell_known (object *op, int spell_type)
int cast_spell (object *op, object *caster, int dir, int type, int ability, int item, const char *stringarg)
int cast_create_obj (object *op, object *new_op, int dir)
static int ok_to_put_more (mapstruct *m, int x, int y, object *op)
int fire_bolt (object *op, object *caster, int dir, int type)
int fire_arch_from_position (object *op, object *caster, sint16 x, sint16 y, int dir, archetype *at, int type, object *target)
int cast_cone (object *op, object *caster, int dir, int strength, int spell_type, archetype *spell_arch)
void cone_drop (object *op)
void move_cone (object *op)
void forklightning (object *op, object *tmp)
int reflwall (mapstruct *m, int x, int y, object *sp_op)
void move_bolt (object *op)
void explode_object (object *op)
void check_fired_arch (object *op)
void move_fired_arch (object *op)
int find_target_for_spell (object *op, object **target, uint32 flags)
int SP_level_dam_adjust (object *caster, int spell_type, int base_dam, int exact)
int SP_level_strength_adjust (object *caster, int spell_type)
int SP_level_spellpoint_cost (object *caster, int spell_type, int caster_level)
void move_swarm_spell (object *op)
void fire_swarm (object *op, object *caster, int dir, archetype *swarm_type, int spell_type, int n, int magic)

Variables

archetypespellarch [NROFREALSPELLS]

Detailed Description

Spell related helper functions.

Definition in file spell_util.c.


Function Documentation

int cast_cone ( object op,
object caster,
int  dir,
int  strength,
int  spell_type,
archetype spell_arch 
)

Casts a cone spell.

Parameters:
opPerson firing the object.
casterObject casting the spell.
dirDirection to fire in.
strengthStrength of the spell.
spell_typeID of the spell.
spell_archSpell's arch.
Return values:
0Couldn't cast.
1Successful cast.

Definition at line 999 of file spell_util.c.

int cast_create_obj ( object op,
object new_op,
int  dir 
)

Creates object new_op in direction dir or if that is blocked, beneath the player (op).

Parameters:
opWho is casting.
new_opObject to insert.
dirDirection to insert into. Can be 0.
Returns:
Direction that the object was actually placed in.

Definition at line 769 of file spell_util.c.

int cast_spell ( object op,
object caster,
int  dir,
int  type,
int  ability,
int  item,
const char *  stringarg 
)

Cast a spell.

Parameters:
opThe creature that is owner of the object that is casting the spell.
casterThe actual object (wand, potion) casting the spell. Can be same as op.
dirDirection to cast in.
typeSpell ID.
abilityIf true, the spell is the innate ability of a monster (ie, don't check for blocks_magic(), and don't add AT_MAGIC to attacktype).
itemThe type of object that is casting the spell.
stringargAny options that are being used.
Returns:
0 on failure, non-zero on success and is used by caller to drain mana/grace.

Definition at line 317 of file spell_util.c.

void check_fired_arch ( object op)

If we are here, the arch (spell) we check was able to move to this place. wall() has failed, including reflection checking.

Look for a target.

Parameters:
opThe spell object.

Definition at line 1471 of file spell_util.c.

int check_spell_known ( object op,
int  spell_type 
)

Checks to see if player knows the spell.

Parameters:
opObject we're checking.
spell_typeSpell ID.
Returns:
1 if op knows the spell, 0 otherwise.

Definition at line 288 of file spell_util.c.

void cone_drop ( object op)

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

Parameters:
opThe object.

Definition at line 1097 of file spell_util.c.

void dump_spells ( )

Dumps all the spells.

Definition at line 172 of file spell_util.c.

void explode_object ( object op)

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

Parameters:
opThe object to explode.

Definition at line 1429 of file spell_util.c.

spell_struct* find_spell ( int  spelltype)

Find a spell in the spells array.

Parameters:
spelltypeID of the spell to find.
Returns:
The spell from the spells array, NULL if not found.

Definition at line 273 of file spell_util.c.

int find_target_for_spell ( object op,
object **  target,
uint32  flags 
)

Detect target for casting a spell.

Parameters:
opCaster.
[out]targetWill contain target for the spell we're casting.
flagsSpell flags.
Returns:
1 if the object can cast the spell on the target, 0 otherwise.

Definition at line 1644 of file spell_util.c.

int fire_arch_from_position ( object op,
object caster,
sint16  x,
sint16  y,
int  dir,
archetype at,
int  type,
object target 
)

Fires an archetype.

Parameters:
opPerson firing the object.
casterObject casting the spell.
xX position where to fire the spell.
yY position where to fire the spell.
dirDirection to fire in.
atThe archetype to fire.
typeSpell ID.
Returns:
0 on failure, 1 on success.

Definition at line 925 of file spell_util.c.

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

Cast a bolt-like spell.

Parameters:
opWho is casting the spell.
casterWhat object is casting the spell (rod, ...).
dirFiring direction.
typeSpell ID.
Return values:
0No bolt could be fired.
1Bolt was fired (but may have been destroyed already).

Definition at line 848 of file spell_util.c.

void fire_swarm ( object op,
object caster,
int  dir,
archetype swarm_type,
int  spell_type,
int  n,
int  magic 
)

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.
dirCast direction.
swarm_typeArchetype of the swarm.
spell_typeID of the spell.
nThe number to be fired.
magicMagic.

Definition at line 1926 of file spell_util.c.

void forklightning ( object op,
object tmp 
)

Causes op to fork.

Parameters:
opOriginal bolt.
tmpFirst piece of the fork.

Definition at line 1224 of file spell_util.c.

void init_spells ( )

Initialize spells.

Definition at line 39 of file spell_util.c.

int insert_spell_effect ( char *  archname,
mapstruct m,
int  x,
int  y 
)

Inserts a spell effect on map.

Parameters:
archnameSpell effect arch.
mMap.
xX position on map.
yY position on map.
Returns:
1 on failure, 0 otherwise.
Todo:
Does not support multi arch effects yet.

Definition at line 229 of file spell_util.c.

void move_bolt ( object op)

Moves bolt 'op'. Basically, it just advances a space, and checks for various things that may stop it.

Parameters:
opThe bolt object moving.

Definition at line 1323 of file spell_util.c.

void move_cone ( object op)

Causes cone object 'op' to move a space/hit creatures.

Parameters:
opCone object moving.

Definition at line 1119 of file spell_util.c.

void move_fired_arch ( object op)

Move a fired arch.

Parameters:
opObject.

Definition at line 1548 of file spell_util.c.

void move_swarm_spell ( object op)

This is an implementation of the swarm spell. It was written for meteor swarm, but it could be used for any swarm. A swarm spell is a special type of object that casts swarms of other types of spells. Which spell it casts is flexible. It fires the spells from a set of squares surrounding the caster, in a given direction.

Parameters:
opThe spell effect.

Definition at line 1850 of file spell_util.c.

static int ok_to_put_more ( mapstruct m,
int  x,
int  y,
object op 
) [static]

Returns true if it is ok to put spell op on the space/may provided.

Parameters:
mMap.
xX position on map.
yY position on map.
opObject to test for.
Returns:
1 if we can add op, 0 else.

Definition at line 811 of file spell_util.c.

int reflwall ( mapstruct m,
int  x,
int  y,
object sp_op 
)

Decides whether the (spell-)object sp_op will be reflected from the given mapsquare. Returns 1 if true.

(Note that for living creatures there is a small chance that reflect_spell fails.)

Parameters:
mMap.
xX position.
yY position.
sp_opSpell object to test.
Returns:
1 if reflected, 0 otherwise.

Definition at line 1299 of file spell_util.c.

int SP_level_dam_adjust ( object caster,
int  spell_type,
int  base_dam,
int  exact 
)

Returns adjusted damage based on the caster.

Parameters:
casterWho is casting.
spell_typeSpell ID we're adjusting.
base_damBase damage.
exactReturn exact damage, unadjusted by random percent?
Returns:
Adjusted damage.

Definition at line 1753 of file spell_util.c.

int SP_level_spellpoint_cost ( object caster,
int  spell_type,
int  caster_level 
)

Scales the spellpoint cost of a spell by it's increased effectiveness. Some of the lower level spells become incredibly vicious at high levels. Very cheap mass destruction. This function is intended to keep the sp cost related to the effectiveness.

Parameters:
casterWhat is casting the spell.
spell_typeSpell ID.
caster_levelLevel of caster. If -1, will use SK_level() to determine caster's level.
Returns:
Spell points cost.

Definition at line 1826 of file spell_util.c.

int SP_level_strength_adjust ( object caster,
int  spell_type 
)

Adjust the strength of the spell based on level.

Parameters:
casterWho is casting.
spell_typeSpell ID we're adjusting.
Returns:
Adjusted strength.

Definition at line 1794 of file spell_util.c.


Variable Documentation

archetype* spellarch[NROFREALSPELLS]

Array of pointers to archetypes used by the spells for quick access.

Definition at line 35 of file spell_util.c.