Skip to content

Commit

Permalink
Merge pull request #4155 from SolastaMods/dev
Browse files Browse the repository at this point in the history
1.5.94.30
  • Loading branch information
ThyWoof authored Oct 22, 2023
2 parents b509b3c + 446c836 commit 44e992c
Show file tree
Hide file tree
Showing 76 changed files with 238 additions and 187 deletions.
9 changes: 8 additions & 1 deletion SolastaUnfinishedBusiness/ChangelogHistory.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
1.5.94.29:
1.5.94.30:

- new content development is halted until December [only fix releases if any are planned in between]
- fixed Devastating Strike incorrectly doubling the bonus damage on hit
- fixed IsMelee issuing false negatives under some scenarios with Power Attacks, Smites, Wildshape, etc.
- fixed Sorcerous Psion not adding CHA modifier to damage when all original damage forms were Psychic

1.5.94.29:

- added additional sample portraits under Portraits [Artyoan]
- fixed gamepad support on extended load and save menus
Expand Down
16 changes: 4 additions & 12 deletions SolastaUnfinishedBusiness/CustomBehaviors/_Global.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Collections.Generic;
using JetBrains.Annotations;
using JetBrains.Annotations;

namespace SolastaUnfinishedBusiness.CustomBehaviors;

Expand All @@ -10,6 +9,7 @@ internal static class Global
IsSettingUpMultiplayer
|| ServiceRepository.GetService<INetworkingService>().IsMultiplayerGame;

// true if on multiplayer setup screen
internal static bool IsSettingUpMultiplayer { get; set; }

//PATCH: Keeps last level up hero selected
Expand All @@ -23,6 +23,7 @@ internal static class Global
// inspected hero on both location and pool
[CanBeNull] internal static RulesetCharacterHero InspectedHero { get; set; }

[CanBeNull]
private static GameLocationCharacter SelectedLocationCharacter
{
get
Expand All @@ -43,21 +44,12 @@ private static GameLocationCharacter SelectedLocationCharacter
}

//PATCH: used in UI references
[CanBeNull]
internal static RulesetCharacter CurrentCharacter =>
InspectedHero
?? LevelUpHero
?? SelectedLocationCharacter?.RulesetCharacter;

//BUGFIX: saving throw not passing correct saving delta on attack actions
internal static CharacterAction CurrentAttackAction { get; set; }

// special case for our powers that add a turn off stop provider
internal static HashSet<FeatureDefinitionPower> PowersThatIgnoreInterruptions { get; } = new();

// keep a tab on last rolled dices [Devastating Strike, Fell Handed]
internal static int LowestAttackRoll { get; set; }
internal static int HighestAttackRoll { get; set; }

// keep a tab on last attack status [Booming Blade, Burning Blade, Resonating Strike]
internal static bool LastAttackWasCantripWeaponAttackHit { get; set; }
}
11 changes: 6 additions & 5 deletions SolastaUnfinishedBusiness/CustomBuilders/EldritchVersatility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -627,7 +627,8 @@ public void OnConditionAdded(RulesetCharacter target, RulesetCondition rulesetCo
// We just remove the power from power used by me list.
public void OnConditionRemoved(RulesetCharacter target, RulesetCondition rulesetCondition)
{
Main.Info("Condition Versatility interrupted");
// ReSharper disable once InvocationIsSkipped
Main.Log("Condition Versatility interrupted");

if (target.CurrentHitPoints <= 0)
{
Expand Down Expand Up @@ -685,7 +686,7 @@ public void OnActionExecutionHandled(
}

// Spend reserved points on cast EB if success
public IEnumerator OnSpellCast(RulesetCharacter featureOwner, GameLocationCharacter caster,
public IEnumerator OnMagicalAttackCastedSpell(RulesetCharacter featureOwner, GameLocationCharacter caster,
CharacterActionCastSpell castAction, RulesetEffectSpell selectEffectSpell,
RulesetSpellRepertoire selectedRepertoire, SpellDefinition selectedSpellDefinition)
{
Expand Down Expand Up @@ -800,7 +801,7 @@ public bool ShouldRemoveImmunityLevel(Func<int, int, bool> isImmuneToSpellLevel)

private sealed class BattlefieldShorthandCopySpells : IMagicalAttackCastedSpell
{
public IEnumerator OnSpellCast(
public IEnumerator OnMagicalAttackCastedSpell(
RulesetCharacter featureOwner,
GameLocationCharacter caster,
CharacterActionCastSpell castAction,
Expand Down Expand Up @@ -1420,7 +1421,7 @@ public void OnActionExecutionHandled(GameLocationCharacter character, CharacterA
}

// Spend reserved points on cast EB
public IEnumerator OnSpellCast(RulesetCharacter featureOwner, GameLocationCharacter caster,
public IEnumerator OnMagicalAttackCastedSpell(RulesetCharacter featureOwner, GameLocationCharacter caster,
CharacterActionCastSpell castAction, RulesetEffectSpell selectEffectSpell,
RulesetSpellRepertoire selectedRepertoire, SpellDefinition selectedSpellDefinition)
{
Expand All @@ -1443,7 +1444,7 @@ public IEnumerator OnSpellCast(RulesetCharacter featureOwner, GameLocationCharac
// Split this part to become a sub feature of invocation definition to make sure that the spells get removed even when the invocation is toggled off.
private class BattlefieldShorthandRemoveCopiedSpells : IMagicalAttackCastedSpell
{
public IEnumerator OnSpellCast(RulesetCharacter featureOwner, GameLocationCharacter caster,
public IEnumerator OnMagicalAttackCastedSpell(RulesetCharacter featureOwner, GameLocationCharacter caster,
CharacterActionCastSpell castAction, [UsedImplicitly] RulesetEffectSpell selectEffectSpell,
[UsedImplicitly] RulesetSpellRepertoire selectedRepertoire, SpellDefinition selectedSpellDefinition)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -930,7 +930,7 @@ public Retaliate(FeatureDefinitionPower pool, ConditionDefinition condition, boo
_pool = pool;
}

public IEnumerator OnAttackFinishedOnMe(
public IEnumerator OnPhysicalAttackFinishedOnMe(
GameLocationBattleManager battleManager,
CharacterAction action,
GameLocationCharacter attacker,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace SolastaUnfinishedBusiness.CustomInterfaces;

public sealed class IgnoreInterruptionCheck : IIgnoreInterruptionCheck
{
public static readonly IgnoreInterruptionCheck Marker = new();
}

public interface IIgnoreInterruptionCheck
{
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace SolastaUnfinishedBusiness.CustomInterfaces;
// On spell being cast
internal interface IMagicalAttackCastedSpell
{
IEnumerator OnSpellCast(
IEnumerator OnMagicalAttackCastedSpell(
RulesetCharacter featureOwner,
GameLocationCharacter caster,
CharacterActionCastSpell castAction,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace SolastaUnfinishedBusiness.CustomInterfaces;
public interface IPhysicalAttackFinishedByMe
{
[UsedImplicitly]
IEnumerator OnAttackFinishedByMe(
IEnumerator OnPhysicalAttackFinishedByMe(
GameLocationBattleManager battleManager,
CharacterAction action,
GameLocationCharacter attacker,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace SolastaUnfinishedBusiness.CustomInterfaces;
public interface IPhysicalAttackFinishedOnMe
{
[UsedImplicitly]
IEnumerator OnAttackFinishedOnMe(
IEnumerator OnPhysicalAttackFinishedOnMe(
GameLocationBattleManager battleManager,
CharacterAction action,
GameLocationCharacter attacker,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace SolastaUnfinishedBusiness.CustomInterfaces;
public interface IPhysicalAttackFinishedOnMeOrAlly
{
[UsedImplicitly]
IEnumerator OnAttackFinishedOnMeOrAlly(
IEnumerator OnPhysicalAttackFinishedOnMeOrAlly(
GameLocationBattleManager battleManager,
CharacterAction action,
GameLocationCharacter attacker,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace SolastaUnfinishedBusiness.CustomInterfaces;
public interface IPhysicalAttackInitiatedByMe
{
[UsedImplicitly]
IEnumerator OnAttackInitiatedByMe(
IEnumerator OnPhysicalAttackInitiatedByMe(
GameLocationBattleManager __instance,
CharacterAction action,
GameLocationCharacter attacker,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace SolastaUnfinishedBusiness.CustomInterfaces;
public interface IPhysicalAttackInitiatedOnMe
{
[UsedImplicitly]
IEnumerator OnAttackInitiatedOnMe(
IEnumerator OnPhysicalAttackInitiatedOnMe(
GameLocationBattleManager __instance,
CharacterAction action,
GameLocationCharacter attacker,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace SolastaUnfinishedBusiness.CustomInterfaces;
public interface IPhysicalAttackInitiatedOnMeOrAlly
{
[UsedImplicitly]
IEnumerator OnAttackInitiatedOnMeOrAlly(
IEnumerator OnPhysicalAttackInitiatedOnMeOrAlly(
GameLocationBattleManager __instance,
CharacterAction action,
GameLocationCharacter attacker,
Expand Down
37 changes: 28 additions & 9 deletions SolastaUnfinishedBusiness/CustomValidators/ValidatorsWeapon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,11 @@ internal static bool IsMelee([CanBeNull] RulesetItem rulesetItem)
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal static bool IsMelee([CanBeNull] RulesetAttackMode attackMode)
{
if (attackMode is { SourceDefinition: MonsterAttackDefinition { proximity: AttackProximity.Melee } })
{
return true;
}

if (attackMode == null
|| attackMode.Ranged
|| attackMode.SourceDefinition is not ItemDefinition itemDefinition
Expand All @@ -111,20 +116,34 @@ internal static bool IsMelee([CanBeNull] RulesetAttackMode attackMode)
return false;
}

// this patch is required for all the special smite use cases integration with vanilla ones
// most melee weapons will fallback here
if (!attackMode.thrown)
{
return true;
}

// unfortunately game sets thrown true even when attack is at melee distance
// this will handle thrown melee weapons like daggers, javelin, etc.
var currentAttackAction = Global.CurrentAttackAction;

// trying to be super safe here with any null scenario
if (currentAttackAction?.ActionParams?.TargetCharacters == null ||
currentAttackAction.ActionParams.TargetCharacters.Count == 0)
{
return false;
}

var gameLocationBattleService = ServiceRepository.GetService<IGameLocationBattleService>();

if (gameLocationBattleService is { IsBattleInProgress: true } &&
gameLocationBattleService.Battle.attackerContender != null &&
gameLocationBattleService.Battle.defenderContender != null)
if (gameLocationBattleService is not { IsBattleInProgress: true })
{
return gameLocationBattleService.IsWithinXCells(
gameLocationBattleService.Battle.attackerContender, gameLocationBattleService.Battle.defenderContender,
attackMode.ReachRange);
return false;
}

// fallback should never happen
return true;
return gameLocationBattleService.IsWithinXCells(
currentAttackAction.ActingCharacter,
currentAttackAction.ActionParams.TargetCharacters[0],
attackMode.ReachRange);
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
Expand Down
1 change: 1 addition & 0 deletions SolastaUnfinishedBusiness/Displays/GameServicesDisplay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ internal static class GameServicesDisplay
{
{ "None", null },
{ "Game", () => ServiceRepository.GetService<IGameService>()?.Game },
{ "ICameraService", ServiceRepository.GetService<ICameraService> },
{ "ICharacterBuildingService", ServiceRepository.GetService<ICharacterBuildingService> },
{ "ICharacterPoolService", ServiceRepository.GetService<ICharacterPoolService> },
{ "IGameCampaignService", ServiceRepository.GetService<IGameCampaignService> },
Expand Down
Loading

0 comments on commit 44e992c

Please sign in to comment.