Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Stop random moving events from facing player upon activation

ooryl2

Member

I think I somewhat solved the dilemma of the preemptive/surprise issue working with Battle Processing within events, and this issue relates to the same project, but figured it should be in a different thread.

Here's the situation:

My encounters are event based, not random, and either approach or run away from the player when they get within a certain range. If the player is at a certain level compared to the Troops in the event, the event will move away from the player instead of moving towards the player. I want there to be a Preemptive strike if the player touches the event when it is facing away from the player, but if the player touches the side or front on the event then it will be a regular battle.

Here's the problem:

The problem is, as soon as the player touches the event, the event turns towards the player, thereby negating the Preemption from triggering. Since the event is set to move away from the player and it changes direction as it does so, I can't use the directional fix option, and if I try to add a Set Move Route in the event to fix the direction, it won't happen until the event already faces the player upon touch.

I can overcome this problem by setting the events to be below the player, but I would like them to be the same level so that the events are not walked over or under.

I think my only option will be a script, but if there's an easier way to do it within the event instead of a script, that would be wonderful. If the only option is a script to make all events not face the player on activation, then I'd probably have to remember to add a "face player" Move Route in each of my other events that should change direction.

Thanks for any advice!
 
How about Set Move:Turn away from player?
Edit:
Running tests I see the problem. This worked for me. 2 event pages. One that switches on a self switch. The Second with Direction fix check and conditional branches that determine if the player is behind the event.
Surpise_event.png

Edit2: I realized the way I set up my conditional branches it doesn't really tell who is behind who. So its possible for the event to trigger a surprise if it touches you from behind. Assuming its set for event touch and not player touch.
Edit3: But you can use variables to compare the player and events X and Y locations.
 

ooryl2

Member

Thanks for the reply. I'll have to look at my events when I get home tonight. I think I've tried similar, but the way I have them set up, it didn't seem to work. I'll have to look at them and post the event scripts here to make sure. If I'm remembering right, this is the general idea of what I have for the events.

Page 3 is the one that is giving me the troubles.

Page 1 Parallel Process, I have a custom move route set up so the event/monster patrols a small diamond path (Move Upper Left, Move Upper Right, Move Lower Right, Move Lower Left, repeat). I have checks for the player's position and event's position. Once the player comes within 3 steps of the event, the event checks the player's level against the encounter's "level" (I did some calculations to find out basically when the player would one-hit the monsters). If the Player's level is at the point where they will one hit the monsters (i.e. level 6 for slimes), Self Switch A is turned on. If the Player's level is slightly below that, Self Switch B is turned on (i.e. level 4 for slimes.) If the Player's level is below that, Self Switch C is turned on.

Page 2, Switch A on, Player Touch, Custom Move route (Move Away from Player), on player touch, the player automatically wins the encounter and receives the xp/gold they would normally. Then "Erase Event".

Page 3, Switch B on, Player Touch, Custom Move route (Move Away from Player), on player touch I have 4 double-conditional branches (i.e. if Player facing Up, then if Event facing Up, Preemptive switch is turned on). Battle Processing (this is where the Preemptive/surprise should kick in but the event always turns upon activation so it doesn't work). If win or flee "Erase Event."

Page 4, Switch C on, Event Touch, Custom Move route (Move Towards Player). same conditional branches about player/event facing. Battle Processing (the surprise condition works here as the player does not autoface the event upon activation). If win or flee "Erase Event."

Page 5, Switch #x is on, Parallel Process. Turn off all Self-Switches and Erase Event (Switch X turns on when Player leaves the zone so that the event will reset itself when the player re-enters.)

From what I remember though, I think I have a Self-Switch D in there somewhere as well. It may be on Page 1 that I have the Self-Switch D turn on when the player gets too close, and then the Self-Switch D page does the level comparison. If that is the case, then I might be able to condense my events to what I described above, and have that Switch D available to try as you suggested.
 

ooryl2

Member

coyotecraft":2pvun9gj said:
How about Set Move:Turn away from player?
Edit:
Running tests I see the problem. This worked for me. 2 event pages. One that switches on a self switch. The Second with Direction fix check and conditional branches that determine if the player is behind the event.

Edit2: I realized the way I set up my conditional branches it doesn't really tell who is behind who. So its possible for the event to trigger a surprise if it touches you from behind. Assuming its set for event touch and not player touch.
Edit3: But you can use variables to compare the player and events X and Y locations.

Thank you so much! It looks to be working perfectly now with using your suggestion!

Here's my relevant event pages, just as an fyi. Not sure if they're as clean as they can be or not. Page 3 is just a copy of page 2 with the appropriate move route. Page 6 is a page to reset the event when the player leaves the map.

page1ula.jpg

page2zg.jpg

page4du.jpg

page4pt2.jpg

page5k.jpg
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top