Merge branch 'lighting' into lighting-expanded-id

This commit is contained in:
Ariel A 2024-06-01 15:22:21 -04:00
commit d6762d4dbc
7 changed files with 39 additions and 13 deletions

View File

@ -141,10 +141,27 @@
"trainer_sight_or_berry_tree_id": "3",
"script": "Route102_EventScript_Allen",
"flag": "0"
},
{
"graphics_id": "OBJ_EVENT_GFX_LIGHT_SPRITE",
"x": -3,
"y": 2,
"elevation": 3,
"movement_type": "MOVEMENT_TYPE_NONE",
"movement_range_x": 0,
"movement_range_y": 0,
"trainer_type": "TRAINER_TYPE_NONE",
"trainer_sight_or_berry_tree_id": "2",
"script": "NULL",
"flag": "0"
}
],
"warp_events": [],
"coord_events": [],
"warp_events": [
],
"coord_events": [
],
"bg_events": [
{
"type": "sign",

View File

@ -26,6 +26,7 @@ UnionRoom_OnResume:
end
UnionRoom_OnTransition:
setflag FLAG_TEMP_HIDE_FOLLOWER
end
UnionRoom_EventScript_Player1::
@ -106,4 +107,3 @@ UnionRoom_EventScript_Unused::
waitstate
releaseall
end

View File

@ -324,6 +324,9 @@
#define OBJ_KIND_CLONE 255 // Exclusive to FRLG
// Special object event local ids
// Used for link player OWs in CreateLinkPlayerSprite
#define OBJ_EVENT_ID_DYNAMIC_BASE 0xF0
#define OBJ_EVENT_ID_PLAYER 0xFF
#define OBJ_EVENT_ID_CAMERA 0x7F
#define OBJ_EVENT_ID_FOLLOWER 0xFE

View File

@ -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)

View File

@ -1354,7 +1354,7 @@ u8 GetFirstInactiveObjectEventId(void)
u8 GetObjectEventIdByLocalIdAndMap(u8 localId, u8 mapNum, u8 mapGroupId)
{
if (localId < OBJ_EVENT_ID_FOLLOWER)
if (localId < OBJ_EVENT_ID_DYNAMIC_BASE)
return GetObjectEventIdByLocalIdAndMapInternal(localId, mapNum, mapGroupId);
return GetObjectEventIdByLocalId(localId);
@ -2231,12 +2231,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);
@ -2306,9 +2306,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;
@ -2336,7 +2338,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};

View File

@ -12,6 +12,7 @@
#include "field_camera.h"
#include "field_control_avatar.h"
#include "field_effect.h"
#include "field_effect_helpers.h"
#include "field_message_box.h"
#include "field_player_avatar.h"
#include "field_screen_effect.h"
@ -61,6 +62,7 @@
#include "wild_encounter.h"
#include "frontier_util.h"
#include "constants/abilities.h"
#include "constants/event_objects.h"
#include "constants/layouts.h"
#include "constants/map_types.h"
#include "constants/region_map_sections.h"
@ -3345,6 +3347,8 @@ static void CreateLinkPlayerSprite(u8 linkPlayerId, u8 gameVersion)
sprite->coordOffsetEnabled = TRUE;
sprite->data[0] = linkPlayerId;
objEvent->triggerGroundEffectsOnMove = 0;
objEvent->localId = OBJ_EVENT_ID_DYNAMIC_BASE + linkPlayerId;
SetUpShadow(objEvent, sprite);
}
}

View File

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