Determining an Actor

Random Panda

Veteran
Veteran
Joined
May 3, 2016
Messages
48
Reaction score
3
First Language
English
Primarily Uses
Hi all, maybe someone here can help me. I am trying to make a plugin and it is almost nearly working. The last thing I am trying to do with it is make something specific happen when Actor 4 is doing it. This is all during combat if that makes a difference. I am trying to achieve this with an IF ELSE statement. What I need to know is what to put for the IF statement. What I was trying was this:

if($gameActors.actor(4) === true) {
THING A HAPPENS;}
else {
THING B HAPPENS;}

But it will only do thing B. It will only do what is in Thing B's place in the IF ELSE statement. So I would imagine "$gameActors.actor(4) === true" isn't the right thing to look for. Any help would be greatly appreciated.

Thanks!
 
Last edited:

Eliaquim

Raze: The Rakuen Zero's Guardian!
Veteran
Joined
May 22, 2018
Messages
907
Reaction score
361
First Language
Portuguese - Br
Primarily Uses
RMMV
i think maybe if you try:
if($gameActors.actor(4) == true) {
THING A HAPPENS;
}
else {
THING B HAPPENS;
}

only with two ==
?
Presuming that 4 refers to actor id and not to the 4º actor(member) in the group.
 

Random Panda

Veteran
Veteran
Joined
May 3, 2016
Messages
48
Reaction score
3
First Language
English
Primarily Uses
No luck. Still the same results. Thank you for the suggestion though.

Oh this is during battle if that makes a difference. I edited the original post to reflect that.
 

Aloe Guvner

Walrus
Veteran
Joined
Sep 28, 2017
Messages
1,627
Reaction score
1,061
First Language
English
Primarily Uses
RMMV
You don't want to compare if Thing1 is true, you want to compare whether Thing1 is the same as Thing2.
The correct idea is more like:
Code:
if (thing === $gameActors.actor(4)) {
   // something happens
}

The key though, is the value of "thing".

Are you looking for the user of a skill? The user of an item? The target of a skill?
Basically what is the context of this condition?
 

Random Panda

Veteran
Veteran
Joined
May 3, 2016
Messages
48
Reaction score
3
First Language
English
Primarily Uses
This is if Actor 4 is attacking.
If Actor 4 is attacking it should display a certain way, if any of the other characters are attacking it should display another way.

So I guess it would be using a skill, The skill being basic attack.
I hope that makes sense.
 

Aloe Guvner

Walrus
Veteran
Joined
Sep 28, 2017
Messages
1,627
Reaction score
1,061
First Language
English
Primarily Uses
RMMV
Is this in the damage formula? Is this in an event? Is this in a plugin (if so, what class is the function in)?

How are you getting the value of the user of the skill?
 

Random Panda

Veteran
Veteran
Joined
May 3, 2016
Messages
48
Reaction score
3
First Language
English
Primarily Uses
It's in a plugin. the full function is this:
Code:
TimedAttackSystem.prototype.showResults = function() {
       var resultId = 0;
       for(var i = 0; i < _.condition.length; i++) {
           if(eval(_.condition)) {
               resultId = i;
               break;
           }
       }
       if(_.parent === 'actor') {
           this._resultActor.removeChild(this._results);
       } else {
           this.removeChild(this._results);
       }
       this._results = new Sprite_TimedAttackResults(resultId);
       this._resultActor = BattleManager._spriteset._actorSprites[BattleManager._subject.index()];
       if(_.parent === 'actor') {
           if($gameActors.actor(4) == true) {
           this._results.y += (this._resultActor._mainSprite.height/3);}
           else {
           this._results.y += (this._resultActor._mainSprite.height/2);}
           this._results.setup('bla');
           this._resultActor.addChild(this._results);
       } else {
           this._results.x = this._resultActor.x;
           if($gameActors.actor(4) == true) {          
               this._results.y = this._resultActor.y + (this._resultActor._mainSprite.height/3);}
           else {
               this._results.y = this._resultActor.y + (this._resultActor._mainSprite.height/2);}
           this._results.setup('bla');
           this.addChild(this._results);
       }
    };

Its a results display that I need to move for one character due to their size.
 

Aloe Guvner

Walrus
Veteran
Joined
Sep 28, 2017
Messages
1,627
Reaction score
1,061
First Language
English
Primarily Uses
RMMV
Just above the line where you have
Code:
if($gameActors.actor(4) == true) {
Please add a line
Code:
console.log(this._resultActor)
Then playtest and open the Console by pressing F8 during playtest. Use the arrow next to what gets logged to expand it a bit. We need to find out whether you even have access to the Game_Actor object or not inside this function. I suspect that's a sprite and not the Game_Actor object.
 

Random Panda

Veteran
Veteran
Joined
May 3, 2016
Messages
48
Reaction score
3
First Language
English
Primarily Uses
So I did that, and it does list the Game_Actor bit in the log, with the Id number. But you are right, it is a sprite.

Is this something way more complicated than I think it is?
 

Aloe Guvner

Walrus
Veteran
Joined
Sep 28, 2017
Messages
1,627
Reaction score
1,061
First Language
English
Primarily Uses
RMMV
If it's the Sprite_Actor, you should be able to get the Game_Actor from it. Theoretically this would work:

Code:
if (this._resultActor._actor === $gameActors.actor(4)) {
or less likely:
Code:
if (this._resultActor === $gameActors.actor(4)) {
 

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

Latest Threads

Latest Posts

Latest Profile Posts

I bought a 2 week emergency food supply. And people are already making fun of me :( I'll be fed for a bit while they go hungry when food supplies get cut(for whatever reason).
Start of semester today. This is going to be a long one.
Can't wait for the next Sonichu
Birdhouses are usually made of wood. Birds typically live in trees. Trees are wood. Birdhouses are made of birdhouses.
He just discovered cellphones...

(I don't know why am I drawing so much these days...)

Forum statistics

Threads
93,671
Messages
914,453
Members
123,261
Latest member
IBIZA
Top