forked from awgil/ffxiv_bossmod
-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #120 from FFXIV-CombatReborn/mergeWIP2
Sync with vbm 0.0.0.158
- Loading branch information
Showing
18 changed files
with
861 additions
and
257 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
namespace BossMod; | ||
|
||
// Framerate-dependent cooldown reduction. | ||
// Imagine game is running at exactly 100fps (10ms frame time), and action is queued when remaining cooldown is 5ms. | ||
// On next frame (+10ms), cooldown will be reduced and clamped to 0, action will be executed and it's cooldown set to X ms - so next time it can be pressed at X+10 ms. | ||
// If we were running with infinite fps, cooldown would be reduced to 0 and action would be executed slightly (5ms) earlier. | ||
// We can't fix that easily, but at least we can fix the cooldown after action execution - so that next time it can be pressed at X+5ms. | ||
// We do that by reducing actual cooldown by difference between previously-remaining cooldown and frame delta, if action is executed at first opportunity. | ||
public sealed class CooldownDelayTweak | ||
{ | ||
private readonly ActionManagerConfig _config = Service.Config.Get<ActionManagerConfig>(); | ||
|
||
public float Adjustment { get; private set; } // if >0 while using an action, cooldown/anim lock will be reduced by this amount as if action was used a bit in the past | ||
|
||
public void StartAdjustment(float prevAnimLock, float prevRemainingCooldown, float dt) => Adjustment = CalculateAdjustment(prevAnimLock, prevRemainingCooldown, dt); | ||
public void StopAdjustment() => Adjustment = 0; | ||
|
||
private float CalculateAdjustment(float prevAnimLock, float prevRemainingCooldown, float dt) | ||
{ | ||
if (!_config.RemoveCooldownDelay) | ||
return 0; // tweak is disabled, so no adjustment | ||
|
||
var maxDelay = Math.Max(prevAnimLock, prevRemainingCooldown); | ||
if (maxDelay <= 0) | ||
return 0; // nothing prevented us from executing the action on previous frame, so no adjustment | ||
|
||
var overflow = dt - maxDelay; // both cooldown and animation lock should expire this much before current frame start | ||
return Math.Clamp(overflow, 0, 0.1f); // use upper limit for time adjustment (if you have dogshit fps, adjusting too much could be suspicious) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
namespace BossMod; | ||
|
||
// Preserving character facing direction tweak. | ||
// When any action is executed, character is automatically rotated to face the target (this can be disabled in-game, but it would simply block an action if not facing target instead). | ||
// This makes maintaining uptime during gaze mechanics unnecessarily complicated (requiring either moving or rotating mouse back-and-forth in non-legacy camera mode). | ||
// This feature remembers original rotation before executing an action and then attempts to restore it. | ||
// Just like any 'manual' way, it is not 100% reliable: | ||
// * client rate-limits rotation updates, so even for instant casts there is a short window of time (~0.1s) following action execution when character faces a target on server | ||
// * for movement-affecting abilities (jumps, charges, etc) rotation can't be restored until animation ends | ||
// * for casted abilities, rotation isn't restored until slidecast window starts, as otherwise cast is interrupted | ||
public sealed class RestoreRotationTweak | ||
{ | ||
private readonly ActionManagerConfig _config = Service.Config.Get<ActionManagerConfig>(); | ||
private Angle _modified; // rotation immediately after action execution; as long as it's not unchanged, we'll try restoring (otherwise we assume player changed facing manually and abort) | ||
private Angle _original; // rotation immediately before action execution; this is what we're trying to restore | ||
private int _numRetries; // for some reason, sometimes after successfully restoring rotation it is snapped back on next frame; in this case we retry again - TODO investigate why this happens | ||
private bool _pending; | ||
|
||
public void Preserve(Angle original, Angle modified) | ||
{ | ||
if (_config.RestoreRotation && original != modified) | ||
{ | ||
_modified = modified; | ||
_original = original; | ||
_numRetries = 2; | ||
_pending = true; | ||
//Service.Log($"[RRT] Restore start: {modified.Rad} -> {original.Rad}"); | ||
} | ||
} | ||
|
||
public bool TryRestore(Angle current, out Angle updated) | ||
{ | ||
//Service.Log($"[RRT] Restore rotation: {current.Rad}: {_modified.Rad}->{_original.Rad}"); | ||
updated = _original; | ||
if (!_pending) | ||
return false; // we don't have any pending rotation to restore | ||
|
||
if (_modified.AlmostEqual(current, 0.01f)) | ||
return true; // we still have the 'post' rotation, try restoring | ||
|
||
if (--_numRetries == 0) | ||
_pending = false; // we have unexpected rotation and we're out of retries, stop trying | ||
return false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.