document StatDrop (#88)

This commit is contained in:
alex 2020-10-22 06:01:11 +01:00 committed by GitHub
parent 6b1ca37bc6
commit 191be39a03
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 12 deletions

View File

@ -2,7 +2,7 @@
body, table, div, p, dl { font: inherit }
body, table, div, p, dl, p.reference, p.definition, .memberdecls .header {
body, table, div, p, dl, p.reference, p.definition, .memberdecls .header, .mdescRight {
color: #121212;
font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji;
}
@ -48,7 +48,7 @@ body {
flex-direction: row;
width: 100%;
max-width: 1000px;
max-width: 1100px;
min-height: 100%;
margin: 0 auto;
}
@ -92,9 +92,7 @@ table {
#details + .groupheader,
.definition,
.memtitle,
.contents > p:first-child > a:first-child /* "Go to the source code of this file." */
{ display: none }
.memtitle { display: none }
table.memname * {
display: inline;
@ -125,19 +123,22 @@ code {
display: block !important;
border-left: 1px solid #eee;
padding-left: 1em;
margin: 1em 0;
margin: 1.5em 0;
width: 100%;
box-sizing: border-box;
}
.memproto {
padding: 8px;
margin-bottom: .5em;
box-shadow: none;
text-shadow: none;
display: inline-block;
}
.memdoc p:first-child {
margin-top: 0;
}
.memname {
margin-left: 0;
}

View File

@ -61,12 +61,25 @@ typedef struct ItemDrop {
/* 0x04 */ s16 unk_08;
} ItemDrop; // size = 0x06
/// @brief Describes heart/flower drop chances after defeating an Npc in the overworld.
///
/// The algorithm for calculating the number of hearts/flowers from a StatDrop is:
/// - If current HP/FP > cutoff, drop 0.
/// - Roll generalChance. If it fails, drop 0.
/// - Roll chancePerAttempt attempts times. For each success, drop a heart/flower.
///
/// StaticNpc holds a table of StatDrops for each stat (hearts, flowers). All are checked together
/// and the number of hearts/flowers to drop is the total number of successful attempts for each stat.
///
/// Each heart/flower is worth 1 HP and 1 FP respectively, if picked up.
///
/// cutoff, generalChance, and chancePerAttempt are short fixed-point percentage values.
/// That is, `F16(0)` is a 0% chance and `F16(100)` is a 100% chance.
typedef struct StatDrop {
// NOTE: these %s are F16
/* 0x00 */ s16 hpCutoff; // % of max HP/FP
/* 0x02 */ s16 generalChance; // %
/* 0x04 */ s16 attempts;
/* 0x06 */ s16 chancePerAttempt; // %
/* 0x00 */ s16 cutoff; ///< % of max HP/FP. If current HP/FP > cutoff, no hearts/flowers can be dropped.
/* 0x02 */ s16 generalChance; ///< % chance for any hearts/flowers to be dropped at all from this StatDrop.
/* 0x04 */ s16 attempts; ///< Maximum number of hearts/flowers that can be dropped from this StatDrop.
/* 0x06 */ s16 chancePerAttempt; ///< % chance for a single heart/flower to be dropped from each attempt.
} StatDrop; // size = 0x08
#define NO_DROPS { F16(100), F16(0), 0, F16(0) }