I am trying to implement a new system, currently having some issues with it not being recognized, even when the global.property, custom property and stat have been implemented.

// Toughness system (in theory)

The concept for the Toughness system is to increase the mitigation damage from the player, depending on the current mitigation score. In order for this system to work, a couple of properties (global and custom) and a new player.stat (max_defense) must be set, to establish a link between properties.

First a Global property called “mitigation” must be created, this property must be a number. The Global property “mitigation” is the primary measure that will trigger each Toughness stage of the system. The custom property “Level Toughness” will set each Toughness stage, from 0 to 5.

example:
Level 0 Toughness:
Level 1 Toughness:
Level 2 Toughness:
Level 3 Toughness:

The purpose of creating the “Level Toughness” custom property, is to allow the player to check the stage of toughness they are currently set too. The next step is to create a new player stat called “max_defense”. The max_defense stat must be created, and the value must be higher than the defense value. The purpose of this new stat is to create the conditions necessary to implement a new formula called “percentage”. (edited)

The percentage formula takes the percentage the player wishes to add to the defense and multiplies this percentage by the max_defense amount. The result of this formula will then be added to the current defense value. This is why the max_defense must be higher than the defense value.

Example: if you want the player to take 91% of the damage, that means that the player is only getting a 9% mitigation boost. Therefore, the formula must reflect this parameter, and the structure would be the following:


($defense_amount = 0.09 * player.stat["max_defense"];) = the player taking 91% of the overall damage.

and then you add this number to the current defense:

player.stat["defense"] += $defense_amount;

So if you are using a value of 1000 for the max_defense and 100 for defense value, the 0.09 would be

0.09 * 1000 = 90 (this is the mitigation amount)
90 + 100 = 190 (this is the stat defense amount)

This means that if you take into consideration the damage logic currently establish by default in RIAB.

$stat_diff = $attacker.stat["attack"] - $defender.stat["defense"];
if ($stat_diff <= 0) then
    $damage = random(0, 1);
elseif $weapon == null then
    $damage = $stat_diff + random(-1, 1);
else
    $damage = $stat_diff + random(-1, 1) + random($weapon.min_damage, $weapon.max_damage);
end;

if ($damage < 0) then
    $damage = 0;
end;

return $damage```

Then the mitigation system increases the defender stat, which will reduce the return $damage, due to a higher defense amount in the $stat_dif equation.

How can the player increase the mitigation score?

The mitigation is increased with equipping armor, jewelry's, and using skills.

//Level 0 Toughness: You take 100% of all damage received                ($defense_amount = 0.00 * player.stat["max_defense"];)
//Level 1 Toughness: You take 91%                                                       ($defense_amount = 0.09 * player.stat["max_defense"];)
//Level 2 Toughness: You take 82%                                                       ($defense_amount = 0.18 * player.stat["max_defense"];)
//Level 3 Toughness: You take 73%                                                       ($defense_amount = 0.27 * player.stat["max_defense"];)
//Level 4 Toughness: You take 64%                                                       ($defense_amount = 0.36 * player.stat["max_defense"];)
//Level 5 Toughness: You take 55%                                                       ($defense_amount = 0.45 * player.stat["max_defense"];)

//Toughness system, a new stat called max_defense must be created, and the value must be higher than the defense value.```



SUMMARY

The idea for the toughness system is to implement higher mitigation for damage on the player. This will also affect the hit ratio, due to how the hit rate works RIAB (need to figure this out). Currently, the system is not functioning. The global.property[“mitigation”] and the player.property[“Level Thougness”] is returning null,  when I try to print using the debug console. However, I believe that the most important part is that the concept is implemented, so once the proper structure is established, it should be functional. (edited)

I placed this in the "when character is damage" in global event section. I tried to make it as a function also, but it did not work.

Okay, so I changed to range (1, 100) and I placed the script in with the When character is hurt, I did not get error , but it did not recognize the global or custom property when I tried to print them in console, still says null.

// Toughness system (in theory)

//Level 0 Toughness: You take 100% of all damage received         ($defense_amount = 0.00 * player.stat["max_defense"];)
//Level 1 Toughness: You take 91%                                 ($defense_amount = 0.09 * player.stat["max_defense"];)
//Level 2 Toughness: You take 82%                                 ($defense_amount = 0.18 * player.stat["max_defense"];)
//Level 3 Toughness: You take 73%                                 ($defense_amount = 0.27 * player.stat["max_defense"];)
//Level 4 Toughness: You take 64%                                 ($defense_amount = 0.36 * player.stat["max_defense"];)
//Level 5 Toughness: You take 55%                                 ($defense_amount = 0.45 * player.stat["max_defense"];)



//Toughness system, a new stat called max_defense must be created, and the value must be higher than the defense value.
if global.property["mitigation"] == range(91, 100) then
    if player.stat["defense"] < player.stat["max_defense"] then
        player.property["Level Toughness"] = "Level Toughness 5";
        $defense_amount = 0.45 * player.stat["max_defense"];
        $text = "mitigation increase by ${$defense_amount}";
        player.stat["defense"] += $defense_amount;
    end;
elseif global.property["mitigation"] == range(75, 90) then
    if player.stat["defense"] < player.stat["max_defense"] then
        player.property["Level Toughness"] = "Level Toughness 4";
        $defense_amount = 0.36 * player.stat["max_defense"];
        $text = "mitigation increase by ${$defense_amount}";
        player.stat["defense"] += $defense_amount;
    end;
elseif global.property["mitigation"] == range(50, 74) then
    if player.stat["defense"] < player.stat["max_defense"] then
        player.property["Level Toughness"] = "Level Toughness 3";
        $defense_amount = 0.27 * player.stat["max_defense"];
        $text = "mitigation increase by ${$defense_amount}";
        player.stat["defense"] += $defense_amount;
    end;
elseif global.property["mitigation"] == range(25, 49) then
    if player.stat["defense"] < player.stat["max_defense"] then
        player.property["Level Toughness"] = "Level Toughness 2";
        $defense_amount = 0.18 * player.stat["max_defense"];
        $text = "mitigation increase by ${$defense_amount}";
        player.stat["defense"] += $defense_amount;
    end;
elseif global.property["mitigation"] == range(10, 24) then
    if player.stat["defense"] < player.stat["max_defense"] then
        player.property["Level Toughness"] = "Level Toughness 1";
        $defense_amount = 0.09 * player.stat["max_defense"];
        $text = "mitigation increase by ${$defense_amount}";
        player.stat["defense"] += $defense_amount;
    end;
elseif global.property["mitigation"] == range(0, 9) then
    if player.stat["defense"] < player.stat["max_defense"] then
        player.property["Level Toughness"] = "Level Toughness 0";
        $defense_amount = 0.00 * player.stat["max_defense"];
        $text = "mitigation increase by ${$defense_amount}";
        player.stat["defense"] += $defense_amount;
    end;
end;```

This is what I had before:

// Toughness system (in theory)

//Level 0 Toughness: You take 100% of all damage received         ($defense_amount = 0.00 * player.stat["max_defense"];)
//Level 1 Toughness: You take 91%                                 ($defense_amount = 0.09 * player.stat["max_defense"];)
//Level 2 Toughness: You take 82%                                 ($defense_amount = 0.18 * player.stat["max_defense"];)
//Level 3 Toughness: You take 73%                                 ($defense_amount = 0.27 * player.stat["max_defense"];)
//Level 4 Toughness: You take 64%                                 ($defense_amount = 0.36 * player.stat["max_defense"];)
//Level 5 Toughness: You take 55%                                 ($defense_amount = 0.45 * player.stat["max_defense"];)



//Toughness system, a new stat called max_defense must be created, and the value must be higher than the defense value.
if global.property["mitigation"] >= 100 then
    if player.stat["defense"] < player.stat["max_defense"] then
        player.property["Level Toughness"] = "Level Toughness 5";
        $defense_amount = 0.45 * player.stat["max_defense"];
        $text = "mitigation increase by ${$defense_amount}";
        player.stat["defense"] += $defense_amount;
    end;
elseif global.property["mitigation"] >= 75 then
    if player.stat["defense"] < player.stat["max_defense"] then
        player.property["Level Toughness"] = "Level Toughness 4";
        $defense_amount = 0.36 * player.stat["max_defense"];
        $text = "mitigation increase by ${$defense_amount}";
        player.stat["defense"] += $defense_amount;
    end;
elseif global.property["mitigation"] >= 50 then
    if player.stat["defense"] < player.stat["max_defense"] then
        player.property["Level Toughness"] = "Level Toughness 3";
        $defense_amount = 0.27 * player.stat["max_defense"];
        $text = "mitigation increase by ${$defense_amount}";
        player.stat["defense"] += $defense_amount;
    end;
elseif global.property["mitigation"] >= 25 then
    if player.stat["defense"] < player.stat["max_defense"] then
        player.property["Level Toughness"] = "Level Toughness 2";
        $defense_amount = 0.18 * player.stat["max_defense"];
        $text = "mitigation increase by ${$defense_amount}";
        player.stat["defense"] += $defense_amount;
    end;
elseif global.property["mitigation"] >= 10 then
    if player.stat["defense"] < player.stat["max_defense"] then
        player.property["Level Toughness"] = "Level Toughness 1";
        $defense_amount = 0.09 * player.stat["max_defense"];
        $text = "mitigation increase by ${$defense_amount}";
        player.stat["defense"] += $defense_amount;
    end;
elseif global.property["mitigation"] <= 9 then
    if player.stat["defense"] < player.stat["max_defense"] then
        player.property["Level Toughness"] = "Level Toughness 0";
        $defense_amount = 0.00 * player.stat["max_defense"];
        $text = "mitigation increase by ${$defense_amount}";
        player.stat["defense"] += $defense_amount;
    end;
end;```

And this was giving me a error.

Error in condition evaluation: Invalid operands in expression 'global.property["mitigation"] >= 100'
Error in condition evaluation: Invalid operands in expression 'global.property["mitigation"] >= 75'
Error in condition evaluation: Invalid operands in expression 'global.property["mitigation"] >= 50'
Error in condition evaluation: Invalid operands in expression 'global.property["mitigation"] >= 25'
Error in condition evaluation: Invalid operands in expression 'global.property["mitigation"] >= 10'
Error in condition evaluation: Invalid operands in expression 'global.property["mitigation"] <= 9'

Any help or suggestions in this matter is appreciated, thank you in advance!