Lucky 7 Fever

I was wondering if someone knew of a script or just a formula to create the “Lucky 7 Fever” skill/state from the Final Fantasy series? To give you a basic knowledge, for those who don’t know, it’s a skill/state that allows the player to deal either 7, 77, 777, or 7777 damage if a character’s health is that same number, otherwise it only does 1 damage. The effect varies depending on the game but it all centers around the number 7. I know how to formulate the damage for that. But what I want to know is if there is a way to create my own version of “Lucky 7 Fever” where the program checks to see if just the last digit of the actor’s health is a 7 and then it deals 777 damage? So essentially your actor’s health could be 7, 37, 167, 7017, or any other number ending in a 7 and they will be able to deal 777 damage, either through scripting or through a simple formula. If anyone has any suggestions or if this just isn’t possible at all..I’m all ears!
As far as checking whether the last digit in a number is a 7, all you need to do is "modulo 10" that number (divide by 10 and then evaluate the remainder). So for a skill formula, it's easy - I think the formula is if a.hp % 10 == 7; 777; else; 1; end and if that doesn't work then try mod instead of %.

To create a state that automatically activates and deactivates when the last digit of the actor's HP is or isn't a 7, that's much trickier and you would need a script. This page links you to a Neon Black script and a HimeWorks script (as well as providing a compatibility patch between the two) that I think you could probably use to make it work. However, note that the formula above would not be sufficient; you would need to figure out the syntax that the scripts want (perhaps in notetag form?), and you would also need to figure out what to call the actor since "a" is a shortcut for the skill user that only works in the formula box. The X.hp % 10 == 7 part should still work, as long as you figure out what you need to replace X with.
Oh wow! The formula you provided gave me exactly what I was looking for! I can't thank you enough! 😛

Original thread: https://forums.rpgmakerweb.com/threads/lucky-7-fever.120982/