Atrinik Server  4.0
Macros | Functions | Variables
process_treasure.c File Reference
#include <global.h>
#include <object.h>
#include "process_treasure.h"

Go to the source code of this file.

Macros

#define JEWELRY_MAX_LEVEL   100
 
#define DIFFICULTY_BONUS_ROLLS   40
 
#define DIFFICULTY_BONUS_CHANCE   5
 
#define MAX_BONUS_TRIES   100
 

Functions

static int jewelry_set_bonus_max_hpsp (object *op, int difficulty, treasure_affinity_t *affinity, double *item_power, int bonus, double diff_scale)
 
static bool jewelry_set_bonus_maxhp (object *op, int difficulty, treasure_affinity_t *affinity, double *item_power, int bonus)
 
static bool jewelry_set_bonus_maxsp (object *op, int difficulty, treasure_affinity_t *affinity, double *item_power, int bonus)
 
static bool jewelry_set_bonus_ac (object *op, int difficulty, treasure_affinity_t *affinity, double *item_power, int bonus)
 
static bool jewelry_set_bonus_wc (object *op, int difficulty, treasure_affinity_t *affinity, double *item_power, int bonus)
 
static bool jewelry_set_bonus_protect (object *op, int difficulty, treasure_affinity_t *affinity, double *item_power, int bonus)
 
bool process_treasure_is_special (object *op)
 
uint32_t process_treasure_table_total_chance (const process_treasure_table_t *table, size_t table_size)
 
static int process_treasure_get_jewelry_bonus (int difficulty)
 
static bool process_treasure_table_set_bonus (const process_treasure_table_t *entry, object *op, int difficulty, treasure_affinity_t *affinity, double *item_power, int bonus)
 
bool process_treasure_table (const process_treasure_table_t *table, size_t table_size, uint32_t total_chance, object *op, int difficulty, treasure_affinity_t *affinity, double *item_power)
 
bool process_treasure_table_jewelry (object *op, int difficulty, treasure_affinity_t *affinity, double *item_power)
 
void process_treasure_set_item_power (object *op, double item_power)
 

Variables

static const
process_treasure_table_t 
jewelry_treasure_table []
 

Detailed Description

Common treasure processing functions.

Author
Alex Tokar

Definition in file process_treasure.c.

Macro Definition Documentation

#define JEWELRY_MAX_LEVEL   100

Maximum level for jewelry items.

Definition at line 40 of file process_treasure.c.

Function Documentation

static bool jewelry_set_bonus_ac ( object op,
int  difficulty,
treasure_affinity_t *  affinity,
double *  item_power,
int  bonus 
)
static

Function for setting a bonus for the specified bonus type.

Parameters
opObject.
difficultyDifficulty level.
affinityTreasure affinity.
[out]item_powerItem power adjustment.
bonusBonus value.
Returns
Whether a bonus was applied.

Definition at line 134 of file process_treasure.c.

static int jewelry_set_bonus_max_hpsp ( object op,
int  difficulty,
treasure_affinity_t *  affinity,
double *  item_power,
int  bonus,
double  diff_scale 
)
static

Set bonus max HP/SP.

Parameters
opObject.
difficultyDifficulty level.
affinityTreasure affinity.
[out]item_powerItem power.
bonusBonus.
diff_scaleDifficulty scaling.
Returns
Max HP/SP to set on the object.

Definition at line 61 of file process_treasure.c.

static bool jewelry_set_bonus_maxhp ( object op,
int  difficulty,
treasure_affinity_t *  affinity,
double *  item_power,
int  bonus 
)
static

Function for setting a bonus for the specified bonus type.

Parameters
opObject.
difficultyDifficulty level.
affinityTreasure affinity.
[out]item_powerItem power adjustment.
bonusBonus value.
Returns
Whether a bonus was applied.

Definition at line 94 of file process_treasure.c.

static bool jewelry_set_bonus_maxsp ( object op,
int  difficulty,
treasure_affinity_t *  affinity,
double *  item_power,
int  bonus 
)
static

Function for setting a bonus for the specified bonus type.

Parameters
opObject.
difficultyDifficulty level.
affinityTreasure affinity.
[out]item_powerItem power adjustment.
bonusBonus value.
Returns
Whether a bonus was applied.

Definition at line 114 of file process_treasure.c.

static bool jewelry_set_bonus_protect ( object op,
int  difficulty,
treasure_affinity_t *  affinity,
double *  item_power,
int  bonus 
)
static

Function for setting a bonus for the specified bonus type.

Parameters
opObject.
difficultyDifficulty level.
affinityTreasure affinity.
[out]item_powerItem power adjustment.
bonusBonus value.
Returns
Whether a bonus was applied.

Definition at line 190 of file process_treasure.c.

static bool jewelry_set_bonus_wc ( object op,
int  difficulty,
treasure_affinity_t *  affinity,
double *  item_power,
int  bonus 
)
static

Function for setting a bonus for the specified bonus type.

Parameters
opObject.
difficultyDifficulty level.
affinityTreasure affinity.
[out]item_powerItem power adjustment.
bonusBonus value.
Returns
Whether a bonus was applied.

Definition at line 162 of file process_treasure.c.

static int process_treasure_get_jewelry_bonus ( int  difficulty)
static

Get a jewelry bonus depending on the specified difficulty. The higher the difficulty, the higher the chance to get a high bonus.

Parameters
difficultyDifficulty level.
Returns
Bonus.

Definition at line 308 of file process_treasure.c.

bool process_treasure_is_special ( object op)

Checks if the specified treasure is already a special item.

Parameters
opObject to check.
Returns
True if the object is a special item, false otherwise.

Definition at line 258 of file process_treasure.c.

void process_treasure_set_item_power ( object op,
double  item_power 
)

Set calculated item power on the specified object.

Parameters
opObject.
item_powerItem power to set.

Definition at line 522 of file process_treasure.c.

bool process_treasure_table ( const process_treasure_table_t table,
size_t  table_size,
uint32_t  total_chance,
object op,
int  difficulty,
treasure_affinity_t *  affinity,
double *  item_power 
)

Process a specific treasure table and apply a single bonus from it to the specified item.

Parameters
tableTable to process.
table_sizeSize of the table.
total_chanceTotal chance of the specified table.
opObject to apply the bonus to.
difficultyDifficulty level.
affinityTreasure affinity.
[out]item_powerItem power adjustment. Make sure this value is initialized to something sane.
Returns
True if a bonus was applied, false otherwise.

Definition at line 408 of file process_treasure.c.

bool process_treasure_table_jewelry ( object op,
int  difficulty,
treasure_affinity_t *  affinity,
double *  item_power 
)

Process the jewelry treasure table and apply a single bonus from it to the specified item.

Parameters
opObject to apply the bonus to.
difficultyDifficulty level.
affinityTreasure affinity.
[out]item_powerItem power adjustment. Make sure this value is initialized to something sane.
Returns
True if a bonus was applied, false otherwise.

Definition at line 493 of file process_treasure.c.

static bool process_treasure_table_set_bonus ( const process_treasure_table_t entry,
object op,
int  difficulty,
treasure_affinity_t *  affinity,
double *  item_power,
int  bonus 
)
static

Process a treasure table bonus and set it on the specified item.

Parameters
entryTable bonus entry to process.
opObject to set the bonus on.
difficultyDifficulty level.
affinityTreasure affinity.
[out]item_powerItem power adjustment.
bonusBonus value to apply.
Returns
Whether a bonus was applied.

Definition at line 353 of file process_treasure.c.

uint32_t process_treasure_table_total_chance ( const process_treasure_table_t table,
size_t  table_size 
)

Calculate the total chance of the specified treasure table.

Parameters
tableTable.
table_sizeNumber of elements in the table.
Returns
Total table chance.

Definition at line 281 of file process_treasure.c.

Variable Documentation

const process_treasure_table_t jewelry_treasure_table[]
static
Initial value:
= {
}
static bool jewelry_set_bonus_wc(object *op, int difficulty, treasure_affinity_t *affinity, double *item_power, int bonus)
static bool jewelry_set_bonus_ac(object *op, int difficulty, treasure_affinity_t *affinity, double *item_power, int bonus)
static bool jewelry_set_bonus_protect(object *op, int difficulty, treasure_affinity_t *affinity, double *item_power, int bonus)
static bool jewelry_set_bonus_maxhp(object *op, int difficulty, treasure_affinity_t *affinity, double *item_power, int bonus)
static bool jewelry_set_bonus_maxsp(object *op, int difficulty, treasure_affinity_t *affinity, double *item_power, int bonus)

The common jewelry treasure table.

Definition at line 241 of file process_treasure.c.