Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
NovaRain committed Jul 18, 2019
2 parents 2cdf0dc + 839e8d2 commit 7c23bb2
Show file tree
Hide file tree
Showing 21 changed files with 147 additions and 105 deletions.
3 changes: 3 additions & 0 deletions artifacts/config_files/sfall-mods.ini
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ MotionScanner=0
Mode=0
;PIDList=62,89,97,107,160,161

;Set a comma delimited list of perk IDs for perks to be inherited from the player during the combat control
PerksList=0,73

;Choose a notification box to display the name of the controlled critter above the interface bar
;Must be between 5 and (4 + the value of BoxBarCount in ddraw.ini)
;For sfall 4.1.6+ the number for the notification box is set automatically, so just use any value
Expand Down
12 changes: 7 additions & 5 deletions artifacts/ddraw.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
;sfall configuration settings
;v4.1.9
;v4.1.9.1

[Main]
;Change to 1 if you want to use command line args to tell sfall to use another ini file.
Expand Down Expand Up @@ -31,7 +31,7 @@ UseCommandLine=0
NumSoundBuffers=0

;Set to 1 to allow attaching sound files to combat float messages
AllowSoundForFloats=1
AllowSoundForFloats=0

;Set to 1 to automatically search for alternative formats (mp3/wma/wav) when Fallout tries to play an acm
;Set to 2 to play alternative music files even if original acm files are not present in the music folder
Expand Down Expand Up @@ -186,7 +186,7 @@ FastMoveFromContainer=0

;A key to press to open a debug game editor
;Set to 0 to disable, or a DX scancode otherwise
;Requires sfall debugging mode and FalloutClient.exe from the modders pack
;Requires sfall debugging mode to be enabled and FalloutClient.exe from the modders pack
DebugEditorKey=0

;XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Expand Down Expand Up @@ -727,6 +727,7 @@ Enable=0

;Fallout 2 Debug Patch
;Set to 1 to send debug output to the screen, 2 to a debug.log file, or 3 to both the screen and a debug.log file
;Does not require enabling sfall debugging mode
;While you don't need to create an environment variable, you do still need to set the appropriate lines in fallout2.cfg:
;-------
;[debug]
Expand All @@ -745,12 +746,12 @@ DebugMode=0
SkipCompatModeCheck=0

;Set to 1 to skip the executable file size check
;Does not require sfall debugging mode
;Does not require enabling sfall debugging mode
SkipSizeCheck=0

;If you're testing changes to the Fallout exe, you can override the CRC that sfall looks for here
;You can use several hex values, separated by commas
;Does not require sfall debugging mode
;Does not require enabling sfall debugging mode
;ExtraCRC=0x00000000,0x00000000

;Set to 1 to stop Fallout from deleting non read-only protos at startup
Expand All @@ -767,6 +768,7 @@ AlwaysFindScripts=0
InjectAllGameHooks=0

;Set to 1 to hide error messages in debug output when a null value is passed to the function as an object
;Requires DebugMode to be enabled
HideObjIsNullMsg=0

;Set to 1 to force critters to display combat float messages
Expand Down
Binary file modified artifacts/mods/gl_partycontrol.int
Binary file not shown.
24 changes: 15 additions & 9 deletions artifacts/mods/gl_partycontrol.ssl
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,10 @@
variable
controlMode,
noCheckArray,
pidList,
pidList, perksList,
lightInt, lightDist, npcControl,
displayName, displayNameColor, isShowTag,
inControl := false,
hasGeckoSkinning := false;
inControl := false;


procedure AllowControl(variable pid) begin
Expand All @@ -37,10 +36,9 @@ procedure combatturn_handler begin
variable
status := get_sfall_arg,
critter := get_sfall_arg,
//arg3 := get_sfall_arg,
pid;
pid, perkID, level;

//display_msg("Combat Turn: " + status + ", by " + obj_name(critter) + ", arg3: " + arg3);
//display_msg("Combat Turn: " + status + ", by " + obj_name(critter) + ", arg3: " + get_sfall_arg);
if npcControl then begin
if lightInt then lightInt := round((lightInt / 65536.0) * 100); // calc percent of intensity
obj_set_light_level(npcControl, lightInt, lightDist); // restore light for prev. controlled NPC
Expand All @@ -49,14 +47,20 @@ procedure combatturn_handler begin
pid := obj_pid(critter);
if (status == 1 and (AllowControl(pid) or controlMode == 1)) then begin
set_dude_obj(critter);
//display_msg("Take control of: " + obj_name(critter));
if (critter != real_dude_obj) then begin
if not(npcControl) then obj_set_light_level(real_dude_obj, 0, 0); // dude off light
npcControl := critter;
// set perks (only work with 4.1.8+)
foreach (perkID in perksList) begin
level := has_trait(TRAIT_PERK, real_dude_obj, perkID);
if (level) then begin
critter_add_trait(critter, TRAIT_PERK, perkID, level);
end
end
lightDist := get_object_data(critter, OBJ_DATA_LIGHT_DISTANCE);
lightInt := get_object_data(critter, OBJ_DATA_LIGHT_INTENSITY);
obj_set_light_level(critter, 100, 4);

if hasGeckoSkinning then critter_add_trait(critter, TRAIT_PERK, PERK_gecko_skinning_perk, 1);
inControl := true;
end else if npcControl then begin
obj_set_light_level(dude_obj, 100, 4); // set dude default light
Expand Down Expand Up @@ -87,7 +91,6 @@ procedure combatturn_handler begin
end

procedure gamemodechange_handler begin
if not(hasGeckoSkinning) then hasGeckoSkinning := has_trait(TRAIT_PERK, real_dude_obj, PERK_gecko_skinning_perk);
if (inControl and not(get_game_mode BWAND COMBAT)) then begin
inControl := false;
npcControl := 0;
Expand Down Expand Up @@ -146,6 +149,9 @@ procedure start begin
fix_array(pidList);
noCheckArray := (len_array(pidList) == 0);

perksList := GetConfigListInt("CombatControl", "PerksList");
fix_array(perksList);

register_hook_proc(HOOK_COMBATTURN, combatturn_handler);
register_hook_proc(HOOK_GAMEMODECHANGE, gamemodechange_handler);
register_hook_proc(HOOK_INVENTORYMOVE, inventorymove_handler);
Expand Down
2 changes: 1 addition & 1 deletion artifacts/scripting/headers/sfall.h
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@
#define ADD_PERK_MODE_REMOVE (4) // remove from the list of selectable perks

// sfall_funcX macros
#define add_extra_msg_file(name, number) sfall_func2("add_extra_msg_file", name, number)
#define add_extra_msg_file(name) sfall_func1("add_extra_msg_file", name)
#define add_iface_tag sfall_func0("add_iface_tag")
#define art_cache_clear sfall_func0("art_cache_clear")
#define attack_is_aimed sfall_func0("attack_is_aimed")
Expand Down
9 changes: 6 additions & 3 deletions artifacts/scripting/sfall function notes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -609,10 +609,13 @@ optional arguments:
> int sfall_func2("has_fake_trait_npc", object npc, string nameTrait)
- these functions are similar to has_fake_*/set_fake_*/set_selectable_perk functions, but apply to the specified party member NPC (including dude_obj)

> void sfall_func2("add_extra_msg_file", string fileName, int fileNumber)
- loads the custom message file and assigns it with the specified ID number
> int sfall_func1("add_extra_msg_file", string fileName)
> int sfall_func2("add_extra_msg_file", string fileName, int fileNumber)
- loads the custom message file, and returns the file ID number assigned to it in range from 0x3000 to 0x3FFF for the message_str_game function to get messages from the file
- fileName: the name of the custom message file (including the .msg extension) in "text\<language>\game\" directory
- fileNumber: the file ID number for the message_str_game function to get messages from the file. The available range is from 0x3000 to 0x3FFF
optional argument:
- fileNumber: the file ID number for the message_str_game function. The available range is from 0x2000 to 0x2FFF (see ExtraGameMsgFileList setting in ddraw.ini)
use fileNumber only if you want to add a message file without editing ddraw.ini or existing scripts to support the old way

------------------------
------ MORE INFO -------
Expand Down
9 changes: 7 additions & 2 deletions sfall/InputFuncs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -282,9 +282,14 @@ class FakeDirectInputDevice : public IDirectInputDeviceA {
for (DWORD i = 0; i < *c; i++) {
DWORD dxKey = b[i].dwOfs;
DWORD state = b[i].dwData & 0x80;
DWORD oldState = keysDown[dxKey];
keysDown[dxKey] = state;
HookScripts::KeyPressHook(&dxKey, (state > 0), MapVirtualKeyEx(dxKey, MAPVK_VSC_TO_VK, keyboardLayout));
if (dxKey != b[i].dwOfs && dxKey > 0) b[i].dwOfs = dxKey; // Override key
keysDown[b[i].dwOfs] = state;
if (dxKey > 0 && dxKey != b[i].dwOfs) {
keysDown[b[i].dwOfs] = oldState;
b[i].dwOfs = dxKey; // Override key
keysDown[b[i].dwOfs] = state;
}
onKeyPressed.invoke(b[i].dwOfs, (state > 0));
}
return hr;
Expand Down
2 changes: 1 addition & 1 deletion sfall/Modules/BugFixes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ void BugFixes::DrugsSaveFix(HANDLE file) {
bool BugFixes::DrugsLoadFix(HANDLE file) {
DWORD count, sizeRead;
ReadFile(file, &count, 4, &sizeRead, 0);
//if (sizeRead != 4) return true;
if (sizeRead != 4) return false;
for (DWORD i = 0; i < count; i++) {
DWORD pid;
ReadFile(file, &pid, 4, &sizeRead, 0);
Expand Down
3 changes: 2 additions & 1 deletion sfall/Modules/DebugEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -358,8 +358,9 @@ void DontDeleteProtosPatch() {
}

void DebugEditor::init() {
if (!isDebug) return;
DebugModePatch();

if (!isDebug) return;
DontDeleteProtosPatch();

debugEditorKey = GetConfigInt("Input", "DebugEditorKey", 0);
Expand Down
14 changes: 7 additions & 7 deletions sfall/Modules/HookScripts/CombatHs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ static void __declspec(naked) CalcApCostHook2() {
}
}

static void __fastcall ComputeDamageHook_Script(fo::ComputeAttackResult &ctd, DWORD rounds, DWORD multiply) {
static void __fastcall ComputeDamageHook_Script(fo::ComputeAttackResult &ctd, DWORD rounds, DWORD multiplier) {
BeginHook();
argCount = 12;

Expand All @@ -140,8 +140,8 @@ static void __fastcall ComputeDamageHook_Script(fo::ComputeAttackResult &ctd, DW
args[5] = ctd.attackerFlags; // flagsSource
args[6] = (DWORD)ctd.weapon;
args[7] = ctd.bodyPart;
args[8] = multiply; // multiply damage
args[9] = rounds; // number rounds
args[8] = multiplier; // damage multiplier
args[9] = rounds; // number of rounds
args[10] = ctd.knockbackValue;
args[11] = ctd.hitMode; // attack type

Expand All @@ -166,13 +166,13 @@ static void __fastcall ComputeDamageHook_Script(fo::ComputeAttackResult &ctd, DW
static void __declspec(naked) ComputeDamageHook() {
__asm {
push ecx;
push ebx; // store dmg multiply args[8]
push edx; // store num rounds args[9]
push ebx; // store dmg multiplier args[8]
push edx; // store num of rounds args[9]
push eax; // store ctd
call fo::funcoffs::compute_damage_;
pop ecx; // restore ctd (eax)
pop edx; // restore num rounds
call ComputeDamageHook_Script; // stack - arg multiply
pop edx; // restore num of rounds
call ComputeDamageHook_Script; // stack - arg multiplier
pop ecx;
retn;
}
Expand Down
10 changes: 6 additions & 4 deletions sfall/Modules/LoadGameHook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,8 @@ static void _stdcall SaveGame2() {
} else {
goto errorSave;
}

return;

/////////////////////////////////////////////////
errorSave:
dlog_f("ERROR creating: %s\n", DL_MAIN, buf);
Expand Down Expand Up @@ -229,8 +229,9 @@ static bool LoadGame_Before() {
if (uID > UniqueID::Start) Objects::uniqueID = uID;
ReadFile(h, &data, 4, &size, 0);
Worldmap::SetAddedYears(data >> 16);
if (size != 4 || !Perks::load(h) || script::LoadArrays(h)) goto errorLoad;
if (BugFixes::DrugsLoadFix(h)) goto errorLoad;
if (size != 4 || !Perks::load(h)) goto errorLoad;
long result = script::LoadArrays(h); // 1 - old save, -1 - broken save
if (result == -1 || (!result && BugFixes::DrugsLoadFix(h))) goto errorLoad;
CloseHandle(h);
} else {
dlogr("Cannot open sfallgv.sav - assuming non-sfall save.", DL_MAIN);
Expand All @@ -245,12 +246,13 @@ static bool LoadGame_Before() {
} else {
dlogr("Cannot open sfalldb.sav.", DL_MAIN);
}

return false;

/////////////////////////////////////////////////
errorLoad:
CloseHandle(h);
dlog_f("ERROR reading data: %s\n", DL_MAIN, buf);
fo::func::debug_printf("\n[SFALL] ERROR reading data: %s", buf);
return (true & !isDebug);
}

Expand Down
13 changes: 11 additions & 2 deletions sfall/Modules/Message.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ const fo::MessageList* gameMsgFiles[] = {
ExtraGameMessageListsMap gExtraGameMsgLists;
static std::vector<std::string> msgFileList;

static long msgNumCounter = 0x3000;

fo::MessageNode *GetMsgNode(fo::MessageList *msgList, int msgRef) {
if (msgList != nullptr && msgList->numMsgs > 0) {
fo::MessageNode *msgNode = msgList->nodes;
Expand Down Expand Up @@ -115,16 +117,22 @@ static void ReadExtraGameMsgFiles() {
}

long Message::AddExtraMsgFile(const char* msgName, long msgNumber) {
if (msgNumber < 0x3000 || msgNumber > 0x3FFF || gExtraGameMsgLists.count(msgNumber)) return -1;
if (msgNumber) {
if (msgNumber < 0x2000 || msgNumber > 0x2FFF) return -1;
if (gExtraGameMsgLists.count(msgNumber)) return 0; // file has already been added
} else if (msgNumCounter > 0x3FFF) return -3;

std::string path("game\\");
path += msgName;
fo::MessageList* list = new fo::MessageList();
if (fo::func::message_load(list, path.c_str())) {
if (msgNumber == 0) msgNumber = msgNumCounter++;
gExtraGameMsgLists.emplace(msgNumber, list);
} else {
delete list;
msgNumber = -2;
}
return 0;
return msgNumber;
}

static void ClearScriptAddedExtraGameMsg() { // C++11
Expand All @@ -136,6 +144,7 @@ static void ClearScriptAddedExtraGameMsg() { // C++11
++it;
}
}
msgNumCounter = 0x3000;
}

static void ClearReadExtraGameMsgFiles() {
Expand Down
Loading

0 comments on commit 7c23bb2

Please sign in to comment.