Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 65 additions & 0 deletions prboom2/src/dsda/configuration.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#include "dsda/exhud.h"
#include "dsda/features.h"
#include "dsda/input.h"
#include "dsda/skill_info.h"
#include "dsda/stretch.h"
#include "dsda/utility.h"

Expand Down Expand Up @@ -1007,6 +1008,70 @@ dsda_config_t dsda_config[dsda_config_count] = {
"dsda_coop_spawns", dsda_config_coop_spawns,
CONF_BOOL(0), NULL, NOT_STRICT, dsda_AlterGameFlags
},
[dsda_config_skill_spawn_filter] = {
"dsda_skill_spawn_filter", dsda_config_skill_spawn_filter,
dsda_config_int, 0, 2, { 1 }, &cskill_spawn_filter
},
[dsda_config_skill_coop_spawns] = {
"dsda_skill_coop_spawns", dsda_config_skill_coop_spawns,
CONF_BOOL(0), &cskill_coop_spawns
},
[dsda_config_skill_ammo_factor] = {
"dsda_skill_ammo_factor", dsda_config_skill_ammo_factor,
dsda_config_int, 0, 4, { 1 }, &cskill_ammo_factor
},
[dsda_config_skill_damage_factor] = {
"dsda_skill_damage_factor", dsda_config_skill_damage_factor,
dsda_config_int, 0, 4, { 1 }, &cskill_damage_factor
},
[dsda_config_skill_armor_factor] = {
"dsda_skill_armor_factor", dsda_config_skill_armor_factor,
dsda_config_int, 0, 4, { 1 }, &cskill_armor_factor
},
[dsda_config_skill_health_factor] = {
"dsda_skill_health_factor", dsda_config_skill_health_factor,
dsda_config_int, 0, 4, { 1 }, &cskill_health_factor
},
[dsda_config_skill_monster_health_factor] = {
"dsda_skill_monster_health_factor", dsda_config_skill_monster_health_factor,
dsda_config_int, 0, 4, { 1 }, &cskill_monster_hp_factor
},
[dsda_config_skill_friend_health_factor] = {
"dsda_skill_friend_health_factor", dsda_config_skill_friend_health_factor,
dsda_config_int, 0, 4, { 1 }, &cskill_friend_hp_factor
},
[dsda_config_skill_respawn_monsters] = {
"dsda_skill_respawn_monsters", dsda_config_skill_respawn_monsters,
CONF_BOOL(0), &cskill_respawn
},
[dsda_config_skill_respawn_time] = {
"dsda_skill_respawn_time", dsda_config_skill_respawn_time,
dsda_config_int, 1, 32, { 12 }, &cskill_respawn_time
},
[dsda_config_skill_no_monsters] = {
"dsda_skill_no_monsters", dsda_config_skill_no_monsters,
CONF_BOOL(0), &cskill_no_monsters
},
[dsda_config_skill_fast_monsters] = {
"dsda_skill_fast_monsters", dsda_config_skill_fast_monsters,
CONF_BOOL(0), &cskill_fast_monsters
},
[dsda_config_skill_aggressive_monsters] = {
"dsda_skill_aggressive_monsters", dsda_config_skill_aggressive_monsters,
CONF_BOOL(0), &cskill_aggressive
},
[dsda_config_skill_easy_brain] = {
"dsda_skill_easy_brain", dsda_config_skill_easy_brain,
CONF_BOOL(0), &cskill_easy_brain
},
[dsda_config_skill_auto_use_health] = {
"dsda_skill_auto_use_health", dsda_config_skill_auto_use_health,
CONF_BOOL(0), &cskill_auto_use_hp
},
[dsda_config_skill_no_pain] = {
"dsda_skill_no_pain", dsda_config_skill_no_pain,
CONF_BOOL(0), &cskill_no_pain
},
[dsda_config_parallel_sfx_limit] = {
"dsda_parallel_sfx_limit", dsda_config_parallel_sfx_limit,
dsda_config_int, 0, 32, { 0 }, NULL, NOT_STRICT, dsda_InitParallelSFXFilter
Expand Down
16 changes: 16 additions & 0 deletions prboom2/src/dsda/configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,22 @@ typedef enum {
dsda_config_fast_monsters,
dsda_config_no_monsters,
dsda_config_coop_spawns,
dsda_config_skill_spawn_filter,
dsda_config_skill_coop_spawns,
dsda_config_skill_ammo_factor,
dsda_config_skill_damage_factor,
dsda_config_skill_armor_factor,
dsda_config_skill_health_factor,
dsda_config_skill_monster_health_factor,
dsda_config_skill_friend_health_factor,
dsda_config_skill_respawn_monsters,
dsda_config_skill_respawn_time,
dsda_config_skill_no_monsters,
dsda_config_skill_fast_monsters,
dsda_config_skill_aggressive_monsters,
dsda_config_skill_easy_brain,
dsda_config_skill_auto_use_health,
dsda_config_skill_no_pain,
dsda_config_parallel_sfx_limit,
dsda_config_parallel_sfx_window,
dsda_config_movement_toggle_sfx,
Expand Down
7 changes: 7 additions & 0 deletions prboom2/src/dsda/demo.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
#include "dsda/map_format.h"
#include "dsda/preferences.h"
#include "dsda/settings.h"
#include "dsda/skill_info.h"
#include "dsda/split_tracker.h"
#include "dsda/utility.h"

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

if (customskill && dsda_Flag(dsda_arg_skill))
{
if (dsda_Arg(dsda_arg_skill)->value.v_int > num_og_skills)
I_Error("Custom Skill is not allowed when recording a demo!\n");
}

demorecording = true;

// Key settings revert when starting a new attempt
Expand Down
1 change: 1 addition & 0 deletions prboom2/src/dsda/global.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ const char* g_skyflatname;
dboolean hexen = false;
dboolean heretic = false;
dboolean raven = false;
dboolean customskill = false;

static void dsda_InitDoom(void) {
int i;
Expand Down
1 change: 1 addition & 0 deletions prboom2/src/dsda/global.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ extern int g_mf_shadow;
extern const char* g_skyflatname;

extern dboolean heretic;
extern dboolean customskill;

void dsda_InitGlobal(void);

Expand Down
27 changes: 27 additions & 0 deletions prboom2/src/dsda/save.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include "dsda/music.h"
#include "dsda/options.h"
#include "dsda/settings.h"
#include "dsda/skill_info.h"

#include "save.h"

Expand Down Expand Up @@ -142,6 +143,30 @@ static void dsda_UnArchiveContext(void) {
true_basetic = gametic - true_logictic_value;
}

skill_info_t saved_custom_skill;

void dsda_ArchiveCustomSkill(void)
{
// don't store info if normal skill
if (gameskill != (num_skills - 1))
return;

saved_custom_skill = skill_infos[num_skills - 1]; // custom skill (-1 to match gameskill)

P_SAVE_X(saved_custom_skill);
}

void dsda_UnArchiveCustomSkill(void)
{
// don't store info if normal skill
if (gameskill != (num_skills - 1))
return;

P_LOAD_X(saved_custom_skill);

skill_infos[num_skills - 1] = saved_custom_skill; // custom skill (-1 to match gameskill)
}

int saved_pistolstart, saved_respawnparm, saved_fastparm, saved_nomonsters, saved_coop_spawns;

void dsda_ArchiveGameModifiers(void)
Expand Down Expand Up @@ -191,6 +216,7 @@ void dsda_ArchiveAll(void) {
P_ArchiveRNG();
P_ArchiveMap();

dsda_ArchiveCustomSkill();
dsda_ArchiveGameModifiers();
dsda_ArchiveInternal();
}
Expand All @@ -212,6 +238,7 @@ void dsda_UnArchiveAll(void) {
P_UnArchiveMap();
P_MapEnd();

dsda_UnArchiveCustomSkill();
dsda_UnArchiveGameModifiers();
dsda_UnArchiveInternal();
}
Expand Down
108 changes: 105 additions & 3 deletions prboom2/src/dsda/skill_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ const skill_info_t hexen_skill_infos[5] = {
};

int num_skills;
int num_og_skills;
skill_info_t* skill_infos;

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

void dsda_CopySkillInfo(int i, const doom_mapinfo_skill_t* info) {
static void dsda_CopySkillInfo(int i, const doom_mapinfo_skill_t* info) {
memset(&skill_infos[i], 0, sizeof(skill_infos[i]));

dsda_CopyFactor(&skill_infos[i].ammo_factor, info->ammo_factor);
Expand Down Expand Up @@ -171,11 +172,18 @@ void dsda_CopySkillInfo(int i, const doom_mapinfo_skill_t* info) {
void dsda_InitSkills(void) {
int i = 0;
int j;
int original_skills;
dboolean clear_skills;

// Check for new skills
dsda_CheckCustomSkill();

clear_skills = (doom_mapinfo.num_skills && doom_mapinfo.skills_cleared);

num_skills = (clear_skills ? 0 : 5) + doom_mapinfo.num_skills;
num_skills = (clear_skills ? 0 : 5) + (int)doom_mapinfo.num_skills + customskill;
num_og_skills = num_skills - customskill;

original_skills = 5;

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

Expand All @@ -186,7 +194,7 @@ void dsda_InitSkills(void) {
heretic ? heretic_skill_infos :
doom_skill_infos;

for (i = 0; i < 5; ++i)
for (i = 0; i < original_skills; ++i)
skill_infos[i] = original_skill_infos[i];
}

Expand Down Expand Up @@ -221,6 +229,87 @@ void dsda_InitSkills(void) {
}
}

/////////////////////////////////////////
//
// Add Custom Skill Properties
//
//

// Custom Skill variables
int cskill_spawn_filter;
int cskill_ammo_factor;
int cskill_damage_factor;
int cskill_armor_factor;
int cskill_health_factor;
int cskill_monster_hp_factor;
int cskill_friend_hp_factor;
int cskill_respawn;
int cskill_respawn_time;
int cskill_coop_spawns;
int cskill_no_monsters;
int cskill_fast_monsters;
int cskill_aggressive;
int cskill_no_pain;
int cskill_easy_brain;
int cskill_auto_use_hp;

static int dsda_GetCustomSpawnFilter(int config) {
switch (config)
{
case 0: return 1; // if "easy", skill 1
case 1: return 3; // if "medium", skill 3
case 2: return 4; // if "hard", skill 4
default: return false;
}
}

static int dsda_GetCustomFactor(int config) {
switch (config)
{
case 0: return FRACUNIT / 2; // Half
case 1: return FRACUNIT; // Default
case 2: return FRACUNIT * 3 / 2; // 1.5x - Raven games use this
case 3: return FRACUNIT * 2; // Double
case 4: return FRACUNIT * 4; // Quad
default: return false;
}
}

void dsda_UpdateCustomSkill(int custom_skill_num) {
// Add label for skill cheat
skill_infos[custom_skill_num].name = "Custom Skill";

// Reset custom skill properties
skill_infos[custom_skill_num].flags = 0;
skill_infos[custom_skill_num].respawn_time = 0;

// Get spawn filter value
skill_infos[custom_skill_num].spawn_filter = dsda_GetCustomSpawnFilter(cskill_spawn_filter);;

// Get multiplier factors
skill_infos[custom_skill_num].ammo_factor = dsda_GetCustomFactor(cskill_ammo_factor);
skill_infos[custom_skill_num].damage_factor = dsda_GetCustomFactor(cskill_damage_factor);
skill_infos[custom_skill_num].armor_factor = dsda_GetCustomFactor(cskill_armor_factor);
skill_infos[custom_skill_num].health_factor = dsda_GetCustomFactor(cskill_health_factor);
skill_infos[custom_skill_num].monster_health_factor = dsda_GetCustomFactor(cskill_monster_hp_factor);
skill_infos[custom_skill_num].friend_health_factor = dsda_GetCustomFactor(cskill_friend_hp_factor);

// Get respawn time (if respawn is enabled)
if (cskill_respawn) skill_infos[custom_skill_num].respawn_time = cskill_respawn_time;

// Add remaining flags
if (cskill_coop_spawns) skill_infos[custom_skill_num].flags |= SI_SPAWN_MULTI;
if (cskill_no_monsters) skill_infos[custom_skill_num].flags |= SI_NO_MONSTERS;
if (cskill_fast_monsters) skill_infos[custom_skill_num].flags |= SI_FAST_MONSTERS;
if (cskill_aggressive) skill_infos[custom_skill_num].flags |= SI_INSTANT_REACTION;
if (cskill_no_pain) skill_infos[custom_skill_num].flags |= SI_NO_PAIN;
if (cskill_easy_brain && !raven) skill_infos[custom_skill_num].flags |= SI_EASY_BOSS_BRAIN;
if (cskill_auto_use_hp && raven) skill_infos[custom_skill_num].flags |= SI_AUTO_USE_HEALTH;

// Update the skill
dsda_UpdateGameSkill(custom_skill_num);
}

// At startup, set-up temp game modifier configs based off args / persistent cfgs
// Only set once, as modifiers can break away from args
//
Expand Down Expand Up @@ -288,6 +377,9 @@ void dsda_RefreshGameSkill(void) {
if (respawnparm && !skill_info.respawn_time)
skill_info.respawn_time = 12;

if (nomonsters)
skill_info.flags |= SI_NO_MONSTERS;

if (fastparm)
skill_info.flags |= SI_FAST_MONSTERS;

Expand All @@ -312,3 +404,13 @@ void dsda_AlterGameFlags(void)

dsda_RefreshGameSkill();
}

void dsda_CheckCustomSkill(void) {
//if (started_demo)
//return;

if (!allow_incompatibility || netgame)
return;

customskill = true;
}
23 changes: 23 additions & 0 deletions prboom2/src/dsda/skill_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,25 @@
#define SI_EASY_BOSS_BRAIN 0x0100
#define SI_MUST_CONFIRM 0x0200
#define SI_AUTO_USE_HEALTH 0x0400
#define SI_NO_MONSTERS 0x1000

// Custom Skill variables
extern int cskill_spawn_filter;
extern int cskill_ammo_factor;
extern int cskill_damage_factor;
extern int cskill_armor_factor;
extern int cskill_health_factor;
extern int cskill_monster_hp_factor;
extern int cskill_friend_hp_factor;
extern int cskill_respawn;
extern int cskill_respawn_time;
extern int cskill_coop_spawns;
extern int cskill_no_monsters;
extern int cskill_fast_monsters;
extern int cskill_aggressive;
extern int cskill_no_pain;
extern int cskill_easy_brain;
extern int cskill_auto_use_hp;

typedef uint16_t skill_info_flags_t;

Expand All @@ -55,10 +74,14 @@ extern skill_info_t skill_info;
extern skill_info_t *skill_infos;

extern int num_skills;
extern int num_og_skills;

void dsda_InitSkills(void);
void dsda_RefreshGameSkill(void);
void dsda_UpdateGameSkill(int skill);
void dsda_UpdateCustomSkill(int custom_skill);
void dsda_CheckCustomSkill(void);

void dsda_AlterGameFlags(void);
void dsda_InitGameModifiers(void);
void dsda_ResetGameModifiers(void);
Expand Down
Loading
Loading