Undertale Boss Battles Script
Undertale, the critically acclaimed indie RPG, has captivated players with its engaging storyline, memorable characters, and unique gameplay mechanics. One of the most distinctive aspects of Undertale is its boss battles, which deviate from traditional turn-based combat. In this blog post, we'll dive into the script behind Undertale's boss battles, exploring the code that brings these encounters to life.
If Sans had a specific attack pattern that could be described with math, for example:
$$ \textDamage = 10 \times \textAttack Power $$
This could be part of a strategy discussion.
ACT commands:
const actCommands =
"Check": () => showBossStats(),
"Flirt": () =>
if (boss.name === "Papyrus") boss.spareProgress += 30;
showText("* You flirt. Papyrus blushes.");
,
"Threaten": () =>
boss.dialog = "* ...?";
boss.spareProgress -= 10;
;
Spare condition:
function checkSpare()
if (boss.spareProgress >= 100 && boss.spareEnabled)
endBattle("SPARED");
A script is more than code; it's a story. When writing the storyboard for your boss, follow the Undertale three-act structure:
This basic script provides a structure for understanding the flow of a boss battle in Undertale. Each battle in the game is meticulously crafted to offer a unique experience that often questions the morality of the player's actions.
Feature: "Emotional Resonance" System
In this feature, the player's actions and emotions affect the boss battle. The boss, Papyrus's older brother, Undyne, has a meter that fills up as the player attacks or uses certain actions. The meter has three stages, each representing Undyne's emotional state:
The player can affect Undyne's emotional state by: Undertale Boss Battles Script
As Undyne's emotional state changes, the battle's music, sound effects, and even the visuals change to reflect her mood. The player's goal is to navigate Undyne's emotions and find a way to resolve the battle without causing her too much trauma.
Example Script
Here's a small example of how this feature could play out in a battle:
**Battle Begins**
You face Undyne, the head of the Royal Guard. She looks focused, but you sense a hint of anxiety.
Undyne's Emotional Resonance: [Calm]
**Your Turn**
1. Attack
2. Use a non-violent action (e.g., "Talk")
3. Show Mercy
Choose your action:
**If you choose to Attack**
Undyne's Emotional Resonance: [Agitated]
Undyne charges at you with her spear! You dodge, but she quickly recovers and strikes again.
**If you choose to Show Mercy**
Undyne's Emotional Resonance: [Calm]
Undyne pauses, looking surprised. "You... won't fight me?" she asks.
**If you choose to Use a non-violent action (e.g., "Talk")**
Undyne's Emotional Resonance: [Agitated]
You try to reason with Undyne, but she becomes frustrated. "You think you can just talk your way out of this? I'll show you my strength!"
This feature adds a new layer of depth to the battle, as the player must consider the emotional consequences of their actions. It also creates opportunities for interesting storytelling and character development, as the player's choices affect Undyne's emotional state and backstory.
How do you like this feature? Would you like to add any other mechanics or ideas to the script? Spare condition: function checkSpare() if (boss
Toriel intentionally aims her fire magic away from you. Script her attack with a conditional if player_hp < 3.
Pseudocode:
toriel_attack()
let pattern = [];
if (player.hp <= 3 && !toriel.has_warned)
toriel.say("I apologize, my child.");
toriel.aim_offset = 20; // pixels away from soul
toriel.has_warned = true;
for (let i=0; i<5; i++)
pattern.push(fireball(target.x + random(-10,10), target.y - 50));
return pattern;
❌ No delay between text & attacks → Player misses dodge
✅ Add wait(0.5) after dialogue
❌ ACT options do nothing → Breaks mercy system
✅ Every ACT must affect mercy meter or enemy behavior
❌ Soul moves out of battle box → Player can’t get hit
✅ Clamp soul position every frame A script is more than code; it's a story
❌ Spare available immediately → No challenge
✅ Require 2-3 ACTs before spare possible