Edit 2: 09.02.2025: Here is the current solution. So far i haven't encountered a problem. I use the VisuMZ_1_MessageCore plugin with its necessary requirements for it to work. The script is called via the Text Code Macro function in the plugin.
The code:
Edit 1 : 07.02.2025: Added thing and changed formatting for more clarity, hopefully
I'm trying to have the damage formulas of the skills displayed as a number in the description of the skill like Base Power: 123.
But I don't really know how to do it. I use the VisuStella Plugin, all core plugins plus some addition plugins one of them is the skill learn system and the skill shop system.
The goal is the have the "Base Power" of a skill displayed in battle, in the skill shop, int the skill menu when viewing the learned skill and in the skill learn menu.
I asked int the VisuStella discord and was told that this is doable with the message core macro function.
I'm struggling with the JS code. I looked at some older forum entries and at the MZ Scrip Call and Scrip Call References. it only helped somewhat.
I have some JS code but i'm stuck at it, because i don't know how to search for certain things and i don't know if the current code that i have is even correct.
Here are some examples of the damage formulas used by the skills:
((a.level*4)+(a.mmp*0.8)+(a.mat*1.1))
((a.level*1.0)+(a.atk*(1.01+(a.level/100))))*0.5
a.states().includes($dataStates[33]) ? ((a.level*3)+(a.mmp*0.7)+(a.mat*1.2))*1.2 : ((a.level*3)+(a.mmp*0.7)+(a.mat*1.0))
The damage calculation against enemy stats id done through the VisuStella Battle core -> damage settings -> damage style
Her is what i have.
Here is the code of the mentioned battle style Armor scaling.
I hope for some one can help me out.
Kind regard
Arthoras
The code:
JavaScript:
// Checks if the script is run while player is in battle.
if (SceneManager._scene instanceof Scene_Battle)
{
// Get the info of the current selected actor when in battle.
a = BattleManager.actor();
//Get the info of the selectes skill when in battle.
item = SceneManager._scene._skillWindow.item();
}
/* This is needed when VisuMZ_4_SkillShop plugin is used. Without this the game crashes uposn trying to
selcet a skill in the skill shop. */
else if (SceneManager._scene instanceof Scene_SkillShop)
{
// Displays "Not Available" insteas of the number for the "power" of the skill.
return "Not Available"
}
// Is used when the scrip is run and player is not in battle.
else
{
// Gets the info of the actor selected in the menu (the menu that opens when pressing ESC).
a = $gameParty.menuActor();
/* Gets the info of the skill currently selected in the menu (the menu that opens when pressing ESC).
if it should stop working / not work try replace it with the one below. */
item = SceneManager._scene.item();
// item = SceneManager._scene._itemWIndow.item();
}
/* Checks if the variable "item" is set to "null". Primarily used to prevent crashing the game when a
skill replaces the "attack command" while in battle */
if (item == null)
{
// Sets the variable "item" to the id of the skill the is used for the "attack command" Is set as a number.
item = a.attackSkillId();
/* Sets the variable "skill_dmg" to the Formula in the damage section from the selected skill.
The script call "$dataSkills[id]" is used since the variable "item" is a number. */
const skill_dmg = $dataSkills[item].damage.formula;
// Calculates the number of the formula from the selected skill
let value = Math.max(eval(skill_dmg), 0);
// Display the calculated number.
return (isNaN(value) ? 0 : value);
}
// Is used when the variabel "item" is NOT set as "null".
else
{
//Sets the variabel "skill_dmg" to the Formula in the damage section from the selected skill.
const skill_dmg = item.damage.formula;
// Calculates the number of the formula from the selected skill
let value = Math.max(eval(skill_dmg), 0);
// Display the calculated number.
return (isNaN(value) ? 0 : value);
}
Edit 1 : 07.02.2025: Added thing and changed formatting for more clarity, hopefully
I'm trying to have the damage formulas of the skills displayed as a number in the description of the skill like Base Power: 123.
But I don't really know how to do it. I use the VisuStella Plugin, all core plugins plus some addition plugins one of them is the skill learn system and the skill shop system.
The goal is the have the "Base Power" of a skill displayed in battle, in the skill shop, int the skill menu when viewing the learned skill and in the skill learn menu.
I asked int the VisuStella discord and was told that this is doable with the message core macro function.
I'm struggling with the JS code. I looked at some older forum entries and at the MZ Scrip Call and Scrip Call References. it only helped somewhat.
I have some JS code but i'm stuck at it, because i don't know how to search for certain things and i don't know if the current code that i have is even correct.
Here are some examples of the damage formulas used by the skills:
((a.level*4)+(a.mmp*0.8)+(a.mat*1.1))
((a.level*1.0)+(a.atk*(1.01+(a.level/100))))*0.5
a.states().includes($dataStates[33]) ? ((a.level*3)+(a.mmp*0.7)+(a.mat*1.2))*1.2 : ((a.level*3)+(a.mmp*0.7)+(a.mat*1.0))
The damage calculation against enemy stats id done through the VisuStella Battle core -> damage settings -> damage style
Her is what i have.
JavaScript:
if (SceneManager.isSceneBattle()) //<- To check if in battle, Copied, slightly modified from the damage formula "Armor Scaling" from the battle core
{
const a = BattleManager.actor(); //<- this is apparently how to get the selected actor in battle
}
else
{
const a = $gameParty.menuActor(); //<- and this is how to get the selected actor outside of battle
}
let formula = $dataSkills[id].damage.formula // <- to my understanding this is how to get the damage formula of a skill
// according to the MZ Scrip Call References
let value = Math.max(eval(formula), 0); //<- Copied from the damage formula "Armor Scaling" from the battle core
return (isNaN(value) ? 0 : value); //<- Copied, slightly modified from the damage formula "Armor Scaling" from the battle core
Here is the code of the mentioned battle style Armor scaling.
JavaScript:
// Declare Constants
const user = this.subject();
const target = arguments[0];
const item = this.item();
const a = this.subject();
const b = target;
const v = $gameVariables._data;
const sign = [3, 4].includes(item.damage.type) ? -1 : 1;
// Replace Formula
let formula = item.damage.formula;
if (SceneManager.isSceneBattle() && !this.isCertainHit()) {
const fmt = 'Math.max(this.applyArmorModifiers(b, %1), 1)';
formula = formula.replace(/b.def/g, fmt.format('b.def'));
formula = formula.replace(/b.mdf/g, fmt.format('b.mdf'));
formula = formula.replace(/b.agi/g, fmt.format('b.agi'));
formula = formula.replace(/b.luk/g, fmt.format('b.luk'));
}
// Calculate Damage
let value = Math.max(eval(formula), 0);
// Apply Defender's Defense Parameter
if (this.isDamage() && !this.isCertainHit()) {
// Calculate Base Armor
let armor = this.isPhysical() ? b.def : b.mdf;
armor = this.applyArmorModifiers(target, armor);
// Apply Armor to Damage
if (armor >= 0) {
value *= 100 / (100 + armor);
} else {
value *= 2 - (100 / (100 - armor));
}
}
// Return Value
return (isNaN(value) ? 0 : value) * sign;
I hope for some one can help me out.
Kind regard
Arthoras