Skip to content

Commit

Permalink
Merge pull request #413 from kraflab/abstract-skill-info
Browse files Browse the repository at this point in the history
Abstract skill info
  • Loading branch information
kraflab authored Jul 22, 2023
2 parents aa94c85 + 6af6f53 commit fdc72ed
Show file tree
Hide file tree
Showing 21 changed files with 291 additions and 84 deletions.
2 changes: 2 additions & 0 deletions prboom2/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,8 @@ set(COMMON_SRC
dsda/sfx.c
dsda/sfx.h
dsda/signal_context.h
dsda/skill_info.c
dsda/skill_info.h
dsda/skip.c
dsda/skip.h
dsda/sndinfo.c
Expand Down
4 changes: 2 additions & 2 deletions prboom2/src/d_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ dboolean nomusicparm;
extern dboolean inhelpscreens;
extern dboolean BorderNeedRefresh;

skill_t startskill;
int startskill;
int startepisode;
int startmap;
dboolean autostart;
Expand Down Expand Up @@ -1676,7 +1676,7 @@ static void D_DoomMainSetup(void)

// get skill / episode / map from parms

startskill = sk_none; // jff 3/24/98 was sk_medium, just note not picked
startskill = dsda_IntConfig(dsda_config_default_skill) - 1;
startepisode = 1;
startmap = 1;
autostart = false;
Expand Down
9 changes: 0 additions & 9 deletions prboom2/src/doomdef.h
Original file line number Diff line number Diff line change
Expand Up @@ -190,15 +190,6 @@ typedef enum {
#define MTF_SKILL4 0x00080000
#define MTF_SKILL5 0x00100000

typedef enum {
sk_none=-1, //jff 3/24/98 create unpicked skill setting
sk_baby=0,
sk_easy,
sk_medium,
sk_hard,
sk_nightmare
} skill_t;

//
// Key cards.
//
Expand Down
7 changes: 2 additions & 5 deletions prboom2/src/doomstat.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,13 +139,13 @@ extern Language_t language;
//

// Defaults for menu, methinks.
extern skill_t startskill;
extern int startskill;
extern int startepisode;

extern dboolean autostart;

// Selected by user.
extern skill_t gameskill;
extern int gameskill;
extern int gameepisode;
extern int gamemap;

Expand All @@ -162,9 +162,6 @@ extern leave_data_t leave_data;
#define LF_SET_ANGLE 0x01
#define LEAVE_VICTORY -1

// Nightmare mode flag, single player.
extern dboolean respawnmonsters;

// Netgame? Only true if >1 player.
extern dboolean netgame;

Expand Down
2 changes: 1 addition & 1 deletion prboom2/src/dsda.c
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ static void dsda_ResetTracking(void) {
dsda_pacifist_note_shown = false;
}

void dsda_WatchDeferredInitNew(skill_t skill, int episode, int map) {
void dsda_WatchDeferredInitNew(int skill, int episode, int map) {
if (!demorecording) return;

++dsda_session_attempts;
Expand Down
2 changes: 1 addition & 1 deletion prboom2/src/dsda.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ void dsda_WatchNewLevel(void);
void dsda_WatchLevelCompletion(void);
void dsda_WatchWeaponFire(weapontype_t weapon);
void dsda_WatchSecret(void);
void dsda_WatchDeferredInitNew(skill_t skill, int episode, int map);
void dsda_WatchDeferredInitNew(int skill, int episode, int map);
void dsda_WatchNewGame(void);
void dsda_WatchLevelReload(int* reloaded);
void dsda_WatchLineActivation(line_t* line, mobj_t* mo);
Expand Down
7 changes: 5 additions & 2 deletions prboom2/src/dsda/analysis.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,9 @@ void dsda_WriteAnalysis(void) {
return;
}

#define SKILL4 3
#define SKILL5 4

const char* dsda_DetectCategory(void) {
dboolean satisfies_max;
dboolean satisfies_respawn;
Expand Down Expand Up @@ -153,7 +156,7 @@ const char* dsda_DetectCategory(void) {
if (solo_net) return "Other";
if (dsda_reborn) return "Other";

if (gameskill == sk_hard) {
if (gameskill == SKILL4) {
if (dsda_nomo && !dsda_respawn && !dsda_fast) {
if (satisfies_100s) return "NoMo 100S";

Expand Down Expand Up @@ -181,7 +184,7 @@ const char* dsda_DetectCategory(void) {

return "UV Speed";
}
else if (gameskill == sk_nightmare) {
else if (gameskill == SKILL5) {
if (nomonsters) return "Other";
if (satisfies_100s) return "NM 100S";

Expand Down
7 changes: 7 additions & 0 deletions prboom2/src/dsda/global.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#include "dsda/mobjinfo.h"
#include "dsda/music.h"
#include "dsda/sfx.h"
#include "dsda/skill_info.h"
#include "dsda/sprite.h"
#include "dsda/state.h"

Expand Down Expand Up @@ -152,6 +153,8 @@ static void dsda_InitDoom(void) {

weaponinfo = doom_weaponinfo;

skill_infos = doom_skill_infos;

g_maxplayers = 4;
g_viewheight = 41 * FRACUNIT;
g_numammo = DOOM_NUMAMMO;
Expand Down Expand Up @@ -291,6 +294,8 @@ static void dsda_InitHeretic(void) {

weaponinfo = wpnlev1info;

skill_infos = heretic_skill_infos;

g_maxplayers = 4;
g_viewheight = 41 * FRACUNIT;
g_numammo = HERETIC_NUMAMMO;
Expand Down Expand Up @@ -448,6 +453,8 @@ static void dsda_InitHexen(void) {

// weaponinfo = wpnlev1info;

skill_infos = hexen_skill_infos;

g_maxplayers = 8;
g_viewheight = 48 * FRACUNIT;
g_numammo = NUMMANA;
Expand Down
4 changes: 3 additions & 1 deletion prboom2/src/dsda/hud_components/map_totals.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
// DSDA Map Totals HUD Component
//

#include "dsda/skill_info.h"

#include "base.h"

#include "map_totals.h"
Expand Down Expand Up @@ -52,7 +54,7 @@ static void dsda_UpdateComponentText(char* str, size_t max_size) {
}
}

if (respawnmonsters) {
if (skill_info.respawn_time) {
fullkillcount = kill_percent_count;
max_kill_requirement = totalkills;
}
Expand Down
4 changes: 3 additions & 1 deletion prboom2/src/dsda/hud_components/stat_totals.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
// DSDA Stat Totals HUD Component
//

#include "dsda/skill_info.h"

#include "base.h"

#include "stat_totals.h"
Expand Down Expand Up @@ -55,7 +57,7 @@ static void dsda_UpdateComponentText(char* str, size_t max_size) {
}
}

if (respawnmonsters) {
if (skill_info.respawn_time) {
fullkillcount = kill_percent_count;
max_kill_requirement = totalkills;
}
Expand Down
139 changes: 139 additions & 0 deletions prboom2/src/dsda/skill_info.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
//
// Copyright(C) 2023 by Ryan Krafnick
//
// This program 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 2
// 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.
//
// DESCRIPTION:
// DSDA Skill Info
//

#include "doomstat.h"

#include "skill_info.h"

skill_info_t skill_info;

const skill_info_t doom_skill_infos[5] = {
{
.ammo_factor = FRACUNIT * 2,
.damage_factor = FRACUNIT / 2,
.spawn_filter = 1,
.key = 'i',
.name = "I'm too young to die.",
.pic_name = "M_JKILL",
.flags = SI_EASY_BOSS_BRAIN
},
{
.spawn_filter = 2,
.key = 'h',
.name = "Hey, not too rough.",
.pic_name = "M_ROUGH",
.flags = SI_EASY_BOSS_BRAIN
},
{
.spawn_filter = 3,
.key = 'h',
.name = "Hurt me plenty.",
.pic_name = "M_HURT",
.flags = SI_DEFAULT_SKILL
},
{
.spawn_filter = 4,
.key = 'u',
.name = "Ultra-Violence.",
.pic_name = "M_ULTRA",
.flags = 0
},
{
.ammo_factor = FRACUNIT * 2,
.spawn_filter = 5,
.key = 'n',
.name = "Nightmare!",
.pic_name = "M_NMARE",
.respawn_time = 12,
.flags = SI_FAST_MONSTERS | SI_INSTANT_REACTION | SI_MUST_CONFIRM
},
};

const skill_info_t heretic_skill_infos[5] = {
{
.ammo_factor = FRACUNIT * 3 / 2,
.damage_factor = FRACUNIT / 2,
.spawn_filter = 1,
.flags = SI_AUTO_USE_HEALTH
},
{
.spawn_filter = 2,
.flags = 0
},
{
.spawn_filter = 3,
.flags = SI_DEFAULT_SKILL
},
{
.spawn_filter = 4,
.flags = 0
},
{
.ammo_factor = FRACUNIT * 3 / 2,
.spawn_filter = 5,
.flags = SI_FAST_MONSTERS | SI_INSTANT_REACTION
},
};

const skill_info_t hexen_skill_infos[5] = {
{
.ammo_factor = FRACUNIT * 3 / 2,
.damage_factor = FRACUNIT / 2,
.spawn_filter = 1,
.flags = SI_AUTO_USE_HEALTH
},
{
.spawn_filter = 2,
.flags = 0
},
{
.spawn_filter = 3,
.flags = SI_DEFAULT_SKILL
},
{
.spawn_filter = 4,
.flags = 0
},
{
.ammo_factor = FRACUNIT * 3 / 2,
.spawn_filter = 5,
.flags = SI_FAST_MONSTERS | SI_INSTANT_REACTION
},
};

const skill_info_t* skill_infos;

int num_skills = 5;

void dsda_RefreshGameSkill(void) {
void G_RefreshFastMonsters(void);

skill_info = skill_infos[gameskill];

if (respawnparm && !skill_info.respawn_time)
skill_info.respawn_time = 12;

if (fastparm)
skill_info.flags |= SI_FAST_MONSTERS;

G_RefreshFastMonsters();
}

void dsda_UpdateGameSkill(int skill) {
gameskill = skill;
dsda_RefreshGameSkill();
}
67 changes: 67 additions & 0 deletions prboom2/src/dsda/skill_info.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
//
// Copyright(C) 2023 by Ryan Krafnick
//
// This program 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 2
// 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.
//
// DESCRIPTION:
// DSDA Skill Info
//

#ifndef __DSDA_SKILL_INFO__
#define __DSDA_SKILL_INFO__

#include "doomdef.h"
#include "m_fixed.h"

#define SI_SPAWN_MULTI 0x0001
#define SI_FAST_MONSTERS 0x0002
#define SI_INSTANT_REACTION 0x0004
#define SI_DISABLE_CHEATS 0x0008
#define SI_NO_PAIN 0x0010
#define SI_DEFAULT_SKILL 0x0020
#define SI_NO_MENU 0x0040
#define SI_PLAYER_RESPAWN 0x0080
#define SI_EASY_BOSS_BRAIN 0x0100
#define SI_MUST_CONFIRM 0x0200
#define SI_AUTO_USE_HEALTH 0x0400

typedef uint16_t skill_info_flags_t;

typedef struct {
fixed_t ammo_factor;
fixed_t damage_factor;
fixed_t armor_factor;
fixed_t health_factor;
fixed_t monster_health_factor;
fixed_t friend_health_factor;
int respawn_time;
int spawn_filter;
char key;
const char* must_confirm;
const char* name;
const char* pic_name;
int text_color;
skill_info_flags_t flags;
} skill_info_t;

extern skill_info_t skill_info;
extern const skill_info_t* skill_infos;

extern const skill_info_t doom_skill_infos[5];
extern const skill_info_t heretic_skill_infos[5];
extern const skill_info_t hexen_skill_infos[5];

extern int num_skills;

void dsda_RefreshGameSkill(void);
void dsda_UpdateGameSkill(int skill);

#endif
Loading

0 comments on commit fdc72ed

Please sign in to comment.