Expert Guide: Draw

At its heart, Noita's wand-building system is a card game. Surprising? Perhaps. This guide will explain the mechanics of Draw - namely, how the Deck, Hand, and Discard areas work, their basic mechanics, and how simple spells interact with them. You will not learn much that is actionable from this guide - instead, you will learn a perspective that is necessary to understand what the more complicated spells are actually doing.

Basics: The Deck, the Hand, and the Discard
To start things off, the first thing we need to talk about is how Noita handles its spells. As you cast a wand, the spells on that wand continuously move between the following three zones:

The Hand, which contains all the spells that you're casting during a given cast. It exists to prevent spells from being cast twice.

The Deck, which contains the spells that haven't been cast yet. Before you use the wand, it contains all the spells, and on no-shuffle wands, it contains them in the order you have them on the wand.

The Discard, which contains all spells that have been cast (or skipped due to other reasons). When a cast has finished, all spells in the Hand are moved to the Discard.

The game will naturally move spells through these zones while you cast any old wand, and we'll describe how this happens. However, some spells will manipulate the zones on their own when they are cast. There are two ways that this happens:

Draw, which is the action of moving a spell from the Deck to the Hand. It's the most common method by far and the most intuitive. Most projectile spells have no draw, most modifiers have one draw, and multicasts have several draw.

Discard, which is the action of moving a spell from the Deck directly to the Discard. It's only used by endgame spells, like the Divide By series, the Add Trigger series and the Requirement series, but we won't talk about those here.

In this guide, we'll be focusing on the normal flow of spells through the Deck, Hand, and Discard. Understanding this well is necessary for a proper understanding of the more complicated late-game spells, so there are many examples with very detailed descriptions. Let's get into it!

Spell Evaluation
So, the Deck is where all of your spells begin. For a non-shuffle wand that has not yet been cast, the Deck will consist of every spell on the wand.

Consider a wand with 1 Spell/Cast. When you click the mouse button to cast the wand, the wand draws the first spell from the Deck and puts it in the Hand. Then, the spell is cast. That is, the spell evaluates itself, then finishes. The cast ends, a visible effect is produced in the game, and then all the spells in the Hand are moved to the Discard.

The description above implies that only one spell is evaluated, but this is, of course, not always the case. The truth is that many spells, such as Modifiers and Multicasts, draw more spells and put them into the Hand in the course of their evaluation. A modifier produces an effect and then draws another spell, for instance, while a Double Spell produces no effect and then draws two spells. Here's an example to demonstrate how spells draw other spells:

Spells/Cast: 1

The spell evaluation tree for this wand (on its first cast) looks like this:


 * Wand's Cast
 * Damage Plus
 * Double Cast
 * Triple Cast
 * Spark Bolt
 * Spark Bolt
 * Spark Bolt
 * Speed Up
 * Spark Bolt

This should be interpreted as:


 * 1) The wand's initial cast draws Damage Plus from the Deck. Damage Plus is moved to the Hand and cast.
 * 2) Damage Plus applies its effect and then draws one card. This happens to be Double Cast, which is moved to the hand and cast.
 * 3) Double cast evaluates, It has no effect aside from drawing 2. First, it draws one card, which is Triple Cast, and evaluates it.
 * 4) Triple Cast's effect is to Draw 3. The first card it draws is Spark Bolt. Spark Bolt is evaluated, and applies its effect (creating a projectile), but it does not draw any cards so the chain ends there.
 * 5) Triple Cast draws its second and third cards, each of which are Spark Bolt. Both of them apply their effect and end their evaluation.
 * 6) Triple Cast has now drawn all three cards, so it ends its evaluation.
 * 7) We return to Double Cast. Now that we have completely evaluated it's first Draw, it draws its second card. At this point, Speed Up is on the top of the Deck, so we draw it.
 * 8) Speed up applies its effect and draws an additional card, which is spark bolt. Spark bolt finishes, then Speed up finishes.
 * 9) We return again to Double cast, and it has now drawn both of its cards. It ends its evaluation.
 * Now, we go back to the wand's cast. Since this wand only has 1 Spells/Cast, the wand will not draw any more. When there is no more draw, evaluation ends and the projectiles fly out into the world.

So, the wand shoots out the projectiles. This wand will, of course, produce four spark bolts, each with Damage Plus and Speed Up applied. At this point, all of the spells except for the Nuke are in the Hand. Now, crucially, everything that is currently in the hand is moved to the Discard as part of the casting process. Cast Delay is then applied. before we can move on to the next cast.

What happens if the wand is cast again? The answer is simple:


 * Wand's Cast
 * Nuke

Everything except for the Nuke is in the Discard, so when the wand draws a spell from the top of the Deck, it finds Nuke. Nuke is moved to the hand and cast. The Nuke projectile is launched into the world, and the Nuke spell is moved to the Discard. Then, something important happens.

Whenever a cast finishes, the game checks whether or not there are any cards left in the deck, and if there aren't any, a recharge is triggered. This is one of the two ways a recharge can occur. A recharge moves all spells from the Discard back to the Deck and resorts them so they are in their proper order. Recharge Time is applied at this point, and when it finishes, this entire process starts again from the beginning, with spells back in the deck and ready to be drawn.

Cast State
One thing that we glossed over in the previous section is how modifiers and projectiles are actually translating their effect into the world. An initial thought is that it might have something to do with the hand - maybe, at the end of evaluation, it reads through all of the spells in the hand and does something with them? This is a natural assumption, but it is incorrect. The Hand has nothing to do with it, and its main purpose is simply to keep track of what spells have already been a part of this cast. Wrapping can reach spells in the Discard but not the Hand, for instance.

What actually happens with spell evaluation is that there is an abstract "Cast State" that stores the effects of all the modifiers and projectiles that have been evaluated.so far. For instance, when Damage Plus is cast, part of its effect is to modify the Cast State with "+10 Projectile Damage". If another Damage Plus is cast, that part of the Cast State is changed to "+20 Projectile Damage."

When a projectile is cast, two things happen: First, the projectile itself is added to the list of projectiles stored in the Cast State. Then, any statistics attached to the projectile modify the statistics already present in the cast state. The projectile's Cast Delay and Spread are added to the Cast Delay and Spread of the Cast State, as well as any other statistics the projectile might have. Modifiers are exactly the same, except they do not add a projectile to the Cast State, and they draw a spell at the end of their evaluation.

When the evaluation of a cast completes (which happens when no more spells are doing any drawing, or there are no spells to draw), all of the projectiles stored in the Cast State are shot out, each of them with all of the modifiers that have been stored in the cast state applied. This is why one Damage Plus applies to every projectile in the Casting Block.

Note that no reference is made to any of the spells in the Deck, hand, or Discard - only the Cast State is used when the spells are actually fired. This is important because some spells, like Wand Refresh, remove spells from the Hand while leaving the Cast State untouched.

Lastly, a note about recharging: If a modifier or projectile has a Recharge Time statistic, that will be added to a separate value. Multiple casts with multiple Cast States may happen before the wand recharges, so the Recharge Time value is separate from each individual Cast State. That being said, it is changed by spells in exactly the same way as the Cast State

Wrapping
So, you've heard of wrapping in the past. How do we explain it with this new framing? The answer is simple: When a spell tries to draw but there is nothing in the Deck, every spell in the Discard is moved to the Deck and reordered. The draw then proceeds - this is what a wrap is. It is very simple, but there's an additional detail: When a wrap occurs, a flag is set in the game that makes it so that the wand will recharge immediately after the wand's current cast finishes. That's why a wand starts at the beginning again even after a wrap casts the first couple spells. Let's do an example. Spells/Cast: 1

Double Cast > Spark Bolt > Spark Bolt > Spark Bolt > Light


 * 1) The wand draws Double Cast.
 * 2) Double Cast draws both Spark Bolts.
 * 3) There is no more draw, so the cast finishes and the two Spark Bolts are shot.
 * 4) Double Cast and the Spark bolts are moved from the Hand to the Discard.
 * 5) Cast Delay is applied.
 * 6) A new cast begins; Spark Bolt is drawn and shot and discarded, cast delay is applied.
 * 7) A new cast begins; the wand draws Light.
 * 8) Light tries to draw, but there is nothing in the Deck. A wrap is initiated. Double Cast and the three Spark Bolts are returned to the Deck.
 * 9) Light can now complete its draw; it draws Double Cast.
 * 10) Double Cast draws two Spark Bolts.
 * 11) No more draw, the cast ends and the Spark Bolts are shot and discarded.
 * 12) At this point, Light, Double Spell, and two Spark Bolts are in the Discard. Nothing is in the hand, and there is one Spark Bolt in the deck.
 * 13) If the wand were to try to draw, it could draw spark bolt, but it does not try. Instead, it recharges the wand immediately because of the flag that was set when Light forced a wrap.

Wrapping and Spells/Cast
A semi-important note is that draw generated by the wand itself cannot cause wrapping. For instance, when a 3 Spells/Cast wand with one projectile left in the Deck tries to draw for the second time, it will not wrap the wand even if there are available spells in the Discard. That is, the following wand will not wrap:

Spells/Cast: 3

It will shoot 3 spark bolts twice, then only a single spark bolt, even through there are ample spark bolts in the Discard to wrap to. This can be circumvented by having a spell do the wrapping, then letting the wand draw only after the wrap finishes:

Spells/Cast: 3

This wand will shoot 3 spark bolts twice, and then:


 * 1) The wand draws Spark Bolt
 * 2) The wand draws Light, and since spells can cause wrapping, the Discard is returned to the Deck when Light tries to draw. Light draws Spark Bolt.
 * 3) The wand, for its third draw, draws the second Spark Bolt that has been returned to the Deck.
 * 4) The wand recharges.

Triggers
Triggers the final thing we need to talk about in this introduction to the mechanics of Draw. You have likely noticed that modifiers applied to a spell with a trigger on it will not apply to the spells cast by a trigger and vice versa. How do we explain this? the answer is that trigger spells actually create an entirely new Cast State. The old Cast State is saved and set aside, and a new Cast State is used to keep track of everything that will be cast by the trigger. Once the evaluation of the spells inside the trigger completes, that Cast State is then finalized and attached to the trigger projectile, to be cast when the trigger detonates. Then, the old Cast State is reinstated, and normal evaluation continues.

Note that the hand and deck remain relatively unchanged during this process - the main mechanism that makes triggers work is the creation of the new Cast State.

Let's run an example (Spells/Cast: 1):

Here's how this is evaluated:


 * 1) The wand draws Homing. Homing modifies the Cast State.
 * 2) Homing draws Piercing. Piercing applies both the ability to pierce and -15 projectile damage to the Cast State. It also sets the Cast State's friendly_fire value to True.
 * 3) Piercing draws Spark Bolt with Trigger. Spark Bolt with Trigger saves the old cast state, sets it aside, and creates a new Cast State.
 * 4) Spark Bolt with Trigger then draws Triple Cast.
 * 5) Triple Cast draws Damage Up. Damage Up modifies the new cast state with +10 projectile damage.
 * 6) Damage Plus draws Digging Blast. Digging Blast adds a projectile to the new Cast State but does not draw anything.
 * 7) Digging Blast completes. Damage Plus completes. Triple Cast draws the two remaining Digging Blasts, which each draw nothing and complete. Triple cast then completes.
 * Now, we return to the evaluation of Spark Bolt with Trigger. What happens now is we create a new projectile. The projectile we create is a Spark Bolt with the effect of casting the newly created Cast State when its trigger detonate.
 * 1) The original Cast State is restored to its place. The newly created and custom projectile is added to the original Cast State. Spark Bolt with Trigger then finishes its evaluation.
 * 2) Piercing completes, then Homing completes, then the wand's cast completes. When the wand's cast completes, the entire thing is cast.
 * 3) At this point the Cast State includes the changes from Piercing, the changes from Homing, and the custom projectile created by Spark Bolt with Trigger. When the trigger detonates, three Digging Blasts with Damage Plus will be spawned.

That's triggers in a nutshell. The separation of cast states allows some cool effects - for instance, this wand shoots a spark bolt with friendly_fire enabled, but enough negative damage that it won't do any damage even if it hits the player. It will, however, spawn high-damage Digging Blasts on contact - but since those are part of a separate Cast State, they don't have friendly_fire enabled and won't deal the player damage either. So this wand, even though it uses Piercing, damages enemies and not the player through the use of separate Cast States.

Conclusion
Hopefully you have a good understanding of how Draw works, along with the Deck, Hand, and Discard. The examples in this guide go into extreme detail on every step of the process to make sure you have a strong grasp on exactly what is happening, because that nuance will be very useful when it comes to understanding how spells like the Greek Letters, the Divides, and various other late-game spells are actually working.

Thanks for reading! The next guides in the series are:

Expert Guide: Greek Letter Spell Details and Expert Guide: Divide By Spells