# HG changeset patch # User Emmanuel Gil Peyrot # Date 1577570192 -3600 # Node ID 0977d479e37d77ecd1c44f1eb9dce3938394cd4d # Parent ff9651cfe1b063e82d875742f972f42bfd898af9 ecl_vm: Uncomment instruction 121 function 8. diff --git a/src/th06/ecl_vm.rs b/src/th06/ecl_vm.rs --- a/src/th06/ecl_vm.rs +++ b/src/th06/ecl_vm.rs @@ -1,7 +1,7 @@ //! ECL runner. use crate::th06::ecl::{Ecl, SubInstruction}; -use crate::th06::enemy::{Enemy, Offset}; +use crate::th06::enemy::{Enemy, Offset, BulletAttributes}; use crate::util::prng::Prng; use std::cell::RefCell; use std::rc::Rc; @@ -1107,30 +1107,43 @@ impl EclRunner { } } 8 => { // Vampire Fantasy - /* - let mut n = 0: - for bullet in game.bullets{ - if bullet._bullet_type.state != 0 && bullet._bullet_type.state != 5 && (30. <= (bullet.sprites[0].additional_infos)->height) { - local_5c.pos[0] = local_bullet_vec->pos[0]; - local_5c.pos[1] = local_bullet_vec->pos[1]; - local_5c.pos[2] = local_bullet_vec->pos[2]; - local_5c.anim = 3; - local_5c.sprite_index_offset = 1; - fVar3 = prng_double(&PRNG_STATE); - local_5c.launch_angle = (self.get_prng().borrow_mut().get_f64() * (2. * std::f64::consts::PI) - std::f64::consts::PI) as f32; - local_5c.speed = 0.00000000; - local_5c.bullets_per_shot = 1; - local_5c.nb_of_shots = 1; - local_5c.flags = 8; - local_5c.bullet_type = 1; - bullet_fire(&local_5c,&ETAMA_ARRAY); + let n = { + let enemy = self.enemy.borrow(); + let game = enemy.game.upgrade().unwrap(); + let mut game = game.borrow_mut(); + let mut n = 0; + for bullet in game.bullets.iter() { + let mut bullet = bullet.borrow(); + // TODO: uncomment that one. + if bullet.state != 0 && bullet.state != 5 /* && (30. <= (bullet.sprites[0].additional_infos).height) */ { + let prng = enemy.prng.upgrade().unwrap(); + let random = prng.borrow_mut().get_f64(); + let launch_angle = (random * (2. * std::f64::consts::PI) - std::f64::consts::PI) as f32; + let mut attribs = BulletAttributes { + // TODO: check if the z value of this pos is really used. + pos: bullet.pos, + anim: 3, + sprite_index_offset: 1, + launch_angle, + speed: 0., + angle: 0., + speed2: 0., + bullets_per_shot: 1, + number_of_shots: 1, + flags: 8, + bullet_type: 1, + extended_attributes: Default::default(), + sound: None, + }; + attribs.fire(); + n += 1 } - n += 1 - } + } + n + }; //TODO: this variable might not always be correct! it uses the argument in //th06: *(int *)(param_1 + 0x9b0) = local_60; - self._setval(-10004, n) - */ + self.set_i32(-10004, n); } 9 => { diff --git a/src/th06/enemy.rs b/src/th06/enemy.rs --- a/src/th06/enemy.rs +++ b/src/th06/enemy.rs @@ -93,6 +93,9 @@ pub struct Bullet { /// Current attributes of the bullet. pub attributes: [f32; 2], + + /// TODO: what are the values? + pub state: i8, } /// God struct of our game.