Expert Guide: Calling and Recursion

From Noita Wiki
Jump to navigation Jump to search
This article may need cleanup to meet quality standards.
Please help improve this if you can. The Discussion page may contain suggestions.
Reason: "Links to mentioned/related guides should be added, as well as any other relevant links for spells mentioned and so on."

This guide covers the sometimes counter-intuitive or confusing aspects of how certain advanced spells behave. In particular, it discusses the mechanics of spells which are designed to copy (or call) other spells from a wand as well as how multiple instances of those spells behave when they are set up to copy each other, potentially recursively.

Normal Casting

Before talking about how spells are copied, let’s talk about how they’re normally cast. A normal cast always happens through draw - either when the wand draws a spell, or a spell draws another spell. In either case, there’s a whole routine that the game goes through as part of the draw process.

When a draw is initiated, the game takes the first spell off the top of the deck and holds it. It doesn’t immediately go to the hand - first, it’s checked to see if the wand has enough mana to cast it and that it’s not out of charges. If either of those things make it so the spell can’t be cast, the card goes to the discard instead of the hand, and the game takes the next spell off the top of the deck and tries again.

When this process succeeds, then the spell’s mana drain is deducted from the wand’s mana bar, the spell is moved to the hand, and the spell is called. To call a spell means to perform the spell’s action - the actual operation that a spell consists of, for instance, adding projectiles or modifiers to the shot state.

The action of a spell is an important concept. A way of thinking about it is that it’s what the spell itself does, rather than what other spells or mechanisms of the game do when interacting with that spell.

For instance, the mana drain and uses remaining of a spell are not part of a spell’s action, because the spell itself doesn’t interact with those values - as we saw before, the drawing mechanism looks at those properties of the spell and does the appropriate things on its own. Only after that’s over is the spell called and its action performed. For technical reasons, attributes like cast delay, recharge time, and damage modification are contained within the action of a spell.

Here are two examples of the actions of spells:

  • The action of Damage Plus is: “Add +10 projectile damage and +0.08s cast delay to the shot state.“
  • The action of Black Hole is: “Add a Black Hole projectile and +1.33s cast delay to the shot state”

Neither of these actions include mana cost or uses remaining, and that is because those values are properties of the spell. A spell’s properties is our second to last new term for now, and it basically refers to all of the miscellaneous things about a spell except for its action. This includes how rare it is and where it can be found, the type of the spell, whether or not the spell is tagged as recursive, which we’ll get to soon, and other various and less relevant things. And, of course, mana cost and uses remaining.

The thing in common about properties is that if they are to come into play, another mechanism of the game must be the one doing it. Properties do not do anything on their own, as we see with mana cost. Either another spell or the action of the spell must interact with the properties of the spell for them to be relevant.

With all that background out of the way, let’s get on to the meat of it: copying.

Copying

Copying a spell, at its most basic, simply calls that spell. It invokes the action of a spell without taking into consideration any of its properties. The action of Gamma, for instance, is this:

“Add +0.25s cast delay to the shot state. Find the spell that’s last in the deck, or if the deck is empty, the spell that’s last in the hand. Call that spell.” (A line is omitted for simplicity - we’ll talk about it soon.)

Note that there is no mention of the mana cost or uses remaining of the target spell in Gamma’s action - the action of the spell is evoked directly with none of the trimmings that the draw process has. That’s why you can cast a 0 charge Black Hole for only 30 mana (Gamma’s cost) by using Gamma. However, since the added cast delay of a spell is always part of the spell’s action, you still have to deal with the cast delay of Black Hole if you call it with Gamma.

However, the action of some spells add back some of the trimmings that are present in the draw process. The Divide By spells, for instance, check and deduct from the uses remaining of their target spell as part of their action. There is no standard process for what all spells that copy do - most of them do various things differently, which is the point of this guide. All of them, however, call their target spell to produce their action. That’s the baseline.

Recursion

Before getting into the specifics of how each spell copies, we need to understand the recursion limit, because all spells that copy other spells reference it in some way.

The first thing to know is that some spells are labelled recursive. Whether or not a spell is recursive is one of its properties, and it’s the property that determines how the recursion level of each instance of a spell is calculated. Here’s how it works:

  • If a spell is drawn and cast that way, its recursion level is 0.
  • If a spell calls a non-recursive spell, the called spell’s recursion level is the same as the caller.
  • If a spell calls a recursive spell, the called spell’s recursion level is 1 plus the caller’s level.
  • If a spell’s recursion level is equal the recursion limit, it cannot call spells marked as recursive.
  • The recursion limit is 2 in vanilla Noita.

This is the general procedure for checking recursion: getting the recursion level of a spell to be called, and determining if it is over the limit or not. All of the spells we’re about to talk about use this logic to limit recursion.

Time for an example to demonstrate!

Tau Example

Wand 0821.png
Shuffle
No
Spells/Cast
1
Tau
Tau
Spark Bolt

The function of Tau is to memorize the top two spells on the deck, check the recursion level of each, and call them if they are not over the limit.

With that in mind, this is how the above example is evaluated:

  • The wand draws Tau. Since it was drawn by normal means, this Tau's recursion counter is 0.
  • Tau (rec = 0) memorizes the top two spells in the deck: Tau and Spark Bolt
  • Tau (rec = 0) calls Tau. This Tau's recursion level is 0 + 1, since Tau is a recursive spell.
    • Tau (rec = 1) memorizes the top two spells of the deck. These are still Tau and Spark Bolt
    • Tau (rec = 1) calls Tau (rec = 2)
      • Tau (rec = 2) memorizes the top two spells of the deck, Tau and Spark Bolt
      • Tau (rec = 2) tries to call Tau, but cannot, because the copied Tau is also recursive. Instead, nothing happens.
      • Tau (rec = 2) calls Spark Bolt (rec = 2). This succeeds.
    • Tau (rec = 1) calls Spark Bolt (rec = 1)
  • Tau (rec = 0) calls Spark Bolt (rec = 0)

In the end, three Spark Bolts are produced, and the Cast Delay from three separate Taus is added. After this is over, the deck still contains the second Tau and Spark Bolt.

Omega example

Wand 0821.png
Shuffle
No
Spells/Cast
1
Gamma
Wand Refresh
Spark Bolt
Omega
Omega

Omega's function (and this is not intuitive!) is to copy all spells, in order, in the discard, then all spells that are NOT recursive in the hand, and then all spells in the deck. Normally, this functionality of not calling recursive spells in the hand works to make it so that Omega does not copy Omega, but things work a little differently when we do it like above. Additionally, Omega has a special case, which is that it will never call Wand Refresh in any situation. Knowing all of that, how many Spark Bolts do you think the above example will call?

Let's see how it goes:

  • Gamma (rec = 0) calls the last spell in the deck, which is Omega (rec = 1)
    • Omega (rec = 1) calls all spells in the discard, in order. No spells are in the discard, so nothing happens.
    • Omega (rec = 1) calls all spells in the hand, skipping recursive ones. The only spell in the hand is Gamma, so nothing happens.
    • Omega (rec = 1) calls all spells in the deck, in order:
    • Omega (rec = 1) skips Wand Refresh
    • Omega (rec = 1) calls Spark Bolt (rec = 1)
    • Omega (rec = 1) calls the first Omega, (rec = 2)
      • Omega (rec = 2) skips Gamma and Wand Refresh, as they are marked recursive.
      • Omega (rec = 2) calls Spark Bolt (rec = 2)
      • Omega (rec = 2) also skips both Omegas.
    • Omega (rec = 1) calls the second Omega, (rec = 2)
      • Same as above; this version of Omega only calls a single Spark Bolt

So, we find that this setup calls 3 copies of Spark Bolt. Very efficient!

List of Recursive Spells

Here's the list:

Notably, the Divide By spells are not recursive. As such, a Divide spell's recursion level is the same as that of its caller.

Conclusion

Hopefully you understand how the recursion limit works now!

At this point, if you've also read and understand the Expert Guide: Draw, you know all of the general mechanics of wandcrafting. What's left is learning the specific details of every spell, which in some cases (like Omega, as seen here) can be quite strange or unintuitive. For that, check out the Expert Guide: Advanced Spell Specifics. Other than that, have fun crafting some obscure wands!

--Written by Zoldort