Clone of Bael'Zharon's Respite @ https://github.com/boardwalk/bzr

PRNG.h 2.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /*
  2. * Bael'Zharon's Respite
  3. * Copyright (C) 2014 Daniel Skorupski
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2 of the License, or
  8. * (at your option) any later version.
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License along
  15. * with this program; if not, write to the Free Software Foundation, Inc.,
  16. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  17. */
  18. #ifndef BZR_PRNG_H
  19. #define BZR_PRNG_H
  20. // if prng(x, y, RND_MID_DIAG) >= 0.5, the landcell's polygon is split NE/SW
  21. static const int32_t RND_MID_DIAG = 0x00000003;
  22. // select scene floor(prng(x, y, RND_SCENE_PICK) * num_scenes) from scene type
  23. static const int32_t RND_SCENE_PICK = 0x00002bf9;
  24. // if prng(x, y, RND_SCENE_FREQ + obj_num) < freq, show object
  25. static const int32_t RND_SCENE_FREQ = 0x00005b67;
  26. // displaces an object prng(x, y RND_SCENE_DISP_X + obj_num) * displace_x units on the x axis
  27. static const int32_t RND_SCENE_DISP_X = 0x0000b2cd;
  28. // displaces an object prng(x, y, RND_SCENE_DISP_Y + obj_num) * displace_y units on the y axis
  29. static const int32_t RND_SCENE_DISP_Y = 0x00011c0f;
  30. // scales an object min_scale * pow(max_scale / min_scale, prng(x, y, RND_SCENE_SCALE_1 + obj_num))
  31. static const int32_t RND_SCENE_SCALE1 = 0x00007f51;
  32. // ??
  33. static const int32_t RND_SCENE_SCALE2 = 0x000096a7;
  34. // if prng(x, y, RND_SCENE_ROT) >= 0.75, (y, -x)
  35. // if prng(...) >= 0.5, (-x, -y)
  36. // if prng(...) >= 0.25, (-y, x)
  37. // else, (y, x) (sub_5A6D40)
  38. static const int32_t RND_SCENE_ROT = 0x0000e7eb;
  39. // rotate a scene object prng(x, y, RND_SCENE_ROT + obj_num) * max_rot degrees
  40. static const int32_t RND_SCENE_OBJROT = 0x0000f697;
  41. // @ 005005CB
  42. static const int32_t RND_LAND_ROT = 0x0000000d;
  43. // @ 00500E51
  44. static const int32_t RND_LAND_TEX = 0x00000011;
  45. static const int32_t RND_LAND_ALPHA2 = 0x00012071;
  46. static const int32_t RND_LAND_ALPHA1 = 0x000002db;
  47. static const int32_t RND_SKILL_APPRAISE = 0x00000013;
  48. static const int32_t RND_TIME_WEATH1 = 0x0000a883;
  49. static const int32_t RND_TIME_WEATH2 = 0x00013255;
  50. // generates a number 0.0 to 1.0
  51. double prng(uint32_t cell_x, uint32_t cell_y, uint32_t seed);
  52. #endif