Event drawing/processing distance

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
30,033
Reaction score
7,029
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

Veteran
Veteran
Joined
Mar 2, 2012
Messages
39,144
Reaction score
12,416
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

Veteran
Veteran
Joined
Mar 2, 2012
Messages
39,144
Reaction score
12,416
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
2,947
Reaction score
3,964
First Language
English
Primarily Uses
RMMV

I've moved this thread to RGSS3 Script Requests. Please be sure to post your threads in the correct forum next time. 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!
 

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

Latest Threads

Latest Posts

Latest Profile Posts

In the strangest turn of events, my animations now live in the characters folder, and my character images now live in the pictures folder. It's a complicated world, but weirdly a more resource efficient one. :LZSexcite:
Did you know that we use robotic spy animals to learn about how different species behave in the wild? We're only a step away from robotic spy humans, and then Terminator. :p
Not being able to do a commission/request after all and having to give back the money is so heartbreaking.

Sometimes I'm just way too eager to help people out and suddenly find myself in a very deep hole because I'm not gonna be able to finish it. I really hope I don't come across as unprofessional to these people and in general. =n="
Learning Action Sequences!

Forum statistics

Threads
98,048
Messages
948,858
Members
129,315
Latest member
thefiendbruh
Top