JavaScript questions that don't deserve their own thread

FirestormNeos

Veteran
Veteran
Joined
Jul 23, 2019
Messages
65
Reaction score
25
First Language
English
Primarily Uses
RMMV
In Yanfly's Battle Engine Core plugin, where is the option that lets me move the player character to the left side of the screen and what do I put in so that it performs that?
 

glaphen

Veteran
Veteran
Joined
Jan 13, 2019
Messages
292
Reaction score
107
First Language
English
Primarily Uses
RMMV

FirestormNeos

Veteran
Veteran
Joined
Jul 23, 2019
Messages
65
Reaction score
25
First Language
English
Primarily Uses
RMMV
Are you talking about yanfly action sequences?
You need the packs at least 1 and 2 to do anything really, and learn how it works on that page.
I'm not entirely sure. I want the player character to be on the left side of the screen, facing right. Rather than the default, where it's the other way around.

Here's a(n edited) "screenshot" of what I'm talking about:
bruh.png
 

matgraz

Veteran
Veteran
Joined
Feb 4, 2018
Messages
65
Reaction score
4
First Language
Portuguese
Primarily Uses
RMMV
Really simple question: which of the animations from the sprite sheet is the WALK motion? I see that being quoted but i've never found it anywhere

1581253486208.png
1581253509434.png
 

glaphen

Veteran
Veteran
Joined
Jan 13, 2019
Messages
292
Reaction score
107
First Language
English
Primarily Uses
RMMV
I'm not entirely sure. I want the player character to be on the left side of the screen, facing right. Rather than the default, where it's the other way around.

Here's a(n edited) "screenshot" of what I'm talking about:
View attachment 133673
For that you would probably have to change home positions of the actors in battle engine core to that area then mirror all the images in the sv actor folder, for enemies you would just have to place them where actors would be in troops and mirror all the sv enemies as well.

Really simple question: which of the animations from the sprite sheet is the WALK motion? I see that being quoted but i've never found it anywhere

View attachment 133676
View attachment 133677
"Walk" is idle whenever it's usually referred to in other programs I think. If you want to make an actual walk animation you would probably have to do it manually by changing one of those motions you don't use so like never use sleep and instead use motion sleep: user for example after any walk attempt,
 

Gargoyle77

Veteran
Veteran
Joined
Dec 4, 2017
Messages
60
Reaction score
6
First Language
English
Primarily Uses
RMMV
Hello, I would use this notetag instead:
Code:
<Custom Respond Effect>
if (this.isPhysical() && target.result().hpDamage > 0) {
   dam = target.result().hpDamage;
   user.gainHp(dam)
   target.removeState(state ID);
}
</Custom Respond Effect>
This worked perfectly! You're awesome! Thanks and sorry for the late answer.
 
  • Like
Reactions: TSR

glaphen

Veteran
Veteran
Joined
Jan 13, 2019
Messages
292
Reaction score
107
First Language
English
Primarily Uses
RMMV
Okay, and where in the Battle Engine Core do I do that?
Sideview Home Position X screenWidth - 16 - (maxSize + 2) * 32 + index * 32
You would have to play around with the math of that to put them where you want, also might have to change step and flinch distance to a negative number.
 

Aerianr

Villager
Member
Joined
Jul 13, 2019
Messages
14
Reaction score
3
First Language
English
Primarily Uses
RMMV
Please delete! My question was answered in another thread. :]
 
Last edited:

MikaTeapot

Villager
Member
Joined
Mar 25, 2019
Messages
12
Reaction score
2
First Language
English
Primarily Uses
RMMV
*Moved to it's own thread*
 
Last edited:

UniqueName

Veteran
Veteran
Joined
Nov 12, 2018
Messages
44
Reaction score
6
First Language
Russian
Primarily Uses
Other
Hey guys whats the difference between $gameActors._data[1].... and $gameActors.actor(1)....
If I want to change some stats through script call would it be better to do it with actor() or _data?
I also noticed that I can address all stats with or without an underscore but I can only change it with underscore
so this $gameActors._data[1]._hp = 100 would work and that $gameActors._data[1].hp = 100 wouldnt
and I also can address exparameters through "xparam()", "_xparam[]"(which is changeable) or their shortname "cri, hit" etc.
its so confusing, I would be grateful if anyone explained how all of that works
 
Last edited:

Silva

Scoobityboo
Veteran
Joined
Nov 5, 2018
Messages
392
Reaction score
210
First Language
English
Primarily Uses
RMMV
This question could very easily merit it's own thread, but I'll try and keep it short.

In terms of what you get when you use $gameActors._data[1] and $gameActors.actor(1), they are exactly the same. The difference is in how they give you the value.

$gameActors._data[1] - will just try to spit out the actor, almost no questions asked.
$gameActors.actor(1) - will first check that the database has an actor 1 in it, then it will make sure that actor 1 has actually been created in the game (if it hasn't, it will create it), then it will give you the actor. If there is no actor in the database it will give you nothing (null).

Unless I have a very compelling reason to use $gameActors._data, I leave it be. $gameActors.actor can handle exceptions better, and is probably less likely to crash your game if you make a mistake. For example, say I want to change a property of actor 1, something like "$gameActors.actor(1)._hp = 5", if I forget to use the ._hp and instead use "$gameActors.actor(1) = 5" I'll get a message in the console telling me that this doesn't make sense and my game will continue. If I did this using "$gameActors._data[1] = 5", my game will crash immediately.

Regarding the difference between ".hp" and "._hp" etc. The versions without an underscore are getter properties, they run a function when you use them and return a value. If you look in the rpg_objects.js file and search "Object.defineProperties(Game_BattlerBase" you'll see a whole list of these properties. When defining properties like this there is the option to add a set function, however, this hasn't been utilised in the default MV code so using ".hp = 5" in effect does nothing.

When deciding which to use, it should be pretty clear that ".hp" isn't going to help you if you need to change an actors hp, but is a safe way of getting the value without any risk of accidentally changing it.

I would advise against just mashing straight in and using "._hp" etc. to set a value because there are functions that already exist for changing these things that have measures in place to make sure parameters don't exceed their maximums . Hp for instance has the function "gainHp", normal params have "addParam" and so on. That's not to say you should never use the "._hp" style properties, but I normally don't unless I have a reason for using them over an existing function.
 

MushroomCake28

KAMO Studio
Global Mod
Joined
Nov 18, 2015
Messages
2,597
Reaction score
3,782
First Language
English
Primarily Uses
RMMV
@Silva It is always preferable to access an object's data through a function than directly referring to its variable. This is something more in line with C/C++/C# kind of languages where you can set variables to private/public/protected.

As for the .hp and the ._hp, it is almost always preferable to use .hp since it's a property (meaning it has it will return the hp with a function). The reason why actor.hp -= 100 doesn't work is because the property only defines a get and not a set (I don't know why to be honest):
Code:
Object.defineProperties(Game_BattlerBase.prototype, {
    // Hit Points
    hp: { get: function() { return this._hp; }, configurable: true },
    // The rest of the properties
}
If there was a set, it would be preferable to use the property rather than accessing the value directly. There are many properties in the MV default code that have a getter and a setter. Check for example:
Code:
Object.defineProperty(Sprite.prototype, 'opacity', {
    get: function() {
        return this.alpha * 255;
    },
    set: function(value) {
        this.alpha = value.clamp(0, 255) / 255;
    },
    configurable: true
});
 

UniqueName

Veteran
Veteran
Joined
Nov 12, 2018
Messages
44
Reaction score
6
First Language
Russian
Primarily Uses
Other
thanks silva and mushroom cake =)
I think i understand now
 

ZServ

Veteran
Veteran
Joined
Jun 16, 2014
Messages
259
Reaction score
71
Primarily Uses
Anyone know the Javascript call for checking if an equipped piece of gear is a certain item?

TL;DR: I'm making an item that grants a flawless Escape rate when equipped. I tried a custom Escape Rate of like:
Code:
base + ($gameVariables.value(xx))
But w/ the variable being modified by a conditional branch if <X Thing> was equipped. Didn't work, since ESCRate is set at the instantiation of a fight.

So I very specifically need to know what the call is for "the item matching this ID is equipped on this actor". :p
 

BurningOrca

Veteran
Veteran
Joined
Apr 14, 2019
Messages
138
Reaction score
100
First Language
German
Primarily Uses
RMMV
Unbenannt.PNG
I have created the state above, but it doesn't work, because if a character cannot move it cannot counter.
I've put this here in the Javascript Support Forum, because I believe what I like to achieve cannot be done without Javascript. I also don't believe it deserves it's own thread.
So how I can make my actor have no actions for 2 turns and still be able to counter attack using Javascript?
 

Silva

Scoobityboo
Veteran
Joined
Nov 5, 2018
Messages
392
Reaction score
210
First Language
English
Primarily Uses
RMMV
Anyone know the Javascript call for checking if an equipped piece of gear is a certain item?

TL;DR: I'm making an item that grants a flawless Escape rate when equipped. I tried a custom Escape Rate of like:
Code:
base + ($gameVariables.value(xx))
But w/ the variable being modified by a conditional branch if <X Thing> was equipped. Didn't work, since ESCRate is set at the instantiation of a fight.

So I very specifically need to know what the call is for "the item matching this ID is equipped on this actor". :p
You should have some luck using one of the examples below. replace actorId with the actor ID, weaponId with the weapon ID. If you're using the party method replace index with the actors position in the party (0 = leader and so on).

JavaScript:
//get actor by actorId
$gameActors.actor(actorId).hasWeapon($dataWeapons[weaponId]);
$gameActors.actor(actorId).hasArmor($dataArmors[armorId]);

//alternatively, using party index, works with hasArmor as well
$gameParty.members(index).hasWeapon($dataWeapons[weaponId]);
View attachment 135507
I have created the state above, but it doesn't work, because if a character cannot move it cannot counter.
I've put this here in the Javascript Support Forum, because I believe what I like to achieve cannot be done without Javascript. I also don't believe it deserves it's own thread.
So how I can make my actor have no actions for 2 turns and still be able to counter attack using Javascript?
In terms of doing this in vanilla MV, I can't think of a solution off the top of my head. You could probably pull this off rather easily with Yanfly's buffs and states core's custom effects to force an attack.
 

BurningOrca

Veteran
Veteran
Joined
Apr 14, 2019
Messages
138
Reaction score
100
First Language
German
Primarily Uses
RMMV
@Silva: Well I tried it with overwritting makeActions and makeActionsTimes, but that leaded to an error as the game didn't create any actions, but it was still able to select e.g. Attack with that Actor.
So I decided to keep the "Cannot move flag" and instead overwrite the itemCnt like that:

JavaScript:
BurningOrca.MyGame.counterRate = Game_Action.prototype.itemCnt;

Game_Action.prototype.itemCnt = function(target)
{
    if( this.isPhysical() )
    {
        if( !this.isForOne() )
        {
            return 0;
        }
        else if( target.canMove() || target.isStateAffected(13) )
        {
            return target.cnt;
        }
        else
        {
            return 0;
        }
    }
    else
    {
        return 0;
    }
};
Because I use Yanfly's Counter Control I also had to overwrite this function:

JavaScript:
BurningOrca.MyGame.canBattlerCounter = Game_Battler.prototype.canCounter;

Game_Battler.prototype.canCounter = function()
{
    if( target.isStateAffected(13) && this.counterTotal() >= this._counters ) return true;
    return Game_Battler.prototype.canCounter.call(this);
}
Then it seemed to work. Also now only attacks that hit a single target get countered, which I thought would be the default.
 

ZServ

Veteran
Veteran
Joined
Jun 16, 2014
Messages
259
Reaction score
71
Primarily Uses
You should have some luck using one of the examples below. replace actorId with the actor ID, weaponId with the weapon ID. If you're using the party method replace index with the actors position in the party (0 = leader and so on).
Thanks a ton, Silva! Very helpful :)
 

Riazey

Master of None
Veteran
Joined
Feb 27, 2014
Messages
55
Reaction score
33
First Language
English
Primarily Uses
RMMV
Back with another question, a smoll one this time (I think they are small oh no)!


What's the best way to get an event to affect multiple tiles? For example, 6 tiles straight ahead of the player, or the front left front and front right (a horizontal line of 3 for say a sword swing). I would be using a tool from Galv's tool plugin that calls a common event, so I just need the common event to do that haha!

I think maybe I should just play a common event that individually targets all the tiles I want to be affected but am not 100% sure how to call that? Like 6 tiles before the player would be 4 directional conditions, plus the six [$gamePlayer.x +1,$gamePlayer.y +1] or player location variable scripts coupled with want used on that tile (in which case if someone could explain how to or the most efficient way of doing so as to not be incredibly messy or lag out someone's poor brick pc)~

If there is an easy way of plugging this or if someone had an example for what one of the directions should look like for my tiny noob brain I would be happy~ qvq (I wouldn't want to make anyone's life difficult tho aa-)




-------------------------------------------------------------------------------

If these are already answered somewhere I apologize, googled myself into a deep corner of the rpg maker web but I'm blind I guess!
 
Last edited:

Users Who Are Viewing This Thread (Users: 0, Guests: 2)

Latest Threads

Latest Posts

Latest Profile Posts

Guys one of our Animal Crossing Villagers (Sherb) just told us that he hoped that the villager who was having her birthday had as memorable of a birthday as his sixth birthday. Which was "the one where the clown went into our house and never came back" and that "his mother says she still sometimes hears the honking in the walls".
My tutor has been furloughed for 8 weeks. If we are too... sucks, but it's a lot of game making time...
Social distancing extended for another week. Personally I'm cool, but this is depressing.
GOOOOD MOOORNING!
APRIL WILL BE BETTER!
First time I've seen the shelves full in my local shop in a while. Still no soap, though.

Forum statistics

Threads
95,570
Messages
930,158
Members
125,853
Latest member
sokka
Top