mirror of
https://github.com/sfall-team/sfall.git
synced 2026-07-27 16:52:34 -07:00
Decoupled hook type 2 of HOOK_AMMOCOST from CheckWeaponAmmoCost
Edits to documents to reflect the hook change. Changed CheckWeaponAmmoCost to be enabled by default. Updated version number.
This commit is contained in:
+3
-3
@@ -1,5 +1,5 @@
|
|||||||
;sfall configuration settings
|
;sfall configuration settings
|
||||||
;v4.3.8.1
|
;v4.3.9
|
||||||
|
|
||||||
[Main]
|
[Main]
|
||||||
;Set to 1 to enable the built-in High Resolution Patch mode that is similar to the hi-res patch by Mash
|
;Set to 1 to enable the built-in High Resolution Patch mode that is similar to the hi-res patch by Mash
|
||||||
@@ -618,10 +618,10 @@ ExplosionsEmitLight=0
|
|||||||
;MovieTimer_artimer3=270
|
;MovieTimer_artimer3=270
|
||||||
;MovieTimer_artimer4=360
|
;MovieTimer_artimer4=360
|
||||||
|
|
||||||
;Set to 1 to add proper check for ammo before attacking and proper calculation of the number of burst rounds
|
;Set to 1 to add proper checks for ammo before attacking
|
||||||
;By default, a weapon can perform an attack with at least one ammo, regardless of ammo cost calculation
|
;By default, a weapon can perform an attack with at least one ammo, regardless of ammo cost calculation
|
||||||
;Note that enabling this option will prevent super cattle prods and mega power fists from attacking with only one ammo left
|
;Note that enabling this option will prevent super cattle prods and mega power fists from attacking with only one ammo left
|
||||||
CheckWeaponAmmoCost=0
|
CheckWeaponAmmoCost=1
|
||||||
|
|
||||||
;Controls the speed of combat panel animations (lower - faster; valid range: 0..65535)
|
;Controls the speed of combat panel animations (lower - faster; valid range: 0..65535)
|
||||||
CombatPanelAnimDelay=1000
|
CombatPanelAnimDelay=1000
|
||||||
|
|||||||
@@ -1560,7 +1560,7 @@
|
|||||||
detail: void set_spray_settings(int centerMult, int centerDiv, int targetMult, int targetDiv)
|
detail: void set_spray_settings(int centerMult, int centerDiv, int targetMult, int targetDiv)
|
||||||
doc: |
|
doc: |
|
||||||
Allows to dynamically change the multipilers and divisors for the bullet distribution of burst attacks. All settings are automatically reset to default values (**ComputeSpray_\*** settings in ddraw.ini) after each attack action
|
Allows to dynamically change the multipilers and divisors for the bullet distribution of burst attacks. All settings are automatically reset to default values (**ComputeSpray_\*** settings in ddraw.ini) after each attack action
|
||||||
- Should be called before the calculation of the bullet distribution (e.g. in `HOOK_TOHIT` or `HOOK_AMMOCOST` with **CheckWeaponAmmoCost=1** in ddraw.ini)
|
- Should be called before the calculation of the bullet distribution (e.g. in `HOOK_TOHIT` or `HOOK_AMMOCOST`)
|
||||||
- `centerDiv/targetDiv`: the minimum value of divisor is 1
|
- `centerDiv/targetDiv`: the minimum value of divisor is 1
|
||||||
- `centerMult/targetMult`: multiplier values are capped at divisor values
|
- `centerMult/targetMult`: multiplier values are capped at divisor values
|
||||||
- __NOTE:__ refer to the description of **ComputeSpray_\*** settings in ddraw.ini for details of the bullet distribution of burst attacks
|
- __NOTE:__ refer to the description of **ComputeSpray_\*** settings in ddraw.ini for details of the bullet distribution of burst attacks
|
||||||
|
|||||||
@@ -297,7 +297,7 @@
|
|||||||
doc: |
|
doc: |
|
||||||
Runs when calculating ammo cost for a weapon. Doesn't affect damage, only how much ammo is spent.<br>
|
Runs when calculating ammo cost for a weapon. Doesn't affect damage, only how much ammo is spent.<br>
|
||||||
By default, a weapon can perform an attack with at least one ammo, regardless of ammo cost calculation.<br>
|
By default, a weapon can perform an attack with at least one ammo, regardless of ammo cost calculation.<br>
|
||||||
To add proper check for ammo before attacking and proper calculation of the number of burst rounds (hook type 1 and 2 in `arg3`), set **CheckWeaponAmmoCost=1** in **Misc** section of ddraw.ini.
|
To add proper checks for ammo before attacking (hook type 1 `arg3`), set **CheckWeaponAmmoCost=1** in **Misc** section of ddraw.ini.
|
||||||
|
|
||||||
__NOTE:__ The return value must be greater than or equal to 0 to be valid.
|
__NOTE:__ The return value must be greater than or equal to 0 to be valid.
|
||||||
|
|
||||||
|
|||||||
@@ -395,7 +395,7 @@ int ret1 - The new maximum damage
|
|||||||
|
|
||||||
Runs when calculating ammo cost for a weapon. Doesn't affect damage, only how much ammo is spent.\
|
Runs when calculating ammo cost for a weapon. Doesn't affect damage, only how much ammo is spent.\
|
||||||
By default, a weapon can perform an attack with at least one ammo, regardless of ammo cost calculation.\
|
By default, a weapon can perform an attack with at least one ammo, regardless of ammo cost calculation.\
|
||||||
To add proper check for ammo before attacking and proper calculation of the number of burst rounds (hook type 1 and 2 in `arg3`), set **CheckWeaponAmmoCost=1** in **Misc** section of ddraw.ini.
|
To add proper checks for ammo before attacking (hook type 1 in `arg3`), set **CheckWeaponAmmoCost=1** in **Misc** section of ddraw.ini.
|
||||||
|
|
||||||
__NOTE:__ The return value must be greater than or equal to 0 to be valid.
|
__NOTE:__ The return value must be greater than or equal to 0 to be valid.
|
||||||
|
|
||||||
|
|||||||
@@ -1068,7 +1068,7 @@ sfall_funcX metarule functions
|
|||||||
`void sfall_func4("set_spray_settings", int centerMult, int centerDiv, int targetMult, int targetDiv)`
|
`void sfall_func4("set_spray_settings", int centerMult, int centerDiv, int targetMult, int targetDiv)`
|
||||||
|
|
||||||
- Allows to dynamically change the multipilers and divisors for the bullet distribution of burst attacks. All settings are automatically reset to default values (**ComputeSpray_\*** settings in ddraw.ini) after each attack action
|
- Allows to dynamically change the multipilers and divisors for the bullet distribution of burst attacks. All settings are automatically reset to default values (**ComputeSpray_\*** settings in ddraw.ini) after each attack action
|
||||||
- Should be called before the calculation of the bullet distribution (e.g. in `HOOK_TOHIT` or `HOOK_AMMOCOST` with **CheckWeaponAmmoCost=1** in ddraw.ini)
|
- Should be called before the calculation of the bullet distribution (e.g. in `HOOK_TOHIT` or `HOOK_AMMOCOST`)
|
||||||
- `centerDiv/targetDiv`: the minimum value of divisor is 1
|
- `centerDiv/targetDiv`: the minimum value of divisor is 1
|
||||||
- `centerMult/targetMult`: multiplier values are capped at divisor values
|
- `centerMult/targetMult`: multiplier values are capped at divisor values
|
||||||
- __NOTE:__ refer to the description of **ComputeSpray_\*** settings in ddraw.ini for details of the bullet distribution of burst attacks
|
- __NOTE:__ refer to the description of **ComputeSpray_\*** settings in ddraw.ini for details of the bullet distribution of burst attacks
|
||||||
|
|||||||
@@ -47,8 +47,8 @@ static long __fastcall ComputeSpray(DWORD* roundsLeftOut, DWORD* roundsRightOut,
|
|||||||
if (roundsCenter == 0) roundsCenter = 1;
|
if (roundsCenter == 0) roundsCenter = 1;
|
||||||
*roundsCenterOut = roundsCenter;
|
*roundsCenterOut = roundsCenter;
|
||||||
|
|
||||||
long roundsLeft = (totalRounds - roundsCenter) / 2;
|
long roundsLeft = (totalRounds - roundsCenter) / 2; // minimum possible value is 0
|
||||||
long roundsRight = totalRounds - roundsCenter - roundsLeft;
|
long roundsRight = totalRounds - roundsCenter - roundsLeft; // is either equal to or one more than roundsLeft
|
||||||
if (roundsLeft != roundsRight && fo::func::roll_random(0, 1)) { // randomize the distribution of one extra bullet
|
if (roundsLeft != roundsRight && fo::func::roll_random(0, 1)) { // randomize the distribution of one extra bullet
|
||||||
roundsLeft++;
|
roundsLeft++;
|
||||||
roundsRight--;
|
roundsRight--;
|
||||||
|
|||||||
@@ -87,12 +87,12 @@ static bool hookedAimedShot;
|
|||||||
static std::vector<DWORD> disabledAS;
|
static std::vector<DWORD> disabledAS;
|
||||||
static std::vector<DWORD> forcedAS;
|
static std::vector<DWORD> forcedAS;
|
||||||
|
|
||||||
static bool checkWeaponAmmoCost;
|
//static bool checkWeaponAmmoCost;
|
||||||
|
|
||||||
// Compares the cost (required count of rounds) for one shot with the current amount of ammo to make an attack or other checks
|
// Compares the cost (required count of rounds) for one shot with the current amount of ammo to make an attack or other checks
|
||||||
long __fastcall Combat::check_item_ammo_cost(fo::GameObject* weapon, fo::AttackType hitMode) {
|
static long __fastcall check_item_ammo_cost(fo::GameObject* weapon, fo::AttackType hitMode) {
|
||||||
long currAmmo = game::Items::item_w_curr_ammo(weapon);
|
long currAmmo = game::Items::item_w_curr_ammo(weapon);
|
||||||
if (!checkWeaponAmmoCost || currAmmo <= 0) return currAmmo;
|
if (currAmmo <= 0) return 0;
|
||||||
|
|
||||||
long rounds = 1; // default ammo for single shot
|
long rounds = 1; // default ammo for single shot
|
||||||
|
|
||||||
@@ -120,7 +120,7 @@ static void __declspec(naked) combat_check_bad_shot_hook() {
|
|||||||
push edx;
|
push edx;
|
||||||
push ecx; // weapon
|
push ecx; // weapon
|
||||||
mov edx, edi; // hitMode
|
mov edx, edi; // hitMode
|
||||||
call Combat::check_item_ammo_cost;
|
call check_item_ammo_cost;
|
||||||
pop ecx;
|
pop ecx;
|
||||||
pop edx;
|
pop edx;
|
||||||
retn;
|
retn;
|
||||||
@@ -134,7 +134,7 @@ static void __declspec(naked) ai_search_inven_weap_hook() {
|
|||||||
push ecx;
|
push ecx;
|
||||||
mov edx, ATKTYPE_RWEAPON_PRIMARY; // hitMode
|
mov edx, ATKTYPE_RWEAPON_PRIMARY; // hitMode
|
||||||
mov ecx, eax; // weapon
|
mov ecx, eax; // weapon
|
||||||
call Combat::check_item_ammo_cost; // enough ammo?
|
call check_item_ammo_cost; // enough ammo?
|
||||||
pop ecx;
|
pop ecx;
|
||||||
retn;
|
retn;
|
||||||
}
|
}
|
||||||
@@ -176,7 +176,7 @@ static long __fastcall divide_burst_rounds_by_ammo_cost(long currAmmo, fo::GameO
|
|||||||
long cost = burstRounds * roundsCost; // amount of ammo required for this burst (multiplied by 1 or by the value returned from HOOK_AMMOCOST)
|
long cost = burstRounds * roundsCost; // amount of ammo required for this burst (multiplied by 1 or by the value returned from HOOK_AMMOCOST)
|
||||||
if (cost > currAmmo) cost = currAmmo; // if cost ammo more than current ammo, set it to current
|
if (cost > currAmmo) cost = currAmmo; // if cost ammo more than current ammo, set it to current
|
||||||
|
|
||||||
return (cost / roundsCost); // divide back to get proper number of rounds for damage calculations
|
return max(1, (cost / roundsCost)); // divide back to get proper number of rounds for damage calculations (minimum is 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void __declspec(naked) compute_spray_hack() {
|
static void __declspec(naked) compute_spray_hack() {
|
||||||
@@ -572,9 +572,8 @@ void Combat::init() {
|
|||||||
// Disables secondary burst attacks for the critter
|
// Disables secondary burst attacks for the critter
|
||||||
MakeCall(0x429E44, ai_pick_hit_mode_hack_noBurst, 1);
|
MakeCall(0x429E44, ai_pick_hit_mode_hack_noBurst, 1);
|
||||||
|
|
||||||
checkWeaponAmmoCost = (IniReader::GetConfigInt("Misc", "CheckWeaponAmmoCost", 0) != 0);
|
MakeCall(0x4234B3, compute_spray_hack, 1); // proper calculation of the number of burst rounds
|
||||||
if (checkWeaponAmmoCost) {
|
if (IniReader::GetConfigInt("Misc", "CheckWeaponAmmoCost", 1)) {
|
||||||
MakeCall(0x4234B3, compute_spray_hack, 1);
|
|
||||||
HookCall(0x4266E9, combat_check_bad_shot_hook);
|
HookCall(0x4266E9, combat_check_bad_shot_hook);
|
||||||
HookCall(0x429A37, ai_search_inven_weap_hook); // check if there is enough ammo to shoot
|
HookCall(0x429A37, ai_search_inven_weap_hook); // check if there is enough ammo to shoot
|
||||||
HookCall(0x42A95D, ai_try_attack_hook); // jz func
|
HookCall(0x42A95D, ai_try_attack_hook); // jz func
|
||||||
|
|||||||
@@ -49,8 +49,6 @@ public:
|
|||||||
|
|
||||||
static long determineHitChance;
|
static long determineHitChance;
|
||||||
|
|
||||||
static long __fastcall check_item_ammo_cost(fo::GameObject* weapon, fo::AttackType hitMode);
|
|
||||||
|
|
||||||
static bool IsBurstDisabled(fo::GameObject* critter);
|
static bool IsBurstDisabled(fo::GameObject* critter);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -28,7 +28,7 @@
|
|||||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||||
<CharacterSet>NotSet</CharacterSet>
|
<CharacterSet>NotSet</CharacterSet>
|
||||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
<PlatformToolset>v141</PlatformToolset>
|
<PlatformToolset>v140</PlatformToolset>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseXP|Win32'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseXP|Win32'" Label="Configuration">
|
||||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||||
|
|||||||
+3
-3
@@ -24,7 +24,7 @@
|
|||||||
|
|
||||||
#define VERSION_MAJOR 4
|
#define VERSION_MAJOR 4
|
||||||
#define VERSION_MINOR 3
|
#define VERSION_MINOR 3
|
||||||
#define VERSION_BUILD 8
|
#define VERSION_BUILD 9
|
||||||
#define VERSION_REV 1
|
#define VERSION_REV 0
|
||||||
|
|
||||||
#define VERSION_STRING "4.3.8.1"
|
#define VERSION_STRING "4.3.9"
|
||||||
|
|||||||
Reference in New Issue
Block a user