Mass Battle Frameworkv1.20.0

Attack.h

USTRUCT ×2 UENUM ×1

Source/MassBattle/Public/Fragments/Attack.h

概述Overview

攻击的配置与运行期状态,外加命中时刻的行为枚举。FAttack 承载作者可调的全部参数:开火门槛、回合时长、命中时刻与命中容差、冷却、攻击期间的转向速率乘数,以及「攻击时是否继续移动」。FAttacking 是每帧推进的攻击状态机。瞄准不在本页:瞄准窗口与两个到位容差住在 Aim.h,开火前由瞄准行为把关节转到位。

The attack config and runtime state, plus the enum for what happens at the hit moment. FAttack carries every authored parameter: entry gate, round duration, hit moment and hit tolerances, cooldown, turn-rate multipliers while attacking, and whether the unit keeps moving during the round. FAttacking is the per-frame attack state machine.Aim is not here: the aim window and the two on-target tolerances live on Aim.h, and the Aim behaviour rotates the joint into place before the round opens.

EAttackMode UENUM

命中时刻的行为枚举,由 FAttack::TimeOfHitAction 使用。

Hit-moment behavior enum, used by FAttack::TimeOfHitAction.

值Value说明Description
None无行为。No behavior.
ApplyDMG造成伤害。Apply damage.
SuicideATK造成伤害后自毁。Apply damage, then despawn.
Despawn自毁(不造成伤害)。Despawn (without damage).

FAttack USTRUCT

攻击配置片段(FA_MassBattleBaseFragment 派生)。所有字段为作者在 Agent 配置中可调的参数,运行时不变。开火前的进入门槛是 Range;命中判定用下面三个命中容差;瞄准窗口与到位容差不在这里。

The attack config fragment (derived from FA_MassBattleBaseFragment). All fields are author-tunable on the agent config and constant at runtime. The pre-shot entry gate is Range; the hit test uses the three hit tolerances below; the aim window and on-target tolerances are not here.

成员变量Members

名称Name类型Type默认值说明Description
bEnablebooltrue是否启用攻击功能。Whether the attack function is enabled.
bCanPlayAnimbooltrue是否播放攻击动画。Whether to play an attack animation.
bAnimAsDurationboolfalse勾选后用攻击动画的长度作为回合时长(动画长度在 Animation 片段里定义)。仅当 bCanPlayAnim 为 true 时可编辑。When enabled, the attack clip's length becomes the round duration (the clip length is defined in the Animation fragment). Editable only when bCanPlayAnim is true.
DurationPerRoundfloat1 秒s每轮攻击的持续时长;动画播放速率会被调整以匹配。仅在不播动画或未用动画时长时可编辑。Duration of each attack round; the clip's play rate is adjusted to fit. Editable only when animation is off or anim-as-duration is off.
TimeOfHitfloat0.5 秒s命中时刻,自回合开始算。恒定生效:命中从不由片段 notify 驱动,notify 只执行自己的动作。勾选 bAnimAsDuration 时,回合时长就是片段的播放长度。Hit time in seconds from round start.Always used: the hit is never driven by clip notifies — those only run their own actions. With bAnimAsDuration the round lasts the clip's play length.
TimeOfHitActionEAttackModeApplyDMG命中时刻的行为(见 EAttackMode)。Behavior at the moment of hit (see EAttackMode).
CoolDownfloat0 秒s攻击冷却时长。瞄准超时也按这份冷却重新计。Attack cooldown duration. An aim timeout also runs this cooldown from zero.
Rangefloat50 cm攻击距离(Attack Range):与目标的表面距离小于该值才发起瞄准——「去攻击」的请求就是「去瞄准」,回合只在瞄准完成后开局。Attack range (Attack Range): aiming is requested only when the surface distance to the target is below this value — a request to attack is a request to aim, and the round opens only after aiming completes.
RangeToleranceHitfloat75 cm命中距离(Hit Range):命中时刻与目标的表面距离在此以内才可击中。Hit range (Hit Range): a hit lands only when the surface distance to the target is below this value at the hit moment.
AngleToleranceHitfloat90 度deg命中角度(Hit Angle):瞄准偏航与目标的夹角在此以内才可击中。Hit angle (Hit Angle): a hit lands only when the aim yaw is within this many degrees of the target.
PitchToleranceHitfloat15 度deg命中俯仰角(Hit Pitch Angle):瞄准俯仰与目标的夹角在此以内才可击中。骨架没有烘出俯仰关节时这一项不参与判定。Hit pitch angle (Hit Pitch Angle): a hit lands only when the aim pitch is within this many degrees of the target. It does not participate when the rig bakes no pitch joint.
bCanAttackWhileMovingboolfalse在攻击回合的每个相位都保持移动并持续追向目标。关闭 = 先行的瞄准行为以及前摇 / 后摇期间站定,只在冷却期向前压进。Keep moving — and keep tracking the target — through every phase of the round. Off = plant during the preceding Aim behaviour and through wind-up / post-cast, pressing forward only while cooling.
YawSpeedMultfloat1攻击时偏航角速度乘数:控制转身面向目标的速度,在减速效果之上叠加。Yaw turn-speed multiplier during the attack: how fast the unit rotates to face the target, applied on top of debuff slow.
YawAccelerationMultfloat1攻击时偏航角加速度乘数。Yaw turn-acceleration multiplier during the attack.

FAttacking USTRUCT

攻击运行期状态片段(FA_MassBattleBaseFragment 派生),由行为系统逐帧推进:State 走 前摇 → 后摇(命中) → 冷却 → 完成,三个计时器各自累计,另带本回合已解析的时长与减速乘数。

The attack runtime state fragment (derived from FA_MassBattleBaseFragment), advanced each frame by the behavior system:State runs wind-up → follow-through (the hit) → cooling → completed, with three separate clocks plus the resolved round duration and the slow multiplier for this round.

成员变量Members

名称Name类型Type默认值说明Description
AimTimefloat0 秒s为快照布局与旧数据保留的瞄准时钟。攻击回合不再推进它——正在用的瞄准计时是行为状态上的 AimTime,归回合之前运行的瞄准行为所有。Legacy aim clock kept for the snapshot layout and older data.The attack round no longer advances it — the live aim timer is AimTime on the behavior state, owned by the Aim behaviour that runs before the round.
ATKTimefloat0 秒s当前回合已累计的攻击时间。Accumulated attack time of the current round.
RealDurationfloat0 秒s本回合实际运行的时长:动画时长解析成功时取片段长度,否则取 DurationPerRound。The duration this round actually runs at: the clip length when anim-as-duration resolves it, otherwise DurationPerRound.
SpeedMultiplierfloat1本回合时钟运行的减速乘数。被减速时小于 1,下限 0.1;生成助手会把配置里的延迟除以它,使生成时刻与本回合时钟一致。Slow multiplier this round's clock runs at. Below 1 while slowed, floored at 0.1; spawn helpers divide a configured delay by it so spawn timing matches this round's clock.
NotifyCursorfloat-1 秒s本轮已处理到的片段 notify 时刻。-1 表示还没有处理过任何 notify,因此 t=0 的 notify 在第一个 tick 就会触发。Last clip-notify time already handled this round.-1 means none yet, so a notify authored at t=0 fires on the first tick.
CoolTimefloat0 秒s当前冷却已累计的时间。Accumulated cooldown time of the current round.
StateEAttackStatePreCast_FirstExec当前攻击状态(枚举定义于 MassBattleEnums.h):前摇首帧、前摇、后摇(命中)、冷却、完成。Current attack state (enum defined in MassBattleEnums.h): first wind-up frame, wind-up, follow-through (hit), cooling, completed.
bAimFailedboolfalse本次开火前的瞄准是否因超时失败。用于直飞 / 驻停冷却行为分支。Whether the aim before this shot failed by timing out. Used for fly-through / stand-still cooldown behavior.

方法Methods

Reset FORCEINLINE void

把全部状态复位到默认值:两个计时与冷却归零、时长归零、减速乘数回到 1、notify 游标回到 -1、状态回到前摇首帧、瞄准失败标记清除。用于实体复用或攻击循环重启。

Resets all state to defaults: both timers and the cooldown to zero, duration to zero, the slow multiplier back to 1, the notify cursor back to -1, the state back to the first wind-up frame, and the aim-failure flag cleared. Used on entity reuse or when the attack loop restarts.

Input

无参数。

No parameters.

Output

无返回值。副作用:全部成员复位。

No return value. Side effect: all members reset.

边界与注意Caveats

先瞄准,再开火。武器就绪且与目标的表面距离在 Range 内时请求瞄准;关节到位并过了瞄准窗口的最短时间后,回合才从前摇开局。瞄准途中目标丢失或走出攻击距离,本次开火结束,行为链重新选择。瞄准窗口与两个到位容差在 Aim.h,不在这里。

Aim first, then fire. Aiming is requested when the weapon is ready and the surface distance to the target is within Range; the round opens at the wind-up only after the joint is on target and the aim window's minimum time has elapsed. If the target is lost or walks out of range while aiming, this shot ends and the behavior chain re-picks. The aim window and the two on-target tolerances live on Aim.h, not here.

关掉攻击,瞄准也会结束。瞄准只为攻击服务:把 bEnable 关掉时,正在瞄准的单位会退出瞄准并回到空闲,而不是带着瞄准状态停在那里。

Disabling attack also ends aiming. Aiming exists to feed the attack: with bEnable off, an aiming unit leaves the Aim behavior and returns to idle instead of sitting there with aim state set.

命中要同时过三道判定。命中时刻,与目标的表面距离必须在 RangeToleranceHit 内,偏航夹角在 AngleToleranceHit 内,并且(骨架烘出俯仰关节时)俯仰夹角在 PitchToleranceHit 内。骨架没有瞄准关节时,身体前向就是瞄准方向,只在水平面上用 AngleToleranceHit 判定。

A hit must pass three tests at once. At the hit moment the surface distance must be within RangeToleranceHit, the yaw within AngleToleranceHit, and — when the rig bakes a pitch joint — the pitch within PitchToleranceHit. With no aim joint the body's forward direction is the aim, tested only in the horizontal plane with AngleToleranceHit.

命中时刻只有一个来源。TimeOfHit 是标量时钟,片段 notify 绝不改变它、也不门控它——notify 只执行自己的动作。若 TimeOfHit 超过本回合实际时长(例如动画比它短),这一轮不会命中,直接进冷却。

The hit moment has one source.TimeOfHit is the scalar clock; clip notifies never move or gate it — they only run their own actions. If TimeOfHit exceeds the round's actual duration (for example a clip shorter than it), that round lands no hit and goes straight to cooling.

命中时刻的特效 / 音效 / 生成物在 notify 表里配。本配置只决定「什么时候命中、命中后做什么行为」;命中瞬间要生成的抛射物、Actor、特效、音效与战利品,写进 NotifyShared.h 的行里。攻击配置上不再提供这些作者入口。

Effects, sounds and spawns at the hit moment are authored in the notify table. This config decides when the hit lands and what behavior follows; projectiles, actors, effects, sounds and loot spawned at that instant are written as rows in NotifyShared.h. The attack config no longer offers those authoring entries.

站定与继续移动是一组交通特权。bCanAttackWhileMoving 关闭时,瞄准、前摇与后摇期间单位站定,冷却期才向前压进,并持有战斗路权(战斗中的优先通行、跳过避障、抑制静止侧让)。开启时整个回合都按压进处理:goal 一直锁在目标身上,停在追击的到达距离上,并让出那套交通特权。

Planting versus moving is a traffic-rights choice. With bCanAttackWhileMoving off, the unit plants during aim, wind-up and post-cast and presses forward only while cooling, holding combat right-of-way (priority in combat, avoidance skip, idle side-step suppression). With it on, the whole round presses in: the goal stays locked on the target, the unit stops at the chase acceptance distance, and it gives up those traffic privileges.

减速会拉长整个回合。开了减速影响攻击节奏时(Defence.bCanSlowATKSpeed),被减速的单位攻击时钟按 SpeedMultiplier 放慢,最低到正常速度的 10%;瞄准阶段跟随同一个乘数,所以瞄准也被拉长。

Slow stretches the whole round. When slow is allowed to affect the attack cadence (Defence.bCanSlowATKSpeed), a slowed unit's attack clock runs at SpeedMultiplier, down to 10% of normal; the aim phase follows the same multiplier, so aiming is stretched too.

瞄准超时按攻击冷却惩罚。瞄准窗口用尽仍未对准时,bAimFailed 置位、状态直接进入冷却并从零开始计,本轮不命中。

An aim timeout is penalized with the attack cooldown. When the aim window expires without alignment,bAimFailed is set, the state drops straight into cooling from zero, and that round lands no hit.

内部结构Internal Structs

本头文件还定义了 1 个仅供内部数据流转的结构体,它们不是作者面配置,因此不单独成节:FDisableAttackTag。

This header also defines 1 structs that only carry internal data; they are not authoring surface, so they get no section of their own: FDisableAttackTag.