Undertale Boss Battles Script -

START Battle
  Load BossData (HP, Attack, Defense, Name, Dialog)
  PlayerTurn = TRUE

LOOP while (Boss.HP > 0 AND Player.HP > 0): IF PlayerTurn: Display "ACT", "FIGHT", "ITEM", "MERCY" HandlePlayerChoice() ApplyEffects() PlayerTurn = FALSE ELSE: ChooseBossAttack() StartBulletPattern() ApplyDamageToPlayer() PlayerTurn = TRUE END LOOP

IF Player.HP <= 0: GameOver() ELSE: SpareOrKillCheck() END



  "encounter": "papyrus",
  "pacifist_dialogue": [
    "BEHOLD! THE GREAT PAPYRUS!",
    "I WILL CAPTURE YOU FOR THE ROYAL GUARD!",
    "...BUT YOU CAN SURRENDER IF YOU WANT."
  ],
  "genocide_dialogue": [
    "HUMAN... YOU'VE BEEN HURTING EVERYONE.",
    "I WON'T LET YOU GO ANY FURTHER.",
    "FOR THE UNDERGROUND!"
  ],
  "mid_battle_barks": 
    "act_silly": "STOP BEING SILLY!",
    "flirt": "WOWIE! YOU'RE FLIRTING WITH ME?",
    "spare_attempt_low_mercy": "I CAN'T ACCEPT YOUR SPARE YET."

Script tip: Use a coroutine or state machine to manage dialogue interlaced with attack patterns. Example: state = "attack" → state = "dialog" → display line → resume attack. Undertale Boss Battles Script


The iconic sparing system requires tracking hidden variables.
Example pseudo-script for Toriel:

if (act_used == "talk" && talk_count >= 3) 
    mercy_value += 30;
if (mercy_value >= 100) 
    spare_possible = true;

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;

| Boss | Special Mechanic Script | |-----------|----------------------------------------------------| | Toriel| Fire spells avoid you if HP low | | Papyrus| Blue attack (can't move through blue bones) | | Undyne| Green mode (shield blocking) + Spear patterns | | Mettaton| Rating system (ACTs increase rating for spare) | | Sans | Karma, dodge attacks, gravity, final attack spam |


Most people think the "script" refers to code. But in the context of SEO and narrative design, the Undertale Boss Battles Script also refers to the dialogue and dramatic timing.

You need a cutscene manager.

// Script: battle_cutscene.gml
function execute_dialogue_step(step)
    switch(step)
        case 0:
            talk("You think you can take me?", "sans_sprite_smirk");
            cutscene_wait = 45;
            break;
        case 1:
            talk("Let's see what you've got.", "sans_sprite_eye_lit");
            camera_shake(5);
            break;
        case 2:
            // Resume battle
            battle_active = true;
            break;

The first major boss, Toriel, sets the tone for the entire game. The player is conditioned to believe that to progress, the obstacle must be destroyed.

If the player chooses to fight, the game delivers a gut-punch. A single, accidental critical hit reduces Toriel to ash in seconds. The game stops. The music cuts. The realization hits: I didn't have to do that.

For players who refuse to fight, the battle is a test of endurance. It forces the player to confront a mother figure who is trying to protect them through imprisonment. It is the first lesson: Mercy is harder than Violence. This boss fight scripts the central thesis of the game early on—violence is the easy path, but it comes with a heavy cost. START Battle Load BossData (HP, Attack, Defense, Name,