Randomized one extra bullet for side groups in burst attacks

* idea from phobos2077.

Added minimum value check to multipliers.
This commit is contained in:
NovaRain
2023-05-19 09:45:15 +08:00
parent 000816acb5
commit c73f311b22
2 changed files with 19 additions and 5 deletions
+13 -3
View File
@@ -17,6 +17,7 @@
*/ */
#include "..\main.h" #include "..\main.h"
#include "..\FalloutEngine\Fallout2.h"
#include "BurstMods.h" #include "BurstMods.h"
#include "MainLoopHook.h" #include "MainLoopHook.h"
@@ -47,8 +48,13 @@ static long __fastcall ComputeSpray(DWORD* roundsLeftOut, DWORD* roundsRightOut,
*roundsCenterOut = roundsCenter; *roundsCenterOut = roundsCenter;
long roundsLeft = (totalRounds - roundsCenter) / 2; long roundsLeft = (totalRounds - roundsCenter) / 2;
long roundsRight = totalRounds - roundsCenter - roundsLeft;
if (roundsLeft != roundsRight && fo::func::roll_random(0, 1)) { // randomize the distribution of one extra bullet
roundsLeft++;
roundsRight--;
}
*roundsLeftOut = roundsLeft; *roundsLeftOut = roundsLeft;
*roundsRightOut = totalRounds - roundsCenter - roundsLeft; *roundsRightOut = roundsRight;
// roundsMainTarget = roundsCenter * mult / div // roundsMainTarget = roundsCenter * mult / div
result = roundsCenter * compute_spray_target_mult; result = roundsCenter * compute_spray_target_mult;
@@ -99,7 +105,9 @@ void BurstMods::init() {
if (compute_spray_center_div < 1) { if (compute_spray_center_div < 1) {
compute_spray_center_div = 1; compute_spray_center_div = 1;
} }
if (compute_spray_center_mult > compute_spray_center_div) { if (compute_spray_center_mult < 1) {
compute_spray_center_mult = 1;
} else if (compute_spray_center_mult > compute_spray_center_div) {
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_mult_def = compute_spray_center_mult;
@@ -110,7 +118,9 @@ void BurstMods::init() {
if (compute_spray_target_div < 1) { if (compute_spray_target_div < 1) {
compute_spray_target_div = 1; compute_spray_target_div = 1;
} }
if (compute_spray_target_mult > compute_spray_target_div) { if (compute_spray_target_mult < 1) {
compute_spray_target_mult = 1;
} else if (compute_spray_target_mult > compute_spray_target_div) {
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_mult_def = compute_spray_target_mult;
+6 -2
View File
@@ -249,12 +249,16 @@ void mf_set_spray_settings(OpcodeContext& ctx) {
targetDiv = ctx.arg(3).rawValue(); targetDiv = ctx.arg(3).rawValue();
if (centerDiv < 1) centerDiv = 1; if (centerDiv < 1) centerDiv = 1;
if (centerMult > centerDiv) { if (centerMult < 1) {
centerMult = 1;
} else if (centerMult > centerDiv) {
centerMult = centerDiv; centerMult = centerDiv;
ctx.printOpcodeError("%s() - Warning: centerMult value is capped at centerDiv.", ctx.getMetaruleName()); ctx.printOpcodeError("%s() - Warning: centerMult value is capped at centerDiv.", ctx.getMetaruleName());
} }
if (targetDiv < 1) targetDiv = 1; if (targetDiv < 1) targetDiv = 1;
if (targetMult > targetDiv) { if (targetMult < 1) {
targetMult = 1;
} else if (targetMult > targetDiv) {
targetMult = targetDiv; targetMult = targetDiv;
ctx.printOpcodeError("%s() - Warning: targetMult value is capped at targetDiv.", ctx.getMetaruleName()); ctx.printOpcodeError("%s() - Warning: targetMult value is capped at targetDiv.", ctx.getMetaruleName());
} }