How do Invisibility and Mirror Image stack?

My character finds himself in a situation where he has access to both the mirror image spell and has the ability to become invisible.

Ignoring the means by which he becomes invisible (he’s not doing anything that’d end his invisibility) what happens when these two effects stack?

Similar, but not identical to: Does Mirror Image stack with Blur?

Mirror Image

  • Three illusory duplicates of yourself appear in your space. Until the spell ends, the duplicates move with you and mimic your Actions, shifting position so it’s impossible to track which image is real. You can use your action to dismiss the illusory duplicates.

  • Each time a creature Targets you with an Attack during the spell’s Duration, roll a d20 to determine whether the Attack instead Targets one of your duplicates.

Invisible Condition

  • An invisible creature is impossible to see without the aid of magic or a Special sense. For the purpose of Hiding, the creature is heavily obscured. The creature’s location can be detected by any noise it makes or any tracks it leaves.
  • Attack rolls against the creature have disadvantage, and the creature’s Attack rolls have advantage.

So, are the mirror images also Invisible (Disadvantage to attack them) – which seems… odd. Although I guess you could argue the mirror images also mirror whatever sounds and other perceptual clues your actual form is making, even if they aren’t obviously visible.

Or are the mirror images visible but you are not? No disadvantage if someone happens to attack a duplicate, but they will have a disadvantage if they attack you.

Or spell fails completely, because of reasons?

How (if at all) do Wild Magic Surges stack with each other?

First off there are a lot of rules on combining/overlapping effects:

The effects of the same spell cast multiple times don’t combine, however. Instead, the most potent effect–such as the highest bonus–from those castings applies while their durations overlap, or the most recent effect applies if the castings are equally potent and their durations overlap.

Player’s Handbook: Chapter 10, Spellcasting; Combining Magical Effects

[…] When two or more game features have the same name, only the effects of one of them—the most potent one—apply while the durations of the effects overlap […] Game features include spells, class features, feats, racial traits, monster abilities, and magic items […]

Dungeon Master’s Guide: Chapter 8, Running The Game; Combining Game Effects (errata)

When two or more effects have the same proper name, only one of them applies while the durations of the effects overlap (a duration is a time span of 1 round or more). The most potent effect–such as the highest bonus–is the one that applies, or the most recent effect applies if the effects are equally potent.

The Essentials Kit: Chapter 0, Welcome to Dungeons & Dragons; Effects with the Same Name Don’t Stack

That all said we also know that things with the same name don’t stack regardless of how different the actual effects might be, for example:

  • If you cast a spell with different effect options twice on the same creature, do multiple castings of the spell stack?
  • If you cast Blindness/Deafness as a 3rd level spell, can you target one creature with both effects?
  • Do the Stone Golem's Slow feature and the Slow spell combine?

In all these cases, despite the actual effects being quite different, the name of the effect is the same and so they cannot stack.

How do these rules apply to Wild Magic Surges? In particular there are effects such as:

15-16: For the next minute, you regain 5 hit points at the start of each of your turns.
23-24: Your skin turns a vibrant shade of blue. A remove curse spell can end this effect.
61-62: For the next minute, you must shout when you speak.
71-72: You gain resistance to all damage for the next minute.

Can multiple different surges exist, simultaneously affecting the same creature? Are they considered to be the same class feature or to have the same proper name and thus do not stack?

Can multiple of the same surge (such as 15-16 above) exist, simultaneously affecting the same creature? Would you regain 10 hit points at the start of each of your turns or just 5?

How do Wild Magic Surges stack with each other (if at all)?

How does the Sanctuary spell stack with the College of Glamour bard’s Unbreakable Majesty feature?

The College of Glamour bard’s Unbreakable Majesty feature (XGE, p. 14-15) has a similar effect to the sanctuary spell, although it requires a Charisma save instead of a Wisdom save.

If someone attacks a creature under the effects of both, does the attacker need to make both saves?

How to take input like “push 10” in C from user for stack implementation?

I am taking part in a contest which is basically stack implementation in C and I have written down the complete code (function definitions) and it’s working fine except for the drive program. Problem is that the input from user is going to be like this:

push 10 push 100 push 200 get_top pop 

I’ll be running a for loop for user specified time and that many times the user is going to operate on stack.

The only problem is that I don’t know how to take input in the format given above. How do I check what function to call when users inputs something like this?

I am coding in C and only allowed to use stdio.h

Please help me

Stack Smashing Challenge

I know what I need to do in this challenge, but I am completely lost on how to do the first crucial step. What needs to happen is that I need to overwrite the global structure variable pin_len, which will then let me overflow user_pin in mask_with_pin(), and jump to get_shell(). I’m not sure at all how to overwrite pin_len, though. To my eye, it seems like the writer is limiting the input using fgets. I would just like a nudge in the right direction. Thank you!

#include <stdio.h> #include <stdlib.h> #include <string.h>  // // Globals //  #define MAX_FIELD_LEN 32 #define BUFFER_SIZE 64  struct scratch_space {     char notepad[BUFFER_SIZE];     unsigned int pin_len; } g_scratch_space;  // // Code //  // TODO: Give a shell to users with a special hash void get_shell() {     system("/bin/sh"); }  void scramble() {     int i = 0;      // Scramble the first name in the global notepad     for (i = 0; g_scratch_space.notepad[i]; i++)         g_scratch_space.notepad[i] ^= ((0x7 << i) & 0xff);      // Tick past the null-delimiter ...     i++;      // Scramble the last name in global notepad     while (g_scratch_space.notepad[i])         g_scratch_space.notepad[i++] |= 0x42; }  void mask_with_pin() {     char user_pin[MAX_FIELD_LEN];      // Prompt the user for a PIN     printf("Enter the PIN you wish to use: ");     fgets(user_pin, g_scratch_space.pin_len, stdin);      // Scramble the global notepad with the user's PIN     for (unsigned int i = 0; i < BUFFER_SIZE; i++)         g_scratch_space.notepad[i] ^= user_pin[i % g_scratch_space.pin_len]; }  void initialize_scratch_space() {     // Initialize the notepad to all zero bytes     memset(g_scratch_space.notepad, 0, BUFFER_SIZE);      if (!g_scratch_space.pin_len)      {         printf("Enter the size of the PIN you wish to use: ");         g_scratch_space.pin_len = get_uint();     }      if (g_scratch_space.pin_len > MAX_FIELD_LEN - 1)      {         printf("[!!] PIN Size exceeds maximum value, quitting...");         exit(1);     }  }  void interface()  {     char firstname[MAX_FIELD_LEN] = {};     char lastname[MAX_FIELD_LEN] = {};     char choice = 'y';      unsigned int firstname_len = 0;     unsigned int lastname_len = 0;      // Initialize the scratchspace for the first time     initialize_scratch_space();      while (choice == 'y')      {          // Zero out our local buffers         memset(firstname, 0, MAX_FIELD_LEN);         memset(lastname, 0, MAX_FIELD_LEN);          // Get the user's first and last name.          printf("Enter your first name: ");         fgets(firstname, MAX_FIELD_LEN, stdin);          printf("Enter your last name: ");         fgets(lastname, MAX_FIELD_LEN, stdin);          // Get the length of the names         firstname_len = strnlen(firstname, MAX_FIELD_LEN);         lastname_len = strnlen(lastname, MAX_FIELD_LEN);          // Copy their first name into the notepad         memcpy(g_scratch_space.notepad, firstname, firstname_len);          // Copy their last name into the notepad, placing it after the first name         memcpy(&g_scratch_space.notepad[++firstname_len], lastname, lastname_len);          // Scramble the input         scramble();           // Check if the user wants to further scramble their hash         printf("Apply PIN Scrambling? [y/n] ");         choice = get_char();          // Apply final scramble (if applicable), and print the resulting hash         if (choice == 'y')          {             mask_with_pin();             print_hash(BUFFER_SIZE, g_scratch_space.notepad);             initialize_scratch_space();         }         else if (choice == 'n')         {             print_hash(BUFFER_SIZE, g_scratch_space.notepad);             initialize_scratch_space();         }          // Allow the user to stop generating hashes         printf("Continue generating hashes? [y/n] ");         choice = get_char();     } }  void main()  {     init_wargame();      printf("------------------------------------------------------------\n");     printf("--[ Stack Smashing Level #2 - SecureHash                    \n");     printf("------------------------------------------------------------\n");     interface();      // Exit the program / return from main } 

Do Guidance and Bardic Inspiration bonus dice stack?

The feature/cantrip descriptions says nothing about their dice can not stack:

Bardic Inspiration

… use a bonus action on your turn to choose one creature other than yourself within 60 feet of you who can hear you. That creature gains one Bardic Inspiration die, a d6. Once within the next 10 minutes, the creature can roll the die and add the number rolled to one ability check, attack roll, or saving throw it makes.


You touch one willing creature. Once before the spell ends, the target can roll a d4 and add the number rolled to one ability check of its choice.

That feels wrong to me, since a pair of 1-level characters can have ridiculously high (up to +10, +6 average) bonus to an ability check.

To my knowledge, bonuses in D&D 5e (advantage, proficiency bonus, etc.) do not stack, hence the question. Can a player use both Bardic Inspiration die AND d4 from Guidance for the same check?

I’ve found a related question, but it is about 3.5e.

Is call stack compile time or runtime detail?

I’m sorry if the question is quite naive, but I don’t understand if a call stack is a language implementation detail or it depends on OS?

What I’m trying to understand is what decides how to store local variables and parameters of a function – the language’s compiler or OS while running the application? Is it possible to write a C compiler, let’s say, for Windows so that it won’t be stack based? Or the language syntax dictates us that it must be stack-based language?

Sorry if I say something wrong, just trying to get the basic idea how everything works.