You would need a plugin (scripts are for the earlier RPG Makers that use Ruby) such as Victor Engine's Command Replace.
JavaScript questions that don't deserve their own thread
Javascript/Plugin SupportSo this is prolly a simple thing for many, but im bad at this stuff.
Using Himeworks weapon damage and the suggested formula is something like
10 * (Math.randomInt(5) + 1) which is fine ofc, but I tried to find an even simpler way for my simple brain and ended up with Math.randomInt(5) + 15. I tested it and it seems fine.
So the question is really just, is this an ok way to do 15-20 damage? Is the suggested way superior in some way I'm not aware of?
Would suck to have to go back and change it all in the long run 😛
Using Himeworks weapon damage and the suggested formula is something like
10 * (Math.randomInt(5) + 1) which is fine ofc, but I tried to find an even simpler way for my simple brain and ended up with Math.randomInt(5) + 15. I tested it and it seems fine.
So the question is really just, is this an ok way to do 15-20 damage? Is the suggested way superior in some way I'm not aware of?
Would suck to have to go back and change it all in the long run 😛
@Willibab
The suggested formula will give you either 10, 20, 30, 40 or 50 damage.
If you want to deal 15-20 damage, you actually came close, but
its actually
"Math.randomInt(6) + 15"
instead of
"Math.randomInt(5) + 15"
Otherwise you'll end up with 15-19 damage instead.
The suggested formula will give you either 10, 20, 30, 40 or 50 damage.
If you want to deal 15-20 damage, you actually came close, but
its actually
"Math.randomInt(6) + 15"
instead of
"Math.randomInt(5) + 15"
Otherwise you'll end up with 15-19 damage instead.
Hey there,
since I recently bought MZ I thought I'd give it a try and see if my script still works the way it did in MV. And so far I didn't have any issues. MZ uses exactly the same DataManager structure as in MV.
The error occurs when you use a primitive data type like strings or numbers. That means that something might be wrong with the json file you stored in the data folder. Can you post the json file your are using? That is, if you haven't solved the problem already.
During battle calls this script and the item command disappears.
JavaScript:
SceneManager._scene._actorCommandWindow._list.pop();
SceneManager._scene._actorCommandWindow.clearItem(3);
If you want it to return use:
JavaScript:
SceneManager._scene._actorCommandWindow.refresh();
You can also have it check if item command is enabled and if not, then have it removed
JavaScript:
let actorWindow = SceneManager._scene._actorCommandWindow;
actorWindow.refresh();
if (!actorWindow._list[3].enabled) {
actorWindow._list.pop();
actorWindow.clearItem(3);
}
Edit:
Sorry for double post, was too tired to realize
Thank you. I will try those. I guess i would run those in troops?
Script that let an event face the player's direction?
I didn't test this, but try this plugin. It should run the script every time you reached the input phase of the battle.
The plugin looks like this
JavaScript:
BattleManager_alias_startInput = BattleManager.startInput;
BattleManager.startInput = function() {
BattleManager_alias_startInput.call(this);
let actorWindow = SceneManager._scene._actorCommandWindow;
actorWindow.refresh();
if (actorWindow._list[3] && !actorWindow._list[3].enabled) {
actorWindow._list.pop();
actorWindow.clearItem(3);
}
}
You don't need a script for that. Just go to the event -> Route... -> Turn Toward Player
Can someone tell me what is wrong with this script code. I searched the forums and found this in a similar topic (I only edited some numbers and names). The idea is trying to use it in a battle script to get random skills at the start of the turn. In this testing phase I tried to set it to randomly select 3 skills out of 5 possilbe.
EDIT: I'm using MZ
EDIT: I'm using MZ
JavaScript:
var skills = [12, 13, 14, 15, 16], vIds = [1, 2, 3];
for (var n = 0; n < vIds.length; n++) {
if (skills.length === 0) break;
var ix = Math.randomInt(skills.length);
$gameParty.leader().learnSkill(vIds[n], skills.splice(ix, 1)[0]);
}
Don't know what exactly isn't working, but one thing that does stick out is the learnSkill method.
If you look at it:
JavaScript:
Game_Actor.prototype.learnSkill = function (skillId) {
if (!this.isLearnedSkill(skillId)) {
this._skills.push(skillId);
this._skills.sort(function (a, b) {
return a - b;
});
}
};
It only takes one argument. But in your code it takes 2. What are the vIds for? And why splice skills? Are they supposed to be assigned only once? Also in your example you are missing a curly bracket at the end. Probably copy&paste mistake.
Not working as in my character isn't gaining the skills. And I don't know anything about coding 😀
I just copied that code from a different topic where it was talking about picking something out of an array (and using it for some other purpose than gaining skills). But since the purpose was kind of similar, I just thought that I could stick that learnSkill thing inside there (obviously not, haha).
Some of that code is meant for making sure that if it picks something, it can't be picked again. So for example if it picks skill number 13, then that number is taken out of the array when it picks the next one (or that's what I read).
Oh ok, gotcha.
Try this:
JavaScript:
var skills = [12, 13, 14, 15, 16]
var randomSkillId = 0;
for (var n = 1; n <= $gameParty.size(); n++) {
if (skills.length === 0) break;
randomSkillId = Math.randomInt(skills.length);
$gameActors._data[n].learnSkill(skills[randomSkillId]);
skills.splice(randomSkillId, 1);
}
EDIT:
Ok, I think I got it to work now. So I changed that n <= $gameParty.size() to n <= 3 (and changed that gameActors part to party leader). Thanks for the help!
/////////////
Now (after changing that gameActors part to party leader thing) I'm getting one skill per turn. Maybe I wasn't clear enough, when I said pick 3 skills out of 5, I meant pick all 3 skills for just one character. So I'm testing a solo battle with just 1 character, and she is getting a number (3) of random skills from a pool (5 for test purposes) at the beginning of a turn. As I said, I don't understand code, but I see your code uses something called gameParty.size, so maybe that code would allocate skills to multiple party members?
I tried it again with the same error. I replaced the file with a simple ["dog","bird","cat"] file and it loaded as expected, so I'm sure you're right that there's something wrong with my new text file. Hardcoding the file contents into the variable works really well, so it's not a huge deal. To make this new file, I took a 5 letter word list with a few thousand words, manually removed uncommon and/or obscure words, added quotes around each word, inserted commas, etc. It's entirely likely I corrupted the file in some way.
Thanks for weighing in. 🙂
One of my plugins supports javascript and I was wondering if there was a piece of code I could use to make the gab window smaller it's too big and there isn't a setting for it
Has anyone made an Object to Object mapping of RPG Maker MZ or any other quick reference resources that I can use for plugin development. It would expedite my development process.
Yeah, looks like there was a misunderstanding with the replacement code you were given.
Code:
var skills = [12, 13, 14, 15, 16];
var randomSkillId;
for (var n = 1; n <= 3; n++) {
randomSkillId = Math.randomInt(skills.length);
$gameParty.leader().learnSkill(skills[randomSkillId]);
skills.splice(randomSkillId, 1);
}
I have no idea what's going on in that original snippet you posted, but this one will make the party leader learn 3 skills randomly chosen from the 5 (or however many) you type into the skills array on the first line.
This should be its own thread in Plugin Support, wherein you provide a link to the plugin in question. Just referencing a "gab window" doesn't mean anything, code-wise, and it's a little pointless to toss suggestions at you without seeing the code that makes the window in the first place.
Hey, quick question. Is there a script call I can use to set Actor X (ID equal to a variable) to party slot 2? The actor is already in the party.
No, you can't directly set an actor to a place in the party - what would happen to any actor already in that spot? And the rest of the party?
There is a $gameParty.swapOrder() function, so you have to use a little logic with it. The easiest thing to do would be:
Code:
$gameParty.swapOrder(1, $gameParty.members().indexOf($gameActors.actor(X)));
Ah, I probably didn't phrase that very clearly. Swapping the actor in the second slot with actor X is what I was hoping to do, and the script call works like a charm. Thank you! 🙏
Original thread: https://forums.rpgmakerweb.com/threads/javascript-questions-that-dont-deserve-their-own-thread.46341/