1
0
Fork 0
mirror of https://github.com/doukutsu-rs/doukutsu-rs synced 2025-01-10 13:07:17 +00:00
This commit is contained in:
Alula 2020-11-01 20:08:52 +01:00
parent 8d0ad30e09
commit 8050beed56
No known key found for this signature in database
GPG key ID: 3E00485503A1D8BA
2 changed files with 19 additions and 2 deletions

View file

@ -454,7 +454,15 @@ impl Stage {
Ok(npc_data)
}
/// Returns true if smoke should be emitted
pub fn tile_at(&self, x: usize, y: usize) -> u8 {
if let Some(&tile) = self.map.tiles.get(y * self.map.width + x) {
tile
} else {
0
}
}
/// Changes map tile. Returns true if smoke should be emitted
pub fn change_tile(&mut self, x: usize, y: usize, tile_type: u8) -> bool {
if let Some(ptr) = self.map.tiles.get_mut(y * self.map.width + x) {
if *ptr != tile_type {

View file

@ -891,6 +891,15 @@ impl TextScriptVM {
exec_state = TextScriptExecutionState::Running(event, cursor.position() as u32);
}
OpCode::SMP => {
let pos_x = read_cur_varint(&mut cursor)? as usize;
let pos_y = read_cur_varint(&mut cursor)? as usize;
let tile_type = game_scene.stage.tile_at(pos_x, pos_y);
game_scene.stage.change_tile(pos_x, pos_y, tile_type.wrapping_sub(1));
exec_state = TextScriptExecutionState::Running(event, cursor.position() as u32);
}
OpCode::CMP => {
let pos_x = read_cur_varint(&mut cursor)? as usize;
let pos_y = read_cur_varint(&mut cursor)? as usize;
@ -1387,7 +1396,7 @@ impl TextScriptVM {
exec_state = TextScriptExecutionState::Running(event, cursor.position() as u32);
}
// Two operand codes
OpCode::SKJ | OpCode::SMP => {
OpCode::SKJ => {
let par_a = read_cur_varint(&mut cursor)?;
let par_b = read_cur_varint(&mut cursor)?;