LSDolphin

Villager
Member
Joined
Mar 28, 2021
Messages
7
Reaction score
0
First Language
English
Primarily Uses
RMMV
So I'm using Buffs & States to create a "flight" state where flying enemies can only be hit by long range skills. If the attacks are not long range, they miss. Yanfly has written some example shield states that are very similar to what I need, so I used those as examples.

Of course, I'm here, so that means that my code does not work. Oddly enough, neither do Yanfly's examples when I test those in my own game. Thought it might be some plugin incompatibility or something, so I double checked that my plugins were in the right load order. They're as suggested. I loaded only Yanfly's plugins into a fresh test project and tested it there. No luck there either. Thought maybe the Custom Select Effect itself wasn't triggering, but if I set this.item().successRate to zero on its own without conditionals then the success rate is indeed set to zero.

So to recap:
1. Notebox code very close to original code, but doesn't work.
2. Original code does not work either.
3. Fresh project exhibits the same issues.
4. Custom Select Effect IS working... but it's allergic to conditionals.

Mysterious!

Here's my notebox code for reference:
<Custom Select Effect> if (this.item() && DataManager.isSkill(this.item()) && this.isForOpponent()) { // create a list of valid skill types. var validtypes = []; // Add the skill type ID's to that pool. validtypes.push(4, 6, 8); // Create a pool of valid skills. var validskills = []; // Add the individual skill ID's to that pool. validskills.push(16,17,20); // check to see if it's a valid move if (!validtypes.contains(this.item().stypeId) || !validskills.contains(this.item().id)) { // store the original success rate. this._formerItemSuccessRate = this.item().successRate; // set the attack to miss. this.item().successRate = 0; } } </Custom Select Effect> <Custom Deselect Effect> // if the success rate has been changed, restore it if (this._formerItemSuccessRate !== undefined) { this.item().successRate = this._formerItemSuccessRate; } </Custom Deselect Effect>
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
3,711
Reaction score
2,823
First Language
English
Primarily Uses
RMMZ
So am I to understand that you're trying to make it so that if the battler with the state is targeted with a skill not of type 4/6/8 or not with the specific skill IDs 16, 17 or 20, it'll miss? (in other words, those three types and three specific skills are the only ones that'll hit)

And it's not doing that currently?
 

LSDolphin

Villager
Member
Joined
Mar 28, 2021
Messages
7
Reaction score
0
First Language
English
Primarily Uses
RMMV
So am I to understand that you're trying to make it so that if the battler with the state is targeted with a skill not of type 4/6/8 or not with the specific skill IDs 16, 17 or 20, it'll miss? (in other words, those three types and three specific skills are the only ones that'll hit)

And it's not doing that currently?
Yep--2/6/8 are Skill Types that are always long ranged and skills 12/17/20 are specific long ranged Skills. So: if it's not a long ranged Skill Type or a long ranged Skill, it should miss. With my current setup, everything misses, no matter what skill is used.

...After typing that out, I realize that maybe I need to make that operator an "and" instead of an "or." I'm going to see how that goes and report back.

EDIT: Nope, setting it to "and" doesn't change anything and all skills continue to miss. The plot thickens.

EDIT: Fixed it just by shuffling some things around and realizing that one of the skills I was using to test this feature was not actually actually on the valid skill list.
<Custom Select Effect> if (this.item() && DataManager.isSkill(this.item()) && this.isForOpponent()) { // create a list of valid skill types. var validtypes = [4, 6, 8]; // Create a pool of valid skills. var validskills = [16,17,20]; // check to see if it's a valid move if (validtypes.contains(this.item().stypeId)) { // if it's a valid skill type, do nothing and let it run as usual. } else if (validskills.contains(this.item().id)) { // if it's a valid skill, do nothing and let it run as usual. } else { // store the original success rate. this._formerItemSuccessRate = this.item().successRate; // force the attack to miss. this.item().successRate = 0; } } </Custom Select Effect> <Custom Deselect Effect> // if the success rate has been changed, restore it if (this._formerItemSuccessRate !== undefined) { this.item().successRate = this._formerItemSuccessRate; } </Custom Deselect Effect>
 
Last edited:

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
3,711
Reaction score
2,823
First Language
English
Primarily Uses
RMMZ
I'm surprised that that works, since as far as I can tell those if statements now do literally nothing.
 

LSDolphin

Villager
Member
Joined
Mar 28, 2021
Messages
7
Reaction score
0
First Language
English
Primarily Uses
RMMV
I'm surprised that that works, since as far as I can tell those if statements now do literally nothing.
If you look closely they now check if the condition is true instead of false like in my initial code. So if (the skill is on the list of valid skills/skill types), then {do nothing and let the attack proceed as normal} else {force the attack to miss}.
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
3,711
Reaction score
2,823
First Language
English
Primarily Uses
RMMZ
If you look closely they now check if the condition is true instead of false like in my initial code. So if (the skill is on the list of valid skills/skill types), then {do nothing and let the attack proceed as normal} else {force the attack to miss}.
Edit: nvm, my brain filled in an extra curly bracket where there wasn't one. I see what you're doing now. There's a more efficient way to write it than that but if it works there's no point in poking at it. :p
 
Last edited:

Latest Threads

Latest Posts

Latest Profile Posts

finally drew the last member of "team outcast" for my game. since my game has a lot fighting game elements in it, there's bosses in teams of three like King of Fighters.
Run Script Calls & Play Unique Sound Effects With Each Skill & Item | RPG Maker News #113

Let's continue making our game in MZ! Touchfuzzy is... still eventing... though this time we may be working on eventing some tutorial stuff for our players!

I work late on the game so I sleep in then I wake up late so I have to work hard to make up for sleeping in meaning I work late again and sleep in again... what a nasty cycle.
I just had my first real fire. Dad made burgers for lunch and the grill caught fire. He tried to get water but I told him you should never put water on a grease fire. So I got him the fire extinguisher under the sink and we managed to put it out. I can still smell a little of the smoke coming from the patio, but at least it's clearing. It sure was scary though.

Forum statistics

Threads
113,843
Messages
1,077,909
Members
147,923
Latest member
bluetop
Top