So I use LeTBS (LeCode's Tactical Battle System) and need help getting Custom/Conditional Scopes working. Originally, a skill's scope is defined in its notebox like so:
But let's say I want the scope to change depending on a conditional. For example, I made a custom function to do so:
...meaning, if Skill 45 is learned, the range will be 4, else it'll be 3. So far so good...the issue shows up in the RegExp portion of the
Specifically, I get an error saying "Cannot read property 'includes' of undefined". This refers to line 4179:
This leads me to believe there's an issue w/ the line above that:
In short, I need to get "R2" to return the results of
For reference, this I what I put in the notebox of the skill:
Also, here's the original/unmodified
@Pharonix Hey, if u see this I could really use your help! (Pharonix is the author of this modification)
JavaScript:
<letbs>
scope: circle(1)
</letbs>
JavaScript:
TBSEntity.prototype.customRanged = function () {
if (user.isLearnedSkill(45))
{return "4";}
else
{return "3";}
};
...meaning, if Skill 45 is learned, the range will be 4, else it'll be 3. So far so good...the issue shows up in the RegExp portion of the
.makeScope() function:
JavaScript:
BattleManagerTBS.makeScope = function (data, center, param) { //Modified by PHX
var str, min, size;
var e = param.user;
if (e)
var a = e.battler();
if (data.match(/(circle|line|square|cross)\((.+)\)/i)) {
console.log(data);
console.log(RegExp.$2);
if (RegExp.$2.includes(",")) {
str = RegExp.$2.split(",");
size = Math.floor(Number(eval(str[0])));
min = Math.floor(Number(eval(str[1])));
} else if (RegExp.$2.match(/(\(.*\))/i)) {
//This checks if a function is used instead of the normal circle(x)/circle(x,y) format to return a number or x,y
//This will only be used if it does not use function(),function() as that will get picked up by the first statement.
//Afterwards, it essentially clones the original function with checking if comma delimited, or not.
R2 = eval(RegExp.$2);
if (R2.includes(",")) {
str = R2.split(",");
size = Math.floor(Number(eval(str[0])));
min = Math.floor(Number(eval(str[1])));
}
else {
size = Math.floor(Number(eval(RegExp.$2)));
}
}
else {
size = Math.floor(Number(eval(RegExp.$2)));
}
}
if (data.match(/custom\((.+)\)/i)) {
var scopeData = Lecode.S_TBS.Config.Custom_Scopes[String(RegExp.$1)];
scope = this.getScopeFromRawData(scopeData, center, param);
} else if (data.match(/circle\((.+)\)/i)) {
scope = this.makeCircleScope(center, size, min, param);
} else if (data.match(/line\((.+)\)/i)) {
scope = this.makeLineScope(center, size, min, param);
} else if (data.match(/square\((.+)\)/i)) {
scope = this.makeSquareScope(center, size, min, param);
} else if (data.match(/cross\((.+)\)/i)) {
scope = this.makeCrossScope(center, size, min, param);
} else if (data.match(/path/i)) {
scope = this.makePathScope(param);
} else {
var cx = center.x;
var cy = center.y;
var aoe = eval("[" + data + "]");
for (var i = 0; i < aoe.length; i++) {
var cell = this.getCellAt(aoe[i][0], aoe[i][1]);
if (cell)
scope.push(cell);
}
}
return LeUtilities.uniqArray(scope);
};
Specifically, I get an error saying "Cannot read property 'includes' of undefined". This refers to line 4179:
if (R2.includes(",")) {This leads me to believe there's an issue w/ the line above that:
R2 = eval(RegExp.$2);eval(RegExp.$2) SHOULD give us the result of the .customRange() function from earlier. I made sure by checking the console.log and saw console.log(data) returned circle(e.customRanged()) and console.log(RegExp.$2) returned e.customRanged() respectively. However, I get the error mentioned earlier.In short, I need to get "R2" to return the results of
e.customRanged(). Ofc, "customRanged" is just 1 example, it should theoretically work w/ any other custom scope function.For reference, this I what I put in the notebox of the skill:
JavaScript:
<letbs>
scope: circle(e.customRanged())
</letbs>
Also, here's the original/unmodified
.makeScope() function: (no custom/conditional scope feature)
JavaScript:
BattleManagerTBS.makeScope = function (data, center, param) {
var str, min, size;
var e = param.user;
if (e)
var a = e.battler();
if (data.match(/(circle|line|square|cross)\((.+)\)/i)) {
if (RegExp.$2.includes(",")) {
str = RegExp.$2.split(",");
size = Math.floor(Number(eval(str[0])));
min = Math.floor(Number(eval(str[1])));
} else {
size = Math.floor(Number(eval(RegExp.$2)));
}
}
if (data.match(/custom\((.+)\)/i)) {
var scopeData = Lecode.S_TBS.Config.Custom_Scopes[String(RegExp.$1)];
scope = this.getScopeFromRawData(scopeData, center, param);
} else if (data.match(/circle\((.+)\)/i)) {
scope = this.makeCircleScope(center, size, min, param);
} else if (data.match(/line\((.+)\)/i)) {
scope = this.makeLineScope(center, size, min, param);
} else if (data.match(/square\((.+)\)/i)) {
scope = this.makeSquareScope(center, size, min, param);
} else if (data.match(/cross\((.+)\)/i)) {
scope = this.makeCrossScope(center, size, min, param);
} else if (data.match(/path/i)) {
scope = this.makePathScope(param);
} else {
var cx = center.x;
var cy = center.y;
var aoe = eval("[" + data + "]");
for (var i = 0; i < aoe.length; i++) {
var cell = this.getCellAt(aoe[i][0], aoe[i][1]);
if (cell)
scope.push(cell);
}
}
return LeUtilities.uniqArray(scope);
};
@Pharonix Hey, if u see this I could really use your help! (Pharonix is the author of this modification)