Prototype game engine for Heroes of Might & Magic, featuring a gameplay plot-twist...
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

251 line
11KB

  1. -- Copyright (c) 2024 - Ognjen 'xolatile' Milan Robovic
  2. --
  3. -- GNU General Public Licence (version 3 or later)
  4. with core, attribute, skill, resource, material, equipment, unit, construction, chad, effect;
  5. use core;
  6. package world is
  7. ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  8. type biome is (
  9. ash, sand, grass, rough, snow, swamp
  10. );
  11. type landmark_index is (
  12. dead_tree, mossy_rock, palm_tree, pine_tree, pine_forest, reeds,
  13. rock, snowed_pine_tree, snowed_rock, spiky_rock, wooden_sign, wooden_arrow_sign,
  14. rune_stone, snowed_rune_stone, mossy_rune_stone, snowed_pine_forest, hyacinths, orchids,
  15. asters, daffodils, royal_grave, grave, humble_grave, wooden_wide_sign,
  16. birch_tree, fir_tree, oak_tree, old_willow_tree
  17. );
  18. type location_index is (
  19. well_of_agility, well_of_knowledge, well_of_strength, old_dwarven_grave, huge_ancient_urn, banana_tree,
  20. apple_tree, cherry_tree, lemon_tree, orange_tree, pear_tree, peach_tree,
  21. plum_tree
  22. );
  23. ------------------------------------------------------------------------------------------
  24. type landmark_stats is record
  25. name : core.short_string;
  26. spawn : biome;
  27. clip : boolean;
  28. frames : integer;
  29. end record;
  30. type location_stats is record
  31. name : core.short_string;
  32. clip : boolean;
  33. frames : integer;
  34. states : integer;
  35. evoke : effect.information;
  36. end record;
  37. type entity_description is record
  38. index : natural;
  39. state : natural;
  40. x, y : integer;
  41. end record;
  42. type integer_matrix is array (natural range <>, natural range <>) of integer;
  43. type boolean_matrix is array (natural range <>, natural range <>) of boolean;
  44. type entity_array is array (natural range <>) of entity_description;
  45. type definition is record
  46. kind : biome;
  47. width : natural;
  48. height : natural;
  49. chad_count : natural;
  50. chad_limit : natural;
  51. tiles : access integer_matrix;
  52. clips : access boolean_matrix;
  53. views : access boolean_matrix;
  54. landmarks : access entity_array;
  55. locations : access entity_array;
  56. constructions : access entity_array;
  57. equipments : access entity_array;
  58. units : access entity_array;
  59. chads : access chad.informations;
  60. end record;
  61. ------------------------------------------------------------------------------------------
  62. biome_count : constant natural := biome'pos (biome'last) + 1;
  63. landmarks : array (landmark_index) of core.sprite;
  64. locations : array (location_index) of core.sprite;
  65. landmark_count : constant natural := landmark_index'pos (landmark_index'last) + 1;
  66. location_count : constant natural := location_index'pos (location_index'last) + 1;
  67. landmark_description : constant array (landmark_index) of landmark_stats := (
  68. dead_tree => ("Dead Tree ", ash, true, 1),
  69. mossy_rock => ("Mossy Rock ", swamp, true, 1),
  70. palm_tree => ("Palm Tree ", sand, true, 4),
  71. pine_tree => ("Pine Tree ", grass, true, 4),
  72. pine_forest => ("Pine Forest ", grass, true, 4),
  73. reeds => ("Reeds ", swamp, false, 4),
  74. rock => ("Rock ", sand, true, 1),
  75. snowed_pine_tree => ("Snowed Pine Tree ", snow, true, 4),
  76. snowed_rock => ("Snowed Rock ", snow, true, 1),
  77. spiky_rock => ("Spiky Rock ", ash, true, 1),
  78. wooden_sign => ("Wooden Sign ", grass, false, 1),
  79. wooden_arrow_sign => ("Wooden Arrow Sign ", grass, false, 1),
  80. rune_stone => ("Rune Stone ", grass, true, 4),
  81. snowed_rune_stone => ("Snowed Rune Stone ", snow, true, 1),
  82. mossy_rune_stone => ("Mossy Rune Stone ", swamp, true, 4),
  83. snowed_pine_forest => ("Snowed Pine Forest ", snow, true, 4),
  84. hyacinths => ("Hyacinths ", grass, false, 1),
  85. orchids => ("Orchids ", grass, false, 1),
  86. asters => ("Asters ", grass, false, 1),
  87. daffodils => ("Daffodils ", grass, false, 1),
  88. royal_grave => ("Royal Grave ", ash, true, 1),
  89. grave => ("Grave ", ash, true, 1),
  90. humble_grave => ("Humble Grave ", ash, true, 1),
  91. wooden_wide_sign => ("Wooden Wide Sign ", grass, false, 1),
  92. birch_tree => ("Birch Tree ", grass, true, 4),
  93. fir_tree => ("Fir Tree ", grass, true, 4),
  94. oak_tree => ("Oak Tree ", grass, true, 4),
  95. old_willow_tree => ("Old Willow Tree ", swamp, true, 4)
  96. );
  97. location_description : constant array (location_index) of location_stats := (
  98. well_of_agility => ("Well of Agility ", true, 4, 3, (effect.modify_attribute, attribute.enumeration'pos (attribute.speed), 2, false, 0)),
  99. well_of_knowledge => ("Well of Knowledge ", true, 4, 3, (effect.modify_attribute, attribute.enumeration'pos (attribute.wisdom), 2, false, 0)),
  100. well_of_strength => ("Well of Strength ", true, 4, 3, (effect.modify_attribute, attribute.enumeration'pos (attribute.offense), 2, false, 0)),
  101. old_dwarven_grave => ("Old Dwarven Grave ", true, 1, 3, (effect.modify_attribute, attribute.enumeration'pos (attribute.defense), 1, false, 0)),
  102. huge_ancient_urn => ("Huge Ancient Urn ", true, 1, 3, (effect.modify_attribute, attribute.enumeration'pos (attribute.offense), 1, false, 0)),
  103. --
  104. banana_tree => ("Banana Tree ", true, 4, 3, (effect.modify_material, material.enumeration'pos (material.banana), 4, true, 600)),
  105. apple_tree => ("Apple Tree ", true, 4, 3, (effect.modify_material, material.enumeration'pos (material.apple), 6, true, 600)),
  106. cherry_tree => ("Cherry Tree ", true, 4, 3, (effect.modify_material, material.enumeration'pos (material.cherry), 6, true, 600)),
  107. lemon_tree => ("Lemon Tree ", true, 4, 3, (effect.modify_material, material.enumeration'pos (material.lemon), 6, true, 600)),
  108. orange_tree => ("Orange Tree ", true, 4, 3, (effect.modify_material, material.enumeration'pos (material.orange), 6, true, 600)),
  109. pear_tree => ("Pear Tree ", true, 4, 3, (effect.modify_material, material.enumeration'pos (material.pear), 6, true, 600)),
  110. peach_tree => ("Peach Tree ", true, 4, 3, (effect.modify_material, material.enumeration'pos (material.peach), 6, true, 600)),
  111. plum_tree => ("Plum Tree ", true, 4, 3, (effect.modify_material, material.enumeration'pos (material.plum), 6, true, 600))
  112. );
  113. month_name : constant array (1 .. 12) of core.unstring := (
  114. +("I <> Month of Red-Haired Goddess"),
  115. +("II <> Month of Xorana"),
  116. +("III <> Month of Heneal"),
  117. +("IV <> Month of Evelor"),
  118. +("V <> Month of Orohan"),
  119. +("VI <> Month of Aezora"),
  120. +("VII <> Month of Mitena"),
  121. +("VIII <> Month of Guarea"),
  122. +("IX <> Month of Kerena"),
  123. +("X <> Month of Uldrae"),
  124. +("XI <> Month of Kanako"),
  125. +("XII <> Month of Time-Rebirth")
  126. );
  127. week_name : constant array (1 .. 52) of core.unstring := (
  128. +("I <> Week of Miners"),
  129. +("II <> Week of Flora"),
  130. +("III <> Week of Alchemists"),
  131. +("IV <> Week of Shape"),
  132. +("V <> Week of Sword"),
  133. +("VI <> Week of Necromancers"),
  134. +("VII <> Week of Fauna"),
  135. +("VIII <> Week of --"),
  136. +("IX <> Week of Guards"),
  137. +("X <> Week of Blacksmiths"),
  138. +("XI <> Week of Archers"),
  139. +("XII <> Week of --"),
  140. +("XIII <> Week of Sound"),
  141. +("XIV <> Week of Water"),
  142. +("XV <> Week of Bankers"),
  143. +("XVI <> Week of --"),
  144. +("XVII <> Week of --"),
  145. +("XVIII <> Week of Thaumaturgs"),
  146. +("XIX <> Week of Stonecutters"),
  147. +("XX <> Week of --"),
  148. +("XXI <> Week of --"),
  149. +("XXII <> Week of Logic"),
  150. +("XXIII <> Week of Mystics"),
  151. +("XXIV <> Week of Diplomats"),
  152. +("XXV <> Week of Boots"),
  153. +("XXVI <> Week of Shield"),
  154. +("XXVII <> Week of Advisors"),
  155. +("XXVIII <> Week of Architects"),
  156. +("XXIX <> Week of Flame"),
  157. +("XXX <> Week of Value"),
  158. +("XXXI <> Week of Healers"),
  159. +("XXXII <> Week of Spear"),
  160. +("XXXIII <> Week of --"),
  161. +("XXXIV <> Week of Leaders"),
  162. +("XXXV <> Week of Skirmishers"),
  163. +("XXXVI <> Week of Lubmerjacks"),
  164. +("XXXVII <> Week of Pathfinders"),
  165. +("XXXVIII <> Week of --"),
  166. +("XXXIX <> Week of --"),
  167. +("XL <> Week of Helmet"),
  168. +("XLI <> Week of Leatherers"),
  169. +("XLII <> Week of --"),
  170. +("XLIII <> Week of --"),
  171. +("XLIV <> Week of Sorcerers"),
  172. +("XLV <> Week of Gloves"),
  173. +("XLVI <> Week of Earth"),
  174. +("XLVII <> Week of Explorers"),
  175. +("XLVIII <> Week of --"),
  176. +("XLIX <> Week of Strategists"),
  177. +("L <> Week of Gemologists"),
  178. +("LI <> Week of Merchants"),
  179. +("LII <> Week of World")
  180. );
  181. day_name : constant array (1 .. 7) of core.unstring := (
  182. +("I <> Day of Sun"),
  183. +("II <> Day of Mother-Moon"),
  184. +("III <> Day of Daughter-Moon"),
  185. +("IV <> Day of All-Earth"),
  186. +("V <> Day of All-Water"),
  187. +("VI <> Day of All-Sky"),
  188. +("VII <> Day of Deities")
  189. );
  190. map : definition;
  191. ------------------------------------------------------------------------------------------
  192. procedure configure;
  193. procedure make (index : in biome; width, height, chad_limit : in natural);
  194. procedure save (file_name : in string);
  195. procedure load (file_name : in string);
  196. procedure draw;
  197. procedure draw_performance_box;
  198. procedure mapshot (file_path : in string);
  199. function map_is_revealed return boolean;
  200. procedure add_chad (data : in chad.information);
  201. procedure resource_cheat_1;
  202. procedure resource_cheat_2;
  203. procedure resource_cheat_3;
  204. procedure resource_cheat_4;
  205. procedure resource_cheat_5;
  206. procedure resource_cheat_6;
  207. procedure reveal_map;
  208. procedure restore_points;
  209. procedure player_up;
  210. procedure player_down;
  211. procedure player_left;
  212. procedure player_right;
  213. ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  214. end world;