aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/fparkan-game/src/main.rs13
-rw-r--r--apps/fparkan-game/src/mission_notices.rs6
-rw-r--r--apps/fparkan-game/src/player_collision.rs7
-rw-r--r--crates/fparkan-runtime/src/lib.rs11
-rw-r--r--crates/fparkan-runtime/src/mission_events.rs27
-rw-r--r--docs/tomes/06-behavior.md6
6 files changed, 53 insertions, 17 deletions
diff --git a/apps/fparkan-game/src/main.rs b/apps/fparkan-game/src/main.rs
index 6c33404a..25b89354 100644
--- a/apps/fparkan-game/src/main.rs
+++ b/apps/fparkan-game/src/main.rs
@@ -105,7 +105,7 @@ use fparkan_render_vulkan::{
VulkanStaticTexture, VulkanStaticTextureMip, VulkanStaticVertex,
};
use fparkan_runtime::{
- apply_projectile_contact, autodemo_camera, board_friendly_warbot, capture_building,
+ apply_projectile_contact, autodemo_camera, board_friendly_warbot, capture_building_with_notice,
capture_neutral_warbot, create, deploy_mine, disembark_warbot, frame as step_mission_frame,
frame_with_player_motion, load_gameplay_mission, load_mission_static_preview,
load_mission_static_preview_roots, loaded_mission_assets, loaded_mission_object_drafts,
@@ -11109,6 +11109,7 @@ impl StaticVulkanApp {
}
}
}
+ let mut capture_notice = None;
if let (true, Some(cockpit), false) = (
std::mem::take(&mut self.player_capture_pressed),
self.cockpit,
@@ -11148,9 +11149,10 @@ impl StaticVulkanApp {
"player_capture object={} queue_time_ms={control_clock_ms}",
target.0
);
- } else if let Some(target) =
- capture_building(engine, cockpit).map_err(|error| error.to_string())?
+ } else if let Some((target, notice)) = capture_building_with_notice(engine, cockpit)
+ .map_err(|error| error.to_string())?
{
+ capture_notice = Some(notice);
eprintln!(
"player_building_capture object={} queue_time_ms={control_clock_ms}",
target.0
@@ -11250,10 +11252,9 @@ impl StaticVulkanApp {
eprintln!("mission_patrol_order unit={} target=[{x},{y}] queue_time_ms={control_clock_ms}", handle.slot);
}
}
- for &notice in frame
- .mission_event
+ for &notice in capture_notice
.iter()
- .flat_map(|tick| &tick.notices)
+ .chain(frame.mission_event.iter().flat_map(|tick| &tick.notices))
.chain(&frame.clan_notices)
{
self.present_mission_notice(notice, control_clock_ms);
diff --git a/apps/fparkan-game/src/mission_notices.rs b/apps/fparkan-game/src/mission_notices.rs
index a4ea8f05..b3f855bf 100644
--- a/apps/fparkan-game/src/mission_notices.rs
+++ b/apps/fparkan-game/src/mission_notices.rs
@@ -4,6 +4,7 @@ use fparkan_runtime::MissionNotice;
impl StaticVulkanApp {
pub(super) fn present_mission_notice(&mut self, notice: MissionNotice, clock_ms: u32) {
match notice {
+ MissionNotice::BuildingCaptured { .. } => {}
MissionNotice::ObjectiveComplete(index) => {
eprintln!(
"mission_objective index={index} status=complete queue_time_ms={clock_ms}"
@@ -39,6 +40,11 @@ impl StaticVulkanApp {
let voice = match notice {
MissionNotice::Information(index) => audio.queue_mission_voice(index),
MissionNotice::ObjectiveComplete(_) => audio.queue_game_voice("VOICE_OBJ_COMPLETE"),
+ MissionNotice::BuildingCaptured { neutral } => audio.queue_game_voice(if neutral {
+ "VOICE_NBUILD_CAPTURE"
+ } else {
+ "VOICE_EBUILD_CAPTURE"
+ }),
MissionNotice::Completed => audio.queue_game_voice("VOICE_MISSION_COMPLETE"),
MissionNotice::Failed => audio.queue_game_voice("VOICE_MISSION_FAIL"),
};
diff --git a/apps/fparkan-game/src/player_collision.rs b/apps/fparkan-game/src/player_collision.rs
index c34422da..4668abd6 100644
--- a/apps/fparkan-game/src/player_collision.rs
+++ b/apps/fparkan-game/src/player_collision.rs
@@ -250,8 +250,11 @@ mod tests {
assert!(z < factory.position[2] - 4.0, "factory cabin at {z}");
assert_eq!(app.terrain.height_at([x, y]).unwrap(), None);
assert_eq!(
- fparkan_runtime::capture_building(&mut engine, cockpit).unwrap(),
- Some(fparkan_world::OriginalObjectId(0))
+ fparkan_runtime::capture_building_with_notice(&mut engine, cockpit).unwrap(),
+ Some((
+ fparkan_world::OriginalObjectId(0),
+ fparkan_runtime::MissionNotice::BuildingCaptured { neutral: true }
+ ))
);
}
}
diff --git a/crates/fparkan-runtime/src/lib.rs b/crates/fparkan-runtime/src/lib.rs
index a67276a3..701a4a2e 100644
--- a/crates/fparkan-runtime/src/lib.rs
+++ b/crates/fparkan-runtime/src/lib.rs
@@ -149,8 +149,8 @@ pub use mesh_collision::{query_building_segment_world, BuildingMeshHit, Building
pub use mining::deploy_mine;
use mission_events::MissionEvents;
pub use mission_events::{
- capture_building, capture_neutral_building, capture_neutral_warbot, MissionEventStop,
- MissionEventTick, MissionNotice,
+ capture_building, capture_building_with_notice, capture_neutral_building,
+ capture_neutral_warbot, MissionEventStop, MissionEventTick, MissionNotice,
};
pub use player_motion::{
plan_player_motion, plan_player_motion_with_collision, PlayerMotion, PlayerMotionStep,
@@ -18228,8 +18228,11 @@ mod tests {
};
let initial_count = count(&engine);
assert_eq!(
- capture_building(&mut engine, hero).unwrap(),
- Some(factory_id)
+ capture_building_with_notice(&mut engine, hero).unwrap(),
+ Some((
+ factory_id,
+ MissionNotice::BuildingCaptured { neutral: false }
+ ))
);
assert_eq!(
identity_metadata(&engine.world, factory).unwrap().owner_id,
diff --git a/crates/fparkan-runtime/src/mission_events.rs b/crates/fparkan-runtime/src/mission_events.rs
index ec976224..5108a058 100644
--- a/crates/fparkan-runtime/src/mission_events.rs
+++ b/crates/fparkan-runtime/src/mission_events.rs
@@ -51,6 +51,8 @@ pub enum MissionNotice {
Information(u32),
/// Objective changed from pending to complete.
ObjectiveComplete(u32),
+ /// The player's capture took a building from a neutral or enemy clan.
+ BuildingCaptured { neutral: bool },
/// Mission completed.
Completed,
/// Mission failed.
@@ -472,6 +474,7 @@ pub fn capture_neutral_building(
cockpit: StartingCockpit,
) -> Result<Option<OriginalObjectId>, EngineError> {
capture_building_at_communicator(engine, cockpit, false)
+ .map(|capture| capture.map(|(id, _)| id))
}
/// Transfers a neutral or hostile building at the player's communicator.
@@ -482,6 +485,18 @@ pub fn capture_building(
engine: &mut Engine,
cockpit: StartingCockpit,
) -> Result<Option<OriginalObjectId>, EngineError> {
+ capture_building_with_notice(engine, cockpit).map(|capture| capture.map(|(id, _)| id))
+}
+
+/// Transfers a building and reports which capture announcement to play.
+///
+/// # Errors
+///
+/// Returns an error if the player's world handle or the ownership update fails.
+pub fn capture_building_with_notice(
+ engine: &mut Engine,
+ cockpit: StartingCockpit,
+) -> Result<Option<(OriginalObjectId, MissionNotice)>, EngineError> {
capture_building_at_communicator(engine, cockpit, true)
}
@@ -489,7 +504,7 @@ fn capture_building_at_communicator(
engine: &mut Engine,
cockpit: StartingCockpit,
allow_hostile: bool,
-) -> Result<Option<OriginalObjectId>, EngineError> {
+) -> Result<Option<(OriginalObjectId, MissionNotice)>, EngineError> {
let Some(mission) = &mut engine.loaded else {
return Ok(None);
};
@@ -522,14 +537,16 @@ fn capture_building_at_communicator(
&& player_clan.relations.iter().any(|relation| {
relation.relation_value == 0 && relation.other_clan_name.raw == clan.name.raw
});
- (class & 0x8000_0000 != 0 && (clan.mode == 3 || hostile)).then_some((
+ let neutral = clan.mode == 3;
+ (class & 0x8000_0000 != 0 && (neutral || hostile)).then_some((
handle,
identity.original_id?,
owner,
class,
+ neutral,
))
})
- .find(|&(handle, id, _, class)| {
+ .find(|&(handle, id, _, class, _)| {
transform_state(&engine.world, handle).is_ok_and(|pose| {
on_communicator(
&mission.mission_assets,
@@ -540,7 +557,7 @@ fn capture_building_at_communicator(
)
})
});
- if let Some((handle, id, former_owner, class)) = candidate {
+ if let Some((handle, id, former_owner, class, neutral)) = candidate {
mission.transfer_building(
&mut engine.world,
handle,
@@ -549,7 +566,7 @@ fn capture_building_at_communicator(
player_owner,
class,
)?;
- Ok(Some(id))
+ Ok(Some((id, MissionNotice::BuildingCaptured { neutral })))
} else {
Ok(None)
}
diff --git a/docs/tomes/06-behavior.md b/docs/tomes/06-behavior.md
index d0981e22..9ee14edb 100644
--- a/docs/tomes/06-behavior.md
+++ b/docs/tomes/06-behavior.md
@@ -3014,6 +3014,12 @@ FParkan показывает эти строки поверх сцены по п
через `0x1ac90`. Точные границы
срабатывания и открытие интерфейса МЦУ ещё исследуются.
+Обработчик `iron3d.dll` по RVA `0xa4840` выбирает реплику по прежнему
+владельцу строения. FParkan ставит в очередь `VOICE_NBUILD_CAPTURE` для
+нейтрального здания и `VOICE_EBUILD_CAPTURE` для вражеского. Имена голосов
+разрешаются через `ui/game_resources.cfg`. Реплика подтверждает именно
+смену владельца и предшествует голосу о выполнении цели миссии.
+
### Выход из миссии через телепорт
Последняя подсказка «Телепорта» просит нырнуть под арку. Центр зоны