<!-- Your starting passage should initialize all of the global variables you are going to use. Specific enemy HP and item variables can be added and removed at your discretion. The maxHP and HP variables should be the same, and it is up to you whether or not the player has the items, or how much gold they get to start with. -->
(set: $kills to 0)
(set: $victories to 0)
(set: $losses to 0)
(set: $gold to 0)
(set: $LV to 1)
(set: $EXP to 0)
(set: $maxHP to 20)
(set: $HP to 20)
(set: $Candle_Grandma_MAX_HP to 129)
(set: $birthdaybear to true)
(set: $sunglasses to true)
(set: $cake to false)
(set: $Candle_Grandma_KILLED to false) <!-- this type of enemy-tracking variable is optional, and should be used only if you want to keep track of if a certain enemy has been killed. -->
(goto: "Name Selection") <!-- the player doesn’t need to know that these all got set, so bring them directly to your name selection passage, or first story passage (whatever that may be) --><!-- this optional passage simply prompts the player to choose their name, before moving on to the next passage, which is probably your first story passage or whatever. -->
(set: $name to (prompt: "Choose a Name.", "Chara"))(goto: "Home")<!-- if your battle system is standalone (not part of a story) and lets players battle multiple enemies, you might want to add a passage like this. NOTE: if you are going to have more than one battle happen in your Twine story, whether it’s a standalone battle system OR part of a larger story, you MUST reset the $damage and $turns variables to 0 after the battle is done to avoid errors!!! It’s up to you whether you want to reset the player back to full HP. If you’re going to make it so that the different enemies can be battled more than once (e.g. minor enemies that there are multiple of), you should reset their HP to their max as well. If you are tracking whether that enemy has been killed and don’t want the player to be able to encounter them again, there’s no need to reset their HP… -->
\(set: $turns to 0)
\(set: $HP to $maxHP)
\(set: $Candle_Grandma_HP to $Candle_Grandma_MAX_HP)
\(set: $ask to 0)
\(set: $crush to 0)
\(set: $talk to 0)
\$name <!-- displays the player’s name -->
Victories: $victories <!-- displays the number of victories -->
Losses: $losses <!-- displays the number of losses -->
Kills: $kills <!-- displays the number of enemies you’ve killed -->
EXP: $EXP <!-- displays your current EXP -->
LV: $LV <!-- displays your current LOVE -->
Gold: $gold <!-- displays the amount of gold you have -->
\(if: $Candle_Grandma_KILLED is false)[
\ [[Start a battle|CANDLE]]]
\(else:)[[[Start a battle|JK]]]
[Buy some cake (10 G)]<buy|(click: ?buy)[
(if: $gold >= 10 and $cake is false)[<!-- if you have enough gold and don’t already have that item, remove the appropriate amount of gold from your inventory and indicate that you now have that item -->
\ (set: $gold to it - 10)(set: $cake to true)
\ You have bought a slice of cake.]
\(elseif: $cake is true)[<!-- if you already have that item, you can’t buy another. Currently this system doesn’t allow you to have more than one of an item using the same variable, although you COULD have more than one item of a certain name if you give them different variable names. -->
\ You already have some cake.]
\(elseif: $gold < 10)[<!-- if you don’t have enough gold you can’t buy the item -->
\ You don't have enough gold.]
\(else:)[... They're out of cake.] <!-- just in case something goes weird. -->
\] <!-- This green section adds the option to buy an item if the player doesn't have one and has enough gold. -->
(if: $HP is 0 or $HP < 0)[ <!-- This is the game over screen if you lose all of your HP. -->
\ (set: $losses to it + 1) <!-- notes that you’ve lost a battle -->
\ <h1>GAME OVER</h1>
You cannot give up hope! $name... [[Stay determined!|Home]]
\]
\(elseif: $Candle_Grandma_HP is 0 or $Candle_Grandma_HP < 0)[ <!-- This is the win screen if the enemy's HP is 0. -->
\ (set: $Candle_Grandma_KILLED to true) <!-- notes that CG has been killed so you can't fight her anymore -->
\ (set: $kills to it +1)
\ (set: $victories to it + 1)
\ (set: _gained to (random: 40, 60))
\ (set: _goldgain to (random: 1, 10))
\ (set: $gold to it + _goldgain)
\ (set: $EXP to it + _gained) <!-- $kills counts the number of enemies you’ve killed, so we add this kill to it. It also counts as a victory. “gained” and “goldgained” give you a randomized amount of EXP and gold, respectively, and they are added to the global EXP and gold counters. -->
\ [[You Won!|Home]]
You've gained _gained EXP and _goldgain gold.
\ (if: $EXP % 3 is 0 or $kills is 1)[<!-- EXP gain is a lot simpler in this battle system than in actual Undertale. Basically, if the amount of EXP you currently have can be divided by 3, or if this is your first kill, your LOVE will increase. -->
\ (set: $LV to it + 1)(set: $maxHP to it + 4)
\ Your LOVE has increased!]
\]
\(else:)[<!-- otherwise, if no one has won yet, continue to your turn. -->
\ (if: $turns is 0)[Candle Grandma approaches!]<!-- if this is the first turn/start of the encounter -->
\ (elseif: $ask >= 7 or $crush >= 5)[Candle Grandma doesn't want to fight anymore.]<!-- if the player has done whatever necessary to spare this particular enemy, show this dialogue to hint that they can spare. This goes ahead of the other elseif’s so that it’s checked first when it’s not the first turn. -->
\ (elseif: $Candle_Grandma_HP <= $Candle_Grandma_MAX_HP/3)[Candle Grandma has low HP.]<!-- if has less than a third of their HP, let the player know. This goes ahead of the other elseifs so that it’s checked second when it’s not the first turn (prioritization is enemy sparable -> enemy about to die -->
\ (elseif: $crush > $ask)[Candle Grandma is no match for your flip flop.]
\ (elseif: $turns >= 1 and $talk is 0 and $crush is 0 and $ask is 0)[Candle Grandma lights a peach bellini candle.]<!-- if you’ve done something, but NOT one of the act options -->
\ (elseif: $ask > 1 and $ask < 4)[Candle Grandma knows better than you.]<!-- if you’ve acted a certain number of times, this can be used to change the dialogue shown. Feel free to change the ACT variables and the counters. This is just visual customization of the battle screen. -->
\ (elseif: $ask > 1 and $ask < 7)[Candle Grandma's kazoo is too powerful..]<!-- same kind of thing as above -->
\ (else:)[Smells like chocolate and mint.] <!-- catch-all dialogue in case none of the above conditions are met. -->
$name LV $LV HP $HP/$maxHP
[[Fight|FightCANDLE]] [Act]<act| [Item]<item| [Mercy]<mercy| <!-- This section holds the players name, LV and current HP, as well as the FIGHT, ACT, ITEM, and MERCY buttons, separated by blank space (the s). It is important that the fight, spare, and flee buttons direct you to a fight/spare/flee passage SPECIFIC TO THE CURRENT ENEMY, unless you only have one UT battle in your Twine game. -->
(click: ?act)[<!-- if the player clicks on the ACT button, show the ACT menu. You can have as many ACT buttons as you want, with two to a line. -->
\ [[Check]] [[Talk|TalkCANDLE]]
[[About NCA]] [[Crush Dreams]]
]
\ (click: ?item)[<!-- if the player chooses to use an item, show the item menu. You should have as many ITEM options as you have ITEM variables, unless there’s a specific item you really don’t want the player to be able to use in a given battle. To add more, add a new line with NO slash (since you want a new line to be shown) and copy-paste the four lines with ITEM3 and ITEM4’s stuff-->
\ (if: $birthdaybear is true)[
\ [[Birthday Bear]]]
\ (if: $sunglasses is true)[
\ [[Sunglasses]]]
(if: $cake is true)[
\ [[Cake]]]
\ ]
\ (click: ?mercy)[<!-- if the player chooses to use mercy, show the mercy menu -->
\ (if: $ask >= 7 or $crush >= 5)[<!-- if the spare conditions are met, the spare button will be yellow. -->
\ (color: yellow)[[[Spare|SpareCANDLE]]]
\ ]
\ (else:)[<!-- otherwise the spare button is white -->
\ [[Spare|SpareCANDLE]]
\ ] [[Flee|FleeCANDLE]]
\ ]
\]Candle Grandma - ATK 2 DEF 5
Evil founder of the NCA... Whatever that is...
[[Z|DodgeCANDLE]] <!-- Z simply represents the player pressing z in Undertale to continue on. Change that to your liking. Like all of the other passages, the “dodge” passage you direct the player to must be unique to this particular battle/enemy. -->
(if: $HP <= $maxHP - 10)[<!-- if using this item is not going to push you over your max HP, just add the number of HP recovered to the current HP. -->
\ (set: $HP to it + 10)]
\(if: $HP > $maxHP - 10)[<!-- if using this item is going to push you over your max HP, just set the player’s current HP to their max. -->
\ (set: $HP to $maxHP)]
\(set: $birthdaybear to false)
\You used the Birthday Bear.
It lifts your spirits.
(if: $HP is $maxHP)[
\ [[HP fully restored!|DodgeCANDLE]]
\](else:)[
\ [[Recovered 10 HP!|DodgeCANDLE]]
\]
You put on your sunglasses because they make you feel cool.
Candle Grandma applauds.
[[You take them back off.|DodgeCANDLE]]
(if: $ask >= 7 or $crush >= 5)[<!-- if the player has done whatever they need to spare the enemy, then they win and the battle ends. If there are multiple ways the player can spare the enemy, use another elseif: with the same content in the brackets, or add ORs to the conditions above.-->
\ (set: $victories to it + 1)<!-- count this as a victory -->
\ (set: _goldgain to (random: 5, 15))<!-- "goldgain” is a temporary variable that will be used to add a random amount of gold to the player’s inventory. -->
\ (set: $gold to it + _goldgain)
\ [[You Won!|Home]]
You've gained 0 EXP and _goldgain gold.
\](else:)[<!-- if the player hasn’t waited enough turns/used the right items/acted the right way the right number of times to spare the enemy, then it won’t work and they’ll go to dodging attacks. -->
\ [[You can't spare Candle Grandma yet.|DodgeCANDLE]]
](set: $escape to (either: true, false))
\(if: $escape is true)[
\[[Escaped...|Home]]
\](else:)[
\(goto: "DodgeCANDLE")]
\
\<!-- The Flee passage just randomizes whether or not you can flee and shows the link accordingly. -->(if: $HP <= $maxHP - 5)[<!-- if using this item is not going to push you over your max HP, just add the number of HP recovered to the current HP. -->
\ (set: $HP to it + 5)]
\(if: $HP > $maxHP - 5)[<!-- if using this item is going to push you over your max HP, just set the player’s current HP to their max. -->
\ (set: $HP to $maxHP)]
\(set: $cake to false)
\You eat the slice of cake.
It tastes like Halloween in March.
(if: $HP is $maxHP)[
\ [[HP fully restored!|DodgeCANDLE]]
\](else:)[
\ [[Recovered 5 HP!|DodgeCANDLE]]
\]
(set: _dialogue to (random: 1,3))
\(if: _dialogue is 1)[
\ You tell Candle Grandma about your Halloween-Birthday party.
[[She nods.|DodgeCANDLE]]
\](elseif: _dialogue is 2)[
\ You tell Candle Grandma about your friends.
[[She nods.|DodgeCANDLE]]
\](else:)[
\ You tell Candle Grandma about some spaghetti you once had.
[[She nods.|DodgeCANDLE]]
\](set: $ask to it + 1)<!-- this helps you track how many times the player has done this particular action -->
\(if: $ask <= 3)[
\ You and Candle Grandma engage in a lenghty conversation about the NCA between attacks.
[[She seems excited.|DodgeCANDLE]]
\](elseif: $ask is 4)[
\ You and Candle Grandma continue discussing the NCA.
[[She tells you they have many candles.|DodgeCANDLE]]
\](elseif: $ask is 5)[
\ You ask about the NCA's candle supply.
[[She tells you about her favorites.|DodgeCANDLE]]
\](elseif: $ask is 6)[
\ You ask if you can join the NCA.
[[Candle Grandma hands you some paperwork.|DodgeCANDLE]]
\](elseif: $ask is 7)[
\ You fill out and give Candle Grandma the papers.
[[She takes them with a smile.|DodgeCANDLE]]
\](elseif: $ask > 7)[
\ You're already a member of the NCA.
[[Candle Grandma is done fighting.|DodgeCANDLE]]
\]
(set: $crush to it + 1)<!-- this helps you track how many times the player has done this particular action -->
\(if: $crush <= 3)[
\ You tell Candle Grandma that the NCA will never be real.
[[She sheds a single tear.|DodgeCANDLE]]
\](elseif: $crush is 4)[
\ You continue to belittle Candle Grandma.
[[Her heart is broken.|DodgeCANDLE]]
\](elseif: $crush >= 5)[(set: $turns to it + 1)
\ Candle Grandma's soul is crushed.
[[She gives up.|DodgeCANDLE]]]
<!-- if there is more than one battle in your Twine game, they must all have unique fight/act/item passages, even if the content is the same! Otherwise, you won’t be removing HP from the correct enemy or redirecting back to the correct main fight passage. -->
\(if: $ask >= 7 or $crush >= 5)[ <!-- if Candle Grandma has stopped fighting, she'll be betrayed and die instantly. -->
\ (set: _clicked to false) <!-- this tracks whether the player has clicked on the hook for the purposes of the event macro. -->
\ Candle Grandma's HP: $Candle_Grandma_HP/$Candle_Grandma_MAX_HP
[ATTACK]<ATTACK|<!-- This hook is clicked to attack, and is set to where faster attacks have a higher chance for larger amounts of damage. -->
\ (click-replace: ?ATTACK)[
\ (set: _clicked to true) <!-- indicates that the player clicked on the link so it doesn't time out -->
\ (set: _damage to 99999) <!-- if candle grandma has had her heart shattered or if you've joined the NCA already, this is a betrayal kill for the max damage. -->
\ (set: $Candle_Grandma_HP to it - _damage) <!-- this removes the appropriate amount from the enemy’s HP. -->
\ [[_damage|DodgeCANDLE]]
\]
\ (event: when time > 6s and _clicked is false)[<!-- if the player has waited more than 6 seconds and has not clicked to attack, it times out. -->
\ (replace: ?ATTACK)[
\ (set: _damage to 0)
\ [[MISS|DodgeCANDLE]]
\ ]
\ ]
\](else:)[<!-- if she's not spareable, run the normal fight passage. -->
\ (set: _clicked to false) <!-- this tracks whether the player has clicked on the hook for the purposes of the event macro. -->
\ Candle Grandma's HP: $Candle_Grandma_HP/$Candle_Grandma_MAX_HP
[ATTACK]<ATTACK|<!-- This hook is clicked to attack, and is set to where faster attacks have a higher chance for larger amounts of damage. -->
\ (click-replace: ?ATTACK)[
\ (if: time >= .1s and time <= 2s)[
\ (set: _clicked to true) <!-- notes that the player clicked on the hook -->
\ (set: _damage to (random: 15, 30)) <!-- sets how much damage the player did -->
\ (set: $Candle_Grandma_HP to it - _damage) <!-- this removes the appropriate amount from the enemy’s HP. -->
\ [[_damage|DodgeCANDLE]]
\ ](elseif: time > 2s and time <= 4s)[
\ (set: _clicked to true)
\ (set: _damage to (random: 5, 15))
\ (set: $Candle_Grandma_HP to it - _damage)
\ [[_damage|DodgeCANDLE]]
\ ](elseif: time > 4s and time <= 6s)[
\ (set: _clicked to true)
\ (set: _damage to (random: 1, 5))
\ (set: $Candle_Grandma_HP to it - _damage)
\ [[_damage|DodgeCANDLE]]
\ ](else:)[<!-- if you wait more than 6 seconds, you'll miss. -->
\ (set: _damage to 0)<!-- if you didn’t do any damage, there’s no reason to remove HP from the enemy.-->
\ [[MISS|DodgeCANDLE]]
\ ]
\ ]
\ (event: when time > 6s and _clicked is false)[<!-- if the player has waited more than 6 seconds and has not clicked to attack, it times out. -->
\ (replace: ?ATTACK)[
\ (set: _damage to 0)
\ [[MISS|DodgeCANDLE]]
\ ]
\ ]
\](if: $Candle_Grandma_HP > 0)[<!-- if the enemy isn't dead, this passage will actually run -->
\ (set: $turns to it + 1)<!-- the turns are counted with each dodging, rather than in the fight/act/item/etc. passages because you will ALWAYS come back to the dodging passage. -->
\ (set: _youdamage to 0)<!-- initializes this value, used to determine how much damage the player took. -->
\ (set: _clicked to false)<!-- initializes this value, used to determine if the player has clicked on the dodge link. -->
\ (if: $ask >= 7)[
\ "Thank you dearie! We can stop fighting now."
[[Z|CANDLE]]](elseif: $crush >= 5)[
\ "... ... ..."
[[Z|CANDLE]]](else:)[
\ (if: $turns is 1 and (history:)'s last is not "Crush Dreams" and (history:)'s last is not "About NCA")[“You're too young to know what you're doing!”]<!-- if this is the first turn/start of the encounter -->
\ (elseif: $turns >= 1 and $ask is 0 and $crush is 0 and $talk is 0)[“No one can withstand my kazoo powers!”]<!-- if you’ve done something, but NOT one of the act options -->
\ (elseif: $crush >= 1 and $crush <=3 and (history:)'s last is "Crush Dreams")[ “...”]
\ (elseif: $crush is 4 and (history:)'s last is "Crush Dreams")[ “... ...”]
\ (elseif: $ask >= 1 and $ask <= 3 and (history:)'s last is "About NCA")[ “Oh, don't you just love candles?”]<!-- if you’ve acted a certain number of times, this can be used to change the dialogue shown. Feel free to change the ACT variables and the counters. This is just visual customization of the battle screen. -->
\ (elseif: $ask is 4 and (history:)'s last is "About NCA")[ “The NCA is a wonderful place!”]<!-- same kind of thing as above -->
\ (elseif: $ask is 5 and (history:)'s last is "About NCA")[ “We have all sorts of candles...”]
\ (elseif: $ask is 6 and (history:)'s last is "About NCA")[ “Oh, give those back after you're done.”]
\ (else:)[ “So that's how you wanna have it...”] <!-- catch-all dialogue in case none of the above conditions are met. This section of code is optional and replicates enemies talking to you during their attacks. -->
[DODGE]<dodging|<!-- This hook is clicked to dodge, and is set to where the faster you click it, the less damage you’ll take. -->
\
\ (click-replace: ?dodging)[
\ (if: time >= .1s and time <= 1.5s)[
\ (set: _clicked to true) <!-- this signals that you clicked on the link so that the time out event down below doesn't happen. -->
\ (set: _youdamage to 0) <!-- if you clicked it really quickly, the enemy does no damage -->
\ You've dodged all of the attacks. [[0 HP lost!|CANDLE]] <!-- this returns you to the main fight sequence. -->
\ ](elseif: time > 1.5s and time <= 4s)[
\ (set: _clicked to true)
\ (set: _youdamage to (random: 1, 5))
\ (set: $HP to it - _youdamage) <!-- this removes the proper amound of HP from the player -->
\ You've dodged most of the attacks. [[_youdamage HP lost.|CANDLE]]
\ ](elseif: time > 4s and time <= 6s)[
\ (set: _clicked to true)
\ (set: _youdamage to (random: 5, 15))
\ (set: $HP to it - _youdamage)
\ You've dodged some of the attacks. [[_youdamage HP lost.|CANDLE]]
\ ](else:)[
\ (set: _clicked to true)
\ (set: _youdamage to (random: 15, 19))
\ (set: $HP to it - _youdamage)
\ You didn't dodge any of the attacks. [[_youdamage HP lost.|CANDLE]]
\ ]
\ ]
\ (event: when time > 6s and _clicked is false)[
\ (replace: ?dodging)[]
\ (show: ?dodging)[<!-- this is set up like this so that only the X HP lost part is a link, not the whole hook. -->
\ (set: _youdamage to (random: 15, 19))
\ (set: $HP to it - _youdamage)
\ You didn't dodge any of the attacks. [[_youdamage HP lost.|CANDLE]]
\ ]
\ ]
\ ]
\](else:)[<!-- if the enemy's HP is 0, they can't attack... -->
\ (redirect: "CANDLE")
\]But nobody came...
[[Return|Home]]
[Reset]<reset|(click: ?reset)[(reload:)]