Game::Xomb - a game featuring @ versus the Xarci Bedo
Xomb is a terminal-based roguelike. Assuming that the development tools (C99 support is required), perl(1), App::cpanminus, and optionally local::lib are installed and setup in a suitable terminal install and run the game via:
cpanm Game::Xomb xomb
? key in game to show the help text. The xomb documentation details other useful game information; it should be available once the module is installed via:
The remainder of this documentation concerns internal details likely only of interest to someone who wants to modify the source code.
The game is data oriented in design; adding a new floor tile would require a new
SPECIES constant, suitable entries in
@Level_Features, and then any additional code for passive effects or whatever. Various routines may need adjustment for a new floor type as there is not a good component system to indicate whether a floor tile is solid, dangerous, etc. A new monster would require similar additions, and would need a custom update_* function for when that critter has an action to make.
Only the player can move, so much of the code assumes that. New player actions would need to be added to
%Key_Commands and suitable code added to carry out the new action.
All entropy comes from the JSF random number generator (see
src/jsf.c). The perl built-in
rand function MUST NOT be used; instead use irand, roll, or one of the other utility functions that call into the JSF code.
There are tests for some of the code, see the
t directory in the module's distribution.
Called by the movement code to determine whether the run should be aborted, e.g. before the player steps to a pool of acid.
$Stickyindicates whether a run is in progress, and runs are caused by the move_player_runner or move_player_snooze functions, see
Removes hitpoints from the given animate, with complications to report the damage and to mark the game as over (for the player) or otherwise the monster as dead. Calls over to
%Damage_Fromtable entries which return the damage as appropriate for the arguments.
- at at_col at_row
These routines move the cursor around the terminal. at takes arguments in col,row (x,y) form.
Floor tiles can have passive effects that can vary depending on the duration the player is within the cell, or could be a message to the player. See passive_burn, passive_msg_maker.
Waits for the player to quit usually from a submenu.
$RKFNholds the function that read keys; these could either come from
STDINor from a save game file.
Indicates whether a terminal exists and is of suitable dimensions.
Called when something goes horribly wrong, usually on fatal signal or internal error.
clampfrom the Common LISP Alexandria library.
- bypair callback list ...
Calls the callback function with pairs of items from the given list of items.
1. Uses the JSF random number generator (see
Returns a string usually shown in the status bar consisting of the
VEGGIE(item, if any) and
MINERAL(floor tile) of the cell the player is in.
Returns a string that prints the player's shield points in the status bar.
Returns a string that prints whether and if so what
VEGGIEis being used to regenerate the shield.
Pythagorean distance between two cells, with rounding. Will differ in some cases from the Chebyshev distance that the linecb and walkcb line functions use for an iterations count.
Whether or not the given weapon hits at the given distance, and what the cost of that move was. The cost will be higher if the target is out of range so that the animate will not wake up until the player can be in range.
Removes a random element from the given array reference and returns it. Uses the JSF random number generator (see
Note that the original order of the array reference will not be preserved. If that order is important, do not use this call. Order preserving extraction can be done with:
... = splice @array, irand(scalar @array), 1;
Shuffles an array reference in place. Uses the JSF random number generator (see
Entry point to the game, see
bin/xombfor how this gets called and what needs to be setup before that. Loops using a simple integer based energy system over active animates and calls the update function for each on that gets a go, plus some complications to change the level, etc.
Called when the game needs to exit for various reasons mostly unrelated to gameplay (terminal size too small, fatal signal).
Generates a level map around where the player is. Various knobs can be found in
Reads a key from the terminal until one in the hash of valid choices is entered. See also
Whether the player is carrying (or has equiped) the Amulet.
Exits game with death screen and score.
Exits game with win screen and score. Should be the only
0exit status of the game.
In game information on keyboard command available
Sets the seed for the JSF random number generator (see
Initial setup of the
@LMap. This is in row,col form though points use the col,row form. Each cell (
ANIMALslots that contain a col,row point for the cell, the floor tile, item (if any), and animate (if any).
- irand max
Integer random value between
max - 1. Uses the JSF random number generator (see
- linecb callback x0 y0 x1 y1
Bresenham line function with some features to keep it from going off of the map and to skip the first point and to abort should the callback return
Used to bold -> normal -> faint cycle log the most recent message (shown at the top of the screen) depending on the age of the message.
Adds a message to the log and displays it at the top of the screen.
Returns the value of the loot the player is carrying.
Creates the amulet and returns it.
Creates a gem and returns it.
Creates a monster and returns it. Suitable parameters must be supplied.
Creates the player, places them into the
HEROslot of the
@Animatesarray, and returns the col,row starting position of the player. generate_map builds the level map around this position.
A far too complicated routine to inspect, drop, or equip items in the inventory list.
Moves the player around the level map, with various game related complications. See
Drops an item from the inventory.
Equips an item from the inventory.
Lets the player move the cursor around the level map to inspect various features.
For when the player climbs down the "stairs".
For when the player tries to climb up the "stairs".
For when the player rests for a turn.
Picks an item (if any) up off of the level map.
Creates a function suitable for moving the player in a particular direction. See
Creates a function suitable for running the player in a particular direction.
Creates a function suitable for resting with over multiple turns.
Prompts whether they want to quit the game.
Unequips an item (if any).
Query the player whether they want to carry out some dangerous move.
- onein max
Returns true if the RNG rolls
0within max. Uses the JSF random number generator (see
Apply acid damage because the player is in a pool of acid.
Returns a subroutine that issues a message when a cell is entered into. The cell should probably be made unique with reify first as otherwise all floor tiles of that type will share the same update routine.
- pathable col row points ...
Ensures that a path exists between the given coordinates and the given list of points; used by generate_map to ensure that the player can reach all the gates and gems.
Picks a random item from the given array reference. Uses the JSF random number generator (see
Clears the PKC error code from the status bar.
Prints a PKC error code in the status bar.
Used by generate_map to place floor tiles somewhat randomly (brown noise) around the level map, as controlled by
Creates and places a monster onto the level map, and that the monster has not been placed above a hole or in acid.
Displays and applies splash damage from Fungi attacks.
Calculates the FOV for the player and updates various related variables such as what monsters are visible.
Reduces a map cell floor tile to
RUBBLE. Some monsters can destroy walls.
Redraw the level map, status bar, and previous message if any.
Marks a particular level map item (
MINERAL, typically) as unique, usually so that a passive_msg_maker can be applied to it.
Handles moving the player from one level map cell to another.
Replays commands from a save game file. See also
Logs a message showing where the player is on the level map.
Logs a message with the game version, seed, and current turn number.
Gets the terminal out of raw mode and more back to normal.
- roll times sides
Dice rolling, so
roll(3,6). Uses the JSF random number generator (see
Slow the player down when they move in (or into, or out of) rubble.
Update the energy cost of the last move.
Returns a string with the game score in it.
Show all the recent messages in the message log.
Prints the status bar at the bottom of the screen.
Prints the most recent log message at the top of the screen.
UPDATEfunction for fungi.
UPDATEfunction for when the player is dead.
UPDATEfunction for ghast.
UPDATEfunction for mimics.
UPDATEfunction for the player. Failed moves (zero-cost things) are looped over until a move that costs energy is made. Input comes from the
$RKFNwhich is usually a function that reads from standard input.
UPDATEfunction for stalkers.
UPDATEfunction for trolls.
Uses an item, possibly swapping it with some existing item.
Returns a string with the name and value of a vegetable (a gem, or the amulet).
Like linecb but continues until the edge of the level map or until the callback function returns
- with_adjacent col row callback
Runs the callback function for each cell adjacent to the given coordinates that is within the level map.
HP 100 You plunge into the hole. HP -140314714594444
'tis but a flesh wound.
Game::PlatformsOfPeril from which this code evolved.
7DRL 2020 - https://itch.io/jam/7drl-challenge-2020
Vektor - Terminal Redux
Copyright (C) 2020 by Jeremy Mates
This program is distributed under the (Revised) BSD License: http://www.opensource.org/licenses/BSD-3-Clause
src directory code appears to be under a "I wrote this PRNG. I place it in the public domain." license: