Requesting some help with a skill cost script

Status
Not open for further replies.

Tailson

"Jim"
Member
Joined
Apr 21, 2014
Messages
6
Reaction score
3
First Language
English
Primarily Uses
RMMV
Hi, first post on the forum, I'm sorry it comes off as one of those whiny help me threads, but I'm a little bit stumped.

I 'borrowed' a script from @mrcopra last night, to get some skills costing gold (thanks!) but I've run into a little issue with it and I don't know enough about javascript to fix it. The gold is displaying next to the skill and is deducting from the total amount just fine, but it's also subtracting from the TP value which I don't want it to do.

Could a coding wizard have a quick look through and tell me what needs to change? I will forever adore you, honest.

Code:
/*:
 * @plugindesc Make skill cost gold. V 1.2
 * Read Help
 * @author mrcopra
 *
 *
 * @param CostGoldColour
 * @desc Change The cost colour
 * @default 17
 *
 * @help Write this in skill's note
 * <costGold:x>     // x is the amount of gold
 */

  var parameters = PluginManager.parameters('SkillCostGold');
   var CostGoldColour = Number(parameters['CostGoldColour'] || 17);
 
Game_BattlerBase.prototype.canPaySkillCost = function(skill) {
    //console.log(Number(skill.meta.costGold))
    if (skill.meta.costGold){
    return $gameParty.gold() >= this.skillGdCost(skill)}else{
    return this._tp >= this.skillTpCost(skill) && this._mp >= this.skillMpCost(skill)};
};

Window_Base.prototype.gdCostColor = function() {
    return this.textColor(CostGoldColour);
};

Window_SkillList.prototype.drawSkillCost = function(skill, x, y, width) {
    if (this._actor.skillGdCost(skill) > 0) {
        this.changeTextColor(this.gdCostColor());
        this.drawText(this._actor.skillGdCost(skill), x, y, width, 'right');
    } else if (this._actor.skillTpCost(skill) > 0) {
        this.changeTextColor(this.tpCostColor());
        this.drawText(this._actor.skillTpCost(skill), x, y, width, 'right');
    } else if (this._actor.skillMpCost(skill) > 0) {
        this.changeTextColor(this.mpCostColor());
        this.drawText(this._actor.skillMpCost(skill), x, y, width, 'right');
    }
};

Game_BattlerBase.prototype.skillMpCost = function(skill) {
    if (skill.meta.costGold){
        return Number(skill.meta.costGold);
    }
    return Math.floor(skill.mpCost * this.mcr);
};

Game_BattlerBase.prototype.skillTpCost = function(skill) {
        if (skill.meta.costGold){
        return Number(skill.meta.costGold);
    }else{
    return skill.tpCost};
};

Game_BattlerBase.prototype.skillGdCost = function(skill) {
    return Number(skill.meta.costGold);
};

Game_BattlerBase.prototype.paySkillCost = function(skill) {
    this._mp -= this.skillMpCost(skill);
    this._tp -= this.skillTpCost(skill);
    if (skill.meta.costGold){
    console.log(this.skillGdCost(skill));
$gameParty.loseGold(this.skillGdCost(skill))} ;
};

Game_BattlerBase.prototype.meetsSkillConditions = function(skill) {
    return (this.meetsUsableItemConditions(skill) &&
            this.isSkillWtypeOk(skill) && this.canPaySkillCost(skill) &&
            !this.isSkillSealed(skill.id) && !this.isSkillTypeSealed(skill.stypeId));
};
 

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,718
First Language
English
Primarily Uses
RMVXA
Before moving this to JS Plugin Support, just one quick question.

Normally skills do not use TP unless you tell it to by giving it a TP cost on the skill tab. Have you checked that the TP for this particular skill is set to zero?
 

Tailson

"Jim"
Member
Joined
Apr 21, 2014
Messages
6
Reaction score
3
First Language
English
Primarily Uses
RMMV
Oh, did I put it in the wrong place? Sorry about that.

Yeah, checked that over. I did a quick test by changing the gold cost from 50 to something silly (30000) in the notes box on the skill. Sure enough, when I used the skill, the TP went to -29,990 for a moment before setting back to 0.

A quick link to show you the skill: http://i.imgur.com/PB8RwOi.png
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
2,616
Reaction score
1,978
First Language
English
Primarily Uses
RMMV
I'm no expert (*snicker*) but I think it might be something to do with this:

Code:
Game_BattlerBase.prototype.skillTpCost = function(skill) {
        if (skill.meta.costGold){
        return Number(skill.meta.costGold);
    }else{
    return skill.tpCost};
};

"If the skill costs gold, then its TP cost should be its gold cost". Does that look right to you? ;)
 

Tailson

"Jim"
Member
Joined
Apr 21, 2014
Messages
6
Reaction score
3
First Language
English
Primarily Uses
RMMV
O- oh. Right, that doesn't look right at all. Hah. What would I need to do to put that right?

Edit: I just commented it out. It was that easy?! Thank you very much, @Trihan. As promised, I adore you forever.
 
Last edited:

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,817
Reaction score
7,885
First Language
German
Primarily Uses
RMMV
[move]Plugin Support[/move]
[closed]IgnoreMe[/closed]
 
Status
Not open for further replies.

Latest Threads

Latest Posts

Latest Profile Posts

Snarkyfork wrote on Trihan's profile.
Hey man, I saw you mention that you do MV javascript work? Just wanted to confirm it before I put you on speed dial. =)
"Man is made by his belief. As he believes, so he is."-Krishna
FastFood in my country is neither fast nor cheap like it's expected to be, but people still buy a lot of it. I don't want to imagine how much of it people would eat if it was.
Started finishing up my bosses and characters...I don't know how long...but its going to take long...

I ended up needing to do a chapter one world map remake. It's still WIP but coming along nicely. =D

Forum statistics

Threads
107,757
Messages
1,031,934
Members
139,900
Latest member
CGI_ERICYT
Top