From 36f1727f824fa949988d60458ba6552e6537f463 Mon Sep 17 00:00:00 2001 From: nmlgc Date: Sat, 21 Dec 2019 14:18:08 +0100 Subject: [PATCH] [Maintenance] [th05] Abstract away randring for shot angles Part of P0062, funded by Touhou Patch Center. --- th05/p_yuuka.cpp | 6 +++--- th05/player/shot.hpp | 4 ++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/th05/p_yuuka.cpp b/th05/p_yuuka.cpp index e0219ccb..63ed15cf 100644 --- a/th05/p_yuuka.cpp +++ b/th05/p_yuuka.cpp @@ -33,7 +33,7 @@ void pascal near shot_yuuka_l2(void) SHOT_FUNC_INIT(1, SC_3X, SC_1X, i += 2); while(( shot = shots_add() ) != NULL) { if(sai.i == 1) { - sai.angle = randring_angle(15, 184); + sai.set_random_angle(15, 184); shot->damage = 9; } else { if(sai.i == 3) { shot->from_option_l(); sai.angle = 184; } @@ -92,10 +92,10 @@ void pascal near shot_yuuka_l4(void) } else { if(sai.i == 5) { shot->from_option_l(); - sai.angle = randring_angle(7, 180); + sai.set_random_angle(7, 180); } else { shot->from_option_r(); - sai.angle = randring_angle(7, 196); + sai.set_random_angle(7, 196); if(option_only == 0) { sai.i = 1; } diff --git a/th05/player/shot.hpp b/th05/player/shot.hpp index 984abbed..12b47a94 100644 --- a/th05/player/shot.hpp +++ b/th05/player/shot.hpp @@ -33,6 +33,10 @@ struct ShotAddIterator { i += n; } + void set_random_angle(char random_range = 15, char offset = 184) { + angle = randring_angle(random_range, offset); + } + unsigned char next(void) { return i -= 1; }