Atrinik Server  4.0
Macros | Functions
artifact.c File Reference
#include <global.h>
#include <loader.h>
#include <toolkit/string.h>
#include <arch.h>
#include <artifact.h>

Go to the source code of this file.

Macros

#define ARTIFACT_TRIES   2
 

Functions

static void artifact_list_free (artifact_list_t *al)
 
static void artifact_load (void)
 
void artifact_init (void)
 
void artifact_deinit (void)
 
static artifact_tartifact_new (void)
 
static void artifact_free (artifact_t *art)
 
static artifact_list_tartifact_list_new (void)
 
artifact_list_tartifact_list_find (uint8_t type)
 
artifact_tartifact_find_type (const char *name, uint8_t type)
 
void artifact_change_object (artifact_t *art, object *op)
 
static bool artifact_can_combine (artifact_t *art, object *op, int difficulty, treasure_affinity_t *affinity)
 
bool artifact_generate (object *op, int difficulty, treasure_affinity_t *affinity)
 

Detailed Description

Everything concerning artifacts.

Definition in file artifact.c.

Macro Definition Documentation

#define ARTIFACT_TRIES   2

How many times to try to generate an artifact from an artifact list.

Definition at line 41 of file artifact.c.

Function Documentation

static bool artifact_can_combine ( artifact_t art,
object op,
int  difficulty,
treasure_affinity_t *  affinity 
)
static

Checks if op can be combined with art, depending on 'Allowed xxx' from the artifacts file (stored in artifact::allowed), the difficulty, etc.

Parameters
artArtifact.
opThe object to check.
difficultyDifficulty.
affinityTreasure affinity to check.
Returns
Whether the object can be combined with the artifact.

Definition at line 489 of file artifact.c.

void artifact_change_object ( artifact_t art,
object op 
)

Fixes the given object, giving it the abilities and titles it should have due to the artifact template.

Parameters
artThe artifact.
opThe object to change.

Definition at line 446 of file artifact.c.

void artifact_deinit ( void  )

Deinitializes artifacts code.

Definition at line 60 of file artifact.c.

artifact_t* artifact_find_type ( const char *  name,
uint8_t  type 
)

Find an artifact by its name and type (as there are several lists of artifacts, depending on their types).

Parameters
nameName of the artifact to find.
typeType of the artifact to find.
Returns
The artifact if found, NULL otherwise.

Definition at line 419 of file artifact.c.

static void artifact_free ( artifact_t art)
static

Frees an artifact structures.

Parameters
artArtifact to free.

Definition at line 84 of file artifact.c.

bool artifact_generate ( object op,
int  difficulty,
treasure_affinity_t *  affinity 
)

Decides randomly which artifact the object should be turned into. Makes sure that the item can become that artifact (means magic, difficulty, and Allowed fields properly). Then calls artifact_change_object() in order to actually create the artifact.

Parameters
opObject.
difficultyDifficulty.
affinityTreasure affinity.
Returns
Whether the object was turned into an artifact.

Definition at line 541 of file artifact.c.

void artifact_init ( void  )

Initializes artifacts code.

Definition at line 51 of file artifact.c.

artifact_list_t* artifact_list_find ( uint8_t  type)

Searches the artifact lists and returns one that has the same type of objects on it.

Parameters
typeType to search for.
Returns
NULL if no suitable list found.

Definition at line 397 of file artifact.c.

static void artifact_list_free ( artifact_list_t al)
static

Frees the specified artifact list, its artifacts, and all linked artifact lists.

Parameters
alArtifact list.

Definition at line 120 of file artifact.c.

static artifact_list_t* artifact_list_new ( void  )
static

Allocate and return the pointer to an empty artifact_list_t structure.

Returns
New structure.

Definition at line 108 of file artifact.c.

void artifact_load ( void  )
static

Builds up the lists of artifacts from the file in the libpath.

Definition at line 133 of file artifact.c.

static artifact_t* artifact_new ( void  )
static

Allocate and return the pointer to an empty artifact structure.

Returns
New structure.

Definition at line 73 of file artifact.c.