vocation.h

main 140 lines · 3.3 KB Raw
Alex Alex Commit Server upload 18/10/2026 23:38
1/**
2 * The Forgotten Server - a free and open-source MMORPG server emulator
3 * Copyright (C) 2019 Mark Samman <mark.samman@gmail.com>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19
20#ifndef FS_VOCATION_H_ADCAA356C0DB44CEBA994A0D678EC92D
21#define FS_VOCATION_H_ADCAA356C0DB44CEBA994A0D678EC92D
22
23#include "enums.h"
24#include "item.h"
25
26class Vocation
27{
28 public:
29 explicit Vocation(uint16_t id) : id(id) {}
30
31 const std::string& getVocName() const {
32 return name;
33 }
34 const std::string& getVocDescription() const {
35 return description;
36 }
37 uint64_t getReqSkillTries(uint8_t skill, uint16_t level);
38 uint64_t getReqMana(uint32_t magLevel);
39
40 uint16_t getId() const {
41 return id;
42 }
43
44 uint8_t getClientId() const {
45 return clientId;
46 }
47
48 uint32_t getHPGain() const {
49 return gainHP;
50 }
51 uint32_t getManaGain() const {
52 return gainMana;
53 }
54 uint32_t getCapGain() const {
55 return gainCap;
56 }
57
58 uint32_t getManaGainTicks() const {
59 return gainManaTicks;
60 }
61 uint32_t getManaGainAmount() const {
62 return gainManaAmount;
63 }
64 uint32_t getHealthGainTicks() const {
65 return gainHealthTicks;
66 }
67 uint32_t getHealthGainAmount() const {
68 return gainHealthAmount;
69 }
70
71 uint8_t getSoulMax() const {
72 return soulMax;
73 }
74 uint16_t getSoulGainTicks() const {
75 return gainSoulTicks;
76 }
77
78 uint32_t getAttackSpeed() const {
79 return attackSpeed;
80 }
81 uint32_t getBaseSpeed() const {
82 return baseSpeed;
83 }
84
85 uint32_t getFromVocation() const {
86 return fromVocation;
87 }
88
89 float meleeDamageMultiplier = 1.0f;
90 float distDamageMultiplier = 1.0f;
91 float defenseMultiplier = 1.0f;
92 float armorMultiplier = 1.0f;
93
94 private:
95 friend class Vocations;
96
97 std::map<uint32_t, uint64_t> cacheMana;
98 std::map<uint32_t, uint32_t> cacheSkill[SKILL_LAST + 1];
99
100 std::string name = "none";
101 std::string description;
102
103 float skillMultipliers[SKILL_LAST + 1] = {1.5f, 2.0f, 2.0f, 2.0f, 2.0f, 1.5f, 1.1f};
104 float manaMultiplier = 4.0f;
105
106 uint32_t gainHealthTicks = 6;
107 uint32_t gainHealthAmount = 1;
108 uint32_t gainManaTicks = 6;
109 uint32_t gainManaAmount = 1;
110 uint32_t gainCap = 500;
111 uint32_t gainMana = 5;
112 uint32_t gainHP = 5;
113 uint32_t fromVocation = VOCATION_NONE;
114 uint32_t attackSpeed = 1500;
115 uint32_t baseSpeed = 220;
116 uint16_t id;
117
118 uint16_t gainSoulTicks = 120;
119
120 uint8_t soulMax = 100;
121 uint8_t clientId = 0;
122
123 static uint32_t skillBase[SKILL_LAST + 1];
124};
125
126class Vocations
127{
128 public:
129 bool loadFromXml();
130
131 Vocation* getVocation(uint16_t id);
132 int32_t getVocationId(const std::string& name) const;
133 uint16_t getPromotedVocation(uint16_t vocationId) const;
134
135 private:
136 std::map<uint16_t, Vocation> vocationsMap;
137};
138
139#endif
140
Top