Assistance with getting xparams to work how I want.

deus69xxx

Villager
Member
Joined
Oct 13, 2013
Messages
11
Reaction score
1
First Language
English
Primarily Uses
RMMV
This is gonna be a bit complex: so, i'm working on getting a system together dealing with params and their pluses separately. That part has succeeded. i've even managed to redraw the positions of said params and the pluses to look the way i wish (almost). now, the issue involves the xparams.

1584557638378.png


I've figured out how to add extra stat falsies, which is all that's necessary in the grand scheme. the numbers for those will be variables. the problem is two-fold. i need to be able to get this to show different variables based on which character is being displayed, and i need a piece of code that will allow me to add to the xparams through script. the code i have so far...

Code:
Window_Status.prototype.drawParameters = function(x, y) {

    var lineHeight = this.lineHeight();

    for (var i = 0; i < 6; i++) {

        var paramId = i + 2;

        var y2 = y + lineHeight * i;

        this.changeTextColor(this.systemColor());

        this.drawText(TextManager.param(paramId), x, y2, 160);

        this.resetTextColor();


//THIS LINE WAS A SUCCESS v

        this.drawText(this._actor.param(paramId)-this._actor.paramPlus(paramId) + " ("+this._actor.paramPlus(paramId)+")", x + 130, y2, 60, 'right');

    }

    this.changeTextColor(this.systemColor());

    this.drawText("Hit", x + 190, y, 160);

    this.drawText("Dodge", x + 190, y + 36, 160);

    this.drawText("Magic", x + 190, y + 72, 160);

    this.drawText("Hacking", x + 190, y + 108, 160);

    this.drawText("Negotiate", x + 190, y + 144, 160);

    this.resetTextColor();


//THESE LINES v

    this.drawText(this._actor.xparam(0) + " (0)", x + 330, y, 60, 'right');

    this.drawText(this._actor.xparam(1) + " (0)", x + 330, y + 36, 60, 'right');


//THIS LINE v

    this.drawText($gameVariables.value(17) + " (0)", x + 330, y + 72, 'right');

    this.drawText();  //when just above is figured, these will matter

    this.drawText();

};

my thought involved using $gameVariables.value(actorId + 17) to have it pick the variable i need, 17 is not important. and i have tried this numerous ways, and all of them fail. eg., $gameActors.actorId, this._actor.id, this._actorId, this._actor(actorId), etc., and none of them have worked. a few tell me id or actorId is undefined, or some throw no error, but won't show the variable it should be referencing, or any of those near that variable, that i have set with distinct numbers for troubleshooting. this is problem one.

problem 2 is much more drastic, i think. i'm at least reasonably certain this can be done, since someone had a code snippet in a forum as an answer in vxace. a way to make it so you can add, through script, such as

$gameActors.actor(actorId).addXParam(0, 5);

by adding a number of functions. i THOUGHT i found them all and i tried this:

Code:
Game_BattlerBase.prototype.xparam = function(xparamId) {
    return this.traitsSum(Game_BattlerBase.TRAIT_XPARAM, xparamId) + this.xparamPlus(xparamId);
};

Game_BattlerBase.prototype.xparamPlus = function(xparamId) {
    return this._xparamPlus[xparamId];
};

Game_BattlerBase.prototype.addXParam = function(xparamId, value) {
    this._xparamPlus[xparamId] += value * 0.1;
    this.refresh();
};

this did not succeed.

I could really use these two things, is anyone willing to help?
 

Silva

Scoobityboo
Veteran
Joined
Nov 5, 2018
Messages
394
Reaction score
212
First Language
English
Primarily Uses
RMMV
Re retrieving an actors ID via script call in the function you're using you would use:

JavaScript:
this._actor.actorId()
You can then pass this as a parameter with whatever addition you need to retrieve the correct variable.

Re adding in xparamPlus, the only thing you're missing is initialising the value of _xparamPlus - by default this will be undefined and you're trying to use it as if it is an array. To get round this you can alias the initMembers method on Game_BattlerBase and have it call a function to set the value to an array of 0's, similar to the way the engine already handles paramPlus.

JavaScript:
var _deus69xxx_Game_BattlerBase_initMembers = Game_BattlerBase.prototype.initMembers;
Game_BattlerBase.prototype.initMembers = function() {
    _deus69xxx_Game_BattlerBase_initMembers.call(this);
    this.clearXparamPlus();
};

Game_BattlerBase.prototype.clearXparamPlus = function() {
    this._xparamPlus = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
};
 

deus69xxx

Villager
Member
Joined
Oct 13, 2013
Messages
11
Reaction score
1
First Language
English
Primarily Uses
RMMV
AHA! success! all of it!

Except i screwed up. I got so into adding the plus, that I didn't think about the part I only need one part of the plus. I assume this will work nearly the same, except is it possible to withdraw the pluses from weapons/armor, and put just those in the parenthesis?

i assume it would look like

this.drawText(this._actor.param(paramId) - this._actor.????????? + " (" + this._actor.?????????? + ")", x + 130, y2, 60, 'right');

and probably a loop to get them all :|
 

Silva

Scoobityboo
Veteran
Joined
Nov 5, 2018
Messages
394
Reaction score
212
First Language
English
Primarily Uses
RMMV
It depends, if you only have xparam traits on weapons and armor, you can just create a copy of the engines original function, call it xparamBase or whatever and then call that to draw the text.

If you have xparam traits on the actors or their classes you'll need to write a new function to retrieve the traits from the weapons and armors exclusively, then filter the traits to extract the relevant xparam values and then sum them together. So you're probably looking at creating new methods on Game_Actor similar to "traitObjects", "allTraits" and "traitsWithId", but only using weapons and armors, then creating a function to sum the relevant xparam traits' values.
 

deus69xxx

Villager
Member
Joined
Oct 13, 2013
Messages
11
Reaction score
1
First Language
English
Primarily Uses
RMMV
I'm at a loss about the traits things, I can't even grasp the concept. I've figured out how to find the regular params from weapons and armor, though I'm having some trouble with a dynamic number of equipment slots (HIME_Equip_Slots_Core) (some characters will only have two slots, others could have up to 8 or 9), which I'm still trying to puzzle out how js would work it, though I see some promising examples. One of the hardest things i'm dealing with is just how to call on something I know, so I can test xD. It took me about 6 hours to figure out how to access the params from equipment x.x

But looking through the portions you listed, none of it looks like I can call anything out of it, or that it returns anything sensible, nor where any of it is applied. :\
 

Silva

Scoobityboo
Veteran
Joined
Nov 5, 2018
Messages
394
Reaction score
212
First Language
English
Primarily Uses
RMMV
Traits are a nightmare to work with if you're not familiar with them. Each trait is effectively given a code, which is what we use to retrieve the values of the trait. If you look in the Game_BattlerBase class you'll see it has a bunch of lines like this

JavaScript:
Game_BattlerBase.TRAIT_ELEMENT_RATE   = 11;
Game_BattlerBase.TRAIT_DEBUFF_RATE    = 12;
This will tell you the various codes for different traits.

With regards to the methods I listed - they work in conjunction with one another (one calls the other to eventually retrieve the value of xparams). We can't use them in their current form because the method "traitObjects" returns all the trait objects that a battler has. This includes the battlers class, states, the battler themselves as well as weapons and armors. You want to only draw from the weapons and armors, so you need a new set of methods to handle this. eg.

JavaScript:
Game_Actor.prototype.equipTraitObjects = function() {
    var objects = [];
    var equips = this.equips();
    for (var i = 0; i < equips.length; i++) {
        var item = equips[i];
        if (item) {
            objects.push(item);
        }
    }
    return objects;
}; // get an array of all occupied equip slots

Game_Actor.prototype.equipTraits = function() {
    return this.equipTraitObjects().reduce(function(r, obj) {
        return r.concat(obj.traits);
    }, []);
}; //extract all traits from occupied equip slots

Game_Actor.prototype.equipTraitsWithId = function(code, id) {
    return this.equipTraits().filter(function(trait) {
        return trait.code === code && trait.dataId === id;
    })
}; //filter out any unnecessary traits

Game_Actor.prototype.equipTraitsSum = function(code, id) {
    return this.equipTraitsWithId(code, id).reduce(function(r, trait) {
        return r + trait.value;
    }, 1)
}; //add all trait values together

Game_Actor.prototype.equipXparam = function(xparamId) {
    return this.equipTraitsSum(Game_BattlerBase.TRAIT_XPARAM, xparamId);
}; //return the value of equipTraitsSum by passing the relevant xparamId.
You then use "this._actor.equipXparam(xparamId)" to get the value for your drawText command.

I don't understand the relevance of the extra equip slots. :kaoswt2:
 

deus69xxx

Villager
Member
Joined
Oct 13, 2013
Messages
11
Reaction score
1
First Language
English
Primarily Uses
RMMV
Work sucks + trying to make this work...

The extra equip slots was because of variable numbers of equip slots, and various tries were telling me things don't exist.

Also, this didn't work, but I have found a way to make it work by making the code for the status screen ugly. The things above were giving me fractions long decimals like .00000009 o_O, and total additions. I'm going to assume I messed up somewhere, but I have made some form of success. Thanks for your help!

Edit: Additionally, it's STILL sometimes giving me long decimals. Odd. Just gonna have to learn how to round xD
 
Last edited:

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

Latest Threads

Latest Posts

Latest Profile Posts

Please do not buy games from g2a.com. The sellers have total power over you. The website has many scam sellers. It looks cheap, but the key code didn't work.
A while back I was having fun making my own custom tiles, then I hit carpet... why is it so difficult!? Lol.
Weekend is finally here... what would you like to see (?):
1) Pokemon into zelda minish-cap style
or
2) Pokemon into zelda gbc style
or
3) Zelda into pokemon style

#= Choose ===============#
||__[ Full mockup ]_[ Charset ]__||
#=======================#
I know someday I'll start working on this...

I'm so happy that I got Steam achievements to work in my game, thanks in large part to the posts by other RPG Maker devs on this issue!

Forum statistics

Threads
97,943
Messages
948,058
Members
129,191
Latest member
Homerx_666
Top