I'm sorry.... "Prototype"?
JavaScript questions that don't deserve their own thread
Javascript/Plugin Supportah. thats what was missing. I had installed LGP_BetterDamagePopup somewhat recently and noticed at some point that all 0 damage popups stopped. Instead of being sensible and assuming it was that, i chose to gaslight myself into thinking that they probably never showed before up and a yanfly plugin did it 🤣
save it as a js file and use it as a plugin, but make the changes they suggest to the
Code:
} else if (result.hpAffected) {
Anyone know what this thing is called? Like in the scripts. I want to find a way to make it stop flashing/blinking/flickering but im running out of words to search for xD
The English word for a UI element that highlights what you're selecting is the cursor.
If you don't want it to fade in and out, you can paste the below into a text editor, save as a *.js file, and include as a plugin:
Code:
Window.prototype._makeCursorAlpha = function() {return this.contentsOpacity/255;};
Wow, im glad im not the type to become embarrassed now 😛 Guess i've been using a custom cursor for so long that the default one doesnt feel like one xD
Tnx!
Could I get a script to check if an actor is affected with a state with a certain notetag, e.g. <aura>?
@AquaEcho - if
If you're starting with an actor ID, you can use
actor is a Game_Actor reference, then you could try:
JavaScript:
actor.states().some(state => "aura" in state.meta)
$gameActors.actor(id) instead, e.g.
JavaScript:
$gameActors.actor(1).some(state => "aura" in state.meta)
Thank you, it works. Follow up: How do I get the state ID of the first result?
I think you could use this in Control Variables -> Script:
JavaScript:
var id = 0; for (var state of actor.states()) if (state.meta.aura) { id = state.id; break; }; id
actor if necessary.)Hi. I have a little old enemy with a skill where they block the damage taken by the next attack (this skill applies a state to the enemy that makes them very tanky, pretty much). I would like to store this damage value into a variable, so I can use this value in the damage formula for this little enemy's second skill.
Any tips on how to implement this?
Any tips on how to implement this?
if you have yanfly's buffs and states, you can try putting
in the state's notebox. just replace the "x"s for some variable ID and refer to it in that skill's damage formula
Code:
<custom react effect>
if (this.isDamage() && value > 0)
$gameVariables.setValue(x, $gameVariables.value(x) + value);
</custom react effect>
EDIT: sorry for the poor wording, edited and hope it’s clear now…
I need a fresh set of eyes here. I want a parallel event to trigger when neither the player nor its followers are at its location. I can't get it to work so am trying to output it to the console to see what is going on and... the parameters seem right, yet the check fails…
I move the player away and the output says:
So nothing happens when the Player x and Event x do seem to be different... any idea?
I need a fresh set of eyes here. I want a parallel event to trigger when neither the player nor its followers are at its location. I can't get it to work so am trying to output it to the console to see what is going on and... the parameters seem right, yet the check fails…
JavaScript:
(!$gamePlayer.x == $gameMap.event(this._eventId).x) &&
(!$gamePlayer.followers().data().some((follower) => follower.x == $gameMap.event(this._eventId).x));
console.log("Player X: " + $gamePlayer.x + ", Event X: " + $gameMap.event(this._eventId).x + ", Player away: " + (!$gamePlayer.x == $gameMap.event(this._eventId).x) + ", Followers away: " + (!$gamePlayer.followers().data().some((follower) => follower.x == $gameMap.event(this._eventId).x)));
I move the player away and the output says:
Player X: 47, Event X: 39, Player away: false, Followers away: trueSo nothing happens when the Player x and Event x do seem to be different... any idea?
@werzaque OMG dude, really? Code tags, line breaks, something!
You have some random placements of the NOT operator which is not doing what you are probably trying to do.
you're comparing a boolean result (the NOT operator will produce true or false) to a numeric value (the value of the event's x coordinate).
I'm not sure what you're actually going for...are you trying to check
?
You have some random placements of the NOT operator which is not doing what you are probably trying to do.
!$gamePlayer.x is true if the x is a zero (or undefined) value. When you say
Code:
(!$gamePlayer.x == $gameMap.event(this._eventId).x)
I'm not sure what you're actually going for...are you trying to check
Code:
$gamePlayer.x != $gameMap.event(this._eventId).x
EDIT: managed to get it to work, see below in green.
Sorry for the block of code... so I tried your suggestion and now have:
Moving away from the event the console says:
Yet still nothing happens...
For context (please ignore the second IF, in the process of isolating the problem):
EDIT: I got it to work by reversing the order of the main code and the console.log part, i.e.:
So apparently only the last line of code is regarded for the script in the IF command. Which kind of makes sense now that I think about it...
Sorry for the block of code... so I tried your suggestion and now have:
JavaScript:
($gamePlayer.x != $gameMap.event(this._eventId).x) &&
!($gamePlayer.followers().data().some((follower) => follower.x == $gameMap.event(this._eventId).x));
console.log(
"Player X: " + $gamePlayer.x +
", Event X: " + $gameMap.event(this._eventId).x +
", Player away: " + ($gamePlayer.x != $gameMap.event(this._eventId).x) +
", Followers away: " + !($gamePlayer.followers().data().some((follower) => follower.x == $gameMap.event(this._eventId).x))
);
Moving away from the event the console says:
Player X: 45, Event X: 39, Player away: true, Followers away: trueYet still nothing happens...
For context (please ignore the second IF, in the process of isolating the problem):
EDIT: I got it to work by reversing the order of the main code and the console.log part, i.e.:
JavaScript:
console.log(
"Player X: " + $gamePlayer.x +
", Event X: " + $gameMap.event(this._eventId).x +
", Player away: " + ($gamePlayer.x != $gameMap.event(this._eventId).x) +
", Followers away: " + !($gamePlayer.followers().data().some((follower) => follower.x == $gameMap.event(this._eventId).x))
);
($gamePlayer.x != $gameMap.event(this._eventId).x) &&
!($gamePlayer.followers().data().some((follower) => follower.x == $gameMap.event(this._eventId).x));
So apparently only the last line of code is regarded for the script in the IF command. Which kind of makes sense now that I think about it...
Wonderful. Thank you so much!
---
I have an unrelated question, and I know I should not double post, so here it is: Is there a way to use an enemy's TP value as a check when using Yanfly's Battle AI Core? The plugin documentation does not mention TP [edit: More precisely, it allows targeting based on TP values, but that is not what I am looking for], so I would assume not, but maybe there is a way? For example, say I have a skill that can only be used if the enemy has over 50 TP, and more than 1 MP. Checking the MP value is simple enough:
JavaScript:
<AI Priority>
User MP param >= 1: SKILL 67
</AI Priority>
But this does not work, sadly:
JavaScript:
<AI Priority>
User MP param >= 1 +++ User TP param >= 50: SKILL 67
</AI Priority>
you could use
Code:
Eval user.tp > 50
if you want to talk about overengineered solutions, skill requirements are considered when the ai is selecting a skill. so if you had a duplicate version of the skill with a tp requirement of 50, it would have to be respected. its more work than using the eval, but its an idea that may be a useful idea for you later
Thank you again!
I have a question related to my first problem above (the one regarding the variable). I have been unable to store the damage value in the variable, in spite of implementing your suggestion. Here is what I have done so far.
I gave the variable an initial value (of zero--and I tried giving it an absurd value of 50, for testing purposes, and the enemy could one shot the player character just fine, as opposed to dealing zero damage).
I added your suggest code to the 'counter' STATE notebox (I think I may have misunderstood the instructions, and this is where the error is at):
JavaScript:
<custom react effect>
if (this.isDamage() && value > 0)
$gameVariables.setValue(501, $gameVariables.value(501) + value);
</custom react effect>
And, I tried this very basically formula (for the secondary skill) to see if it works at all: v[501]. Yup, just variable value as the damage value. However, if I add the variable value to my usual formula, it does not work at all. My usual formula is: (a.atk + skill_damage) - b.def) + 1. In this case, it would be ((a.atk + v[501]) - b.def) + 1. Still, the main problem is I failed to store the damage value in the variable.
an easy way to see if the state is working without opening up the console is to set a troop event to use show text to display the variable at the end of every turn. it should only increase on turns where the enemy is hit while the state is active
a thing to note is that if you use the variable that way, it needs to have its value set somewhere first. if not, v[501] will be undefined and would cause the entire formula as you have it to not result in any damage being dealt. if damage was dealt to the enemy while the state is active, then it should be fine, otherwise it wouldnt do anything no matter what the a.atk and b.def are
I actually did that. I have a message that shows the value of the variable, at the end of every turn, and it always says 0. As for your second suggestion, I did that as well. I set the variable to 0, before the battle processing event is run.
So, I am assuming I did not mess up the code I shared above?
nope. what you have should work just fine. theres no mistakes there or anything.
just as a sanity check, yanfly's buffs and states plugin is installed, youve saved your project after setting the notetag, and youve made a new save file for the playtest while trying this out instead of loading one?
Original thread: https://forums.rpgmakerweb.com/threads/javascript-questions-that-dont-deserve-their-own-thread.46341/