Check if Player and event are facing

I really need to start studying myself, but, until then, I need a script string to check if the player and an event are facing eachother.


If anyone could help, it would be great!
To be more precise I'm trying to write a shielding system, using SAS IV.


In this part:


  def damage_hero(value)
    actor = $game_party.members[0]
    value -= actor.def
 


I know how to check for the ''raised shield'', not how to check if the player and the enemy are facing eachother.


Both would be required to set value of the inflicted damage as 0.
I've moved this thread to Script Support. Please be sure to post your threads in the correct forum next time. Thank you.


Please give a link to the script, we can't help you without



Any ABS changes the engine in such a massive way that no compatible solution can be worked out without knowing the script.
This is the script, ty.


<removed script> 
This is the script



No, I asked for a link to the script, preferably to the site that also contains its descriptions and manual.


We do not want scripts reposted here for dozens of reasons, including that most scripters do not want reposts of their scripts and that for problem solution we need to check which bugfixes and updates might be available on the script's main site
My fault.


The script is linked in his thread here.
You can't check that in the method you wrote here, you don't have access to the attacker there.


If you trace that method, you will arrive in the 'attack' method found in the 'Game_Event' class (it's in the main SAS IV script).


That is where you can check if the event is facing the player or not by using this condition:


if @direction == reverse_dir($game_player.direction)


This would return true if they are facing towards each other.


As for where to put this in the method I mentioned, that depends on what you want to achieve with it, because there is a lot of thing going on in that method, not just the damage execution (some movements and animations are triggered there too).


But if you just want to avoid taking damage (with keeping all the other stuff happening in that method), you can wrap the whole damage triggering lines in this condition (this will not show any damage pop ups, I guess), or you can set the damage to 0 (or whatever value you want) when they are facing each other and the player is holding the shield (this will show the popup, because the damage is executed, but it is not the default damage).


I haven't tried this, but it should work like that, in theory.
You can't check that in the method you wrote here, you don't have access to the attacker there.


If you trace that method, you will arrive in the 'attack' method found in the 'Game_Event' class (it's in the main SAS IV script).


That is where you can check if the event is facing the player or not by using this condition:



if @direction == reverse_dir($game_player.direction)


This would return true if they are facing towards each other.


As for where to put this in the method I mentioned, that depends on what you want to achieve with it, because there is a lot of thing going on in that method, not just the damage execution (some movements and animations are triggered there too).


But if you just want to avoid taking damage (with keeping all the other stuff happening in that method), you can wrap the whole damage triggering lines in this condition (this will not show any damage pop ups, I guess), or you can set the damage to 0 (or whatever value you want) when they are facing each other and the player is holding the shield (this will show the popup, because the damage is executed, but it is not the default damage).


I haven't tried this, but it should work like that, in theory.



That worked like a charm, thank you!

Original thread: https://forums.rpgmakerweb.com/threads/check-if-player-and-event-are-facing.57160/