From d5e714548432e6dc214ddd300707ff7609b5ad75 Mon Sep 17 00:00:00 2001 From: David Goldstein Date: Mon, 9 Nov 2026 08:38:32 -0500 Subject: [PATCH 1/2] Row 3024: the Master of Disguise waits in his forest as the searcher's own Chief Knight Ereve's five hideouts (108010600 to 108010640) place nobody in the data, so the Cygnus third-job quests 20301 to 20305 could not be finished. A searcher entering one now finds the Chief Knight (1104100 to 1104104); to a Knight of his own line he drops the disguise and the Master of Disguise (9001009) comes out where he stood, as Cosmic's 1104100.js does. The Dawn Warrior's proof 4032101 joins the mob's drops at 70%. --- game-data/placeholder_text.toml | 2 + game-data/reward_overrides.toml | 1 + game-data/server_content.toml | 2 + game-data/src/server_content.rs | 6 +++ net/src/handler.rs | 3 ++ net/src/npc_scripts.rs | 48 +++++++++++++++++ net/src/scripts.rs | 71 +++++++++++++++++++++++++- runtime/src/actor/client/npc_script.rs | 4 ++ runtime/src/actor/field.rs | 16 ++++++ 9 files changed, 151 insertions(+), 2 deletions(-) diff --git a/game-data/placeholder_text.toml b/game-data/placeholder_text.toml index c2941e278..9874d9901 100644 --- a/game-data/placeholder_text.toml +++ b/game-data/placeholder_text.toml @@ -553,6 +553,8 @@ "medal.explorer.earned_info" = "[placeholder] The {name} title is yours; Dalair keeps its medal for you." "portal.disguise.occupied" = "[placeholder] Someone else is searching that forest." "portal.disguise.already_found" = "[placeholder] You found him already; tell the Chief Knight." +"disguise.not_here" = "[placeholder] #h #, you're searching too? The intruder isn't here; I've searched this forest already." +"disguise.found_out" = "[placeholder] You found me out! Then we fight, as the Black Wings do!" "portal.mysterious_force" = "[placeholder] Something keeps you out." "portal.minar_elli.spent" = "[placeholder] A Magic Seed is used up and the portal carries you away." "portal.minar_elli.no_seed" = "[placeholder] This portal only works with a Magic Seed." diff --git a/game-data/reward_overrides.toml b/game-data/reward_overrides.toml index 46326b189..fccf42e63 100644 --- a/game-data/reward_overrides.toml +++ b/game-data/reward_overrides.toml @@ -2204,6 +2204,7 @@ add = [{ item = 4032518, prob = 0.4, quest = 3743 }] # The New and Improved, Ob [mobs.9001009] # Master of Disguise. add = [ + { item = 4032101, prob = 0.7, quest = 20301 }, # The Master of Disguise { item = 4032102, prob = 0.7, quest = 20302 }, # The Master of Disguise { item = 4032103, prob = 0.7, quest = 20303 }, # The Master of Disguise { item = 4032104, prob = 0.7, quest = 20304 }, # The Master of Disguise diff --git a/game-data/server_content.toml b/game-data/server_content.toml index 8c0ff53e0..cf3a4d0f4 100644 --- a/game-data/server_content.toml +++ b/game-data/server_content.toml @@ -698,6 +698,8 @@ unsourced = [ "medal.explorer.earned_info", "portal.disguise.occupied", "portal.disguise.already_found", + "disguise.not_here", + "disguise.found_out", "portal.mysterious_force", "portal.earth.no_card", "portal.ariant_palace.intruder", diff --git a/game-data/src/server_content.rs b/game-data/src/server_content.rs index 5f2531722..4a038c889 100644 --- a/game-data/src/server_content.rs +++ b/game-data/src/server_content.rs @@ -805,6 +805,10 @@ pub mod keys { /// else is searching, or he has already been found. pub const DISGUISE_FOREST_OCCUPIED: &str = "portal.disguise.occupied"; pub const DISGUISE_ALREADY_FOUND: &str = "portal.disguise.already_found"; + /// A forest's Chief Knight (1104100 to 1104104): to a Knight of another + /// line, nobody is hiding here; to the Knight's own, found out. + pub const DISGUISE_NOT_HERE: &str = "disguise.not_here"; + pub const DISGUISE_FOUND_OUT: &str = "disguise.found_out"; /// Ways a quest has yet to open (`tristanEnter`, `s4resur_enter`, /// `s4rush`). pub const MYSTERIOUS_FORCE: &str = "portal.mysterious_force"; @@ -4650,6 +4654,8 @@ mod tests { keys::MEDAL_EARNED_INFO, keys::DISGUISE_FOREST_OCCUPIED, keys::DISGUISE_ALREADY_FOUND, + keys::DISGUISE_NOT_HERE, + keys::DISGUISE_FOUND_OUT, keys::MYSTERIOUS_FORCE, keys::MAGIC_SEED_SPENT, keys::MAGIC_SEED_NEEDED, diff --git a/net/src/handler.rs b/net/src/handler.rs index 9de6db24a..91bab8105 100644 --- a/net/src/handler.rs +++ b/net/src/handler.rs @@ -1046,6 +1046,9 @@ pub enum FieldRequest { /// A script brings out NPC `npc_id` on the ground below `at`, unless /// it is here already. BringOutNpc { npc_id: i32, at: (i16, i16) }, + /// A script has NPC `npc_id` here go and a `mob_id` come out where it + /// stood, unless one is out already (`scripts::Effect::Unmask`). + Unmask { npc_id: i32, mob_id: i32 }, /// A script brings out a `mob_id` on the ground below each of `at`. BringOutMobs { mob_id: i32, at: Vec<(i16, i16)> }, /// A script puts the reactors named `name` here in `state` diff --git a/net/src/npc_scripts.rs b/net/src/npc_scripts.rs index 0d6a9e392..46072c024 100644 --- a/net/src/npc_scripts.rs +++ b/net/src/npc_scripts.rs @@ -2569,6 +2569,9 @@ impl NpcScript { if npc_id == OPENING_NEINHEART { return Some(opening_neinheart()); } + if (scripts::DISGUISED_KNIGHTS..scripts::DISGUISED_KNIGHTS + 5).contains(&npc_id) { + return Some(disguised_knight(npc_id, player)); + } if let Some(&(_, mob_id, ask, notice)) = BOSS_SWITCHES.iter().find(|s| s.0 == npc_id) { return Some(boss_switch(npc_id, mob_id, ask, notice)); } @@ -6567,6 +6570,23 @@ fn violetta_found() -> NpcScript { script } +/// The Chief Knight a searcher finds in one of the Master of Disguise's +/// forests (1104100 to 1104104, Cosmic `1104100.js` on): to a Knight of +/// another line, they have searched there already; to their own line's +/// Knight, he is found out, and once that is read he fights. +fn disguised_knight(npc_id: i32, player: &Player) -> NpcScript { + let line = 11 + (npc_id - scripts::DISGUISED_KNIGHTS); + if i32::from(player.stats.job) / 100 != line { + return NpcScript::new(npc_id, vec![Page::Say(text(keys::DISGUISE_NOT_HERE))]); + } + let mut script = NpcScript::new(npc_id, vec![Page::Say(text(keys::DISGUISE_FOUND_OUT))]); + script.on_end = vec![Effect::Unmask { + npc_id, + mob_id: scripts::MASTER_OF_DISGUISE, + }]; + script +} + /// `q2333s`, The Story of Betrayal: Violetta asks for help, names the /// Prime Minister, and he comes out (Cosmic `2333.js` and /// `MK_PrimeMinister`). @@ -20002,6 +20022,34 @@ mod tests { (npc, end.effects) } + #[test] + fn a_forests_chief_knight_is_the_master_of_disguise_only_to_his_own_line() { + let knight = |job: i16| { + let mut player = player(50); + player.stats.job = job; + player + }; + // Hawkeye (1104104) in the Drill Hall's entrance unmasks for a + // Thunder Breaker, through the dispatcher as the client asks. + let hawkeye = scripts::DISGUISED_KNIGHTS + 4; + let found = NpcScript::for_npc(hawkeye, &knight(1510)).unwrap(); + assert_eq!( + read_through(found), + ( + hawkeye, + vec![Effect::Unmask { + npc_id: hawkeye, + mob_id: scripts::MASTER_OF_DISGUISE + }] + ) + ); + // Mihile (1104100) does for a Dawn Warrior but not a Blaze Wizard. + let mihile = scripts::DISGUISED_KNIGHTS; + assert!(!read_through(disguised_knight(mihile, &knight(1110))).1.is_empty()); + assert_eq!(read_through(disguised_knight(mihile, &knight(1210))), (mihile, vec![])); + assert_eq!(read_through(disguised_knight(mihile, &knight(1111))).1.len(), 1); + } + #[test] fn the_trash_can_holds_jms_list_from_5_to_8_pm() { let list = Effect::GiveItem { diff --git a/net/src/scripts.rs b/net/src/scripts.rs index c1aa92e77..b1ba5465e 100644 --- a/net/src/scripts.rs +++ b/net/src/scripts.rs @@ -568,6 +568,14 @@ const DISGUISE_WAYS: [(i32, &str); 5] = [ ]; const DISGUISE_FORESTS: i32 = 108010600; const DISGUISE_PROOF: i32 = 4032101; +/// The Chief Knight each forest's searcher finds there (Mihile, Oz, Irena, +/// Eckhart and Hawkeye, 1104100 on), and where. The forests' data places +/// nobody, so they come out for a searcher on the way in; the Knight's own +/// Chief is the Master of Disguise (`npc_scripts`, Cosmic `1104100.js`). +pub const DISGUISED_KNIGHTS: i32 = 1104100; +const DISGUISED_KNIGHTS_AT: [(i16, i16); 5] = + [(2250, 60), (3750, 60), (-400, 60), (-1700, 60), (650, 60)]; +pub const MASTER_OF_DISGUISE: i32 = 9001009; /// Ariant's Treasure Room of Queen (`skyrom`), which one player at a time /// searches for the jewel quest 3935 is after. const QUEENS_TREASURE_ROOM: i32 = 926000010; @@ -1164,6 +1172,14 @@ pub enum Effect { npc_id: i32, at: (i16, i16), }, + /// NPC `npc_id` on the player's map goes, and `mob_id` comes out on + /// the ground where it stood unless one is out already, as the Master + /// of Disguise drops his disguise (Cosmic's `spawnMonsterOnGroundBelow` + /// at the NPC, then `destroyNPC`). + Unmask { + npc_id: i32, + mob_id: i32, + }, /// Bring out `each` of `mob_id` on the ground below each point of `at` /// in the player's map, as the Magic Library's black shadow sets Blue /// Mushrooms on the player. They never respawn. @@ -1363,6 +1379,14 @@ const STRANGE_INFORMATION_RECORD: i16 = 21762; /// beaten yet (Cosmic `enterInfo`). His fall sets 21733's record /// (`crate::quests::kill_records`). pub fn unscripted_map_enter(player: &Player) -> Vec { + if let Some(at) = disguise_forest(player.stats.map_id) { + let npc_id = DISGUISED_KNIGHTS + (player.stats.map_id - DISGUISE_FORESTS) / 10; + return if disguise_searching(player) { + vec![Effect::BringOutNpc { npc_id, at }] + } else { + Vec::new() + }; + } match player.stats.map_id { PUPPETEERS_HIDEOUT => hunted_puppeteer(player) .map(|mob_id| Effect::BringOutMob { @@ -3420,11 +3444,24 @@ fn elevator(map_id: i32, t: i64) -> ScriptOutcome { } } +/// Whether `player` is on one of the Master of Disguise quests. +fn disguise_searching(player: &Player) -> bool { + (20301..=20305).any(|id| player.quests.state(id) == QuestState::Started) +} + +/// Where the Chief Knight stands in `map`, if it is one of the Master of +/// Disguise's forests. +fn disguise_forest(map: i32) -> Option<(i16, i16)> { + let n = map.checked_sub(DISGUISE_FORESTS)?; + (n % 10 == 0) + .then(|| DISGUISED_KNIGHTS_AT.get(usize::try_from(n / 10).ok()?).copied()) + .flatten() +} + /// Ereve's Training Forest way on for the Knight `job` (0 to 4); see /// `DISGUISE_WAYS`. fn disguise(player: &Player, job: usize) -> ScriptOutcome { - let searching = (20301..=20305).any(|id| player.quests.state(id) == QuestState::Started); - if !searching { + if !disguise_searching(player) { let (map, portal) = DISGUISE_WAYS[job]; return through(Effect::WarpToPortal(map, named(map, portal))); } @@ -7550,6 +7587,36 @@ mod tests { assert_eq!(super::portal("enterDisguise6", &fresh), None); } + #[test] + fn each_forest_shows_a_searcher_its_chief_knight_standing_on_its_ground() { + let data = crate::get_game_data().unwrap(); + let quest = [(20301, QuestState::Started)]; + for (n, at) in DISGUISED_KNIGHTS_AT.into_iter().enumerate() { + let map = DISGUISE_FORESTS + 10 * n as i32; + let mut searcher = player_with(&quest); + searcher.stats.map_id = map; + assert_eq!( + unscripted_map_enter(&searcher), + [Effect::BringOutNpc { + npc_id: DISGUISED_KNIGHTS + n as i32, + at + }] + ); + // Nobody waits for one who isn't searching. + let mut passer = player_with(&[]); + passer.stats.map_id = map; + assert!(unscripted_map_enter(&passer).is_empty()); + // The forest's floor is under the spot. + let field = data.field(map).unwrap(); + assert_eq!(field.footholds.ground_below(at.0, at.1), Some(88), "{map}"); + } + // The forest after them is no forest of his. + let mut beyond = player_with(&quest); + beyond.stats.map_id = DISGUISE_FORESTS + 50; + assert!(disguise_forest(beyond.stats.map_id).is_none()); + assert!(disguise_forest(DISGUISE_FORESTS + 5).is_none()); + } + #[test] fn a_magic_seed_carries_the_player_between_ellinia_and_leafre() { assert!(pink(&portal("minar_elli", &player_with(&[])).unwrap())); diff --git a/runtime/src/actor/client/npc_script.rs b/runtime/src/actor/client/npc_script.rs index 24d374156..038546b78 100644 --- a/runtime/src/actor/client/npc_script.rs +++ b/runtime/src/actor/client/npc_script.rs @@ -276,6 +276,10 @@ impl ClientActor { npc_id: *npc_id, at: *at, }), + Effect::Unmask { npc_id, mob_id } => to_field.push(FieldRequest::Unmask { + npc_id: *npc_id, + mob_id: *mob_id, + }), Effect::BringOutMobs { mob_id, at, each } => { to_field.push(FieldRequest::BringOutMobs { mob_id: *mob_id, diff --git a/runtime/src/actor/field.rs b/runtime/src/actor/field.rs index f9463e2a6..c4c7165be 100644 --- a/runtime/src/actor/field.rs +++ b/runtime/src/actor/field.rs @@ -1268,6 +1268,7 @@ impl FieldActor { self.appear(npc_id, at); } } + FieldRequest::Unmask { npc_id, mob_id } => self.unmask(from, npc_id, mob_id), FieldRequest::OpenReactor { name } => self.open_reactor(name), FieldRequest::NpcSpecialAction { npc_id, action } => { self.npc_special_action(npc_id, action) @@ -3717,6 +3718,21 @@ impl FieldActor { } } + /// NPC `npc_id` goes from here, and a `mob_id` comes out where it stood + /// unless one is out already (`scripts::Effect::Unmask`). + fn unmask(&mut self, from: ClientId, npc_id: i32, mob_id: i32) { + let Some(index) = self.map_npcs.iter().position(|npc| npc.npc_id == npc_id) else { + return; + }; + let npc = self.map_npcs.remove(index); + for packet in [build_uncontrol_npc(npc.object_id), build_remove_npc(npc.object_id)] { + if let Ok(packet) = packet { + self.broadcast(None, packet); + } + } + self.handle_bring_out_mob(from, mob_id, (npc.x, npc.y)); + } + /// Bring out NPC `npc_id` on the ground below (x, y), there until the /// field closes, and hand it to the NPCs' controller. fn appear(&mut self, npc_id: i32, (x, y): (i16, i16)) { From 51dff8a5e58d4020402fe69c4447bb686f541b31 Mon Sep 17 00:00:00 2001 From: David Goldstein Date: Mon, 9 Nov 2026 08:39:17 -0500 Subject: [PATCH 2/2] rustfmt --- net/src/npc_scripts.rs | 16 +++++++++++++--- net/src/scripts.rs | 6 +++++- runtime/src/actor/field.rs | 5 ++++- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/net/src/npc_scripts.rs b/net/src/npc_scripts.rs index 46072c024..de355a11e 100644 --- a/net/src/npc_scripts.rs +++ b/net/src/npc_scripts.rs @@ -20045,9 +20045,19 @@ mod tests { ); // Mihile (1104100) does for a Dawn Warrior but not a Blaze Wizard. let mihile = scripts::DISGUISED_KNIGHTS; - assert!(!read_through(disguised_knight(mihile, &knight(1110))).1.is_empty()); - assert_eq!(read_through(disguised_knight(mihile, &knight(1210))), (mihile, vec![])); - assert_eq!(read_through(disguised_knight(mihile, &knight(1111))).1.len(), 1); + assert!(!read_through(disguised_knight(mihile, &knight(1110))) + .1 + .is_empty()); + assert_eq!( + read_through(disguised_knight(mihile, &knight(1210))), + (mihile, vec![]) + ); + assert_eq!( + read_through(disguised_knight(mihile, &knight(1111))) + .1 + .len(), + 1 + ); } #[test] diff --git a/net/src/scripts.rs b/net/src/scripts.rs index b1ba5465e..039b467e3 100644 --- a/net/src/scripts.rs +++ b/net/src/scripts.rs @@ -3454,7 +3454,11 @@ fn disguise_searching(player: &Player) -> bool { fn disguise_forest(map: i32) -> Option<(i16, i16)> { let n = map.checked_sub(DISGUISE_FORESTS)?; (n % 10 == 0) - .then(|| DISGUISED_KNIGHTS_AT.get(usize::try_from(n / 10).ok()?).copied()) + .then(|| { + DISGUISED_KNIGHTS_AT + .get(usize::try_from(n / 10).ok()?) + .copied() + }) .flatten() } diff --git a/runtime/src/actor/field.rs b/runtime/src/actor/field.rs index c4c7165be..965004460 100644 --- a/runtime/src/actor/field.rs +++ b/runtime/src/actor/field.rs @@ -3725,7 +3725,10 @@ impl FieldActor { return; }; let npc = self.map_npcs.remove(index); - for packet in [build_uncontrol_npc(npc.object_id), build_remove_npc(npc.object_id)] { + for packet in [ + build_uncontrol_npc(npc.object_id), + build_remove_npc(npc.object_id), + ] { if let Ok(packet) = packet { self.broadcast(None, packet); }