Merge branch 'followers' into followers-expanded-id
This commit is contained in:
commit
e420f99fc3
3 changed files with 11 additions and 9 deletions
|
@ -65,7 +65,7 @@ struct FollowerMsgInfoExtended {
|
|||
#define MATCH_SPECIES(species) MATCH_U24(MSG_COND_SPECIES, species)
|
||||
#define MATCH_TYPES(type1, type2) MATCH_U8(MSG_COND_TYPE, type1, type2, 0)
|
||||
// Checks that follower has *neither* of the two types
|
||||
#define MATCH_NOT_TYPES(type1, type2) MATCH_U8(MSG_COND_TYPE, type1, type2, TYPE_NONE)
|
||||
#define MATCH_NOT_TYPES(type1, type2) MATCH_U8(MSG_COND_TYPE, type1, type2, TYPE_NONE | 1)
|
||||
#define MATCH_STATUS(status) MATCH_U24(MSG_COND_STATUS, status)
|
||||
#define MATCH_MAPSEC(mapsec) MATCH_U24(MSG_COND_MAPSEC, mapsec)
|
||||
#define MATCH_MAP_RAW(mapGroup, mapNum) MATCH_U8(MSG_COND_MAP, mapGroup, mapNum, 0)
|
||||
|
|
|
@ -2220,12 +2220,12 @@ bool32 CheckMsgCondition(const struct MsgCondition *cond, struct Pokemon *mon, u
|
|||
case MSG_COND_TYPE:
|
||||
multi = (SpeciesHasType(species, cond->data.bytes[0]) ||
|
||||
SpeciesHasType(species, cond->data.bytes[1]));
|
||||
// if bytes[2] == TYPE_NONE,
|
||||
// if bytes[2] nonzero,
|
||||
// invert; check that mon has *neither* type!
|
||||
if (cond->data.bytes[2] == 0)
|
||||
return multi;
|
||||
else
|
||||
if (cond->data.bytes[2] != 0)
|
||||
return !multi;
|
||||
else
|
||||
return multi;
|
||||
break;
|
||||
case MSG_COND_STATUS:
|
||||
return (cond->data.raw & mon->status);
|
||||
|
@ -2296,9 +2296,11 @@ bool8 ScrFunc_getfolloweraction(struct ScriptContext *ctx) // Essentially a big
|
|||
[FOLLOWER_EMOTION_UPSET] = 15,
|
||||
[FOLLOWER_EMOTION_ANGRY] = 15,
|
||||
[FOLLOWER_EMOTION_PENSIVE] = 15,
|
||||
[FOLLOWER_EMOTION_LOVE] = 0,
|
||||
[FOLLOWER_EMOTION_SURPRISE] = 10,
|
||||
[FOLLOWER_EMOTION_CURIOUS] = 10,
|
||||
[FOLLOWER_EMOTION_MUSIC] = 15,
|
||||
[FOLLOWER_EMOTION_POISONED] = 0,
|
||||
};
|
||||
u32 i, j;
|
||||
bool32 pickedCondition = FALSE;
|
||||
|
@ -2326,7 +2328,7 @@ bool8 ScrFunc_getfolloweraction(struct ScriptContext *ctx) // Essentially a big
|
|||
if (GetCurrentWeather() == WEATHER_SUNNY_CLOUDS)
|
||||
condEmotes[condCount++] = (struct SpecialEmote) {.emotion=FOLLOWER_EMOTION_HAPPY, .index=31};
|
||||
// Health & status-related
|
||||
multi = mon->hp * 100 / mon->maxHP;
|
||||
multi = SAFE_DIV(mon->hp * 100, mon->maxHP);
|
||||
if (multi < 20) {
|
||||
emotion_weight[FOLLOWER_EMOTION_SAD] = 30;
|
||||
condEmotes[condCount++] = (struct SpecialEmote) {.emotion=FOLLOWER_EMOTION_SAD, .index=4};
|
||||
|
|
|
@ -35,15 +35,15 @@ u16 Random2(void)
|
|||
// Returns a random index according to a list of weights
|
||||
u8 RandomWeightedIndex(u8 *weights, u8 length) {
|
||||
u32 i;
|
||||
u16 random_value;
|
||||
u16 randomValue;
|
||||
u16 weightSum = 0;
|
||||
for (i = 0; i < length; i++)
|
||||
weightSum += weights[i];
|
||||
random_value = Random() % weightSum;
|
||||
randomValue = weightSum > 0 ? Random() % weightSum : 0;
|
||||
weightSum = 0;
|
||||
for (i = 0; i < length; i++) {
|
||||
weightSum += weights[i];
|
||||
if (random_value <= weightSum)
|
||||
if (randomValue <= weightSum)
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue