So i wanna know if it's possible to make the engine check which is the highest attribute an actor has when comparing 2 or more of them to calculate damage or healing or anything else.
I think this could make building characters way more flexibe compared to force the player to have an specific route to follow based on skills alone.
i have no idea about how to do it either, could you give an example plx
Ok, I can do that. 🙂
Lets say you have a skill that uses either the hp, mp or tp value from the battler - depending on which is higher..
You would put something like this into your skill formula box:
Math.max(a.hp,a.mp,a.tp) * 4 - Math.max(b.hp,b.mp,b.tp) * 2;
That would use the highest value from hp/tp/tp and compare it against the targets highest stat from those same three.
You could go a step further (and arguably more professional) and create custom skill forumla directly inside the battler class, for example - creating a new plugin script, and loading it within your game. The plugin you created would consist solely of forumlas for use within your skills/items.
The main benefit to doing this, is being able to create insanely complex formulae such as the example below:
Game_BattlerBase.prototype.myAwesomeSkillFormula = function(target) {
// Defines the base atk and def values.
var atkValue = Math.max(this.hp, this.mp, this.tp);
var defValue = Math.max(target.hp, target.mp, target.tp);
// If game switch 1 is on, add the value held
// in game variable 1 onto base atk value.
if ($gameSwitches.value(1)){
atkValue += $gameVariables.value(1);
};
// If game switch 2 is on, add the value held
// in game variable 2 onto base def value.
if ($gameSwitches.value(2)){
defValue += $gameVariables.value(2);
};
// Check value of variable 3, and do a different thing based on it
// Lets assume we have a difficulty value stored in this variable-
// 1 being easy, 2 medium, and 3 is hard mode. This allows us to
// change the atk value based on the 'game mode' variable.
switch( Number( $gameVariables.value(3) ) ){
case 1: atkValue *= 1.25; break;
case 2: atkValue *= 1.00; break;
case 3: atkValue *= 0.75; break;
};
// Store the current date for use in a moment..
var theDate = new Date();
// Check the day of the week, and if monday morning then allow continue
// 0 = sunday, 1 = monday, 2 = tuesday and so on..
if (theDate.getDay() === 1){
// Check the time of the day, and if before mid day, reduce both
// battlers values - cause everyone knows monday mornings are .
// Hour value is between 0 and 23.
if (theDate.getHours() < 12){
atkValue /= 2;
defValue /= 2;
};
};
// Now lets calculate the damage using a basic formula.
// This is identical to how most default fomrulas work.
var damageValue = atkValue * 4 - defValue * 2;
// Return damage value to formula box (required)
// Use .clamp on the number to limit its returned value.
// the 1 signifies the minimum, and 999 the maximum.
return damageValue.clamp(1, 999);
};
Then, to use the awesome new formula you made in your skills, reference it within the skill formula box, as shown below:
a.myAwesomeSkillFormula(b);
This calls the function on the attacker, and passes the target into the function - which is required to obtain the values for the defValue modifier.
Anyway - hope that info helps some. 🙂
With comments it helps a lot, it's really impressive.
Thx a lot, really.
No problem, glad it is helpful for you. 🙂