Crossfire Server, Trunk  R20513
Macros | Functions | Variables
power_crystal.c File Reference

The implementation of a Power Crystal. More...

#include <global.h>
#include <ob_methods.h>
#include <ob_types.h>
#include <sproto.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
Include dependency graph for power_crystal.c:

Go to the source code of this file.

Macros

#define LEVELS   7
 

Functions

static void add_capacity (const object *op, StringBuffer *buf, int previous_sp)
 Add the capacity of the crystal to the buffer. More...
 
static int crystal_level (const object *op, int sp)
 Return the level, [0..LEVELS[, of charge of the item. More...
 
void init_type_power_crystal (void)
 Initializer for the POWER_CRYSTAL object type. More...
 
static void power_crystal_describe (const ob_methods *context, const object *op, const object *observer, char *buf, size_t size)
 
static method_ret power_crystal_type_apply (ob_methods *context, object *op, object *applier, int aflags)
 This function handles the application of power crystals. More...
 

Variables

static const char * crystal_levels [LEVELS]
 Existing levels, dot-terminated. More...
 

Detailed Description

The implementation of a Power Crystal.

A Power Crystal can store mana from a player, and give it back when needed.

Definition in file power_crystal.c.

Macro Definition Documentation

#define LEVELS   7

Definition at line 37 of file power_crystal.c.

Referenced by add_capacity().

Function Documentation

static void add_capacity ( const object op,
StringBuffer buf,
int  previous_sp 
)
static

Add the capacity of the crystal to the buffer.

Sentence will be dot-terminated.

Parameters
opcrystal to add the capacity of.
bufwhere to put the capacity.
previous_spif -1 then ignored, else previous sp of the crystal to add 'still ' or 'now ' to the message to signal level changes.

Definition at line 81 of file power_crystal.c.

References crystal_level(), crystal_levels, LEVELS, liv::sp, obj::stats, and stringbuffer_append_string().

Referenced by power_crystal_describe(), and power_crystal_type_apply().

Here is the call graph for this function:

Here is the caller graph for this function:

static int crystal_level ( const object op,
int  sp 
)
static

Return the level, [0..LEVELS[, of charge of the item.

Parameters
opcrystal to get the level of, only for the maxsp.
spsp value to get the level for.
Returns
level.

Definition at line 56 of file power_crystal.c.

References liv::maxsp, and obj::stats.

Referenced by add_capacity().

Here is the caller graph for this function:

void init_type_power_crystal ( void  )

Initializer for the POWER_CRYSTAL object type.

Definition at line 131 of file power_crystal.c.

References POWER_CRYSTAL, power_crystal_describe(), power_crystal_type_apply(), register_apply(), and register_describe().

Referenced by register_all_ob_types().

Here is the call graph for this function:

Here is the caller graph for this function:

static void power_crystal_describe ( const ob_methods context,
const object op,
const object observer,
char *  buf,
size_t  size 
)
static

Definition at line 99 of file power_crystal.c.

References add_capacity(), liv::maxsp, query_name(), obj::stats, stringbuffer_append_printf(), stringbuffer_finish(), and stringbuffer_new().

Referenced by init_type_power_crystal().

Here is the call graph for this function:

Here is the caller graph for this function:

static method_ret power_crystal_type_apply ( ob_methods context,
object op,
object applier,
int  aflags 
)
static

This function handles the application of power crystals.

Power crystals, when applied, either suck power from the applier, if he's at full spellpoints, or gives him power, if it's got spellpoins stored.

Parameters
contextThe method context
opThe power crystal to apply
applierThe object applying the crystal
aflagsSpecial flags (always apply/unapply)
Returns
The return value is always METHOD_OK

Definition at line 147 of file power_crystal.c.

References add_capacity(), draw_ext_info(), esrv_update_item(), MAX_BUF, liv::maxsp, METHOD_OK, MIN, MSG_TYPE_APPLY, MSG_TYPE_APPLY_SUCCESS, treasureliststruct::name, NDI_UNIQUE, object_update_speed(), PLAYER, query_name(), liv::sp, obj::speed, obj::stats, stringbuffer_append_printf(), stringbuffer_append_string(), stringbuffer_finish(), stringbuffer_new(), obj::type, and UPD_ANIMSPEED.

Referenced by init_type_power_crystal().

Here is the call graph for this function:

Here is the caller graph for this function:

Variable Documentation

const char* crystal_levels[LEVELS]
static
Initial value:
= {
"empty.",
"almost empty.",
"partially filled.",
"half full.",
"well charged.",
"almost full.",
"fully charged.",
}

Existing levels, dot-terminated.

Definition at line 40 of file power_crystal.c.

Referenced by add_capacity().