Vendily

Big push events

Jul 26th, 2020 (edited)
1,713
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #===============================================================================
  2. # Big Push Events - By Vendily [v17]
  3. #===============================================================================
  4. # This script allows you to tether multiple events together to move as one.
  5. # Think strength rocks from gen 5, that size. Or bigger, or wide and thin rocks.
  6. #===============================================================================
  7. # Each event in the unit must contain the same script call:
  8. #   pbPushManyEvents(width,height,[array of all the tethered event ids])
  9. # Mind, if you're using tiles from the Tileset and Player Touch, the tiles can't
  10. #  have Passage (4 dir) set. It's all or nothing for Player Touch
  11. # Also includes pbPushBigBoulder, used the same way, that requires Strength.
  12. #===============================================================================
  13. module InterpreterFieldMixin
  14.   def pbPushManyEvents(w,h,event_ids)
  15.     events=[]
  16.     for e in event_ids
  17.       events.push(get_character(e))
  18.     end
  19.     d=w
  20.     case $game_player.direction
  21.     when 2
  22.       d=w
  23.       events.sort!{|a,b|
  24.         next -(a.y<=>b.y) if a.y != b.y
  25.         next (a.x<=>b.x)
  26.       }
  27.     when 4
  28.       d=h
  29.       events.sort!{|a,b|
  30.         next (a.x<=>b.x) if a.x != b.x
  31.         next (a.y<=>b.y)
  32.       }
  33.     when 6
  34.       d=h
  35.       events.sort!{|a,b|
  36.         next -(a.x<=>b.x) if a.x != b.x
  37.         next (a.y<=>b.y)
  38.       }
  39.     when 8
  40.       d=w
  41.       events.sort!{|a,b|
  42.         next (a.y<=>b.y) if a.y != b.y
  43.         next (a.x<=>b.x)
  44.       }
  45.     end
  46.     pass=[]
  47.     d.times do |i|
  48.       ep=events[i].passableStrict?(events[i].x,events[i].y,$game_player.direction)
  49.       pass.push(ep)
  50.     end
  51.     return if pass.any?{|p| p==false}
  52.     oldx=events[0].x
  53.     oldy=events[0].y
  54.     for e in events
  55.       e.through=true
  56.       case $game_player.direction
  57.       when 2; e.move_down  # down
  58.       when 4; e.move_left  # left
  59.       when 6; e.move_right # right
  60.       when 8; e.move_up    # up
  61.       end
  62.       e.through=false
  63.     end
  64.     $PokemonMap.addMovedEvent(@event_id) if $PokemonMap
  65.     if oldx!=events[0].x || oldy!=events[0].y
  66.       $game_player.lock
  67.       begin
  68.         Graphics.update
  69.         Input.update
  70.         pbUpdateSceneMap
  71.       end until !events[0].moving?
  72.       $game_player.unlock
  73.     end
  74.   end
  75.  
  76.   def pbPushBigBoulder(w,h,event_ids)
  77.     pbPushManyEvents(w,h,event_ids) if $PokemonMap.strengthUsed
  78.     return true
  79.   end
  80. end
RAW Paste Data