1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
| #===================================
# ** GameBaker Anti-Event Lag
#===============================
# by sandgolem
# Concept based on Near Fantastica's original RMXP script
#
# Still a beta version, still the looping bug
#
# Version 3 [VX]
# February 22nd, 2008
#==========================================
module GameBaker
AntiLagDisable = 0
AntiLagModifierX = 408
AntiLagModifierWidth = 272
AntiLagModifierY = 272
AntiLagModifierHeight = 408
AntiLagAlwaysMove = '&'
end
#=========================================
#
# To check for updates or find more scripts, visit:
# http://www.gamebaker.com/rmvx/scripts/
# Our RMXP scripts: http://www.gamebaker.com/rmxp/scripts/
#
# This script is not exclusive to our site!
# Feel free to pass around as long as you leave the links here.
# A license is required for commercial use, see instructions below.
#
# Instructions: http://www.gamebaker.com/rmvx/scripts/e/anti-event-lag.php
# Discussion/Help: http://forums.gamebaker.com/showthread.php?t=1242
#
#==============================
class Game_CommonEvent
alias gamebaker_antilag_commonrefresh refresh
def refresh
gamebaker_antilag_commonrefresh
gamebaker_antilag_add if @interpreter
gamebaker_antilag_remove if !@interpreter
end
def gamebaker_antilag_remove
return if !$game_map.gb_antilagcommons.include?(@common_event_id)
$game_map.gb_antilagcommons -= [@common_event_id]
end
def gamebaker_antilag_add
return if $game_map.gb_antilagcommons.include?(@common_event_id)
$game_map.gb_antilagcommons += [@common_event_id]
end
end
class Game_Event
def force_move_route(move_route)
super(move_route)
if $game_map.gb_antilagnonmove.include?(@id)
$game_map.gb_antilagnonmove -= [@id]
$game_map.gb_antilagmoveevents += [@id]
end
end
alias gamebaker_antilag_init initialize
def initialize(map_id, event)
gamebaker_antilag_init(map_id, event)
if event.name.include?(GameBaker::AntiLagAlwaysMove)
$game_map.gb_antilagmove += [@id]
end
end
alias gamebaker_antilag_evsetup setup
def setup(new_page)
gamebaker_antilag_evsetup(new_page)
if @trigger == 3 or @trigger == 4
start if @trigger == 3
if !$game_map.gb_antilagprocess.include?(@id)
$game_map.gb_antilagprocess += [@id]
end
elsif $game_map.gb_antilagprocess.include?(@id)
$game_map.gb_antilagprocess -= [@id]
end
if @character_name == "" && @tile_id == 0
if !$game_map.gb_antilagnosprite.include?(@id)
$game_map.gb_antilagnosprite += [@id]
end
elsif $game_map.gb_antilagnosprite.include?(@id)
$game_map.gb_antilagnosprite -= [@id]
end
if @move_type == 0 && !@step_anime &&
!$game_map.gb_antilagnonmove.include?(@id)
$game_map.gb_antilagnonmove += [@id]
elsif $game_map.gb_antilagnonmove.include?(@id)
$game_map.gb_antilagnonmove -= [@id]
end
end
def gamebaker_antilag_interupdate
if @interpreter != nil
unless @interpreter.running?
@interpreter.setup(@list, @event.id)
end
@interpreter.update
end
end
def update
super
end
end
class Game_Map
attr_accessor :gb_antilagcommons, :gb_antilagnonmove, :gb_antilagnosprite,
:gb_antilagmoveevents, :gb_antilagmove, :gb_antilagprocess,
:gb_antilagspriteevents, :gb_antilag_spriteupdate
def gamebaker_antilag?(sg)
return false if sg.real_x < @gb_antilagscreen_x or
sg.real_x > @gb_antilagscreen_width or
sg.real_y < @gb_antilagscreen_y or
sg.real_y > @gb_antilagscreen_height
return true
end
alias gamebaker_antilag_setupev setup_events
def setup_events
gamebaker_antilag_getscreen
@gb_antilagnonmove = []
@gb_antilagmove = []
@gb_antilagnosprite = []
@gb_antilagprocess = []
@gb_antilagcommons = [] if !@gb_antilagcommons
gamebaker_antilag_setupev
gamebaker_antilag_refresh_events
end
def gamebaker_antilag_getscreen
@gb_antilagscreen_x = @display_x - GameBaker::AntiLagModifierX
@gb_antilagscreen_y = @display_y - GameBaker::AntiLagModifierY
@gb_antilagscreen_width =
@display_x + (Graphics.width * 8) + GameBaker::AntiLagModifierWidth
@gb_antilagscreen_height =
@display_y + (Graphics.height * 8) + GameBaker::AntiLagModifierHeight
end
def gamebaker_antilag_refresh_events
@gb_antilagalwaysmove = []
@gb_antilagmoveevents = []
@gb_antilagspriteevents = []
for i in @events.values
next if @gb_antilagnosprite.include?(i)
@gb_antilagspriteevents += [i]
end
@gb_antilagspriteevents += [$game_player]
for vehicle in $game_map.vehicles
next if vehicle.map_id != @map_id
@gb_antilagspriteevents += [vehicle]
end
for i in 0...@gb_antilagmove.size
@gb_antilagalwaysmove += [@events[@gb_antilagmove[i]].id]
end
for i in @events.values
next if @gb_antilagnonmove.include?(i.id)
next if @gb_antilagmove.include?(i.id)
@gb_antilagmoveevents += [i.id]
end
@gb_antilag_spriteupdate = true
end
alias gamebaker_antilag_ue update_events
def update_events
return gamebaker_antilag_ue if $game_switches[GameBaker::AntiLagDisable]
gamebaker_antilag_getscreen
for i in 0...@gb_antilagprocess.size
@events[@gb_antilagprocess[i]].gamebaker_antilag_interupdate
end
for i in 0...@gb_antilagalwaysmove.size
@events[@gb_antilagalwaysmove[i]].update
end
for i in 0...@gb_antilagmoveevents.size
j = @gb_antilagmoveevents[i]
@events[j].update if gamebaker_antilag?(@events[j])
end
for i in 0...@gb_antilagcommons.size
@common_events[@gb_antilagcommons[i]].update
end
end
alias gamebaker_antilag_maprefresh refresh
def refresh
gamebaker_antilag_maprefresh
gamebaker_antilag_refresh_events
end
end
class Game_Vehicle; attr_accessor :map_id; end
class Spriteset_Map
def gamebaker_antilag_characters
@gb_antilag_eventsprites = []
for sprite in @character_sprites
next if !$game_map.gb_antilagspriteevents.include?(sprite.character)
@gb_antilag_eventsprites += [sprite]
end
$game_map.gb_antilag_spriteupdate = nil
end
alias gamebaker_antilag_uc update_characters
def update_characters
return gamebaker_antilag_uc if $game_switches[GameBaker::AntiLagDisable]
gamebaker_antilag_characters if $game_map.gb_antilag_spriteupdate
for sprite in @gb_antilag_eventsprites
sprite.update if $game_map.gamebaker_antilag?(sprite.character)
end
end
end
#========================
# End of file! You can find more of our scripts at http://www.gamebaker.com |