Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static Tile tiles[5600];
- typedef struct TileStruct
- {
- u16 xval, yval;
- } Tile;
- static u16 FishingPoints_CountFishingTilesInMapThird(u8 a0)
- {
- u16 retval = 0;
- u16 height = gMapHeader.mapLayout->height / 3;
- u16 y;
- u16 x;
- u16 start = height * a0;
- u8 tilecounter;
- tiles[gMapHeader.mapLayout->height * gMapHeader.mapLayout->width];
- for (y = start; y < start + height; y++)
- {
- for (x = 0; x < gMapHeader.mapLayout->width; x++)
- {
- (tiles + tilecounter)->xval = x;
- (tiles+ tilecounter)->yval = y;
- tilecounter++;
- if (MetatileBehavior_IsSurfableAndNotWaterfall(MapGridGetMetatileBehaviorAt(x + 7, y + 7)) == TRUE)
- {
- retval++;
- }
- }
- }
- return retval;
- }
- static u16 FishingPoints_GetIndexOfCurrentFishingSpot(void)
- {
- u16 retval = 0;
- s16 x;
- s16 y;
- u16 xx;
- u16 yy;
- GetXYCoordsOneStepInFrontOfPlayer(&x, &y);
- x -= 7;
- y -= 7;
- for (yy = 0; yy < gMapHeader.mapLayout->height; yy++)
- {
- for (xx = 0; xx < gMapHeader.mapLayout->width; xx++)
- {
- if (MetatileBehavior_IsSurfableAndNotWaterfall(MapGridGetMetatileBehaviorAt(xx + 7, yy + 7)) == TRUE)
- {
- retval++;
- if (x == xx && y == yy)
- return retval;
- }
- }
- }
- return retval + 1;
- }
- void FishingPoints(void)
- {
- u16 nWaterTiles;
- u16 nFeebas;
- FeebasSeedRng(gSaveBlock1Ptr->easyChatPairs[0].unk2);
- nWaterTiles = FishingPoints_CountFishingTilesInMapThird(0) + FishingPoints_CountFishingTilesInMapThird(1) + FishingPoints_CountFishingTilesInMapThird(2);
- nFeebas = 0;
- while (nFeebas != 6)
- {
- u16 randTile = FeebasRandom() % nWaterTiles;
- if (randTile == 0)
- randTile = nWaterTiles;
- if (randTile == 0 || randTile > 3)
- {
- MapGridSetMetatileIdAt(tiles[randTile].xval, tiles[randTile].yval, 0x147);
- nFeebas++;
- }
- }
- }
- static u16 GetRoute119WaterTileNum(s16 x, s16 y, u8 section)
- {
- u16 xCur;
- u16 yCur;
- u16 yMin = gRoute119WaterTileData[section * 3 + 0];
- u16 yMax = gRoute119WaterTileData[section * 3 + 1];
- u16 tileNum = gRoute119WaterTileData[section * 3 + 2];
- for (yCur = yMin; yCur <= yMax; yCur++)
- {
- for (xCur = 0; xCur < gMapHeader.mapLayout->width; xCur++)
- {
- u8 tileBehaviorId = MapGridGetMetatileBehaviorAt(xCur + 7, yCur + 7);
- if (MetatileBehavior_IsSurfableAndNotWaterfall(tileBehaviorId) == TRUE)
- {
- tileNum++;
- if (x == xCur && y == yCur)
- return tileNum;
- }
- }
- }
- return tileNum + 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement