Compare commits

...
Author SHA1 Message Date
jirik2077 3d5fbe061c fix -Wswitch warnings 2026-07-27 22:33:16 +02:00
jirik2077 c33eeb0342 premade character enum usage hardened 2026-07-27 22:25:33 +02:00
jirik2077 d8df3cdd73 editor folder, editor derived stat to be named enums 2026-07-27 22:19:17 +02:00
jirik2077 8663fe5b60 pcstat enum usage hardened 2026-07-27 22:08:02 +02:00
jirik2077 4720ce1b7d stat enum usage hardened 2026-07-27 21:51:30 +02:00
22 changed files with 1110 additions and 1049 deletions
+2 -2
View File
@@ -1994,9 +1994,9 @@ int _compute_dmg_damage(int min, int max, Object* obj, int* knockbackDistancePtr
knockbackDistancePtr = nullptr;
}
int damage = randomBetween(min, max) - critterGetStat(obj, STAT_DAMAGE_THRESHOLD + damageType);
int damage = randomBetween(min, max) - critterGetStat(obj, static_cast<Stat>(STAT_DAMAGE_THRESHOLD + damageType));
if (damage > 0) {
damage -= critterGetStat(obj, STAT_DAMAGE_RESISTANCE + damageType) * damage / 100;
damage -= critterGetStat(obj, static_cast<Stat>(STAT_DAMAGE_RESISTANCE + damageType)) * damage / 100;
}
if (damage < 0) {
+38 -40
View File
@@ -50,8 +50,6 @@
namespace fallout {
#define RENDER_ALL_STATS 7
#define EDITOR_WINDOW_WIDTH 640
#define EDITOR_WINDOW_HEIGHT 480
@@ -106,13 +104,13 @@ namespace fallout {
#define TOWN_REPUTATION_COUNT 19
#define ADDICTION_REPUTATION_COUNT 8
typedef enum EditorFolder {
enum EditorFolder : int {
EDITOR_FOLDER_PERKS,
EDITOR_FOLDER_KARMA,
EDITOR_FOLDER_KILLS,
} EditorFolder;
};
enum {
enum EditorDerivedStat : int {
EDITOR_DERIVED_STAT_ARMOR_CLASS,
EDITOR_DERIVED_STAT_ACTION_POINTS,
EDITOR_DERIVED_STAT_CARRY_WEIGHT,
@@ -170,7 +168,7 @@ inline Editor operator--(Editor& e, int)
return result;
}
enum {
enum EditorGraphics : int {
EDITOR_GRAPHIC_BIG_NUMBERS,
EDITOR_GRAPHIC_AGE_MASK,
EDITOR_GRAPHIC_AGE_OFF,
@@ -264,7 +262,7 @@ static int characterEditorKillsCompare(const void* a1, const void* a2);
static int characterEditorDrawKillsFolder();
static void characterEditorDrawBigNumber(int x, int y, int flags, int value, int previousValue, int windowHandle);
static void characterEditorDrawPcStats();
static void characterEditorDrawPrimaryStat(int stat, bool animate, int previousValue);
static void characterEditorDrawPrimaryStat(Stat stat, bool animate, int previousValue);
static void characterEditorDrawGender();
static void characterEditorDrawAge();
static void characterEditorDrawName();
@@ -473,7 +471,7 @@ static const int gCharacterEditorPrimaryStatY[7] = {
// NOTE: the type is originally short
//
// 0x431D6
static const int gCharacterEditorDerivedStatsMap[EDITOR_DERIVED_STAT_COUNT] = {
static const Stat gCharacterEditorDerivedStatsMap[EDITOR_DERIVED_STAT_COUNT] = {
STAT_ARMOR_CLASS,
STAT_MAXIMUM_ACTION_POINTS,
STAT_CARRY_WEIGHT,
@@ -736,7 +734,7 @@ static int gCharacterEditorMouseX; // mouse x
static Editor characterEditorSelectedItem;
// 0x5707D4 folder
static int characterEditorWindowSelectedFolder;
static EditorFolder characterEditorWindowSelectedFolder;
// 0x5707D8 frstc_draw1
static bool gCharacterEditorCardDrawn;
@@ -841,7 +839,7 @@ int characterEditorShow(bool isCreationMode)
critterUpdateDerivedStats(gDude);
characterEditorDrawOptionalTraits();
characterEditorDrawSkills(0);
characterEditorDrawPrimaryStat(RENDER_ALL_STATS, 0, 0);
characterEditorDrawPrimaryStat(PRIMARY_STAT_COUNT, 0, 0);
characterEditorDrawDerivedStats();
characterEditorDrawCard();
}
@@ -1004,7 +1002,7 @@ int characterEditorShow(bool isCreationMode)
} else if (characterEditorSelectedItem >= EDITOR_FIRST_TRAIT && characterEditorSelectedItem <= EDITOR_LAST_TRAIT) {
characterEditorSelectedItem = EDITOR_HIT_POINTS;
}
characterEditorDrawPrimaryStat(RENDER_ALL_STATS, 0, 0);
characterEditorDrawPrimaryStat(PRIMARY_STAT_COUNT, 0, 0);
characterEditorDrawOptionalTraits();
characterEditorDrawSkills(0);
characterEditorDrawPcStats();
@@ -1104,7 +1102,7 @@ int characterEditorShow(bool isCreationMode)
gCharacterEditorCurrentSkill = static_cast<Skill>(characterEditorSelectedItem - EDITOR_FIRST_SKILL);
}
characterEditorDrawPrimaryStat(RENDER_ALL_STATS, 0, 0);
characterEditorDrawPrimaryStat(PRIMARY_STAT_COUNT, 0, 0);
characterEditorDrawOptionalTraits();
characterEditorDrawSkills(0);
characterEditorDrawPcStats();
@@ -1157,7 +1155,7 @@ int characterEditorShow(bool isCreationMode)
gCharacterEditorCurrentSkill = static_cast<Skill>(characterEditorSelectedItem - EDITOR_FIRST_SKILL);
}
characterEditorDrawPrimaryStat(RENDER_ALL_STATS, 0, 0);
characterEditorDrawPrimaryStat(PRIMARY_STAT_COUNT, 0, 0);
characterEditorDrawOptionalTraits();
characterEditorDrawSkills(0);
characterEditorDrawPcStats();
@@ -1553,7 +1551,7 @@ static int characterEditorWindowInit()
str = getmsg(&gCharacterEditorMessageList, &gCharacterEditorMessageListItem, 100);
fontDrawText(gCharacterEditorWindowBuffer + (EDITOR_WINDOW_WIDTH * DONE_BTN_Y) + DONE_BTN_X, str, EDITOR_WINDOW_WIDTH, EDITOR_WINDOW_WIDTH, COLOR_DARK_YELLOW);
characterEditorDrawPrimaryStat(RENDER_ALL_STATS, 0, 0);
characterEditorDrawPrimaryStat(PRIMARY_STAT_COUNT, 0, 0);
characterEditorDrawDerivedStats();
if (!gCharacterEditorIsCreationMode) {
@@ -2461,7 +2459,7 @@ static void characterEditorDrawPcStats()
}
// 0x434B38 PrintBasicStat
static void characterEditorDrawPrimaryStat(int stat, bool animate, int previousValue)
static void characterEditorDrawPrimaryStat(Stat stat, bool animate, int previousValue)
{
int off;
int color;
@@ -2472,16 +2470,16 @@ static void characterEditorDrawPrimaryStat(int stat, bool animate, int previousV
fontSetCurrent(101);
if (stat == RENDER_ALL_STATS) {
if (stat == PRIMARY_STAT_COUNT) {
// NOTE: Original code is different, looks like tail recursion
// optimization.
for (stat = EDITOR_FIRST_PRIMARY_STAT; stat <= EDITOR_LAST_PRIMARY_STAT; stat++) {
for (stat = STAT_FIRST; stat < PRIMARY_STAT_COUNT; stat++) {
characterEditorDrawPrimaryStat(stat, 0, 0);
}
return;
}
if (characterEditorSelectedItem == stat) {
if (characterEditorSelectedItem == static_cast<Editor>(stat)) {
color = COLOR_LIGHT_YELLOW;
} else {
color = COLOR_GREEN;
@@ -3092,9 +3090,9 @@ static void characterEditorDrawCard()
blitBufferToBuffer(_editorBackgroundFrmImage.getData() + (640 * 267) + 345, 277, 170, 640, gCharacterEditorWindowBuffer + (267 * 640) + 345, 640);
if (characterEditorSelectedItem >= EDITOR_FIRST_PRIMARY_STAT && characterEditorSelectedItem <= EDITOR_LAST_PRIMARY_STAT) {
description = statGetDescription(characterEditorSelectedItem);
title = statGetName(characterEditorSelectedItem);
graphicId = statGetFrmId(characterEditorSelectedItem);
description = statGetDescription(static_cast<Stat>(characterEditorSelectedItem));
title = statGetName(static_cast<Stat>(characterEditorSelectedItem));
graphicId = statGetFrmId(static_cast<Stat>(characterEditorSelectedItem));
characterEditorDrawCardWithOptions(graphicId, title, nullptr, description);
} else if (characterEditorSelectedItem >= EDITOR_LEVEL && characterEditorSelectedItem <= EDITOR_NEXT_LEVEL) {
if (gCharacterEditorIsCreationMode) {
@@ -3180,7 +3178,7 @@ static void characterEditorDrawCard()
}
} else if (characterEditorSelectedItem >= EDITOR_FIRST_DERIVED_STAT && characterEditorSelectedItem <= EDITOR_LAST_DERIVED_STAT) {
int derivedStatIndex = characterEditorSelectedItem - EDITOR_FIRST_DERIVED_STAT;
int stat = gCharacterEditorDerivedStatsMap[derivedStatIndex];
Stat stat = gCharacterEditorDerivedStatsMap[derivedStatIndex];
description = statGetDescription(stat);
title = statGetName(stat);
graphicId = gCharacterEditorDerivedStatFrmIds[derivedStatIndex];
@@ -3510,7 +3508,7 @@ static int characterEditorEditAge()
if (flags == ANIMATE) {
characterEditorDrawAge();
characterEditorDrawPrimaryStat(RENDER_ALL_STATS, 0, 0);
characterEditorDrawPrimaryStat(PRIMARY_STAT_COUNT, 0, 0);
characterEditorDrawDerivedStats();
windowRefresh(gCharacterEditorWindow);
windowRefresh(win);
@@ -3559,7 +3557,7 @@ static int characterEditorEditAge()
characterEditorDrawBigNumber(55, 10, flags, age, previousAge, win);
if (flags == ANIMATE) {
characterEditorDrawAge();
characterEditorDrawPrimaryStat(RENDER_ALL_STATS, 0, 0);
characterEditorDrawPrimaryStat(PRIMARY_STAT_COUNT, 0, 0);
characterEditorDrawDerivedStats();
windowRefresh(gCharacterEditorWindow);
windowRefresh(win);
@@ -3592,7 +3590,7 @@ static int characterEditorEditAge()
critterSetBaseStat(gDude, STAT_AGE, savedAge);
characterEditorDrawAge();
characterEditorDrawPrimaryStat(RENDER_ALL_STATS, 0, 0);
characterEditorDrawPrimaryStat(PRIMARY_STAT_COUNT, 0, 0);
characterEditorDrawDerivedStats();
windowRefresh(gCharacterEditorWindow);
windowRefresh(win);
@@ -3707,7 +3705,7 @@ static void characterEditorEditGender()
if (eventCode == KEY_ESCAPE || _game_user_wants_to_quit != GAME_QUIT_REQUEST_NONE) {
critterSetBaseStat(gDude, STAT_GENDER, savedGender);
characterEditorDrawPrimaryStat(RENDER_ALL_STATS, 0, 0);
characterEditorDrawPrimaryStat(PRIMARY_STAT_COUNT, 0, 0);
characterEditorDrawDerivedStats();
windowRefresh(gCharacterEditorWindow);
break;
@@ -3726,7 +3724,7 @@ static void characterEditorEditGender()
case 502:
// TODO: Original code is slightly different.
critterSetBaseStat(gDude, STAT_GENDER, eventCode - 501);
characterEditorDrawPrimaryStat(RENDER_ALL_STATS, 0, 0);
characterEditorDrawPrimaryStat(PRIMARY_STAT_COUNT, 0, 0);
characterEditorDrawDerivedStats();
break;
}
@@ -3754,8 +3752,8 @@ static void characterEditorAdjustPrimaryStat(int eventCode)
return;
}
int incrementingStat = eventCode - 503;
int decrementingStat = eventCode - 510;
Stat incrementingStat = static_cast<Stat>(eventCode - 503);
Stat decrementingStat = static_cast<Stat>(eventCode - 510);
int v11 = 0;
@@ -4078,7 +4076,7 @@ static int characterEditorShowOptions()
if (gcdLoad(string4) == 0) {
critterUpdateDerivedStats(gDude);
pcStatsReset();
for (int stat = 0; stat < SAVEABLE_STAT_COUNT; stat++) {
for (Stat stat = STAT_FIRST; stat < SAVEABLE_STAT_COUNT; stat++) {
critterSetBonusStat(gDude, stat, 0);
}
perksReset();
@@ -4813,7 +4811,7 @@ static void characterEditorResetScreen()
characterEditorDrawGender();
characterEditorDrawOptionalTraits();
characterEditorDrawSkills(0);
characterEditorDrawPrimaryStat(RENDER_ALL_STATS, 0, 0);
characterEditorDrawPrimaryStat(PRIMARY_STAT_COUNT, 0, 0);
characterEditorDrawDerivedStats();
characterEditorDrawCard();
windowRefresh(gCharacterEditorWindow);
@@ -5183,7 +5181,7 @@ static void characterEditorHandleInfoButtonPressed(int eventCode)
break;
}
characterEditorDrawPrimaryStat(RENDER_ALL_STATS, 0, 0);
characterEditorDrawPrimaryStat(PRIMARY_STAT_COUNT, 0, 0);
characterEditorDrawOptionalTraits();
characterEditorDrawSkills(0);
characterEditorDrawPcStats();
@@ -5394,7 +5392,7 @@ static void characterEditorToggleTaggedSkill(Skill skill)
gCharacterEditorTaggedSkillCount = insertionIndex;
characterEditorSelectedItem = static_cast<Editor>(skill + EDITOR_FIRST_SKILL);
characterEditorDrawPrimaryStat(RENDER_ALL_STATS, 0, 0);
characterEditorDrawPrimaryStat(PRIMARY_STAT_COUNT, 0, 0);
characterEditorDrawDerivedStats();
characterEditorDrawSkills(2);
characterEditorDrawCard();
@@ -5525,7 +5523,7 @@ static void characterEditorToggleOptionalTrait(int trait)
characterEditorDrawSkills(0);
critterUpdateDerivedStats(gDude);
characterEditorDrawBigNumber(126, 282, 0, gCharacterEditorRemainingCharacterPoints, 0, gCharacterEditorWindow);
characterEditorDrawPrimaryStat(RENDER_ALL_STATS, false, 0);
characterEditorDrawPrimaryStat(PRIMARY_STAT_COUNT, false, 0);
characterEditorDrawDerivedStats();
characterEditorDrawCard();
windowRefresh(gCharacterEditorWindow);
@@ -5728,7 +5726,7 @@ void characterEditorDisplayStats()
critterAdjustHitPoints(gDude, 0);
characterEditorDrawSkills(0);
characterEditorDrawPrimaryStat(RENDER_ALL_STATS, 0, 0);
characterEditorDrawPrimaryStat(PRIMARY_STAT_COUNT, 0, 0);
characterEditorDrawPcStats();
characterEditorDrawDerivedStats();
characterEditorDrawFolders();
@@ -6020,7 +6018,7 @@ static int perkDialogShow()
}
characterEditorDrawSkills(0);
characterEditorDrawPrimaryStat(RENDER_ALL_STATS, 0, 0);
characterEditorDrawPrimaryStat(PRIMARY_STAT_COUNT, 0, 0);
characterEditorDrawPcStats();
characterEditorDrawDerivedStats();
characterEditorDrawFolders();
@@ -6802,10 +6800,10 @@ static void _pop_perks()
// 0x43DF50 is_supper_bonus
static int _is_supper_bonus()
{
for (int stat = 0; stat < 7; stat++) {
int v1 = critterGetBaseStatWithTraitModifier(gDude, stat);
int v2 = critterGetBonusStat(gDude, stat);
if (v1 + v2 > 10) {
for (Stat stat = STAT_FIRST; stat < PRIMARY_STAT_COUNT; stat++) {
int baseStat = critterGetBaseStatWithTraitModifier(gDude, stat);
int bonusStat = critterGetBonusStat(gDude, stat);
if (baseStat + bonusStat > 10) {
return 1;
}
}
+23 -8
View File
@@ -67,12 +67,27 @@ namespace fallout {
#define CS_WINDOW_SECONDARY_STAT_MID_X (379)
#define CS_WINDOW_BIO_X (438)
typedef enum PremadeCharacter {
enum PremadeCharacter : int {
PREMADE_CHARACTER_NARG,
PREMADE_CHARACTER_CHITSA,
PREMADE_CHARACTER_MINGUN,
PREMADE_CHARACTER_COUNT,
} PremadeCharacter;
PREMADE_CHARACTER_FIRST = PREMADE_CHARACTER_NARG
};
inline PremadeCharacter operator++(PremadeCharacter& e, int)
{
PremadeCharacter result = e;
e = static_cast<PremadeCharacter>(static_cast<int>(e) + 1);
return result;
}
inline PremadeCharacter operator--(PremadeCharacter& e, int)
{
PremadeCharacter result = e;
e = static_cast<PremadeCharacter>(static_cast<int>(e) - 1);
return result;
}
typedef struct PremadeCharacterDescription {
char fileName[20];
@@ -91,7 +106,7 @@ static bool characterSelectorWindowFatalError(bool result);
static void premadeCharactersLocalizePath(char* path);
// 0x51C84C premade_index
static int gCurrentPremadeCharacter = PREMADE_CHARACTER_NARG;
static PremadeCharacter gCurrentPremadeCharacter = PREMADE_CHARACTER_NARG;
// 0x51C850 premade_characters
static PremadeCharacterDescription gPremadeCharacterDescriptions[PREMADE_CHARACTER_COUNT] = {
@@ -223,9 +238,9 @@ int characterSelectorOpen()
soundPlayFile("ib2p1xx1");
// FALLTHROUGH
case 500:
gCurrentPremadeCharacter -= 1;
if (gCurrentPremadeCharacter < 0) {
gCurrentPremadeCharacter = gPremadeCharacterCount - 1;
gCurrentPremadeCharacter--;
if (gCurrentPremadeCharacter < PREMADE_CHARACTER_FIRST) {
gCurrentPremadeCharacter--;
}
characterSelectorWindowRefresh();
@@ -234,9 +249,9 @@ int characterSelectorOpen()
soundPlayFile("ib2p1xx1");
// FALLTHROUGH
case 501:
gCurrentPremadeCharacter += 1;
gCurrentPremadeCharacter++;
if (gCurrentPremadeCharacter >= gPremadeCharacterCount) {
gCurrentPremadeCharacter = 0;
gCurrentPremadeCharacter = PREMADE_CHARACTER_FIRST;
}
characterSelectorWindowRefresh();
+731 -731
View File
File diff suppressed because it is too large Load Diff
+2 -1
View File
@@ -2,6 +2,7 @@
#define COMBAT_DEFS_H
#include "obj_types.h"
#include "stat_defs.h"
#define EXPLOSION_TARGET_COUNT (6)
@@ -229,7 +230,7 @@ typedef union CriticalHitDescription {
// Stat to check to upgrade this critical hit to massive critical hit or
// -1 if there is no massive critical hit.
int massiveCriticalStat;
Stat massiveCriticalStat;
// Bonus/penalty to massive critical stat.
int massiveCriticalStatModifier;
+1 -1
View File
@@ -107,7 +107,7 @@ static const int gRadiationEnduranceModifiers[RADIATION_LEVEL_COUNT] = {
// [RADIATION_EFFECT_PRIMARY_STAT_COUNT] for more info.
//
// 0x518358 rad_stat
static const int gRadiationEffectStats[RADIATION_EFFECT_COUNT] = {
static const Stat gRadiationEffectStats[RADIATION_EFFECT_COUNT] = {
STAT_STRENGTH,
STAT_PERCEPTION,
STAT_ENDURANCE,
+23
View File
@@ -4,6 +4,7 @@
#include "combat_defs.h"
#include "object.h"
#include "proto_types.h"
#include "stat_defs.h"
#include <setjmp.h>
#include <vector>
@@ -323,6 +324,28 @@ inline Skill programStackPopEnum(Program* program)
return static_cast<Skill>(skill);
}
template <>
inline Stat programStackPopEnum(Program* program)
{
int stat = programStackPopInteger(program);
if (!statIsValid(stat)) {
programPrintError("invalid stat %d", stat);
}
return static_cast<Stat>(stat);
}
template <>
inline PcStat programStackPopEnum(Program* program)
{
int pcStat = programStackPopInteger(program);
if (!pcStatIsValid(pcStat)) {
programPrintError("invalid pc stat %d", pcStat);
}
return static_cast<PcStat>(pcStat);
}
void programReturnStackPushValue(Program* program, ProgramValue& programValue);
void programReturnStackPushInteger(Program* program, int value);
void programReturnStackPushPointer(Program* program, void* value);
+5 -5
View File
@@ -638,7 +638,7 @@ static void opSkillContest(Program* program)
static void opDoCheck(Program* program)
{
int mod = programStackPopInteger(program);
int stat = programStackPopInteger(program);
Stat stat = programStackPopEnum<Stat>(program);
Object* object = static_cast<Object*>(programStackPopPointer(program));
int roll = 0;
@@ -1292,7 +1292,7 @@ static void opGetItemType(Program* program)
// 0x455C10 op_get_critter_stat
static void opGetCritterStat(Program* program)
{
int stat = programStackPopInteger(program);
Stat stat = programStackPopEnum<Stat>(program);
Object* object = static_cast<Object*>(programStackPopPointer(program));
int value = -1;
@@ -1313,7 +1313,7 @@ static void opGetCritterStat(Program* program)
static void opSetCritterStat(Program* program)
{
int value = programStackPopInteger(program);
int stat = programStackPopInteger(program);
Stat stat = programStackPopEnum<Stat>(program);
Object* object = static_cast<Object*>(programStackPopPointer(program));
int result = 0;
@@ -4887,9 +4887,9 @@ static void opGetObjectName(Program* program)
// 0x45CD64 op_get_pc_stat
static void opGetPcStat(Program* program)
{
int data = programStackPopInteger(program);
PcStat pcStat = programStackPopEnum<PcStat>(program);
int value = pcGetStat(data);
int value = pcGetStat(pcStat);
programStackPushInteger(program, value);
}
+7 -7
View File
@@ -3055,8 +3055,8 @@ void adjustCritterStatsOnArmorChange(Object* critter, Object* oldArmor, Object*
int newArmorClass = armorGetArmorClass(newArmor);
critterSetBonusStat(critter, STAT_ARMOR_CLASS, armorClassBonus - oldArmorClass + newArmorClass);
int damageResistanceStat = STAT_DAMAGE_RESISTANCE;
int damageThresholdStat = STAT_DAMAGE_THRESHOLD;
Stat damageResistanceStat = STAT_DAMAGE_RESISTANCE;
Stat damageThresholdStat = STAT_DAMAGE_THRESHOLD;
for (DamageType damageType = DAMAGE_TYPE_FIRST; damageType < DAMAGE_TYPE_COUNT; damageType++) {
int damageResistanceBonus = critterGetBonusStat(critter, damageResistanceStat);
int oldArmorDamageResistance = armorGetDamageResistance(oldArmor, damageType);
@@ -3068,8 +3068,8 @@ void adjustCritterStatsOnArmorChange(Object* critter, Object* oldArmor, Object*
int newArmorDamageThreshold = armorGetDamageThreshold(newArmor, damageType);
critterSetBonusStat(critter, damageThresholdStat, damageThresholdBonus - oldArmorDamageThreshold + newArmorDamageThreshold);
damageResistanceStat += 1;
damageThresholdStat += 1;
damageResistanceStat++;
damageThresholdStat++;
}
if (objectIsPartyMember(critter)) {
@@ -3412,10 +3412,10 @@ int objectGetCarriedQuantityByPid(Object* object, int pid)
// 0x471D5C display_stats
static void inventoryRenderSummary()
{
int summaryStats[7];
Stat summaryStats[7];
memcpy(summaryStats, gSummaryStats, sizeof(summaryStats));
int summaryStats2[7];
Stat summaryStats2[7];
memcpy(summaryStats2, gSummaryStats2, sizeof(summaryStats2));
char formattedText[80];
@@ -3454,7 +3454,7 @@ static void inventoryRenderSummary()
MessageListItem messageListItem;
int offset = pitch * 2 * fontGetLineHeight() + pitch * INVENTORY_SUMMARY_Y + summaryX;
for (int stat = 0; stat < PRIMARY_STAT_COUNT; stat++) {
for (Stat stat = STAT_FIRST; stat < PRIMARY_STAT_COUNT; stat++) {
messageListItem.num = stat;
if (messageListGetItem(&gInventoryMessageList, &messageListItem)) {
fontDrawText(windowBuffer + offset, messageListItem.text, 80, pitch, COLOR_GREEN);
+8 -8
View File
@@ -51,8 +51,8 @@ static int _item_move_func(Object* source, Object* target, Object* item, int qua
static bool _item_identical(Object* item1, Object* item2);
static int stealthBoyTurnOn(Object* object);
static int stealthBoyTurnOff(Object* critter, Object* item);
static int _insert_drug_effect(Object* critter, Object* item, int duration, int* stats, int* mods);
static void _perform_drug_effect(Object* critter, int* stats, int* mods, bool isImmediate);
static int _insert_drug_effect(Object* critter, Object* item, int duration, Stat* stats, int* mods);
static void _perform_drug_effect(Object* critter, Stat* stats, int* mods, bool isImmediate);
static bool _drug_effect_allowed(Object* critter, int pid);
static int _insert_withdrawal(Object* obj, int active, int duration, int perk, int pid);
static int _item_wd_clear_all(Object* obj, void* data);
@@ -2706,7 +2706,7 @@ int ammoGetDamageDivisor(Object* armor)
// [duration] is in minutes
//
// 0x479B44
static int _insert_drug_effect(Object* critter, Object* item, int duration, int* stats, int* mods)
static int _insert_drug_effect(Object* critter, Object* item, int duration, Stat* stats, int* mods)
{
int index;
for (index = 0; index < 3; index++) {
@@ -2747,7 +2747,7 @@ static int _insert_drug_effect(Object* critter, Object* item, int duration, int*
}
// 0x479C20
static void _perform_drug_effect(Object* critter, int* stats, int* mods, bool isImmediate)
static void _perform_drug_effect(Object* critter, Stat* stats, int* mods, bool isImmediate)
{
MessageListItem messageListItem;
const char* name;
@@ -2766,8 +2766,8 @@ static void _perform_drug_effect(Object* critter, int* stats, int* mods, bool is
for (int index = startIndex; index < 3; index++) {
int oldStatBonus;
int statBonus;
int stat = stats[index];
if (stat == -1) {
Stat stat = stats[index];
if (stat == STAT_INVALID) {
continue;
}
@@ -3008,7 +3008,7 @@ int drugEffectEventRead(File* stream, void** dataPtr)
return -1;
}
if (fileReadInt32List(stream, drugEffectEvent->stats, 3) == -1) goto err;
if (fileReadInt32List(stream, reinterpret_cast<int*>(drugEffectEvent->stats), 3) == -1) goto err;
if (fileReadInt32List(stream, drugEffectEvent->modifiers, 3) == -1) goto err;
*dataPtr = drugEffectEvent;
@@ -3025,7 +3025,7 @@ int drugEffectEventWrite(File* stream, void* data)
{
DrugEffectEvent* drugEffectEvent = (DrugEffectEvent*)data;
if (fileWriteInt32List(stream, drugEffectEvent->stats, 3) == -1) return -1;
if (fileWriteInt32List(stream, reinterpret_cast<int*>(drugEffectEvent->stats), 3) == -1) return -1;
if (fileWriteInt32List(stream, drugEffectEvent->modifiers, 3) == -1) return -1;
return 0;
+2 -2
View File
@@ -1609,11 +1609,11 @@ static int _partyMemberCopyLevelInfo(Object* critter, int stagePid)
int maxHp = critterGetStat(critter, STAT_MAXIMUM_HIT_POINTS);
critterAdjustHitPoints(critter, maxHp);
for (int stat = 0; stat < SPECIAL_STAT_COUNT; stat++) {
for (Stat stat = STAT_FIRST; stat < SPECIAL_STAT_COUNT; stat++) {
proto->critter.data.baseStats[stat] = stageProto->critter.data.baseStats[stat];
}
for (int stat = 0; stat < SPECIAL_STAT_COUNT; stat++) {
for (Stat stat = STAT_FIRST; stat < SPECIAL_STAT_COUNT; stat++) {
proto->critter.data.bonusStats[stat] = stageProto->critter.data.bonusStats[stat];
}
+123 -123
View File
@@ -27,7 +27,7 @@ typedef struct PerkDescription {
int maxRank;
int minLevel;
// Critter stat to modify for every perk rank.
int stat;
Stat stat;
// Stat modifier for every perk rank.
int statModifier;
// Skill number, normally. If bit 0x4000000 is set, will be treated as global var number instead.
@@ -54,125 +54,125 @@ static void perkResetRanks();
// 0x519DCC perk_data
static PerkDescription gPerkDescriptions[PERK_COUNT] = {
{ nullptr, nullptr, 72, 1, 3, -1, 0, -1, 0, 0, -1, 0, 0, 5, 0, 0, 0, 0, 0 },
{ nullptr, nullptr, 73, 1, 15, -1, 0, -1, 0, 0, -1, 0, 0, 0, 0, 0, 0, 6, 0 },
{ nullptr, nullptr, 74, 3, 3, 11, 2, -1, 0, 0, -1, 0, 6, 0, 0, 0, 0, 6, 0 },
{ nullptr, nullptr, 75, 2, 6, -1, 0, -1, 0, 0, -1, 0, 0, 0, 0, 0, 0, 5, 0 },
{ nullptr, nullptr, 76, 2, 6, -1, 0, -1, 0, 0, -1, 0, 0, 0, 0, 0, 0, 6, 6 },
{ nullptr, nullptr, 77, 1, 15, -1, 0, -1, 0, 0, -1, 0, 0, 6, 0, 0, 6, 7, 0 },
{ nullptr, nullptr, 78, 3, 3, 13, 2, -1, 0, 0, -1, 0, 0, 6, 0, 0, 0, 0, 0 },
{ nullptr, nullptr, 79, 3, 3, 14, 2, -1, 0, 0, -1, 0, 0, 0, 6, 0, 0, 0, 0 },
{ nullptr, nullptr, 80, 3, 6, 15, 5, -1, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 6 },
{ nullptr, nullptr, 81, 1, 3, -1, 0, -1, 0, 0, -1, 0, 0, 6, 0, 0, 0, 0, 0 },
{ nullptr, nullptr, 82, 3, 3, -1, 0, -1, 0, 0, -1, 0, 0, 0, 0, 6, 0, 0, 0 },
{ nullptr, nullptr, 83, 2, 6, 31, 15, -1, 0, 0, -1, 0, 0, 0, 6, 0, 4, 0, 0 },
{ nullptr, nullptr, 84, 3, 3, 24, 10, -1, 0, 0, -1, 0, 0, 0, 6, 0, 0, 0, 6 },
{ nullptr, nullptr, 85, 3, 3, 12, 50, -1, 0, 0, -1, 0, 6, 0, 6, 0, 0, 0, 0 },
{ nullptr, nullptr, 86, 1, 9, -1, 0, -1, 0, 0, -1, 0, 0, 7, 0, 0, 6, 0, 0 },
{ nullptr, nullptr, 87, 1, 6, -1, 0, 8, 50, 0, -1, 0, 0, 0, 0, 0, 0, 6, 0 },
{ nullptr, nullptr, 88, 1, 3, -1, 0, 17, 40, 0, -1, 0, 0, 0, 6, 0, 6, 0, 0 },
{ nullptr, nullptr, 89, 1, 12, -1, 0, 15, 75, 0, -1, 0, 0, 0, 0, 7, 0, 0, 0 },
{ nullptr, nullptr, 90, 3, 6, -1, 0, -1, 0, 0, -1, 0, 0, 0, 0, 0, 6, 0, 0 },
{ nullptr, nullptr, 91, 2, 3, -1, 0, 6, 40, 0, -1, 0, 0, 7, 0, 0, 5, 6, 0 },
{ nullptr, nullptr, 92, 1, 6, -1, 0, -1, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 8 },
{ nullptr, nullptr, 93, 1, 9, 16, 20, -1, 0, 0, -1, 0, 0, 6, 0, 0, 0, 4, 6 },
{ nullptr, nullptr, 94, 1, 6, -1, 0, -1, 0, 0, -1, 0, 0, 7, 0, 0, 5, 0, 0 },
{ nullptr, nullptr, 95, 1, 24, -1, 0, 3, 80, 0, -1, 0, 8, 0, 0, 0, 0, 8, 0 },
{ nullptr, nullptr, 96, 1, 24, -1, 0, 0, 80, 0, -1, 0, 0, 8, 0, 0, 0, 8, 0 },
{ nullptr, nullptr, 97, 1, 18, -1, 0, 8, 80, 2, 3, 80, 0, 0, 0, 0, 0, 10, 0 },
{ nullptr, nullptr, 98, 2, 12, 8, 1, -1, 0, 0, -1, 0, 0, 0, 0, 0, 0, 5, 0 },
{ nullptr, nullptr, 99, 1, 310, -1, 0, -1, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0 },
{ nullptr, nullptr, 100, 2, 12, -1, 0, -1, 0, 0, -1, 0, 0, 0, 4, 0, 0, 0, 0 },
{ nullptr, nullptr, 101, 1, 9, 9, 5, -1, 0, 0, -1, 0, 0, 0, 0, 0, 0, 6, 0 },
{ nullptr, nullptr, 102, 2, 6, 32, 25, -1, 0, 0, -1, 0, 0, 0, 3, 0, 0, 0, 0 },
{ nullptr, nullptr, 103, 1, 12, -1, 0, 13, 40, 1, 12, 40, 0, 0, 0, 0, 0, 0, 0 },
{ nullptr, nullptr, 104, 1, 12, -1, 0, 6, 40, 1, 7, 40, 0, 0, 0, 0, 0, 0, 0 },
{ nullptr, nullptr, 105, 1, 12, -1, 0, 10, 50, 2, 9, 50, 0, 0, 0, 0, 0, 0, 0 },
{ nullptr, nullptr, 106, 1, 9, -1, 0, 14, 50, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0 },
{ nullptr, nullptr, 107, 3, 6, -1, 0, -1, 0, 0, -1, 0, -9, 0, 0, 0, 0, 0, 0 },
{ nullptr, nullptr, 108, 1, 310, -1, 0, -1, 0, 0, -1, 0, 0, 4, 0, 0, 0, 0, 0 },
{ nullptr, nullptr, 109, 1, 15, -1, 0, 10, 80, 0, -1, 0, 0, 0, 0, 0, 0, 8, 0 },
{ nullptr, nullptr, 110, 1, 6, -1, 0, 8, 60, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0 },
{ nullptr, nullptr, 111, 1, 12, -1, 0, -1, 0, 0, -1, 0, 0, 0, 0, 10, 0, 0, 0 },
{ nullptr, nullptr, 112, 1, 310, -1, 0, -1, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 8 },
{ nullptr, nullptr, 113, 1, 9, -1, 0, -1, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0 },
{ nullptr, nullptr, 114, 1, 310, -1, 0, -1, 0, 0, -1, 0, 0, 0, 5, 0, 0, 0, 0 },
{ nullptr, nullptr, 115, 2, 6, -1, 0, 17, 40, 0, -1, 0, 0, 0, 6, 0, 0, 0, 0 },
{ nullptr, nullptr, 116, 1, 310, -1, 0, 17, 25, 0, -1, 0, 0, 0, 0, 0, 5, 0, 0 },
{ nullptr, nullptr, 117, 1, 3, -1, 0, -1, 0, 0, -1, 0, 0, 7, 0, 0, 0, 0, 0 },
{ nullptr, nullptr, 118, 1, 9, -1, 0, -1, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 4 },
{ nullptr, nullptr, 119, 1, 6, -1, 0, -1, 0, 0, -1, 0, 0, 6, 0, 0, 0, 0, 0 },
{ nullptr, nullptr, 120, 1, 3, -1, 0, -1, 0, 0, -1, 0, 0, 0, 0, 0, 0, 5, 0 },
{ nullptr, nullptr, 121, 3, 3, -1, 0, -1, 0, 0, -1, 0, 0, 0, 0, 0, 4, 0, 0 },
{ nullptr, nullptr, 122, 3, 3, -1, 0, -1, 0, 0, -1, 0, 0, 0, 0, 0, 4, 0, 0 },
{ nullptr, nullptr, 123, 1, 12, -1, 0, -1, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0 },
{ nullptr, nullptr, 124, 1, 9, -1, 0, -1, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0 },
{ nullptr, nullptr, 125, -1, 1, -1, 0, -1, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0 },
{ nullptr, nullptr, 126, -1, 1, -1, 0, -1, 0, 0, -1, 0, -2, 0, -2, 0, 0, -3, 0 },
{ nullptr, nullptr, 127, -1, 1, -1, 0, -1, 0, 0, -1, 0, 0, 0, 0, 0, -3, -2, 0 },
{ nullptr, nullptr, 128, -1, 1, -1, 0, -1, 0, 0, -1, 0, 0, 0, 0, 0, -2, 0, 0 },
{ nullptr, nullptr, 129, -1, 1, 31, -20, -1, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0 },
{ nullptr, nullptr, 130, -1, 1, -1, 0, -1, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0 },
{ nullptr, nullptr, 131, -1, 1, -1, 0, -1, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0 },
{ nullptr, nullptr, 132, -1, 1, -1, 0, -1, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0 },
{ nullptr, nullptr, 133, -1, 1, -1, 0, -1, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0 },
{ nullptr, nullptr, 134, -1, 1, 31, 30, -1, 0, 0, -1, 0, 3, 0, 0, 0, 0, 0, 0 },
{ nullptr, nullptr, 135, -1, 1, 31, 20, -1, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0 },
{ nullptr, nullptr, 136, -1, 1, -1, 0, -1, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0 },
{ nullptr, nullptr, 137, -1, 1, -1, 0, -1, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0 },
{ nullptr, nullptr, 138, -1, 1, -1, 0, -1, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0 },
{ nullptr, nullptr, 139, -1, 1, -1, 0, -1, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0 },
{ nullptr, nullptr, 140, -1, 1, 31, 60, -1, 0, 0, -1, 0, 4, 0, 0, 0, 0, 0, 0 },
{ nullptr, nullptr, 141, -1, 1, 31, 75, -1, 0, 0, -1, 0, 4, 0, 0, 0, 0, 0, 0 },
{ nullptr, nullptr, 136, -1, 1, 8, -1, -1, 0, 0, -1, 0, -1, -1, 0, 0, 0, 0, 0 },
{ nullptr, nullptr, 149, -1, 1, -1, 0, -1, 0, 0, -1, 0, 0, -2, 0, 0, -1, 0, -1 },
{ nullptr, nullptr, 154, -1, 1, -1, 0, -1, 0, 0, -1, 0, 0, 0, 0, 2, 0, 0, 0 },
{ nullptr, nullptr, 158, -1, 1, -1, 0, -1, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0 },
{ nullptr, nullptr, 157, -1, 1, -1, 0, -1, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0 },
{ nullptr, nullptr, 157, -1, 1, 3, -1, -1, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0 },
{ nullptr, nullptr, 168, -1, 1, -1, 0, -1, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0 },
{ nullptr, nullptr, 168, -1, 1, 3, -1, -1, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0 },
{ nullptr, nullptr, 172, -1, 1, -1, 0, -1, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0 },
{ nullptr, nullptr, 155, 1, 6, -1, 0, -1, 0, 0, -1, 0, -10, 0, 0, 0, 0, 0, 0 },
{ nullptr, nullptr, 156, 1, 3, -1, 0, -1, 0, 0, -1, 0, 0, 6, 0, 0, 0, 0, 0 },
{ nullptr, nullptr, 122, 1, 3, -1, 0, -1, 0, 0, -1, 0, 0, 0, 0, 0, 6, 0, 0 },
{ nullptr, nullptr, 39, 1, 9, -1, 0, 11, 75, 0, -1, 0, 0, 0, 0, 0, 0, 4, 0 },
{ nullptr, nullptr, 44, 1, 6, -1, 0, 16, 50, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0 },
{ nullptr, nullptr, 0, 1, 12, -1, 0, -1, 0, 0, -1, 0, -10, 0, 0, 0, 0, 0, 0 },
{ nullptr, nullptr, 1, 1, 12, -1, 0, -1, 0, 0, -1, 0, 0, -10, 0, 0, 0, 0, 0 },
{ nullptr, nullptr, 2, 1, 12, -1, 0, -1, 0, 0, -1, 0, 0, 0, -10, 0, 0, 0, 0 },
{ nullptr, nullptr, 3, 1, 12, -1, 0, -1, 0, 0, -1, 0, 0, 0, 0, -10, 0, 0, 0 },
{ nullptr, nullptr, 4, 1, 12, -1, 0, -1, 0, 0, -1, 0, 0, 0, 0, 0, -10, 0, 0 },
{ nullptr, nullptr, 5, 1, 12, -1, 0, -1, 0, 0, -1, 0, 0, 0, 0, 0, 0, -10, 0 },
{ nullptr, nullptr, 6, 1, 12, -1, 0, -1, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, -10 },
{ nullptr, nullptr, 160, 1, 6, -1, 0, 10, 50, 2, 0x4000000, 50, 0, 0, 0, 0, 0, 0, 0 },
{ nullptr, nullptr, 161, 1, 3, -1, 0, -1, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0 },
{ nullptr, nullptr, 159, 1, 12, -1, 0, 3, 75, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0 },
{ nullptr, nullptr, 163, 1, 3, -1, 0, -1, 0, 0, -1, 0, 0, 0, 5, 0, 0, 5, 0 },
{ nullptr, nullptr, 162, 1, 9, -1, 0, -1, 0, 0, -1, 0, 0, 0, 0, 6, 0, 0, 0 },
{ nullptr, nullptr, 164, 1, 9, -1, 0, -1, 0, 0, -1, 0, 0, 0, 0, 0, 0, 5, 5 },
{ nullptr, nullptr, 165, 1, 12, -1, 0, 7, 60, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0 },
{ nullptr, nullptr, 166, 1, 6, -1, 0, -1, 0, 0, -1, 0, 0, 0, 0, -10, 0, 0, 0 },
{ nullptr, nullptr, 43, 1, 6, -1, 0, 15, 50, 2, 14, 50, 0, 0, 0, 0, 0, 0, 0 },
{ nullptr, nullptr, 167, 1, 6, 12, 50, -1, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0 },
{ nullptr, nullptr, 169, 1, 9, -1, 0, 1, 75, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0 },
{ nullptr, nullptr, 170, 1, 6, -1, 0, -1, 0, 0, -1, 0, 0, 0, 0, 0, 0, 5, 0 },
{ nullptr, nullptr, 121, 1, 6, -1, 0, 15, 50, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0 },
{ nullptr, nullptr, 171, 1, 3, -1, 0, -1, 0, 0, -1, 0, 6, 0, 0, 0, 0, 0, 0 },
{ nullptr, nullptr, 38, 1, 3, -1, 0, -1, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0 },
{ nullptr, nullptr, 173, 1, 12, -1, 0, -1, 0, 0, -1, 0, -7, 0, 0, 0, 0, 5, 0 },
{ nullptr, nullptr, 104, -1, 1, -1, 0, 7, 75, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0 },
{ nullptr, nullptr, 142, -1, 1, -1, 0, -1, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0 },
{ nullptr, nullptr, 142, -1, 1, -1, 0, -1, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0 },
{ nullptr, nullptr, 52, -1, 1, -1, 0, -1, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0 },
{ nullptr, nullptr, 52, -1, 1, -1, 0, -1, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0 },
{ nullptr, nullptr, 104, -1, 1, -1, 0, -1, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0 },
{ nullptr, nullptr, 104, -1, 1, -1, 0, -1, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0 },
{ nullptr, nullptr, 35, -1, 1, -1, 0, -1, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0 },
{ nullptr, nullptr, 35, -1, 1, -1, 0, -1, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0 },
{ nullptr, nullptr, 154, -1, 1, -1, 0, -1, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0 },
{ nullptr, nullptr, 154, -1, 1, -1, 0, -1, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0 },
{ nullptr, nullptr, 64, -1, 1, -1, 0, -1, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0 },
{ nullptr, nullptr, 72, 1, 3, STAT_INVALID, 0, -1, 0, 0, -1, 0, 0, 5, 0, 0, 0, 0, 0 },
{ nullptr, nullptr, 73, 1, 15, STAT_INVALID, 0, -1, 0, 0, -1, 0, 0, 0, 0, 0, 0, 6, 0 },
{ nullptr, nullptr, 74, 3, 3, STAT_MELEE_DAMAGE, 2, -1, 0, 0, -1, 0, 6, 0, 0, 0, 0, 6, 0 },
{ nullptr, nullptr, 75, 2, 6, STAT_INVALID, 0, -1, 0, 0, -1, 0, 0, 0, 0, 0, 0, 5, 0 },
{ nullptr, nullptr, 76, 2, 6, STAT_INVALID, 0, -1, 0, 0, -1, 0, 0, 0, 0, 0, 0, 6, 6 },
{ nullptr, nullptr, 77, 1, 15, STAT_INVALID, 0, -1, 0, 0, -1, 0, 0, 6, 0, 0, 6, 7, 0 },
{ nullptr, nullptr, 78, 3, 3, STAT_SEQUENCE, 2, -1, 0, 0, -1, 0, 0, 6, 0, 0, 0, 0, 0 },
{ nullptr, nullptr, 79, 3, 3, STAT_HEALING_RATE, 2, -1, 0, 0, -1, 0, 0, 0, 6, 0, 0, 0, 0 },
{ nullptr, nullptr, 80, 3, 6, STAT_CRITICAL_CHANCE, 5, -1, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 6 },
{ nullptr, nullptr, 81, 1, 3, STAT_INVALID, 0, -1, 0, 0, -1, 0, 0, 6, 0, 0, 0, 0, 0 },
{ nullptr, nullptr, 82, 3, 3, STAT_INVALID, 0, -1, 0, 0, -1, 0, 0, 0, 0, 6, 0, 0, 0 },
{ nullptr, nullptr, 83, 2, 6, STAT_RADIATION_RESISTANCE, 15, -1, 0, 0, -1, 0, 0, 0, 6, 0, 4, 0, 0 },
{ nullptr, nullptr, 84, 3, 3, STAT_DAMAGE_RESISTANCE, 10, -1, 0, 0, -1, 0, 0, 0, 6, 0, 0, 0, 6 },
{ nullptr, nullptr, 85, 3, 3, STAT_CARRY_WEIGHT, 50, -1, 0, 0, -1, 0, 6, 0, 6, 0, 0, 0, 0 },
{ nullptr, nullptr, 86, 1, 9, STAT_INVALID, 0, -1, 0, 0, -1, 0, 0, 7, 0, 0, 6, 0, 0 },
{ nullptr, nullptr, 87, 1, 6, STAT_INVALID, 0, 8, 50, 0, -1, 0, 0, 0, 0, 0, 0, 6, 0 },
{ nullptr, nullptr, 88, 1, 3, STAT_INVALID, 0, 17, 40, 0, -1, 0, 0, 0, 6, 0, 6, 0, 0 },
{ nullptr, nullptr, 89, 1, 12, STAT_INVALID, 0, 15, 75, 0, -1, 0, 0, 0, 0, 7, 0, 0, 0 },
{ nullptr, nullptr, 90, 3, 6, STAT_INVALID, 0, -1, 0, 0, -1, 0, 0, 0, 0, 0, 6, 0, 0 },
{ nullptr, nullptr, 91, 2, 3, STAT_INVALID, 0, 6, 40, 0, -1, 0, 0, 7, 0, 0, 5, 6, 0 },
{ nullptr, nullptr, 92, 1, 6, STAT_INVALID, 0, -1, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 8 },
{ nullptr, nullptr, 93, 1, 9, STAT_BETTER_CRITICALS, 20, -1, 0, 0, -1, 0, 0, 6, 0, 0, 0, 4, 6 },
{ nullptr, nullptr, 94, 1, 6, STAT_INVALID, 0, -1, 0, 0, -1, 0, 0, 7, 0, 0, 5, 0, 0 },
{ nullptr, nullptr, 95, 1, 24, STAT_INVALID, 0, 3, 80, 0, -1, 0, 8, 0, 0, 0, 0, 8, 0 },
{ nullptr, nullptr, 96, 1, 24, STAT_INVALID, 0, 0, 80, 0, -1, 0, 0, 8, 0, 0, 0, 8, 0 },
{ nullptr, nullptr, 97, 1, 18, STAT_INVALID, 0, 8, 80, 2, 3, 80, 0, 0, 0, 0, 0, 10, 0 },
{ nullptr, nullptr, 98, 2, 12, STAT_MAXIMUM_ACTION_POINTS, 1, -1, 0, 0, -1, 0, 0, 0, 0, 0, 0, 5, 0 },
{ nullptr, nullptr, 99, 1, 310, STAT_INVALID, 0, -1, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0 },
{ nullptr, nullptr, 100, 2, 12, STAT_INVALID, 0, -1, 0, 0, -1, 0, 0, 0, 4, 0, 0, 0, 0 },
{ nullptr, nullptr, 101, 1, 9, STAT_ARMOR_CLASS, 5, -1, 0, 0, -1, 0, 0, 0, 0, 0, 0, 6, 0 },
{ nullptr, nullptr, 102, 2, 6, STAT_POISON_RESISTANCE, 25, -1, 0, 0, -1, 0, 0, 0, 3, 0, 0, 0, 0 },
{ nullptr, nullptr, 103, 1, 12, STAT_INVALID, 0, 13, 40, 1, 12, 40, 0, 0, 0, 0, 0, 0, 0 },
{ nullptr, nullptr, 104, 1, 12, STAT_INVALID, 0, 6, 40, 1, 7, 40, 0, 0, 0, 0, 0, 0, 0 },
{ nullptr, nullptr, 105, 1, 12, STAT_INVALID, 0, 10, 50, 2, 9, 50, 0, 0, 0, 0, 0, 0, 0 },
{ nullptr, nullptr, 106, 1, 9, STAT_INVALID, 0, 14, 50, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0 },
{ nullptr, nullptr, 107, 3, 6, STAT_INVALID, 0, -1, 0, 0, -1, 0, -9, 0, 0, 0, 0, 0, 0 },
{ nullptr, nullptr, 108, 1, 310, STAT_INVALID, 0, -1, 0, 0, -1, 0, 0, 4, 0, 0, 0, 0, 0 },
{ nullptr, nullptr, 109, 1, 15, STAT_INVALID, 0, 10, 80, 0, -1, 0, 0, 0, 0, 0, 0, 8, 0 },
{ nullptr, nullptr, 110, 1, 6, STAT_INVALID, 0, 8, 60, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0 },
{ nullptr, nullptr, 111, 1, 12, STAT_INVALID, 0, -1, 0, 0, -1, 0, 0, 0, 0, 10, 0, 0, 0 },
{ nullptr, nullptr, 112, 1, 310, STAT_INVALID, 0, -1, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 8 },
{ nullptr, nullptr, 113, 1, 9, STAT_INVALID, 0, -1, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0 },
{ nullptr, nullptr, 114, 1, 310, STAT_INVALID, 0, -1, 0, 0, -1, 0, 0, 0, 5, 0, 0, 0, 0 },
{ nullptr, nullptr, 115, 2, 6, STAT_INVALID, 0, 17, 40, 0, -1, 0, 0, 0, 6, 0, 0, 0, 0 },
{ nullptr, nullptr, 116, 1, 310, STAT_INVALID, 0, 17, 25, 0, -1, 0, 0, 0, 0, 0, 5, 0, 0 },
{ nullptr, nullptr, 117, 1, 3, STAT_INVALID, 0, -1, 0, 0, -1, 0, 0, 7, 0, 0, 0, 0, 0 },
{ nullptr, nullptr, 118, 1, 9, STAT_INVALID, 0, -1, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 4 },
{ nullptr, nullptr, 119, 1, 6, STAT_INVALID, 0, -1, 0, 0, -1, 0, 0, 6, 0, 0, 0, 0, 0 },
{ nullptr, nullptr, 120, 1, 3, STAT_INVALID, 0, -1, 0, 0, -1, 0, 0, 0, 0, 0, 0, 5, 0 },
{ nullptr, nullptr, 121, 3, 3, STAT_INVALID, 0, -1, 0, 0, -1, 0, 0, 0, 0, 0, 4, 0, 0 },
{ nullptr, nullptr, 122, 3, 3, STAT_INVALID, 0, -1, 0, 0, -1, 0, 0, 0, 0, 0, 4, 0, 0 },
{ nullptr, nullptr, 123, 1, 12, STAT_INVALID, 0, -1, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0 },
{ nullptr, nullptr, 124, 1, 9, STAT_INVALID, 0, -1, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0 },
{ nullptr, nullptr, 125, -1, 1, STAT_INVALID, 0, -1, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0 },
{ nullptr, nullptr, 126, -1, 1, STAT_INVALID, 0, -1, 0, 0, -1, 0, -2, 0, -2, 0, 0, -3, 0 },
{ nullptr, nullptr, 127, -1, 1, STAT_INVALID, 0, -1, 0, 0, -1, 0, 0, 0, 0, 0, -3, -2, 0 },
{ nullptr, nullptr, 128, -1, 1, STAT_INVALID, 0, -1, 0, 0, -1, 0, 0, 0, 0, 0, -2, 0, 0 },
{ nullptr, nullptr, 129, -1, 1, STAT_RADIATION_RESISTANCE, -20, -1, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0 },
{ nullptr, nullptr, 130, -1, 1, STAT_INVALID, 0, -1, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0 },
{ nullptr, nullptr, 131, -1, 1, STAT_INVALID, 0, -1, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0 },
{ nullptr, nullptr, 132, -1, 1, STAT_INVALID, 0, -1, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0 },
{ nullptr, nullptr, 133, -1, 1, STAT_INVALID, 0, -1, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0 },
{ nullptr, nullptr, 134, -1, 1, STAT_RADIATION_RESISTANCE, 30, -1, 0, 0, -1, 0, 3, 0, 0, 0, 0, 0, 0 },
{ nullptr, nullptr, 135, -1, 1, STAT_RADIATION_RESISTANCE, 20, -1, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0 },
{ nullptr, nullptr, 136, -1, 1, STAT_INVALID, 0, -1, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0 },
{ nullptr, nullptr, 137, -1, 1, STAT_INVALID, 0, -1, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0 },
{ nullptr, nullptr, 138, -1, 1, STAT_INVALID, 0, -1, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0 },
{ nullptr, nullptr, 139, -1, 1, STAT_INVALID, 0, -1, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0 },
{ nullptr, nullptr, 140, -1, 1, STAT_RADIATION_RESISTANCE, 60, -1, 0, 0, -1, 0, 4, 0, 0, 0, 0, 0, 0 },
{ nullptr, nullptr, 141, -1, 1, STAT_RADIATION_RESISTANCE, 75, -1, 0, 0, -1, 0, 4, 0, 0, 0, 0, 0, 0 },
{ nullptr, nullptr, 136, -1, 1, STAT_MAXIMUM_ACTION_POINTS, -1, -1, 0, 0, -1, 0, -1, -1, 0, 0, 0, 0, 0 },
{ nullptr, nullptr, 149, -1, 1, STAT_INVALID, 0, -1, 0, 0, -1, 0, 0, -2, 0, 0, -1, 0, -1 },
{ nullptr, nullptr, 154, -1, 1, STAT_INVALID, 0, -1, 0, 0, -1, 0, 0, 0, 0, 2, 0, 0, 0 },
{ nullptr, nullptr, 158, -1, 1, STAT_INVALID, 0, -1, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0 },
{ nullptr, nullptr, 157, -1, 1, STAT_INVALID, 0, -1, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0 },
{ nullptr, nullptr, 157, -1, 1, STAT_CHARISMA, -1, -1, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0 },
{ nullptr, nullptr, 168, -1, 1, STAT_INVALID, 0, -1, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0 },
{ nullptr, nullptr, 168, -1, 1, STAT_CHARISMA, -1, -1, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0 },
{ nullptr, nullptr, 172, -1, 1, STAT_INVALID, 0, -1, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0 },
{ nullptr, nullptr, 155, 1, 6, STAT_INVALID, 0, -1, 0, 0, -1, 0, -10, 0, 0, 0, 0, 0, 0 },
{ nullptr, nullptr, 156, 1, 3, STAT_INVALID, 0, -1, 0, 0, -1, 0, 0, 6, 0, 0, 0, 0, 0 },
{ nullptr, nullptr, 122, 1, 3, STAT_INVALID, 0, -1, 0, 0, -1, 0, 0, 0, 0, 0, 6, 0, 0 },
{ nullptr, nullptr, 39, 1, 9, STAT_INVALID, 0, 11, 75, 0, -1, 0, 0, 0, 0, 0, 0, 4, 0 },
{ nullptr, nullptr, 44, 1, 6, STAT_INVALID, 0, 16, 50, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0 },
{ nullptr, nullptr, 0, 1, 12, STAT_INVALID, 0, -1, 0, 0, -1, 0, -10, 0, 0, 0, 0, 0, 0 },
{ nullptr, nullptr, 1, 1, 12, STAT_INVALID, 0, -1, 0, 0, -1, 0, 0, -10, 0, 0, 0, 0, 0 },
{ nullptr, nullptr, 2, 1, 12, STAT_INVALID, 0, -1, 0, 0, -1, 0, 0, 0, -10, 0, 0, 0, 0 },
{ nullptr, nullptr, 3, 1, 12, STAT_INVALID, 0, -1, 0, 0, -1, 0, 0, 0, 0, -10, 0, 0, 0 },
{ nullptr, nullptr, 4, 1, 12, STAT_INVALID, 0, -1, 0, 0, -1, 0, 0, 0, 0, 0, -10, 0, 0 },
{ nullptr, nullptr, 5, 1, 12, STAT_INVALID, 0, -1, 0, 0, -1, 0, 0, 0, 0, 0, 0, -10, 0 },
{ nullptr, nullptr, 6, 1, 12, STAT_INVALID, 0, -1, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, -10 },
{ nullptr, nullptr, 160, 1, 6, STAT_INVALID, 0, 10, 50, 2, 0x4000000, 50, 0, 0, 0, 0, 0, 0, 0 },
{ nullptr, nullptr, 161, 1, 3, STAT_INVALID, 0, -1, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0 },
{ nullptr, nullptr, 159, 1, 12, STAT_INVALID, 0, 3, 75, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0 },
{ nullptr, nullptr, 163, 1, 3, STAT_INVALID, 0, -1, 0, 0, -1, 0, 0, 0, 5, 0, 0, 5, 0 },
{ nullptr, nullptr, 162, 1, 9, STAT_INVALID, 0, -1, 0, 0, -1, 0, 0, 0, 0, 6, 0, 0, 0 },
{ nullptr, nullptr, 164, 1, 9, STAT_INVALID, 0, -1, 0, 0, -1, 0, 0, 0, 0, 0, 0, 5, 5 },
{ nullptr, nullptr, 165, 1, 12, STAT_INVALID, 0, 7, 60, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0 },
{ nullptr, nullptr, 166, 1, 6, STAT_INVALID, 0, -1, 0, 0, -1, 0, 0, 0, 0, -10, 0, 0, 0 },
{ nullptr, nullptr, 43, 1, 6, STAT_INVALID, 0, 15, 50, 2, 14, 50, 0, 0, 0, 0, 0, 0, 0 },
{ nullptr, nullptr, 167, 1, 6, STAT_CARRY_WEIGHT, 50, -1, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0 },
{ nullptr, nullptr, 169, 1, 9, STAT_INVALID, 0, 1, 75, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0 },
{ nullptr, nullptr, 170, 1, 6, STAT_INVALID, 0, -1, 0, 0, -1, 0, 0, 0, 0, 0, 0, 5, 0 },
{ nullptr, nullptr, 121, 1, 6, STAT_INVALID, 0, 15, 50, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0 },
{ nullptr, nullptr, 171, 1, 3, STAT_INVALID, 0, -1, 0, 0, -1, 0, 6, 0, 0, 0, 0, 0, 0 },
{ nullptr, nullptr, 38, 1, 3, STAT_INVALID, 0, -1, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0 },
{ nullptr, nullptr, 173, 1, 12, STAT_INVALID, 0, -1, 0, 0, -1, 0, -7, 0, 0, 0, 0, 5, 0 },
{ nullptr, nullptr, 104, -1, 1, STAT_INVALID, 0, 7, 75, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0 },
{ nullptr, nullptr, 142, -1, 1, STAT_INVALID, 0, -1, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0 },
{ nullptr, nullptr, 142, -1, 1, STAT_INVALID, 0, -1, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0 },
{ nullptr, nullptr, 52, -1, 1, STAT_INVALID, 0, -1, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0 },
{ nullptr, nullptr, 52, -1, 1, STAT_INVALID, 0, -1, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0 },
{ nullptr, nullptr, 104, -1, 1, STAT_INVALID, 0, -1, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0 },
{ nullptr, nullptr, 104, -1, 1, STAT_INVALID, 0, -1, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0 },
{ nullptr, nullptr, 35, -1, 1, STAT_INVALID, 0, -1, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0 },
{ nullptr, nullptr, 35, -1, 1, STAT_INVALID, 0, -1, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0 },
{ nullptr, nullptr, 154, -1, 1, STAT_INVALID, 0, -1, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0 },
{ nullptr, nullptr, 154, -1, 1, STAT_INVALID, 0, -1, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0 },
{ nullptr, nullptr, 64, -1, 1, STAT_INVALID, 0, -1, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0 },
};
// An array of perk ranks for each party member.
@@ -402,7 +402,7 @@ static bool perkCanAdd(Object* critter, int perk)
}
}
for (int stat = 0; stat < PRIMARY_STAT_COUNT; stat++) {
for (Stat stat = STAT_FIRST; stat < PRIMARY_STAT_COUNT; stat++) {
if (perkDescription->stats[stat] < 0) {
if (critterGetStat(critter, stat) >= -perkDescription->stats[stat]) {
return false;
@@ -582,7 +582,7 @@ void perkAddEffect(Object* critter, int perk)
}
if (perkDescription->maxRank == -1) {
for (int stat = 0; stat < PRIMARY_STAT_COUNT; stat++) {
for (Stat stat = STAT_FIRST; stat < PRIMARY_STAT_COUNT; stat++) {
int value = critterGetBonusStat(critter, stat);
critterSetBonusStat(critter, stat, value + perkDescription->stats[stat]);
}
@@ -615,7 +615,7 @@ void perkRemoveEffect(Object* critter, int perk)
}
if (perkDescription->maxRank == -1) {
for (int stat = 0; stat < PRIMARY_STAT_COUNT; stat++) {
for (Stat stat = STAT_FIRST; stat < PRIMARY_STAT_COUNT; stat++) {
int value = critterGetBonusStat(critter, stat);
critterSetBonusStat(critter, stat, value - perkDescription->stats[stat]);
}
+8 -8
View File
@@ -419,8 +419,8 @@ int proto_item_subdata_init(Proto* proto, int type)
break;
case ITEM_TYPE_DRUG:
proto->item.data.drug.stat[0] = STAT_STRENGTH;
proto->item.data.drug.stat[1] = -1;
proto->item.data.drug.stat[2] = -1;
proto->item.data.drug.stat[1] = STAT_INVALID;
proto->item.data.drug.stat[2] = STAT_INVALID;
proto->item.data.drug.amount[0] = 0;
proto->item.data.drug.amount[1] = 0;
proto->item.data.drug.amount[2] = 0;
@@ -1388,9 +1388,9 @@ int protoInit()
_mp_critter_stats_list = _aDrugStatSpecia;
_critter_stats_list = _critter_stats_list_strs;
_critter_stats_list_None = _aNone_1;
for (i = 0; i < STAT_COUNT; i++) {
_critter_stats_list_strs[i] = statGetName(i);
if (_critter_stats_list_strs[i] == nullptr) {
for (Stat stat = STAT_FIRST; stat < STAT_COUNT; stat++) {
_critter_stats_list_strs[stat] = statGetName(stat);
if (_critter_stats_list_strs[stat] == nullptr) {
debugPrint("\nError: Finding stat names!");
return -1;
}
@@ -1566,9 +1566,9 @@ static int protoItemDataRead(ItemProtoData* item_data, int type, File* stream)
return 0;
case ITEM_TYPE_DRUG:
if (fileReadInt32(stream, &(item_data->drug.stat[0])) == -1) return -1;
if (fileReadInt32(stream, &(item_data->drug.stat[1])) == -1) return -1;
if (fileReadInt32(stream, &(item_data->drug.stat[2])) == -1) return -1;
if (fileReadInt32(stream, reinterpret_cast<int*>(&(item_data->drug.stat[0]))) == -1) return -1;
if (fileReadInt32(stream, reinterpret_cast<int*>(&(item_data->drug.stat[1]))) == -1) return -1;
if (fileReadInt32(stream, reinterpret_cast<int*>(&(item_data->drug.stat[2]))) == -1) return -1;
if (fileReadInt32List(stream, item_data->drug.amount, 3) == -1) return -1;
if (fileReadInt32(stream, &(item_data->drug.duration1)) == -1) return -1;
if (fileReadInt32List(stream, item_data->drug.amount1, 3) == -1) return -1;
+4 -3
View File
@@ -2,6 +2,7 @@
#define PROTO_TYPES_H
#include "skill_defs.h"
#include "stat_defs.h"
namespace fallout {
@@ -318,7 +319,7 @@ typedef struct {
} ProtoItemContainerData;
typedef struct {
int stat[3]; // d.stat
Stat stat[3]; // d.stat
int amount[3]; // d.amount
int duration1; // d.duration1
int amount1[3]; // d.amount1
@@ -410,8 +411,8 @@ typedef struct ItemProto {
typedef struct CritterProtoData {
int flags; // d.flags
int baseStats[35]; // d.stat_base
int bonusStats[35]; // d.stat_bonus
int baseStats[SAVEABLE_STAT_COUNT]; // d.stat_base
int bonusStats[SAVEABLE_STAT_COUNT]; // d.stat_bonus
int skills[SKILL_COUNT]; // d.stat_points
BodyType bodyType; // d.body
int experience;
+2 -1
View File
@@ -3,6 +3,7 @@
#include "db.h"
#include "obj_types.h"
#include "stat_defs.h"
namespace fallout {
@@ -26,7 +27,7 @@ typedef enum EventType {
typedef struct DrugEffectEvent {
int drugPid;
int stats[3];
Stat stats[3];
int modifiers[3];
} DrugEffectEvent;
+22 -22
View File
@@ -123,7 +123,7 @@ static void op_set_pc_base_stat(Program* program)
// dude's proto, without calling |critterSetBaseStat|. This function has
// important call to update derived stats, which is not present in Sfall.
int value = programStackPopInteger(program);
int stat = programStackPopInteger(program);
Stat stat = programStackPopEnum<Stat>(program);
critterSetBaseStat(gDude, stat, value);
}
@@ -133,7 +133,7 @@ static void op_set_critter_base_stat(Program* program)
// dude's proto, without calling |critterSetBaseStat|. This function has
// important call to update derived stats, which is not present in Sfall.
int value = programStackPopInteger(program);
int stat = programStackPopInteger(program);
Stat stat = programStackPopEnum<Stat>(program);
Object* obj = static_cast<Object*>(programStackPopPointer(program));
critterSetBaseStat(obj, stat, value);
}
@@ -145,7 +145,7 @@ static void op_set_pc_bonus_stat(Program* program)
// dude's proto, without calling |critterSetBonusStat|. This function has
// important call to update derived stats, which is not present in Sfall.
int value = programStackPopInteger(program);
int stat = programStackPopInteger(program);
Stat stat = programStackPopEnum<Stat>(program);
critterSetBonusStat(gDude, stat, value);
}
@@ -155,7 +155,7 @@ static void op_set_critter_extra_stat(Program* program)
// dude's proto, without calling |critterSetBonusStat|. This function has
// important call to update derived stats, which is not present in Sfall.
int value = programStackPopInteger(program);
int stat = programStackPopInteger(program);
Stat stat = programStackPopEnum<Stat>(program);
Object* obj = static_cast<Object*>(programStackPopPointer(program));
critterSetBonusStat(obj, stat, value);
}
@@ -166,7 +166,7 @@ static void op_get_pc_base_stat(Program* program)
// CE: Implementation is different. Sfall obtains value directly from
// dude's proto. This can have unforeseen consequences when dealing with
// current stats.
int stat = programStackPopInteger(program);
Stat stat = programStackPopEnum<Stat>(program);
programStackPushInteger(program, critterGetBaseStat(gDude, stat));
}
@@ -175,7 +175,7 @@ static void op_get_critter_base_stat(Program* program)
// CE: Implementation is different. Sfall obtains value directly from
// dude's proto. This can have unforeseen consequences when dealing with
// current stats.
int stat = programStackPopInteger(program);
Stat stat = programStackPopEnum<Stat>(program);
Object* obj = static_cast<Object*>(programStackPopPointer(program));
programStackPushInteger(program, critterGetBaseStat(obj, stat));
}
@@ -183,14 +183,14 @@ static void op_get_critter_base_stat(Program* program)
// get_pc_extra_stat
static void op_get_pc_bonus_stat(Program* program)
{
int stat = programStackPopInteger(program);
Stat stat = programStackPopEnum<Stat>(program);
int value = critterGetBonusStat(gDude, stat);
programStackPushInteger(program, value);
}
static void op_get_critter_extra_stat(Program* program)
{
int stat = programStackPopInteger(program);
Stat stat = programStackPopEnum<Stat>(program);
Object* obj = static_cast<Object*>(programStackPopPointer(program));
int value = critterGetBonusStat(obj, stat);
programStackPushInteger(program, value);
@@ -1875,22 +1875,22 @@ void sfallOpcodesInit()
// ^ 0x81da - int call_offset_r3(int address, int arg1, int arg2, int arg3)
// ^ 0x81db - int call_offset_r4(int address, int arg1, int arg2, int arg3, int arg4)
// 0x815a - void set_pc_base_stat(int StatID, int value)
// 0x815a - void set_pc_base_stat(Stat stat, int value)
interpreterRegisterOpcode(0x815A, op_set_pc_base_stat);
// 0x815b - void set_pc_extra_stat(int StatID, int value)
// 0x815b - void set_pc_extra_stat(Stat stat, int value)
interpreterRegisterOpcode(0x815B, op_set_pc_bonus_stat);
// 0x815c - int get_pc_base_stat(int StatID)
// 0x815c - int get_pc_base_stat(Stat stat)
interpreterRegisterOpcode(0x815C, op_get_pc_base_stat);
// 0x815d - int get_pc_extra_stat(int StatID)
// 0x815d - int get_pc_extra_stat(Stat stat)
interpreterRegisterOpcode(0x815D, op_get_pc_bonus_stat);
// 0x815e - void set_critter_base_stat(object, int StatID, int value)
// 0x815e - void set_critter_base_stat(object, Stat stat, int value)
interpreterRegisterOpcode(0x815E, op_set_critter_base_stat);
// 0x815f - void set_critter_extra_stat(object, int StatID, int value)
// 0x815f - void set_critter_extra_stat(object, Stat stat, int value)
interpreterRegisterOpcode(0x815F, op_set_critter_extra_stat);
// 0x8160 - int get_critter_base_stat(object, int StatID)
// 0x8160 - int get_critter_base_stat(object, Stat stat)
interpreterRegisterOpcode(0x8160, op_get_critter_base_stat);
// 0x8161 - int get_critter_extra_stat(object, int StatID)
// 0x8161 - int get_critter_extra_stat(object, Stat stat)
interpreterRegisterOpcode(0x8161, op_get_critter_extra_stat);
// 0x8242 - void set_critter_skill_points(int critter, Skill skill, int value)
// 0x8243 - int get_critter_skill_points(int critter, Skill skill)
@@ -1898,12 +1898,12 @@ void sfallOpcodesInit()
// 0x8245 - int get_available_skill_points()
// 0x8246 - void mod_skill_points_per_level(int value)
// 0x81b4 - void set_stat_max(int stat, int value)
// 0x81b5 - void set_stat_min(int stat, int value)
// 0x81b7 - void set_pc_stat_max(int stat, int value)
// 0x81b8 - void set_pc_stat_min(int stat, int value)
// 0x81b9 - void set_npc_stat_max(int stat, int value)
// 0x81ba - void set_npc_stat_min(int stat, int value)
// 0x81b4 - void set_stat_max(Stat stat, int value)
// 0x81b5 - void set_stat_min(Stat stat, int value)
// 0x81b7 - void set_pc_stat_max(Stat stat, int value)
// 0x81b8 - void set_pc_stat_min(Stat stat, int value)
// 0x81b9 - void set_npc_stat_max(Stat stat, int value)
// 0x81ba - void set_npc_stat_min(Stat stat, int value)
// 0x816b - int input_funcs_available() // deprecated; do not implement
// 0x816c - int key_pressed(int dxScancode)
+2 -2
View File
@@ -44,8 +44,8 @@ typedef struct SkillDescription {
int frmId;
int defaultValue;
int statModifier;
int stat1;
int stat2;
Stat stat1;
Stat stat2;
int baseValueMult;
int experience;
int gainXpFromSkillPenalty;
+56 -52
View File
@@ -120,17 +120,17 @@ int statsInit()
return -1;
}
for (int stat = 0; stat < STAT_COUNT; stat++) {
for (Stat stat = STAT_FIRST; stat < STAT_COUNT; stat++) {
gStatDescriptions[stat].name = getmsg(&gStatsMessageList, &messageListItem, 100 + stat);
gStatDescriptions[stat].description = getmsg(&gStatsMessageList, &messageListItem, 200 + stat);
}
for (int pcStat = 0; pcStat < PC_STAT_COUNT; pcStat++) {
for (PcStat pcStat = PC_STAT_FIRST; pcStat < PC_STAT_COUNT; pcStat++) {
gPcStatDescriptions[pcStat].name = getmsg(&gStatsMessageList, &messageListItem, 400 + pcStat);
gPcStatDescriptions[pcStat].description = getmsg(&gStatsMessageList, &messageListItem, 500 + pcStat);
}
for (int index = 0; index < PRIMARY_STAT_RANGE; index++) {
for (int index = PRIMARY_STAT_MIN - 1; index < PRIMARY_STAT_RANGE; index++) {
gStatValueDescriptions[index] = getmsg(&gStatsMessageList, &messageListItem, 301 + index);
}
@@ -209,13 +209,13 @@ int statGetUnspentApPerkBonus()
}
// 0x4AEF48
int critterGetStat(Object* critter, int stat)
int critterGetStat(Object* critter, Stat stat)
{
if (PID_TYPE(critter->pid) != OBJ_TYPE_CRITTER) {
return 0;
}
int value;
if (stat >= 0 && stat < SAVEABLE_STAT_COUNT) {
if (stat >= STAT_FIRST && stat < SAVEABLE_STAT_COUNT) {
value = critterGetBaseStatWithTraitModifier(critter, stat);
value += critterGetBonusStat(critter, stat);
@@ -275,6 +275,8 @@ int critterGetStat(Object* critter, int stat)
case STAT_AGE:
value += gameTimeGetTime() / GAME_TIME_TICKS_PER_YEAR;
break;
default:
break;
}
if (critter == gDude) {
@@ -394,6 +396,8 @@ int critterGetStat(Object* critter, int stat)
value += 10;
}
break;
default:
break;
}
}
@@ -421,7 +425,7 @@ int critterGetStat(Object* critter, int stat)
// Returns base stat value (accounting for traits if critter is dude).
//
// 0x4AF3E0
int critterGetBaseStatWithTraitModifier(Object* critter, int stat)
int critterGetBaseStatWithTraitModifier(Object* critter, Stat stat)
{
int value = critterGetBaseStat(critter, stat);
@@ -433,31 +437,31 @@ int critterGetBaseStatWithTraitModifier(Object* critter, int stat)
}
// 0x4AF408
int critterGetBaseStat(Object* critter, int stat)
int critterGetBaseStat(Object* critter, Stat stat)
{
Proto* proto;
if (stat >= 0 && stat < SAVEABLE_STAT_COUNT) {
if (stat >= STAT_FIRST && stat < SAVEABLE_STAT_COUNT) {
protoGetProto(critter->pid, &proto);
return proto->critter.data.baseStats[stat];
} else {
switch (stat) {
case STAT_CURRENT_HIT_POINTS:
return critterGetHitPoints(critter);
case STAT_CURRENT_POISON_LEVEL:
return critterGetPoison(critter);
case STAT_CURRENT_RADIATION_LEVEL:
return critterGetRadiation(critter);
}
}
return 0;
switch (stat) {
case STAT_CURRENT_HIT_POINTS:
return critterGetHitPoints(critter);
case STAT_CURRENT_POISON_LEVEL:
return critterGetPoison(critter);
case STAT_CURRENT_RADIATION_LEVEL:
return critterGetRadiation(critter);
default:
return 0;
}
}
// 0x4AF474
int critterGetBonusStat(Object* critter, int stat)
int critterGetBonusStat(Object* critter, Stat stat)
{
if (stat >= 0 && stat < SAVEABLE_STAT_COUNT) {
if (stat >= STAT_FIRST && stat < SAVEABLE_STAT_COUNT) {
Proto* proto;
protoGetProto(critter->pid, &proto);
return proto->critter.data.bonusStats[stat];
@@ -467,7 +471,7 @@ int critterGetBonusStat(Object* critter, int stat)
}
// 0x4AF4BC
int critterSetBaseStat(Object* critter, int stat, int value)
int critterSetBaseStat(Object* critter, Stat stat, int value)
{
Proto* proto;
@@ -475,7 +479,7 @@ int critterSetBaseStat(Object* critter, int stat, int value)
return -5;
}
if (stat >= 0 && stat < SAVEABLE_STAT_COUNT) {
if (stat >= STAT_FIRST && stat < SAVEABLE_STAT_COUNT) {
if (stat > STAT_LUCK && stat <= STAT_POISON_RESISTANCE) {
// Cannot change base value of derived stats.
return -1;
@@ -510,14 +514,14 @@ int critterSetBaseStat(Object* critter, int stat, int value)
return critterAdjustPoison(critter, value - critterGetPoison(critter));
case STAT_CURRENT_RADIATION_LEVEL:
return critterAdjustRadiation(critter, value - critterGetRadiation(critter));
default:
// Should be unreachable
return 0;
}
// Should be unreachable
return 0;
}
// 0x4AF5D4
int critterIncBaseStat(Object* critter, int stat)
int critterIncBaseStat(Object* critter, Stat stat)
{
int value = critterGetBaseStat(critter, stat);
@@ -529,7 +533,7 @@ int critterIncBaseStat(Object* critter, int stat)
}
// 0x4AF608
int critterDecBaseStat(Object* critter, int stat)
int critterDecBaseStat(Object* critter, Stat stat)
{
int value = critterGetBaseStat(critter, stat);
@@ -541,13 +545,13 @@ int critterDecBaseStat(Object* critter, int stat)
}
// 0x4AF63C
int critterSetBonusStat(Object* critter, int stat, int value)
int critterSetBonusStat(Object* critter, Stat stat, int value)
{
if (!statIsValid(stat)) {
return -5;
}
if (stat >= 0 && stat < SAVEABLE_STAT_COUNT) {
if (stat >= STAT_FIRST && stat < SAVEABLE_STAT_COUNT) {
Proto* proto;
protoGetProto(critter->pid, &proto);
proto->critter.data.bonusStats[stat] = value;
@@ -557,25 +561,25 @@ int critterSetBonusStat(Object* critter, int stat, int value)
}
return 0;
} else {
switch (stat) {
case STAT_CURRENT_HIT_POINTS:
return critterAdjustHitPoints(critter, value);
case STAT_CURRENT_POISON_LEVEL:
return critterAdjustPoison(critter, value);
case STAT_CURRENT_RADIATION_LEVEL:
return critterAdjustRadiation(critter, value);
}
}
// Should be unreachable
return -1;
switch (stat) {
case STAT_CURRENT_HIT_POINTS:
return critterAdjustHitPoints(critter, value);
case STAT_CURRENT_POISON_LEVEL:
return critterAdjustPoison(critter, value);
case STAT_CURRENT_RADIATION_LEVEL:
return critterAdjustRadiation(critter, value);
default:
// Should be unreachable
return -1;
}
}
// 0x4AF6CC
void protoCritterDataResetStats(CritterProtoData* data)
{
for (int stat = 0; stat < SAVEABLE_STAT_COUNT; stat++) {
for (Stat stat = STAT_FIRST; stat < SAVEABLE_STAT_COUNT; stat++) {
data->baseStats[stat] = gStatDescriptions[stat].defaultValue;
data->bonusStats[stat] = 0;
}
@@ -609,13 +613,13 @@ void critterUpdateDerivedStats(Object* critter)
}
// 0x4AF854
char* statGetName(int stat)
char* statGetName(Stat stat)
{
return statIsValid(stat) ? gStatDescriptions[stat].name : nullptr;
}
// 0x4AF898
char* statGetDescription(int stat)
char* statGetDescription(Stat stat)
{
return statIsValid(stat) ? gStatDescriptions[stat].description : nullptr;
}
@@ -633,13 +637,13 @@ char* statGetValueDescription(int value)
}
// 0x4AF8FC
int pcGetStat(int pcStat)
int pcGetStat(PcStat pcStat)
{
return pcStatIsValid(pcStat) ? gPcStatValues[pcStat] : 0;
}
// 0x4AF910
int pcSetStat(int pcStat, int value)
int pcSetStat(PcStat pcStat, int value)
{
int result;
@@ -674,7 +678,7 @@ int pcSetStat(int pcStat, int value)
// 0x4AF980
void pcStatsReset()
{
for (int pcStat = 0; pcStat < PC_STAT_COUNT; pcStat++) {
for (PcStat pcStat = PC_STAT_FIRST; pcStat < PC_STAT_COUNT; pcStat++) {
gPcStatValues[pcStat] = gPcStatDescriptions[pcStat].defaultValue;
}
}
@@ -705,19 +709,19 @@ int pcGetExperienceForLevel(int level)
}
// 0x4AF9F4
char* pcStatGetName(int pcStat)
char* pcStatGetName(PcStat pcStat)
{
return pcStat >= 0 && pcStat < PC_STAT_COUNT ? gPcStatDescriptions[pcStat].name : nullptr;
return pcStatIsValid(pcStat) ? gPcStatDescriptions[pcStat].name : nullptr;
}
// 0x4AFA14
char* pcStatGetDescription(int pcStat)
char* pcStatGetDescription(PcStat pcStat)
{
return pcStat >= 0 && pcStat < PC_STAT_COUNT ? gPcStatDescriptions[pcStat].description : nullptr;
return pcStatIsValid(pcStat) ? gPcStatDescriptions[pcStat].description : nullptr;
}
// 0x4AFA34
int statGetFrmId(int stat)
int statGetFrmId(Stat stat)
{
return statIsValid(stat) ? gStatDescriptions[stat].frmId : 0;
}
@@ -736,7 +740,7 @@ int statGetFrmId(int stat)
// `NULL` if you're not interested in this value.
//
// 0x4AFA78
int statRoll(Object* critter, int stat, int modifier, int* howMuch)
int statRoll(Object* critter, Stat stat, int modifier, int* howMuch)
{
int value = critterGetStat(critter, stat) + modifier;
int chance = randomBetween(PRIMARY_STAT_MIN, PRIMARY_STAT_MAX);
+16 -26
View File
@@ -20,42 +20,32 @@ void statSetUnspentApBonus(int multiplier);
int statGetUnspentApBonus();
void statSetUnspentApPerkBonus(int multiplier);
int statGetUnspentApPerkBonus();
int critterGetStat(Object* critter, int stat);
int critterGetBaseStatWithTraitModifier(Object* critter, int stat);
int critterGetBaseStat(Object* critter, int stat);
int critterGetBonusStat(Object* critter, int stat);
int critterSetBaseStat(Object* critter, int stat, int value);
int critterIncBaseStat(Object* critter, int stat);
int critterDecBaseStat(Object* critter, int stat);
int critterSetBonusStat(Object* critter, int stat, int value);
int critterGetStat(Object* critter, Stat stat);
int critterGetBaseStatWithTraitModifier(Object* critter, Stat stat);
int critterGetBaseStat(Object* critter, Stat stat);
int critterGetBonusStat(Object* critter, Stat stat);
int critterSetBaseStat(Object* critter, Stat stat, int value);
int critterIncBaseStat(Object* critter, Stat stat);
int critterDecBaseStat(Object* critter, Stat stat);
int critterSetBonusStat(Object* critter, Stat stat, int value);
void protoCritterDataResetStats(CritterProtoData* data);
void critterUpdateDerivedStats(Object* critter);
char* statGetName(int stat);
char* statGetDescription(int stat);
char* statGetName(Stat stat);
char* statGetDescription(Stat stat);
char* statGetValueDescription(int value);
int pcGetStat(int pcStat);
int pcSetStat(int pcStat, int value);
int pcGetStat(PcStat pcStat);
int pcSetStat(PcStat pcStat, int value);
void pcStatsReset();
int pcGetExperienceForNextLevel();
int pcGetExperienceForLevel(int level);
char* pcStatGetName(int pcStat);
char* pcStatGetDescription(int pcStat);
int statGetFrmId(int stat);
int statRoll(Object* critter, int stat, int modifier, int* howMuch);
char* pcStatGetName(PcStat pcStat);
char* pcStatGetDescription(PcStat pcStat);
int statGetFrmId(Stat stat);
int statRoll(Object* critter, Stat stat, int modifier, int* howMuch);
int pcAddExperience(int xp, int* xpGained = nullptr);
int pcAddExperienceWithOptions(int xp, bool doParty, int* xpGained = nullptr);
int pcSetExperience(int xp);
static inline bool statIsValid(int stat)
{
return stat >= 0 && stat < STAT_COUNT;
}
static inline bool pcStatIsValid(int pcStat)
{
return pcStat >= 0 && pcStat < PC_STAT_COUNT;
}
} // namespace fallout
#endif /* STAT_H */
+30 -5
View File
@@ -19,7 +19,8 @@ namespace fallout {
#define PC_LEVEL_MAX 99
// Available stats.
typedef enum Stat {
enum Stat : int {
STAT_INVALID = -1,
STAT_STRENGTH,
STAT_PERCEPTION,
STAT_ENDURANCE,
@@ -59,6 +60,7 @@ typedef enum Stat {
STAT_CURRENT_POISON_LEVEL,
STAT_CURRENT_RADIATION_LEVEL,
STAT_COUNT,
STAT_FIRST = STAT_STRENGTH,
// Number of primary stats.
PRIMARY_STAT_COUNT = 7,
@@ -68,19 +70,42 @@ typedef enum Stat {
// Number of saveable stats (i.e. excluding CURRENT pseudostats).
SAVEABLE_STAT_COUNT = 35,
} Stat;
};
#define STAT_INVALID -1
inline bool statIsValid(int stat)
{
return stat >= STAT_FIRST && stat < STAT_COUNT;
}
inline Stat operator++(Stat& e, int)
{
Stat result = e;
e = static_cast<Stat>(static_cast<int>(e) + 1);
return result;
}
// Special stats that are only relevant to player character.
typedef enum PcStat {
enum PcStat : int {
PC_STAT_UNSPENT_SKILL_POINTS,
PC_STAT_LEVEL,
PC_STAT_EXPERIENCE,
PC_STAT_REPUTATION,
PC_STAT_KARMA,
PC_STAT_COUNT,
} PcStat;
PC_STAT_FIRST = PC_STAT_UNSPENT_SKILL_POINTS
};
inline bool pcStatIsValid(int pcStat)
{
return pcStat >= PC_STAT_FIRST && pcStat < PC_STAT_COUNT;
}
inline PcStat operator++(PcStat& e, int)
{
PcStat result = e;
e = static_cast<PcStat>(static_cast<int>(e) + 1);
return result;
}
} // namespace fallout

Some files were not shown because too many files have changed in this diff Show More