This is probably going to be a long one.
My project is based on SAS - Sapphire Action System. However, it uses a custom system made by me that modify some aspects of gameplay. For instance, the player has a stamina bar and is only able to attack if their stamina is positive. There's also a custom dodging and running system, and some "ai" attack patterns for the enemies, among other things.
One of the core systems that affect gameplay is the parrying system. Where the player presses a button and, if an enemy hits them in a small timeframe, they negate incoming damage and, for a tiny timeframe, is able to counterattack for critical damage.
It works like this (click to enlarge):
This is a parallel process common event that starts running at the start of the game. "DAMAGE condition" is a switch that activates the "graphical-hurt" state system and is turned off to make sure the player is standing up when parrying. "char_effect" has to do with a gfx script for characters. The event checks if the player has received any damage during the "parry" animation, if yes, they'll recover the lost hp, then enter the "parrying" state where they'll be invulnerable and having 120% of the regular attack stat.
Then, it will turn on a switch that activates another common event, which will last 12 frames (the duration of the opening to riposte):
This common event is a parallel process that checks if the player has pressed the attack button, then if the player is currently able to attack (i.e not in a "pain" animation, or have enough stamina), and if he's buffed with the "parrying" state (which grants them additional damage). Then it modifies a variable to later make sure the riposte was executed and some SEs play/ the screen shakes to indicate that the player has succesfully executed a riposte. Then the event is deactivated. You can ignore the first condition, i recently removed it and it makes no difference.
After that's done, we continue to the first event:
The first thing it does is checking if the player has actually riposted, by evaluating the number of the variable that is defined before the opening and updated if the player ripostes during the opening. If yes, the game waits a bit before removing the buff (to make sure the buff lasts just enough to fit with the player's attack speed). If no, it just removes it with no waiting.
What happens next is the player receives a mana point and recovers his lost health. Then the game deactivates the switches that indicate the player being in a parrying state and things return to normal.
THE ISSUE:
For some reason, this doesn't work all the time. As you can check in the timestamps in the video below... and please try to not mind the annoying bell sound, it's used for debugging and is supposed to be like that so it's very obvious when the game understands that a riposte is executed - that way i can more easily identify when something goes wrong with the system:
You can see the bug at around 00:17 where it hits for regular damage (7) instead of critical damage (27), 00:24 where it hits for 7 then 0 damage (the attack doesn't connect), at around 00:57, 00:59, 01:21 and 01:24 where the player deals 7 damage when they should deal 27.
I'm trying hard to make sure the player meets all criteria to riposte successfully. I only very recently added a lot of the conditions you see that "guarantee" the player will be able to deal the proper amount of damage. But somehow, it is not 100% consistent. And i don't like the idea of having an inconsistent mechanic in the game (even if i come up with an excuse saying something like "parrying only works 90% of the time because it's an op mechanic"). There's also the issue of the game identifying the criteria being met, playing the SEs and shaking the camera as if the riposte was executed, but the attack simply isn't executed - though this is more rare.
I'd deeply appreciate any directions, suggestions and any help of any kind. I'm no coder but i was also thinking if this is solvable via script, i could get some directions and start working on a workaround - maybe even improve the system.
I'd appreciate any help.
My project is based on SAS - Sapphire Action System. However, it uses a custom system made by me that modify some aspects of gameplay. For instance, the player has a stamina bar and is only able to attack if their stamina is positive. There's also a custom dodging and running system, and some "ai" attack patterns for the enemies, among other things.
One of the core systems that affect gameplay is the parrying system. Where the player presses a button and, if an enemy hits them in a small timeframe, they negate incoming damage and, for a tiny timeframe, is able to counterattack for critical damage.
It works like this (click to enlarge):
This is a parallel process common event that starts running at the start of the game. "DAMAGE condition" is a switch that activates the "graphical-hurt" state system and is turned off to make sure the player is standing up when parrying. "char_effect" has to do with a gfx script for characters. The event checks if the player has received any damage during the "parry" animation, if yes, they'll recover the lost hp, then enter the "parrying" state where they'll be invulnerable and having 120% of the regular attack stat.
Then, it will turn on a switch that activates another common event, which will last 12 frames (the duration of the opening to riposte):
This common event is a parallel process that checks if the player has pressed the attack button, then if the player is currently able to attack (i.e not in a "pain" animation, or have enough stamina), and if he's buffed with the "parrying" state (which grants them additional damage). Then it modifies a variable to later make sure the riposte was executed and some SEs play/ the screen shakes to indicate that the player has succesfully executed a riposte. Then the event is deactivated. You can ignore the first condition, i recently removed it and it makes no difference.
After that's done, we continue to the first event:
The first thing it does is checking if the player has actually riposted, by evaluating the number of the variable that is defined before the opening and updated if the player ripostes during the opening. If yes, the game waits a bit before removing the buff (to make sure the buff lasts just enough to fit with the player's attack speed). If no, it just removes it with no waiting.
What happens next is the player receives a mana point and recovers his lost health. Then the game deactivates the switches that indicate the player being in a parrying state and things return to normal.
THE ISSUE:
For some reason, this doesn't work all the time. As you can check in the timestamps in the video below... and please try to not mind the annoying bell sound, it's used for debugging and is supposed to be like that so it's very obvious when the game understands that a riposte is executed - that way i can more easily identify when something goes wrong with the system:
You can see the bug at around 00:17 where it hits for regular damage (7) instead of critical damage (27), 00:24 where it hits for 7 then 0 damage (the attack doesn't connect), at around 00:57, 00:59, 01:21 and 01:24 where the player deals 7 damage when they should deal 27.
I'm trying hard to make sure the player meets all criteria to riposte successfully. I only very recently added a lot of the conditions you see that "guarantee" the player will be able to deal the proper amount of damage. But somehow, it is not 100% consistent. And i don't like the idea of having an inconsistent mechanic in the game (even if i come up with an excuse saying something like "parrying only works 90% of the time because it's an op mechanic"). There's also the issue of the game identifying the criteria being met, playing the SEs and shaking the camera as if the riposte was executed, but the attack simply isn't executed - though this is more rare.
I'd deeply appreciate any directions, suggestions and any help of any kind. I'm no coder but i was also thinking if this is solvable via script, i could get some directions and start working on a workaround - maybe even improve the system.
I'd appreciate any help.