MassBattle Docsv1.19.20

Attack.h

USTRUCT ×3 UENUM ×1

Source/MassBattle/Public/Fragments/Attack.h

概述 Overview

攻击相关的 fragment 集合。包含三类:配置数据 FAttack(策划可调参数)、运行时状态 FAttacking(每帧推进的攻击状态机)、辅助结构 FAnimHitTime(多动画命中时刻)与枚举 EAttackMode(命中时刻行为)。配置与运行时状态分离是 MassBattle 的标准模式:配置经 EntityConfig 注入后不变,状态由处理器逐帧更新。

Attack-related fragment collection. Three kinds: config data FAttack (designer-tunable parameters), runtime state FAttacking (per-frame attack state machine), plus the helper struct FAnimHitTime (per-animation hit moments) and the enum EAttackMode (hit-moment behavior). Separating config from runtime state is the standard MassBattle pattern: config is injected via EntityConfig and stays constant; state is advanced by processors each frame.

EAttackMode UENUM

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

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

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

FAnimHitTime USTRUCT

五个动画各自的命中时刻(归一化时间)。与 FAttack::bAnimAsDuration 配合使用:当攻击时长由动画长度决定时,用此结构指定每个动画的命中时间点。

Per-animation hit moments (normalized time) for five animation slots. Used together with FAttack::bAnimAsDuration: when attack duration follows the animation length, this struct specifies the hit moment for each animation.

成员变量 Members

名称 Name类型 Type默认值说明 Description
Anim0float0.5f动画 0 的命中时间。Hit time for animation 0.
Anim1float0.5f动画 1 的命中时间。Hit time for animation 1.
Anim2float0.5f动画 2 的命中时间。Hit time for animation 2.
Anim3float0.5f动画 3 的命中时间。Hit time for animation 3.
Anim4float0.5f动画 4 的命中时间。Hit time for animation 4.

方法 Methods

operator[] float (int32 Index)

按索引读取命中时间(0–4),越界返回 0.f。switch 直查,无数组存储。

Reads the hit time by index (0–4); returns 0.f out of range. Direct switch lookup, no array storage.

Input
参数 Param类型 Type说明 Description
Indexint32动画槽索引(0–4)。Animation slot index (0–4).
Output

返回对应动画的命中时间;越界返回 0.f。

Returns the hit time for the slot; 0.f out of range.

FAttack USTRUCT

攻击配置 fragment(FA_MassBattleBaseFragment 派生)。所有字段为策划在 EntityConfig 中可调参数,运行时不变。经 MASS_FRAGMENT_ACCEPT_NOT_TRIVIALLY_COPYABLE 声明为不可平凡拷贝(含 TArray 成员)。

Attack config fragment (derived from FA_MassBattleBaseFragment). All fields are designer-tunable EntityConfig parameters, constant at runtime. Declared via MASS_FRAGMENT_ACCEPT_NOT_TRIVIALLY_COPYABLE as not-trivially-copyable (contains TArray members).

成员变量 Members

名称 Name类型 Type默认值说明 Description
bEnablebooltrue是否启用攻击功能。Whether the attack function is enabled.
bCanPlayAnimbooltrue是否播放攻击动画。Whether to play the attack animation.
bAnimAsDurationboolfalse勾选后使用攻击动画长度作为攻击行为时长(动画长度定义在 Animation fragment 里)。仅当 bCanPlayAnim 为 true 时可编辑。When enabled, uses the attack anim length as the attack behavior duration (defined in the Animation fragment). Editable only when bCanPlayAnim is true.
DurationPerRoundfloat1.f每轮攻击持续时长(秒),会调整动画播放速度来匹配。仅当不播动画或未用动画时长时可编辑。Duration of each attack round in seconds; the anim playrate is adjusted to fit. Editable only when animation is off or anim-as-duration is off.
AimTimeRangeFVector2f(0.0, 3.0)瞄准时间范围(X=最小,Y=最大):角度有效时达到 X 即可开火;达到 Y 仍无有效角度则攻击失败。Aim time range (X=Min, Y=Max): attack may start after Min if the angle is valid; attack fails if Max is reached without a valid angle.
TimeOfHitfloat0.5f施加伤害的时刻(攻击时长内的归一化/秒值)。仅当未使用动画时长时可编辑。Moment when damage is applied (within the attack duration). Editable only when anim-as-duration is off.
AnimHitTimeFAnimHitTime—分动画的命中时刻。仅当 bAnimAsDuration 为 true 时可编辑(与 TimeOfHit 互斥显示)。Per-animation hit moments. Editable only when bAnimAsDuration is true (mutually exclusive with TimeOfHit).
CoolDownfloat0.f攻击冷却时长(秒)。Attack cooldown duration in seconds.
Rangefloat200.f攻击发起距离:与目标距离小于该值才可发起攻击。Attack initiation range: an attack can start only when closer than this to the target.
AngleToleranceATKfloat15.f攻击发起角度容差(度):与目标夹角小于该值才可发起攻击。Attack initiation angle tolerance in degrees: an attack can start only when the angle to the target is smaller.
RangeToleranceHitfloat400.f击中距离容差:距离小于该值可以击中。Hit range tolerance: a hit lands when closer than this value.
AngleToleranceHitfloat180.f击中角度容差(度):夹角小于该值可以击中。Hit angle tolerance in degrees: a hit lands when the angle is smaller.
YawSpeedMultfloat1.f攻击时偏航角速度乘数——控制转身面向目标的速度,在减速效果基础上叠加。Yaw turn speed multiplier during attack — scales how fast the agent rotates to face the target; applied on top of debuff slow.
YawAccelerationMultfloat1.f攻击时偏航角加速度乘数。Yaw turn acceleration multiplier during attack.
TimeOfHitActionEAttackModeApplyDMG击中时刻的行为(见 EAttackMode)。Behavior at the moment of hit (see EAttackMode).
SpawnProjectileTArray<FProjectileConfig>空命中时刻生成的抛射物配置列表。Projectiles to spawn at the hit moment.
SpawnActorTArray<FActorSpawnConfig_Attack>空命中时刻生成的 Actor 配置列表。Actors to spawn at the hit moment.
SpawnFxTArray<FFxConfig_Attack>空命中时刻生成的特效配置列表。FX to spawn at the hit moment.
PlaySoundTArray<FSoundConfig_Attack>空命中时刻播放的音效配置列表。Sounds to play at the hit moment.

FAttacking USTRUCT

攻击运行时状态 fragment。由攻击相关处理器逐帧推进:AimTime 累计瞄准时长、ATKTime 累计攻击时长、CoolTime 累计冷却,State 驱动 Aim → Attack → Cooldown 状态流转。

Attack runtime state fragment, advanced per frame by the attack processors: AimTime accumulates aiming, ATKTime accumulates attacking, CoolTime accumulates cooldown, and State drives the Aim → Attack → Cooldown transitions.

成员变量 Members

名称 Name类型 Type默认值说明 Description
AimTimefloat0.0f当前瞄准累计时间(秒)。Current accumulated aiming time in seconds.
ATKTimefloat0.0f当前攻击累计时间(秒)。Current accumulated attack time in seconds.
CoolTimefloat0.0f当前冷却累计时间(秒)。Current accumulated cooldown time in seconds.
StateEAttackStateAim当前攻击状态(枚举定义于 MassBattleEnums.h)。Current attack state (enum defined in MassBattleEnums.h).
bAimFailedboolfalse瞄准是否因超时而失败。用于直飞(冲锋) / 驻停冷却行为分支。Whether aiming failed due to timeout. Used for fly-through / stand-still cooldown behavior.

方法 Methods

Reset FORCEINLINE void

将全部状态复位到默认值(瞄准 0 / 攻击 0 / 冷却 0 / State=Aim / 未失败)。用于实体复用或攻击循环重启。

Resets all state to defaults (aim 0 / attack 0 / cooldown 0 / State=Aim / not failed). Used on entity reuse or attack loop restart.

Input

无参数。

No parameters.

Output

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

No return value. Side effect: all members reset.

补充说明 Notes

文件末尾的 FDisableAttackTag 为注释掉的预留 Tag 定义,当前未启用。

The commented-out FDisableAttackTag at the end of the file is a reserved tag definition, currently disabled.