1
0
Fork 0
mirror of https://github.com/doukutsu-rs/doukutsu-rs synced 2025-03-23 10:29:18 +00:00

tsc: interaction lock fixes

This commit is contained in:
Alula 2020-09-11 01:41:00 +02:00
parent 4bac32f3a3
commit f4dc0def53
No known key found for this signature in database
GPG key ID: 3E00485503A1D8BA
4 changed files with 10 additions and 8 deletions

View file

@ -83,7 +83,7 @@ bitfield! {
impl Debug;
pub flag_x01, set_flag_x01: 0;
pub control_enabled, set_control_enabled: 1;
pub flag_x04, set_flag_x04: 2;
pub interactions_disabled, set_interactions_disabled: 2;
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]

View file

@ -129,7 +129,7 @@ impl Player {
}
if state.control_flags.control_enabled() {
if state.key_trigger.only_down() && state.key_state.only_down() && !self.cond.interacted() && !state.control_flags.flag_x04() {
if state.key_trigger.only_down() && state.key_state.only_down() && !self.cond.interacted() && !state.control_flags.interactions_disabled() {
self.cond.set_interacted(true);
self.question = true;
} else {
@ -534,7 +534,7 @@ impl GameEntity<()> for Player {
// todo: add additional control modes like NXEngine has such as noclip?
match self.control_mode {
ControlMode::Normal => {
if state.control_flags.flag_x04() && state.control_flags.control_enabled() {
if state.control_flags.interactions_disabled() && state.control_flags.control_enabled() {
// AirProcess(); // todo
}

View file

@ -162,19 +162,19 @@ impl Player {
flags = self.judge_hit_npc_non_solid(npc);
}
if npc.npc_flags.interactable() && !state.control_flags.flag_x04() && flags.0 != 0 && self.cond.interacted() {
if npc.npc_flags.interactable() && !state.control_flags.interactions_disabled() && flags.0 != 0 && self.cond.interacted() {
state.textscript_vm.start_script(npc.event_num);
self.cond.set_interacted(false);
self.vel_x = 0;
self.question = false;
}
if npc.npc_flags.event_when_touched() && !state.control_flags.flag_x04() && flags.0 != 0 {
if npc.npc_flags.event_when_touched() && !state.control_flags.interactions_disabled() && flags.0 != 0 {
state.textscript_vm.start_script(npc.event_num);
}
if state.control_flags.control_enabled() && !npc.npc_flags.interactable() {
if flags.0 != 0 && npc.damage != 0 && !state.control_flags.flag_x04() {
if flags.0 != 0 && npc.damage != 0 && !state.control_flags.interactions_disabled() {
self.damage(npc.damage as isize, state);
}
}

View file

@ -383,6 +383,7 @@ impl TextScriptVM {
pub fn start_script(&mut self, event_num: u16) {
self.reset();
self.state = TextScriptExecutionState::Running(event_num, 0);
log::info!("Started script: #{:04}", event_num);
}
@ -392,11 +393,11 @@ impl TextScriptVM {
match state.textscript_vm.state {
TextScriptExecutionState::Ended => {
state.control_flags.set_flag_x04(false);
break;
}
TextScriptExecutionState::Running(event, ip) => {
state.control_flags.set_flag_x04(true);
state.control_flags.set_flag_x01(true);
state.control_flags.set_interactions_disabled(true);
state.textscript_vm.state = TextScriptVM::execute(event, ip, state, game_scene, ctx)?;
if state.textscript_vm.state == TextScriptExecutionState::Ended {
@ -540,6 +541,7 @@ impl TextScriptVM {
OpCode::_END | OpCode::END => {
state.control_flags.set_flag_x01(true);
state.control_flags.set_control_enabled(true);
state.control_flags.set_interactions_disabled(false);
state.textscript_vm.flags.set_render(false);
state.textscript_vm.flags.set_background_visible(false);