1 /***************************************************************************
2 * Copyright (C) 2011 by Andrey Afletdinov <fheroes2@gmail.com> *
3 * *
4 * Part of the Free Heroes2 Engine: *
5 * http://sourceforge.net/projects/fheroes2 *
6 * *
7 * This program is free software; you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation; either version 2 of the License, or *
10 * (at your option) any later version. *
11 * *
12 * This program is distributed in the hope that it will be useful, *
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15 * GNU General Public License for more details. *
16 * *
17 * You should have received a copy of the GNU General Public License *
18 * along with this program; if not, write to the *
19 * Free Software Foundation, Inc., *
20 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
21 ***************************************************************************/
22
23 #include <array>
24
25 #include "game.h"
26 #include "game_static.h"
27 #include "mp2.h"
28 #include "race.h"
29 #include "resource.h"
30 #include "save_format_version.h"
31 #include "serialize.h"
32 #include "skill.h"
33 #include "skill_static.h"
34
35 namespace Skill
36 {
37 stats_t _stats[] = { { "knight",
38 { 1, 1, 1, 1 },
39 { 2, 2, 1, 1 },
40 0,
41 0,
42 { 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0 },
43 10,
44 { 35, 45, 10, 10 },
45 { 25, 25, 25, 25 },
46 { 2, 4, 3, 1, 3, 5, 3, 1, 1, 2, 0, 3, 2, 2 } },
47 { "barbarian",
48 { 1, 1, 1, 1 },
49 { 3, 1, 1, 1 },
50 0,
51 0,
52 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0 },
53 10,
54 { 55, 35, 5, 5 },
55 { 30, 30, 20, 20 },
56 { 3, 3, 2, 1, 2, 3, 3, 2, 1, 3, 0, 4, 4, 1 } },
57 { "sorceress",
58 { 0, 0, 2, 2 },
59 { 0, 0, 2, 3 },
60 1,
61 15,
62 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 1 },
63 10,
64 { 10, 10, 30, 50 },
65 { 20, 20, 30, 30 },
66 { 3, 3, 2, 2, 2, 1, 2, 3, 3, 4, 0, 2, 1, 4 } },
67 { "warlock",
68 { 0, 0, 2, 2 },
69 { 0, 0, 3, 2 },
70 1,
71 19,
72 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 1 },
73 10,
74 { 10, 10, 50, 30 },
75 { 20, 20, 30, 30 },
76 { 1, 3, 2, 3, 2, 1, 2, 1, 3, 2, 1, 2, 4, 5 } },
77 { "wizard",
78 { 0, 0, 2, 2 },
79 { 0, 1, 2, 2 },
80 1,
81 17,
82 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2 },
83 10,
84 { 10, 10, 40, 40 },
85 { 20, 20, 30, 30 },
86 { 1, 3, 2, 3, 2, 2, 2, 2, 4, 2, 0, 2, 2, 5 } },
87 { "necromancer",
88 { 0, 0, 2, 2 },
89 { 1, 0, 2, 2 },
90 1,
91 10,
92 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1 },
93 10,
94 { 15, 15, 35, 35 },
95 { 25, 25, 25, 25 },
96 { 1, 3, 2, 3, 2, 0, 2, 1, 3, 2, 5, 3, 1, 4 } },
97 { nullptr,
98 { 0, 0, 0, 0 },
99 { 0, 0, 0, 0 },
100 0,
101 0,
102 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
103 10,
104 { 0, 0, 0, 0 },
105 { 0, 0, 0, 0 },
106 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } } };
107
108 values_t _values[] = {
109 { "pathfinding", { 25, 50, 100 } }, { "archery", { 10, 25, 50 } }, { "logistics", { 10, 20, 30 } }, { "scouting", { 1, 2, 3 } },
110 { "diplomacy", { 25, 50, 100 } }, { "navigation", { 33, 66, 100 } }, { "leadership", { 1, 2, 3 } }, { "wisdom", { 3, 4, 5 } },
111 { "mysticism", { 2, 3, 4 } }, { "luck", { 1, 2, 3 } }, { "ballistics", { 0, 0, 0 } }, { "eagleeye", { 20, 30, 40 } },
112 { "necromancy", { 10, 20, 30 } }, { "estates", { 100, 250, 500 } }, { nullptr, { 0, 0, 0 } },
113 };
114
115 secondary_t _from_witchs_hut = {
116 /* archery */ 1, /* ballistics */ 1, /* diplomacy */ 1, /* eagleeye */ 1,
117 /* estates */ 1, /* leadership */ 0, /* logistics */ 1, /* luck */ 1,
118 /* mysticism */ 1, /* navigation */ 1, /* necromancy*/ 0, /* pathfinding */ 1,
119 /* scouting */ 1, /* wisdom */ 1};
120 }
121
122 namespace GameStatic
123 {
124 u8 whirlpool_lost_percent = 50;
125
126 /* town, castle, heroes, artifact_telescope, object_observation_tower, object_magi_eyes */
127 std::array<uint8_t, 6> overview_distance = { 4, 5, 4, 1, 20, 9 };
128
129 u8 gameover_lost_days = 7;
130
131 // kingdom
132 u8 kingdom_max_heroes = 8;
133
134 // castle
135 u8 castle_grown_well = 2;
136 u8 castle_grown_wel2 = 8;
137 u8 castle_grown_week_of = 5;
138 u8 castle_grown_month_of = 100;
139
140 const uint32_t mageguild_restore_spell_points_day[5] = { 20, 40, 60, 80, 100 };
141
142 // heroes
143 u8 heroes_spell_points_day = 1;
144
145 // spells
146 u16 spell_dd_distance = 0;
147 u16 spell_dd_sp = 0;
148 u16 spell_dd_hp = 0;
149
150 // monsters
151 float monsterUpgradeRatio = 1.0f;
152
153 // visit objects mod: OBJ_BUOY, OBJ_OASIS, OBJ_WATERINGHOLE, OBJ_TEMPLE, OBJ_GRAVEYARD, OBJ_DERELICTSHIP,
154 // OBJ_SHIPWRECK, OBJ_MERMAID, OBJ_FAERIERING, OBJ_FOUNTAIN, OBJ_IDOL, OBJ_PYRAMID
155 int8_t objects_mod[] = {1, 1, 1, 2, -1, -1, -1, 1, 1, 1, 1, -2};
156
157 // world
158 u32 uniq = 0;
159 }
160
GetLostOnWhirlpoolPercent(void)161 u32 GameStatic::GetLostOnWhirlpoolPercent( void )
162 {
163 return whirlpool_lost_percent;
164 }
165
GetOverViewDistance(u32 d)166 u32 GameStatic::GetOverViewDistance( u32 d )
167 {
168 return d >= overview_distance.size() ? 0 : overview_distance[d];
169 }
170
GetGameOverLostDays(void)171 u32 GameStatic::GetGameOverLostDays( void )
172 {
173 return gameover_lost_days;
174 }
175
GetHeroesRestoreSpellPointsPerDay(void)176 u32 GameStatic::GetHeroesRestoreSpellPointsPerDay( void )
177 {
178 return heroes_spell_points_day;
179 }
180
GetMageGuildRestoreSpellPointsPercentDay(int level)181 u32 GameStatic::GetMageGuildRestoreSpellPointsPercentDay( int level )
182 {
183 return level && level < 6 ? mageguild_restore_spell_points_day[level - 1] : 0;
184 }
185
GetKingdomMaxHeroes(void)186 u32 GameStatic::GetKingdomMaxHeroes( void )
187 {
188 return kingdom_max_heroes;
189 }
190
GetCastleGrownWell(void)191 u32 GameStatic::GetCastleGrownWell( void )
192 {
193 return castle_grown_well;
194 }
195
GetCastleGrownWel2(void)196 u32 GameStatic::GetCastleGrownWel2( void )
197 {
198 return castle_grown_wel2;
199 }
200
GetCastleGrownWeekOf(void)201 u32 GameStatic::GetCastleGrownWeekOf( void )
202 {
203 return castle_grown_week_of;
204 }
205
GetCastleGrownMonthOf(void)206 u32 GameStatic::GetCastleGrownMonthOf( void )
207 {
208 return castle_grown_month_of;
209 }
210
ObjectVisitedModifiers(const MP2::MapObjectType objectType)211 s32 GameStatic::ObjectVisitedModifiers( const MP2::MapObjectType objectType )
212 {
213 switch ( objectType ) {
214 case MP2::OBJ_BUOY:
215 return objects_mod[0];
216 case MP2::OBJ_OASIS:
217 return objects_mod[1];
218 case MP2::OBJ_WATERINGHOLE:
219 return objects_mod[2];
220 case MP2::OBJ_TEMPLE:
221 return objects_mod[3];
222 case MP2::OBJ_GRAVEYARD:
223 return objects_mod[4];
224 case MP2::OBJ_DERELICTSHIP:
225 return objects_mod[5];
226 case MP2::OBJ_SHIPWRECK:
227 return objects_mod[6];
228 case MP2::OBJ_MERMAID:
229 return objects_mod[7];
230 case MP2::OBJ_FAERIERING:
231 return objects_mod[8];
232 case MP2::OBJ_FOUNTAIN:
233 return objects_mod[9];
234 case MP2::OBJ_IDOL:
235 return objects_mod[10];
236 case MP2::OBJ_PYRAMID:
237 return objects_mod[11];
238 default:
239 break;
240 }
241
242 return 0;
243 }
244
GetSkillStats(int race)245 const Skill::stats_t * GameStatic::GetSkillStats( int race )
246 {
247 switch ( race ) {
248 case Race::KNGT:
249 return &Skill::_stats[0];
250 case Race::BARB:
251 return &Skill::_stats[1];
252 case Race::SORC:
253 return &Skill::_stats[2];
254 case Race::WRLK:
255 return &Skill::_stats[3];
256 case Race::WZRD:
257 return &Skill::_stats[4];
258 case Race::NECR:
259 return &Skill::_stats[5];
260 default:
261 break;
262 }
263
264 return nullptr;
265 }
266
GetSkillValues(int type)267 const Skill::values_t * GameStatic::GetSkillValues( int type )
268 {
269 switch ( type ) {
270 case Skill::Secondary::PATHFINDING:
271 return &Skill::_values[0];
272 case Skill::Secondary::ARCHERY:
273 return &Skill::_values[1];
274 case Skill::Secondary::LOGISTICS:
275 return &Skill::_values[2];
276 case Skill::Secondary::SCOUTING:
277 return &Skill::_values[3];
278 case Skill::Secondary::DIPLOMACY:
279 return &Skill::_values[4];
280 case Skill::Secondary::NAVIGATION:
281 return &Skill::_values[5];
282 case Skill::Secondary::LEADERSHIP:
283 return &Skill::_values[6];
284 case Skill::Secondary::WISDOM:
285 return &Skill::_values[7];
286 case Skill::Secondary::MYSTICISM:
287 return &Skill::_values[8];
288 case Skill::Secondary::LUCK:
289 return &Skill::_values[9];
290 case Skill::Secondary::BALLISTICS:
291 return &Skill::_values[10];
292 case Skill::Secondary::EAGLEEYE:
293 return &Skill::_values[11];
294 case Skill::Secondary::NECROMANCY:
295 return &Skill::_values[12];
296 case Skill::Secondary::ESTATES:
297 return &Skill::_values[13];
298 default:
299 break;
300 }
301
302 return nullptr;
303 }
304
GetSkillForWitchsHut(void)305 const Skill::secondary_t * GameStatic::GetSkillForWitchsHut( void )
306 {
307 return &Skill::_from_witchs_hut;
308 }
309
GetBattleMoatReduceDefense(void)310 int GameStatic::GetBattleMoatReduceDefense( void )
311 {
312 return 3;
313 }
314