# 伪代码：增强版辅助瞄准（多目标情况）
def enhanced_aim_assist(targets, current_aim, player_state, delta_time):
    if not targets:
        return current_aim  # 无目标不处理
    
    # 计算每个目标的优先级得分
    scored_targets = []
    for target in targets:
        score = 0.0
        
        # 因子1：距离权重（40%）
        dist = distance(current_aim, target.position)
        dist_score = max(0, 1 - dist / MAX_DIST) * 0.4
        
        # 因子2：威胁权重（25%）
        threat_score = 0
        if target.is_attacking(player_state):  # 正在攻击玩家
            threat_score = 0.25
        elif target.is_facing(player_state):   # 面向玩家
            threat_score = 0.15
        
        # 因子3：血量权重（20%）
        health_score = (1 - target.health) * 0.2  # 目标血量越低权重越高
        
        # 因子4：运动趋势（15%）
        trend_score = 0
        if target.moving_toward(player_state): # 目标正在靠近玩家
            trend_score = 0.15
        
        total_score = dist_score + threat_score + health_score + trend_score
        scored_targets.append((target, total_score, dist))
    
    # 选择最高优先级目标
    best_target = max(scored_targets, key=lambda x: x[1])[0]
    best_dist = min(x[2] for x in scored_targets)  # 实际取最近距离用于强度计算
    
    # 冷却机制检查（防止目标切换过快）
    global last_switch_time
    if time.time() - last_switch_time < SWITCH_COOLDOWN:
        best_target = last_target  # 保持原目标
    else:
        last_switch_time = time.time()
        last_target = best_target
    
    # 动态辅助强度计算（加入玩家移动状态影响）
    base_strength = max(0, 1 - best_dist / ASSIST_THRESHOLD)
    
    # 移动惩罚：玩家移动时降低辅助
    if player_state.is_moving:
        move_penalty = 0.7
    else:
        move_penalty = 1.0
    
    # 开镜增强：开镜时增加辅助精度
    if player_state.is_aiming:
        ads_boost = 1.2
    else:
        ads_boost = 1.0
    
    final_strength = clamp(base_strength * move_penalty * ads_boost, 0, MAX_STRENGTH)
    
    # 运动轨迹预测
    predicted_position = predict_motion(best_target, delta_time)
    
    # 计算辅助偏移
    aim_offset = (predicted_position - current_aim) * final_strength * ASSIST_FACTOR
    new_aim = current_aim + aim_offset
    
    return new_aim

# 辅助函数：目标运动预测
def predict_motion(target, delta_time):
    # 基础位置预测
    base_pos = target.position + target.velocity * delta_time
    
    # 抛物线补偿（考虑重力）
    if is_projectile_weapon():  # 如果是投掷物等
        gravity = Vector3(0, -9.8, 0)
        base_pos += 0.5 * gravity * (delta_time**2)
    
    return base_pos
    