Okay I need some handholding... what exactly is being done here?
JavaScript questions that don't deserve their own thread
Javascript/Plugin Support$gamePlayer.direction() returns a numeric value corresponding to the numpad keys with the appropriate arrow on them. 2, 4, 6, or 8. That arrow/number is the direction the player is facing.
Aqua wanted to use a numeric value to get some other value, so the simple solution is an array. The odd numbers aren't used, so those values don't matter - we leave them as zero. (note that there was a mistake in my first post, there needs to be one more empty element at the beginning of the array for index 0).
So the array is
[0, 0, 'down', 0, 'left', 0, 'right', 0, 'up'] - we don't care about actually declaring a variable that's going to store these values, we're just going to reference it on the spot. Just like you could type the number 5 or the string "stuff".The syntax to reference one element of an array is
array[index] - in this case, we're using the output of $gamePlayer.direction() as the index.Thus:
If you don't like the empty elements in the array, you could do some math to the output of the function:
Code:
['down', 'left', 'right', 'up'][$gamePlayer.direction()/2-1]
Just... wow! Thanks a lot, this was quite eye-opening. It's a shame I can only click "Like" once.
Is it possible to make the code run line by line in RPG maker console?
Back in the days when I programmed in VB this was a seriously powerful debug tool
Now I've to check where my JS plugin fails to do the math, I'm using console.log at every turn but it's full of IF and loops, it's a torture
It would be easier to follow the code line by line to see where it goes and where it doesn't pick up the right path
Is there a way?
Back in the days when I programmed in VB this was a seriously powerful debug tool
Now I've to check where my JS plugin fails to do the math, I'm using console.log at every turn but it's full of IF and loops, it's a torture
It would be easier to follow the code line by line to see where it goes and where it doesn't pick up the right path
Is there a way?
Oh, never mind! Found 😀
I feel really stupid for posting this, but I've been unable to get "change enemy sprite when hit" feature for a front-view battles for a couple of days already. I've been using Stella_VisuMZ free plugins, and since I have no idea if Stella can do something like that, I tried running TSR_SpriteEnemy (it actually works, but I have to disable VisuMZ_BattleCore, since it messes up with spritesheet, making game show the whole spritesheet) and Akea Animated Battle System 2 (I didn't managed to set up it, because of "JSON 0 Input error, which kept occuring even without any other plugin").
Now I have no idea what to do with it, because even when I tried to config some settings in VisuMZ_BattleCore I didn't found anything, that could disable changes of spritesheet, to make TSR_SpriteEnemy work. So, if anyone has any ideas what to do with it, I would be very glad, since I really want to implement feature like that, but in the same time I don't want to disable VisuMZ_BattleCore, since I guess it's pretty useful? I didn't managed to get my hands on combat yet, but I believe it will help me in a future anyway.
Now I have no idea what to do with it, because even when I tried to config some settings in VisuMZ_BattleCore I didn't found anything, that could disable changes of spritesheet, to make TSR_SpriteEnemy work. So, if anyone has any ideas what to do with it, I would be very glad, since I really want to implement feature like that, but in the same time I don't want to disable VisuMZ_BattleCore, since I guess it's pretty useful? I didn't managed to get my hands on combat yet, but I believe it will help me in a future anyway.
@Jobhob Please note that per the first post in this thread, it is for JavaScript questions, which you don't actually ask 😉
You should start your own separate thread for getting a plugin to work (or post your question in the thread for that plugin, like you linked to the Akea plugin).
I also suggest, as a side tip, adding some line breaks every other sentence or so...big walls of text can discourage people from reading your posts.
Good luck!
You should start your own separate thread for getting a plugin to work (or post your question in the thread for that plugin, like you linked to the Akea plugin).
I also suggest, as a side tip, adding some line breaks every other sentence or so...big walls of text can discourage people from reading your posts.
Good luck!
Oh, sorry, I guess I didn't got the theme of thread right. Should I delete my previous post?
I would like a script call which does the following:
When the party leader is doing something e.g. a step backwards, all the followers do the same so that the leader doesn't crash into them. I have the script call for getting them all to turn in the same direction, but not for all moving.
VS Events Move Core won't work in this instance as it would mean having to do several separate plugin commands, which would be tedious for one instance, but as I would like to use this fairly often it would become overburdensome.
Thank you.
When the party leader is doing something e.g. a step backwards, all the followers do the same so that the leader doesn't crash into them. I have the script call for getting them all to turn in the same direction, but not for all moving.
VS Events Move Core won't work in this instance as it would mean having to do several separate plugin commands, which would be tedious for one instance, but as I would like to use this fairly often it would become overburdensome.
Thank you.
HI all, I'm trying to script an effect similar to how extra damage is dealt in D&D, additionally to normal weapon damage. this is shamelessly inspired by EnFire by @Trihan .
This is meant to be attached to a weapon rather than a state (you know, like some weapons inflict damage). I'm also using the BattleCore feature that records damage in a variable, since target.result().hpDamage; isn't a real function.
However, whenever I attack, the second damage popup is 0. What am I doing wrong?
EDIT: why, in tarnation, does this work?
JavaScript:
<JS Post-Damage As User>
if (this.isHpEffect() && this.isAttack() && this.isPhysical()) {
target.startDamagePopup();
const elementId = 3;
const hpDamage = $gameVariables.value(29);
const newDamage = Math.ceil(hpDamage / 2);
const elementRate = target.elementRate(elementId);
const finalDamage = Math.ceil(elementRate * newDamage);
$gameTemp.requestAnimation([target], 66);
target.gainHp(-finalDamage);
target.startDamagePopup();
}
</JS Post-Damage As User>
This is meant to be attached to a weapon rather than a state (you know, like some weapons inflict damage). I'm also using the BattleCore feature that records damage in a variable, since target.result().hpDamage; isn't a real function.
However, whenever I attack, the second damage popup is 0. What am I doing wrong?
EDIT: why, in tarnation, does this work?
JavaScript:
<JS Post-Damage As User>
const localBaseDamage = target.result().hpDamage;
if (this.isHpEffect() && this.isAttack() && this.isPhysical()) {
target.startDamagePopup();
const elementId = 3;
const finalDamage = Math.ceil(target.elementRate(elementId) * localBaseDamage);
$gameTemp.requestAnimation([target], 66);
target.gainHp(-finalDamage);
target.startDamagePopup();
}
</JS Post-Damage As User>
Why do you say that?
It's not a function at all, since it has no parentheses to take arguments - but it's certainly a real property. If I grep the code for it, it comes up in multiple places:
Code:
Game_Battler.prototype.gainHp = function(value) {
this._result.hpDamage = -value;
Code:
Game_ActionResult.prototype.clear = function() {
this.hpDamage = 0;
Code:
Window_BattleLog.prototype.displayHpDamage = function(target) {
if (target.result().hpAffected) {
if (target.result().hpDamage > 0
However, why can't you just use
value? Granted it's undocumented because that's the way VisuStella rolls, but as far as I know it's present in all of the attack-related notetags just like it was in Yanfly.@Kes Try:
Code:
$gamePlayer.followers().forEach(follower => follower.moveBackward());
erroneous documentation.
I'm not sure how?
well it did work - but if you can share how you'd use value, I'd like that.
I don't really understand the question.
value should be provided as a variable that contains the amount of damage dealt. So you use it like you would any other variable that contains a numeric value.I meant that I'm unsure where to put it in my code
@ATT_Turan Thanks, that script call does the job.
I made a sweeping change in my database to end up running into a slight issue. Can someone point me in the right direction towards editing yanfly's autopassives plugin so that stateId works within <Custom Passive Condition> tags?
as an example, above is a state that's id ends in 1, but while that doesnt activate the passive for having more than 50% hp while being either main classed or sub classed as class 1, just setting the comparisons to == 1 does.
JavaScript:
<Custom Passive Condition>
condition = user.hpRate() >.5 && (user.currentClass().id == stateId%10 || user._subclassId == stateId%10);
</Custom Passive Condition>
as an example, above is a state that's id ends in 1, but while that doesnt activate the passive for having more than 50% hp while being either main classed or sub classed as class 1, just setting the comparisons to == 1 does.
If you look up the function in the code, you'll see it takes the state as an argument. So you should be able to simply do
state.idIve tried it putting it into the condition for the state, but it doesnt work. The game hung on the black loading screen for a couple minutes and then console threw multiple errors all saying that state wasnt defined. state.id works just fine in other tags, but it doesnt seem to work in <custom passive condition>.
Admittedly, it isnt a big issue. just more of an inconvenience and slightly curiosity
Ive been looking into the evals in the js for a few plugins to see how its handled elsewhere but i cant quite get it yet. I cant seem to access .id from the state being passed to the functions in the passive plugin despite seeing it being used, but i saw another plugin use the state id as the argument instead and gets the state from $dataStates that way. im not familiar enough with js to actually understand everything going on there
Huh. I haven't tried this specifically, but the function definition says
Code:
Game_BattlerBase.prototype.passiveStateConditionEval = function(state)
And the function calling it has:
Code:
var state = $dataStates[stateId];
this.passiveStateConditionEval(state);
So that ought to work.
What's the best way to restrict the player from being able to leave a z radius of a coordinate x,y? I want to tether the player's movement to a range around a coordinate.
Original thread: https://forums.rpgmakerweb.com/threads/javascript-questions-that-dont-deserve-their-own-thread.46341/