MV Charm Status Effect!

Hello everyone, it's been a while. I want to try and create a Charm/Love state similar to SMT version of the state. I know that for enemies, this is easy if tedious. I can duplicate the skills the enemy uses and change the target to the "opposite target" and make them use those skills while affected. No problem there.

Now I want to try my hand at doing this to the player.

My first idea was kinda simple, make a state that turns on auto battle in the character, that's easy enough, the character now randomly uses the skills they know, and then using some of the notetags of Buff and State core, invert the target that the skill uses.

Now the big question is, in which case, what would be the solution?, or do you think the autobattle is the issue here? or something else. I once read that someone was going to try to use action sequences for this, but they never replied or answered, and agai,n I would like to try and create a "generic" version, something someone can just copy and paste.


Thank you all for your help in advance.

Edit: Remove part that breaks the rules as I has not read them in a while.
Just gonna drop this here.

IMG_5958.jpeg
Now the big question is, did the AI give me junk?
yes. thats not even a notetag for any of yanfly's plugins

I want to try and create a Charm/Love state similar to SMT version of the state. I know that for enemies, this is easy if tedious. I can duplicate the skills the enemy uses and change the target to the "opposite target" and make them use those skills while affected. No problem there.
start by saying exactly what you want it to do. IIRC, SMT charm only executed normal attacks, buffs, and heals - which is important because...
My first idea was kinda simple, make a state that turns on auto battle in the character, that's easy enough, the character now randomly uses the skills they know, and then using some of the notetags of Buff and State core, invert the target that the skill uses.
auto battling actors dont consider using heals and buffs. they select whatever skill they deem will do the most damage at the time by running the damage formula for each skill they know.


you can take the yanfly paralyze trick as a starting point and have it replace the user's skill with another. another way could be to use the target core to invert the scope of specific skills but that still requires the skill to be chosen and would either need you to do above anyways or use a plugin to change how auto battlers act to get the buffs and heals usable
Didn't that Maliki Confusion Control work with charms like this? I kind of remember Robro33 recommending it to someone but I might be wrong.
good point. i was hung up on the auto battle bit, but Maliki's Confusion Control is also a good direction to take with it.

I dont think its able to restrict the charm state skills to only ones the battler knows as opposed to the entire list set in the class/battler, but if anything Maliki might consider adding it as a feature if asked?
it should also be possible to use a plugin that adds skill condition evals, duplicate the skills, and give the charmed versions a requirement that the base version is learned to limit charmed states to what the actor knows
another way could be to use the target core to invert the scope of specific skills but that still requires the skill to be chosen and would either need you to do above anyways or use a plugin to change how auto battlers act to get the buffs and heals usable
I'm interested in understanding how to invert the scope of targets. What could be an option?

Autobattling actually heals, so far it only triggers when allies have low health, not the enemies but that would work enough for now, I think.

As I'm using mostly MV I want to try to avoid using MZ plug-in, I'll test it but there is a comment in the plug-in thread about an error, and no follow-up on any part.

But I will test it.
As I'm using mostly MV I want to try to avoid using MZ plug-in
it should work for both

Autobattling actually heals, so far it only triggers when allies have low health, not the enemies but that would work enough for now, I think.
never noticed it does have a section to handle heals. the the current and max hps are factored so that it avoids overhealing, so it seems that as long as the damaging options dont outweigh the healing ones and the heals wouldnt be wasted, they remain valid targets

I'm interested in understanding how to invert the scope of targets. What could be an option?
it would use the target core's <Custom Target Eval> notetag and check if the user is charmed before choosing battlers from the other unit
Seems Mal Plug-In is incompatible with a lot of Yanfly stuff, a couple of which are too important in my project. I'll mention it to them, but as their plug-in is primarily MZ, my hopes are low.

So Mal's may not be an option for me, it seems.


1758895914752.png


And is <Custom Target Eval> only for skills right so I would need to make the Eval in every skill?
Seems Mal Plug-In is incompatible with a lot of Yanfly stuff, a couple of which are too important in my project. I'll mention it to them, but as their plug-in is primarily MZ, my hopes are low.
from there, it seems like the aura plugin is the one that conflicts with Maliki's plugin. He might be interested in looking into it to set up some anti recursion method there to catch that
@Maliki79

And is <Custom Target Eval> only for skills right so I would need to make the Eval in every skill?
yeah, every skill that should work with this would need the notetag to invert the scope, and youll still need a way to get the battlers to use the skill. whether or not its going to be through restrictions like Maliki's plugin or soemthing through autobattle like Yanfly's actor ai plugin, an additional plugin will be needed to get them to use the skills for it to work
Seems Mal Plug-In is incompatible with a lot of Yanfly stuff, a couple of which are too important in my project. I'll mention it to them, but as their plug-in is primarily MZ, my hopes are low.

So Mal's may not be an option for me, it seems.


View attachment 350164

And is <Custom Target Eval> only for skills right so I would need to make the Eval in every skill?
I'll try to take a look when I can to get things compatible.
(New job blues...)
I'll try to take a look when I can to get things compatible.
(New job blues...)
I get that, thank you very much for your time!

I'll still try to make a version that uses the Custom target eval.

EDIT:
So far, I have come up with this, and it works, but only for skills that target all enemies or random enemies

JavaScript:
<Custom Target Eval>
if (user.isStateAffected(25)) {
  if (this.isForOpponent()) {
    targets = $gameParty.aliveMembers();
  } else {
    targets = $gameTroop.aliveMembers();
  }
} else {
  if (this.isForOpponent()) {
    targets = $gameTroop.aliveMembers();
  } else {
    targets = $gameParty.aliveMembers();
  }
}
</Custom Target Eval>

I had the else condition, because if I don't, the skill doesn't target anybody at all, the problem is... I have no idea what to do for single-target skills, I do not know the code/call/script for it... Sorry, so any ideas?

BTW if I do this for Single target skills they become AoE skills... XP
I had the else condition, because if I don't, the skill doesn't target anybody at all
not setting the targets variable might cause the skill to not have any targets. id have to check the plugin to make sure if its the case, but it sounds like it.

since the tag goes into the skills themselves, the only check you need to make is the one for being charmed. all the other checks like isForOne and isForOpponent are meaningless as those already depend on the skill itself and will be either always true or always false.

Code:
<Custom Target Eval>
targets = user.isStateAffected(25) ? allies.aliveMembers() : foes.aliveMembers()
</Custom Target Eval>
should set the targets to be all alive allies when charmed and all alive foes when not. flip the foes and allies for the opposite

no idea what to do for single-target skills
to get a single random battler, you should be able to use
Code:
var members = user.friendsUnit().aliveMembers();
targets = [members[Math.randomInt(members.length)]];
and opponentsUnit()

BTW if I do this for Single target skills they become AoE skills... XP
yep. once you use the notetag to set targets, the targets are the targets. it doesnt matter what the skill originally was, it is whatever the evel code says it is.
to get a single random battler, you should be able to use
Code:
var members = user.friendsUnit().aliveMembers();
targets = [members[Math.randomInt(members.length)]];
and opponentsUnit()
Thank you very much.

It works as it should; however...

How do I make it so that the character acts as normal, basically, right now, if I do this

JavaScript:
<Custom Target Eval>
if (user.isStateAffected(25)) {
var members = user.friendsUnit().aliveMembers();
targets = [members[Math.randomInt(members.length)]];
} else {
}
</Custom Target Eval>

As long as the target is affected, it is acting as it should, it attacks/debuffs allies, and if I change it to the user.opponentsUnit(), it heals/buffs enemies, the problem is what to put in the else condition, as again, if I leave it like this, nobody does anything if they are healthy XD sorry to bother so much.

Edit:

I think I need to use this somewhere, BattleManager._action._targetIndex, but I have no idea how... I'm lost also, do I need to do this in like a custom initiate effect or something because, if I do everything inside Custom Target, Am I not erasing the target without saving the original scope of the skill... T_T
How do I make it so that the character acts as normal, basically, right now, if I do this
try targets = [target];
I think... maybe I figured out... maybe...

So first, thank you for your answers @Robro33

So in total, you need maybe 3 different codes that basically cover the basic targets; you could need 6 if you want to make them all separated, and I don´t know, maybe somebody could figure out how to have this in a single code, but I'm not good enough with javascript to figure it out, sorry XP.

Remember that the actual Charm state has the Autobattle trait added to the affected actor, if they don't you can still have the player control the actor and attack their own teammates. Maybe if you want to do some kind of spy in party battle or something? XP

This is the first that targets 1 ally/enemy. It works pretty much as it should. The only extra thing I added was
Code:
this.isForOpponent()
, so that the same code could be used for Damage/Heal/Support/Debuff.

JavaScript:
<Custom Target Eval>
if (user.isStateAffected(25)) {
  if (this.isForOpponent()) {
var members = user.friendsUnit().aliveMembers();
targets = [members[Math.randomInt(members.length)]];
} else {
var members = user.opponentsUnit().aliveMembers();
targets = [members[Math.randomInt(members.length)]];
}
} else {
    targets = [target];
}
</Custom Target Eval>

The next one is for a skill that targets all enemies/allies. It looks more complicated as I tried to use
Code:
targets = [target]
, same as before, but the result was the skill affecting only 1 foe/ally I tried adding an s so it read targets, and that just crashed XD XD XD. Used
Code:
this.isForOpponent()
again to allow the code to be use for Damage or Healing skills.

JavaScript:
<Custom Target Eval>
if (user.isStateAffected(25)) {
  if (this.isForOpponent()) {
    targets = $gameParty.aliveMembers();
  } else {
    targets = $gameTroop.aliveMembers();
  }
} else {
  if (this.isForOpponent()) {
    targets = $gameTroop.aliveMembers();
  } else {
    targets = $gameParty.aliveMembers();
  }
}
</Custom Target Eval>

The last one is the one that took me the longest to figure out. I originally thought that the previous code would work for Random hitting skills, but it doesn't; it changes that skill scope to just all allies/enemies. So I tried to use this code for that. Now this code doesn't exclude targets after they are hit, so it can attack the same target multiple times. You can change the number of attacks in
Code:
var numberOfTargets = X
where X is the number of attacks you want.


JavaScript:
<Custom Target Eval>
function getRandomTargets(members, N) {
    if (members.length === 0) {
        return [];
    }   
    var randomTargets = [];
    for (var i = 0; i < N; i++) {
        var randomIndex = Math.randomInt(members.length);       
        randomTargets.push(members[randomIndex]);
    }
    return randomTargets;
}
var numberOfTargets = 3;
if (user.isStateAffected(25)) {
    if (this.isForOpponent()) {
        var members = user.friendsUnit().aliveMembers();
        targets = getRandomTargets(members, numberOfTargets);
    } else {
        var members = user.opponentsUnit().aliveMembers();
        targets = getRandomTargets(members, numberOfTargets);
    }
} else {
    if (this.isForOpponent()) {
        var members = user.opponentsUnit().aliveMembers();
        targets = getRandomTargets(members, numberOfTargets);
    } else {
        var members = user.friendsUnit().aliveMembers();
        targets = getRandomTargets(members, numberOfTargets);
    }
}
</Custom Target Eval>

So if anyone can suggest ways of cleaning the codes, if possible, or knows of better ways of doing this, I would appreciate the help. In the meantime, the three work, so if anyone wants to try their hand at a Charm state for Actor, here they are.

Original thread: https://forums.rpgmakerweb.com/threads/charm-status-effect.180308/