Merge branch 'develop'

This commit is contained in:
NovaRain
2018-09-06 21:18:59 +08:00
54 changed files with 2722 additions and 1236 deletions
+2 -1
View File
@@ -39,7 +39,8 @@ MotionScanner=0
Mode=0
;PIDList=62,89,97,107,160,161
;Choose a notification box to display the name of the controlled critter above the interface bar. Must be between 5 and 9
;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)
;Set to 0 to disable
DisplayName=0
+42 -3
View File
@@ -1,5 +1,5 @@
;sfall configuration settings
;v4.0.8
;v4.1
[Main]
;Change to 1 if you want to use command line args to tell sfall to use another ini file.
@@ -195,6 +195,10 @@ WorldMapSlots=0
;Modified: master_patches > critter_patches > patchXXX.dat > critter_dat > f2_res_patches > f2_res_dat > master_dat
DataLoadOrderPatch=0
;Set to 1 to enable loading alternative dialog msg files from text/language/dialog_female/ for female PC
;Set to 2 to also load subtitle files from text/language/cuts_female/ for female PC
FemaleDialogMsgs=0
;To change the default and starting player models, uncomment the next four lines.
;The default models can also be changed ingame via script
;MaleStartModel=hmwarr
@@ -371,8 +375,14 @@ Repair=293
RemoveWindowRounding=0
;Set to 1 to add scroll buttons to the pipboy quest list, and remove the quests per area limit
;Set to 2 to use a different set of scroll buttons
UseScrollingQuestsList=1
;To change the location of quest list scroll buttons, uncomment the next two lines
;Defaults are 140 for the X-axis and 334 for the Y-axis
;QuestsScrollButtonsX=140
;QuestsScrollButtonsY=334
;Uncomment these lines to control the premade characters offered when starting a new game
;Multiple options should be separated by commas, and there must be the same number of entries in both lines
;PremadePaths=combat,diplomat,stealth
@@ -388,6 +398,14 @@ UseScrollingQuestsList=1
;Set to 1 to add additional pages of save slots
ExtraSaveSlots=0
;To use more than one save slot for quick saving (F6 key) without picking a slot beforehand, set the next two lines
;AutoQuickSave sets how many save slots on a page you want to use for quick saving (valid range: 1..10)
;AutoQuickSavePage is the page number to use (valid range: 1..1000) if ExtraSaveSlots is enabled
;The quick saves will be rotated from the first slot on the page to the n-th slot
;Set to 0 to disable. AutoQuickSave will use page 1 if AutoQuickSavePage is disabled
AutoQuickSave=0
AutoQuickSavePage=0
;Set to 1 to speed up the HP/AC counter animations
;Set to 2 to update the HP/AC counters instantly
SpeedInterfaceCounterAnims=0
@@ -404,8 +422,11 @@ ScienceOnCritters=0
;Default is 166
SpeedInventoryPCRotation=166
;Uncomment to set the text colour of the extra 5 interface boxes
;The line must contain a 5 digits, each either a 0 for green or 1 for red
;Modify the number of the extra interface boxes available to modders. (Default is 5, and the maximum is 95)
BoxBarCount=5
;Uncomment to set the text colour of the extra interface boxes
;The line must contain the same number of digits as the value of BoxBarCount, each either a 0 for green or 1 for red
;BoxBarColours=00000
;Set to 1 to fix the bug that caused bonus HtH damage to not be applied correctly.
@@ -482,6 +503,9 @@ QuickPocketsApCostReduction=2
;Set to 1 to allow objects seeing through other objects with their ShootThru flag set
ObjCanSeeObj_ShootThru_Fix=0
;Set to 1 to fix the broken obj_can_hear_obj script function
ObjCanHearObjFix=0
;Set to 1 to enable the balanced bullet distribution formula for burst attacks
ComputeSprayMod=0
@@ -562,6 +586,9 @@ CarChargingFix=1
InstantWeaponEquip=0
;To add additional game msg files, uncomment the next line and set a comma delimited list of filenames without .msg extension
;By default, the files will have consecutive numbers assigned beginning with 0
;You can use the syntax 'filename:number' to manually assign numbers to specific msg files, with each pair separated by a comma
;If a file after the specified pair does not have a number assigned, it will have the next consecutive number from the last pair
;You need to use the message_str_game script function to get messages from the files
;ExtraGameMsgFileList=
@@ -571,6 +598,15 @@ NumbersInDialogue=0
;Set to 1 to use Fallout's normal text font instead of DOS-like font on the world map
WorldMapFontPatch=0
;Set to 1 to keep the selected attack mode when moving the weapon between active item slots
KeepWeaponSelectMode=1
;Set to 1 to display full item description for weapon/ammo in barter screen
FullItemDescInBarter=0
;Set to 1 to display experience points with the bonus from Swift Learner perk when gained from non-scripted situations
DisplaySwiftLearnerExp=1
;Set to 1 to display sfall built-in credits at the bottom of credits.txt contents instead of at the top
CreditsAtBottom=0
@@ -624,6 +660,9 @@ DontDeleteProtos=0
;Set to 1 to give scripts direct access to Fallout's address space, and to make arbitrary calls into Fallout's code
AllowUnsafeScripting=0
;Set to 1 to force sfall to inject all hooks code into the game, even if corresponding hook scripts don't exist
InjectAllGameHooks=0
;These options control what output is saved in the debug log (sfall-log.txt)
;Prints messages duing sfall initialization
@@ -0,0 +1,44 @@
/*
Example implementation of the algorithm of how the game engine sets the explosive timer.
*/
#include "..\..\scripting_docs\headers\sfall.h"
#include "..\..\scripting_docs\headers\define_lite.h"
// from CONDTION.H
#define ROLL_CRITICAL_FAILURE (0)
#define ROLL_FAILURE (1)
#define ROLL_SUCCESS (2)
#define ROLL_CRITICAL_SUCCESS (3)
procedure start;
procedure start begin
if game_loaded then begin
register_hook(HOOK_EXPLOSIVETIMER);
end else begin
variable
time := get_sfall_arg,
result := ROLL_CRITICAL_FAILURE;
if has_trait(TRAIT_PERK, dude_obj, PERK_demolition_expert_perk) then
result := ROLL_SUCCESS;
else begin
result := roll_vs_skill(dude_obj, SKILL_TRAPS, 0);
end
if (result) then begin
if (result == ROLL_FAILURE) then
time /= 2;
else begin // success or critical success
result := ROLL_SUCCESS;
end
end else begin // critical failure
time := 0;
result := ROLL_FAILURE;
end
set_sfall_return(time);
set_sfall_return(result); // failure/success
end
end
@@ -0,0 +1,60 @@
/*
Example implementation of the algorithm of how the game engine checks if one critter sees another critter.
NOTE: the AllowUnsafeScripting option must be enabled.
*/
#include "..\headers\define.h"
#include "..\headers\command.h"
#include "..\headers\sfall\sfall.h"
#include "..\headers\sfall\define_extra.h"
#define can_see_(source, target) call_offset_r2(0x412BEC, source, target)
#define obj_dist_(target, source) call_offset_r2(0x48BBD4, target, source)
procedure start;
procedure start begin
if game_loaded then begin
register_hook(HOOK_WITHINPERCEPTION);
end else begin
variable
source := get_sfall_arg,
target := get_sfall_arg,
original := get_sfall_arg,
hookType := get_sfall_arg, /* new arg */
result := 0,
distance;
if target then begin
distance := get_critter_stat(source, STAT_pe);
if can_see_(source, target) then begin
distance *= 5;
if (get_flags(target) bwand FLAG_TRANSGLASS) then distance /= 2;
end else if combat_is_initialized then begin
distance *= 2;
end
if (target == dude_obj) then begin
if sneak_success then begin
distance /= 4;
if has_skill(target, SKILL_SNEAK) > 120 then distance -= 1;
end else if dude_is_sneaking then begin
distance := distance * 2 / 3;
end
end
if obj_dist_(target, source) <= distance then result := 1;
// example
if (result) then begin
display_msg("hs_withinperception: " + obj_name(source) + " sees " + obj_name(target) + " [original: " + original + " script: " + result + "]");
end else begin
display_msg("hs_withinperception: " + obj_name(source) + " does not see " + obj_name(target) + " [original: " + original + " script: " + result + "]");
end
end
//set_sfall_return(result);
end
end
+5
View File
@@ -18,6 +18,7 @@
#define INTFACELOOT (0x10000)
#define BARTER (0x20000)
#define HEROWIN (0x40000)
#define DIALOGVIEW (0x80000)
//Valid arguments to register_hook
#define HOOK_TOHIT (0)
@@ -52,6 +53,8 @@
#define HOOK_SETGLOBALVAR (29)
#define HOOK_RESTTIMER (30)
#define HOOK_GAMEMODECHANGE (31)
#define HOOK_USEANIMOBJ (32)
#define HOOK_EXPLOSIVETIMER (33)
//Valid arguments to list_begin
#define LIST_CRITTERS (0)
@@ -221,6 +224,7 @@
#define attack_is_aimed sfall_func0("attack_is_aimed")
#define car_gas_amount sfall_func0("car_gas_amount")
#define critter_inven_obj2(obj, type) sfall_func2("critter_inven_obj2", obj, type)
#define dialog_message(text) sfall_func1("dialog_message", text)
#define display_stats sfall_func0("display_stats")
#define exec_map_update_scripts sfall_func0("exec_map_update_scripts")
#define floor2(value) sfall_func1("floor2", value)
@@ -230,6 +234,7 @@
#define get_ini_sections(file) sfall_func1("get_ini_sections", file)
#define get_map_enter_position sfall_func0("get_map_enter_position")
#define get_outline(obj) sfall_func1("get_outline", obj)
#define get_string_pointer(text) sfall_func1("get_string_pointer", text)
#define intface_hide sfall_func0("intface_hide")
#define intface_is_hidden sfall_func0("intface_is_hidden")
#define intface_redraw sfall_func0("intface_redraw")
+41 -3
View File
@@ -265,7 +265,8 @@ critter arg7 - table of offered goods (being sold to NPC)
int arg8 - the total cost of the goods offered by the player
int arg9 - set 1 if the "offers" button was pressed (not for a party member), otherwise 0
int ret1 - the modified value of all of the goods
int ret1 - the modified value of all of the goods (pass -1 if you just want to modify offered goods)
int ret2 - the modified value of all offered goods
-------------------------------------------
@@ -323,12 +324,12 @@ HOOK_AMMOCOST (hs_ammocost.int)
Runs when calculating ammo cost for a weapon. Doesn't affect damage, only how much ammo is spent.
By default, weapon will shoot when at least 1 round is left, regardless of ammo cost calculations.
To add proper check for ammo before shooting and proper calculation of number of burst rounds, set Misc.CheckWeaponAmmoCost=1 in ddraw.ini
To add proper check for ammo before shooting and proper calculation of number of burst rounds (hook type 1 and 2 in arg4), set Misc.CheckWeaponAmmoCost=1 in ddraw.ini
Item arg1 - weapon
int arg2 - Number of bullets in burst (1 for single shots)
int arg3 - Ammo cost calculated by original function (this is basically 2 for Super Cattle Prod and Mega Power Fist)
int arg4 - Type of hook (0 - when subtracting ammo after attack, 1 - when checking for "out of ammo" before attack)
int arg4 - Type of hook (0 - when subtracting ammo after single shot attack, 1 - when checking for "out of ammo" before attack, 2 - when calculating number of burst rounds, 3 - when subtracting ammo after burst attack)
int ret1 - new ammo cost value (set to 0 for unlimited ammo)
@@ -400,6 +401,7 @@ This is fired after the default calculation is made.
Critter arg1 - Watcher object
Obj arg2 - Target object
int arg3 - Result of vanilla function: 1 - within perception range, 0 - otherwise
int arg4 - Type of hook: 1 - when being called from obj_can_see_obj script function, 2 when being called from obj_can_hear_obj script function (need to set ObjCanHearObjFix=1 in ddraw.ini), 0 for all other cases
int ret1 - overrides the returned result of the function: 0 - not in range (can't see), 1 - in range (will see if not blocked), 2 - forced detection (will see regardless, only used in obj_can_see_obj scripting function which is called by every critter in the game)
@@ -506,3 +508,39 @@ HOOK_GAMEMODECHANGE (hs_gamemodechange.int)
Runs once every time when the game mode was changed, like opening/closing the inventory, character screen, pipboy, etc.
int arg1 - event type: 1 - when the player exits the game, 0 - otherwise
-------------------------------------------
HOOK_USEANIMOBJ (hs_useanimobj.int)
Runs before playing the "use" (usually "magic hands") animation when a critter uses a scenery/container object on the map, or before walking/running animation if the player is at a distance from the object.
Critter arg1 - the critter that uses an object (usually dude_obj)
Obj arg2 - the object being used
int arg3 - the animation code being used (see ANIM_* in Animcomd.h)
int ret1 - overrides the animation code (pass -1 if you want to skip the animation)
-------------------------------------------
HOOK_EXPLOSIVETIMER (hs_explosivetimer.int)
Runs after setting the explosive timer. You can override the result.
int arg1 - the time in ticks set in the timer
Obj arg2 - the explosive object
int arg3 - the result of engine calculation of whether the timer was set successfully: 1 - failure, 2 - success (similar to ROLL_* in Condtion.h)
int ret1 - overrides the time of the timer (maximum 18000 ticks)
int ret2 - overrides the result of engine calculation: 0/1 - failure, 2/3 - success (similar to ROLL_*), any other value - use engine handler
-------------------------------------------
HOOK_DESCRIPTIONOBJ (hs_descriptionobj.int)
Runs when using the examine action icon to display item description. You can override the description of the item.
An example usage would be to add an additional description to the item based on player's stats/skills.
Obj arg1 - the item
int ret1 - a pointer to the new text received by using "get_string_pointer" function
+9 -2
View File
@@ -50,7 +50,7 @@ has_fake_trait and has_fake_perk return the number of levels the player has of t
perk_add_mode, set_selectable_perk, set_perkbox_title, hide_real_perks, show_real_perks and clear_selectable_perks control the behaviour of the select a perk box. set_selectable_perk can be used to add additional items by setting the 'active' parameter to 1, and to remove them again by setting it to 0. set_perkbox_title can be used to change the title of the box, or by using "" it will be set back to the default. hide and show_real_perks can be used to prevent the dialog from displaying any of the original 119 perks. perk_add_mode modifies what happens when a fake perk is selected from the perks dialog. It is treated as a set of flags - if bit 1 is set then it is added to the players traits, if bit 2 is set it is added to the players perks, and if bit 3 is set it is removed from the list of selectable perks. The default is 0x2. clear_selectable_perks restores the dialog to it's default state.
show_iface_tag, hide_iface_tag and is_iface_tag_active relate to the boxes that appear above the interface such as SNEAK and LEVEL. You can use 3 for LEVEL and 4 for ADDICT, or the range from 5 to 9 for custom boxes. Remember to add your messages to intrface.msg and set up the font colours in ddraw.ini if you're going to use custom boxes.
show_iface_tag, hide_iface_tag and is_iface_tag_active relate to the boxes that appear above the interface such as SNEAK and LEVEL. You can use 3 for LEVEL and 4 for ADDICT, or the range from 5 to (4 + the value of BoxBarCount in ddraw.ini) for custom boxes. Remember to add your messages to intrface.msg and set up the font colours in ddraw.ini if you're going to use custom boxes. Starting from sfall 4.1, is_iface_tag_active can also be used to check 0 for SNEAK, 1 for POISONED, and 2 for RADIATED.
get/set_bodypart_hit_modifier alter the hit percentage modifiers for aiming at specific bodyparts. Valid bodypart id's are from 0 to 8. Changes are not saved, and will reset to the defaults (or to the values specified in ddraw.ini if they exist) at each reload.
@@ -304,6 +304,7 @@ Some utility/math functions are available:
- works exactly the same as message_str, except you get messages from files in "text/english/game" folder
- use GAME_MSG_* defines or mstr_* macros from sfall.h to use specific msg file
- Additional game msg files added by ExtraGameMsgFileList setting will have consecutive fileIds assigned beginning from 0x2000. (e.g. if you set ExtraGameMsgFileList=foo,bar in ddraw.ini, foo.msg will be associated with 0x2000 and bar.msg with 0x2001.)
- if a file has a specific number assigned in ExtraGameMsgFileList, its fileId will be (0x2000 + assigned number). (e.g. with ExtraGameMsgFileList=foo,bar:2,foobar in ddraw.ini, bar.msg will be associated with 0x2002 and foobar.msg with 0x2003.)
> int sneak_success
- returns 1 if the player is currently sneaking, and last sneak attempt (roll against skill) was successful; 0 otherwise
@@ -482,7 +483,7 @@ Some utility/math functions are available:
> void sfall_func3("set_iface_tag_text", int tag, string text, int color)
- sets the text messages and colors for custom notification boxes to the interface without the need to add messages to intrface.msg and set up the font colors in ddraw.ini
- tag value is the same as used in show_iface_tag, hide_iface_tag, and is_iface_tag_active. The valid range is from 5 to 9 (custom boxes)
- tag value is the same as used in show_iface_tag, hide_iface_tag, and is_iface_tag_active. The valid range is from 5 to (4 + the value of BoxBarCount in ddraw.ini)
- The text is limited to 19 characters
- available colors: 0 - green, 1 - red, 2 - white, 3 - yellow, 4 - dark yellow, 5 - blue, 6 - purple
@@ -490,6 +491,12 @@ Some utility/math functions are available:
- redraws inventory list in the inventory/use inventory item on/loot/barter screens
- invSide specifies which side needs to be redrawn: 0 - the player, 1 - target (container/NPC in loot/barter screens)
> int sfall_func1("get_string_pointer", string text)
- returns a pointer to a string variable or to a text
> void sfall_func1("dialog_message", string text)
- displays a message in the NPC response window in dialog or barter screen
------------------------
------ MORE INFO -------
------------------------
+17 -4
View File
@@ -20,6 +20,7 @@
#include "Functions.h"
#include "Structs.h"
#include "Variables.h"
#include "VariableOffsets.h"
#include "EngineUtils.h"
@@ -79,21 +80,33 @@ int _fastcall GetItemType(GameObject* item) {
}
_declspec(noinline) GameObject* GetItemPtrSlot(GameObject* critter, InvenType slot) {
GameObject* itemPtr = 0;
GameObject* itemPtr = nullptr;
switch (slot) {
case fo::INVEN_TYPE_LEFT_HAND :
case fo::INVEN_TYPE_LEFT_HAND:
itemPtr = fo::func::inven_left_hand(critter);
break;
case fo::INVEN_TYPE_RIGHT_HAND :
case fo::INVEN_TYPE_RIGHT_HAND:
itemPtr = fo::func::inven_right_hand(critter);
break;
case fo::INVEN_TYPE_WORN :
case fo::INVEN_TYPE_WORN:
itemPtr = fo::func::inven_worn(critter);
break;
}
return itemPtr;
}
long& GetActiveItemMode() {
return fo::var::itemButtonItems[fo::var::itemCurrentItem].mode;
}
GameObject* GetActiveItem() {
return fo::var::itemButtonItems[fo::var::itemCurrentItem].item;
}
bool HeroIsFemale() {
return (fo::func::stat_level(fo::var::obj_dude, fo::Stat::STAT_gender) == fo::Gender::GENDER_FEMALE);
}
//---------------------------------------------------------
//print text to surface
void PrintText(char *DisplayText, BYTE ColourIndex, DWORD Xpos, DWORD Ypos, DWORD TxtWidth, DWORD ToWidth, BYTE *ToSurface) {
+6
View File
@@ -54,6 +54,12 @@ int _fastcall GetItemType(GameObject* item);
_declspec(noinline) GameObject* GetItemPtrSlot(GameObject* critter, InvenType slot);
long& GetActiveItemMode();
GameObject* GetActiveItem();
bool HeroIsFemale();
// Print text to surface
void PrintText(char *displayText, BYTE colorIndex, DWORD x, DWORD y, DWORD textWidth, DWORD destWidth, BYTE *surface);
// gets the height of the currently selected font
+81
View File
@@ -213,6 +213,15 @@ enum ObjType : char
OBJ_TYPE_SPATIAL = 6
};
enum ArtType : char
{
OBJ_TYPE_INTRFACE = 6,
OBJ_TYPE_INVEN = 7,
OBJ_TYPE_HEAD = 8,
OBJ_TYPE_BACKGROUND = 9,
OBJ_TYPE_SKILLDEX = 10
};
// Some FO2 PIDs possibly used by engine
enum ProtoId : long
{
@@ -587,6 +596,30 @@ enum InvenType : long
INVEN_TYPE_LEFT_HAND = 2,
};
enum AttackType : long
{
ATKTYPE_LWEAPON_PRIMARY = 0,
ATKTYPE_LWEAPON_SECONDARY = 1,
ATKTYPE_RWEAPON_PRIMARY = 2,
ATKTYPE_RWEAPON_SECONDARY = 3,
ATKTYPE_PUNCH = 4,
ATKTYPE_KICK = 5,
ATKTYPE_LWEAPON_RELOAD = 6,
ATKTYPE_RWEAPON_RELOAD = 7,
ATKTYPE_STRONGPUNCH = 8,
ATKTYPE_HAMMERPUNCH = 9,
ATKTYPE_HAYMAKER = 10,
ATKTYPE_JAB = 11,
ATKTYPE_PALMSTRIKE = 12,
ATKTYPE_PIERCINGSTRIKE = 13,
ATKTYPE_STRONGKICK = 14,
ATKTYPE_SNAPKICK = 15,
ATKTYPE_POWERKICK = 16,
ATKTYPE_HIPKICK = 17,
ATKTYPE_HOOKKICK = 18,
ATKTYPE_PIERCINGKICK = 19
};
#define OBJFLAG_CAN_WEAR_ITEMS (0xf000000)
#define OBJFLAG_HELD_IN_RIGHT (0x10000)
@@ -608,4 +641,52 @@ enum RollResult
ROLL_CRITICAL_SUCCESS = 0x3,
};
namespace Fields {
enum CommonObj : long
{
id = 0x00,
tile = 0x04,
x = 0x08,
y = 0x0C,
sx = 0x10,
sy = 0x14,
frm = 0x18,
rotation = 0x1C,
artFid = 0x20,
flags = 0x24,
elevation = 0x28,
inventory = 0x2C,
protoId = 0x64,
cid = 0x68,
lightDistance = 0x6C,
lightIntensity = 0x70,
outline = 0x74,
scriptId = 0x78,
owner = 0x7C,
scriptIndex = 0x80,
};
enum CritterObj : long
{
reaction = 0x38,
combatState = 0x3C,
movePoints = 0x40,
damageFlags = 0x44,
damageLastTurn = 0x48,
aiPacket = 0x4C,
teamNum = 0x50,
whoHitMe = 0x54,
health = 0x58,
rads = 0x5C,
poison = 0x60,
};
enum ItemObj : long
{
updatedFlags = 0x38,
charges = 0x3C,
ammoPid = 0x40,
};
}
}
@@ -1562,12 +1562,15 @@ FUNC(gsound_internal_effect_callback_, 0x451AD0)
FUNC(gsound_internal_speech_callback_, 0x451A90)
FUNC(gsound_load_sound_, 0x4510DC)
FUNC(gsound_load_sound_volume_, 0x45145C)
FUNC(gsound_med_butt_press_, 0x451988)
FUNC(gsound_med_butt_release_, 0x451990)
FUNC(gsound_open_, 0x451A08)
FUNC(gsound_play_sfx_file_, 0x4519A8)
FUNC(gsound_play_sfx_file_volume_, 0x45108C)
FUNC(gsound_play_sound_, 0x451510)
FUNC(gsound_read_, 0x451A30)
FUNC(gsound_red_butt_press_, 0x451970)
FUNC(gsound_red_butt_release_, 0x451978)
FUNC(gsound_reset_, 0x450164)
FUNC(gsound_seek_, 0x451A4C)
FUNC(gsound_set_master_volume_, 0x4502EC)
+9
View File
@@ -63,6 +63,15 @@ bool __stdcall art_exists(long artFid) {
WRAP_WATCOM_CALL1(art_exists_, artFid)
}
long __fastcall _word_wrap(const char* text, int maxWidth, DWORD* buf, BYTE* count) {
__asm {
mov eax, ecx;
mov ecx, count;
mov ebx, buf;
call fo::funcoffs::_word_wrap_;
}
}
// Returns the name of the critter
const char* __stdcall critter_name(GameObject* critter) {
WRAP_WATCOM_CALL1(critter_name_, critter)
+2
View File
@@ -36,6 +36,8 @@ namespace func
bool __stdcall art_exists(long artFid);
long __fastcall _word_wrap(const char* text, int maxWidth, DWORD* buf, BYTE* count);
// Returns the name of the critter
const char* __stdcall critter_name(GameObject* critter);
+12 -1
View File
@@ -24,6 +24,7 @@ WRAP_WATCOM_FUNC2(FrmFrameData*, art_ptr_lock, long, frmId, DWORD*, lockPtr)
WRAP_WATCOM_FUNC4(BYTE*, art_ptr_lock_data, long, frmId, long, frameNum, long, rotation, DWORD*, lockPtr)
WRAP_WATCOM_FUNC4(BYTE*, art_lock, long, frmId, DWORD*, lockPtr, long*, widthOut, long*, heightOut)
WRAP_WATCOM_FUNC1(long, art_ptr_unlock, DWORD, lockId)
WRAP_WATCOM_FUNC2(long, barter_compute_value, GameObject*, source, GameObject*, target)
WRAP_WATCOM_FUNC1(void*, dbase_open, const char*, fileName)
WRAP_WATCOM_FUNC1(void, dbase_close, void*, dbPtr)
WRAP_WATCOM_FUNC3(long, db_freadShortCount, DbFile*, file, WORD*, dest, long, count)
@@ -38,6 +39,7 @@ WRAP_WATCOM_FUNC2(long, combat_turn, GameObject*, critter, long, isDudeTurn)
WRAP_WATCOM_FUNC1(long, critter_is_dead, GameObject*, critter)
WRAP_WATCOM_FUNC1(void, EndLoad, DbFile*, file)
WRAP_WATCOM_FUNC1(long, game_get_global_var, long, globalVar)
WRAP_WATCOM_FUNC1(void, gdialogDisplayMsg, const char*, message)
WRAP_WATCOM_FUNC1(long, gmouse_3d_set_mode, long, mode)
WRAP_WATCOM_FUNC1(long, gmouse_set_cursor, long, picNum)
WRAP_WATCOM_FUNC1(Window*, GNW_find, long, winRef)
@@ -45,8 +47,14 @@ WRAP_WATCOM_FUNC0(long, intface_is_item_right_hand)
WRAP_WATCOM_FUNC0(void, intface_toggle_item_state)
WRAP_WATCOM_FUNC0(void, intface_use_item)
WRAP_WATCOM_FUNC0(long, is_pc_sneak_working)
WRAP_WATCOM_FUNC1(long, item_w_max_ammo, GameObject*, item)
WRAP_WATCOM_FUNC1(long, item_caps_total, GameObject*, object)
WRAP_WATCOM_FUNC1(long, item_total_cost, GameObject*, object)
WRAP_WATCOM_FUNC1(long, item_w_anim_code, GameObject*, item)
WRAP_WATCOM_FUNC2(long, item_w_anim_weap, GameObject*, item, DWORD, hitMode)
WRAP_WATCOM_FUNC2(long, item_w_compute_ammo_cost, GameObject*, item, DWORD*, rounds)
WRAP_WATCOM_FUNC1(long, item_w_curr_ammo, GameObject*, item)
WRAP_WATCOM_FUNC1(long, item_w_rounds, GameObject*, item)
WRAP_WATCOM_FUNC1(long, item_w_max_ammo, GameObject*, item)
WRAP_WATCOM_FUNC1(long, item_weight, GameObject*, item)
// returns light level at given tile
WRAP_WATCOM_FUNC2(long, light_get_tile, long, elevation, long, tileNum)
@@ -57,9 +65,12 @@ WRAP_WATCOM_FUNC0(void, mouse_hide)
WRAP_WATCOM_FUNC6(long, make_path_func, GameObject*, objectFrom, long, tileFrom, long, tileTo, char*, pathDataBuffer, long, arg5, void*, blockingFunc)
// calculates bounding box (rectangle) for a given object
WRAP_WATCOM_FUNC2(void, obj_bound, GameObject*, object, BoundRect*, boundRect)
WRAP_WATCOM_FUNC2(long, obj_erase_object, GameObject*, object, BoundRect*, boundRect)
WRAP_WATCOM_FUNC2(long, obj_pid_new, fo::GameObject*, object, long, pid)
// checks/unjams jammed locks
WRAP_WATCOM_FUNC1(long, obj_lock_is_jammed, GameObject*, object)
WRAP_WATCOM_FUNC1(void, obj_unjam_lock, GameObject*, object)
WRAP_WATCOM_FUNC6(long, pick_death, GameObject*, attacker, GameObject*, target, GameObject*, weapon, long, amount, long, anim, long, hitFromBack)
WRAP_WATCOM_FUNC3(long, register_object_animate, GameObject*, object, long, anim, long, delay)
WRAP_WATCOM_FUNC3(long, register_object_animate_and_hide, GameObject*, object, long, anim, long, delay)
// WRAP_WATCOM_FUNC3(long, register_object_animate_and_move_straight_, GameObject*, object;
+27 -3
View File
@@ -100,7 +100,7 @@ struct GameObject {
union {
struct {
char gap_38[4];
char updatedFlags[4];
// for weapons - ammo in magazine, for ammo - amount of ammo in last ammo pack
long charges;
// current type of ammo loaded in magazine
@@ -151,8 +151,8 @@ struct ComputeAttackResult {
GameObject* target;
long targetTile;
long bodyPart;
long damage;
long flags;
long targetDamage;
long targetFlags;
long knockbackValue;
GameObject* mainTarget;
long numExtras;
@@ -640,4 +640,28 @@ struct Window {
long drawFuncP;
};
#pragma pack(1)
struct LSData {
char signature[24];
short majorVer;
short minorVer;
char charR;
char playerName[32];
char comment[30];
char unused1;
short realMonth;
short realDay;
short realYear;
short unused2;
long realTime;
short gameMonth;
short gameDay;
short gameYear;
short unused3;
long gameTime;
short mapElev;
short mapNumber;
char mapName[16];
};
}
+11
View File
@@ -5,6 +5,7 @@
// To add another variable, first add FO_VAR_* constant with it's address, then add it in Varaibles_def.h
// PLEASE USE THOSE IN ASM BLOCKS!
#define FO_VAR_aDialogS_msg 0x50DBE8
#define FO_VAR_aiInfoList 0x510948
#define FO_VAR_ambient_light 0x51923C
#define FO_VAR_anim_set 0x54CC14
@@ -12,6 +13,10 @@
#define FO_VAR_art_name 0x56C9E4
#define FO_VAR_art_vault_guy_num 0x5108A4
#define FO_VAR_art_vault_person_nums 0x5108A8
#define FO_VAR_aTextSCuts 0x501A8C
#define FO_VAR_aTextSCutsS 0x503530
#define FO_VAR_aTextSCutsSS 0x50B01C
#define FO_VAR_bboxslot 0x5970E0
#define FO_VAR_bckgnd 0x5707A4
#define FO_VAR_black_palette 0x663FD0
#define FO_VAR_BlueColor 0x6A38EF
@@ -125,6 +130,12 @@
#define FO_VAR_objectTable 0x639DA0
#define FO_VAR_objItemOutlineState 0x519798
#define FO_VAR_optionRect 0x58ECC0
#define FO_VAR_optionsButtonDown 0x59D400
#define FO_VAR_optionsButtonDown1 0x570518
#define FO_VAR_optionsButtonDownKey 0x518F2C
#define FO_VAR_optionsButtonUp 0x59D3FC
#define FO_VAR_optionsButtonUp1 0x570514
#define FO_VAR_optionsButtonUpKey 0x518F28
#define FO_VAR_outlined_object 0x518D94
#define FO_VAR_partyMemberAIOptions 0x519DB8
#define FO_VAR_partyMemberCount 0x519DAC
+6
View File
@@ -120,6 +120,12 @@ VAR_(obj_dude, GameObject*)
VAR_(objectTable, DWORD)
VAR_(objItemOutlineState, DWORD)
VAR_(optionRect, DWORD)
VAR_(optionsButtonDown, DWORD)
VAR_(optionsButtonDown1, DWORD)
VAR_(optionsButtonDownKey, DWORD)
VAR_(optionsButtonUp, DWORD)
VAR_(optionsButtonUp1, DWORD)
VAR_(optionsButtonUpKey, DWORD)
VAR_(outlined_object, GameObject*)
VAR_(partyMemberAIOptions, DWORD)
VAR_(partyMemberCount, DWORD)
+110 -67
View File
@@ -29,70 +29,78 @@ static const DWORD DisplayBoxesRet1 = 0x4615A8;
static const DWORD DisplayBoxesRet2 = 0x4615BE;
static const DWORD SetIndexBoxRet = 0x4612E8;
int BarBoxes::boxCount; // total count box
static int actualBoxCount;
static int sizeBox;
#define sSize (12)
struct sBox {
DWORD msg;
DWORD colour;
void* mem;
};
static sBox boxes[10];
static DWORD boxesEnabled[5];
#define tSize (28)
#define tSize (25)
struct tBox {
DWORD hasText;
bool hasText;
DWORD color;
char text[tSize - 8];
char text[tSize - 5];
};
static tBox boxText[5];
static DWORD clrBakup[5];
static sBox* boxes;
static tBox* boxText;
static bool* boxesEnabled;
static DWORD* colorBakup;
static bool setCustomBoxText;
static const DWORD bboxMemAddr[] = {
0x461266, 0x4612AC, 0x461374, 0x4613E8, 0x461479, 0x46148C, 0x4616BB,
};
static void __declspec(naked) DisplayBoxesHook() {
static void __declspec(naked) DisplayBoxesHack() {
__asm {
mov ebx, 0;
mov edx, [boxesEnabled];
mov ebx, 0;
start:
mov eax, boxesEnabled[ebx * 4];
test eax, eax;
jz next;
lea eax, [ebx + 5];
mov al, byte ptr [edx][ebx];
test al, al;
jz next;
lea eax, [ebx + 5];
call fo::funcoffs::add_bar_box_;
add esi, eax;
add esi, eax;
next:
inc ebx;
cmp ebx, 5;
jne start;
cmp esi, 1;
jle fail;
jmp DisplayBoxesRet1;
inc ebx;
cmp ebx, actualBoxCount;
jne start;
// engine code
cmp esi, 1;
jle fail;
jmp DisplayBoxesRet1;
fail:
jmp DisplayBoxesRet2;
jmp DisplayBoxesRet2;
}
}
static void __declspec(naked) BarBoxesTextHack() {
__asm {
//mov ecx, [esp + 0x440 - 0x1C];
push ecx; // ecx = BoxIndex
sub ecx, 5;
push ecx; // ecx = BoxIndex
sub ecx, 5;
imul ecx, tSize;
cmp boxText[ecx], 1; // .hasText
jnz end;
mov esi, [boxText]; // boxText addr
cmp byte ptr [esi][ecx], 1; // .hasText
jnz end;
// get color
mov ebx, boxText[ecx + 4]; // .color
mov ebx, dword ptr [esi][ecx + 1]; // .color
// set text
lea eax, [boxText + ecx + 8]; // .text
lea eax, [esi + ecx + 5]; // .text
// set color
pop ecx;
pop ecx;
imul ecx, sSize;
cmp boxes[ecx + 4], 2; // .colour
jb skip;
mov [esp + 0x440 - 0x20], ebx; // Color
mov esi, [boxes]; // boxes addr
cmp dword ptr [esi][ecx + 4], 2; // .colour
jb skip;
mov [esp + 0x440 - 0x20], ebx; // Color
skip:
retn;
end:
@@ -110,6 +118,18 @@ static void __declspec(naked) BarBoxesIndexHack() {
}
}
static const DWORD SizeLoopBoxRet = 0x461477;
static const DWORD ExitLoopBoxRet = 0x461498;
static void __declspec(naked) BarBoxesSizeHack() {
__asm {
cmp edx, sizeBox;
jz exitLoop;
jmp SizeLoopBoxRet;
exitLoop:
jmp ExitLoopBoxRet;
}
}
static void ReconstructBarBoxes() {
__asm {
call fo::funcoffs::refresh_box_bar_win_;
@@ -119,9 +139,9 @@ static void ReconstructBarBoxes() {
}
static void ResetBoxes() {
for (int i = 0; i < 5; i++) {
boxesEnabled[i] = 0;
boxes[i + 5].colour = clrBakup[i];
for (int i = 0; i < actualBoxCount; i++) {
boxesEnabled[i] = false;
boxes[i + 5].colour = colorBakup[i];
}
if (!setCustomBoxText) return;
@@ -138,7 +158,7 @@ static void ResetBoxes() {
void BarBoxes::SetText(int box, const char* text, DWORD color) {
boxes[box].colour = color;
box -= 5;
boxText[box].hasText = 1;
boxText[box].hasText = true;
strncpy_s(boxText[box].text, text, _TRUNCATE);
DWORD clr;
@@ -163,10 +183,10 @@ void BarBoxes::SetText(int box, const char* text, DWORD color) {
}
boxText[box].color = clr;
int enabled[5];
for (int i = 0; i < 5; i++) {
bool* enabled = new bool[actualBoxCount];
for (int i = 0; i < actualBoxCount; i++) {
enabled[i] = boxesEnabled[i];
boxesEnabled[i] = 0;
boxesEnabled[i] = false;
}
if (!setCustomBoxText) {
@@ -177,59 +197,82 @@ void BarBoxes::SetText(int box, const char* text, DWORD color) {
ReconstructBarBoxes();
for (int i = 0; i < 5; i++) {
for (int i = 0; i < actualBoxCount; i++) {
boxesEnabled[i] = enabled[i];
}
delete[] enabled;
__asm call fo::funcoffs::refresh_box_bar_win_;
}
void BarBoxes::init() {
SafeWriteBatch<DWORD>((DWORD)boxes + 8, bboxMemAddr); //.mem
SafeWrite32(0x4612FE, (DWORD)boxes + 4); //.colour
SafeWrite32(0x46133C, (DWORD)boxes); //.msg
int size = sSize * 10;
memset(boxes, 0, size);
memset(boxesEnabled, 0, 5 * 4);
boxCount = 5 + GetConfigInt("Misc", "BoxBarCount", 5);
if (boxCount < 10) boxCount = 10;
if (boxCount > 100) boxCount = 100;
actualBoxCount = boxCount - 5;
sizeBox = sSize * boxCount;
boxes = new sBox[boxCount]();
boxText = new tBox[actualBoxCount]();
boxesEnabled = new bool[actualBoxCount]();
colorBakup = new DWORD[actualBoxCount]();
memcpy(boxes, (void*)0x518FE8, sSize * 5);
for (int i = 5; i < 10; i++) {
for (int i = 5; i < boxCount; i++) {
boxes[i].msg = 100 + i;
}
SafeWrite8(0x46127C, 10);
SafeWrite8(0x46140B, 10);
SafeWrite8(0x461495, size);
MakeJump(0x4615A3, DisplayBoxesHook);
auto boxBarColors = GetConfigString("Misc", "BoxBarColours", "", 6);
if (boxBarColors.size() >= 5) {
for (int i = 0; i < 5; i++) {
if (boxBarColors[i] == '1') {
boxes[i + 5].colour = 1;
clrBakup[i] = 1;
} else {
clrBakup[i] = 0;
}
auto boxBarColors = GetConfigString("Misc", "BoxBarColours", "", actualBoxCount + 1);
int size = boxBarColors.size();
for (int i = 0; i < size; i++) {
if (boxBarColors[i] == '1') {
boxes[i + 5].colour = 1;
colorBakup[i] = 1;
}
}
SafeWriteBatch<DWORD>((DWORD)boxes + 8, bboxMemAddr); //.mem
SafeWrite32(0x4612FE, (DWORD)boxes + 4); //.colour
SafeWrite32(0x46133C, (DWORD)boxes); //.msg
SafeWrite8(0x46127C, boxCount);
SafeWrite8(0x46140B, boxCount);
if (boxCount > 10) {
MakeJump(0x461493, BarBoxesSizeHack);
} else {
SafeWrite8(0x461495, sizeBox);
}
MakeJump(0x4615A3, DisplayBoxesHack);
LoadGameHook::OnGameReset() += ResetBoxes;
}
int _stdcall GetBox(int i) {
if (i < 5 || i > 9) return 0;
bool BarBoxes::GetBox(int i) {
if (i < 5 || i > BarBoxes::MaxBox()) return false;
return boxesEnabled[i - 5];
}
void _stdcall AddBox(int i) {
if (i < 5 || i > 9) return;
void BarBoxes::AddBox(int i) {
if (i < 5 || i > BarBoxes::MaxBox()) return;
boxesEnabled[i - 5] = 1;
_asm call fo::funcoffs::refresh_box_bar_win_;
}
void _stdcall RemoveBox(int i) {
if (i < 5 || i > 9) return;
void BarBoxes::RemoveBox(int i) {
if (i < 5 || i > BarBoxes::MaxBox()) return;
boxesEnabled[i - 5] = 0;
_asm call fo::funcoffs::refresh_box_bar_win_;
}
void BarBoxes::exit() {
delete[] boxes;
delete[] boxText;
delete[] boxesEnabled;
delete[] colorBakup;
}
}
+10 -4
View File
@@ -4,15 +4,21 @@ namespace sfall
{
class BarBoxes : public Module {
private:
static int boxCount;
public:
const char* name() { return "BarBoxes"; }
void init();
void exit() override;
static int MaxBox() { return boxCount - 1; }
static void SetText(int box, const char* text, DWORD color);
static bool GetBox(int);
static void AddBox(int);
static void RemoveBox(int);
};
int _stdcall GetBox(int i);
void _stdcall AddBox(int i);
void _stdcall RemoveBox(int i);
}
File diff suppressed because it is too large Load Diff

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