Advertisement
nathmatt

Move Route Conditions Version: 1.0

May 22nd, 2011
488
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 3.19 KB | None | 0 0
  1. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  2. # Move Route Conditions by Nathmatt
  3. # Version: 1.0
  4. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  5. #  
  6. #  This work is protected by the following license:
  7. # #----------------------------------------------------------------------------
  8. # #  
  9. # #  Creative Commons - Attribution-NonCommercial-ShareAlike 3.0 Unported
  10. # #  ( http://creativecommons.org/licenses/by-nc-sa/3.0/ )
  11. # #  
  12. # #  You are free:
  13. # #  
  14. # #  to Share - to copy, distribute and transmit the work
  15. # #  to Remix - to adapt the work
  16. # #  
  17. # #  Under the following conditions:
  18. # #  
  19. # #  Attribution. You must attribute the work in the manner specified by the
  20. # #  author or licensor (but not in any way that suggests that they endorse you
  21. # #  or your use of the work).
  22. # #  
  23. # #  Noncommercial. You may not use this work for commercial purposes.
  24. # #  
  25. # #  Share alike. If you alter, transform, or build upon this work, you may
  26. # #  distribute the resulting work only under the same or similar license to
  27. # #  this one.
  28. # #  
  29. # #  - For any reuse or distribution, you must make clear to others the license
  30. # #    terms of this work. The best way to do this is with a link to this web
  31. # #    page.
  32. # #  
  33. # #  - Any of the above conditions can be waived if you get permission from the
  34. # #    copyright holder.
  35. # #  
  36. # #  - Nothing in this license impairs or restricts the author's moral rights.
  37. # #  
  38. # #----------------------------------------------------------------------------
  39. #
  40. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  41. # Instructions:
  42. #   Use the script calls in the move route script calls
  43. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  44. # Script Calls:
  45. #   condition_skip(con)       Con is the condition for the condition branch
  46. #   #end                      is to end the condition branch dont forget the (#)
  47. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  48. # Conditions:
  49. #   distance_from_target(target) Target is ($game_player) of $game_map.events[id]
  50. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  51. class Game_Character
  52.   #--------------------------------------------------------------------------
  53.   # distance_from_target(target)
  54.   #--------------------------------------------------------------------------
  55.   def distance_from_target(target)
  56.     return Math.hypot((@x - target.x),(@y - target.y))
  57.   end
  58.   #--------------------------------------------------------------------------
  59.   # * Condition Skip
  60.   #--------------------------------------------------------------------------
  61.   def condition_skip(con)
  62.     @move_route_index += find_condition_end if !con
  63.   end
  64.   #--------------------------------------------------------------------------
  65.   # * Find Condition End
  66.   #--------------------------------------------------------------------------
  67.   def find_condition_end
  68.     (@move_route_index+1..@move_route.list.size).each{|move|
  69.     if @move_route.list[move].code == 45 &&
  70.           @move_route.list[move].parameters[0] == '#end'
  71.       return move
  72.     end}
  73.   end
  74.  
  75. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement