Cleanup perk.h

See #42
This commit is contained in:
Alexander Batalov 2022-06-18 18:37:23 +03:00
parent 428b4baa7b
commit 13a7b5e743
2 changed files with 32 additions and 38 deletions

View File

@ -4,6 +4,7 @@
#include "game.h" #include "game.h"
#include "game_config.h" #include "game_config.h"
#include "memory.h" #include "memory.h"
#include "message.h"
#include "object.h" #include "object.h"
#include "party_member.h" #include "party_member.h"
#include "platform_compat.h" #include "platform_compat.h"
@ -12,8 +13,32 @@
#include <stdio.h> #include <stdio.h>
typedef struct PerkDescription {
char* name;
char* description;
int frmId;
int maxRank;
int minLevel;
int stat;
int statModifier;
int param1;
int value1;
int field_24;
int param2;
int value2;
int stats[PRIMARY_STAT_COUNT];
} PerkDescription;
typedef struct PerkRankData {
int ranks[PERK_COUNT];
} PerkRankData;
static PerkRankData* perkGetRankData(Object* critter);
static bool perkCanAdd(Object* critter, int perk);
static void perkResetRanks();
// 0x519DCC // 0x519DCC
PerkDescription gPerkDescriptions[PERK_COUNT] = { static PerkDescription gPerkDescriptions[PERK_COUNT] = {
{ NULL, NULL, 72, 1, 3, -1, 0, -1, 0, 0, -1, 0, 0, 5, 0, 0, 0, 0, 0 }, { NULL, NULL, 72, 1, 3, -1, 0, -1, 0, 0, -1, 0, 0, 5, 0, 0, 0, 0, 0 },
{ NULL, NULL, 73, 1, 15, -1, 0, -1, 0, 0, -1, 0, 0, 0, 0, 0, 0, 6, 0 }, { NULL, NULL, 73, 1, 15, -1, 0, -1, 0, 0, -1, 0, 0, 0, 0, 0, 0, 6, 0 },
{ NULL, NULL, 74, 3, 3, 11, 2, -1, 0, 0, -1, 0, 6, 0, 0, 0, 0, 6, 0 }, { NULL, NULL, 74, 3, 3, 11, 2, -1, 0, 0, -1, 0, 6, 0, 0, 0, 0, 6, 0 },
@ -138,18 +163,18 @@ PerkDescription gPerkDescriptions[PERK_COUNT] = {
// An array of perk ranks for each party member. // An array of perk ranks for each party member.
// //
// 0x51C120 // 0x51C120
PerkRankData* gPartyMemberPerkRanks = NULL; static PerkRankData* gPartyMemberPerkRanks = NULL;
// Amount of experience points granted when player selected "Here and now" // Amount of experience points granted when player selected "Here and now"
// perk. // perk.
// //
// 0x51C124 // 0x51C124
int gHereAndNowBonusExperience = 0; static int gHereAndNowBonusExperience = 0;
// perk.msg // perk.msg
// //
// 0x6642D4 // 0x6642D4
MessageList gPerksMessageList; static MessageList gPerksMessageList;
// 0x4965A0 // 0x4965A0
int perksInit() int perksInit()
@ -238,7 +263,7 @@ int perksSave(File* stream)
// perkGetLevelData // perkGetLevelData
// 0x49678C // 0x49678C
PerkRankData* perkGetRankData(Object* critter) static PerkRankData* perkGetRankData(Object* critter)
{ {
if (critter == gDude) { if (critter == gDude) {
return gPartyMemberPerkRanks; return gPartyMemberPerkRanks;
@ -256,7 +281,7 @@ PerkRankData* perkGetRankData(Object* critter)
} }
// 0x49680C // 0x49680C
bool perkCanAdd(Object* critter, int perk) static bool perkCanAdd(Object* critter, int perk)
{ {
if (!perkIsValid(perk)) { if (!perkIsValid(perk)) {
return false; return false;
@ -377,7 +402,7 @@ bool perkCanAdd(Object* critter, int perk)
// Resets party member perks. // Resets party member perks.
// //
// 0x496A0C // 0x496A0C
void perkResetRanks() static void perkResetRanks()
{ {
for (int index = 0; index < gPartyMemberDescriptionsLength; index++) { for (int index = 0; index < gPartyMemberDescriptionsLength; index++) {
PerkRankData* ranksData = &(gPartyMemberPerkRanks[index]); PerkRankData* ranksData = &(gPartyMemberPerkRanks[index]);

View File

@ -2,45 +2,14 @@
#define PERK_H #define PERK_H
#include "db.h" #include "db.h"
#include "message.h"
#include "obj_types.h" #include "obj_types.h"
#include "perk_defs.h" #include "perk_defs.h"
#include "stat_defs.h"
typedef struct PerkDescription {
char* name;
char* description;
int frmId;
int maxRank;
int minLevel;
int stat;
int statModifier;
int param1;
int value1;
int field_24;
int param2;
int value2;
int stats[PRIMARY_STAT_COUNT];
} PerkDescription;
typedef struct PerkRankData {
int ranks[PERK_COUNT];
} PerkRankData;
extern PerkDescription gPerkDescriptions[PERK_COUNT];
extern PerkRankData* gPartyMemberPerkRanks;
extern int gHereAndNowBonusExperience;
extern MessageList gPerksMessageList;
int perksInit(); int perksInit();
void perksReset(); void perksReset();
void perksExit(); void perksExit();
int perksLoad(File* stream); int perksLoad(File* stream);
int perksSave(File* stream); int perksSave(File* stream);
PerkRankData* perkGetRankData(Object* critter);
bool perkCanAdd(Object* critter, int perk);
void perkResetRanks();
int perkAdd(Object* critter, int perk); int perkAdd(Object* critter, int perk);
int perkAddForce(Object* critter, int perk); int perkAddForce(Object* critter, int perk);
int perkRemove(Object* critter, int perk); int perkRemove(Object* critter, int perk);