I find out $gameActors.actor(actorId)._actions[0]._ item._itemId is a Sellected Skill Id in thread. And this is 0 when I start battle.
But this value does not change when I cancel the skill.
And when I use skill the value does not defined because of 'TypeError: Cannot read property '_item' of undefined' before next turn start. (I find those with SRDude's HUD MAKER and there are only one error 'TypeError: Cannot read property '_item' of undefined')
I want the value to be 0 again when canceled and used skill.
Please Help Me!😢
This is my code.
Cost ID = {};
Cost.SID = function (skill) {
var caster = $gameActors.actor($gameParty.members()[0].actorId());
var action = caster._actions[0]._item;
var sid = action._itemId
{return sid}
};
+ I am sorry for the mistake of using English. But if you write something for me. I'll try hard to use that!
You gave us your function, but completely forgot to give us one more important thing.... How you use that function. If we don't know how you use it, it is not the easiest to fix it.
So the Game_BattlerBase stuff calls your Cost.SID?
Ok, I'll wait until then. Because as it is now, it is impossible to orientate in.
This is my all script.
It works like last time.
And I find out error when I use skill menu.
'TypeError: Cannot read property '_item' of undefined'
I think I should add $gameparty,inbattle()
var COST = {};
COST.party1 = function cost1() {
var c1 = null;
if ($gameParty.members()[0].actorId() > 0) {
c1 = 5 + Math.trunc($gameActors.actor($gameParty.members()[0].actorId()).level / 5)
} else {c1 = 0};
{ return c1 }
};
COST.party2 = function cost2() {
var c2 = null;
if ($gameParty.members().length >= 2) {
c2 = 5 + Math.trunc($gameActors.actor($gameParty.members()[1].actorId()).level / 5)
} else {c2 = 0};
{ return c2 }
};
COST.party3 = function cost3() {
var c3 = null;
if ($gameParty.members().length >= 3) {
c3 = 5 + Math.trunc($gameActors.actor($gameParty.members()[2].actorId()).level / 5)
} else {c3 = 0};
{ return c3 }
};
COST.party4 = function cost4() {
var c4 = null;
if ($gameParty.members().length >= 4) {
c4 = 5 + Math.trunc($gameActors.actor($gameParty.members()[3].actorId()).level / 5)
} else {c4 = 0};
{ return c4 }
};
COST.partyvalue = function cost() {
var C = COST.party1() + COST.party2() + COST.party3() + COST.party4();
{return C}
};
COST.Skill1 = function scost1(skill){
var sid = 0;
var caster = $gameActors.actor($gameParty.members()[0].actorId());
var action = caster._actions[0]._item
if (action.isSkill()) {
if (action._itemId > 0) {var sid = $dataSkills[action._itemId].meta.cost;}
else {var sid = 0;} }
else {var sid = 0;}
{return sid}
};
COST.Skill2 = function scost2(skill){
var sid = 0;
if ($gameParty.members().length >= 2){
var caster = $gameActors.actor($gameParty.members()[1].actorId());
var action = caster._actions[0]._item;
if (action.isSkill()) {
if (action._itemId > 0) {var sid = $dataSkills[action._itemId].meta.cost;}
else {var sid = 0;} }
else {var sid = 0;} }
else {var sid = 0;}
{return sid}
};
COST.Skill3 = function scost3(skill){
var sid = 0;
if ($gameParty.members().length >= 3){
var caster = $gameActors.actor($gameParty.members()[2].actorId());
var action = caster._actions[0]._item;
if (action.isSkill()) {
if (action._itemId > 0) {var sid = $dataSkills[action._itemId].meta.cost;}
else {var sid = 0;} }
else {var sid = 0;} }
else {var sid = 0;}
{return sid}
};
COST.TSkill = function totalscost(skill){
var total = Number(COST.Skill1(skill)) + Number(COST.Skill2(skill)) + Number(COST.Skill3(skill));
{return total}
};
Game_BattlerBase.prototype.canPaySkillCost = function(skill) {
if (Game_Actor.prototype.isActor() == true) {return this._tp >= this.skillTpCost(skill) && this._mp >= this.skillMpCost(skill) && COST.partyvalue() - COST.TSkill(skill) >= this.skillMpCost(skill);
} else {return this._tp >= this.skillTpCost(skill) && this._mp >= this.skillMpCost(skill)};
};