Skip to content

Commit 8ce9ce8

Browse files
committed
Add Custom Skill
1 parent be974ca commit 8ce9ce8

File tree

13 files changed

+430
-14
lines changed

13 files changed

+430
-14
lines changed

prboom2/src/dsda/configuration.c

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
#include "dsda/exhud.h"
3838
#include "dsda/features.h"
3939
#include "dsda/input.h"
40+
#include "dsda/skill_info.h"
4041
#include "dsda/stretch.h"
4142
#include "dsda/utility.h"
4243

@@ -1007,6 +1008,70 @@ dsda_config_t dsda_config[dsda_config_count] = {
10071008
"dsda_coop_spawns", dsda_config_coop_spawns,
10081009
CONF_BOOL(0), NULL, NOT_STRICT, dsda_AlterGameFlags
10091010
},
1011+
[dsda_config_skill_spawn_filter] = {
1012+
"dsda_skill_spawn_filter", dsda_config_skill_spawn_filter,
1013+
dsda_config_int, 0, 2, { 1 }, &cskill_spawn_filter
1014+
},
1015+
[dsda_config_skill_coop_spawns] = {
1016+
"dsda_skill_coop_spawns", dsda_config_skill_coop_spawns,
1017+
CONF_BOOL(0), &cskill_coop_spawns
1018+
},
1019+
[dsda_config_skill_ammo_factor] = {
1020+
"dsda_skill_ammo_factor", dsda_config_skill_ammo_factor,
1021+
dsda_config_int, 0, 4, { 1 }, &cskill_ammo_factor
1022+
},
1023+
[dsda_config_skill_damage_factor] = {
1024+
"dsda_skill_damage_factor", dsda_config_skill_damage_factor,
1025+
dsda_config_int, 0, 4, { 1 }, &cskill_damage_factor
1026+
},
1027+
[dsda_config_skill_armor_factor] = {
1028+
"dsda_skill_armor_factor", dsda_config_skill_armor_factor,
1029+
dsda_config_int, 0, 4, { 1 }, &cskill_armor_factor
1030+
},
1031+
[dsda_config_skill_health_factor] = {
1032+
"dsda_skill_health_factor", dsda_config_skill_health_factor,
1033+
dsda_config_int, 0, 4, { 1 }, &cskill_health_factor
1034+
},
1035+
[dsda_config_skill_monster_health_factor] = {
1036+
"dsda_skill_monster_health_factor", dsda_config_skill_monster_health_factor,
1037+
dsda_config_int, 0, 4, { 1 }, &cskill_monster_hp_factor
1038+
},
1039+
[dsda_config_skill_friend_health_factor] = {
1040+
"dsda_skill_friend_health_factor", dsda_config_skill_friend_health_factor,
1041+
dsda_config_int, 0, 4, { 1 }, &cskill_friend_hp_factor
1042+
},
1043+
[dsda_config_skill_respawn_monsters] = {
1044+
"dsda_skill_respawn_monsters", dsda_config_skill_respawn_monsters,
1045+
CONF_BOOL(0), &cskill_respawn
1046+
},
1047+
[dsda_config_skill_respawn_time] = {
1048+
"dsda_skill_respawn_time", dsda_config_skill_respawn_time,
1049+
dsda_config_int, 1, 32, { 12 }, &cskill_respawn_time
1050+
},
1051+
[dsda_config_skill_no_monsters] = {
1052+
"dsda_skill_no_monsters", dsda_config_skill_no_monsters,
1053+
CONF_BOOL(0), &cskill_no_monsters
1054+
},
1055+
[dsda_config_skill_fast_monsters] = {
1056+
"dsda_skill_fast_monsters", dsda_config_skill_fast_monsters,
1057+
CONF_BOOL(0), &cskill_fast_monsters
1058+
},
1059+
[dsda_config_skill_aggressive_monsters] = {
1060+
"dsda_skill_aggressive_monsters", dsda_config_skill_aggressive_monsters,
1061+
CONF_BOOL(0), &cskill_aggressive
1062+
},
1063+
[dsda_config_skill_easy_brain] = {
1064+
"dsda_skill_easy_brain", dsda_config_skill_easy_brain,
1065+
CONF_BOOL(0), &cskill_easy_brain
1066+
},
1067+
[dsda_config_skill_auto_use_health] = {
1068+
"dsda_skill_auto_use_health", dsda_config_skill_auto_use_health,
1069+
CONF_BOOL(0), &cskill_auto_use_hp
1070+
},
1071+
[dsda_config_skill_no_pain] = {
1072+
"dsda_skill_no_pain", dsda_config_skill_no_pain,
1073+
CONF_BOOL(0), &cskill_no_pain
1074+
},
10101075
[dsda_config_parallel_sfx_limit] = {
10111076
"dsda_parallel_sfx_limit", dsda_config_parallel_sfx_limit,
10121077
dsda_config_int, 0, 32, { 0 }, NULL, NOT_STRICT, dsda_InitParallelSFXFilter

prboom2/src/dsda/configuration.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,22 @@ typedef enum {
221221
dsda_config_fast_monsters,
222222
dsda_config_no_monsters,
223223
dsda_config_coop_spawns,
224+
dsda_config_skill_spawn_filter,
225+
dsda_config_skill_coop_spawns,
226+
dsda_config_skill_ammo_factor,
227+
dsda_config_skill_damage_factor,
228+
dsda_config_skill_armor_factor,
229+
dsda_config_skill_health_factor,
230+
dsda_config_skill_monster_health_factor,
231+
dsda_config_skill_friend_health_factor,
232+
dsda_config_skill_respawn_monsters,
233+
dsda_config_skill_respawn_time,
234+
dsda_config_skill_no_monsters,
235+
dsda_config_skill_fast_monsters,
236+
dsda_config_skill_aggressive_monsters,
237+
dsda_config_skill_easy_brain,
238+
dsda_config_skill_auto_use_health,
239+
dsda_config_skill_no_pain,
224240
dsda_config_parallel_sfx_limit,
225241
dsda_config_parallel_sfx_window,
226242
dsda_config_movement_toggle_sfx,

prboom2/src/dsda/demo.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
#include "dsda/map_format.h"
4040
#include "dsda/preferences.h"
4141
#include "dsda/settings.h"
42+
#include "dsda/skill_info.h"
4243
#include "dsda/split_tracker.h"
4344
#include "dsda/utility.h"
4445

@@ -280,6 +281,12 @@ void dsda_InitDemoRecording(void) {
280281
if (dsda_Flag(dsda_arg_pistol_start))
281282
I_Error("The -pistolstart option is not allowed when recording a demo!");
282283

284+
if (customskill && dsda_Flag(dsda_arg_skill))
285+
{
286+
if (dsda_Arg(dsda_arg_skill)->value.v_int > num_og_skills)
287+
I_Error("Custom Skill is not allowed when recording a demo!\n");
288+
}
289+
283290
demorecording = true;
284291

285292
// Key settings revert when starting a new attempt

prboom2/src/dsda/global.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ const char* g_skyflatname;
138138
dboolean hexen = false;
139139
dboolean heretic = false;
140140
dboolean raven = false;
141+
dboolean customskill = false;
141142

142143
static void dsda_InitDoom(void) {
143144
int i;

prboom2/src/dsda/global.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ extern int g_mf_shadow;
104104
extern const char* g_skyflatname;
105105

106106
extern dboolean heretic;
107+
extern dboolean customskill;
107108

108109
void dsda_InitGlobal(void);
109110

prboom2/src/dsda/skill_info.c

Lines changed: 99 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ const skill_info_t hexen_skill_infos[5] = {
127127
};
128128

129129
int num_skills;
130+
int num_og_skills;
130131
skill_info_t* skill_infos;
131132

132133
static void dsda_CopyFactor(fixed_t* dest, const char* source) {
@@ -139,7 +140,7 @@ static void dsda_CopyFactor(fixed_t* dest, const char* source) {
139140
*dest = dsda_StringToFixed(source) + 1;
140141
}
141142

142-
void dsda_CopySkillInfo(int i, const doom_mapinfo_skill_t* info) {
143+
static void dsda_CopySkillInfo(int i, const doom_mapinfo_skill_t* info) {
143144
memset(&skill_infos[i], 0, sizeof(skill_infos[i]));
144145

145146
dsda_CopyFactor(&skill_infos[i].ammo_factor, info->ammo_factor);
@@ -171,11 +172,18 @@ void dsda_CopySkillInfo(int i, const doom_mapinfo_skill_t* info) {
171172
void dsda_InitSkills(void) {
172173
int i = 0;
173174
int j;
175+
int original_skills;
174176
dboolean clear_skills;
175177

178+
// Check for new skills
179+
dsda_CheckCustomSkill();
180+
176181
clear_skills = (doom_mapinfo.num_skills && doom_mapinfo.skills_cleared);
177182

178-
num_skills = (clear_skills ? 0 : 5) + doom_mapinfo.num_skills;
183+
num_skills = (clear_skills ? 0 : 5) + (int)doom_mapinfo.num_skills + customskill;
184+
num_og_skills = num_skills - customskill;
185+
186+
original_skills = 5;
179187

180188
skill_infos = Z_Calloc(num_skills, sizeof(*skill_infos));
181189

@@ -186,7 +194,7 @@ void dsda_InitSkills(void) {
186194
heretic ? heretic_skill_infos :
187195
doom_skill_infos;
188196

189-
for (i = 0; i < 5; ++i)
197+
for (i = 0; i < original_skills; ++i)
190198
skill_infos[i] = original_skill_infos[i];
191199
}
192200

@@ -221,6 +229,84 @@ void dsda_InitSkills(void) {
221229
}
222230
}
223231

232+
/////////////////////////////////////////
233+
//
234+
// Add Custom Skill Properties
235+
//
236+
//
237+
238+
// Custom Skill variables
239+
int cskill_spawn_filter;
240+
int cskill_ammo_factor;
241+
int cskill_damage_factor;
242+
int cskill_armor_factor;
243+
int cskill_health_factor;
244+
int cskill_monster_hp_factor;
245+
int cskill_friend_hp_factor;
246+
int cskill_respawn;
247+
int cskill_respawn_time;
248+
int cskill_coop_spawns;
249+
int cskill_no_monsters;
250+
int cskill_fast_monsters;
251+
int cskill_aggressive;
252+
int cskill_no_pain;
253+
int cskill_easy_brain;
254+
int cskill_auto_use_hp;
255+
256+
static int dsda_GetCustomSpawnFilter(int config) {
257+
switch (config)
258+
{
259+
case 0: return 1; // if "easy", skill 1
260+
case 1: return 3; // if "medium", skill 3
261+
case 2: return 4; // if "hard", skill 4
262+
default: return false;
263+
}
264+
}
265+
266+
static int dsda_GetCustomFactor(int config) {
267+
switch (config)
268+
{
269+
case 0: return FRACUNIT / 2; // Half
270+
case 1: return FRACUNIT; // Default
271+
case 2: return FRACUNIT * 3 / 2; // 1.5x - Raven games use this
272+
case 3: return FRACUNIT * 2; // Double
273+
case 4: return FRACUNIT * 4; // Quad
274+
default: return false;
275+
}
276+
}
277+
278+
void dsda_UpdateCustomSkill(int custom_skill_num) {
279+
// Add label for skill cheat
280+
skill_infos[custom_skill_num].name = "Custom Skill";
281+
282+
// Reset custom skill properties
283+
skill_infos[custom_skill_num].flags = 0;
284+
skill_infos[custom_skill_num].respawn_time = 0;
285+
286+
// Get spawn filter value
287+
skill_infos[custom_skill_num].spawn_filter = dsda_GetCustomSpawnFilter(cskill_spawn_filter);;
288+
289+
// Get multiplier factors
290+
skill_infos[custom_skill_num].ammo_factor = dsda_GetCustomFactor(cskill_ammo_factor);
291+
skill_infos[custom_skill_num].damage_factor = dsda_GetCustomFactor(cskill_damage_factor);
292+
skill_infos[custom_skill_num].armor_factor = dsda_GetCustomFactor(cskill_armor_factor);
293+
skill_infos[custom_skill_num].health_factor = dsda_GetCustomFactor(cskill_health_factor);
294+
skill_infos[custom_skill_num].monster_health_factor = dsda_GetCustomFactor(cskill_monster_hp_factor);
295+
skill_infos[custom_skill_num].friend_health_factor = dsda_GetCustomFactor(cskill_friend_hp_factor);
296+
297+
// Get respawn time (if respawn is enabled)
298+
if (cskill_respawn) skill_infos[custom_skill_num].respawn_time = cskill_respawn_time;
299+
300+
// Add remaining flags
301+
if (cskill_coop_spawns) skill_infos[custom_skill_num].flags |= SI_SPAWN_MULTI;
302+
if (cskill_no_monsters) skill_infos[custom_skill_num].flags |= SI_NO_MONSTERS;
303+
if (cskill_fast_monsters) skill_infos[custom_skill_num].flags |= SI_FAST_MONSTERS;
304+
if (cskill_aggressive) skill_infos[custom_skill_num].flags |= SI_INSTANT_REACTION;
305+
if (cskill_no_pain) skill_infos[custom_skill_num].flags |= SI_NO_PAIN;
306+
if (cskill_easy_brain && !raven) skill_infos[custom_skill_num].flags |= SI_EASY_BOSS_BRAIN;
307+
if (cskill_auto_use_hp && raven) skill_infos[custom_skill_num].flags |= SI_AUTO_USE_HEALTH;
308+
}
309+
224310
// At startup, set-up temp game modifier configs based off args / persistent cfgs
225311
// Only set once, as modifiers can break away from args
226312
//
@@ -315,3 +401,13 @@ void dsda_AlterGameFlags(void)
315401

316402
dsda_RefreshGameSkill();
317403
}
404+
405+
void dsda_CheckCustomSkill(void) {
406+
//if (started_demo)
407+
//return;
408+
409+
if (!allow_incompatibility || netgame)
410+
return;
411+
412+
customskill = true;
413+
}

prboom2/src/dsda/skill_info.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,24 @@
3333
#define SI_AUTO_USE_HEALTH 0x0400
3434
#define SI_NO_MONSTERS 0x1000
3535

36+
// Custom Skill variables
37+
extern int cskill_spawn_filter;
38+
extern int cskill_ammo_factor;
39+
extern int cskill_damage_factor;
40+
extern int cskill_armor_factor;
41+
extern int cskill_health_factor;
42+
extern int cskill_monster_hp_factor;
43+
extern int cskill_friend_hp_factor;
44+
extern int cskill_respawn;
45+
extern int cskill_respawn_time;
46+
extern int cskill_coop_spawns;
47+
extern int cskill_no_monsters;
48+
extern int cskill_fast_monsters;
49+
extern int cskill_aggressive;
50+
extern int cskill_no_pain;
51+
extern int cskill_easy_brain;
52+
extern int cskill_auto_use_hp;
53+
3654
typedef uint16_t skill_info_flags_t;
3755

3856
typedef struct {
@@ -56,10 +74,14 @@ extern skill_info_t skill_info;
5674
extern skill_info_t *skill_infos;
5775

5876
extern int num_skills;
77+
extern int num_og_skills;
5978

6079
void dsda_InitSkills(void);
6180
void dsda_RefreshGameSkill(void);
6281
void dsda_UpdateGameSkill(int skill);
82+
void dsda_UpdateCustomSkill(int custom_skill);
83+
void dsda_CheckCustomSkill(void);
84+
6385
void dsda_AlterGameFlags(void);
6486
void dsda_InitGameModifiers(void);
6587
void dsda_ResetGameModifiers(void);

prboom2/src/dsda/wad_stats.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -268,19 +268,23 @@ void dsda_WadStatsExitMap(int missed_monsters) {
268268
int skill;
269269
int nightmare_skill;
270270
int best_normal_skill;
271+
int extra_skill;
271272
int nomo_flag;
273+
int skip_stats;
272274

273275
if (!current_map_stats || demoplayback)
274276
return;
275277

276-
nightmare_skill = num_skills;
277-
best_normal_skill = num_skills - 1;
278+
skill = gameskill + 1;
279+
nightmare_skill = num_og_skills;
280+
best_normal_skill = num_og_skills - 1;
281+
extra_skill = skill > num_og_skills;
278282

279283
// Get conditions for recording wad stats
280284
nomo_flag = skill_info.flags & SI_NO_MONSTERS;
285+
skip_stats = extra_skill || nomo_flag;
281286

282-
if (!nomo_flag) {
283-
skill = gameskill + 1;
287+
if (!skip_stats) {
284288
if (skill > current_map_stats->best_skill) {
285289
if (current_map_stats->best_skill < best_normal_skill) {
286290
current_map_stats->best_time = -1;

0 commit comments

Comments
 (0)