Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ##### This is the problematic part of my script. I left out the vast majority of
- ##### my script because this is the only part causing problems.
- class Game_Map # didn't alias because I couldn't seem to get the alias to work
- # properly.
- def update(main = false)
- refresh if @need_refresh
- update_interpreter if main
- update_scroll
- update_events
- update_vehicles
- update_parallax
- @screen.update
- if $weather != nil && $weather.raining == true # if weather object exists and
- $weather.precipAnim # it is currently raining
- end
- end
- def any_direction_passable?(x, y, directions = 0b1111) # by Another Fen to
- # easier check for tile passability
- tile = all_tiles(x, y).find { |tile_id| tileset.flags[tile_id] & 0x10 == 0 }
- return (tile != nil and (directions & ~tileset.flags[tile]) != 0)
- end
- end
- # code to allow spawning an event from the event spawn map
- def spawn_event(spawn_from_map_id, _map_id, _event_id, _x, _y)
- map = load_data(sprintf("Data/Map%03d.rvdata2", spawn_from_map_id))
- event_id = $game_map.events.keys.max + 1
- preprocess = map.events[_event_id]
- preprocess.id = event_id
- event = $game_map.events[event_id] = Game_Event.new(_map_id, preprocess)
- sp_map = SceneManager.scene.instance_eval('@spriteset')
- sp_map_char_sprs = sp_map.instance_eval('@character_sprites')
- sp_map_view_1 = sp_map.instance_eval('@viewport1')
- sp_map_char_sprs.push(Sprite_Character.new(sp_map_view_1, event))
- event.moveto(_x, _y)
- end
- # begin of partial problematic code
- class DrykulWeatherSystem
- attr_accessor :raining
- attr_accessor :firstSplashId
- attr_accessor :splashEventIds
- def initialize
- @raining = false # check for current weather type
- @haltAnim = false # pause to allow events to delete themselves
- @firstSplashId = 0 # the very first splash event to spawn in's event ID
- @splashCounter = 0 # var. init so all events don't spawn at the same time
- @splashEventIds = [] # array init, contains all existing splash event IDs
- end
- def precipAnim
- if @haltAnim == false
- if @firstSplashId != 0
- tooManyEvents = @firstSplashId + 14
- check = @splashEventIds.size - 1
- if @splashEventIds[check] > tooManyEvents
- @haltAnim = true
- return
- end
- end
- if @splashCounter == 5
- xVariance = rand(8)
- yVariance = rand(6)
- dirVarianceCalc = rand(2)
- if dirVarianceCalc == 1
- dirVariance = 1
- else
- dirVariance = -1
- end
- splashXpos = $game_player.x + (xVariance * dirVariance)
- splashYpos = $game_player.y + (yVariance * dirVariance)
- if $game_map.any_direction_passable?(splashXpos, splashYpos) == true
- spawn_event(2, 1, 1, splashXpos, splashYpos)
- @splashCounter = 0
- end
- else
- @splashCounter += 1
- end
- else
- if @splashEventIds.size == 0
- @firstSplashId = 0
- @splashCounter = 0
- @haltAnim = false
- end
- end
- end
- end
- ##### This next bit of code is in the splash event template set to parallel process. The event is on a different map that is
- ##### reserved for template events that will be spawned in.
- if $weather.firstSplashId == 0
- $weather.firstSplashId = @event_id
- end
- $weather.splashEventIds[$weather.splashEventIds.size] = @event_id
- # Next is an event command Wait for 25 frames. After words this code snippet:
- $weather.splashEventIds.delete(@event_id)
- e = $game_map.events.delete(@event_id)
- e.erase unless e.nil?
RAW Paste Data