Roguelikes, turns and tactics
The Roguelike template
Section titled “The Roguelike template”The Roguelike template is a menu showing the deepest floor reached, with Play and Quit, and a Crypt scene made anew every game by a Dungeon Generator (Seed 0) on a tilemap of stone walls and flagstone floors: the hero starts in the first room and the stairs wait in the furthest, with three or four slimes, a bat or two, a potion or two and some gold scattered through the other rooms. It’s turn-based: the hero steps a cell a turn (Tab waits one), and every monster steps or hits once after. The hero walks into monsters to fight them (a Bump Attack, two hits for a slime, one for a bat); slimes (Prefabs/Slime.prefab) notice the hero within five cells if they can see them, bats (Prefabs/Bat.prefab) anywhere within eight, flying diagonally, and either hits the hero by walking into them. Gold counts up, potions go in the hero’s inventory and 1 drinks one (four hit points back). The stairs make the next floor, keeping the hero’s health and potions. The HUD shows the hero’s health bar, the floor (a counter of the Output Floor, keeping the deepest), gold and potions; it’s dark but for the hero’s lantern. A You Died panel opens on the hero’s Death Message Game Over with the floor reached and the deepest, Again and Menu, and the pause menu is there too, with no scripts.
Entity → Gameplay → Turn Order makes a game turn-based: a Turn Order whose text in the top-right corner says whose turn it is, and an End Turn button in the bottom-right corner. Its Teams take turns in order (Player, Enemy, or Blue, Red for two people at one keyboard), and whatever acts gets a Turn Taker naming its Team (or, with its Team left empty, whatever else puts it on a team: a Team on it or on the entity it’s inside). They’re the teams every genre shares (see Teams), so a strategy faction, a card hand or a platformer’s hero on the team Red takes Red’s turns, and scenes saved when they were called Sides and Side still load. Off its team’s turn, a turn taker waits: the player’s keys don’t reach it (nor its scripts’ Input), and its Patrol, Chase, Grid Chase, Grid Patrol, Attack and Shooter hold still. It still falls, gets pushed and gets hurt, and everything with no turn taker (moving platforms, particles, a ball still rolling) runs in real time as ever, so a turn can be a stretch of real-time play, as in Worms. A person’s turn ends when they press End Turn (Tab or the gamepad’s Back: its End Action) or click a button whose Action is End Turn (faded while they can’t), or when its Turn Time runs out (0 waits for them). The Computer Teams (Enemy) can’t be ended that way: their turn lasts Computer Turn Time seconds, long enough for patrols to walk and turrets to fire. Give a turn taker Actions to limit what it does in a turn: each attack swing and each shot uses one (scripts use them with Act()), it waits once it has used them, and once everyone on a team has, the turn passes by itself. Between turns nobody acts for a moment, so a last shot lands. A team with nobody left is skipped, and once a team that had turn takers loses the last of them it’s beaten: its Defeat Message goes out once ({0}Defeated: RedDefeated, with the team as its data), for a Victory or Defeat panel to open on. Each turn sends its Message ({0}Turn: PlayerTurn, then EnemyTurn, with the team as its data, so a panel or a sound player can greet it) and plays its Sound; its Format fills its text ({0}'s turn, with {1} the Round and {2} the seconds left). Current, Round, Time Left and each turn taker’s Actions Used are saved with the scene, so rewinding goes back to whose turn it was. In a network game the host runs the turns, and with the Multiplayer’s Teams each player’s character is on its player’s team (the same Blue, Red teams); only the players on that team can end its turn. A turn order covers the whole scene, or with Within (an entity’s name) only what’s inside that entity or standing in its area: a turn-based arena in a real-time game, or two boards each taking their own turns. A turn taker takes turns in the turn order whose Within covers it, else in one over the whole scene, and one covered by none acts freely; something that walks into the arena joins its turns and walks out of them as it leaves. End Turn ends the turn of each turn order a person may end, and an End Turn button that of the one whose Within it’s in (see Mixing genres).
Roguelike turns
Section titled “Roguelike turns”On a grid, a turn taker with Actions takes turns a step at a time: each step of its Grid Movement uses an action (bumping a wall doesn’t), and a Grid Chase or Grid Patrol steps once an action, passing when it has nowhere to go (out of range, waiting at a point, blocked) and nothing to swing at, so its team’s turn ends straight away rather than after Computer Turn Time. With one action each and Between at 0, everything moves when the player moves: the player steps, every enemy steps (or swings) once, and it’s the player’s turn again, the steps gliding at the same time. A swing lands before its team’s turn passes, so a monster’s blow can’t be dodged by stepping away; the next turn also waits for a mover still gliding from its last step, so play goes at the pace of the slowest mover. Holding a way walks a step a turn, a way pressed while the computer takes its turn is taken as the turn comes back, and Tab (End Turn) waits a turn. A grid patrol waits whole turns at its points (its Wait, rounded up). A Turn Order made in a scene with grid movers sets all this up: each grid mover gets a turn taker with one action (players on the first team a person plays, chasers and patrols on the first the computer plays), Between is 0, the text counts turns (Turn {1}) and the button says Wait; grid players and enemies made after it take turns too. Online, a player’s step on their own machine is their action on the host.
Tactics
Section titled “Tactics”Entity → Genres → Tactics → Tactics Unit makes a unit for a tactics game: a box in its team’s color with a Grid Movement, a Health of 3, a Tactics Unit and a Turn Taker with one action, on whichever team has the fewest units so far (so making four gives two even teams, Blue down the left and Red down the right). In a scene with no turn order it also makes one (Blue, Red, with the computer playing Red, and an End Turn button), and a Tactics Controls to pick units with. On your team’s turn, click one of your units: the cells it can walk to light up blue (up to its Move, 4, around walls and other units, which block friend and foe alike), and the cells it could hit from them red (things from Min Range to Range steps away, 1 for a sword; an archer is Range 3, Min Range 2; ranges reach over walls). Hover a cell to see the way it would go, and click it to walk there. Then click a foe in reach to attack it (its Damage, with an Attack Sound, a Hit Effect and a Hit Stop), or the unit itself to wait; with nothing in reach it’s done as soon as it gets there. Clicking a foe straight away walks up to the nearest cell it can hit it from and attacks. A right click (or Cancel, Shift or the gamepad’s B) takes the walk back, or lets the unit go. Attacking or waiting uses the unit’s action, it’s dimmed (Done Tint) until its team’s next turn, and once every unit on the team has had its go the turn passes. Hovering any unit shows faintly how far it reaches, health bars sit under the units, and the arrow keys or the stick move a cursor that Space (or the gamepad’s A) clicks with (Confirm Action and Cancel Action), all colored to taste. A unit’s foes are the units on other teams and anything else with health on another team (a platformer’s hero who joined Red is a foe of Blue’s units), or with Layers set, whatever has health on them (a gate to break down). Scripts read a unit’s Reachable, Targets, Can Act and Is Done, give it orders with MoveTo((x, y)), Attack(entity), Wait() and UndoMove(), hear Moved, Attacked and Done, and pick a unit with the controls’ Selected. With no code, its Wait and Undo Move actions end its go or take its walk back (a trigger on the beat, a card), and its Moved, Can Act and Done outputs show where it is in its go. Whether a unit has moved is saved, so rewinds keep its go; online the host moves the units and each player picks on their own screen, their clicks sent to the host.
The computer’s team in tactics
Section titled “The computer’s team in tactics”On a team the turn order’s Computer Teams names (Red, when a Tactics Unit made the turn order; clear it for two people at one keyboard), the computer takes each unit’s go in turn, the unit nearest a foe first: its reach lights up for the controls’ Computer Pause (0.5 seconds) so you can see what’s coming, then it attacks the best foe it can reach with a walk and a hit (one it can finish off first, then the weakest, then the nearest), walking up to it, or with nothing in reach walks as far as it can toward the nearest foe, around walls. Each unit’s Stance says how it plays: Charge (always comes at you), Guard (stays put until you come within a walk and a hit of it) or Hold (never walks, only attacking what’s already in range: a tower, an archer on a wall). Set the turn order’s Computer Turn Time to 0 (as a Tactics Unit’s turn order has it) so its turn lasts as long as its units need. The host plays the computer’s team in a network game.
The Tactics template
Section titled “The Tactics template”The Tactics template is a menu (Play and Quit) and a Battle on a field of grass with trees and rocks in the way, painted on a tilemap: your two knights (Move 4, 6 hit points, 2 damage up close) and two archers (Move 3, shooting two or three cells off) start on the left, and the computer’s three orcs (charging), a goblin archer guarding the far side and another holding the rocks start on the right. It’s played as the Tactics section above says, Blue first; the turn text counts the rounds ({0}'s turn · Round {1}), health bars show who’s hurt, and hits throw sparks with swings and shots to hear. Beat every orc and goblin and Victory opens (on RedDefeated, the turn order’s Defeat Message); lose all four of yours and it’s Defeat (BlueDefeated). Both offer Again and Menu, and the pause menu is there too, with no scripts.
RPG battles
Section titled “RPG battles”A Battler is a fighter in a turn-based battle, as in an RPG, with no code. Give an entity a Health, a Battler and a Turn Taker (1 action), set its Foe (Enemy, or Knight, Mage for a party: it goes for the first still standing; empty fights the first battler standing on another team), and on its turn it makes one move: an Attack (its Damage, or Damage Roll dice rolled each hit, less the foe’s Armor, never below 1), its Spell (Spell Cost paid from its Mana, which Mana Per Turn tops up as each turn starts; Spell Damage to the foe through armor, Spell Heal to itself, each with dice of its own) or one of its Items (the Item’s Item Heal, Item Mana or Item Damage: a potion, an ether, a bomb). Each move uses its turn taker’s action, so the turn passes by itself; a move it can’t make (no mana, nothing left) is said and uses nothing.
The player’s fighter moves when its actions are done: Attack, Cast Spell and Use Item, by buttons whose Action is Do (faded while it can’t), triggers, wires or Game.Do, or by its own Attack Action, Spell Action and Item Action keys while it’s Controllable (it has focus, like any piece that takes the player’s input). On a team its Turn Order’s Computer Teams names, it picks for itself after Think Time: it heals when its health is under Heal Below (an item, or a spell that heals), casts while it has the mana and the spell hits at least as hard as an attack, throws an item that hits harder still, and otherwise attacks. What it last did is its Said output (Elf Mage casts Fireball on Orc: 24 damage.), with Title (what it’s called), Mana, Spell, Spell Cost, Item and Items to show on texts and bars beside it. Its numbers are made to come from tables: a Table Values beside it sets them from a class’s or an enemy’s row, and a balance simulation plays the same fight thousands of times (see Tables of game data). In a network game the host carries out the moves.
The RPG Stats template
Section titled “The RPG Stats template”The RPG Stats template is a menu where left and right pick a Class (Knight, Mage, Rogue or Cleric) and a Foe (Slime, Goblin, Skeleton, Orc or Wyvern), and a Battle on a meadow at dusk between them: the hero on the left, the foe on the right with its name, health bar and the line it last said. You go first: 1 attacks, 2 casts your class’s spell, 3 uses its item (or click the buttons, which fade on the foe’s turn and when you haven’t the mana or the item), and the computer plays the foe. Win and Victory opens with what the foe was worth, read from its row; fall and it’s Defeat; both offer Again and Menu, and the pause menu is there too. Every number in the fight comes from the game’s tables through Table Values, and a Balance simulation is ready to run on them: Tables of game data walks through both.
Dungeons
Section titled “Dungeons”Entity → Genres → Dungeons → Dungeon makes a dungeon: a tilemap with a Dungeon Generator, 48 cells across (Width) and 32 down (Height), centered in the view and showing a dungeon made from a new seed, its rooms and corridors cut from solid wall so they show without a tileset. As the game starts it fills its tilemap with a new floor: up to Rooms (9) rooms, each Min Room Size to Max Room Size cells across and down, a wall apart, joined by corridors Corridor Width wide (each room to its nearest, so they’re short), plus Loops more between rooms already joined, so there’s more than one way round. Floors are Floor Tile (-1 leaves them empty; list a floor tile in the tilemap’s Background Tiles so nothing collides with it) and the cells round them Wall Tile, a row deep, or everything else with Fill Walls. The entities named in Players (Player) are put in the middle of the first room, the Exit (a staircase, say) in the room the longest walk from it, and Spawns are scattered through the other rooms, one per line: a prefab and how many (Enemy 4, Potion 1-2 picks a number between, Gold is one), never on the exit or each other. A player stepping onto the exit’s cell (once a grid mover’s step ends) goes down to the next floor (untick Descend On Exit to go only when told): a new dungeon, the last floor’s spawns cleared away, the players in the new first room. So does sending its Next Floor Message (say Next Floor, from a button or a script). Floor counts the floors, and each one after the first plays Floor Sound and sends Floor Message (Floor, with 1). A Counter counting the Output Floor shows the floor (Floor {0}), even in a panel that was closed as the floors went by, and with Save Best As keeps the deepest. The same Seed always makes the same dungeon, each floor its own; 0 (to begin with) makes a new one every game. Entity → Generate Dungeon makes the selected dungeon in the editor to see it, putting the players and exit in place as one undo step (with Seed 0, a new one each time; the game still makes its own). Untick Generate On Play to play the map as painted, with the floors after it made. Spawns go inside a Spawns entity in the dungeon’s. Scripts call NextFloor() and Generate() (this floor again), read RoomList, RoomAt(x, y), ExitCell and UsedSeed, and hear Generated. The tiles and Floor are saved with the scene, so a rewind goes back to the floor it was on. In a network game the host makes the floors and everyone sees them.