Crossfire Server, Trunk
power_crystal.c File Reference
#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)
 
static int crystal_level (const object *op, int sp)
 
void init_type_power_crystal (void)
 
static void power_crystal_describe (const object *op, const object *observer, int use_media_tags, char *buf, size_t size)
 
static method_ret power_crystal_type_apply (object *op, object *applier, int aflags)
 

Variables

static const char * crystal_levels [LEVELS]
 

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

◆ LEVELS

#define LEVELS   7

Definition at line 37 of file power_crystal.c.

Function Documentation

◆ add_capacity()

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 buf, crystal_level(), crystal_levels, replace::current, LEVELS, give::op, say::previous, 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:

◆ crystal_level()

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 if(), and give::op.

Referenced by add_capacity().

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

◆ init_type_power_crystal()

void init_type_power_crystal ( void  )

Initializer for the POWER_CRYSTAL object type.

Definition at line 134 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:

◆ power_crystal_describe()

static void power_crystal_describe ( const object op,
const object observer,
int  use_media_tags,
char *  buf,
size_t  size 
)
static

Definition at line 99 of file power_crystal.c.

References add_capacity(), buf, give::op, query_name(), stringbuffer_append_printf(), stringbuffer_append_string(), stringbuffer_finish(), stringbuffer_new(), and nlohmann::detail::void().

Referenced by init_type_power_crystal().

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

◆ power_crystal_type_apply()

static method_ret power_crystal_type_apply ( 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
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 149 of file power_crystal.c.

References add_capacity(), draw_ext_info(), esrv_update_item(), MAX_BUF, liv::maxsp, diamondslots::message, METHOD_OK, MIN, MSG_TYPE_APPLY, MSG_TYPE_APPLY_SUCCESS, give::name, NDI_UNIQUE, object_update_speed(), give::op, PLAYER, query_name(), liv::sp, obj::stats, stringbuffer_append_printf(), stringbuffer_append_string(), stringbuffer_finish(), stringbuffer_new(), obj::type, UPD_ANIMSPEED, and nlohmann::detail::void().

Referenced by init_type_power_crystal().

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

Variable Documentation

◆ crystal_levels

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().