summaryrefslogtreecommitdiff
path: root/src/map/refine.h
blob: 05ab0f076431f34bf404468fbba63de67db83c90 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/**
* This file is part of Hercules.
* http://herc.ws - http://github.com/HerculesWS/Hercules
*
* Copyright (C) 2019  Hercules Dev Team
*
* Hercules is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef MAP_REFINE_H
#define MAP_REFINE_H

/** @file
 * Refine Interface.
 **/
#include "common/hercules.h"

/* Defines */
/**
* Max Refine available to your server
* Changing this limit requires edits to refine_db.conf
**/
#ifdef RENEWAL
	#define MAX_REFINE 20
#else
	#define MAX_REFINE 10
#endif

/* Forward Declarations */
struct refine_interface_private;

/* Enums */
enum refine_type {
	REFINE_TYPE_ARMOR   = 0,
	REFINE_TYPE_WEAPON1 = 1,
	REFINE_TYPE_WEAPON2 = 2,
	REFINE_TYPE_WEAPON3 = 3,
	REFINE_TYPE_WEAPON4 = 4,
#ifndef REFINE_TYPE_MAX
	REFINE_TYPE_MAX     = 5
#endif
};

enum refine_chance_type {
	REFINE_CHANCE_TYPE_NORMAL     = 0, // Normal Chance
	REFINE_CHANCE_TYPE_ENRICHED   = 1, // Enriched Ore Chance
	REFINE_CHANCE_TYPE_E_NORMAL   = 2, // Event Normal Ore Chance
	REFINE_CHANCE_TYPE_E_ENRICHED = 3, // Event Enriched Ore Chance
	REFINE_CHANCE_TYPE_MAX
};

/* Structures */
struct s_refine_info {
	int chance[REFINE_CHANCE_TYPE_MAX][MAX_REFINE]; // success chance
	int bonus[MAX_REFINE];                          // cumulative fixed bonus damage
	int randombonus_max[MAX_REFINE];                // cumulative maximum random bonus damage
};

struct refine_interface_dbs {
	struct s_refine_info refine_info[REFINE_TYPE_MAX];
};

/**
 * Refine Interface
 **/
struct refine_interface {
	struct refine_interface_private *p;
	struct refine_interface_dbs *dbs;

	/**
	 * Initialize refine system
	 * @param minimal sets refine system to minimal mode in which it won't load or initialize itself
	 * @return returns 0 in-case of success 1 otherwise
	 **/
	int (*init)(bool minimal);

	/**
	 * Finalize refine system
	 **/
	void (*final)(void);

	/**
	 * Get the chance to upgrade a piece of equipment.
	 * @param wlv The weapon type of the item to refine (see see enum refine_type)
	 * @param refine The target refine level
	 * @return The chance to refine the item, in percent (0~100)
	 **/
	int (*get_refine_chance) (enum refine_type wlv, int refine_level, enum refine_chance_type type);

	/**
	 * Gets the attack/deffense bonus for the given equipment type and refine level
	 * @param equipment_type the equipment type
	 * @param refine_level the equipment refine level
	 * @return returns the bonus from refine db
	 **/
	int (*get_bonus) (enum refine_type equipment_type, int refine_level);

	/**
	* Gets the maximum attack/deffense random bonus for the given equipment type and refine level
	* @param equipment_type the equipment type
	* @param refine_level the equipment refine level
	* @return returns the bonus from refine db
	**/
	int(*get_randombonus_max) (enum refine_type equipment_type, int refine_level);
};

#ifdef HERCULES_CORE
void refine_defaults(void);
#endif

HPShared struct refine_interface *refine;
#endif