My project is heavily based on SAS - Sapphire Action System. I recently found a way to make enemies only be able to attack under the condition that a specific switch is on.
Here is the relevant event page (click to enlarge):
This is a parallel-process common event that manages enemy AI. In this page you can see the process of an enemy attack. There's a windup where the enemy shows the player that it's about to attack: they show a balloon, step backwards and wait a bit; and there's an attack, where the enemy changes its graphic (right now it's only a red tint over them) and charge forward.
When the windup process ends, the page checks if there's any enemy currently attacking. If there aren't, the game will Turn On a global switch that allows enemies to deal damage when touching the player and will turn On a switch that indicates there's an enemy attacking. If there are enemies attacking, the page will simply disable both switches - to try and guarantee that the player does not receive damage from enemy that is touching him but isn't in the "attack" state.
I say try because it doesn't work all the time. Check the video below, a slowed down fight highlighting the problem - note that the first two charges are correctly processed since the criteria is met (enemy is red and their front is touching the player):
At around 00:16 an enemy is able to hit the player even though he is not in the "attack" state (he's not red - he's simply walking towards the player. I suspect this happens because the second enemy activates the "enemies can attack" switch right when the first one finishes his charge, thus allowing the first one to hit the player when he shouldn't.
Is there an ingenious eventing way to fix this problem? Or even a way to script a solution? I run a slightly modified version of SAS made for the project and I could handle it to anyone interested in finding a script solution - since I'm no expert, but can handle the basics.
Any help is appreciated. Thanks.
Here is the relevant event page (click to enlarge):
This is a parallel-process common event that manages enemy AI. In this page you can see the process of an enemy attack. There's a windup where the enemy shows the player that it's about to attack: they show a balloon, step backwards and wait a bit; and there's an attack, where the enemy changes its graphic (right now it's only a red tint over them) and charge forward.
When the windup process ends, the page checks if there's any enemy currently attacking. If there aren't, the game will Turn On a global switch that allows enemies to deal damage when touching the player and will turn On a switch that indicates there's an enemy attacking. If there are enemies attacking, the page will simply disable both switches - to try and guarantee that the player does not receive damage from enemy that is touching him but isn't in the "attack" state.
I say try because it doesn't work all the time. Check the video below, a slowed down fight highlighting the problem - note that the first two charges are correctly processed since the criteria is met (enemy is red and their front is touching the player):
At around 00:16 an enemy is able to hit the player even though he is not in the "attack" state (he's not red - he's simply walking towards the player. I suspect this happens because the second enemy activates the "enemies can attack" switch right when the first one finishes his charge, thus allowing the first one to hit the player when he shouldn't.
Is there an ingenious eventing way to fix this problem? Or even a way to script a solution? I run a slightly modified version of SAS made for the project and I could handle it to anyone interested in finding a script solution - since I'm no expert, but can handle the basics.
Any help is appreciated. Thanks.