Atrinik Server 2.5
Functions
server/apply.c File Reference
#include <global.h>
#include <math.h>

Go to the source code of this file.

Functions

static int is_legal_2ways_exit (object *op, object *exit)
void move_apply (object *trap, object *victim, object *originator, int flags)
objectfind_special_prayer_mark (object *op, int spell)
static void insert_special_prayer_mark (object *op, int spell)
void do_learn_spell (object *op, int spell, int special_prayer)
void do_forget_spell (object *op, int spell)
int manual_apply (object *op, object *tmp, int aflag)
int player_apply (object *pl, object *op, int aflag, int quiet)
void player_apply_below (object *pl)
static int apply_check_item_power (object *who, const object *op)
int apply_special (object *who, object *op, int aflags)
int monster_apply_special (object *who, object *op, int aflags)

Detailed Description

Handles objects being applied, and their effect.

Definition in file apply.c.


Function Documentation

static int apply_check_item_power ( object who,
const object op 
) [static]

Checks for item power restrictions when applying an item.

Parameters:
whoThe object applying the item.
opThe item being applied.
Returns:
Whether applying is possible.

Definition at line 1041 of file apply.c.

int apply_special ( object who,
object op,
int  aflags 
)

Apply an object.

This function doesn't check for unpaid items, but checks other restrictions.

Usage example: apply_special(who, op, AP_UNAPPLY | AP_IGNORE_CURSE)

Parameters:
whoObject using op. It can be a monster.
opObject being used. Should be an equipment type item, eg, one which you put on and keep on for a while, and not something like a potion or scroll.
aflagsFlags.
Returns:
1 if the action could not be completed, 0 on success.

Definition at line 1071 of file apply.c.

void do_forget_spell ( object op,
int  spell 
)

Make player forget a spell.

Parameters:
opPlayer object to make forget the spell.
spellID of the spell.

Definition at line 428 of file apply.c.

void do_learn_spell ( object op,
int  spell,
int  special_prayer 
)

Make player learn a new spell.

Parameters:
opThe player object learning the new spell.
spellSpell ID.
special_prayerIs this a special prayer?

Definition at line 373 of file apply.c.

object* find_special_prayer_mark ( object op,
int  spell 
)

Find a special prayer marker in object's inventory.

Special prayers are granted by gods and lost when the follower decides to pray to different gods. 'Force' objects keep track of which prayers are special.

Parameters:
opObject to search in.
spellSpell ID to find.
Returns:
The marker object, NULL if not found.

Definition at line 339 of file apply.c.

static void insert_special_prayer_mark ( object op,
int  spell 
) [static]

Insert a special prayer marker inside an object.

Parameters:
opThe object to insert the marker to.
spellThe spell (prayer) ID.

Definition at line 358 of file apply.c.

static int is_legal_2ways_exit ( object op,
object exit_ob 
) [static]

This function return true if the exit is not a two ways one or it is two ways, valid exit.

A valid two way exit means:

  • You can come back (there is another exit on the other side)
  • You are
    • The owner of the exit
    • Or in the same party as the owner
      Note:
      An owner in a two way exit is saved as the owner's name in the field exit->name cause the field exit->owner doesn't survive in the swapping (in fact the whole exit doesn't survive).
      Parameters:
      opPlayer to check for.
      exit_obExit object.
      Returns:
      1 if exit is not two way, 0 otherwise.

Definition at line 483 of file apply.c.

int manual_apply ( object op,
object tmp,
int  aflag 
)

Main apply handler.

Checks for unpaid items before applying.

Parameters:
opobject causing tmp to be applied.
tmpobject being applied.
aflagSpecial (always apply/unapply) flags. Nothing is done with them in this function - they are passed to apply_special().
Return values:
0Player or monster can't apply objects of that type.
1Has been applied, or there was an error applying the object.
2Objects of that type can't be applied if not in inventory.

Definition at line 606 of file apply.c.

int monster_apply_special ( object who,
object op,
int  aflags 
)

Monster applies an item.

Parameters:
whoThe monster.
opThe object to apply.
aflagsApply flags.
Returns:
1 if the action could not be completed, 0 on success.
See also:
apply_special()

Definition at line 1494 of file apply.c.

void move_apply ( object trap,
object victim,
object originator,
int  flags 
)

'victim' moves onto 'trap' (trap has FLAG_WALK_ON or FLAG_FLY_ON set) or 'victim' leaves 'trap' (trap has FLAG_WALK_OFF or FLAG_FLY_OFF) set.

I added the flags parameter to give the single events more information about whats going on:

Most important is the "MOVE_APPLY_VANISHED" flag. If set, a object has left a tile but "vanished" and not moved (perhaps it exploded or something). This means that some events are not triggered like trapdoors or teleporter traps for example which have a "FLY/MOVE_OFF" set. This will avoid that they touch invalid objects.

Parameters:
trapObject victim moved on.
victimThe object that moved on trap.
originatorPlayer, monster or other object that caused 'victim' to move onto 'trap'. Will receive messages caused by this action. May be NULL, however, some types of traps require an originator to function.
flagsFlags.

Definition at line 56 of file apply.c.

int player_apply ( object pl,
object op,
int  aflag,
int  quiet 
)

Living thing is applying an object.

Parameters:
plobject causing op to be applied.
opobject being applied.
aflagSpecial (always apply/unapply) flags. Nothing is done with them in this function - they are passed to apply_special().
quietIf 1, suppresses the "don't know how to apply" and "you must get it first" messages as needed by player_apply_below(). There can still be "but you are floating high above the ground" messages.
Return values:
0Player or monster can't apply objects of that type.
1Has been applied, or there was an error applying the object.
2Objects of that type can't be applied if not in inventory.

Definition at line 941 of file apply.c.

void player_apply_below ( object pl)

Attempt to apply the object 'below' the player.

If the player has an open container, we use that for below, otherwise we use the ground.

Parameters:
plPlayer.

Definition at line 988 of file apply.c.