Skip to content
This repository has been archived by the owner on Aug 28, 2024. It is now read-only.

Commit

Permalink
fix: add effect range.
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchiDog1998 committed May 10, 2023
1 parent 7fb5d94 commit 9d377c0
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
2 changes: 1 addition & 1 deletion RotationSolver.Basic/Actions/BaseAction_ActionInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace RotationSolver.Basic.Actions;
public partial class BaseAction
{
public float Range => ActionManager.GetActionRange(ID);

public float EffectRange => _action?.EffectRange ?? 0;
internal ActionID[] ComboIdsNot { private get; init; } = null;

internal ActionID[] ComboIds { private get; init; } = null;
Expand Down
22 changes: 11 additions & 11 deletions RotationSolver.Basic/Actions/BaseAction_Target.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ private bool FindTarget(bool mustUse, out BattleChara target)
float range = Range;

//如果都没有距离,这个还需要选对象嘛?选自己啊!
if (range == 0 && _action.EffectRange == 0)
if (range == 0 && EffectRange == 0)
{
target = player;
return true;
Expand Down Expand Up @@ -99,7 +99,7 @@ private bool FindTarget(bool mustUse, out BattleChara target)
private bool TargetArea(float range, bool mustUse, int aoeCount, PlayerCharacter player)
{
//移动
if (_action.EffectRange == 1 && range >= 15)
if (EffectRange == 1 && range >= 15)
{
return TargetAreaMove(range, mustUse);
}
Expand Down Expand Up @@ -161,7 +161,7 @@ private bool TargetAreaFriend(float range, bool mustUse, PlayerCharacter player)
//计算玩家和被打的T之间的关系。
else
{
var effectRange = (ActionID)ID == ActionID.LiturgyOfTheBell ? 20 : _action.EffectRange;
var effectRange = (ActionID)ID == ActionID.LiturgyOfTheBell ? 20 : EffectRange;
var attackT = TargetFilter.FindAttackedTarget(DataCenter.PartyTanks.GetObjectInRadius(range + effectRange), mustUse);

if (attackT == null)
Expand Down Expand Up @@ -327,7 +327,7 @@ private bool TargetHostileManual(BattleChara b, bool mustUse, int aoeCount, out

private bool TargetSelf(bool mustUse, int aoeCount)
{
if (_action.EffectRange > 0 && !IsFriendly)
if (EffectRange > 0 && !IsFriendly)
{
if (NoAOE)
{
Expand All @@ -340,10 +340,10 @@ private bool TargetSelf(bool mustUse, int aoeCount)
if (!Configuration.PluginConfiguration.GetValue(SettingsCommand.UseAOEWhenManual) && !mustUse) return false;
}

var tars = TargetFilter.GetObjectInRadius(TargetFilterFuncEot(DataCenter.HostileTargets, mustUse), _action.EffectRange);
var tars = TargetFilter.GetObjectInRadius(TargetFilterFuncEot(DataCenter.HostileTargets, mustUse), EffectRange);
if (tars.Count() < aoeCount) return false;

if (Service.Config.NoNewHostiles && TargetFilter.GetObjectInRadius(DataCenter.AllHostileTargets, _action.EffectRange)
if (Service.Config.NoNewHostiles && TargetFilter.GetObjectInRadius(DataCenter.AllHostileTargets, EffectRange)
.Any(t => t.TargetObject == null)) return false;
}
return true;
Expand All @@ -353,7 +353,7 @@ private bool TargetSelf(bool mustUse, int aoeCount)
private IEnumerable<BattleChara> GetMostObjects(IEnumerable<BattleChara> targets, int maxCount)
{
var range = Range;
var canAttack = TargetFilter.GetObjectInRadius(targets, range + _action.EffectRange);
var canAttack = TargetFilter.GetObjectInRadius(targets, range + EffectRange);
var canGetObj = TargetFilter.GetObjectInRadius(canAttack, range).Where(CanUseTo);

if (_action.CastType == 1) return canGetObj;
Expand Down Expand Up @@ -419,20 +419,20 @@ public bool CanGetTarget(BattleChara target, BattleChara subTarget)
switch (_action.CastType)
{
case 2: // 圆形范围攻击
return Vector3.Distance(target.Position, subTarget.Position) - subTarget.HitboxRadius <= _action.EffectRange;
return Vector3.Distance(target.Position, subTarget.Position) - subTarget.HitboxRadius <= EffectRange;

case 3: // Sector
if(subTarget.DistanceToPlayer() > _action.EffectRange) return false;
if(subTarget.DistanceToPlayer() > EffectRange) return false;
tdir += dir / dir.Length() * target.HitboxRadius / (float)Math.Sin(_alpha);
return Vector3.Dot(dir, tdir) / (dir.Length() * tdir.Length()) >= Math.Cos(_alpha);

case 4: //直线范围攻击
if (subTarget.DistanceToPlayer() > _action.EffectRange) return false;
if (subTarget.DistanceToPlayer() > EffectRange) return false;
return Vector3.Cross(dir, tdir).Length() / dir.Length() <= 2 + target.HitboxRadius;

case 10: //环形范围攻击也就这么判断吧,我烦了。
var dis = Vector3.Distance(target.Position, subTarget.Position) - subTarget.HitboxRadius;
return dis <= _action.EffectRange && dis >= 8;
return dis <= EffectRange && dis >= 8;
}

PluginLog.LogDebug(Name + "'s CastType is not valid! The value is " + _action.CastType.ToString());
Expand Down
1 change: 1 addition & 0 deletions RotationSolver.Basic/Actions/IBaseAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public interface IBaseAction : IAction
float CastTime { get; }

float Range { get; }
float EffectRange { get; }

[EditorBrowsable(EditorBrowsableState.Never)]
bool IsFriendly { get; }
Expand Down

0 comments on commit 9d377c0

Please sign in to comment.