Merge pull request #487 from GriffinRichards/trainer-type-constants

Add missing trainer type constant usage
This commit is contained in:
GriffinR
2022-02-11 19:52:26 -05:00
committed by GitHub
11 changed files with 31 additions and 36 deletions
+2 -2
View File
@@ -23,7 +23,7 @@
"movement_type": "MOVEMENT_TYPE_FACE_DOWN", "movement_type": "MOVEMENT_TYPE_FACE_DOWN",
"movement_range_x": 0, "movement_range_x": 0,
"movement_range_y": 0, "movement_range_y": 0,
"trainer_type": "66", "trainer_type": "FLAG_HIDE_SEAFOAM_B1F_BOULDER_1",
"trainer_sight_or_berry_tree_id": "0", "trainer_sight_or_berry_tree_id": "0",
"script": "EventScript_StrengthBoulder", "script": "EventScript_StrengthBoulder",
"flag": "FLAG_HIDE_SEAFOAM_1F_BOULDER_1" "flag": "FLAG_HIDE_SEAFOAM_1F_BOULDER_1"
@@ -36,7 +36,7 @@
"movement_type": "MOVEMENT_TYPE_FACE_DOWN", "movement_type": "MOVEMENT_TYPE_FACE_DOWN",
"movement_range_x": 0, "movement_range_x": 0,
"movement_range_y": 0, "movement_range_y": 0,
"trainer_type": "67", "trainer_type": "FLAG_HIDE_SEAFOAM_B1F_BOULDER_2",
"trainer_sight_or_berry_tree_id": "0", "trainer_sight_or_berry_tree_id": "0",
"script": "EventScript_StrengthBoulder", "script": "EventScript_StrengthBoulder",
"flag": "FLAG_HIDE_SEAFOAM_1F_BOULDER_2" "flag": "FLAG_HIDE_SEAFOAM_1F_BOULDER_2"
+2 -2
View File
@@ -23,7 +23,7 @@
"movement_type": "MOVEMENT_TYPE_FACE_DOWN", "movement_type": "MOVEMENT_TYPE_FACE_DOWN",
"movement_range_x": 0, "movement_range_x": 0,
"movement_range_y": 0, "movement_range_y": 0,
"trainer_type": "68", "trainer_type": "FLAG_HIDE_SEAFOAM_B2F_BOULDER_1",
"trainer_sight_or_berry_tree_id": "0", "trainer_sight_or_berry_tree_id": "0",
"script": "EventScript_StrengthBoulder", "script": "EventScript_StrengthBoulder",
"flag": "FLAG_HIDE_SEAFOAM_B1F_BOULDER_1" "flag": "FLAG_HIDE_SEAFOAM_B1F_BOULDER_1"
@@ -36,7 +36,7 @@
"movement_type": "MOVEMENT_TYPE_FACE_DOWN", "movement_type": "MOVEMENT_TYPE_FACE_DOWN",
"movement_range_x": 0, "movement_range_x": 0,
"movement_range_y": 0, "movement_range_y": 0,
"trainer_type": "69", "trainer_type": "FLAG_HIDE_SEAFOAM_B2F_BOULDER_2",
"trainer_sight_or_berry_tree_id": "0", "trainer_sight_or_berry_tree_id": "0",
"script": "EventScript_StrengthBoulder", "script": "EventScript_StrengthBoulder",
"flag": "FLAG_HIDE_SEAFOAM_B1F_BOULDER_2" "flag": "FLAG_HIDE_SEAFOAM_B1F_BOULDER_2"
+2 -2
View File
@@ -23,7 +23,7 @@
"movement_type": "MOVEMENT_TYPE_FACE_DOWN", "movement_type": "MOVEMENT_TYPE_FACE_DOWN",
"movement_range_x": 0, "movement_range_x": 0,
"movement_range_y": 0, "movement_range_y": 0,
"trainer_type": "70", "trainer_type": "FLAG_HIDE_SEAFOAM_B3F_BOULDER_1",
"trainer_sight_or_berry_tree_id": "0", "trainer_sight_or_berry_tree_id": "0",
"script": "EventScript_StrengthBoulder", "script": "EventScript_StrengthBoulder",
"flag": "FLAG_HIDE_SEAFOAM_B2F_BOULDER_1" "flag": "FLAG_HIDE_SEAFOAM_B2F_BOULDER_1"
@@ -36,7 +36,7 @@
"movement_type": "MOVEMENT_TYPE_FACE_DOWN", "movement_type": "MOVEMENT_TYPE_FACE_DOWN",
"movement_range_x": 0, "movement_range_x": 0,
"movement_range_y": 0, "movement_range_y": 0,
"trainer_type": "71", "trainer_type": "FLAG_HIDE_SEAFOAM_B3F_BOULDER_2",
"trainer_sight_or_berry_tree_id": "0", "trainer_sight_or_berry_tree_id": "0",
"script": "EventScript_StrengthBoulder", "script": "EventScript_StrengthBoulder",
"flag": "FLAG_HIDE_SEAFOAM_B2F_BOULDER_2" "flag": "FLAG_HIDE_SEAFOAM_B2F_BOULDER_2"
+2 -2
View File
@@ -49,7 +49,7 @@
"movement_type": "MOVEMENT_TYPE_FACE_DOWN", "movement_type": "MOVEMENT_TYPE_FACE_DOWN",
"movement_range_x": 0, "movement_range_x": 0,
"movement_range_y": 0, "movement_range_y": 0,
"trainer_type": "77", "trainer_type": "FLAG_HIDE_SEAFOAM_B4F_BOULDER_2",
"trainer_sight_or_berry_tree_id": "0", "trainer_sight_or_berry_tree_id": "0",
"script": "EventScript_StrengthBoulder", "script": "EventScript_StrengthBoulder",
"flag": "FLAG_HIDE_SEAFOAM_B3F_BOULDER_5" "flag": "FLAG_HIDE_SEAFOAM_B3F_BOULDER_5"
@@ -88,7 +88,7 @@
"movement_type": "MOVEMENT_TYPE_FACE_DOWN", "movement_type": "MOVEMENT_TYPE_FACE_DOWN",
"movement_range_x": 0, "movement_range_x": 0,
"movement_range_y": 0, "movement_range_y": 0,
"trainer_type": "76", "trainer_type": "FLAG_HIDE_SEAFOAM_B4F_BOULDER_1",
"trainer_sight_or_berry_tree_id": "0", "trainer_sight_or_berry_tree_id": "0",
"script": "EventScript_StrengthBoulder", "script": "EventScript_StrengthBoulder",
"flag": "FLAG_HIDE_SEAFOAM_B3F_BOULDER_3" "flag": "FLAG_HIDE_SEAFOAM_B3F_BOULDER_3"
+1 -1
View File
@@ -114,7 +114,7 @@
"movement_type": "MOVEMENT_TYPE_FACE_DOWN", "movement_type": "MOVEMENT_TYPE_FACE_DOWN",
"movement_range_x": 0, "movement_range_x": 0,
"movement_range_y": 0, "movement_range_y": 0,
"trainer_type": "88", "trainer_type": "FLAG_HIDE_VICTORY_ROAD_2F_BOULDER",
"trainer_sight_or_berry_tree_id": "0", "trainer_sight_or_berry_tree_id": "0",
"script": "EventScript_StrengthBoulder", "script": "EventScript_StrengthBoulder",
"flag": "FLAG_HIDE_VICTORY_ROAD_3F_BOULDER" "flag": "FLAG_HIDE_VICTORY_ROAD_3F_BOULDER"
+1 -1
View File
@@ -64,7 +64,7 @@ bool8 TryGetObjectEventIdByLocalIdAndMap(u8, u8, u8, u8 *);
u8 GetObjectEventIdByXY(s16, s16); u8 GetObjectEventIdByXY(s16, s16);
void SetObjectEventDirection(struct ObjectEvent *, u8); void SetObjectEventDirection(struct ObjectEvent *, u8);
void RemoveObjectEventByLocalIdAndMap(u8 localId, u8 mapNum, u8 mapGroup); void RemoveObjectEventByLocalIdAndMap(u8 localId, u8 mapNum, u8 mapGroup);
u16 GetObjectEventFlagByLocalIdAndMap(u8 localId, u8 mapNum, u8 mapGroup); u16 GetBoulderRevealFlagByLocalIdAndMap(u8 localId, u8 mapNum, u8 mapGroup);
void LoadPlayerObjectReflectionPalette(u16, u8); void LoadPlayerObjectReflectionPalette(u16, u8);
void LoadSpecialObjectReflectionPalette(u16, u8); void LoadSpecialObjectReflectionPalette(u16, u8);
void TryMoveObjectEventToMapCoords(u8, u8, u8, s16, s16); void TryMoveObjectEventToMapCoords(u8, u8, u8, s16, s16);
+6 -7
View File
@@ -17,6 +17,7 @@
#include "trig.h" #include "trig.h"
#include "constants/event_object_movement.h" #include "constants/event_object_movement.h"
#include "constants/event_objects.h" #include "constants/event_objects.h"
#include "constants/trainer_types.h"
static void MoveCoordsInDirection(u32, s16 *, s16 *, s16, s16); static void MoveCoordsInDirection(u32, s16 *, s16 *, s16, s16);
static bool8 ObjectEventExecSingleMovementAction(struct ObjectEvent *, struct Sprite *); static bool8 ObjectEventExecSingleMovementAction(struct ObjectEvent *, struct Sprite *);
@@ -1682,7 +1683,7 @@ int SpawnSpecialObjectEventParameterized(u8 graphicsId, u8 movementBehavior, u8
objectEventTemplate.movementType = movementBehavior; objectEventTemplate.movementType = movementBehavior;
objectEventTemplate.movementRangeX = 0; objectEventTemplate.movementRangeX = 0;
objectEventTemplate.movementRangeY = 0; objectEventTemplate.movementRangeY = 0;
objectEventTemplate.trainerType = 0; objectEventTemplate.trainerType = TRAINER_TYPE_NONE;
objectEventTemplate.trainerRange_berryTreeId = 0; objectEventTemplate.trainerRange_berryTreeId = 0;
return SpawnSpecialObjectEvent(&objectEventTemplate); return SpawnSpecialObjectEvent(&objectEventTemplate);
} }
@@ -2588,8 +2589,10 @@ u8 GetObjectTrainerTypeByLocalIdAndMap(u8 localId, u8 mapNum, u8 mapGroup)
return gObjectEvents[objectEventId].trainerType; return gObjectEvents[objectEventId].trainerType;
} }
u16 GetObjectEventFlagByLocalIdAndMap(u8 localId, u8 mapNum, u8 mapGroup) u16 GetBoulderRevealFlagByLocalIdAndMap(u8 localId, u8 mapNum, u8 mapGroup)
{ {
// Pushable boulder object events store the flag to reveal the boulder
// on the floor below in their trainer type field.
return GetObjectEventTemplateByLocalIdAndMap(localId, mapNum, mapGroup)->trainerType; return GetObjectEventTemplateByLocalIdAndMap(localId, mapNum, mapGroup)->trainerType;
} }
@@ -2824,13 +2827,9 @@ bool8 ObjectEventIsTrainerAndCloseToPlayer(struct ObjectEvent *objectEvent)
s16 maxY; s16 maxY;
if (!TestPlayerAvatarFlags(PLAYER_AVATAR_FLAG_DASH)) if (!TestPlayerAvatarFlags(PLAYER_AVATAR_FLAG_DASH))
{
return FALSE; return FALSE;
} if (objectEvent->trainerType != TRAINER_TYPE_NORMAL && objectEvent->trainerType != TRAINER_TYPE_BURIED)
if (objectEvent->trainerType != 1 && objectEvent->trainerType != 3)
{
return FALSE; return FALSE;
}
PlayerGetDestCoords(&playerX, &playerY); PlayerGetDestCoords(&playerX, &playerY);
objX = objectEvent->currentCoords.x; objX = objectEvent->currentCoords.x;
objY = objectEvent->currentCoords.y; objY = objectEvent->currentCoords.y;
+1 -1
View File
@@ -1069,7 +1069,7 @@ void HandleBoulderFallThroughHole(struct ObjectEvent * object)
{ {
PlaySE(SE_FALL); PlaySE(SE_FALL);
RemoveObjectEventByLocalIdAndMap(object->localId, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup); RemoveObjectEventByLocalIdAndMap(object->localId, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup);
FlagClear(GetObjectEventFlagByLocalIdAndMap(object->localId, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup)); FlagClear(GetBoulderRevealFlagByLocalIdAndMap(object->localId, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup));
} }
} }
+2 -1
View File
@@ -25,6 +25,7 @@
#include "constants/songs.h" #include "constants/songs.h"
#include "constants/metatile_behaviors.h" #include "constants/metatile_behaviors.h"
#include "constants/moves.h" #include "constants/moves.h"
#include "constants/trainer_types.h"
static EWRAM_DATA struct ObjectEvent * sPlayerObjectPtr = NULL; static EWRAM_DATA struct ObjectEvent * sPlayerObjectPtr = NULL;
static EWRAM_DATA u8 sTeleportSavedFacingDirection = DIR_NONE; static EWRAM_DATA u8 sTeleportSavedFacingDirection = DIR_NONE;
@@ -1295,7 +1296,7 @@ void InitPlayerAvatar(s16 x, s16 y, u8 direction, u8 gender)
playerObjEventTemplate.movementType = MOVEMENT_TYPE_PLAYER; playerObjEventTemplate.movementType = MOVEMENT_TYPE_PLAYER;
playerObjEventTemplate.movementRangeX = 0; playerObjEventTemplate.movementRangeX = 0;
playerObjEventTemplate.movementRangeY = 0; playerObjEventTemplate.movementRangeY = 0;
playerObjEventTemplate.trainerType = 0; playerObjEventTemplate.trainerType = TRAINER_TYPE_NONE;
playerObjEventTemplate.trainerRange_berryTreeId = 0; playerObjEventTemplate.trainerRange_berryTreeId = 0;
playerObjEventTemplate.script = NULL; playerObjEventTemplate.script = NULL;
playerObjEventTemplate.flagId = 0; playerObjEventTemplate.flagId = 0;
+6 -8
View File
@@ -10,6 +10,7 @@
#include "constants/battle_setup.h" #include "constants/battle_setup.h"
#include "constants/event_object_movement.h" #include "constants/event_object_movement.h"
#include "constants/event_objects.h" #include "constants/event_objects.h"
#include "constants/trainer_types.h"
typedef u8 (*TrainerApproachFunc)(struct ObjectEvent *, s16, s16, s16); typedef u8 (*TrainerApproachFunc)(struct ObjectEvent *, s16, s16, s16);
typedef bool8 (*TrainerSeeFunc)(u8, struct Task *, struct ObjectEvent *); typedef bool8 (*TrainerSeeFunc)(u8, struct Task *, struct ObjectEvent *);
@@ -93,12 +94,9 @@ bool8 CheckForTrainersWantingBattle(void)
for (i = 0; i < OBJECT_EVENTS_COUNT; i++) for (i = 0; i < OBJECT_EVENTS_COUNT; i++)
{ {
if (gObjectEvents[i].active if (gObjectEvents[i].active
&& ( && (gObjectEvents[i].trainerType == TRAINER_TYPE_NORMAL
gObjectEvents[i].trainerType == 1 || gObjectEvents[i].trainerType == TRAINER_TYPE_BURIED)
|| gObjectEvents[i].trainerType == 3 && CheckTrainer(i))
)
&& CheckTrainer(i)
)
return TRUE; return TRUE;
} }
return FALSE; return FALSE;
@@ -129,12 +127,12 @@ static u8 GetTrainerApproachDistance(struct ObjectEvent *trainerObj)
u8 approachDistance; u8 approachDistance;
PlayerGetDestCoords(&x, &y); PlayerGetDestCoords(&x, &y);
if (trainerObj->trainerType == 1) // can only see in one direction if (trainerObj->trainerType == TRAINER_TYPE_NORMAL) // can only see in one direction
{ {
approachDistance = sDirectionalApproachDistanceFuncs[trainerObj->facingDirection - 1](trainerObj, trainerObj->trainerRange_berryTreeId, x, y); approachDistance = sDirectionalApproachDistanceFuncs[trainerObj->facingDirection - 1](trainerObj, trainerObj->trainerRange_berryTreeId, x, y);
return CheckPathBetweenTrainerAndPlayer(trainerObj, approachDistance, trainerObj->facingDirection); return CheckPathBetweenTrainerAndPlayer(trainerObj, approachDistance, trainerObj->facingDirection);
} }
else // can see in all directions else // TRAINER_TYPE_SEE_ALL_DIRECTIONS, TRAINER_TYPE_BURIED
{ {
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
{ {
+6 -9
View File
@@ -638,14 +638,11 @@ void VsSeekerResetObjectMovementAfterChargeComplete(void)
for (i = 0; i < gMapHeader.events->objectEventCount; i++) for (i = 0; i < gMapHeader.events->objectEventCount; i++)
{ {
if (( if ((templates[i].trainerType == TRAINER_TYPE_NORMAL
templates[i].trainerType == TRAINER_TYPE_NORMAL || templates[i].trainerType == TRAINER_TYPE_BURIED)
|| templates[i].trainerType == TRAINER_TYPE_BURIED && (templates[i].movementType == MOVEMENT_TYPE_VS_SEEKER_4D
) && ( || templates[i].movementType == MOVEMENT_TYPE_VS_SEEKER_4E
templates[i].movementType == MOVEMENT_TYPE_VS_SEEKER_4D || templates[i].movementType == MOVEMENT_TYPE_VS_SEEKER_4F))
|| templates[i].movementType == MOVEMENT_TYPE_VS_SEEKER_4E
|| templates[i].movementType == MOVEMENT_TYPE_VS_SEEKER_4F
))
{ {
movementType = GetRandomFaceDirectionMovementType(); movementType = GetRandomFaceDirectionMovementType();
TryGetObjectEventIdByLocalIdAndMap(templates[i].localId, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup, &objEventId); TryGetObjectEventIdByLocalIdAndMap(templates[i].localId, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup, &objEventId);
@@ -808,7 +805,7 @@ static void GatherNearbyTrainerInfo(void)
for (objectEventIdx = 0; objectEventIdx < gMapHeader.events->objectEventCount; objectEventIdx++) for (objectEventIdx = 0; objectEventIdx < gMapHeader.events->objectEventCount; objectEventIdx++)
{ {
if (templates[objectEventIdx].trainerType == 1 || templates[objectEventIdx].trainerType == 3) if (templates[objectEventIdx].trainerType == TRAINER_TYPE_NORMAL || templates[objectEventIdx].trainerType == TRAINER_TYPE_BURIED)
{ {
sVsSeeker->trainerInfo[vsSeekerObjectIdx].script = templates[objectEventIdx].script; sVsSeeker->trainerInfo[vsSeekerObjectIdx].script = templates[objectEventIdx].script;
sVsSeeker->trainerInfo[vsSeekerObjectIdx].trainerIdx = GetTrainerFlagFromScript(templates[objectEventIdx].script); sVsSeeker->trainerInfo[vsSeekerObjectIdx].trainerIdx = GetTrainerFlagFromScript(templates[objectEventIdx].script);