Advertisement
Vlue

Simple Mounts

Dec 27th, 2014
525
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 3.42 KB | None | 0 0
  1. # Simple Mounts v1.0
  2. #----------#
  3. #Features: Magically mount and dismount a mount! (Nothing to do with vehicles,
  4. #           can you even do this with vehicles? I don't know. I didn't bother
  5. #           to look it up. But hey, you can set areas mounts can walk and can
  6. #           not walk. You try and do that with vehicles. Yah.. and a SE. So..)
  7. #
  8. #Usage:    Press the button, mount mount, Success.
  9. #
  10. #          Notetags (Actor):
  11. #           <Mount ["graphic_name",index]> - defines mount graphic for character
  12. #            I.e.: <Mount ["Riding",0]>
  13. #          Notetags (Map):
  14. #           <No mount> - no mounting on this map
  15. #
  16. #
  17. #~ #----------#
  18. #-- Script by: V.M of D.T
  19. #
  20. #- Questions or comments can be:
  21. #    given by email: sumptuaryspade@live.ca
  22. #    provided on facebook: http://www.facebook.com/DaimoniousTailsGames
  23. #   All my other scripts and projects can be found here: http://daimonioustails.weebly.com/
  24. #
  25. #--- Free to use in any project, commercial or non-commercial, with credit given
  26. # - - Though a donation's always a nice way to say thank you~ (I also accept actual thank you's)
  27.  
  28. #Mount press button! From :A-:Z and all like 4 buttons in between. (See INPUT helpfile)
  29. MOUNT_BUTTON = :Z
  30. #The speed of the mounted mount (default player speed is 4)
  31. MOUNTED_MOVE_SPEED = 5
  32. #List of regions that the mount is able to walk on! (Ignores passability)
  33. MOUNT_ZONE_PASSABLE = [2]
  34. #List of regions that the mount is unable to walk on!
  35. MOUNT_ZONE_UNPASSABLE = [3]
  36. #Switch to activate ability to mount (0 for no use)
  37. MOUNT_UNLOCK_SWITCH = 0
  38. #Sound effect to be played when mounting (or dismounting)
  39. MOUNT_SE = "Horse"
  40.  
  41. class Game_Player
  42.   attr_accessor :mounted
  43.   alias mount_init initialize
  44.   alias mount_pt perform_transfer
  45.   def initialize(*args)
  46.     mount_init(*args)
  47.     @mounted = false
  48.     @old_speed = 0
  49.   end
  50.   def mount
  51.     array = actor.actor.mounted_graphic
  52.     if array
  53.       actor.set_graphic(array[0],array[1],actor.face_name,actor.face_index)
  54.       refresh
  55.     end
  56.     @old_speed = @move_speed
  57.     @move_speed = MOUNTED_MOVE_SPEED
  58.     @mounted = true
  59.     Audio.se_play("Audio/SE/" + MOUNT_SE,100,100)
  60.   end
  61.   def dismount
  62.     pactor = $data_actors[actor.actor_id]
  63.     actor.set_graphic(pactor.character_name,pactor.character_index,actor.face_name,actor.face_index)
  64.     refresh
  65.     @move_speed = @old_speed
  66.     @mounted = false
  67.     Audio.se_play("Audio/SE/" + MOUNT_SE,100,100)
  68.   end
  69.   def map_passable?(x,y,d)
  70.     if @mounted
  71.       return true if MOUNT_ZONE_PASSABLE.include?($game_map.region_id(x,y))
  72.       return false if MOUNT_ZONE_UNPASSABLE.include?($game_map.region_id(x,y))
  73.     end
  74.     $game_map.passable?(x,y,d)
  75.   end
  76.   def perform_transfer
  77.     mount_pt
  78.     dismount if !$game_map.allow_mounts
  79.   end
  80. end
  81.  
  82. class Scene_Map
  83.   alias mount_update update
  84.   def update(*args)
  85.     mount_update(*args)
  86.     if Input.trigger?(MOUNT_BUTTON)
  87.       if MOUNT_UNLOCK_SWITCH > 0
  88.         return unless $game_switches[MOUNT_UNLOCK_SWITCH]
  89.       end
  90.       return unless $game_map.allow_mounts
  91.       $game_player.mounted ? $game_player.dismount : $game_player.mount
  92.     end
  93.   end
  94. end
  95.  
  96. class RPG::Actor
  97.   def mounted_graphic
  98.     self.note =~ /<Mount (.+)>/
  99.     if $1
  100.       array = eval($1)
  101.       return array
  102.     end
  103.     return false
  104.   end
  105. end
  106.  
  107. class Game_Actor
  108.   attr_reader :actor_id
  109. end
  110.  
  111. class Game_Map
  112.   def allow_mounts
  113.     @map.note =~ /<No mount>/ ? false : true
  114.   end
  115. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement