feat(orb): contra-atac amb bullet_double dirigida al jugador en rebre impacte
This commit is contained in:
@@ -186,6 +186,11 @@ namespace {
|
||||
}
|
||||
}
|
||||
|
||||
// Forward-decl: aimModeFromString viu més avall (junt amb la resta de
|
||||
// helpers d'AI) però parseActionList el necessita per al payload de
|
||||
// FIRE_BULLET. Evita reordenar tot el bloc.
|
||||
auto aimModeFromString(const std::string& s) -> std::optional<AimMode>;
|
||||
|
||||
auto actionTypeFromString(const std::string& s) -> std::optional<EnemyActionType> {
|
||||
if (s == "set_hurt") { return EnemyActionType::SET_HURT; }
|
||||
if (s == "destroy") { return EnemyActionType::DESTROY; }
|
||||
@@ -197,6 +202,7 @@ namespace {
|
||||
if (s == "apply_impulse") { return EnemyActionType::APPLY_IMPULSE; }
|
||||
if (s == "decrease_health") { return EnemyActionType::DECREASE_HEALTH; }
|
||||
if (s == "flash") { return EnemyActionType::FLASH; }
|
||||
if (s == "fire_bullet") { return EnemyActionType::FIRE_BULLET; }
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
@@ -219,19 +225,50 @@ namespace {
|
||||
<< event_name << " (" << enemy_name << ")\n";
|
||||
return false;
|
||||
}
|
||||
out.push_back({*PARSED});
|
||||
EnemyAction action;
|
||||
action.type = *PARSED;
|
||||
// Payload de FIRE_BULLET. Camps opcionals; els defaults són els del struct.
|
||||
if (action.type == EnemyActionType::FIRE_BULLET) {
|
||||
if (item.contains("bullet")) {
|
||||
action.bullet_config_name = item["bullet"].get_value<std::string>();
|
||||
}
|
||||
if (item.contains("bullet_speed")) {
|
||||
action.bullet_speed = item["bullet_speed"].get_value<float>();
|
||||
}
|
||||
if (item.contains("aim_mode")) {
|
||||
const auto AIM_STR = item["aim_mode"].get_value<std::string>();
|
||||
const auto AIM = aimModeFromString(AIM_STR);
|
||||
if (!AIM) {
|
||||
std::cerr << "[EnemyConfig] Error: aim_mode desconegut '" << AIM_STR
|
||||
<< "' a " << event_name << " (" << enemy_name << ")\n";
|
||||
return false;
|
||||
}
|
||||
action.aim_mode = *AIM;
|
||||
}
|
||||
if (item.contains("jitter_rad")) {
|
||||
action.jitter_rad = item["jitter_rad"].get_value<float>();
|
||||
}
|
||||
}
|
||||
out.push_back(action);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// Defaults: replica el flux hardcoded actual (set_hurt → destroy → score+debris+fireworks).
|
||||
// Construïm via mutació per esquivar warnings de designated-init parcial sobre
|
||||
// l'EnemyAction (que té payload de FIRE_BULLET no rellevant ací).
|
||||
void fillLegacyDefaults(EnemyEventConfig& events) {
|
||||
events.on_hit = {{EnemyActionType::SET_HURT}};
|
||||
events.on_hurt_end = {{EnemyActionType::DESTROY}};
|
||||
const auto MAKE = [](EnemyActionType type) {
|
||||
EnemyAction a;
|
||||
a.type = type;
|
||||
return a;
|
||||
};
|
||||
events.on_hit = {MAKE(EnemyActionType::SET_HURT)};
|
||||
events.on_hurt_end = {MAKE(EnemyActionType::DESTROY)};
|
||||
events.on_destroy = {
|
||||
{EnemyActionType::ADD_SCORE},
|
||||
{EnemyActionType::CREATE_DEBRIS},
|
||||
{EnemyActionType::CREATE_FIREWORKS},
|
||||
MAKE(EnemyActionType::ADD_SCORE),
|
||||
MAKE(EnemyActionType::CREATE_DEBRIS),
|
||||
MAKE(EnemyActionType::CREATE_FIREWORKS),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user