Compare commits

..
4 Commits
Author SHA1 Message Date
Mike Klaas 7dab1e6219 Test fix web build mouse 2026-04-19 20:28:31 -07:00
Mike Klaas dcba8882bf Commandline .dat file viewer (#373) 2026-04-19 15:29:18 -07:00
Mike Klaas 62c2621fef Implement HOOK_ONDEATH (#384)
* Implement HOOK_ONDEATH

Test both combat death and script-triggered death

* move hp and DEAD flag above hook call
2026-04-19 14:24:51 -07:00
Vlad Kandgithub-actions[bot] 5188ebd4f4 Simplify settings registry with macros (#386)
* Simplify settings registry with macros

* chore: auto-format with clang-format

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-04-17 22:44:23 +02:00
53 changed files with 846 additions and 12331 deletions
+1
View File
@@ -10,6 +10,7 @@
*.userosscache
*.sln.docstates
.DS_Store
.local-tools/
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
+22 -12
View File
@@ -98,12 +98,6 @@ target_sources(${EXECUTABLE_NAME} PUBLIC
"src/file_find.h"
"src/file_utils.cc"
"src/file_utils.h"
"src/fo1db/fo1_assoc.cc"
"src/fo1db/fo1_assoc.h"
"src/fo1db/fo1_db.cc"
"src/fo1db/fo1_db.h"
"src/fo1db/fo1_lzss.cc"
"src/fo1db/fo1_lzss.h"
"src/font_manager.cc"
"src/font_manager.h"
"src/game_config.cc"
@@ -120,8 +114,6 @@ target_sources(${EXECUTABLE_NAME} PUBLIC
"src/game_movie.h"
"src/game_sound.cc"
"src/game_sound.h"
"src/game_variant.cc"
"src/game_variant.h"
"src/game_vars.h"
"src/game.cc"
"src/game.h"
@@ -330,10 +322,6 @@ if(WIN32)
)
endif()
if(MSVC)
target_compile_options(${EXECUTABLE_NAME} PRIVATE /EHsc)
endif()
if(WIN32)
target_link_libraries(${EXECUTABLE_NAME}
winmm
@@ -458,6 +446,28 @@ target_include_directories(${EXECUTABLE_NAME} PRIVATE ${ZLIB_INCLUDE_DIRS})
target_link_libraries(${EXECUTABLE_NAME} ${SDL2_LIBRARIES})
target_include_directories(${EXECUTABLE_NAME} PRIVATE ${SDL2_INCLUDE_DIRS})
add_executable(fallout2-dat
"tools/dat_tool.cc"
"src/dfile.cc"
"src/platform_compat.cc"
)
if(APPLE)
set_target_properties(fallout2-dat PROPERTIES
XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED "NO"
XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO"
)
endif()
target_link_libraries(fallout2-dat
fpattern_windows::fpattern_windows
${ZLIB_LIBRARIES}
${SDL2_LIBRARIES}
)
target_include_directories(fallout2-dat PRIVATE "src")
target_include_directories(fallout2-dat PRIVATE ${ZLIB_INCLUDE_DIRS})
target_include_directories(fallout2-dat PRIVATE ${SDL2_INCLUDE_DIRS})
if(APPLE)
if(IOS)
install(TARGETS ${EXECUTABLE_NAME} DESTINATION "Payload")
-3
View File
@@ -119,9 +119,6 @@
"base"
],
"generator": "Xcode",
"cacheVariables": {
"CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY": ""
},
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
+20
View File
@@ -2,6 +2,26 @@
This file is currently a shell to be filled in over time. For now, it only captures project-specific maintenance notes that are easy to miss.
## `.dat` CLI Tool
There is a small command-line archive tool in this repo for inspecting Fallout `.dat` files using the same reader implementation as the game.
Build it with `make TARGET=fallout2-dat`.
The executable is written to your selected `BUILD_DIR`, so the default path is `out/build/local-debug-arm64/fallout2-dat` on this macOS setup, but other platforms or custom build directories will differ.
The current tool is read-only. Available commands:
1. `./<BUILD_DIR>/fallout2-dat <archive.dat> list [pattern]`
2. `./<BUILD_DIR>/fallout2-dat <archive.dat> info [pattern]`
3. `./<BUILD_DIR>/fallout2-dat <archive.dat> extract [--lower] <output-dir> [pattern]`
4. `./<BUILD_DIR>/fallout2-dat <archive.dat> cat <entry>`
Use `--lower` with `extract` when you want every extracted file and directory name forced to lowercase.
For example, from `/Applications/Fallout2Codex` you can run:
`/Users/klaas/game/fallout2-ce/out/build/local-debug-arm64/fallout2-dat master.dat extract --lower /tmp/fallout2-dat-lower data\\*`
## Updating SDL
SDL is pinned for native builds in `third_party/sdl2/CMakeLists.txt`. Right now, Android also relies on checked-in Java bindings in `os/android/app/src/main/java/org/libsdl/app`, and those bindings must match the SDL version fetched by CMake.
+1 -1
View File
@@ -82,7 +82,7 @@ See [`https://sfall-team.github.io/sfall/`](https://sfall-team.github.io/sfall/)
| DeathAnim1 | `HOOK_DEATHANIM1` | đźš« | Use DEATHANIM2 instead |
| DeathAnim2 | `HOOK_DEATHANIM2` | âś… | - |
| CombatDamage | `HOOK_COMBATDAMAGE` | âś… | - |
| OnDeath | `HOOK_ONDEATH` | đźš« | - |
| OnDeath | `HOOK_ONDEATH` | âś… | - |
| FindTarget | `HOOK_FINDTARGET` | đźš« | (maybe) |
| UseObjOn | `HOOK_USEOBJON` | âś… | - |
| UseObj | `HOOK_USEOBJ` | âś… | CE notes an sfall-matching inconsistency around return code `2` behavior between interface contexts. |
File diff suppressed because it is too large Load Diff
-61
View File
@@ -1,61 +0,0 @@
#
# enddeath.txt
#
# format of each line is:
#
# gvar, value, worldAreaKnown, worldAreaNotKnown, minLevel, %, narrator file
#
# Where:
#
# gvar is the GVAR_* number for the variable controlling the slide.
#
# value is the value that the gvar must be >= to for this slide
# to be shown
#
# worldAreaKnown is the # of a worldmap area that has to be known
# in order to get this one as an option
#
# worldAreaNotKnown is the # of a worldmap area that has to be *not*
# known in order to get this one as an option
#
# minLevel is the minimum player level in order to get this one as
# an option
#
# % is the % chance of a given line to occur
#
# narrator file is the base filename (no path path or extension) used
# for the narrator voice-over and subtitles. Maximum of 8 characters.
#
#####
# Generic Deaths
#####
-1, 0, -1, -1, 0, 20, NAR_3
-1, 0, -1, -1, 0, 20, NAR_4
-1, 0, -1, -1, 0, 20, NAR_5
-1, 0, -1, -1, 0, 20, NAR_6
-1, 0, 8, -1, 0, 20, NAR_8
#####
# Specific Deaths
#####
-1, 0, -1, 0, 200, 0, nar_dth3
-1, 0, -1, 0, 200, 0, nar_dth4
-1, 0, -1, 0, 200, 0, nar_dth5
-1, 0, -1, 0, 200, 0, nar_dth6
-1, 0, -1, 0, 200, 0, nar_dth7
-1, 0, -1, 0, 200, 0, nar_dth8
-1, 0, -1, 0, 200, 0, nar_dth9
# Special Radiation Death
491, 999, 3, -1, 150, 0, NAR_7
#####
# Joke Deaths
#####
-1, 0, -1, -1, 10, 1, nar_jdd1
-1, 0, -1, -1, 10, 1, nar_jdd3
-1, 0, -1, -1, 10, 1, nar_jdd4
-1, 0, -1, -1, 10, 1, nar_jdd5
-1, 0, -1, -1, 10, 1, nar_jdd6
File diff suppressed because it is too large Load Diff
-104
View File
@@ -1,104 +0,0 @@
;
; Party Member valid option data
;
;
; Warning: Adding a party member here means you must also add it to party.h!
;
;
; Note: Party Member level-up float messages are found in game\misc.msg!
;
[Party Member 0] ; Player -- Not actually used!
party_member_pid=16777216
area_attack_mode=always, sometimes, be_sure, be_careful, be_absolutely_sure
attack_who=whomever_attacking_me, strongest, weakest, whomever, closest
best_weapon=no_pref, melee, melee_over_ranged, ranged_over_melee, ranged, unarmed, unarmed_over_thrown, random
chem_use=clean, stims_when_hurt_little, stims_when_hurt_lots, sometimes, anytime, always
distance=stay_close, charge, snipe, on_your_own, stay
run_away_mode=none, coward, finger_hurts, bleeding, not_feeling_good, tourniquet, never
disposition=none, custom, coward, defensive, aggressive, berserk
level_minimum=0
level_up_every=0
level_pids=-1
[Party Member 1] ; pMIan_PID
party_member_pid=16777292
area_attack_mode=always, sometimes, be_sure, be_careful, be_absolutely_sure
attack_who=whomever_attacking_me, strongest, weakest, whomever, closest
best_weapon=no_pref, melee, ranged_over_melee, ranged
chem_use=clean, stims_when_hurt_little, stims_when_hurt_lots, sometimes, anytime
distance=stay_close, charge, snipe, on_your_own, stay
run_away_mode=none, not_feeling_good, tourniquet, never
disposition=none, custom, defensive, aggressive, berserk
level_minimum=3
level_up_every=3
level_pids=16777530,16777531,16777532,16777533
[Party Member 2] ; pMDog_PID
party_member_pid=16777338
area_attack_mode=
attack_who=whomever_attacking_me, strongest, weakest, whomever, closest
best_weapon=unarmed
chem_use=clean
distance=stay_close, charge, on_your_own, stay
run_away_mode=none, not_feeling_good, tourniquet, never
disposition=none, custom, aggressive, berserk
level_minimum=4
level_up_every=3
level_pids=16777542,16777543,16777544,16777545
[Party Member 3] ; pMTycho_PID
party_member_pid=16777426
area_attack_mode=always, sometimes, be_sure, be_careful, be_absolutely_sure
attack_who=whomever_attacking_me, strongest, weakest, whomever, closest
best_weapon=no_pref, ranged_over_melee, ranged, unarmed
chem_use=clean, stims_when_hurt_little, stims_when_hurt_lots, sometimes, anytime
distance=stay_close, charge, snipe, on_your_own, stay
run_away_mode=none, not_feeling_good, tourniquet, never
disposition=none, custom, defensive, aggressive, berserk
level_minimum=4
level_up_every=3
level_pids=16777534,16777535,16777536,16777537
[Party Member 4] ; pMKatja_PID
party_member_pid=16777518
area_attack_mode=sometimes, be_sure, be_careful, be_absolutely_sure
attack_who=whomever_attacking_me, weakest, whomever, closest
best_weapon=no_pref, melee, melee_over_ranged, ranged_over_melee, ranged, unarmed
chem_use=stims_when_hurt_little, stims_when_hurt_lots
distance=stay_close, charge, on_your_own, stay
run_away_mode=none, coward, finger_hurts, bleeding, not_feeling_good
disposition=none, custom, defensive, aggressive, coward
level_minimum=4
level_up_every=2
level_pids=16777538,16777539,16777540,16777541
[Party Member 5] ; pMTandi_PID
party_member_pid=16777279
area_attack_mode=always, sometimes, be_sure, be_careful, be_absolutely_sure
attack_who=whomever_attacking_me, strongest, weakest, whomever, closest
best_weapon=no_pref, melee, melee_over_ranged, ranged_over_melee, ranged, unarmed
chem_use=clean, stims_when_hurt_little, stims_when_hurt_lots, sometimes, anytime, always
distance=stay_close, charge, snipe, on_your_own, stay
run_away_mode=none, coward, finger_hurts, bleeding, not_feeling_good, tourniquet, never
disposition=none, custom, coward, defensive, aggressive, berserk
level_minimum=0
level_up_every=0
level_pids=-1
[Party Member 6] ; pMMrHandyC_PID
party_member_pid=16777529
area_attack_mode=always, sometimes, be_sure, be_careful, be_absolutely_sure
attack_who=whomever_attacking_me, strongest, weakest, whomever, closest
best_weapon=no_pref, melee, melee_over_ranged, ranged_over_melee, ranged, unarmed
chem_use=clean
distance=stay_close, charge, snipe, on_your_own, stay
run_away_mode=none, coward, finger_hurts, bleeding, not_feeling_good, tourniquet, never
disposition=none, custom, coward, defensive, aggressive, berserk
level_minimum=0
level_up_every=0
level_pids=-1
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
-402
View File
@@ -1,402 +0,0 @@
;
; Fallout team quotes
;
; The fonts used to display this file are the reverse of the
; credits.txt file. In other words, the font used to display
; titles in credits.txt (the lines with the '@') is the font
; used to display these quotes. Putting an '@' at the start of
; a line in this file will use the font used to display the
; names in the credits.txt file (currently 104).
;
; Max line length with the current font (103) is about 63.
; Anything longer than that won't be displayed, as it won't fit
; on the screen.
;
; All lines are automatically centered on the display.
;
; See top of credits.txt for additional info.
;
@Quotes from the Fallout team:
(Press ESC if you don't want to see some raw language)
I asked for anatomically correct, but not naked!
- Tim C.
I appreciate the fact that ?? is only speaking to us when spoken to.
- Leonard
So now that you are past the learning curve,
you can blow up people much faster, right?
- Tim C.
So how fast can _you_ draw a bunny?
- JT
I didn't do it yet today because I was waiting for Leonard's head.
- Scott C.
Did you see Steven Spielberg go by?
- Tim C.
No, I was taking a piss.
- Mark Harrison
Blueberry muffins are one of Man's crowning achievements.
- JT
Out of my way. I'm a fucking genius.
- Jason
Dismemberment is just inherently funny.
- JT
I had a wooden one, but Spence broke it.
- Jesse
You can say penis, but you can't say cocksucker.
- Leonard
It's fun to make fun of people who are stupid.
- JT
Crap is the hardest stuff to make.
- Michael
No, I haven't shot anyone today.
- JT
But 15 _is_ an even number!
- Leonard
But 15 isn't divisible by 2.
- Tim.
You know what I mean. I meant 15 is prime.
- Leonard
I'll be going on to death at the end of the day.
- Michael
I'm tired of looking at that peanut.
- Tim C.
I only wash my nose. It's the only thing that gets dirty.
- Fred
I'm going to jiujitsu his ass.
- Leonard
I'll have to remember or else I'll forget.
- Jesse
You never know what wacky things I'm going to do with my hand.
- Tim C.
Sorry I'm late, but Mary needed marbles and I had lost mine.
- Chris T.
It's fun hitting other people's balls.
- Tim C.
I'm going to kill this game.
- Mark Morgan
Do you want help putting on your bikini?
- Fred to Tim C.
I like to get them in the butt.
- Tim C.
I need more peasants!
- Fred
If I hadn't had sex, I would have called Tom or Jesse.
- Scotty
Did you know you can talk to people who don't have heads?
- Jesse
We'll have a little bowl hair-cut kid so you
can't tell if it's a boy or a girl when you're killing it.
- Leonard
It's just a flag!
- Scotty
I'll tell them to give me more exploding peasants.
- Fred
Do you need help changing his pants?
- Leonard
I was getting home and getting ready to get some,
and I remembered it was a holiday.
- Scotty
I'd rather drink a bottle of urine than THAT!
- Scotty
Rusty wants any body he can have.
- Gus
Nick's are worn and falling apart and orange.
- Jesse
I never let work interfere with my cooking.
- Tim C.
I don't want you to stop making them,
because it's the only time I get any.
- Scotty
I vote for Hate.
- Jason
That reminds me of Toxic Avenger, the unrated version.
- Scotty
You know, we should lock down sex.
- Chris T.
How do I kill people? I need some dead bodies.
- Robert H.
Don't quote me on that.
- Leonard
I had a weird dream involving Scotty,
and I don't even want to remember it.
- Jesse
What?!
- Scotty
I don't know what we're going to do about it.
I guess we're going to have to start cutting heads.
- Tim C.
Well, that's true and that's untrue.
- Gus
But I like being a woman!
- Scotty
I'm used to playing with myself.
- Scotty
That's the essence of art -- making it all work together.
- Leonard
Did I tell you I broke my thingy?
- Dave
I want more randomness in my randomology.
- Robert H.
I can't finish the AI without drugs.
- Tim C.
Please do not make fun of my poop.
- Tim C.
I know how to tell males from females now.
- Tim C.
Excuse me, my butt did that.
- Jesse
I'm going to kick you in the butt.
- Robert H. to Tim C.
Because it's soft as a baby's behind.
- Jesse.
How do you know?
- Scotty
I can do Troy. I used to be his monkey.
- Chris T.
I had one once, but I pumped it too hard and I broke it.
- Scotty
I stripped and wiped.
- Scotty
Why can't I be a lesbian?
- Shanna
I wonder what that thing hanging there is.
- Shanna
I need more intelligence.
- Nick
At the same time, I want to make sure that
I don't have dead people stand up.
- Tim C.
I'd model dust, if I could.
- Jason
I'm on top now.
- Evan
I do a good cow.
- Greg B.
If he's on top of me, I'm gonna be pissed!
- Shanna
If I was a girl, I'd do him.
- Evan
You won't be here when I get off.
- Mike Krueger
Well, I was playing with it last night but I
couldn't get anything to come out!
- Mike Krueger
Stop shaking my monkey!
- Matt Murakami
I like people who say poop.
- Savina
It's not unstable, it's just buggy.
There's a difference.
- Chris J.
Instead of sexual urges, they get
sucking blood urges.
- Scotty
I like little boys who wear skirts.
- Mike Krueger
His iguana-stick is way too long.
- Leonard
Fallout is "By Americans, For Americans" and
the rest of the world can just get stuffed.
- Scotty
All the Brotherhood do it. They know how.
- Nick
I'm going to teach you to script,
that'll be torture.
- Nick
His little thing looks better anyway.
- Evan
He TOLD me to touch it!
- Nick
I'm really scared of the people on the Internet.
They're all dumb. Except for that one guy.
- Scotty
I haven't touched it for two months.
- Nick
Well, you better start touching it.
- Evan
You can never be paranoid enough.
- Scotty
You should be 14-18 when you blow the Master.
- Jess
Oh, wait a minute, talk to Jesse.
Jesse usually has lots of drugs.
- Scotty
I burnt my part, for one thing.
- Mark H.
I'm usually a lot happier about the
game when I'm not playing it.
- Scotty
You gotta take it easy, this is my first time.
- Dave Hendee
It's really quick to get it up.
- Mark H.
I can find the hole without looking now.
- Ed H.
I've actually had it both ways, but I'm not sure why...
- Dan S.
I can touch it everywhere and it seems to work.
- Scotty
OK, I was sleeping with Ian...
- Gus
What is the sound of one man working on another?
- Dan S.
I hate being fucked.
- Gus
I think our game has a high potential
for being very violent.
- Jason A.
I'm not going to be beaten by cheesecake.
- Tim C.
I have new respect for crowbars.
(pause)
Well, at least it isn't about sex.
- Scotty
That thing is a little too
big to stick right there.
- Matt G.
I'm not going to do the cows.
- Dan S.
The cows are glad to hear that.
- Robert H.
But I love faggot pizza.
- Scotty
It won't crash any more. In theory.
- Mark H.
I wasn't wearing anything
the first time I won the game.
- Tim C.
@FIN
+52
View File
@@ -0,0 +1,52 @@
#include "sfall.h"
#include "dik.h"
#include "define_lite.h"
#define TEST_KEY (DIK_J)
procedure ondeath_handler begin
variable
dead_critter := get_sfall_arg_at(0),
critter_name := "<null>",
critter_pid := -1;
if (dead_critter) then begin
critter_name := obj_name(dead_critter);
critter_pid := obj_pid(dead_critter);
end
display_msg(string_format2("ondeath critter=%s pid=%d", critter_name, critter_pid));
end
procedure keypress_handler begin
variable
pressed := get_sfall_arg_at(0),
key := get_sfall_arg_at(1),
target;
if (not pressed) then return;
if (key != TEST_KEY) then return;
target := obj_under_cursor(true, false);
if (target == 0) then begin
display_msg("ondeath test: no critter under cursor");
return;
end
if (target == dude_obj) then begin
display_msg("ondeath test: refusing to kill dude");
return;
end
display_msg(string_format1("ondeath test: killing %s", obj_name(target)));
critter_dmg(target, 9999, DMG_BYPASS_ARMOR);
end
procedure start begin
if (not game_loaded) then return;
display_msg("ondeath manual test ready: hover a critter and press J");
register_hook_proc(HOOK_KEYPRESS, keypress_handler);
register_hook_proc(HOOK_ONDEATH, ondeath_handler);
end
-8
View File
@@ -9,7 +9,6 @@
#include "debug.h"
#include "draw.h"
#include "game.h"
#include "game_variant.h"
#include "memory.h"
#include "object.h"
#include "proto.h"
@@ -232,13 +231,6 @@ int artInit()
critterFileNames += 13;
}
// FO1 does not have a tribal look; use jumpsuit as the default player art.
if (gameVariantIsFallout1() && _art_vault_guy_num == 0) {
_art_vault_guy_num = _art_vault_person_nums[DUDE_NATIVE_LOOK_JUMPSUIT][GENDER_MALE];
_art_vault_person_nums[DUDE_NATIVE_LOOK_TRIBAL][GENDER_MALE] = _art_vault_person_nums[DUDE_NATIVE_LOOK_JUMPSUIT][GENDER_MALE];
_art_vault_person_nums[DUDE_NATIVE_LOOK_TRIBAL][GENDER_FEMALE] = _art_vault_person_nums[DUDE_NATIVE_LOOK_JUMPSUIT][GENDER_FEMALE];
}
for (int critterIndex = 0; critterIndex < gArtListDescriptions[OBJ_TYPE_CRITTER].fileNamesLength; critterIndex++) {
if (!fileReadString(string, sizeof(string), stream)) {
break;
+2 -2
View File
@@ -6988,7 +6988,7 @@ static int karmaInit()
File* stream = fileOpen("data\\karmavar.txt", "rt");
if (stream == nullptr) {
return 0;
return -1;
}
char string[256];
@@ -7087,7 +7087,7 @@ static int genericReputationInit()
File* stream = fileOpen("data\\genrep.txt", "rt");
if (stream == nullptr) {
return 0;
return -1;
}
char string[256];
-5
View File
@@ -610,8 +610,6 @@ static bool characterSelectorWindowRenderFace()
// 0x4A7EA8
static bool characterSelectorWindowRenderStats()
{
static char emptyString[] = "";
char* str;
char text[260];
int length;
@@ -830,9 +828,6 @@ static bool characterSelectorWindowRenderStats()
y += vh;
str = skillGetName(skills[index]);
if (str == nullptr) {
str = emptyString;
}
strcpy(text, str);
length = fontGetStringWidth(text);
+1
View File
@@ -4938,6 +4938,7 @@ static void _damage_object(Object* a1, int damage, bool animated, int a4, Object
}
partyMemberRemove(a1);
scriptHooks_OnDeath(a1);
}
}
+14 -39
View File
@@ -420,50 +420,29 @@ int aiInit()
if (!configGetInt(&config, sectionEntry->key, "outline_color", &(ai->outline_color))) goto err;
if (!configGetInt(&config, sectionEntry->key, "chance", &(ai->chance))) goto err;
if (!configGetInt(&config, sectionEntry->key, "run_start", &(ai->run.start))) goto err;
if (!configGetInt(&config, sectionEntry->key, "run_end", &(ai->run.end))) goto err;
if (!configGetInt(&config, sectionEntry->key, "move_start", &(ai->move.start))) goto err;
if (!configGetInt(&config, sectionEntry->key, "move_end", &(ai->move.end))) goto err;
if (!configGetInt(&config, sectionEntry->key, "attack_start", &(ai->attack.start))) goto err;
if (!configGetInt(&config, sectionEntry->key, "attack_end", &(ai->attack.end))) goto err;
if (!configGetInt(&config, sectionEntry->key, "miss_start", &(ai->miss.start))) goto err;
if (!configGetInt(&config, sectionEntry->key, "miss_end", &(ai->miss.end))) goto err;
if (!configGetInt(&config, sectionEntry->key, "hit_head_start", &(ai->hit[HIT_LOCATION_HEAD].start))) goto err;
if (!configGetInt(&config, sectionEntry->key, "hit_head_end", &(ai->hit[HIT_LOCATION_HEAD].end))) goto err;
if (!configGetInt(&config, sectionEntry->key, "hit_left_arm_start", &(ai->hit[HIT_LOCATION_LEFT_ARM].start))) goto err;
if (!configGetInt(&config, sectionEntry->key, "hit_left_arm_end", &(ai->hit[HIT_LOCATION_LEFT_ARM].end))) goto err;
if (!configGetInt(&config, sectionEntry->key, "hit_right_arm_start", &(ai->hit[HIT_LOCATION_RIGHT_ARM].start))) goto err;
if (!configGetInt(&config, sectionEntry->key, "hit_right_arm_end", &(ai->hit[HIT_LOCATION_RIGHT_ARM].end))) goto err;
if (!configGetInt(&config, sectionEntry->key, "hit_torso_start", &(ai->hit[HIT_LOCATION_TORSO].start))) goto err;
if (!configGetInt(&config, sectionEntry->key, "hit_torso_end", &(ai->hit[HIT_LOCATION_TORSO].end))) goto err;
if (!configGetInt(&config, sectionEntry->key, "hit_right_leg_start", &(ai->hit[HIT_LOCATION_RIGHT_LEG].start))) goto err;
if (!configGetInt(&config, sectionEntry->key, "hit_right_leg_end", &(ai->hit[HIT_LOCATION_RIGHT_LEG].end))) goto err;
if (!configGetInt(&config, sectionEntry->key, "hit_left_leg_start", &(ai->hit[HIT_LOCATION_LEFT_LEG].start))) goto err;
if (!configGetInt(&config, sectionEntry->key, "hit_left_leg_end", &(ai->hit[HIT_LOCATION_LEFT_LEG].end))) goto err;
if (!configGetInt(&config, sectionEntry->key, "hit_eyes_start", &(ai->hit[HIT_LOCATION_EYES].start))) goto err;
if (!configGetInt(&config, sectionEntry->key, "hit_eyes_end", &(ai->hit[HIT_LOCATION_EYES].end))) goto err;
if (!configGetInt(&config, sectionEntry->key, "hit_groin_start", &(ai->hit[HIT_LOCATION_GROIN].start))) goto err;
// *_end fields are optional: FO1's ai.txt omits them and uses each *_start as
// the inclusive upper bound of the preceding range (FO1-CE convention).
// FO2's ai.txt always supplies explicit *_end values.
if (!configGetInt(&config, sectionEntry->key, "run_end", &(ai->run.end)))
ai->run.end = ai->move.start;
if (!configGetInt(&config, sectionEntry->key, "move_end", &(ai->move.end)))
ai->move.end = ai->attack.start;
if (!configGetInt(&config, sectionEntry->key, "attack_end", &(ai->attack.end)))
ai->attack.end = ai->miss.start;
if (!configGetInt(&config, sectionEntry->key, "miss_end", &(ai->miss.end)))
ai->miss.end = ai->hit[HIT_LOCATION_HEAD].start;
if (!configGetInt(&config, sectionEntry->key, "hit_head_end", &(ai->hit[HIT_LOCATION_HEAD].end)))
ai->hit[HIT_LOCATION_HEAD].end = ai->hit[HIT_LOCATION_LEFT_ARM].start;
if (!configGetInt(&config, sectionEntry->key, "hit_left_arm_end", &(ai->hit[HIT_LOCATION_LEFT_ARM].end)))
ai->hit[HIT_LOCATION_LEFT_ARM].end = ai->hit[HIT_LOCATION_RIGHT_ARM].start;
if (!configGetInt(&config, sectionEntry->key, "hit_right_arm_end", &(ai->hit[HIT_LOCATION_RIGHT_ARM].end)))
ai->hit[HIT_LOCATION_RIGHT_ARM].end = ai->hit[HIT_LOCATION_TORSO].start;
if (!configGetInt(&config, sectionEntry->key, "hit_torso_end", &(ai->hit[HIT_LOCATION_TORSO].end)))
ai->hit[HIT_LOCATION_TORSO].end = ai->hit[HIT_LOCATION_RIGHT_LEG].start;
if (!configGetInt(&config, sectionEntry->key, "hit_right_leg_end", &(ai->hit[HIT_LOCATION_RIGHT_LEG].end)))
ai->hit[HIT_LOCATION_RIGHT_LEG].end = ai->hit[HIT_LOCATION_LEFT_LEG].start;
if (!configGetInt(&config, sectionEntry->key, "hit_left_leg_end", &(ai->hit[HIT_LOCATION_LEFT_LEG].end)))
ai->hit[HIT_LOCATION_LEFT_LEG].end = ai->hit[HIT_LOCATION_EYES].start;
if (!configGetInt(&config, sectionEntry->key, "hit_eyes_end", &(ai->hit[HIT_LOCATION_EYES].end)))
ai->hit[HIT_LOCATION_EYES].end = ai->hit[HIT_LOCATION_GROIN].start;
// groin: FO1 uses last_msg as the inclusive end; CE expects the value before
// the ++ below, so store last_msg - 1 so that ++ yields last_msg.
if (!configGetInt(&config, sectionEntry->key, "hit_groin_end", &(ai->hit[HIT_LOCATION_GROIN].end))) {
int lastMsg;
if (!configGetInt(&config, sectionEntry->key, "last_msg", &lastMsg)) goto err;
ai->hit[HIT_LOCATION_GROIN].end = lastMsg - 1;
}
if (!configGetInt(&config, sectionEntry->key, "hit_groin_end", &(ai->hit[HIT_LOCATION_GROIN].end))) goto err;
ai->hit[HIT_LOCATION_GROIN].end++;
@@ -598,11 +577,8 @@ int aiLoad(File* stream)
int pid = gPartyMemberPids[index];
if (pid != -1 && PID_TYPE(pid) == OBJ_TYPE_CRITTER) {
Proto* proto;
// TODO: fo1_shims party.txt contains FO2 pids with no valid proto
// in FO1. Skip them rather than abort; fix by supplying a minimal
// FO1-only party.txt.
if (protoGetProto(pid, &proto) == -1) {
continue;
return -1;
}
AiPacket* ai = aiGetPacketByNum(proto->critter.aiPacket);
@@ -622,9 +598,8 @@ int aiSave(File* stream)
int pid = gPartyMemberPids[index];
if (pid != -1 && PID_TYPE(pid) == OBJ_TYPE_CRITTER) {
Proto* proto;
// TODO: same FO1 party.txt issue as aiLoad — skip invalid pids.
if (protoGetProto(pid, &proto) == -1) {
continue;
return -1;
}
AiPacket* ai = aiGetPacketByNum(proto->critter.aiPacket);
+5 -3
View File
@@ -25,6 +25,7 @@
#include "random.h"
#include "reaction.h"
#include "scripts.h"
#include "sfall_script_hooks.h"
#include "skill.h"
#include "stat.h"
#include "tile.h"
@@ -825,7 +826,11 @@ void critterKill(Object* critter, int anim, bool refreshRect)
int elevation = critter->elevation;
critter->data.critter.hp = 0;
critter->data.critter.combat.results |= DAM_DEAD;
partyMemberRemove(critter);
scriptHooks_OnDeath(critter);
// NOTE: Original code uses goto to jump out from nested conditions below.
bool shouldChangeFid = false;
@@ -893,9 +898,6 @@ void critterKill(Object* critter, int anim, bool refreshRect)
_obj_turn_off_light(critter, &tempRect);
rectUnion(&updatedRect, &tempRect, &updatedRect);
critter->data.critter.hp = 0;
critter->data.critter.combat.results |= DAM_DEAD;
if (critter->sid != -1) {
scriptRemove(critter->sid);
critter->sid = -1;
-29
View File
@@ -4,8 +4,6 @@
#include <stdlib.h>
#include <string.h>
#include "debug.h"
#include "game_variant.h"
#include "platform_compat.h"
#include "xfile.h"
@@ -39,22 +37,6 @@ static int gFileReadProgressChunkSize;
// 0x673044
static FileList* gFileListHead;
static bool dbShouldUseFo1Fallback(const char* path)
{
if (path == nullptr) {
return false;
}
const char* baseName = strrchr(path, '/');
if (baseName == nullptr) {
baseName = strrchr(path, '\\');
}
baseName = baseName != nullptr ? baseName + 1 : path;
return compat_stricmp(baseName, "master.dat") == 0 || compat_stricmp(baseName, "critter.dat") == 0;
}
// Opens file database.
//
// Returns -1 if [filePath1] was specified, but could not be opened by the
@@ -66,17 +48,6 @@ int dbOpen(const char* filePath1, const char* filePath2)
{
if (filePath1 != nullptr) {
if (!xbaseOpen(filePath1)) {
if (dbShouldUseFo1Fallback(filePath1)) {
gameVariantForceFallout1();
debugPrint("dbOpen: retrying %s with Fallout 1 backend.\n", filePath1);
if (xbaseOpen(filePath1)) {
if (filePath2 != nullptr) {
xbaseOpen(filePath2);
}
return 0;
}
}
return -1;
}
}

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