Check if Player and event are facing

TheTowerfan

Veteran
Veteran
Joined
Oct 15, 2015
Messages
31
Reaction score
3
First Language
Eng
Primarily Uses
N/A
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!
 
Last edited by a moderator:

TheTowerfan

Veteran
Veteran
Joined
Oct 15, 2015
Messages
31
Reaction score
3
First Language
Eng
Primarily Uses
N/A
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.
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,434
Reaction score
7,713
First Language
German
Primarily Uses
RMMV
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.
 

TheTowerfan

Veteran
Veteran
Joined
Oct 15, 2015
Messages
31
Reaction score
3
First Language
Eng
Primarily Uses
N/A
This is the script, ty.


<removed script> 
 
Last edited by a moderator:

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,434
Reaction score
7,713
First Language
German
Primarily Uses
RMMV
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
 

TheTowerfan

Veteran
Veteran
Joined
Oct 15, 2015
Messages
31
Reaction score
3
First Language
Eng
Primarily Uses
N/A
My fault.


The script is linked in his thread here.
 
Last edited by a moderator:

Sixth

Veteran
Veteran
Joined
Jul 4, 2014
Messages
2,162
Reaction score
823
First Language
Hungarian
Primarily Uses
RMVXA
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.
 

TheTowerfan

Veteran
Veteran
Joined
Oct 15, 2015
Messages
31
Reaction score
3
First Language
Eng
Primarily Uses
N/A
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!
 
Last edited by a moderator:

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

On my journey of character rework: I had this character, she was meant to be just a princess that joins your party. And at long term she was just uninteresting... So I tweaked her to be a rebel agaisn't the royalty before meeting up with the party.

Quick tip for any other ametuer pixel artists! When trying to create a colour palette, enabling Antialiasing can speed up the process of creating different shades! Just place your lightest colour and your darkest colour next to each other, select both pixels, and stretch it out!
Revolutionizing the JRPG Industry: Knocking on Doors.

Take that, murderhobos.
Don't forget, aspiring writers: Personality isn't what your characters do, it is WHY they do it.

Forum statistics

Threads
106,054
Messages
1,018,580
Members
137,843
Latest member
Betwixt000
Top