Toxsick

Veteran
Veteran
Joined
Sep 21, 2019
Messages
32
Reaction score
4
First Language
English
Primarily Uses
RMMV
Ok
So here are revised instructions based on you having a flexible party composition. Some of them are the same, I'll emphasize the changes:

0- Choose an unused variable in your game to use for this. I'll call it HealerIndex.

1 - Give your troop a turn 0 event that gives your healer an invisible state. I'll call it CheckHeal. Give it an expiration at end of battle.

2 - Create a troop event with a span of Moment and a condition of Switch X ON (an unused switch number in your project).

3 - In the event, make a command from tab 3 -> Script, and enter:
Code:
$gameTroop.members()[enemyIndex].forceAction(silenceId, $gameVariables.value(healerIndexId));
Replace enemyIndex with the enemy you want casting silence, in the order they were added to the troop (so the first enemy you added is 0, second is 1, etc.)
Replace silenceId with the ID of your silence skill.
Replace healerIndexId with the ID of your HealerIndex variable.

3a - This isn't new, but you missed it before: enter the event command to turn switch X OFF.

4 - In your healing spells, put the changed notetag:
Code:
<Custom Execution>
if (user.isStateAffected(stateId))
{
    $gameSwitches.setValue(X, true);
    $gameVariables.setValue(healerIndexId, $gameParty.members().indexOf(user.actorId()));
}
</Custom Execution>
where stateId is the ID for CheckHeal, X is the same switch ID as above, and healerIndexId is the ID of your HealerIndex variable as above.

5 - On the map where these enemies can be fought, make an event that has a blank first page; on page 2, give it a condition of Switch X is ON, trigger type autorun, and have it turn Switch X back OFF.
I’ll try this once I’m home. I hate to bug you further but this would help me not to have to bug you in the future. I read through the code and I think it’s the variable that’s supposed to determine where the healer is in the line up. But I can’t figure out exactly which part changes the variable to show which character used the ability. This would help me in future attempts to code all this sort of stuff in the future.
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
4,568
Reaction score
2,918
First Language
English
Primarily Uses
RMMV
But I can’t figure out exactly which part changes the variable to show which character used the ability.
It's in the Custom Execution notetag that you're adding to each healing skill. user.actorId() returns the actor ID of the person using the skill.

Then, $gameParty.members().indexOf(ID) returns the party index of the actor that has a given ID. So:
Code:
$gameParty.members().indexOf(user.actorId()));
will give you the party index of the actor using the healing ability.

We then store that in your chosen game variable, so:
Code:
$gameVariables.setValue(healerIndexId, $gameParty.members().indexOf(user.actorId()));

Then we use the JavaScript version of Force Action so that we're not limited to the drop-down menu in the event command, we can use the value of that variable to tell the enemy which party member index to target.
 

Toxsick

Veteran
Veteran
Joined
Sep 21, 2019
Messages
32
Reaction score
4
First Language
English
Primarily Uses
RMMV
It's in the Custom Execution notetag that you're adding to each healing skill. user.actorId() returns the actor ID of the person using the skill.

Then, $gameParty.members().indexOf(ID) returns the party index of the actor that has a given ID. So:
Code:
$gameParty.members().indexOf(user.actorId()));
will give you the party index of the actor using the healing ability.

We then store that in your chosen game variable, so:
Code:
$gameVariables.setValue(healerIndexId, $gameParty.members().indexOf(user.actorId()));

Then we use the JavaScript version of Force Action so that we're not limited to the drop-down menu in the event command, we can use the value of that variable to tell the enemy which party member index to target.
Ohh so this actually is much better then the previous version because it’s not limited to just the healer I can add this to any heal skill and it’ll locate that skill reference it with the actor then silence them? This is exactly what I was looking for thank you so much!! And thank you for the explanation I can use similar codes to achieve other results I’m thinking if as well so I appreciate the patience.
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
4,568
Reaction score
2,918
First Language
English
Primarily Uses
RMMV
If you're thinking of using this in more situations, I would suggest that instead of having an event on every map to turn the switches back off, install a plugin that runs a common event at the end of every battle and turns them all off there.
 

Toxsick

Veteran
Veteran
Joined
Sep 21, 2019
Messages
32
Reaction score
4
First Language
English
Primarily Uses
RMMV
If you're thinking of using this in more situations, I would suggest that instead of having an event on every map to turn the switches back off, install a plugin that runs a common event at the end of every battle and turns them all off there.
Ok I’ll do that. Does yanfly possibly have a plug in for that? Cuz I was planning on using this sort of targeting system in a few diff ways.
 

AphoticAmaranth

An Ordinary Human
Veteran
Joined
Mar 29, 2020
Messages
244
Reaction score
327
First Language
English
Primarily Uses
RMMV
Ok I’ll do that. Does yanfly possibly have a plug in for that? Cuz I was planning on using this sort of targeting system in a few diff ways

Base troop events should be able to do it.


Though, might I suggest an alternative method, using YEP BattleAI Core?

On each of your healing skills, have it add an invisible state to the caster, if it is used while in battle. Set it to remove on battle end.

Code:
<Custom Execution>
if($gameParty.inBattle())
{
    user.addState(n); //Replace 'n' with your invisible state's number
}
</Custom Execution>

Then, on your silence skills, at the top of the AI priority list, have the enemies target players with that state

Code:
<AI Priority>
STATE === State n : Silence        //Replace 'n' with your invisible state's number, 'Silence' with whatever your silence spell is called
</AI Priority>

This way, you won't have to worry about turning off a switch after every battle, since we're relying on the state to determine if the player is a healer, and the state will be automatically removed at the end of the battle. Also, this would allow more than one character to be labelled as a healer.
 

Toxsick

Veteran
Veteran
Joined
Sep 21, 2019
Messages
32
Reaction score
4
First Language
English
Primarily Uses
RMMV
Base troop events should be able to do it.


Though, might I suggest an alternative method, using YEP BattleAI Core?

On each of your healing skills, have it add an invisible state to the caster, if it is used while in battle. Set it to remove on battle end.

Code:
<Custom Execution>
if($gameParty.inBattle())
{
    user.addState(n); //Replace 'n' with your invisible state's number
}
</Custom Execution>

Then, on your silence skills, at the top of the AI priority list, have the enemies target players with that state

Code:
<AI Priority>
STATE === State n : Silence        //Replace 'n' with your invisible state's number, 'Silence' with whatever your silence spell is called
</AI Priority>

This way, you won't have to worry about turning off a switch after every battle, since we're relying on the state to determine if the player is a healer, and the state will be automatically removed at the end of the battle. Also, this would allow more than one character to be labelled as a healer.
Wouldn’t this have the enemy to just continue silencing though? Since the state is never removed the AI core would just have the monster re apply silence next turn wouldn’t it?
 

AphoticAmaranth

An Ordinary Human
Veteran
Joined
Mar 29, 2020
Messages
244
Reaction score
327
First Language
English
Primarily Uses
RMMV
Wouldn’t this have the enemy to just continue silencing though? Since the state is never removed the AI core would just have the monster re apply silence next turn wouldn’t it?

Yes, if you set the state to only expire at the end of battle.

If you do not want the enemy to continue silencing throughout the rest of the battle, you could set the state to expire after 1~2 turns.

If you just want to avoid the enemy casting silence on an already silenced player, you could write

Code:
<AI Priority>
STATE === State n +++ STATE !== Silence : Silence
</AI Priority>
 

Latest Threads

Latest Profile Posts

ScreenShot_7_1_2022_11_41_55.png
When the Panic gauge is full, Mike will turn into Omar in a state of actual panic. his move list changes and until the meter depletes completely, he'll be able make use of this alter ego.
So unbelievably excited for IGMC this year! First public game was for the original one and I'm just so pumped!!
Sometimes I am amazed at how relentless spam bots are. I would clear the que and then see 800~5k more depending on their mood.
Work on UD is already so delayed but I gotta drop everything so that I have something ready for IGMC!
Messed up the chains... :kaoback:
Sw7U8dA.jpg

Character: Jeanne D'Arc from Fate/Apocrypha.

Forum statistics

Threads
123,255
Messages
1,155,242
Members
161,636
Latest member
qixxi
Top