Status
Not open for further replies.

dopan

Veteran
Veteran
Joined
Mar 27, 2020
Messages
1,018
Reaction score
530
First Language
German
Primarily Uses
RMMV
Ok, well i am trying to add something to "Game_Actor"'s "this._equips[]", but the default "rpg_object" actionChain,seems to overwrite my "EDIT"..

here is the stuff which i wanna add:
JavaScript:
Game_Actor.prototype.srpgEquipSlotsUpgrade = function() {
    this._battleUnit = 'actor';
    if (this._equips) {
        if (this._equips[0]) {this._equips[0].equipIsGone = false};
        if (this._equips[1]) {this._equips[1].equipIsGone = false};
        if (this._equips[2]) {this._equips[2].equipIsGone = false};
        if (this._equips[3]) {this._equips[3].equipIsGone = false};
        if (this._equips[4]) {this._equips[4].equipIsGone = false};
    }
};

Thats just an simple example, for what i wanna do..
in this case the script to trigger this small function would be:

Game_Actor.prototype.srpgEquipSlotsUpgrade.call(this);
or
this.srpgEquipSlotsUpgrade();

(depending on where i use it)


However, i think i need to overwrite another ,
(default "rpg_object"-)
"Game_Actor"- function, and add it there to make my Edit permament.
( i dont want this edit to be triggered more than once. this would set the switch to false with every update )

My Question is:
What is the best Approch do make that happen?
if anybody has some ideas, that would be very welcome.thx



edit
and just to be clear ,i need these switches and cant use:
"if (this._equips[0]. _ItemId === 0)" instead

these switches are supposed to store the info, if an Equip was "Stolen" or "Broken
" no matter if the slot is empty or not
 
Last edited:

dopan

Veteran
Veteran
Joined
Mar 27, 2020
Messages
1,018
Reaction score
530
First Language
German
Primarily Uses
RMMV
well i solved it, with a slightly different approach..

instead of adding something to "this._equips"..
i replicated a similar ,more simple thing like "this._equips"..
Called "this._equipIsGone", which by default is connected to nothing and cant get any actionChane Conflict..

example code for Game_Actor:
JavaScript:
    Game_Actor.prototype.initialize = function(actorId) {
        Game_Battler.prototype.initialize.call(this);
        this.setup(actorId);
        //stuff above is default stuff below is added
        this._equipIsGone = [];
        this._equipIsGone.push(0, 1, 2, 3, 4);
        this._equipIsGone[0] = false;
        this._equipIsGone[1] = false;
        this._equipIsGone[2] = false;
        this._equipIsGone[3] = false;
        this._equipIsGone[4] = false;        
        this._battleUnit = 'actor';      
    };

i will report this as solved.thx
 

ramza

Lunatic Coder
Veteran
Joined
Jan 28, 2013
Messages
952
Reaction score
603
First Language
English
Primarily Uses
RMMV
@dopan The way you've solved this is still by overwriting the original function. That means anyone who's added something to Game_Actor.prototype.intialize will have those changes ignored if they're also using your plugin.

Or if this isn't a plugin, and it's just a change you want specifically for your project, you will run into problems if you try to use any plugins that modified that function, and load them before your changes.

What you want to do is make an alias, or a monkeypatch.

JavaScript:
var newName = Game_Actor.prototype.initialize
Game_Actor.prototype.initialize = function(actorId) {
        newName.call(this, actorId)
        //stuff above is default stuff below is added
        this._equipIsGone = [false, false, false, false, false];
        this._battleUnit = 'actor';     
};

By making a new function equal to the original, and then calling it, you do what the original function did, including any changes any other plugins have made to that function. Then, after calling the original, your changes get added to the end. Any new plugins that also use this function will continue to use your changes to it as well, improving compatibility.
I also cleaned up your code a smidge. There's no need to declare an array as blank, and then immediately make each of the elements equal to something else. You can declare it as having those values directly, and the line where you push a bunch of numbers to it only to erase them on the next line is unnecessary. The element Id you reference is its position in the array, not a value you set beforehand.
 

mlogan

Global Moderators
Global Mod
Joined
Mar 18, 2012
Messages
16,245
Reaction score
9,013
First Language
English
Primarily Uses
RMMV

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

 
Status
Not open for further replies.

Latest Threads

Latest Posts

Latest Profile Posts

All aboard the Advent calendar train, riding Avery's coattails as an excuse to make more sprites. ;)
Advent2021-01.gif

Get 'em in my thread in General Resources.
I had a dream where it was Friday, and what happened in the dream was irrelevant, because I woke up and it's not Friday, so I'm sad.
edit: third time's the charm? some graphic text I whipped up that I like for the mid-game intertitle, now with all of the actual letters in the stupid damn words I was trying to spell :uswt2:
kcsmall.png
It is december, my dudes

badge_xmas.png

Forum statistics

Threads
117,096
Messages
1,104,541
Members
153,106
Latest member
worldofmz_rpg
Top