Llov11

Villager
Member
Joined
Jul 22, 2018
Messages
16
Reaction score
1
First Language
Spanish
Primarily Uses
RMVXA
Hi guys! Sorry to bother with this noob question, but I've searched through the forum to find an answer to my doubt and wasn't able to find any.

Is there a way to change the distance in which events are drawn/processed?

My problem is with a rather large sprite. It's 5x5 tiles and when the user aproaches it from avobe, then the sprite kind of apears out of nowhere.

I understand that if the distance of event processing is increased that would mean that more events would be processed simultaneously and thus creating more lag, but that is a risk I'm willing to take.

Any help is welcome! And thank you on advanced!
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
33,389
Reaction score
8,398
First Language
German
Primarily Uses
RMMV
you need to search for the so-called anti-lag scripts.

disabling event processing over a distance is an anti-lag feature, and of the five or six scripts for anti-lag that existed years ago there were several that could both exclude specific events and modify that range in general. I just don't know which of those scripts are still around because a lot of the links in the Ace Master Script List go to deleted websites.
 

Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
42,914
Reaction score
15,006
First Language
English
Primarily Uses
RMMV
Because this is handled by code, you will need a script to change it.

Try the following - it is untested so report back if you get any errors.

Code:
class Game_Event < Game_Character
  def near_the_screen?(dx = 17, dy = 13)
    ax = $game_map.adjust_x(@real_x) - Graphics.width / 2 / 32
    ay = $game_map.adjust_y(@real_y) - Graphics.height / 2 / 32
    ax >= -dx && ax <= dx && ay >= -dy && ay <= dy
  end

  def near_the_player?
    sx = distance_x_from($game_player.x).abs
    sy = distance_y_from($game_player.y).abs
    sx + sy < 25
  end
end

Note, because this is expanding the border around the screen within which events will become active (and visible), you may see a performance impact.
 

Llov11

Villager
Member
Joined
Jul 22, 2018
Messages
16
Reaction score
1
First Language
Spanish
Primarily Uses
RMVXA
Because this is handled by code, you will need a script to change it.

Try the following - it is untested so report back if you get any errors.

Code:
class Game_Event < Game_Character
  def near_the_screen?(dx = 17, dy = 13)
    ax = $game_map.adjust_x(@real_x) - Graphics.width / 2 / 32
    ay = $game_map.adjust_y(@real_y) - Graphics.height / 2 / 32
    ax >= -dx && ax <= dx && ay >= -dy && ay <= dy
  end

  def near_the_player?
    sx = distance_x_from($game_player.x).abs
    sy = distance_y_from($game_player.y).abs
    sx + sy < 25
  end
end

Note, because this is expanding the border around the screen within which events will become active (and visible), you may see a performance impact.
Wow! This worked beautifully! Yeah, the performance dropped a bit, but that was expected. I'll have to be careful with the amount of events in my maps.

Sorry for my ignorance, but how many tiles have you increased the "range" of event processing?

Obviously I cannot thank you enough for this!
 

Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
42,914
Reaction score
15,006
First Language
English
Primarily Uses
RMMV
5 tiles. This is what was originally in those methods:

Code:
class Game_Event < Game_Character
  def near_the_screen?(dx = 12, dy = 8)
    ax = $game_map.adjust_x(@real_x) - Graphics.width / 2 / 32
    ay = $game_map.adjust_y(@real_y) - Graphics.height / 2 / 32
    ax >= -dx && ax <= dx && ay >= -dy && ay <= dy
  end

  def near_the_player?
    sx = distance_x_from($game_player.x).abs
    sy = distance_y_from($game_player.y).abs
    sx + sy < 20
  end
end

You could try just increasing them by 3 instead of 5 (because they already allowed 2), so change dx to 15, dy to 11, and sx + sy < 20 to 23.
 

MushroomCake28

KAMO Studio
Global Mod
Joined
Nov 18, 2015
Messages
3,934
Reaction score
4,847
First Language
EN, FR
Primarily Uses
RMMZ

I've moved this thread to RGSS3 Script Requests. Thank you.

 

Llov11

Villager
Member
Joined
Jul 22, 2018
Messages
16
Reaction score
1
First Language
Spanish
Primarily Uses
RMVXA
5 tiles. This is what was originally in those methods:

Code:
class Game_Event < Game_Character
  def near_the_screen?(dx = 12, dy = 8)
    ax = $game_map.adjust_x(@real_x) - Graphics.width / 2 / 32
    ay = $game_map.adjust_y(@real_y) - Graphics.height / 2 / 32
    ax >= -dx && ax <= dx && ay >= -dy && ay <= dy
  end

  def near_the_player?
    sx = distance_x_from($game_player.x).abs
    sy = distance_y_from($game_player.y).abs
    sx + sy < 20
  end
end

You could try just increasing them by 3 instead of 5 (because they already allowed 2), so change dx to 15, dy to 11, and sx + sy < 20 to 23.
Oh I see, thank you so much Shaz! that's exactly what I was looking for! Have a great day!
 

Latest Threads

Latest Posts

Latest Profile Posts

Feeling overwhelmed by this project's scope lately, and lured by other projects; but it also feels like I'm on the verge of a turning point, almost finished laying the "foundations" and can soon start building the real structure. In other words, the dreaded "middle phase lull." I recognize and will resist it. So, the latest work: battle sprite for the second major party member.

If you REALLY want to slow a loop down... stick a console.log statement in it. lol
welp... YED_Sideview Battler works on MZ with FOSSIL, and it even works with the new MZ Battle Core. problem is I dunno if the new battle core allows for custom motions with YED like the MV one does.
My first game is gonna be a really ambitious one. But it's costing me a lot of money to make lol. it'll be worth it though
Ugh...Guests always put the Ketchup in the fridge....bloody savages the lot of them! :)

Forum statistics

Threads
113,962
Messages
1,078,676
Members
148,067
Latest member
Momonica
Top