Creating a new resource to replace TP, but still use TP. Requested example: RAGE.
Plugin(s) required: VisuMZ_1_SkillsStatesCore
Optional: VisuMZ_2_EnhancedTpSystem
VisuMZ_1_SkillsStatesCore > Skill Cost Types >
Double-Click an empty area to create a new type >
Double-Click an empty area to create a new type >
Name - A name for this Skill Cost Type. This example: RG
Icon - Icon used for this Skill Cost Type. This example: 0
Font Color - Text Color used to display this cost. This example: #E60000
Font Size - Font size used to display this cost. This Example: 22
Expected result:
Optional: using Icon
Expected result:
Cost Processing
Code on how to calculate this resource cost for the skill.
Code:
// Declare Variables
const user = this;
const skill = arguments[0];
let cost = 0;
// Calculations
const note = skill.note;
if (note.match(/<RG COST:[ ](\d+)>/i)) {
cost += Number(RegExp.$1);
}
if (note.match(/<RG COST:[ ](\d+)([%%])>/i)) {
cost += Math.ceil(Number(RegExp.$1) * user.tp / 100);
}
if (note.match(/<JS RG COST>\s*([\s\S]*)\s*<\/JS RG COST>/i)) {
const code = String(RegExp.$1);
eval(code);
}
// Apply Trait Cost Alterations
if (cost > 0) {
const rateNote = /<RG COST:[ ](\d+\.?\d*)([%%])>/i;
const rates = user.traitObjects().map((obj) => (obj && obj.note.match(rateNote) ? Number(RegExp.$1) / 100 : 1));
const flatNote = /<RG COST:[ ]([\+\-]\d+)>/i;
const flats = user.traitObjects().map((obj) => (obj && obj.note.match(flatNote) ? Number(RegExp.$1) : 0));
cost = rates.reduce((r, rate) => r * rate, cost);
cost = flats.reduce((r, flat) => r + flat, cost);
cost = Math.max(1, cost);
}
// Set Cost Limits
if (note.match(/<RG COST MAX:[ ](\d+)>/i)) {
cost = Math.min(cost, Number(RegExp.$1));
}
if (note.match(/<RG COST MIN:[ ](\d+)>/i)) {
cost = Math.max(cost, Number(RegExp.$1));
}
// Return cost value
return Math.round(Math.max(0, cost));
Code on calculating whether or not the user is able to pay the cost.
Code:
// Declare Variables
const user = this;
const skill = arguments[0];
const cost = arguments[1];
// Return Boolean
if (cost <= 0) {
return true;
} else {
return user.tp > cost
}
Code for if met, this is the actual process of paying the cost.
Code:
// Declare Variables
const user = this;
const skill = arguments[0];
const cost = arguments[1];
// Process Payment
user._tp -= cost;
Window Display
Code for determining if the cost is shown or not.
Code:
// Declare Variables
const user = this;
const skill = arguments[0];
const cost = arguments[1];
// Return Boolean
return cost > 0;
Code to determine the text (with Text Code support) used for the displayed cost.
Code:
// Declare Variables
const user = this;
const skill = arguments[0];
const cost = arguments[1];
const settings = arguments[2];
const fontSize = settings.FontSize;
const color = settings.FontColor;
const name = settings.Name;
const icon = settings.Icon;
let text = '';
// Text: Change Font Size
text += '\\FS[%1]'.format(fontSize);
// Text: Add Color
if (color.match(/#(.*)/i) && Imported.VisuMZ_1_MessageCore) {
text += `\\HexColor<${color}>`.format(String(RegExp.$1));
} else {
text += '\\C[%1]'.format(color);
}
// Text: Add Cost
text += '%1 %2'.format(cost, name);
// Text: Add Icon
if (icon > 0) {
text += '\\I[%1]'.format(icon);
}
// Return text
return text;
Gauge Display
Code to determine the maximum value used for this Skill Cost resource for gauges.
Code:
// Declare Variables
const user = this;
// Return value
return user.maxTp();
Code:
// Declare Variables
const user = this;
// Return value
return user.tp;
Code to determine how to draw the Skill Cost resource for this gauge type.
Code:
const color1 = "#660000";
const color2 = "#FFFFFF";
const label = "RAGE";
Code:
// Declare Settings
const color1 = "#660000"; // Change this for the left color blend
const color2 = "#E60000"; // Change this for the right color blend
const label = "RG"; // Change this to the text you want displayed on gauge
// Declare Variables
const sprite = this;
const settings = sprite._costSettings;
const bitmap = sprite.bitmap;
const user = sprite._battler;
const currentValue = sprite.currentDisplayedValue();
const bitmapWidth = sprite.bitmapWidth();
const bitmapHeight = sprite.textHeight ? sprite.textHeight() : sprite.bitmapHeight();
const gaugeHeight = sprite.gaugeHeight();
// Draw Gauge
const gx = 0;
const gy = bitmapHeight - gaugeHeight;
const gw = bitmapWidth - gx;
const gh = gaugeHeight;
this.drawFullGauge(color1, color2, gx, gy, gw, gh);
// Draw Label
const lx = 4;
const ly = 0;
const lw = bitmapWidth;
const lh = bitmapHeight;
sprite.setupLabelFont();
bitmap.textColor = settings.FontColor;
bitmap.paintOpacity = 255;
bitmap.drawText(label, lx, ly, lw, lh, "left");
// Draw Value
const vw = bitmapWidth - 2;
const vh = bitmapHeight;
sprite.setupValueFont();
bitmap.textColor = "#FFFFFF"; // Change this for the value color
bitmap.drawText(currentValue, 0, 0, vw, vh, "right");
Code:
bitmap.textColor = "#FF00FF";
Changing the resource displayed for class
Add the replacement notetag in the class notebox:
Code:
<Replace TP Gauge: RG>
Add the replacement notetag in the skill notebox:
Code:
<RG Cost: 10>
Everything here is just an example, explore your ideas!
You can now optionally setup the way this resource functions using VisuMZ_2_EnhancedTpSystem