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.

[VX] Enemy Sight Range

In the game I'm making, I want the enemies to appear on the map and run after the character when the character is in their sight.  When they touch, I want a battle to start using the traditional turn-based combat system.  I want it to be similar to the system used in Xenosaga: Episode I, which is described like this:

Wikipedia":31ofjh08 said:
Enemies are not encountered randomly; they patrol fixed locations on each map. When the player touches an enemy, he or she will enter a battle.

I want to use this system so that the player has the opportunity to explore and still face enemies.  It's annoying having to fight through fifty enemies while backtracking, so I want to remedy this.  I found something similar, http://www.rmvx.org/forums/index.php?topic=11641.0, but it was for XP.
 
You don't need a script. You can do it by events.

In each guard (or sentinel, or whatever), put them in Player Touch, and if the Player touches them, a battle will occur. In another event, put it in Paralel Process and actiave two variables (X and Y). These will represen't when your player touches an X coordinate or an Y coordinate. Like, make it, Variable 0001:X and Variable 0002:Y. In X, select Character: Player's Map X, and in Y select Character: Player's Map Y. Now, imagine there's a horizontal coridor you have to cross, and a guard in the middle looking downwards. His coordinates are, for example, (3, 3). In this coridor, you can pass in 2 tiles (Y=1 and Y=2, for example, X will always be 3 on where the guard will be looking). Ok, so, with this defined, in the guard's event, under the Variables, put something like: IF Variable X = 3 and IF Variable Y = 1 something happens.

Like:

@>Control Variables: [0001] = Player's Map X
@>Control Variables: [0002] = Player's Map Y
@>Conditional Branch: Variable [0001] == 3
    @>Conditional Branch: Variable [0002] == 1
        @>Set Move Route: [Guard 1] (Wait)
        :                      : $>Move Toward Player
        :                      : $>Move Toward Player
        :                      : $>Move Toward Player
        :                      : $>Move Toward Player
        :                      : $>Move Toward Player
        :                      : $>Move Toward Player
        :                      : $>Move Toward Player
        :                      : $>Move Toward Player
        :                      : $>Move Toward Player
        :                      : $>Move Toward Player
        @>
      : Else
        @>Conditional Branch: Variable[0002] ==2
            @>Set Move Route: [Guard 1] (Wait)
            :                      : $>Move Toward Player
            :                      : $>Move Toward Player
            :                      : $>Move Toward Player
            :                      : $>Move Toward Player
            :                      : $>Move Toward Player
            :                      : $>Move Toward Player
            :                      : $>Move Toward Player
            :                      : $>Move Toward Player
            :                      : $>Move Toward Player
            :                      : $>Move Toward Player
            @>
          : Else
            @>
          : Branch End
        @>
      :  Branch End
    @>
Else
    @>
Branch End
@> 

So, each time your character crosses (3, 1) or (3, 2) the guard will see him and start running after him (put as many of those as you want). Define the guard's speed in his event and, when he touches the player, start a battle. If you want him to be there never again, but a switch and leave it... if you want him to be, but only after you return to the map, put a switch to make him dissapear, but at the teleports, make all the guards go back to their original places (with Transfer Event) and put the switch off.  If you want him to just be therre after the battle, you just put "transfer event" to the place he was before.

Hope you can pull it off.
 
I've thought about using events, but a sight range script would be much easier since I intend to have quite a few monsters per map.  Also, I want the monsters to be able to move around instead of just stand guard, and that would get very messy with events.  Thanks for your help, though.
 
Wouldn't be very messy... Just hard to do. You'd had to choose conditions and variables to all the enemies, and state when they were there and character would pass in front, they would come after. Basically, you would be doubling your work. But, I also agreee a script would be much easier.
 
I would highly recommend this scriptlet to help you out in your endeavor.  It adds a method to the interpreter which allows you to check the distance between two objects.

With some creative use of that command inside conditionals of parallel-process events, it should be relatively easy to make your enemies change from their patrol route to a pursuit and back again.  Keep in mind that, once they've begun to pursue, they'll be off their patrol route.  To correct that, I recommend finding one of the A* pathfinding scripts out there, set their regular patrol to the equivalent of "move to this point, move to that point, move to the other point", so that wherever they've managed to find themselves after you lose them, they can get back where they're supposed to be.
 

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