diff options
author | DizzyEggg <jajkodizzy@wp.pl> | 2017-12-18 16:58:14 +0100 |
---|---|---|
committer | DizzyEggg <jajkodizzy@wp.pl> | 2017-12-18 16:58:14 +0100 |
commit | cb229f56e8951e3f9efc35516447a54e18e8fef0 (patch) | |
tree | 656599caae716c6cc8e81121f2b1cd061927b99e /src/trainer_see.c | |
parent | c3abe2863feb8ebb21921c40d3c685a27a4135c4 (diff) | |
parent | 6a674e1e83db097d7a31a3786d12e42987f09f70 (diff) |
fix pokeblock conflicts
Diffstat (limited to 'src/trainer_see.c')
-rw-r--r-- | src/trainer_see.c | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/src/trainer_see.c b/src/trainer_see.c new file mode 100644 index 000000000..b30f27347 --- /dev/null +++ b/src/trainer_see.c @@ -0,0 +1,68 @@ +#include "global.h" +#include "trainer_see.h" +#include "battle_setup.h" + +extern u8 gApproachingTrainerId; +extern u8 gNoOfApproachingTrainers; +extern u8 gUnknown_030060AC; +extern u16 gUnknown_03006080; + +// this file's functions +u8 CheckIfTrainerWantsBattle(u8 mapObjectId); + +bool8 CheckForTrainersWantingBattle(void) +{ + u8 i; + + gNoOfApproachingTrainers = 0; + gApproachingTrainerId = 0; + + for (i = 0; i < MAP_OBJECTS_COUNT; i++) + { + u8 retVal; + + if (!gMapObjects[i].active) + continue; + if (gMapObjects[i].trainerType != 1 && gMapObjects[i].trainerType != 3) + continue; + + retVal = CheckIfTrainerWantsBattle(i); + if (retVal == 2) + break; // two trainers have been found + + if (retVal == 0) // no trainers + continue; + + if (gNoOfApproachingTrainers > 1) + break; + if (GetMonsStateToDoubles_2() != 0) // one trainer found and cant have a double battle + break; + } + + if (gNoOfApproachingTrainers == 1) + { + ResetTrainerOpponentIds(); + ConfigureAndSetUpOneTrainerBattle(gApproachingTrainers[gNoOfApproachingTrainers - 1].mapObjectId, + gApproachingTrainers[gNoOfApproachingTrainers - 1].trainerScriptPtr); + gUnknown_030060AC = 1; + return TRUE; + } + else if (gNoOfApproachingTrainers == 2) + { + ResetTrainerOpponentIds(); + for (i = 0; i < gNoOfApproachingTrainers; i++, gApproachingTrainerId++) + { + ConfigureTwoTrainersBattle(gApproachingTrainers[i].mapObjectId, + gApproachingTrainers[i].trainerScriptPtr); + } + SetUpTwoTrainersBattle(); + gApproachingTrainerId = 0; + gUnknown_030060AC = 1; + return TRUE; + } + else + { + gUnknown_030060AC = 0; + return FALSE; + } +} |