More trainer type usage
This commit is contained in:
+10
-9
@@ -17,6 +17,7 @@
|
||||
#include "constants/event_objects.h"
|
||||
#include "constants/event_object_movement.h"
|
||||
#include "constants/field_effects.h"
|
||||
#include "constants/trainer_types.h"
|
||||
|
||||
// this file's functions
|
||||
static u8 CheckTrainer(u8 objectEventId);
|
||||
@@ -181,18 +182,18 @@ bool8 CheckForTrainersWantingBattle(void)
|
||||
|
||||
for (i = 0; i < OBJECT_EVENTS_COUNT; i++)
|
||||
{
|
||||
u8 retVal;
|
||||
u8 numTrainers;
|
||||
|
||||
if (!gObjectEvents[i].active)
|
||||
continue;
|
||||
if (gObjectEvents[i].trainerType != 1 && gObjectEvents[i].trainerType != 3)
|
||||
if (gObjectEvents[i].trainerType != TRAINER_TYPE_NORMAL && gObjectEvents[i].trainerType != TRAINER_TYPE_BURIED)
|
||||
continue;
|
||||
|
||||
retVal = CheckTrainer(i);
|
||||
if (retVal == 2)
|
||||
break; // two trainers have been found
|
||||
numTrainers = CheckTrainer(i);
|
||||
if (numTrainers == 2)
|
||||
break;
|
||||
|
||||
if (retVal == 0) // no trainers
|
||||
if (numTrainers == 0)
|
||||
continue;
|
||||
|
||||
if (gNoOfApproachingTrainers > 1)
|
||||
@@ -289,14 +290,14 @@ static u8 GetTrainerApproachDistance(struct ObjectEvent *trainerObj)
|
||||
u8 approachDistance;
|
||||
|
||||
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);
|
||||
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 < ARRAY_COUNT(sDirectionalApproachDistanceFuncs); i++)
|
||||
{
|
||||
approachDistance = sDirectionalApproachDistanceFuncs[i](trainerObj, trainerObj->trainerRange_berryTreeId, x, y);
|
||||
if (CheckPathBetweenTrainerAndPlayer(trainerObj, approachDistance, i + 1)) // directions are 1-4 instead of 0-3. south north west east
|
||||
|
||||
Reference in New Issue
Block a user