Enemies 'not appeared' still take damage

I have a couple of enemies which, when I created the troop, I set to 'Appear Halfway'. Their appearance is dependent on the HP of the Boss. However, unless I set them to a 'dummy' enemy with a blank sprite, I can still see them. I then have to do a 'Enemy Transform' command as well as the 'Enemy Appear' command.
The battle begins, and, with the blank sprite, they are not visible.
But, if an all-party skill is used, they take damage. I know this because I'm using Yanfly's script which shows enemy HP bars. Those bars come up and I can see that HP has been removed.
When the condition is met, they appear, with their reduced HP.

How is it possible for them to take damage when, strictly speaking, they are not 'there'? How do I prevent that? Am I supposed to do something in addition to simply clicking 'Appear Halfway' when setting up the troop?
I would also love to know how to ensure that their HP bars don't show until they appear, but that is probably the subject of another thread. Or it may be the consequence of incorrectly setting them up in the first place.

I have a nasty feeling that I have overlooked something incredibly basic.

Thank you.
I know that Yanfly's script has always added the HP bars to those that you set to appear halfway. I have the same issue in my game, and I also recall seeing it in Tale of a Common Man with the final boss. It seems it's just a quirk of the script which adds HP bars.

But...I've never seen them take damage until now. Maybe a new script you're using?
There must be a conflict with some script. Setting an enemy to "Appear Halfway" should be enough to hide it. And hidden enemies should not take any damage when a skill with scope "All Enemies" is used.

One thing you could try is to set your dummy enemy to have an incredible ammount of health and then set its current hp to what the real enemy should have. Be aware of the fact that this will create a conflict with hp bars, the bar would be almost empty!
Here are my battle scripts - I am assuming, perhaps naively, that non-battle scripts won't affect this.
upload_2017-8-18_14-20-21.png


There is nothing there that I can identify as being in conflict.

@Heirukichi If I set the dummy enemy to massive HP, that sorts it when I also use 'Enemy Transform' to the real enemy which has a much lower starting HP. Their HP bars are full. What I find bizarre is that I also set the dummys' PDR, MDR and TGR all to 0%, but they still took some damage.
Are your skills certain hit? If so that will ignore PDR and MDR.
@bgillisp Nope, the only Certain Hit skills are buffs/debuffs and healing skills.
I was checking the default code and how it is suppose to work is:
1. When you set an enemy in a troop to appear halfway the hide variable for that enemy becomes true.
2. This in turn sets the hidden variable to true (which gets checked by the hidden? method).
3. This then gets checked by the exist? method which uses not (!) to make the true hidden? method return false.
4. Now it checks to see if the enemy is alive (which also checks to see if the enemy exist?).
5. When creating targets for multi-target (and random target) skills it checks for alive_members (which iterates through all members checking to see if they are alive? and returning only those that are).

So if I had to guess I would say something is modifying the behavior of checking alive_members.
Edit: If it is not alive_members start going up the chain and see if any of the other parts are being modified.

Original thread: https://forums.rpgmakerweb.com/threads/enemies-not-appeared-still-take-damage.82885/