From a085037fc6b485ff2eed2990a6615b0ef40342c4 Mon Sep 17 00:00:00 2001 From: jake Date: Tue, 29 Jun 2021 21:00:22 -0700 Subject: [PATCH 1/4] Fixed various inaccuracies regarding player interaction --- src/player/player_hit.rs | 1 - src/scene/game_scene.rs | 1 + src/text_script.rs | 9 +++++++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/player/player_hit.rs b/src/player/player_hit.rs index c8c890f..8b8d711 100644 --- a/src/player/player_hit.rs +++ b/src/player/player_hit.rs @@ -330,7 +330,6 @@ impl Player { state.control_flags.set_interactions_disabled(true); state.textscript_vm.executor_player = id; state.textscript_vm.start_script(npc.event_num); - self.cond.set_interacted(false); self.vel_x = 0; self.question = false; } diff --git a/src/scene/game_scene.rs b/src/scene/game_scene.rs index 1886663..ab525cc 100644 --- a/src/scene/game_scene.rs +++ b/src/scene/game_scene.rs @@ -1537,6 +1537,7 @@ impl GameScene { if self.player1.controller.trigger_inventory() { state.textscript_vm.set_mode(ScriptMode::Inventory); + self.player1.cond.set_interacted(false); } } diff --git a/src/text_script.rs b/src/text_script.rs index 9d058db..ef4c584 100644 --- a/src/text_script.rs +++ b/src/text_script.rs @@ -879,6 +879,8 @@ impl TextScriptVM { game_scene.player1.direction = direction; game_scene.player2.direction = direction; } + game_scene.player1.cond.set_interacted(false); + game_scene.player2.cond.set_interacted(false); game_scene.player1.vel_x = 0; game_scene.player2.vel_x = 0; @@ -891,6 +893,10 @@ impl TextScriptVM { game_scene.player1.vel_y = -0x200; game_scene.player2.vel_y = -0x200; + // Reset interaction condition, needed for places like talking to Toroko in shack + game_scene.player1.cond.set_interacted(false); + game_scene.player2.cond.set_interacted(false); + if let Some(direction) = Direction::from_int_facing(new_direction) { match direction { Direction::Left => { @@ -1221,6 +1227,9 @@ impl TextScriptVM { new_scene.player2.vel_y = 0; new_scene.player2.x = pos_x; new_scene.player2.y = pos_y; + // Reset player interaction flag upon TRA + new_scene.player1.cond.set_interacted(false); + new_scene.player2.cond.set_interacted(false); new_scene.frame.wait = game_scene.frame.wait; let skip = state.textscript_vm.flags.cutscene_skip(); From cfbb2c32869744ce3e1076620a8e5841d8b79502 Mon Sep 17 00:00:00 2001 From: jake Date: Wed, 30 Jun 2021 18:48:26 -0700 Subject: [PATCH 2/4] Make { game_scene.player1.vel_y = 0x200; game_scene.player2.vel_y = 0x200; + game_scene.player1.cond.set_interacted(true); + game_scene.player2.cond.set_interacted(true); } Direction::FacingPlayer => { // todo npc direction dependent bump @@ -1254,6 +1256,9 @@ impl TextScriptVM { let pos_x = read_cur_varint(&mut cursor)? as i32 * block_size; let pos_y = read_cur_varint(&mut cursor)? as i32 * block_size; + new_scene.player1.cond.set_interacted(false); + new_scene.player2.cond.set_interacted(false); + for player in [&mut game_scene.player1, &mut game_scene.player2].iter_mut() { player.vel_x = 0; player.vel_y = 0; From d427651de3273ac23591091882b738320010608d Mon Sep 17 00:00:00 2001 From: jake Date: Wed, 30 Jun 2021 19:15:27 -0700 Subject: [PATCH 3/4] moved down facing this from MYB to MYD, whoops. Also implemented { game_scene.player1.vel_y = 0x200; game_scene.player2.vel_y = 0x200; - game_scene.player1.cond.set_interacted(true); - game_scene.player2.cond.set_interacted(true); } Direction::FacingPlayer => { - // todo npc direction dependent bump + for npc in game_scene.npc_list.iter_alive() { + if npc.event_num == event_num { + if game_scene.player1.x >= npc.x { + game_scene.player1.direction = Left; + game_scene.player1.vel_x = 0x200; + }else{ + game_scene.player1.direction = Right; + game_scene.player1.vel_x = -0x200; + } + + if game_scene.player2.x >= npc.x { + game_scene.player2.direction = Left; + game_scene.player2.vel_x = 0x200; + }else{ + game_scene.player2.direction = Right; + game_scene.player2.vel_x = -0x200; + } + break; + } + } } } } From 639c296bcc1c0bb84cda9dd45982ffd51ea7201e Mon Sep 17 00:00:00 2001 From: jake Date: Wed, 30 Jun 2021 19:29:14 -0700 Subject: [PATCH 4/4] Make { + game_scene.player1.direction = Left; + game_scene.player2.direction = Left; game_scene.player1.vel_x = 0x200; game_scene.player2.vel_x = 0x200; } @@ -910,6 +912,8 @@ impl TextScriptVM { game_scene.player2.vel_y = -0x200; } Direction::Right => { + game_scene.player1.direction = Right; + game_scene.player2.direction = Right; game_scene.player1.vel_x = -0x200; game_scene.player2.vel_x = -0x200; } @@ -919,7 +923,7 @@ impl TextScriptVM { } Direction::FacingPlayer => { for npc in game_scene.npc_list.iter_alive() { - if npc.event_num == event_num { + if npc.event_num == new_direction as u16{ if game_scene.player1.x >= npc.x { game_scene.player1.direction = Left; game_scene.player1.vel_x = 0x200; @@ -1275,8 +1279,8 @@ impl TextScriptVM { let pos_x = read_cur_varint(&mut cursor)? as i32 * block_size; let pos_y = read_cur_varint(&mut cursor)? as i32 * block_size; - new_scene.player1.cond.set_interacted(false); - new_scene.player2.cond.set_interacted(false); + game_scene.player1.cond.set_interacted(false); + game_scene.player2.cond.set_interacted(false); for player in [&mut game_scene.player1, &mut game_scene.player2].iter_mut() { player.vel_x = 0;