2023-10-15 09:08:31 -04:00
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-- Copyright (c) 2023 - Ognjen 'xolatile' Milan Robovic
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-- Xabina is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either
-- version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the
-- implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-- Experimental minimal terminal rogue-like game in Ada programming language. I used to write a lot of Ada programs some time ago, then went in full C and assembly mode, and came
-- back to Ada, but realized that I keep my folders messy... Since it's bothersome to find my old Ada projects and share them here, I decided that the most easy thing to do is to
-- write a new program in Ada, a tiny game. Work in progress, it's messy and ugly for now...
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
with ada.text_io ;
use ada.text_io ;
package core is
2023-10-15 10:01:21 -04:00
type colour_type is
record
grey : character := ' 0 ' ;
red : character := ' 1 ' ;
green : character := ' 2 ' ;
yellow : character := ' 3 ' ;
blue : character := ' 4 ' ;
pink : character := ' 5 ' ;
cyan : character := ' 6 ' ;
white : character := ' 7 ' ;
end record ;
type effect_type is
record
normal : character := ' 0 ' ;
bold : character := ' 1 ' ;
italic : character := ' 3 ' ;
underline : character := ' 4 ' ;
blink : character := ' 5 ' ;
contra : character := ' 7 ' ;
end record ;
2023-10-15 09:08:31 -04:00
CANCEL : constant character := character ' val ( 24 ) ;
CARRIAGE_RETURN : constant character := character ' val ( 10 ) ;
LINE_FEED : constant character := character ' val ( 13 ) ;
ESCAPE : constant character := character ' val ( 27 ) ;
------------------------------------------------------------------------------------------
procedure action_idle ;
type procedure_pointer is access procedure ;
type ascii_range is mod 2 * * 8 ;
type action_type is array ( ascii_range ) of procedure _pointer ;
type screen_width is mod 120 ;
type screen_height is mod 40 ;
type screen_type is array ( screen_height , screen_width ) of character ;
type description is new string ( 1 . . 144 ) ;
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-- Entity
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
type entity_list is (
ENTITY_NULL , ENTITY_MENU , ENTITY_MAP , ENTITY_ITEM , ENTITY_MAGIC , ENTITY_AMMUNITION , ENTITY_WEAPON , ENTITY_ARMOUR ,
2023-10-15 10:01:21 -04:00
ENTITY_SCROLL , ENTITY_POTION , ENTITY_CONSUMABLE , ENTITY_NOTE , ENTITY_PLANT , ENTITY_ANIMAL , ENTITY_MONSTER , ENTITY_PLAYER
2023-10-15 09:08:31 -04:00
) ;
------------------------------------------------------------------------------------------
type entity_constant_type is tagged
record
entity : entity_list := ENTITY_NULL ; -- Entity identifier.
name : string ( 1 . . 20 ) := "- " ; -- Entity general name.
symbol : character := ' ' ; -- Entity ASCII character representation.
2023-10-15 10:01:21 -04:00
colour : character := ' 7 ' ; -- Entity VT100 escape sequence colour.
effect : character := ' 0 ' ; -- Entity VT100 escape sequence effect.
2023-10-15 09:08:31 -04:00
end record ;
type entity_variable_type is tagged
record
x : integer := 0 ; -- Global X coordinate.
y : integer := 0 ; -- Global Y coordinate.
end record ;
type soul_type is
record
envy : natural := 0 ;
gluttony : natural := 0 ;
greed : natural := 0 ;
lust : natural := 0 ;
pride : natural := 0 ;
sloth : natural := 0 ;
wrath : natural := 0 ;
end record ;
type mind_type is
record
fear : natural := 0 ;
pain : natural := 0 ;
thirst : natural := 0 ;
hunger : natural := 0 ;
exhaustion : natural := 0 ;
solitude : natural := 0 ;
faith : natural := 0 ;
end record ;
type body_type is
record
head : natural := 0 ;
chest : natural := 0 ;
stomach : natural := 0 ;
left_arm : natural := 0 ;
right_arm : natural := 0 ;
left_leg : natural := 0 ;
right_leg : natural := 0 ;
end record ;
------------------------------------------------------------------------------------------
active : boolean := true ;
signal : character := ' ' ;
action_list : action_type := ( others => action_idle ' access ) ;
screen_symbol : screen_type := ( others => ( others => CANCEL ) ) ;
2023-10-15 10:01:21 -04:00
screen_colour : screen_type := ( others => ( others => ' 7 ' ) ) ;
screen_effect : screen_type := ( others => ( others => ' 0 ' ) ) ;
colour : colour_type ;
effect : effect_type ;
2023-10-15 09:08:31 -04:00
------------------------------------------------------------------------------------------
--~active := true;
--~signal := ' ';
--~action_list := (others => action_idle'access);
--~screen_symbol := (others => (others => CANCEL));
2023-10-15 10:01:21 -04:00
--~screen_colour := (others => (others => colour.white));
--~screen_effect := (others => (others => effect.normal));
2023-10-15 09:08:31 -04:00
------------------------------------------------------------------------------------------
--~active : boolean;
--~signal : character;
--~action_list : action_type;
--~screen_symbol : screen_type;
--~screen_colour : screen_type;
--~screen_effect : screen_type;
------------------------------------------------------------------------------------------
procedure bind ( symbol : character := CANCEL ;
action : procedure _pointer := action_idle ' access ) ;
procedure unbind ( symbol : character := CANCEL ) ;
procedure action_exit ;
procedure action_move_up ;
procedure action_move_down ;
procedure action_move_left ;
procedure action_move_right ;
procedure render_screen_delete ;
procedure render_screen_offset ;
procedure render_cursor_hide ;
procedure render_cursor_show ;
procedure render_realignment ;
procedure render_character ( symbol : character := ' ' ;
2023-10-15 10:01:21 -04:00
colour : character := ' 7 ' ;
effect : character := ' 0 ' ;
2023-10-15 09:08:31 -04:00
y : screen_height := 0 ;
x : screen_width := 0 ) ;
procedure render_screen ;
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-- Player
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
type trait_list is (
TRAIT_STRENGTH , TRAIT_PERCEPTION , TRAIT_EDURANCE , TRAIT_CHARISMA , TRAIT_INTELLIGENCE , TRAIT_AGILITY , TRAIT_LUCK , TRAIT_AUTISM
) ;
type skill_list is (
-- Combat skills.
SKILL_BLADES , SKILL_AXES , SKILL_MACES , SKILL_POLEARMS , SKILL_SHIELDS , SKILL_BOWS , SKILL_CROSSBOWS , SKILL_HANDS ,
SKILL_ONEHANDED , SKILL_TWOHANDED , SKILL_PRECISION , SKILL_THRUST , SKILL_ATHLETICS , SKILL_EQUITATION , SKILL_TACTICS , SKILL_SKIRMISH ,
-- Magic skills.
SKILL_FIRE_MAGIC , SKILL_WATER_MAGIC , SKILL_EARTH_MAGIC , SKILL_WIND_MAGIC , SKILL_NATURE_MAGIC , SKILL_VENOM_MAGIC , SKILL_SHADOW_MAGIC , SKILL_BONE_MAGIC ,
SKILL_RUNE_MAGIC , SKILL_PUPPET_MAGIC , SKILL_SUMMON_MAGIC , SKILL_INSECT_MAGIC , SKILL_RITUAL_MAGIC , SKILL_ROT_MAGIC , SKILL_TABBOO_MAGIC , SKILL_ABYSS_MAGIC ,
-- Trait skills.
SKILL_WISDOM , SKILL_PATIENCE , SKILL_RELIGION , SKILL_SPEECH , SKILL_REFLECTION , SKILL_REFRACTION , SKILL_AUTHORITY , SKILL_DECEPTION ,
SKILL_LIFE_FORCE , SKILL_MANA_FORCE , SKILL_REGENERATION , SKILL_RESTORATION , SKILL_SPELLCRAFT , SKILL_PROTECTION , SKILL_SYNTHESIS , SKILL_EVOCATION ,
-- Knowledge skills.
SKILL_MEDICINE , SKILL_MERCANTILE , SKILL_EDUCATION , SKILL_NAVIGATION , SKILL_CONJURATION , SKILL_ALTERATION , SKILL_ENCHANEMENT , SKILL_TELEPORTATION ,
SKILL_ASTRONOMY , SKILL_OCCULTISM , SKILL_MYSTICISM , SKILL_SURVIVAL , SKILL_EVASION , SKILL_STEALTH , SKILL_DETECTION , SKILL_IDENTIFICATION ,
-- Work skills.
SKILL_BLACKSMITH , SKILL_WHITESMITH , SKILL_LIGHT_CRAFT , SKILL_HEAVY_CRAFT , SKILL_LIGHT_WORKS , SKILL_HEAVY_WORKS , SKILL_LEATHER , SKILL_CONSTRUCTION ,
SKILL_WEAPONS , SKILL_ARMOURS , SKILL_ENGINEER , SKILL_ALCHEMY , SKILL_RITUAL , SKILL_EXPERIENCE , SKILL_NECROMANCY , SKILL_REINCARNATION
) ;
type title_list is (
TITLE_HERO , TITLE_DEMON_LORD , TITLE_DRAGON_SLAYER , TITLE_GOBLIN_SLAYER
) ;
type player_data is
record
--~x : map_width := 0;
--~y : map_height := 0;
x : screen_width := 0 ;
y : screen_height := 0 ;
health : natural := 0 ;
armour : natural := 0 ;
mana : natural := 0 ;
stamina : natural := 0 ;
end record ;
------------------------------------------------------------------------------------------
--~trait_info : constant array (trait_list) of description;
--~skill_info : constant array (skill_list) of description;
--~title_info : constant array (title_list) of description;
trait_info : constant array ( trait_list ) of description := (
" " ,
" " ,
" " ,
" " ,
" " ,
" " ,
" " ,
" "
) ;
-- Trying out descriptions, this adds nothing to gameplay really, might even remove this shit, for now it's bad and unaligned...
skill_info : constant array ( skill_list ) of description := (
"Blades: Master the art of wielding sharp-edged weapons like swords and daggers to deliver swift and precise strikes. " ,
"Axes: Become adept at swinging heavy battle axes and hatchets, crushing your enemies with sheer brute force. " ,
"Maces: Hone your skill with blunt weapons like maces and hammers, shattering bones and armor with powerful blows. " ,
"Polearms: Command long-reaching weapons like spears and halberds, keeping your foes at bay with deadly thrusts and sweeps. " ,
"Shields: Learn to effectively block and parry incoming attacks using different types of shields, ensuring your defense remains intact. " ,
"Bows: Master the art of archery, using bows to launch arrows with deadly accuracy from a distance. " ,
"Crossbows: Handle crossbows, powerful ranged weapons that can deliver devastating bolts to penetrate even the toughest armor. " ,
"Hands: Refine your unarmed combat skills, unleashing a flurry of punches, kicks, and grapples to overpower your opponents. " ,
"One-handed: Develop proficiency in wielding one-handed weapons, granting you versatility in combat with a free hand for defense or utility. " ,
"Two-handed: Embrace the raw power of massive two-handed weapons like greatswords and battle axes, obliterating foes with mighty strikes. " ,
"Precision: Cultivate your precision, increasing your chances of landing critical hits and striking vital points for maximum damage. " ,
"Thrust: Focus on the art of thrusting attacks, gaining the ability to pierce armor and penetrate deep into your adversaries' defenses. " ,
"Athletics: Strengthen your physical prowess, enhancing your speed, stamina, and agility for swift maneuvers and resilience in combat. " ,
"Equitation: Master the art of horse riding, enabling you to swiftly navigate the battlefield and engage enemies from mounted advantage. " ,
"Tactics: Develop strategic thinking and decision-making skills, enabling you to plan your actions and exploit your enemies' weaknesses. " ,
"Skirmish: Become adept in hit-and-run tactics, excelling in quick engagements where mobility, agility, and surprise are key to victory. " ,
"Fire Magic: Harness the power of flames, incinerating foes and wreaking havoc with infernal spells, but beware not to harm yourself. " ,
"Water Magic: Manipulate the currents of water and create it from the void, casting torrents and freezing enemies with chilling precision. " ,
"Earth Magic: Command the strength of the earth, crushing adversaries with seismic shocks and sturdy defenses. " ,
"Wind Magic: Control the swift breeze, unleashing gusts and tearing through enemies with razor-sharp projectiles or increase your speed. " ,
"Nature Magic: Channel the essence of the natural world, nurturing allies and summoning creatures of the wilderness. " ,
"Venom Magic: Inflict deadly toxins and poisons, weakening enemies and watching them succumb to vile venom, or weaken them and run away. " ,
"Shadow Magic: Embrace the darkness, concealing yourself in the shadows and draining life energy with sinister shadow spells. " ,
"Bone Magic: Manipulate the skeletal remnants of the deceased, raising undead minions and casting bone-shattering spells or healing ones. " ,
"Rune Magic: Inscribe and activate ancient runes, unleashing elemental forces and unraveling unseen and destructive ancient magical barriers. " ,
"Puppet Magic: Seize control of minds, bending the will of your enemies and forcing them to do your bidding or create a puppet to do it. " ,
"Summon Magic: Conjure ethereal allies and mythical creatures, bolstering your forces and overwhelming your foes. " ,
"Insect Magic: Command swarms of insects, inflicting agonizing stings and unleashing plague-like devastation, making allies of former foes. " ,
"Ritual Magic: Perform intricate and powerful sacrificial rituals to exchange life force for items, magic, scrolls, gold or power. " ,
"Rot Magic: Embrace decay and putrefaction, corroding the flesh of your enemies and spreading pestilence and plague. " ,
"Taboo Magic: Seek forbidden arts, delving into dark rituals and wielding forbidden spells with dire consequences, but be very careful. " ,
"Abyss Magic: Harness the eldritch forces from the depths of the abyss, unraveling reality and engulfing enemies in chaos. " ,
"Wisdom: Acquire profound knowledge and insight to navigate challenges wisely. " ,
"Patience: Endure and persevere through trials with calmness and resilience. " ,
"Religion: Channel divine power through faith and devotion to overcome obstacles. " ,
"Speech: Persuasively communicate thoughts and ideas, influencing others effectively. " ,
"Reflection: Engage in self-analysis, learning from experiences for personal growth. " ,
"Refraction: Bend and manipulate the flow of energy to alter its course. " ,
"Authority: Command respect, possess leadership skills, and wield influence. " ,
"Deception: Master the art of trickery and illusion to deceive opponents cunningly. " ,
"Life Force: Harness the essence of vitality to sustain and strengthen oneself. " ,
"Mana Force: Manipulate and control magical energy for various purposes. " ,
"Regeneration: Restore health and vitality gradually and naturally over time. " ,
"Restoration: Mend and heal wounds, restoring physical and spiritual well-being. " ,
"Spellcraft: Master the intricate art of casting spells with precision and expertise. " ,
"Protection: Shield oneself and allies, providing defense against harm and danger. " ,
"Synthesis: Combine elements harmoniously, creating powerful and synergistic effects. " ,
"Evocation: Summon and command mystical forces, unleashing their power and potential. " ,
"Medicine: Heal wounds and cure ailments, preserving health and vitality. " ,
"Mercantile: Master the art of trade and negotiation, obtaining valuable resources and goods. " ,
"Education: Expand knowledge and gain expertise in various subjects, unlocking new possibilities. " ,
"Navigation: Navigate through treacherous terrains, uncovering hidden paths and shortcuts. " ,
"Conjuration: Summon and command ethereal beings and objects to aid in battle and exploration. " ,
"Alteration: Manipulate and reshape the physical world, bending it to your will. " ,
"Enchantment: Infuse objects with magical properties, enhancing their abilities and powers. " ,
"Teleportation: Instantly transport yourself across distances, bypassing obstacles and traps. " ,
"Astronomy: Study celestial bodies and their movements, unlocking celestial insights and abilities. " ,
"Occultism: Harness forbidden knowledge and practices, tapping into dark and mysterious forces. " ,
"Mysticism: Connect with spiritual realms, accessing mystical powers and ancient wisdom. " ,
"Survival: Thrive in harsh environments, utilizing nature's resources and adapting to challenges. " ,
"Evasion: Evade and dodge attacks with exceptional reflexes and agility. " ,
"Stealth: Move silently and remain undetected, infiltrating enemy territories with stealth and precision. " ,
"Detection: Uncover hidden secrets and traps, perceive hidden objects and enemies. " ,
"Identification: Identify and analyze unknown items and artifacts, revealing their true nature and potential. " ,
"Blacksmith: Master the art of forging and shaping metals, crafting powerful weapons and armor. " ,
"Whitesmith: Refine and enhance crafted items, imbuing them with special properties and bonuses. " ,
"Light Craft: Create delicate and intricate objects, such as jewelry and trinkets, with finesse and precision. " ,
"Heavy Craft: Construct robust and durable structures, fortifying defenses and creating formidable tools. " ,
"Light Works: Skillfully manipulate light and optics, creating illusions and harnessing blinding brilliance. " ,
"Heavy Works: Command elemental forces and harness their raw power, shaping them for destruction or creation. " ,
"Leather: Tame and work with animal hides, fashioning resilient armor and accessories. " ,
"Construction: Design and erect structures, fortresses, and defenses in an efficient and strategic manner. " ,
"Weapons: Wield a wide array of lethal weapons, mastering various combat styles and techniques. " ,
"Armours: Forge resilient armor and protective gear, shielding against incoming threats and attacks. " ,
"Engineer: Innovate and create mechanical wonders, building intricate contraptions and mechanisms. " ,
"Alchemy: Transmute and brew potent elixirs and potions, unlocking the power of transformative substances. " ,
"Ritual: Perform ancient rituals, invoking otherworldly energies to manipulate reality itself. " ,
"Experience: Draw upon accumulated knowledge and insights, gaining wisdom and enhancing abilities. " ,
"Necromancy: Command the forces of death and undeath, bending the deceased to your will. " ,
"Reincarnation: Manipulate the cycle of life and death, granting second chances and renewed existence. "
) ;
title_info : constant array ( title_list ) of description := (
" " ,
" " ,
" " ,
" "
) ;
player : player_data ;
procedure render_player ;
end core ;