let x = 5;
let y = x; //the actual value 5 gets assigned
y = 3;
console.log(x); //still 5
console.log(y); //now 3
let a = {foo:'bar', bar:'foo'};
let b = a; //the actual value in a still gets copied to b
//but since the actual value is only a pointer to where the object is stored, a and b point to the same object.
b.foo = 'foo';
console.log(a); //even though we changed b.foo, now a.foo is also 'foo'
Putting it simply, you can look at a primitive as a type of variable that only holds one value at any given time. For example, a number variable can only hold one number at any given time, so it is a primitive. The same goes for a boolean variable, as it can only hold eitherHello.
Anybody knows a simple tutorial/lesson to learn the difference between primitives and references variables?
I read something explaining objects and references to them, but it's not clicking in my head. If you have maybe tips on what to learn BEFORE objects so I can grasp enough fundamentals.
Cheers.
true
or false
at any given time--never both. In JavaScript, strings are also considered primitives.Huh, I didn't know that. In every other language I regularily work with they are considered complex, as they are an array of the actually primitive character "under the hood".In JavaScript, strings are also considered primitives.
Math.ceil()If the Math.floor() function always rounds down, what rounds up?
Thanks.
thank you<Custom Apply Effect>
// Default the stockpile stacks to 0.
user._stockpile = user._stockpile || 0;
// Increase the stockpile stack by 1
user._stockpile += 1;
// Cap the stockpile stack at 3
user._stockpile = Math.min(user._stockpile, 3);
// Update the state counter for the stockpile stack
user.setStateCounter(stateId, user._stockpile);
</Custom Apply Effect>
<Custom Respond Effect>
user._stockpile -= 1;
user.setStateCounter(stateId, user._stockpile);
if (user._stockpile = 0){
user.removeState(stateId)
}
</Custom Respond Effect>
Why are you using this secondhi im using yanfly buffs and states core to to create a stacking block state that is removed one by on per hit but the counter is not ticking down can someone tell me what i am doing wrong?
user._stockpile
variable? If you're also using state counters, everything you're doing with the stockpile variable can just be done with the counters directly...I don't see the point of messing with two different things.if (user._stockpile = 0){
if (user._stockpile==0)
No. For one, 1 and 0.1 are completely different numbers (I know that's obvious, and I don't intend it to come across as snarky, but you typed them both as ideasI am trying to change how buffs, debuffs, and elemental rates are handled in my game.
Buff formula: this._buffs[paramId] * 0.25 + 1.0
If I remove the "* 0.25", leaving the formula as "this._buffs[paramId] + 1.0 or "this._buffs[paramId] + 0.1", would that mean a buff would add 1 point to the respective stat?
this._buffs[paramId]
is going to be 2, and the formula's result of 1.5 is what your ATK is multiplied by. You simply make it add the buffRate instead of multiply it.Alternatively, in YEP_BaseParamControl, there are many entries such as the MaxHP formula: (base + plus) * paramRate * buffRate + flat...My question is, how do I simplify this formula, considering...I want to ditch percentile in buffs?
No, not quite right. You don't want to mess with the paramRate, that's nothing to do with elemental anything, we're talking about parameters. If you go into an Actor, Class or State, one of the traits you can select is Parameter and it's a multiplier.How does "base + paramRate + flat" sound? If I am not missing anything, that means the formula considers the actor's health, some extra stuff based on traits (which I guess refers to stuff like elemental resistances and weaknesses, I will cross that bridge later) and a flat buff that will be defined in skills and such. Right?
(base + plus) * paramRate + buffRate + flat
this._buffs[paramId]
and it will add 1 point for each stack of buff.Why are you using this seconduser._stockpile
variable? If you're also using state counters, everything you're doing with the stockpile variable can just be done with the counters directly...I don't see the point of messing with two different things.
Aside from that, your error is this line:
if (user._stockpile = 0){
That line is setting the stockpile variable equal to 0. If you're trying to check whether it is equal to 0, that's two equal signs: if (user._stockpile==0)
You are also repeatedly using the variable "stateId" but that should be a number - the ID of the state.thank you for the help but the counter is still not counting down when the user is hit by an attack.
i am using the correct state number the one i originally put here a was a blank version i made so when i was working on the skillYou are also repeatedly using the variable "stateId" but that should be a number - the ID of the state.
Okay...it makes the most sense to post the current actual code you're using. Otherwise, how are we to know there isn't some other little change that's causing your problems?i am using the correct state number the one i originally put here a was a blank version i made so when i was working on the skill
<Custom Apply Effect>
// Increase the stockpile stack by 1
user.addStateCounter(stateId, 1);
// Cap the stockpile stack at 3
user.clampStateCounter(stateId, 1, 3);
</Custom Apply Effect>
<Custom Respond Effect>
user.addStateCounter(stateId, -1);
if (user.getStateCounter(stateId) == 0)
user.removeState(stateId);
</Custom Respond Effect>
Okay...it makes the most sense to post the current actual code you're using. Otherwise, how are we to know there isn't some other little change that's causing your problems?
I'm going to get rid of the extra variable stuff and just use the state counter commands to make this easier to follow. As before, you'll have to replace all instances of stateId.
Code:<Custom Apply Effect> // Increase the stockpile stack by 1 user.addStateCounter(stateId, 1); // Cap the stockpile stack at 3 user.clampStateCounter(stateId, 1, 3); </Custom Apply Effect> <Custom Respond Effect> user.addStateCounter(stateId, -1); if (user.getStateCounter(stateId) == 0){ user.removeState(stateId); user.clearStateCounter(stateId); } </Custom Respond Effect>
I didn't see anything actually wrong with your code beyond the "==" already mentioned. This does cut the number of lines of code in about half, so if it still doesn't work it should be a bit easier to troubleshoot.
Some recommendations:
- Turn on the plugin parameter that shows you the state counters so you can see what's happening
- Make sure you're starting a new play test, not loading a save or using the Battle Test from the editor
- If it still doesn't work, you should start a new thread for help troubleshooting
The states as buffs idea sounds cleaner than messing too much with stuff I don't understand well. I will give it a try, thanks!Why are you using this seconduser._stockpile
variable? If you're also using state counters, everything you're doing with the stockpile variable can just be done with the counters directly...I don't see the point of messing with two different things.
Aside from that, your error is this line:
if (user._stockpile = 0){
That line is setting the stockpile variable equal to 0. If you're trying to check whether it is equal to 0, that's two equal signs:if (user._stockpile==0)
No. For one, 1 and 0.1 are completely different numbers (I know that's obvious, and I don't intend it to come across as snarky, but you typed them both as ideas).
For another, that's not how buffs work in RPG Maker. They aren't additive, they're multiplicative - the buff formula is multiplied by your base parameter value.
So if you have two layers of ATK buff on, and your ATK is 25,this._buffs[paramId]
is going to be 2, and the formula's result of 1.5 is what your ATK is multiplied by.
In order to do what you want, you could not use buffs. Use states with a plugin such as Quasi Param Plus that allows you to attach flat values to states (and Yanfly's Buffs and States already allows you to stack states like buffs if you want).
Or...
You simply make it add the buffRate instead of multiply it.
No, not quite right. You don't want to mess with the paramRate, that's nothing to do with elemental anything, we're talking about parameters. If you go into an Actor, Class or State, one of the traits you can select is Parameter and it's a multiplier.
Just change the part of the formula that you actually want to change - the buffs.
Code:(base + plus) * paramRate + buffRate + flat
Then you'd do what you proposed above, making the Buff formula bethis._buffs[paramId]
and it will add 1 point for each stack of buff.