Advertisement
Kurausukun

Untitled

Nov 22nd, 2018
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.84 KB | None | 0 0
  1. static Tile tiles[5600];
  2.  
  3. typedef struct TileStruct
  4. {
  5. u16 xval, yval;
  6. } Tile;
  7.  
  8. static u16 FishingPoints_CountFishingTilesInMapThird(u8 a0)
  9. {
  10. u16 retval = 0;
  11. u16 height = gMapHeader.mapLayout->height / 3;
  12. u16 y;
  13. u16 x;
  14. u16 start = height * a0;
  15. u8 tilecounter;
  16. tiles[gMapHeader.mapLayout->height * gMapHeader.mapLayout->width];
  17.  
  18. for (y = start; y < start + height; y++)
  19. {
  20. for (x = 0; x < gMapHeader.mapLayout->width; x++)
  21. {
  22. (tiles + tilecounter)->xval = x;
  23. (tiles+ tilecounter)->yval = y;
  24. tilecounter++;
  25. if (MetatileBehavior_IsSurfableAndNotWaterfall(MapGridGetMetatileBehaviorAt(x + 7, y + 7)) == TRUE)
  26. {
  27. retval++;
  28. }
  29. }
  30. }
  31.  
  32. return retval;
  33. }
  34.  
  35. static u16 FishingPoints_GetIndexOfCurrentFishingSpot(void)
  36. {
  37. u16 retval = 0;
  38. s16 x;
  39. s16 y;
  40. u16 xx;
  41. u16 yy;
  42.  
  43. GetXYCoordsOneStepInFrontOfPlayer(&x, &y);
  44. x -= 7;
  45. y -= 7;
  46.  
  47. for (yy = 0; yy < gMapHeader.mapLayout->height; yy++)
  48. {
  49. for (xx = 0; xx < gMapHeader.mapLayout->width; xx++)
  50. {
  51. if (MetatileBehavior_IsSurfableAndNotWaterfall(MapGridGetMetatileBehaviorAt(xx + 7, yy + 7)) == TRUE)
  52. {
  53. retval++;
  54. if (x == xx && y == yy)
  55. return retval;
  56. }
  57. }
  58. }
  59. return retval + 1;
  60. }
  61.  
  62. void FishingPoints(void)
  63. {
  64. u16 nWaterTiles;
  65. u16 nFeebas;
  66.  
  67. FeebasSeedRng(gSaveBlock1Ptr->easyChatPairs[0].unk2);
  68.  
  69. nWaterTiles = FishingPoints_CountFishingTilesInMapThird(0) + FishingPoints_CountFishingTilesInMapThird(1) + FishingPoints_CountFishingTilesInMapThird(2);
  70. nFeebas = 0;
  71.  
  72. while (nFeebas != 6)
  73. {
  74. u16 randTile = FeebasRandom() % nWaterTiles;
  75. if (randTile == 0)
  76. randTile = nWaterTiles;
  77. if (randTile == 0 || randTile > 3)
  78. {
  79. MapGridSetMetatileIdAt(tiles[randTile].xval, tiles[randTile].yval, 0x147);
  80. nFeebas++;
  81. }
  82. }
  83. }
  84.  
  85. static u16 GetRoute119WaterTileNum(s16 x, s16 y, u8 section)
  86. {
  87. u16 xCur;
  88. u16 yCur;
  89. u16 yMin = gRoute119WaterTileData[section * 3 + 0];
  90. u16 yMax = gRoute119WaterTileData[section * 3 + 1];
  91. u16 tileNum = gRoute119WaterTileData[section * 3 + 2];
  92.  
  93. for (yCur = yMin; yCur <= yMax; yCur++)
  94. {
  95. for (xCur = 0; xCur < gMapHeader.mapLayout->width; xCur++)
  96. {
  97. u8 tileBehaviorId = MapGridGetMetatileBehaviorAt(xCur + 7, yCur + 7);
  98. if (MetatileBehavior_IsSurfableAndNotWaterfall(tileBehaviorId) == TRUE)
  99. {
  100. tileNum++;
  101. if (x == xCur && y == yCur)
  102. return tileNum;
  103. }
  104. }
  105. }
  106. return tileNum + 1;
  107. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement