Cannot use damaging skills (including HP/MP drain) outside of battle

This is more of a question/request for clarification because every source I could find seemed to imply the process was straightforward. I have an actor who can select an ally to drain a percentage of HP from, even outside of battle. However, when selecting the target ally from the skills scene, the skill does nothing. It just fails.

I messed around with formulas, elements, and parameters, but ultimately only HP/MP recover would work when used on an ally. So I looked into how damage is calculated in rpg_objects.js and found this:

JavaScript:
Game_Action.prototype.testApply = function(target) {
    return (this.isForDeadFriend() === target.isDead() &&
            ($gameParty.inBattle() || this.isForOpponent() ||
            (this.isHpRecover() && target.hp < target.mhp) ||
            (this.isMpRecover() && target.mp < target.mmp) ||
            (this.hasItemAnyValidEffects(target))));
};

...which confirms that, outside of battle, friendly fire skills appear to fail automatically. When I added this.isForFriend() in there, my HP drain skill did start working, but I would like to know if there's a reason for this default behavior that I should be aware of. I don't want to mess anything up by altering the wrong piece of code, but I would like the HP drain effect to be visible to the player (as it shows from the skills scene natively) rather than taking place inside a common event. Any information is appreciated.
check your skills => skill tab => skill ID => occasion => always

if this is on battle screen, than only battle screen is useable,
if its menu only, it can't be used in battle, if its always, it can be both.
This one is set to Menu Only -- I have a separate version for battle that uses a common event to do the drain. The battle version shows dialog between the user and target, but I wanted to make a separate one for outside of battle that players can just use quickly.

Does this mean ally-damaging skills should be usable outside of battle by default then? I checked my other plugins and found nothing else that seemed to interfere with this by preventing out-of-battle friendly fire.
the other issue that may arise is that they share the same name.
if this is true, call the one for menu "SkillName2" skill name you use
with a 2 behind.

in case this works, we can alter the name afterwards to remove the number.
if it doesn't work, let us know too as I use a code in my NaviCustomiser to remove
a tag in the name, so that may work for you too with little modification like
removing the "2" or <menu> tag or something, but the name otherwise are equal 🙂
It actually does have a 2 at the end for testing, but I already use one of those "<hide in battle/field>" plugins to make sure only the correct one is visible during the actual game. I even tried setting it to occasion: Always just to see if that made a difference but nope, still can't use any damaging skills outside of battle. Is there anything else that might be causing this?
I'm out of options really....

can you show the screen shot of the skill how it is setup?
how it deals/drain dmg?
It's incredibly simple, I'm just as stumped as you are. And again, swapping "HP drain" to "HP recover" works without issue, so it seems only the type of damage is causing it to fail, as further evidenced by the engine only checking for HP/MP recovery and effects.

rmmv drain.png
that it may be the type of contact, but it may also be that it "wont work"
that way on map?

however, you can make it work if you use the effect => call common event.
and do what needs to be done there, if that works, use that, otherwise, you
may need a snippet to make it work what you want for this case.

as I don't know otherwise really.
Does this mean ally-damaging skills should be usable outside of battle by default then?
nope. the code says so right there 😛

I don't want to mess anything up by altering the wrong piece of code
the thing is, you found a solution to your issue. if youre unsure of if itll mess something up elsewhere, then you can test it and see.

Two of the reasons why its recommended to make all your changes plugins instead of overwriting the core js files directly is because it makes it easier to keep track of your changes and even easier to revert them if you need to do so

When I added this.isForFriend() in there, my HP drain skill did start working, but I would like to know if there's a reason for this default behavior that I should be aware of.
i cant speak about the intent of how the code was set up nor if its because of a technical reason, but the code makes assertions everywhere about how things should work and leaves it open so that anyone who can read it can change it to do what they want.

maybe they did that way because they thought it didnt make sense to allow an actor to be able to kill themselves in the skill menu, the same way you cant use a healing item on an actor that doesnt need healing.

can't use any damaging skills outside of battle
one thing to note, is that the hasItemAnyValidEffects call includes the effects an item/skill has and the rules for if those should be valid. if you wanted to, you could have the skill both apply and remove a blank state and itll always be valid. that wouldnt require any code changes.
I just wanted to check and see if there was a known reason for this behavior that I hadn't heard or thought of. The only reason I tested it in objects.js was to see whether that was actually the final execution of the skill, or if a plugin was handling it. I logged it in the console to confirm this.

I trust people here to know more about RMMV than I do, so even if something seems unusual to me (even when working as intended, as the code shows), someone else might have an explanation for it that I'd want to know about before making an alteration.

you cant use a healing item on an actor that doesnt need healing.
Also, yes you can do this. I just made a dummy item that heals an actor for 100 HP and used it on each of my actors, who already have full HP. The item was consumed each time. Earlier in development I had to get a plugin to manually check for the item having any effect before consumption because it seemed ridiculous that they would allow items with no actual effect to still be consumed, much like I am baffled now learning that damaging skills cannot be used outside of battle by default.
Also, yes you can do this. I just made a dummy item that heals an actor for 100 HP and used it on each of my actors, who already have full HP. The item was consumed each time. Earlier in development I had to get a plugin to manually check for the item having any effect before consumption
what version of the core scripts are you using? this is not the case in the current one (v1.6.2). are you certain that the item only has a recovery effect on it (either through the effect or the formula) and didnt have some other effect that would allow it to still be valid even at full hp?

I am baffled now learning that damaging skills cannot be used outside of battle by default.
as mentioned, you can if the skill adds and removes a state. preferably blank. but thats more of a side effect rather than anything else
what version of the core scripts are you using?
It says v1.6.1 for each of them. I downloaded RMMV from their website during the 2023 winter sale then updated the nwjs to be compatible with a specific version of Greenworks/Steam integration a few months ago. I don't think the core version would've been affected by that though.

I tried combining the in- and out-of-battle effects (common event and visual HP drain using damage formula, respectively) into one skill, but unfortunately it seems that without this.isForFriend() included in the testApply, using Hime's Effect Conditions to disable the effect also disables the damage application outside of battle. With this.isForFriends() included, it successfully disables the common event, but then pops the skill scene anyway, so the visual effect of the HP drain between user and target (which does successfully occur) is not seen by the player. I guess I will have to have this split into two separate skills after all to achieve the effect I want for each version.

Edit: Using Yanfly's Skill Core, I set the custom execution to check if the party was in battle and just run the common event from there if so. This way I only need 1 version of the skill, and can either use the add/remove state effect mentioned above, or use my script that allows damage to occur even with a blank effects list. Thank you both for your help~

Original thread: https://forums.rpgmakerweb.com/threads/cannot-use-damaging-skills-including-hp-mp-drain-outside-of-battle.181516/