Advertisement
Archeia

RGSS3 Patrol

Oct 5th, 2017
502
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 1.25 KB | None | 0 0
  1. #This is a private script that emulates Rm2k3 Horizontal and Vertical movement.
  2.  
  3. class Game_Event < Game_Character
  4.  
  5.   def note
  6.     begin
  7.       data = []
  8.       @page.list.each do |item|
  9.         next unless item && (item.code == 108 || item.code == 408)
  10.         data.push(item.parameters[0])
  11.       end
  12.       return data
  13.     rescue
  14.       return []
  15.     end
  16.   end
  17.  
  18.   def patrol_hor?; note.include?("<patrol hor>"); end
  19.   def patrol_ver?; note.include?("<patrol ver>"); end  
  20.    
  21.   alias yami_patrol_event_update_self_movement update_self_movement
  22.   def update_self_movement
  23.     yami_patrol_event_update_self_movement
  24.     if @stop_count > stop_count_threshold
  25.       if patrol_hor?
  26.         set_direction([6,4].sample) unless [6,4].include?(@direction)
  27.         set_direction(4) if @direction == 6 && !passable?(@x, @y, 6)
  28.         set_direction(6) if @direction == 4 && !passable?(@x, @y, 4)
  29.         move_forward
  30.         return
  31.       end
  32.       #---
  33.       if patrol_ver?
  34.         set_direction([8,2].sample) unless [8,2].include?(@direction)
  35.         set_direction(2) if @direction == 8 && !passable?(@x, @y, 8)
  36.         set_direction(8) if @direction == 2 && !passable?(@x, @y, 2)
  37.         move_forward
  38.         return
  39.       end
  40.     end
  41.   end
  42.    
  43. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement