mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2024-11-16 19:47:35 +01:00
Clamp RandomPercentage to 0...100
This commit is contained in:
parent
7b306b6147
commit
35952cf7ad
@ -80,8 +80,21 @@ enum RandomTag
|
|||||||
|
|
||||||
#define RandomPercentage(tag, t) \
|
#define RandomPercentage(tag, t) \
|
||||||
({ \
|
({ \
|
||||||
|
u32 r; \
|
||||||
|
if (t <= 0) \
|
||||||
|
{ \
|
||||||
|
r = FALSE; \
|
||||||
|
} \
|
||||||
|
else if (t >= 100) \
|
||||||
|
{ \
|
||||||
|
r = TRUE; \
|
||||||
|
} \
|
||||||
|
else \
|
||||||
|
{ \
|
||||||
const u8 weights[] = { 100 - t, t }; \
|
const u8 weights[] = { 100 - t, t }; \
|
||||||
RandomWeightedArray(tag, 100, ARRAY_COUNT(weights), weights); \
|
r = RandomWeightedArray(tag, 100, ARRAY_COUNT(weights), weights); \
|
||||||
|
} \
|
||||||
|
r; \
|
||||||
})
|
})
|
||||||
|
|
||||||
#define RandomElement(tag, array) \
|
#define RandomElement(tag, array) \
|
||||||
|
Loading…
Reference in New Issue
Block a user