Trouble with Yanfly's Target Core and Selection Control

Okk

Veteran
Veteran
Joined
Apr 24, 2015
Messages
46
Reaction score
11
First Language
English
Primarily Uses
I'm working with Yanfly's Target Core and Selection Control, but I'm having a little trouble hammering out the details of its functions. There are two skills in particular that I'm working on.

My first problem is a magic skill that damages all enemies. I'd also like it to optionally damage all allies instead; otherwise I wouldn't be using the Selection Control plugin. Unfortunately, notetags such as <Actor or Enemy Select> seem to completely override the Scope of the skill, changing it into a single-target attack.

The second problem is a revive spell. Ultimately, I'd like any KOed or undead targets to be valid, but I can't even get a spell to target KOed units. Again, the <Actor or Enemy Select> overrides the Scope, so with that alone, the spell will fail to target any KOed character. I've tried using <Select Conditions> using state 1 and zero hp, but the skill is disabled even when there are KOed actors on the field. I've also tried custom lunatic code, but it seems to get ignored.
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
33,993
Reaction score
8,627
First Language
German
Primarily Uses
RMMV
the spell will fail to target any KOed character
that is because KO'ed actors are a different target than non-KO'ed actors, see the regular targeting scope.
Selecting actors as target will automatically exclude the targets "actor (dead)".

Sorry, I can't tell you how to solve this but that is where you have to start looking for an answer why the dead actors can't be targeted.
 

caethyril

^_^
Global Mod
Joined
Feb 21, 2018
Messages
2,862
Reaction score
2,196
First Language
EN
Primarily Uses
RMMZ
Plugin links for convenience:
Not sure about the All Allies / All Enemies thing. After a quick look through Selection Control's options it seems like "Actor or Enemy" selection is single-target only. You may need an add-on plugin to implement a "Party or Troop" scope. :kaoslp:

For the dead or alive thing: there's a plugin called DeadOrAliveItem (for me it's in my RMMV install folder, under dlc/KadokawaPlugins) that lets you bypass the dead/alive scope difference that Andar mentions. Last I checked it had some conflicts with Yanfly's Selection Control; I have a compatibility patch over here in case you're interested: view/download CaeX_YEPDeadOrAlive (Google Drive).
 

Okk

Veteran
Veteran
Joined
Apr 24, 2015
Messages
46
Reaction score
11
First Language
English
Primarily Uses
For the dead or alive thing: there's a plugin called DeadOrAliveItem (for me it's in my RMMV install folder, under dlc/KadokawaPlugins) that lets you bypass the dead/alive scope difference that Andar mentions. Last I checked it had some conflicts with Yanfly's Selection Control; I have a compatibility patch over here in case you're interested

Sorry, not sure why I keep forgetting to link the relevant plugins. Like I can't grasp that somebody might not know about Yanfly engine.

Thanks, caethyril. I can actually target dead allies with revive spells now, which is probably the most important part. It seems that the Select Conditions are causing the trouble. Things like 'Param HP% === 0' or 'State: 1' are always evaluating as false. Maybe the Selection Control plugin is only bothering to check alive members in the first place.
 

caethyril

^_^
Global Mod
Joined
Feb 21, 2018
Messages
2,862
Reaction score
2,196
First Language
EN
Primarily Uses
RMMZ
No worries! I just link the plugins because otherwise it's an extra search + click away. Much more convenient to simply click a link~ :kaothx:

And you're correct, by default there is no "dead and alive" scope, and Selection Control only decides which targets of the given scope can be selected. So, if the skill can't target dead allies in the first place, the select condition "State: 1" won't have any effect, since possible targets are either all alive or all dead. :kaophew:

I've been looking at Target Core / Selection Control trying to figure out how to implement a "Party or Troop" scope, but can't seem to see it. :kaoslp: Hopefully someone else can help there, sounds like a neat feature! :kaojoy:
 

Okk

Veteran
Veteran
Joined
Apr 24, 2015
Messages
46
Reaction score
11
First Language
English
Primarily Uses
Well, I've managed to make a revive spell that can hit a KOed ally without being shunted to the next living ally, which is a good start. It's not pretty though. I can't use my desired select conditions (Param HP% === 0) because the always evaluate to false, defeated enemies are not valid targets (I can live with that one), and when the spell is forced to miss because the target is alive, they still display their damaged animation and SFX and the 'miss' popup appears twice. (The spell also deals damage instead of healing it, but I'm pretty sure that's an error in my damage formula.)
As is, the spell 'works' in the strictest sense of the word, but I do hope there's a more elegant solution.
 

Okk

Veteran
Veteran
Joined
Apr 24, 2015
Messages
46
Reaction score
11
First Language
English
Primarily Uses
After a little experimenting, I'm starting to wonder if this thread wouldn't be better off in the Plugin Requests board. I could be mistaken, but if my select conditions are ignoring KOed battlers, regardless of what the conditions may be, then I think the plugins may just not support that natively and may need a patch. Most of the time, ignoring dead battlers is fine, but fringe cases always pop up like this.
 

caethyril

^_^
Global Mod
Joined
Feb 21, 2018
Messages
2,862
Reaction score
2,196
First Language
EN
Primarily Uses
RMMZ
The thing is, as mentioned, "Dead Ally" is a separate scope. (And "Dead Enemy", by default, doesn't exist.) It's easy to make a skill that targets only dead allies or only living allies, just select the scope in the database. The DeadOrAliveItem plugin should allow a skill to "combine" these scopes. As such, the select condition "State: 1" seems redundant to me, why not just select Dead Ally scope? :kaoswt2:

If this is about the dead enemy targetting, then yes, I think that'll need another plugin to add the required scope.
 

Okk

Veteran
Veteran
Joined
Apr 24, 2015
Messages
46
Reaction score
11
First Language
English
Primarily Uses
The thing is, as mentioned, "Dead Ally" is a separate scope. (And "Dead Enemy", by default, doesn't exist.) It's easy to make a skill that targets only dead allies or only living allies, just select the scope in the database. The DeadOrAliveItem plugin should allow a skill to "combine" these scopes. As such, the select condition "State: 1" seems redundant to me, why not just select Dead Ally scope? :kaoswt2:

If this is about the dead enemy targetting, then yes, I think that'll need another plugin to add the required scope.

You're right, but that's kind of what I'm on about with my second query: A revive spell that can target either a KOed ally or an enemy with the Undead passive state. With the DeadOrAliveItem plugin and thanks to your compatibility patch, I was able to get a "good enough" situation in place. But ideally, I want a spell that can target any KOed unit or any unit with Undead state, friend or foe, and if no such unit exists, the spell cannot be used. (Why I want so much to let the player hurt themself, who can say?)

Part of the problem is that, until recently, I wasn't clear on the difference between "selecting" and "targeting." When that finally dawned on me during testing, I started digging around in Yanfly's Selection Control in hopes of finding answers, and when I noticed the recurring use of ".aliveMembers" as opposed to ".members" I thought maybe I could make a little patch myself. So I gave that a shot, and not only does it give me the desired result, it only does it when I want it to, via my new notetag.

Unfortunately, I don't actually know Javascript, or the RPG Maker API, or what kind of methods Yanfly employs, and honestly I was never a very good programmer in the first place. As such, I managed to introduce a game-crashing bug in the process. When my skill is chosen, there is no default selection. The player can select a valid unit from there (by pressing up or down I think), but if they try to cast the spell on this null target first, the game crashes. The skill should automatically begin the selection process pointing at a valid target (preferably favoring a KOed ally, if one exists.) This issue only seems to occur when I'm using the custom select notetags below.

I'll go ahead and include my patch here, along with other relevant information, in case anybody wants to take a peek and try to help me out. I really do enjoy programming, I just wish I was better at it.

EDIT: I've disabled my patch, and this bug still exists when using the custom select conditions listed below. KOed enemies are not accounted for, but if there are Undead enemies and no KOed allies, the selection starts pointing at a null target.

Code:
<CAN HIT DEAD>
<scope:oneDeadOrAlive>
<Actor or Enemy Select>

<Custom Select Condition>
  if (target.hp <= 0) {condition = true;}
  else if (target.isStateAffected(244)) {condition = true;}
  else {condition = false;}
</Custom Select Condition>
 

Attachments

  • selectdeadpatch.js
    6 KB · Views: 4
Last edited:

caethyril

^_^
Global Mod
Joined
Feb 21, 2018
Messages
2,862
Reaction score
2,196
First Language
EN
Primarily Uses
RMMZ
Oh I see! Yes: scope, targets, and selection are all different. Will have a look at your patch when I get a chance, see if I can spot anything~
 

Okk

Veteran
Veteran
Joined
Apr 24, 2015
Messages
46
Reaction score
11
First Language
English
Primarily Uses
Will have a look at your patch when I get a chance, see if I can spot anything~

Thank you very much, I would appreciate that.

I've actually managed to reproduce this null target bug without my patch though, in a fresh project. I used only the three aforementioned Yanfly plugins, the Dead Or Alive Item plugin and the compatibility patch, then added these notetags to the Fire skill:
Code:
<Custom Select Condition>
  if (target.mhp == 200) {condition = true;}
  else {condition = false;}
</Custom Select Condition>
<scope:oneDeadOrAlive>
<Actor or Enemy Select>

I made a troop with a bat, a slime and a second bat to test on, and when I choose the fire skill, the selection defaults to nothing. Selecting the null target results in TypeError, Cannot read property 'index' of undefined.
 

caethyril

^_^
Global Mod
Joined
Feb 21, 2018
Messages
2,862
Reaction score
2,196
First Language
EN
Primarily Uses
RMMZ
OK I am still confused but I managed to get an error ("isActor is undefined") with the setup you described, as soon as I selected the Fire skill for use. Looks like it was because two of the listed targets are actually strings: "ALL ALLIES" and "ALL ENEMIES". I added this little override and the error seemed to disappear:
Code:
Window_BattleEnemy.prototype.autoSelectFirstDeadActor = function() {
    var length = this._enemies.length;
    for (var i = 0; i < length; ++i) {
      var member = this._enemies[i];
      if (typeof member === 'string') continue;  // <-- added
      if (member && member.isActor() && member.isDead()) return i;
    }
    return 0;
};
Not sure why we'd see different errors, though, so there's probably still some problem(s) lurking... :kaoslp:
 

Okk

Veteran
Veteran
Joined
Apr 24, 2015
Messages
46
Reaction score
11
First Language
English
Primarily Uses
I added this little override and the error seemed to disappear
This doesn't seem to make a difference for me, in either the new project or my game's revive skill. Was I supposed to just drop it into a plugin at the bottom of my list?
I'm also not sure about the different errors, so I checked the versions of all my yanfly scripts, and they seem to be up to date.
 

caethyril

^_^
Global Mod
Joined
Feb 21, 2018
Messages
2,862
Reaction score
2,196
First Language
EN
Primarily Uses
RMMZ
This doesn't seem to make a difference for me, in either the new project or my game's revive skill. Was I supposed to just drop it into a plugin at the bottom of my list?
I'm also not sure about the different errors, so I checked the versions of all my yanfly scripts, and they seem to be up to date.
Yep, that's what I did, but you'll probably need a different fix given you get a different error. It's difficult for me to guess at the solution if I can't replicate the problem, though, sorry... I'm testing with a v1.6.1 project, maybe that's it? Otherwise hopefully someone else can help. :kaoswt2:
 

Okk

Veteran
Veteran
Joined
Apr 24, 2015
Messages
46
Reaction score
11
First Language
English
Primarily Uses
Yep, that's what I did, but you'll probably need a different fix given you get a different error. It's difficult for me to guess at the solution if I can't replicate the problem, though, sorry... I'm testing with a v1.6.1 project, maybe that's it? Otherwise hopefully someone else can help. :kaoswt2:
I just checked my RPG Maker version, and it looks like I'm using v1.6.2. I made my clean test project in that version. I suppose it's possible that's enough to make the difference.
 

Okk

Veteran
Veteran
Joined
Apr 24, 2015
Messages
46
Reaction score
11
First Language
English
Primarily Uses
1.6.2 and 1.6.1 should have functionally identical code (supporting post by Archeia), the version difference is just because the JP editor needed an update re the closure of a connected service (related Steam announcement).
In that case, I'm a bit stumped. Should I send this fresh project somewhere or something?

EDIT
: I asked a friend of mine if he could help me out. After poring over code for several hours, he finally told me to comment out line 84 of CaeX_YEPDeadOrAlive.js (this.select(iSel);). This appears to have fixed my problem and given me the results I wanted with the revive spell. I hope this edit won't cause issues down the road though...
 
Last edited:

Okk

Veteran
Veteran
Joined
Apr 24, 2015
Messages
46
Reaction score
11
First Language
English
Primarily Uses
It took a while, but I modified my previous script to also allow skills that can only target either entire group. I think I got it functioning right, but working with something as modular as MV is like a stressful scavenger hunt.
@caethyril Thank you for helping me out with this sort of stuff. Please let me know if you think commenting out line 84 could cause problems down the road.
 

Attachments

  • grouponly.js
    7.5 KB · Views: 6

caethyril

^_^
Global Mod
Joined
Feb 21, 2018
Messages
2,862
Reaction score
2,196
First Language
EN
Primarily Uses
RMMZ
Interesting... I think that line only affects who is originally selected after picking a skill to use, shouldn't be a big issue. Then again, I wouldn't have expected it to cause this error in the first place. :kaoslp:

Glad you eventually found a fix, thanks for letting me know! :kaothx:
 
  • Like
Reactions: Okk

Latest Threads

Latest Profile Posts

Can't wait for next update! :)
I really want to get a cat... but our puppy is still... well... a puppy and would eat and bark at a cat if we got one... *sighs* I guess I'll wait a couple of years~
unintentionally made a track that sounds straight out of Yume Nikki
Revisiting one of my older projects in a long time to work some more on the mechanics. I've been working on- and off-again for about a year now on recreating the Force and Mystic systems from Wild ARMs. And I think I've finally made some good breakthroughs on that!

Still, it is not perfect and I may post my thoughts at a later time to see if there are any other suggestions or alternatives I've missed.
actor name string, why you gotta be case sensitive like that?

Forum statistics

Threads
116,111
Messages
1,095,882
Members
151,516
Latest member
HevaCat
Top