Added "set_spray_settings" function for scriptable burst

Added documentation for set_spray_settings.
Remove postbuild.cmd from git.
This commit is contained in:
NovaRain
2023-05-19 09:51:58 +08:00
parent 637de0e07d
commit ddf2854938
9 changed files with 75 additions and 24 deletions
+1
View File
@@ -362,6 +362,7 @@
#define set_rest_heal_time(time) sfall_func1("set_rest_heal_time", time)
#define set_rest_mode(mode) sfall_func1("set_rest_mode", mode)
#define set_scr_name(name) sfall_func1("set_scr_name", name)
#define set_spray_settings(ctrMult, ctrDiv, tgtMult, tgtDiv) sfall_func4("set_spray_settings", ctrMult, ctrDiv, tgtMult, tgtDiv)
#define set_terrain_name(x, y, name) sfall_func3("set_terrain_name", x, y, name)
#define set_town_title(areaID, title) sfall_func2("set_town_title", areaID, title)
#define set_unique_id(obj) sfall_func1("set_unique_id", obj)
+11 -1
View File
@@ -261,7 +261,7 @@ FUNCTION REFERENCE
-----
##### `int/array metarule2_explosions(int arg1, int arg2, int arg3)`
- Was made as a dirty easy hack to allow dynamically change some explosion parameters (ranged attack). All changed parameters are reset to vanilla state automatically after each attack action. Following macros are available in **sfall.h**:
- Was made as a dirty easy hack to allow to dynamically change some explosion parameters (ranged attack). All changed parameters are automatically reset to vanilla state after each attack action. Following macros are available in **sfall.h**:
-----
##### `void set_attack_explosion_pattern(x, y)`
@@ -1034,6 +1034,16 @@ sfall_funcX metarule functions
`bool sfall_func1("obj_is_openable", object obj)`
- Returns True if the object is openable (i.e. has an opening/closing animation), False otherwise
----
##### set_spray_settings
`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
- Should be called before the calculation of the bullet distribution (e.g. in `HOOK_TOHIT` or `HOOK_AMMOCOST` with **CheckWeaponAmmoCost=1** in ddraw.ini)
- `centerDiv/targetDiv`: the minimum value of divisor is 1
- `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
****
_See other documentation files (arrays.md, hookscripts.md) for related functions reference._
+33 -1
View File
@@ -17,6 +17,7 @@
*/
#include "..\main.h"
#include "..\FalloutEngine\Fallout2.h"
#include "BurstMods.h"
@@ -28,6 +29,14 @@ static long compute_spray_center_div;
static long compute_spray_target_mult;
static long compute_spray_target_div;
// default values
static long compute_spray_center_mult_def;
static long compute_spray_center_div_def;
static long compute_spray_target_mult_def;
static long compute_spray_target_div_def;
static bool computeSpraySettingsReset = false;
static long __fastcall ComputeSpray(DWORD* roundsLeftOut, DWORD* roundsRightOut, DWORD totalRounds, DWORD* roundsCenterOut) {
// roundsCenter = totalRounds * mult / div
long result = totalRounds * compute_spray_center_mult;
@@ -65,8 +74,25 @@ static void __declspec(naked) compute_spray_rounds_distribution() {
}
}
void BurstMods::SetComputeSpraySettings(long centerMult, long centerDiv, long targetMult, long targetDiv) {
compute_spray_center_mult = centerMult;
compute_spray_center_div = centerDiv;
compute_spray_target_mult = targetMult;
compute_spray_target_div = targetDiv;
computeSpraySettingsReset = true;
}
void ResetComputeSpraySettings() {
if (!computeSpraySettingsReset) return;
compute_spray_center_mult = compute_spray_center_mult_def;
compute_spray_center_div = compute_spray_center_div_def;
compute_spray_target_mult = compute_spray_target_mult_def;
compute_spray_target_div = compute_spray_target_div_def;
computeSpraySettingsReset = false;
}
void BurstMods::init() {
//if (IniReader::GetConfigInt("Misc", "ComputeSprayMod", 0)) {
//if (IniReader::GetConfigInt("Misc", "ComputeSprayMod", 1)) {
dlogr("Applying ComputeSpray settings to burst attacks.", DL_INIT);
compute_spray_center_mult = IniReader::GetConfigInt("Misc", "ComputeSpray_CenterMult", 1);
compute_spray_center_div = IniReader::GetConfigInt("Misc", "ComputeSpray_CenterDiv", 3);
@@ -76,6 +102,9 @@ void BurstMods::init() {
if (compute_spray_center_mult > compute_spray_center_div) {
compute_spray_center_mult = compute_spray_center_div;
}
compute_spray_center_mult_def = compute_spray_center_mult;
compute_spray_center_div_def = compute_spray_center_div;
compute_spray_target_mult = IniReader::GetConfigInt("Misc", "ComputeSpray_TargetMult", 1);
compute_spray_target_div = IniReader::GetConfigInt("Misc", "ComputeSpray_TargetDiv", 2);
if (compute_spray_target_div < 1) {
@@ -84,6 +113,9 @@ void BurstMods::init() {
if (compute_spray_target_mult > compute_spray_target_div) {
compute_spray_target_mult = compute_spray_target_div;
}
compute_spray_target_mult_def = compute_spray_target_mult;
compute_spray_target_div_def = compute_spray_target_div;
MakeJump(0x4234F1, compute_spray_rounds_distribution);
//}
}
+4
View File
@@ -25,6 +25,10 @@ class BurstMods {
public:
static const char* name() { return "BurstMods"; }
static void init();
static void SetComputeSpraySettings(long centerMult, long centerDiv, long targetMult, long targetDiv);
};
void ResetComputeSpraySettings();
}
+3 -1
View File
@@ -18,6 +18,7 @@
#include "..\FalloutEngine\Fallout2.h"
#include "..\SafeWrite.h"
#include "BurstMods.h"
#include "Explosions.h"
#include "ScriptExtender.h"
@@ -42,7 +43,8 @@ static void __stdcall CombatLoop() { // OnCombatLoop
}
static void __stdcall AfterCombatAttack() { // OnAfterCombatAttack
ResetExplosionSettings(); // after each combat attack, reset metarule_explosions settings
ResetExplosionSettings(); // after each combat attack, reset metarule_explosions settings
ResetComputeSpraySettings(); // after each combat attack, reset ComputeSpray settings
}
static void __declspec(naked) MainGameLoopHook() {
@@ -19,6 +19,7 @@
#include "..\..\..\FalloutEngine\AsmMacros.h"
#include "..\..\..\FalloutEngine\Fallout2.h"
#include "..\..\AI.h"
#include "..\..\BurstMods.h"
#include "..\..\Combat.h"
#include "..\..\KillCounter.h"
@@ -241,5 +242,24 @@ void mf_combat_data(OpcodeContext& ctx) {
ctx.setReturn((DWORD)ctd, DATATYPE_INT);
}
void mf_set_spray_settings(OpcodeContext& ctx) {
long centerMult = ctx.arg(0).rawValue(),
centerDiv = ctx.arg(1).rawValue(),
targetMult = ctx.arg(2).rawValue(),
targetDiv = ctx.arg(3).rawValue();
if (centerDiv < 1) centerDiv = 1;
if (centerMult > centerDiv) {
centerMult = centerDiv;
ctx.printOpcodeError("%s() - Warning: centerMult value is capped at centerDiv.", ctx.getMetaruleName());
}
if (targetDiv < 1) targetDiv = 1;
if (targetMult > targetDiv) {
targetMult = targetDiv;
ctx.printOpcodeError("%s() - Warning: targetMult value is capped at targetDiv.", ctx.getMetaruleName());
}
BurstMods::SetComputeSpraySettings(centerMult, centerDiv, targetMult, targetDiv);
}
}
}
@@ -56,5 +56,7 @@ void mf_attack_is_aimed(OpcodeContext&);
void mf_combat_data(OpcodeContext&);
void mf_set_spray_settings(OpcodeContext&);
}
}
@@ -122,6 +122,7 @@ static const SfallMetarule metarules[] = {
{"outlined_object", mf_outlined_object, 0, 0},
{"real_dude_obj", mf_real_dude_obj, 0, 0},
{"remove_timer_event", mf_remove_timer_event, 0, 1, -1, {ARG_INT}},
{"set_spray_settings", mf_set_spray_settings, 4, 4, -1, {ARG_INT, ARG_INT, ARG_INT, ARG_INT}},
{"set_can_rest_on_map", mf_set_rest_on_map, 3, 3, -1, {ARG_INT, ARG_INT, ARG_INT}},
{"set_car_intface_art", mf_set_car_intface_art, 1, 1, -1, {ARG_INT}},
{"set_cursor_mode", mf_set_cursor_mode, 1, 1, -1, {ARG_INT}},
-21
View File
@@ -1,21 +0,0 @@
@ECHO OFF
rem debug, release, etc.
SET type=%1
rem full path to the compiled DLL
SET target=%2
SET destination=C:\Games\Fallout2\ddraw.dll
SET pdb="%~dpn2.pdb"
IF EXIST ducible.exe (
IF EXIST %pdb% (
ducible %target% %pdb%
) ELSE (
ducible %target%
)
)
rem echo Copying %target% to %destination% ...
rem copy %target% %destination%