Skip to content

Commit 3ccb087

Browse files
committed
Add burst mod (#29)
1 parent 3f9145b commit 3ccb087

File tree

3 files changed

+109
-34
lines changed

3 files changed

+109
-34
lines changed

src/combat.cc

Lines changed: 94 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@ static int calledShotSelectHitLocation(Object* critter, int* hitLocation, int hi
9494
static void criticalsInit();
9595
static void criticalsReset();
9696
static void criticalsExit();
97+
static void burstModInit();
98+
static int burstModComputeRounds(int totalRounds, int* centerRoundsPtr, int* leftRoundsPtr, int* rightRoundsPtr);
9799

98100
// 0x500B50
99101
static char _a_1[] = ".";
@@ -1925,6 +1927,12 @@ static const char* gCritDataMemberKeys[CRIT_DATA_MEMBER_COUNT] = {
19251927
"FailMessage",
19261928
};
19271929

1930+
static bool gBurstModEnabled = false;
1931+
static int gBurstModCenterMultiplier = SFALL_CONFIG_BURST_MOD_DEFAULT_CENTER_MULTIPLIER;
1932+
static int gBurstModCenterDivisor = SFALL_CONFIG_BURST_MOD_DEFAULT_CENTER_DIVISOR;
1933+
static int gBurstModTargetMultiplier = SFALL_CONFIG_BURST_MOD_DEFAULT_TARGET_MULTIPLIER;
1934+
static int gBurstModTargetDivisor = SFALL_CONFIG_BURST_MOD_DEFAULT_TARGET_DIVISOR;
1935+
19281936
// combat_init
19291937
// 0x420CC0
19301938
int combatInit()
@@ -1965,6 +1973,7 @@ int combatInit()
19651973

19661974
// SFALL
19671975
criticalsInit();
1976+
burstModInit();
19681977

19691978
return 0;
19701979
}
@@ -3591,31 +3600,36 @@ static int _compute_spray(Attack* attack, int accuracy, int* a3, int* a4, int an
35913600
accuracy += 20;
35923601
}
35933602

3594-
int v31;
3595-
int v14;
3596-
int v33;
3597-
int v30;
3603+
int leftRounds;
3604+
int mainTargetRounds;
3605+
int centerRounds;
3606+
int rightRounds;
35983607
if (anim == ANIM_FIRE_BURST) {
3599-
v33 = ammoQuantity / 3;
3600-
if (v33 == 0) {
3601-
v33 = 1;
3602-
}
3608+
// SFALL: Burst mod.
3609+
if (gBurstModEnabled) {
3610+
mainTargetRounds = burstModComputeRounds(ammoQuantity, &centerRounds, &leftRounds, &rightRounds);
3611+
} else {
3612+
centerRounds = ammoQuantity / 3;
3613+
if (centerRounds == 0) {
3614+
centerRounds = 1;
3615+
}
36033616

3604-
v31 = ammoQuantity / 3;
3605-
v30 = ammoQuantity - v33 - v31;
3606-
v14 = v33 / 2;
3607-
if (v14 == 0) {
3608-
v14 = 1;
3609-
v33 -= 1;
3617+
leftRounds = ammoQuantity / 3;
3618+
rightRounds = ammoQuantity - centerRounds - leftRounds;
3619+
mainTargetRounds = centerRounds / 2;
3620+
if (mainTargetRounds == 0) {
3621+
mainTargetRounds = 1;
3622+
centerRounds -= 1;
3623+
}
36103624
}
36113625
} else {
3612-
v31 = 1;
3613-
v14 = 1;
3614-
v33 = 1;
3615-
v30 = 1;
3626+
leftRounds = 1;
3627+
mainTargetRounds = 1;
3628+
centerRounds = 1;
3629+
rightRounds = 1;
36163630
}
36173631

3618-
for (int index = 0; index < v14; index += 1) {
3632+
for (int index = 0; index < mainTargetRounds; index += 1) {
36193633
if (randomRoll(accuracy, 0, NULL) >= ROLL_SUCCESS) {
36203634
*a3 += 1;
36213635
}
@@ -3626,28 +3640,25 @@ static int _compute_spray(Attack* attack, int accuracy, int* a3, int* a4, int an
36263640
}
36273641

36283642
int range = _item_w_range(attack->attacker, attack->hitMode);
3629-
int v19 = _tile_num_beyond(attack->attacker->tile, attack->defender->tile, range);
3630-
3631-
*a3 += _shoot_along_path(attack, v19, v33 - *a3, anim);
3643+
int mainTargetEndTile = _tile_num_beyond(attack->attacker->tile, attack->defender->tile, range);
3644+
*a3 += _shoot_along_path(attack, mainTargetEndTile, centerRounds - *a3, anim);
36323645

3633-
int v20;
3646+
int centerTile;
36343647
if (objectGetDistanceBetween(attack->attacker, attack->defender) <= 3) {
3635-
v20 = _tile_num_beyond(attack->attacker->tile, attack->defender->tile, 3);
3648+
centerTile = _tile_num_beyond(attack->attacker->tile, attack->defender->tile, 3);
36363649
} else {
3637-
v20 = attack->defender->tile;
3650+
centerTile = attack->defender->tile;
36383651
}
36393652

3640-
int rotation = tileGetRotationTo(v20, attack->attacker->tile);
3641-
int v23 = tileGetTileInDirection(v20, (rotation + 1) % ROTATION_COUNT, 1);
3642-
3643-
int v25 = _tile_num_beyond(attack->attacker->tile, v23, range);
3653+
int rotation = tileGetRotationTo(centerTile, attack->attacker->tile);
36443654

3645-
*a3 += _shoot_along_path(attack, v25, v31, anim);
3655+
int leftTile = tileGetTileInDirection(centerTile, (rotation + 1) % ROTATION_COUNT, 1);
3656+
int leftEndTile = _tile_num_beyond(attack->attacker->tile, leftTile, range);
3657+
*a3 += _shoot_along_path(attack, leftEndTile, leftRounds, anim);
36463658

3647-
int v26 = tileGetTileInDirection(v20, (rotation + 5) % ROTATION_COUNT, 1);
3648-
3649-
int v28 = _tile_num_beyond(attack->attacker->tile, v26, range);
3650-
*a3 += _shoot_along_path(attack, v28, v30, anim);
3659+
int rightTile = tileGetTileInDirection(centerTile, (rotation + 5) % ROTATION_COUNT, 1);
3660+
int rightEndTile = _tile_num_beyond(attack->attacker->tile, rightTile, range);
3661+
*a3 += _shoot_along_path(attack, rightEndTile, rightRounds, anim);
36513662

36523663
if (roll != ROLL_FAILURE || (*a3 <= 0 && attack->extrasLength <= 0)) {
36533664
if (roll >= ROLL_SUCCESS && *a3 == 0 && attack->extrasLength == 0) {
@@ -6117,3 +6128,52 @@ void criticalsResetValue(int killType, int hitLocation, int effect, int dataMemb
61176128
gCriticalHitTables[killType][hitLocation][effect].values[dataMember] = gBaseCriticalHitTables[killType][hitLocation][effect].values[dataMember];
61186129
}
61196130
}
6131+
6132+
static void burstModInit()
6133+
{
6134+
configGetBool(&gSfallConfig, SFALL_CONFIG_MISC_KEY, SFALL_CONFIG_BURST_MOD_ENABLED_KEY, &gBurstModEnabled);
6135+
6136+
configGetInt(&gSfallConfig, SFALL_CONFIG_MISC_KEY, SFALL_CONFIG_BURST_MOD_CENTER_MULTIPLIER_KEY, &gBurstModCenterMultiplier);
6137+
configGetInt(&gSfallConfig, SFALL_CONFIG_MISC_KEY, SFALL_CONFIG_BURST_MOD_CENTER_DIVISOR_KEY, &gBurstModCenterDivisor);
6138+
if (gBurstModCenterDivisor < 1) {
6139+
gBurstModCenterDivisor = 1;
6140+
}
6141+
if (gBurstModCenterMultiplier > gBurstModCenterDivisor) {
6142+
gBurstModCenterMultiplier = gBurstModCenterDivisor;
6143+
}
6144+
6145+
configGetInt(&gSfallConfig, SFALL_CONFIG_MISC_KEY, SFALL_CONFIG_BURST_MOD_TARGET_MULTIPLIER_KEY, &gBurstModTargetMultiplier);
6146+
configGetInt(&gSfallConfig, SFALL_CONFIG_MISC_KEY, SFALL_CONFIG_BURST_MOD_TARGET_DIVISOR_KEY, &gBurstModTargetDivisor);
6147+
if (gBurstModTargetDivisor < 1) {
6148+
gBurstModTargetDivisor = 1;
6149+
}
6150+
if (gBurstModTargetMultiplier > gBurstModTargetDivisor) {
6151+
gBurstModTargetMultiplier = gBurstModTargetDivisor;
6152+
}
6153+
}
6154+
6155+
static int burstModComputeRounds(int totalRounds, int* centerRoundsPtr, int* leftRoundsPtr, int* rightRoundsPtr)
6156+
{
6157+
int totalRoundsMultiplied = totalRounds * gBurstModCenterMultiplier;
6158+
int centerRounds = totalRoundsMultiplied / gBurstModCenterDivisor;
6159+
if ((totalRoundsMultiplied % gBurstModCenterDivisor) != 0) {
6160+
centerRounds++;
6161+
}
6162+
6163+
if (centerRounds == 0) {
6164+
centerRounds++;
6165+
}
6166+
*centerRoundsPtr = centerRounds;
6167+
6168+
int leftRounds = (totalRounds - centerRounds) / 2;
6169+
*leftRoundsPtr = leftRounds;
6170+
*rightRoundsPtr = totalRounds - centerRounds - leftRounds;
6171+
6172+
int centerRoundsMultiplied = centerRounds * gBurstModTargetMultiplier;
6173+
int mainTargetRounds = centerRoundsMultiplied / gBurstModTargetDivisor;
6174+
if ((centerRoundsMultiplied % gBurstModTargetDivisor) != 0) {
6175+
mainTargetRounds++;
6176+
}
6177+
6178+
return mainTargetRounds;
6179+
}

src/sfall_config.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ bool sfallConfigInit(int argc, char** argv)
4242
configSetString(&gSfallConfig, SFALL_CONFIG_MISC_KEY, SFALL_CONFIG_CONSOLE_OUTPUT_FILE_KEY, "");
4343
configSetString(&gSfallConfig, SFALL_CONFIG_MISC_KEY, SFALL_CONFIG_PREMADE_CHARACTERS_FILE_NAMES_KEY, "");
4444
configSetString(&gSfallConfig, SFALL_CONFIG_MISC_KEY, SFALL_CONFIG_PREMADE_CHARACTERS_FACE_FIDS_KEY, "");
45+
configSetBool(&gSfallConfig, SFALL_CONFIG_MISC_KEY, SFALL_CONFIG_BURST_MOD_ENABLED_KEY, false);
46+
configSetInt(&gSfallConfig, SFALL_CONFIG_MISC_KEY, SFALL_CONFIG_BURST_MOD_CENTER_MULTIPLIER_KEY, SFALL_CONFIG_BURST_MOD_DEFAULT_CENTER_MULTIPLIER);
47+
configSetInt(&gSfallConfig, SFALL_CONFIG_MISC_KEY, SFALL_CONFIG_BURST_MOD_CENTER_DIVISOR_KEY, SFALL_CONFIG_BURST_MOD_DEFAULT_CENTER_DIVISOR);
48+
configSetInt(&gSfallConfig, SFALL_CONFIG_MISC_KEY, SFALL_CONFIG_BURST_MOD_TARGET_MULTIPLIER_KEY, SFALL_CONFIG_BURST_MOD_DEFAULT_TARGET_MULTIPLIER);
49+
configSetInt(&gSfallConfig, SFALL_CONFIG_MISC_KEY, SFALL_CONFIG_BURST_MOD_TARGET_DIVISOR_KEY, SFALL_CONFIG_BURST_MOD_DEFAULT_TARGET_DIVISOR);
4550

4651
char path[COMPAT_MAX_PATH];
4752
char* executable = argv[0];

src/sfall_config.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,16 @@
3030
#define SFALL_CONFIG_CONSOLE_OUTPUT_FILE_KEY "ConsoleOutputPath"
3131
#define SFALL_CONFIG_PREMADE_CHARACTERS_FILE_NAMES_KEY "PremadePaths"
3232
#define SFALL_CONFIG_PREMADE_CHARACTERS_FACE_FIDS_KEY "PremadeFIDs"
33+
#define SFALL_CONFIG_BURST_MOD_ENABLED_KEY "ComputeSprayMod"
34+
#define SFALL_CONFIG_BURST_MOD_CENTER_MULTIPLIER_KEY "ComputeSpray_CenterMult"
35+
#define SFALL_CONFIG_BURST_MOD_CENTER_DIVISOR_KEY "ComputeSpray_CenterDiv"
36+
#define SFALL_CONFIG_BURST_MOD_TARGET_MULTIPLIER_KEY "ComputeSpray_TargetMult"
37+
#define SFALL_CONFIG_BURST_MOD_TARGET_DIVISOR_KEY "ComputeSpray_TargetDiv"
38+
39+
#define SFALL_CONFIG_BURST_MOD_DEFAULT_CENTER_MULTIPLIER 1
40+
#define SFALL_CONFIG_BURST_MOD_DEFAULT_CENTER_DIVISOR 3
41+
#define SFALL_CONFIG_BURST_MOD_DEFAULT_TARGET_MULTIPLIER 1
42+
#define SFALL_CONFIG_BURST_MOD_DEFAULT_TARGET_DIVISOR 2
3343

3444
extern bool gSfallConfigInitialized;
3545
extern Config gSfallConfig;

0 commit comments

Comments
 (0)