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,703
Reaction score
2,804
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,703
Reaction score
2,804
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,703
Reaction score
2,804
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

Ugh, I opened MV after a few weeks and I'm completely lost on what I was working on.
Does it happen to someone else or am I the only disorganized one around? :kaoswt:
xH5Fk2f.jpg
Today was not a really productive day, but at least i got some bust sketches going <3
E7QXZHNXoAIkpG8
hmm in exploring MZ with FOSSIL... I see I'll probably need to stick with MV for now as none of the menu altering plugins I use work on MZ lol. and I don't have the money to dump into what I would need in some cases to update plugins to their MZ versions. Everytime I think of converting, 5 or more reasons popup on why I shouldn't.
Hmm... Game has 91 views, 25 downloads, 5 reviews and netted me 7 additional followers. Meanwhile the image I posted just yesterday on Imgur to showcase it has 45,197 views. Interesting, I think I have a new advertising idea. Also Twitter? The post got 16 retweets, 20 likes, and 1,683 views.... And a whole 3 hits to my game, completely valueless. I am glad I did this game jam, this information is quite valuable.
We're playing another Touch the Stars game jam entry, come join us! :D

Forum statistics

Threads
113,661
Messages
1,076,499
Members
147,681
Latest member
antales
Top