changeset 732:5f00b2e0c06a

ecl_vm: remilia lasers done
author Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
date Sun, 03 Nov 2019 02:07:18 +0100
parents ca46b4312df1
children 770e5057f6bc
files src/th06/ecl_vm.rs
diffstat 1 files changed, 68 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/th06/ecl_vm.rs	Sat Nov 02 19:37:06 2019 +0100
+++ b/src/th06/ecl_vm.rs	Sun Nov 03 02:07:18 2019 +0100
@@ -1007,6 +1007,73 @@
                             self.frame.ints1[i] = knowledge[character][i];
                         }
                     }
+                    7 => { // Remilia's lazer maze
+                        // so what this does is kinda complex: 2 rounds of 3 subrounds of 8 shots, either
+                        // laser or standard bullets depending on the argument passed.
+                        // it is done in 2 steps: first we precalculate coordinates of the 8 shots for the first subround
+                        // set the shot properties depending on difficulties and current round and then
+                        // edit  the coordinates for the next round
+                        let rnd_pos = self.get_prng().borrow_mut().get_f64() * 2. * std::f64::consts::PI;
+                        let enemy = self.enemy.borrow();
+                        for i in 0..2 {
+                            let mut pos: [f64; 8*3] = [0.; 8*3];
+                            let mut offset = rnd_pos -((std::f64::consts::PI/8.)*7.);
+                            let mut next_offset = -std::f64::consts::PI/4.;
+                            if (i == 0) {
+                                offset = rnd_pos -std::f64::consts::PI;
+                                next_offset = std::f64::consts::PI/4.;
+                            }
+
+                            // we calculate angle, speed and offset for the 8 shots
+                            let mut offset_copy=offset;
+                            for y in 0..8 {
+                                pos[y * 3] = offset_copy.cos() * 32. + enemy.pos.x as f64;
+                                pos[y * 3 + 1] = offset_copy.sin() * 32. + enemy.pos.y as f64;
+                                pos[y * 3 + 2] = enemy.z as f64;
+                                offset_copy += std::f64::consts::PI/4.;
+                            }
+
+                            // 3 rounds of 8 shots
+                            for z in 0..3 {
+
+                                let mut length = 112.;
+                                // last subround
+                                if (z == 2) {length = 480.;}
+
+                                for y in 0..8 {
+                                    /*
+                                    if (arg == 0) {
+                                        let (mut si, mut ged, mut ed) = (8, 20.,ed=430.);
+                                        if (LEVEL.rank < 2) {si=2; ged=28.; ed=length;}
+                                        laser_args.angle = pos[y * 3];
+                                        laser_args.speed = pos[y * 3 + 1];
+                                        laser_args.start_offset = pos[y * 3 + 2];
+                                        laser_args.type = 1;
+                                        laser_args.sprite_index_offset = si;
+                                        laser_args.end_offset = offset;
+                                        laser_args.width = 0.;
+                                        laser_args.duration = 0;
+                                        laser_args.grazing_extra_duration = ged;
+                                        laser_args.end_duration = ed;
+                                        laser_args.UNK1 = z * 0x10 + 0x3c;
+                                        laser_args.grazing_delay = laser_args.end_duration;
+                                        fire_laser(&ETAMA_ARRAY,&laser_args);
+                                    }
+                                    else {
+                                        (enemy->bullet_attributes).pos[0] = pos[y * 3];
+                                        (enemy->bullet_attributes).pos[1] = pos[y*3+1];
+                                        (enemy->bullet_attributes).pos[2] = pos[y*3+2];
+                                        bullet_fire(&enemy->bullet_attributes,&ETAMA_ARRAY);
+                                    }
+                                    */
+                                    pos[y * 3] = offset.cos() * length + pos[y * 3];
+                                    pos[y * 3 + 1] = offset.sin() * length + pos[y * 3 + 1];
+                                    offset = offset + std::f64::consts::PI/4.;
+                                }
+                                offset = (next_offset - 2.*std::f64::consts::PI) + offset;
+                            }
+                        }
+                    }
                     8 => { // Vampire Fantasy
                         /*
                         let mut n = 0:
@@ -1033,6 +1100,7 @@
                         self._setval(-10004, n)
                         */
                     }
+                    
                     9 => {
                         let mut rnd = self.get_prng().borrow_mut().get_f64();
                         //TODO: the game does that