Checking the ID of the currently selected actor?

Papillon

Veteran
Veteran
Joined
Feb 22, 2017
Messages
60
Reaction score
8
First Language
English
Primarily Uses
RMMV
Hi there.
I'm currently making a small tweak to the critical damage formula that scales off the level of the currently attacking actor. But I cannot work out the script call for the life of me. The code is currently:
Code:
Math.floor((damage * 1.5) * Math.log($gameActors.actor(1).level) + 1 );
but that only scales off the level of the first actor's level. I've tried "this.actor().level" and so on but they don't seem to work.

What's the function I'm missing?
 

Ossra

Formerly Exhydra
Veteran
Joined
Aug 21, 2013
Messages
1,076
Reaction score
853
First Language
English
Primarily Uses
RMMV
Are you directly editing a method in the original code, or is this being done through a plugin? If being done through a plugin, which one?
 

Papillon

Veteran
Veteran
Joined
Feb 22, 2017
Messages
60
Reaction score
8
First Language
English
Primarily Uses
RMMV
Are you directly editing a method in the original code, or is this being done through a plugin? If being done through a plugin, which one?
It's an edit of the original code but being done through a very small plugin.
As in I've just copied the applyCritical function and swapped the damage formula.
 

Ossra

Formerly Exhydra
Veteran
Joined
Aug 21, 2013
Messages
1,076
Reaction score
853
First Language
English
Primarily Uses
RMMV
Ah, then you can just use 'this.subject()' to nab the current Actor.
 

Ossra

Formerly Exhydra
Veteran
Joined
Aug 21, 2013
Messages
1,076
Reaction score
853
First Language
English
Primarily Uses
RMMV
Also, if you only want that critical value to work for actors and not enemies -- because subject() also handles enemies, too -- use 'this._subjectActorId > 0' in the check.
 

Papillon

Veteran
Veteran
Joined
Feb 22, 2017
Messages
60
Reaction score
8
First Language
English
Primarily Uses
RMMV
Also, if you only want that critical value to work for actors and not enemies -- because subject() also handles enemies, too -- use 'this._subjectActorId > 0' in the check.
Duly noted. I noticed that when an enemy wiped out an entire party in one hit. Code has since been corrected. Thanks again for the help!

EDIT: For future reference, what are some other script calls I can use? A subjectActorId check doesn't appear to work with SumRndmDde's HUD maker.
 
Last edited:

Aloe Guvner

Walrus
Veteran
Joined
Sep 28, 2017
Messages
1,628
Reaction score
1,115
First Language
English
Primarily Uses
RMMV
To check if it's an actor, you can also use:
Code:
this.subject().isActor()
which will be true if it's an actor and false if it isn't.

It's exactly equivalent to the suggestion above, but is more clear if you look at it months from now to remember what it's doing.

EDIT: For future reference, what are some other script calls I can use?
One place to find all possible calls is https://kinoar.github.io/rmmv-doc-web

It can be confusing at first, especially if you haven't read documentation of that type before. The key is that you have to know what "this" actually is, which depends on context. There's more to it, but basically "this" is not a constant thing, it represents what the current object or context is.

In your example, "this" refers to a Game_Action. You could find this out by looking for the function you mentioned "applyCritical" and notice it's owned by Game_Action. Then in the documentation above go to the Game_Action page and you can see all the properties and methods you can use on "this" (it helps to know what a property and method is, of course).
 

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

Latest Threads

Latest Posts

Latest Profile Posts

Been scratching away at my game and making progress, but just had a revelation. I'm working in full screen and adjusting all my pictures accordingly, but will they resize if someone's screen is smaller?? I hope this doesn't turn out to be a problem later.
Why is there so much month left at the end of money? D=
Hello humans! How goes your day in this journey of living? I hope it is good, for I am human like you, and I am feeling great! Worship the altar.

Forum statistics

Threads
105,625
Messages
1,015,061
Members
137,287
Latest member
AKPoliandro
Top