[Maintenance] [th05] Abstract away randring for shot angles

Part of P0062, funded by Touhou Patch Center.
This commit is contained in:
nmlgc 2019-12-21 14:18:08 +01:00
parent 765eae82e8
commit 36f1727f82
2 changed files with 7 additions and 3 deletions

View File

@ -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;
}

View File

@ -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;
}