JavaScript questions that don't deserve their own thread

Lanzy

Veteran
Veteran
Joined
Feb 29, 2020
Messages
122
Reaction score
50
First Language
English
Primarily Uses
RMMV
Howdy, developers!

How do I:
- Completely nullify TP natural Gain?
- Hide TP Bars outside of battles?

I want TP Bars only to be shown in battle, and each character will have it's own methods of gaining TP.
I'd be interested in seeing the solution to that question as well ^^ :D
I'm assuming you are using MV.

How to completely nullify TP natural gain:

JavaScript:
//this will only have enemies gain tp by damage
Game_Battler.prototype.chargeTpByDamage = function(damageRate) {
    if (this.isEnemy()) {
        var value = Math.floor(50 * damageRate * this.tcr);
        this.gainSilentTp(value);
    }
};
//this will only have enemies gain tp each round
Game_Battler.prototype.regenerateTp = function() {
    if (this.isEnemy()) {
        var value = Math.floor(100 * this.trg);
        this.gainSilentTp(value);
    }
};
//this will only have enemies gain tp by item effects (this might cause trouble if you want to 
//have actors gain tp through item effects. If so, just delete this part.
Game_Action.prototype.applyItemUserEffect = function(target) {
    var value = Math.floor(this.item().tpGain * this.subject().tcr);
    if(this.subject().isEnemy()) this.subject().gainSilentTp(value);
};

//turns off initial tp given at beginning of battle
Game_Battler.prototype.initTp = function() {
    if (this.isEnemy()) this.setTp(Math.randomInt(25));
};
Just add this code to your plugins.

I checked and couldn't find any other place than the battles where TP gauges are visible.
So I don't know where else you would want to hide them?
 

HELLFIRE3110

Omega Deciple
Member
Joined
Jan 6, 2015
Messages
8
Reaction score
10
First Language
English
Primarily Uses
RMMV
Thank you so much @Lanzy, this cleared up a lot of things I was having issues with in one go!
 

CHKNRAVE

Surprisingly not sponsored by Yanfly.
Veteran
Joined
May 11, 2020
Messages
114
Reaction score
65
First Language
French
Primarily Uses
RMMV
Is there a way to prevent Gab Window from clearing gabs on map change? It's a bad feature given what I use it for.
 

Lanzy

Veteran
Veteran
Joined
Feb 29, 2020
Messages
122
Reaction score
50
First Language
English
Primarily Uses
RMMV
Is there a way to prevent Gab Window from clearing gabs on map change? It's a bad feature given what I use it for.
Unless there is an option in the plugin to carry gabs over to a new map, this problem is not solvable without some more or less extensive coding.
 

zelanius

Everyman
Veteran
Joined
Apr 29, 2020
Messages
46
Reaction score
4
First Language
English
Primarily Uses
RMMV
Hi, I am trying to find a way to apply a state with items upkeep. I applied the Mending Tips and Tricks from YEP (link: http://www.yanfly.moe/wiki/Mending_(MV_Plugin_Tips_&_Tricks)) but made changes, and came up with the following:

<Custom Regenerate Effect>
if ($gameActors.actor(1).isAlive() && $gameParty.numItems($dataItems[$gameVariables.value(25)]) >= 1) {
$gameParty.loseItem($dataItems[$gameVariables.value(25)], 1);
} else {
var regen = -100;
user.gainHp(regen);
user.startDamagePopup();
user.clearResult();
}
</Custom Regenerate Effect>

However, it does not reduce the item for some reason. If I do MP and follow the original (with the change being from "origin" to actor 1 only, and adding the -100 regen effect), it works perfectly, so not sure what I am doing wrong when I tried to change it over.

Just to explain, the purpose of this is to create summons with item upkeep cost (and I limited summon skills to actor 1, my main character), after which the summon would start losing HP every turn until it collapses.
 

CHKNRAVE

Surprisingly not sponsored by Yanfly.
Veteran
Joined
May 11, 2020
Messages
114
Reaction score
65
First Language
French
Primarily Uses
RMMV
Try user.consumeItem(itemID) to consume items in combat. It's the recommended command for damage formulas.
 

zelanius

Everyman
Veteran
Joined
Apr 29, 2020
Messages
46
Reaction score
4
First Language
English
Primarily Uses
RMMV
Try user.consumeItem(itemID) to consume items in combat. It's the recommended command for damage formulas.
Thanks CHKNRAVE, but the item is still not reducing. I ran a few turns in battle to be sure, but the -regen did not happen, and when I escaped the battle, my inventory still had the item.
 

CHKNRAVE

Surprisingly not sponsored by Yanfly.
Veteran
Joined
May 11, 2020
Messages
114
Reaction score
65
First Language
French
Primarily Uses
RMMV
Are the 2 conditions still valid? You need Actor 1 to be alive, and for the item whose ID is in variable number 25 to still be in the inventory. Try making a battle event that just displays as a message \V[25]. Is this the ID of the item that needs to be checked and consumed?

Also, apparently, the correct syntax for an item owned condition is $gameParty._items[itemID] >= n, in your case the first line should be if($gameActors.actor(1).isAlive() && $gameParty._items[$gameVariables.value(25)] >= 1) { . The reason why your item count doesn't decrease could be that the condition is just never true because of that.
Can you try this condition and tell me if it works?
 
Last edited:

zelanius

Everyman
Veteran
Joined
Apr 29, 2020
Messages
46
Reaction score
4
First Language
English
Primarily Uses
RMMV
Are the 2 conditions still valid? You need Actor 1 to be alive, and for the item whose ID is in variable number 25 to still be in the inventory. Try making a battle event that just displays as a message \V[25]. Is this the ID of the item that needs to be checked and consumed?

Also, apparently, the correct syntax for an item owned condition is $gameParty._items[itemID] >= n, in your case the first line should be if($gameActors.actor(1).isAlive() && $gameParty._items[$gameVariables.value(25)] >= 1) { . The reason why your item count doesn't decrease could be that the condition is just never true because of that.
Can you try this condition and tell me if it works?
Thanks for the response, but it doesn't work either. It does not detect the item and went straight to the 2nd condition. However, with what you responded, I managed to adjust my original code, and the below does work perfectly, so thank you very much!

<Custom Regenerate Effect>
if ($gameActors.actor(1).isAlive() && $gameParty._items[25] {
$gameParty.loseItem($dataItems[25], 1);
} else {
var regen = -100;
user.gainHp(regen);
user.startDamagePopup();
user.clearResult();
}
</Custom Regenerate Effect>
 

CHKNRAVE

Surprisingly not sponsored by Yanfly.
Veteran
Joined
May 11, 2020
Messages
114
Reaction score
65
First Language
French
Primarily Uses
RMMV
Thanks for the response, but it doesn't work either. It does not detect the item and went straight to the 2nd condition. However, with what you responded, I managed to adjust my original code, and the below does work perfectly, so thank you very much!

<Custom Regenerate Effect>
if ($gameActors.actor(1).isAlive() && $gameParty._items[25] {
$gameParty.loseItem($dataItems[25], 1);
} else {
var regen = -100;
user.gainHp(regen);
user.startDamagePopup();
user.clearResult();
}
</Custom Regenerate Effect>
Watch out, you're missing a little closing parenthese in the first line of code.
 

Dio_Brando

Villager
Member
Joined
Sep 11, 2020
Messages
26
Reaction score
3
First Language
English
Primarily Uses
RMMV
what are the javascript commands for visustella? i cant seem to find a list of them.
 

zelanius

Everyman
Veteran
Joined
Apr 29, 2020
Messages
46
Reaction score
4
First Language
English
Primarily Uses
RMMV
Watch out, you're missing a little closing parenthese in the first line of code.
thanks for pointing out! I totally missed it when I copied it over into the forum (it's correct in my notetag). The revised one is here:

<Custom Regenerate Effect>
if ($gameActors.actor(1).isAlive() && $gameParty._items[25] >= 1) {
$gameParty.loseItem($dataItems[25], 1);
} else {
var regen = -100;
user.gainHp(regen);
user.startDamagePopup();
user.clearResult();
}
</Custom Regenerate Effect>
 

CHKNRAVE

Surprisingly not sponsored by Yanfly.
Veteran
Joined
May 11, 2020
Messages
114
Reaction score
65
First Language
French
Primarily Uses
RMMV
How do I get the total value of all tags with the same name inside the states worn by a specific actor / enemy in battle?

I want to do custom stats and temporary boosts, and the first one will be Damage. I got it to work with equipment, but now I'm stuck on states.

It's all going to fit inside a Custom Confirm Effect.
What I want to do is to create a variable that starts at 0, then scan for every state the user of the skill is wearing in case some have a <Damage: X> tag, and add these X values to the variable so the total is added to value at the end.
 

StrawberrySmiles

The Talking Fruit
Veteran
Joined
Nov 23, 2012
Messages
1,762
Reaction score
568
First Language
English
Primarily Uses
RMMV
Hey peeps!

How can I show a character's equipment on other screens, like on the main menu next to their HP/MP/TP/etc? I thought I could find it and it'd be easy, but I was wrong lol.
 

Nate_Tillern

Villager
Member
Joined
Apr 14, 2019
Messages
11
Reaction score
0
First Language
English
Primarily Uses
RMMV
Hey all, so I'm using Yanfly's States Core plugin and I think I'm just lacking the proper syntax knowledge to achieve what I want.

I want states that buff stats, but to have the buff dependent on the intelligence of the character who applied the buff. I have been testing this with a state that should buff the targets intelligence by an amount dependent on the caster's intelligence, I have been messing around with the following basic notetag:

<Custom Apply Effect>

target.mat = target.mat * (1 + (origin.mat / 1000));

</Custom Apply Effect>

This does not cause any errors when I try to use the skill that applies the state in battle, but no change to damage dealt by spells dependent on intelligence occurs once the state is applied. Even when I make the change radical (e.g. target.mat = target.mat + 500). I'm guessing I just don't know the syntax well enough to properly refer to the things I want changed. Any help is greatly appreciated.
 

zelanius

Everyman
Veteran
Joined
Apr 29, 2020
Messages
46
Reaction score
4
First Language
English
Primarily Uses
RMMV
Hey all, so I'm using Yanfly's States Core plugin and I think I'm just lacking the proper syntax knowledge to achieve what I want.

I want states that buff stats, but to have the buff dependent on the intelligence of the character who applied the buff. I have been testing this with a state that should buff the targets intelligence by an amount dependent on the caster's intelligence, I have been messing around with the following basic notetag:

<Custom Apply Effect>

target.mat = target.mat * (1 + (origin.mat / 1000));

</Custom Apply Effect>

This does not cause any errors when I try to use the skill that applies the state in battle, but no change to damage dealt by spells dependent on intelligence occurs once the state is applied. Even when I make the change radical (e.g. target.mat = target.mat + 500). I'm guessing I just don't know the syntax well enough to properly refer to the things I want changed. Any help is greatly appreciated.
Even if it works, the problem is that this apply effect will stay even after the states are removed.

I am kind of copying some things over that I know (but it's super limited), but maybe the below works, as it amplifies damage, instead of boosting the state's user mat permanently. Idea from: http://www.yanfly.moe/wiki/Black_Resonance_(MV_Plugin_Tips_&_Tricks)

<Custom Confirm Effect>
// Check if this is a skill that deals HP damage
if (this.isSkill() && this.isHpEffect() && value > 0) {
// Make a pool of the skill types that uses mat
var skillTypes = [];
// Insert the skill types you want applied here
skillTypes.push(x, y, z);
// Create a pool of individual skills that uses mat (you might have skills within other skill types)
var skills = [];
// Add the individual skill ID's to that pool
skills.push(a, b, c);
// Check if the current skill has the skill type
if (skillTypes.contains(this.item().stypeId)) || skills.contains(this.item().Id)) {
// Use the origin mat as a multiplier
var multiplier = 1 + origin.mat/1000;
// Adjust the damage by the multiplier
value *= multiplier;
// Round up the damage
value = Math.ceil(value);
}
}
</Custom Confirm Effect>

However, I am not an expert in JS, so might need someone to run through this script and correct any syntax I might have missed out.
 

Nate_Tillern

Villager
Member
Joined
Apr 14, 2019
Messages
11
Reaction score
0
First Language
English
Primarily Uses
RMMV
Even if it works, the problem is that this apply effect will stay even after the states are removed.

I am kind of copying some things over that I know (but it's super limited), but maybe the below works, as it amplifies damage, instead of boosting the state's user mat permanently. Idea from: http://www.yanfly.moe/wiki/Black_Resonance_(MV_Plugin_Tips_&_Tricks)

<Custom Confirm Effect>
// Check if this is a skill that deals HP damage
if (this.isSkill() && this.isHpEffect() && value > 0) {
// Make a pool of the skill types that uses mat
var skillTypes = [];
// Insert the skill types you want applied here
skillTypes.push(x, y, z);
// Create a pool of individual skills that uses mat (you might have skills within other skill types)
var skills = [];
// Add the individual skill ID's to that pool
skills.push(a, b, c);
// Check if the current skill has the skill type
if (skillTypes.contains(this.item().stypeId)) || skills.contains(this.item().Id)) {
// Use the origin mat as a multiplier
var multiplier = 1 + origin.mat/1000;
// Adjust the damage by the multiplier
value *= multiplier;
// Round up the damage
value = Math.ceil(value);
}
}
</Custom Confirm Effect>

However, I am not an expert in JS, so might need someone to run through this script and correct any syntax I might have missed out.
Thank you for the insight into how the notetags work and for the quick reply. The damage modification seems like it would be effectively the same thing, I will try to see if I can get the code to run.

Just out of curiosity, could you theoretically include both <Custom Apply Effect> and then<Custom Remove Effect> to edit stats and then have them revert? Assuming you have the math be properly inverted?

Edit: I have another quick question, I follow the logic of creating vectors of skill types and skills themselves to then check for when doing the multiplier, code-wise should I refer to them using their string name or using the two/three digit number they have?
 
Last edited:

zelanius

Everyman
Veteran
Joined
Apr 29, 2020
Messages
46
Reaction score
4
First Language
English
Primarily Uses
RMMV
Thank you for the insight into how the notetags work and for the quick reply. The damage modification seems like it would be effectively the same thing, I will try to see if I can get the code to run.

Just out of curiosity, could you theoretically include both <Custom Apply Effect> and then<Custom Remove Effect> to edit stats and then have them revert? Assuming you have the math be properly inverted?

Edit: I have another quick question, I follow the logic of creating vectors of skill types and skills themselves to then check for when doing the multiplier, code-wise should I refer to them using their string name or using the two/three digit number they have?
Hi, I tried the <Custom Apply Effect> and then <Custom Remove Effect>, but the problem is, the maths needed got a bit too complicated (mostly I was using Math.round() function, so it always returns an integer, and then I added that value in Custom Apply Effect, but when I do the same for Custom Remove Effect, the amount to remove had to be recalculated, and was calculated on the higher user mat, which caused the removal to be higher than the added amount. Theoretically, you could create variables to store the original mat, but if you have a big cast of actors, you would need 1 variable for each (including any "guest" characters).

For the vectors you mentioned, you just need the ID of the skills or type in the database as an integer, so 0001 would be just 1, 0020 would be just 20, so on and so forth.
 

Users Who Are Viewing This Thread (Users: 1, Guests: 4)

Latest Threads

Latest Posts

Latest Profile Posts

I always told my DA fans how much I hate slot machines. They're fine in games as a risk-and-reward system. But when you're spending REAL MONEY in a Vegas casino to try and hit the jackpot (which very, very few people will), it can really hurt your budget. Gambling is a bad habit, and I don't like wasting my money on a slim chance. Go to Vegas for the experience, not the jackpot.
Took the kids to a corn maze. They gave us a map and had lights at certain points in the maze. Not overwhelming... or underwhelming... just... whelming.
Okay, vacuuming fruit flies out of the air is surprisingly effective.
Finally finished my menu redesign after like a month of coding! I hate designing menus... Good news though - I thought of a complete redesign for it now, so yay...
Still no scam calls all day... also I got a quick gig designing a mascot drawing for a small business, so I might actually make some green of my own after all. That would be a perfect job for me, since I love art and digital design.

Forum statistics

Threads
104,388
Messages
1,006,027
Members
135,916
Latest member
RewSYso
Top