nathmatt

MCES Version: 1.74

May 22nd, 2011
2,043
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  2. # Mouse Controller Enhancement Script by Nathmatt
  3. # Version: 1.74
  4. # Type: Add On
  5. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  6. #  
  7. #  This work is protected by the following license:
  8. # #----------------------------------------------------------------------------
  9. # #  
  10. # #  Creative Commons - Attribution-NonCommercial-ShareAlike 3.0 Unported
  11. # #  ( http://creativecommons.org/licenses/by-nc-sa/3.0/ )
  12. # #  
  13. # #  You are free:
  14. # #  
  15. # #  to Share - to copy, distribute and transmit the work
  16. # #  to Remix - to adapt the work
  17. # #  
  18. # #  Under the following conditions:
  19. # #  
  20. # #  Attribution. You must attribute the work in the manner specified by the
  21. # #  author or licensor (but not in any way that suggests that they endorse you
  22. # #  or your use of the work).
  23. # #  
  24. # #  Noncommercial. You may not use this work for commercial purposes.
  25. # #  
  26. # #  Share alike. If you alter, transform, or build upon this work, you may
  27. # #  distribute the resulting work only under the same or similar license to
  28. # #  this one.
  29. # #  
  30. # #  - For any reuse or distribution, you must make clear to others the license
  31. # #    terms of this work. The best way to do this is with a link to this web
  32. # #    page.
  33. # #  
  34. # #  - Any of the above conditions can be waived if you get permission from the
  35. # #    copyright holder.
  36. # #  
  37. # #  - Nothing in this license impairs or restricts the author's moral rights.
  38. # #  
  39. # #----------------------------------------------------------------------------
  40. #
  41. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  42. # Instructions:
  43. #
  44. #  To use the event effects in this script you will need to name the following.
  45. #
  46. #  definitions
  47. #  d    = 2 down, 4 left 6, right, or 8 up
  48. #  right click to access an events command list
  49. #
  50. #  \ignore               Use on events you want to be walkable
  51. #
  52. #  \msg[message]         This will add the message above the highlighted event
  53. #
  54. #  \directionfix[d]      If an event has a graphic and needs a specific direction
  55. #                        they must be named this d as the open direction
  56. #
  57. #  \direction[d]         If an event has no graphic or isn't direction specific
  58. #                        they must be named this d as the open direction
  59. #
  60. #  \commands             This will create a command list for each page with the
  61. #                        name of the first avalible comment
  62. #
  63. #  \curser[graphic]      This will change the graphic of the curser while
  64. #                        over that event
  65. #
  66. #  \auto                 This will start the event as soon as you click it
  67. #
  68. #  \door[id]             This will run the pages of an event as the following
  69. #                        id is the item id needed to unlock the door
  70. #                        first   page when door is locked
  71. #                        second page when unlocking the door
  72. #                        third   page any time after being unlocked
  73. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  74. # Script Calls:
  75. #
  76. #  $MCES.disabled = true/false           whether or not this script is disabled
  77. #
  78. #  $MCES.movement_disabled = true/false  whether or not movement is disabled
  79. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  80. module MCES
  81.  
  82.   Version = 1.74
  83.   #============================================================================
  84.   # MCES::Config
  85.   #----------------------------------------------------------------------------
  86.   #  The configuration for $MCES
  87.   #============================================================================
  88.   module Config
  89.     No_Walk_Tag   = 7         # The terrain tag for unreachable locations
  90.     Text_Size     = 20        # The size of the event name text
  91.     Text_Color    = [0,0,160] # The color of the event name text
  92.     Click_Graphic = false     # The sprite placed for move target
  93.     Range         = 30        # The range for allows click movement    
  94.   end
  95.  
  96.   #============================================================================
  97.   # MCES::Cache
  98.   #----------------------------------------------------------------------------
  99.   # Stores data for use throughout $MCES
  100.   #============================================================================
  101.   module Cache
  102.     PathDirs = [[0, 1, 2], [-1, 0, 4], [1, 0, 6], [0, -1, 8]]
  103.     TDirs = [[0, true], [1, true], [2, true], [3, true], [4, true], [5, true],
  104.         [6, true], [7, true], [8, true], [9, true]]
  105.     DirOffsets = [[0, 0], [-1, 1], [0, 1], [1, 1], [-1, 0], [0, 0], [1, 0],
  106.                   [-1, -1], [0, -1], [1, -1]]
  107.     Direction = 0
  108.     Commands = 1
  109.     Curser = 2
  110.     Auto = 3
  111.     Door = 4
  112.     Msg = 5
  113.     Ignore = 6
  114.   end
  115.  
  116.   #============================================================================
  117.   # MCES::Processor
  118.   #----------------------------------------------------------------------------
  119.   #  This class performs the $MCES's processing.
  120.   #============================================================================
  121.   class Processor
  122.    
  123.     attr_accessor :item,:curser_lock,:disabled,:movement_disabled,:location
  124.     attr_reader   :event_start
  125.    
  126.     def initialize
  127.       @disabled,@movement_disabled,@location = false,false,[]
  128.       @lwait,@rwait,curser_lock,@carry_sprite = 0,0,false,Sprite.new
  129.       @carry_sprite.z = 999999;@carry_sprite.bitmap = Bitmap.new(24, 24)
  130.       @mouse_set = true
  131.     end
  132.    
  133.     def update
  134.       if @lwait > 0;@lwait-= 1;end
  135.       if @rwait > 0;@rwait-= 1;end
  136.       @item = $data_items[@item] if @item.is_a?(Numeric)
  137.       return if @disabled
  138.       if !$scene.is_a?(Scene_Map);@lwait = 5;return;end
  139.       if Input.trigger?(Input::Key['Mouse Left']) &&
  140.           !$game_temp.message_window_showing && @lwait == 0
  141.         @lwait = 5
  142.         check_left
  143.       elsif Input.trigger?(Input::Key['Mouse Right']) && @rwait == 0
  144.         @rwait = 5
  145.         check_right
  146.       end
  147.       check_player
  148.       check_carry
  149.       check_mouse
  150.       if @command_window != nil && !@command_window.disposed?
  151.         @command_window.update
  152.       end
  153.     end
  154.    
  155.     def check_left
  156.       x,y = mouse_tile
  157.       return if check_event || !$game_map.passable?(x,y,0) || @movement_disabled ||
  158.         check_terrain_tag(x,y) || check_range(x,y,MCES::Config::Range)
  159.       return if @command_window != nil && !@command_window.disposed?
  160.       $game_player.set(x,y)
  161.     end
  162.    
  163.     def check_event
  164.       $game_map.events.each_value{|event|
  165.       next if event.erased
  166.       if event.mouse_in_area?
  167.         if event.type.include?(MCES::Cache::Ignore)
  168.           return false
  169.         end
  170.         if event.type.include?(MCES::Cache::Auto)
  171.           event.start_event
  172.           return true
  173.         elsif event.type.include?(MCES::Cache::Door)
  174.           event.check_door
  175.           return true
  176.         else
  177.           $game_player.set(event) if !@movement_disabled
  178.           return true
  179.         end
  180.       end}
  181.       return false
  182.     end
  183.      
  184.    
  185.     def check_right
  186.       $game_map.events.each_value{|event|
  187.       next if event.erased
  188.       if event.mouse_in_area?
  189.         if event.type.include?(MCES::Cache::Commands)
  190.           return if @command_window != nil && !@command_window.disposed?
  191.           @command_window = Event_Command.new(event)
  192.           return
  193.         end
  194.       end}
  195.     end
  196.    
  197.     def mouse_tile
  198.       x,y = $mouse.x,$mouse.y
  199.       return (x+$game_map.display_x/4)/32,(y+$game_map.display_y/4)/32
  200.     end
  201.      
  202.      
  203.     def check_terrain_tag(x,y)
  204.       return ($game_map.terrain_tag(x,y) == Config::No_Walk_Tag)
  205.     end
  206.    
  207.     def check_target(x,y=0)
  208.       if x.is_a?(Game_Character)
  209.         c = x
  210.         d = (x.direction_fixed != nil ? x.direction_fixed : x.direction)
  211.         x,y = c.x,c.y
  212.         x += (d == 4 ? -1 : 1) if d != (2 || 8)
  213.         y += (d == 8 ? -1 : 1) if d != (4 || 6)
  214.       end
  215.       return x,y
  216.     end
  217.    
  218.     def check_player
  219.       return if @request == nil
  220.       count = 4
  221.       characters = [$game_player]
  222.       while characters.size > 0 && count > 0
  223.         char = characters.shift
  224.         result = find_path
  225.         result != nil ? char.force_movement = result : characters.push(char)
  226.         count -= 1
  227.       end
  228.     end
  229.    
  230.     def check_carry
  231.       @carry_sprite.x,@carry_sprite.y = $mouse.x,$mouse.y
  232.       if @item != nil
  233.         if @carry_curser != @item.icon_name
  234.           @carry_curser = @item.icon_name
  235.           @carry_sprite.bitmap.blt(0, 0, RPG::Cache.icon(@carry_curser),
  236.             Rect.new(0, 0, 24, 24))
  237.         end
  238.       else
  239.         @carry_curser = nil
  240.         @carry_sprite.bitmap.clear
  241.       end
  242.     end
  243.    
  244.     def check_mouse
  245.       $game_map.events.each_value{|event|
  246.       if event.mouse_in_area?
  247.         next if event.erased
  248.         if event.type.include?(MCES::Cache::Curser)
  249.           $mouse.set_cursor(event.curser)
  250.           @mouse_set = false
  251.           return
  252.         end
  253.       end}
  254.       if !@mouse_set
  255.         return if @curser_lock
  256.         @mouse_set = true
  257.         $mouse.set_cursor(Mouse::MOUSE_ICON)
  258.       end
  259.     end
  260.    
  261.     def request_path(x, y = nil)
  262.       x,y = check_target(x,y)
  263.       if x != nil && y != nil && @request == nil
  264.         @request = PathRequesting.new(x, y)
  265.       end
  266.     end
  267.    
  268.     def distance(x,y,tx,ty)
  269.       return Math.hypot((x - tx),(y - ty))
  270.     end
  271.    
  272.     def check_range(x,y,range)
  273.       pl = $game_player
  274.       return (range <= distance(pl.x,pl.y,x,y))
  275.     end
  276.  
  277.     def find_path
  278.       request = @request
  279.       if request.open.size == 0;@request = nil;return []end
  280.       found = false
  281.       key = request.open.keys.min {|a, b|
  282.           Math.hypot(a[0] - request.tx, a[1] - request.ty) <=>
  283.           Math.hypot(b[0] - request.tx, b[1] - request.ty)}
  284.       request.closed[key[0], key[1]] = request.open[key]
  285.       request.open.delete(key)
  286.       Cache::PathDirs.each {|dir|
  287.       kx, ky = key[0] + dir[0], key[1] + dir[1]
  288.       if kx == request.tx && ky == request.ty
  289.         request.closed[kx, ky] = dir[2]
  290.         found = true
  291.         break
  292.       elsif request.closed[kx, ky] == 0 &&
  293.         $game_player.passable?(key[0], key[1], dir[2])
  294.         request.open[[kx, ky]] = dir[2]
  295.       end}
  296.       return nil unless found
  297.       @request = nil
  298.       return request.backtrack
  299.     end
  300.    
  301.   end
  302.  
  303.   #============================================================================
  304.   # MCES::Msg_Sprite
  305.   #----------------------------------------------------------------------------
  306.   #  The msg sprite.
  307.   #============================================================================
  308.   class Msg_Sprite < Sprite
  309.  
  310.     def initialize(event)
  311.       super()
  312.       @event = event
  313.       self.z,self.opacity = 1000,0
  314.       self.set
  315.       @h = MCES::Config::Text_Size
  316.       @w = event.msg.size*@h
  317.       c = MCES::Config::Text_Color
  318.       self.bitmap = Bitmap.new(@w,@h)
  319.       self.bitmap.font.size = @h
  320.       self.bitmap.font.color = Color.new(c[0],c[1],c[2])
  321.       self.bitmap.draw_text(0,0,@w,@h,event.msg,1)
  322.     end
  323.  
  324.     def set
  325.       return if !$scene.is_a?(Scene_Map) || @event.erased
  326.       b = @event.get_sprite.inner_bitmap
  327.       xs = @event.get_sprite.x-(@event.get_sprite.cw/2)
  328.       ys = @event.get_sprite.y-@event.get_sprite.ch
  329.       self.x,self.y = xs + (b.width/2)-(@w/2),ys-@h
  330.     end
  331.  
  332.     def update
  333.       self.set
  334.       return self.opacity = 0 if @event.erased
  335.       if @event.mouse_in_area?
  336.         if self.opacity < 255
  337.           self.opacity += 25
  338.         end
  339.       elsif self.opacity > 0
  340.         self.opacity -= 25
  341.       end
  342.     end
  343.   end
  344.  
  345.   #============================================================================
  346.   # MCES::Set_Sprite
  347.   #----------------------------------------------------------------------------
  348.   #  The set sprite.
  349.   #============================================================================
  350.   class Set_Sprite < Sprite
  351.  
  352.     def initialize(v)
  353.       super
  354.       self.bitmap = RPG::Cache.picture(MCES::Config::Click_Graphic)
  355.       @x,@y,self.opacity,self.z = 0,0,0,1
  356.     end
  357.    
  358.     def set(x,y)
  359.       return if MCES::Config::Click_Graphic == false
  360.       @e,x,y = x,x.x,x.y if x.is_a?(Game_Character)
  361.       @x,@y,self.opacity = x,y,255
  362.     end
  363.    
  364.     def update_screen
  365.       return if self.opacity == 0
  366.       x = ((@x * 128) - $game_map.display_x + 3) / 4
  367.       y = ((@y * 128) - $game_map.display_y + 3) / 4
  368.       self.x,self.y = x,y
  369.     end
  370.  
  371.     def update
  372.       return if MCES::Config::Click_Graphic == false
  373.       update_screen
  374.     end
  375.    
  376.   end
  377.  
  378.   #============================================================================
  379.   # MCES::Event_Command
  380.   #----------------------------------------------------------------------------
  381.   #  The event command window.
  382.   #============================================================================  
  383.   class Event_Command < Window_Command
  384.  
  385.     def initialize(event)
  386.       @size = 0
  387.       @event = event
  388.       @main_commands = event.commands
  389.       @array = []
  390.       @main_commands.each{|command|
  391.       @array.push(command) if command != nil
  392.       @size = (command.size * 32) if (command.size * 32) > @size}
  393.       super(@size,@array)
  394.       self.x,self.y = $mouse.position
  395.     end
  396.  
  397.     def indexes
  398.       return @main_commands.index(@array[self.index])
  399.     end
  400.    
  401.     def update
  402.       super
  403.       if Input.trigger?(Input::Key['Mouse Left'])
  404.         if self.index >= 0
  405.           @event.start_command(indexes)
  406.           self.dispose
  407.         else
  408.           self.dispose
  409.         end
  410.       end
  411.     end
  412.    
  413.   end
  414.  
  415.   #============================================================================
  416.   # MCES::Pathrequest
  417.   #----------------------------------------------------------------------------
  418.   #  This class preforms the movement requests.
  419.   #============================================================================
  420.   class PathRequesting
  421.    
  422.     attr_reader :open,:closed,:sx,:sy,:tx,:ty,:jd
  423.    
  424.     def initialize(tx, ty, jd = 0)
  425.       pix = ($BlizzABS != nil ? BlizzABS::Config::PIXEL_MOVEMENT_RATE : 1)
  426.       ox,oy = $game_player.location
  427.       @sx, @sy, @tx, @ty, @jd = ox, oy, tx, ty, jd
  428.       @x_off, @y_off = ox - @sx, oy - @sy
  429.       @open = {[@sx, @sy] => -1}
  430.       @closed = Table.new($game_map.width, $game_map.height)
  431.     end
  432.    
  433.     def backtrack
  434.       cx, cy, x, y, result = @tx, @ty, 0, 0, []
  435.       loop do
  436.         cx, cy = cx - x, cy - y
  437.         break if cx == @sx && cy == @sy
  438.         result.unshift(Cache::TDirs[@closed[cx, cy]])
  439.         x, y = Cache::DirOffsets[@closed[cx, cy]]
  440.       end
  441.       return result
  442.     end
  443.    
  444.   end
  445.  
  446. end
  447.  
  448. raise('This script requires Mouse Controller by Blizzard to work') if $mouse == nil
  449. $MCES = MCES::Processor.new
  450.  
  451. #============================================================================
  452. # Game_Character
  453. #----------------------------------------------------------------------------
  454. #  Adds a mouse_in_area? method to any instance of this class.
  455. #============================================================================
  456. class Game_Character
  457.  
  458.   attr_reader   :type
  459.   attr_accessor :icon_name,:direction_fixed
  460.  
  461.   alias mces_character_initialize initialize
  462.   def initialize
  463.     @type = []
  464.     mces_character_initialize
  465.   end
  466.  
  467.   def mouse_in_area?
  468.     return false if get_sprite == nil || get_sprite.is_a?(Array)
  469.     return false if get_sprite.inner_bitmap == nil
  470.     return false if get_sprite.cw == nil || get_sprite.ch == nil
  471.     return true if [$mouse.x/32,$mouse.y/32] == [self.x,self.y]
  472.     b = get_sprite.inner_bitmap
  473.     xs = get_sprite.x-(get_sprite.cw/2)
  474.     ys = get_sprite.y-get_sprite.ch
  475.     return ($mouse.x >= xs && $mouse.x < xs + b.width &&
  476.         $mouse.y >= ys && $mouse.y < ys + b.height &&
  477.         b.get_pixel($mouse.x-xs, $mouse.y-ys) != Color.new(255,255,255,0))
  478.   end
  479.    
  480.  
  481.   def get_sprite
  482.     return if !$scene.is_a?(Scene_Map)
  483.     $scene.spriteset.character_sprites.each{|s|return s if s.character == self}
  484.   end
  485.  
  486. end
  487.  
  488. #============================================================================
  489. # Game_Event
  490. #----------------------------------------------------------------------------
  491. #  This class sets the events proccesing for MCES.
  492. #============================================================================
  493. class Game_Event < Game_Character
  494.  
  495.   attr_accessor :event_start
  496.   attr_reader   :key,:curser,:msg,:commands,:erased
  497.  
  498.   alias mces_initialize initialize
  499.   def initialize(id,event)
  500.     mces_initialize(id,event)
  501.     @child_interpeter = Interpreter.new
  502.     @event_start = false
  503.     @type,@commands, = [],[]
  504.     check_name
  505.   end
  506.  
  507.   alias mces_update update
  508.   def update
  509.     mces_update
  510.     @child_interpeter.update
  511.     @msg_sprite.update if @msg_sprite != nil
  512.   end
  513.  
  514.   alias mces_start start
  515.   def start
  516.     return if @trigger == 0 && (!@event_start || @commands.size > 0)
  517.     mces_start
  518.     @event_start = false
  519.   end
  520.  
  521.   def start_event
  522.     @event_start = true
  523.     start
  524.   end
  525.  
  526.   def check_door
  527.     if @key == $MCES.item
  528.       @child_interpeter.setup(@event.pages[1].list,@id)
  529.       $game_party.gain_item($MCES.item.id, -1)
  530.       $MCES.item = nil
  531.       @key_unlock = true
  532.     elsif @key_unlock
  533.       @child_interpeter.setup(@event.pages[2].list,@id)
  534.     else
  535.       @child_interpeter.setup(@event.pages[0].list,@id)
  536.     end
  537.     return
  538.   end
  539.  
  540.   def start_command(i)
  541.     @child_interpeter.setup(@event.pages[i].list,@id)
  542.   end
  543.  
  544.   def check_name
  545.     if @event.name.clone.gsub!(/\\[Ii]gnore/) {''}
  546.       @type.push(MCES::Cache::Ignore)
  547.     end
  548.     if @event.name.clone.gsub!(/\\[Aa]uto/) {''}
  549.       @type.push(MCES::Cache::Auto)
  550.     end
  551.     if @event.name.clone.gsub!(/\\[Cc]ommands/) {''}
  552.       @type.push(MCES::Cache::Commands)
  553.       @interpreter = Interpreter.new
  554.       @event.pages.each{|page|page.list.each{|list|
  555.       @last_list = list if @last_list == nil
  556.       if list.code == 108
  557.         if @last_list.code == 111
  558.           if @interpreter.command_111([@last_list,list])
  559.             @commands[@event.pages.index(page)] = list.parameters[0]
  560.           end
  561.         else
  562.           @commands[@event.pages.index(page)] = list.parameters[0]
  563.         end
  564.       end
  565.       @last_list = list}}
  566.       @interpreter = nil
  567.     end
  568.     if @event.name.clone.gsub!(/\\[Dd]irectionfix\[(\d+)\]/) {"#[$1]"}
  569.       @type.push(MCES::Cache::Direction)
  570.       @direction_fixed = $1.to_i
  571.     end
  572.     if @event.name.clone.gsub!(/\\[Dd]irection\[(\d+)\]/) {"#[$1]"}
  573.       @type.push(MCES::Cache::Direction)
  574.       @direction = $1.to_i
  575.     end
  576.     if @event.name.clone.gsub!(/\\[Ll]ocked\[(\d+)\]/) {"#[$1]"}
  577.       @type.push(MCES::Cache::Door)
  578.       @key = $data_items[$1.to_i]
  579.     end  
  580.     if @event.name.clone.gsub!(/\\[Cc]urser\[(.+?)\]/) {"#[$1]"}
  581.       @type.push(MCES::Cache::Curser)
  582.       @curser = $1
  583.     end
  584.     if @event.name.clone.gsub!(/\\[Mm]sg\[(.+?)\]/) {"#[$1]"}
  585.       @type.push(MCES::Cache::Msg)
  586.       @msg = $1
  587.       @msg_sprite = MCES::Msg_Sprite.new(self)
  588.     end
  589.   end
  590.    
  591. end
  592.  
  593. #============================================================================
  594. # Game_Player
  595. #----------------------------------------------------------------------------
  596. #  Adds force movement.
  597. #============================================================================
  598. class Game_Player
  599.  
  600.   attr_accessor :force_movement
  601.  
  602.   alias mces_update update
  603.   def update
  604.     mces_update
  605.     if @target_x == nil
  606.       @force_movement = []
  607.       $MCES.location = []
  608.     else
  609.       if @force_movement == []
  610.         $MCES.request_path(@target_x, @target_y)
  611.       end
  612.       update_forcemovement if !moving?
  613.       if location == $MCES.check_target(@target_x,@target_y)
  614.         if @target_x.is_a?(Game_Event)
  615.           @target_x.start_event
  616.           face_target
  617.         end
  618.         if $scene.spriteset.set_sprite != nil
  619.           $scene.spriteset.set_sprite.opacity = 0
  620.         end
  621.         @target_x = @target_y = nil
  622.         @force_movement = []
  623.         $MCES.location = []
  624.       end
  625.     end
  626.   end
  627.  
  628.   def face_target
  629.     sx = @x - @target_x.x
  630.     sy = @y - @target_x.y
  631.     return if sx == 0 and sy == 0
  632.     sx > 0 ? turn_left : turn_right if sx.abs > sy.abs
  633.     sy > 0 ? turn_up : turn_down if sx.abs < sy.abs
  634.   end
  635.  
  636.   def update_forcemovement
  637.     return if @force_movement.size == 0
  638.     move = @force_movement.shift
  639.     case move[0]
  640.     when 1 then move_lower_left
  641.     when 2 then move_down(move[1])
  642.     when 3 then move_lower_right
  643.     when 4 then move_left(move[1])
  644.     when 6 then move_right(move[1])
  645.     when 7 then move_upper_left
  646.     when 8 then move_up(move[1])
  647.     when 9 then move_upper_right
  648.     end
  649.   end
  650.  
  651.   def location
  652.     return self.x,self.y
  653.   end
  654.  
  655.   def click_jump(x,y)
  656.     new_x,new_y = x-self.y,x-self.y
  657.     jump(new_x,new_y)
  658.   end
  659.  
  660.   def set(x,y=nil)
  661.     @force_movement = []
  662.     @target_x, @target_y = x,y
  663.     $scene.spriteset.set_sprite.set(x,y) if MCES::Config::Click_Graphic != false
  664.   end
  665.  
  666. end
  667.  
  668. #============================================================================
  669. # Interpreter
  670. #----------------------------------------------------------------------------
  671. #  Allows external use of the condition command.
  672. #============================================================================
  673. class Interpreter
  674.  
  675.   alias mces_command_111 command_111
  676.   def command_111(list = nil)
  677.     if list != nil
  678.       @index = 0
  679.       @list = list
  680.       @list.push(RPG::EventCommand.new(412, list[0].indent, []))
  681.       @parameters = list[0].parameters
  682.     end
  683.     mces_command_111
  684.     if list != nil
  685.       return @branch[0] == nil
  686.     end
  687.   end
  688.  
  689. end
  690. #============================================================================
  691. # Input
  692. #----------------------------------------------------------------------------
  693. #  Adds the alias methods and updates the processor.
  694. #============================================================================
  695. module Input
  696.  
  697.   class << Input
  698.     alias mces_trigger? trigger?
  699.     alias mces_update update
  700.   end
  701.  
  702.   def self.update
  703.     $MCES.update
  704.     mces_update
  705.   end
  706.  
  707. end
  708. if ($tons_version || $BlizzABS  || $network) == nil
  709. #============================================================================
  710. # Input
  711. #----------------------------------------------------------------------------
  712. #  Adds the mouse trigger commands if not using Blizzards input methods.
  713. #============================================================================  
  714. module Input
  715.  
  716.   Key = {'Mouse Left' => 1, 'Mouse Right' => 2}
  717.   C = Key['Mouse Left']
  718.   #======================================
  719.   # |–>  Keyboard Input Module
  720.   #======================================
  721.   #   By: Near Fantastica
  722.   #   Date: 06.07.05
  723.   #   Version: 3  
  724.   #
  725.   #   Cut down by Zeriab
  726.   #   Date: 16.08.06
  727.   #======================================
  728.   def self.trigger?(key)
  729.     return false if key == nil
  730.     if !Win32API.new("user32","GetKeyState",['i'],'i').call(key).between?(0, 1)
  731.       return true
  732.     else
  733.       return mces_trigger?(key)
  734.     end
  735.   end
  736.  
  737. end
  738.  
  739. end
  740. #============================================================================
  741. # Sprite_Character
  742. #----------------------------------------------------------------------------
  743. #  Creats a inner bitmap for use with the mouse_in_area? method.
  744. #============================================================================
  745. class Sprite_Character
  746.   attr_reader :ch,:cw,:inner_bitmap
  747.  
  748.   alias mces_initialize initialize
  749.   def initialize(viewport,character = nil)
  750.     mces_initialize(viewport,character)
  751.   end
  752.  
  753.   alias mces_update update
  754.   def update
  755.     mces_update
  756.     if $BlizzABS != nil
  757.       return if @sprite == nil
  758.       return if @sprite.cw == nil || @sprite.ch == nil
  759.       @cw,@ch = @sprite.cw, @sprite.ch
  760.     end
  761.     if @character.icon_name != nil || @character.tile_id >= 384
  762.       @inner_bitmap = self.bitmap.clone
  763.       return
  764.     end
  765.     @inner_bitmap = Bitmap.new(@cw,@ch) if @inner_bitmap == nil
  766.     if @pattern != @character.pattern
  767.       @pattern = @character.pattern
  768.       bitmap = ($BlizzABS != nil ? @sprite.bitmap : self.bitmap)
  769.       src_rect = ($BlizzABS != nil ? @sprite.src_rect : self.src_rect)
  770.       @inner_bitmap.clear
  771.       @inner_bitmap.blt(0, 0, bitmap, src_rect)
  772.     end
  773.   end
  774.  
  775. end
  776. #============================================================================
  777. # Spriteset_Map
  778. #----------------------------------------------------------------------------
  779. #  Creats the set_sprite
  780. #============================================================================
  781. class Spriteset_Map
  782.   attr_reader :character_sprites,:set_sprite
  783.  
  784.   alias mces_initialize initialize
  785.   def initialize
  786.     mces_initialize
  787.     if MCES::Config::Click_Graphic != false
  788.       @set_sprite = MCES::Set_Sprite.new(@viewport1)
  789.     end
  790.   end
  791.  
  792.   alias mces_update update
  793.   def update
  794.     mces_update
  795.     @set_sprite.update if @set_sprite != nil
  796.   end
  797.  
  798. end
  799. #============================================================================
  800. #  Adds eternal reading of methods.
  801. #============================================================================
  802. class Sprite_Character_ABSEAL_ed;    attr_reader :ch,:cw end if $BlizzABS != nil
  803. class Scene_Map;        attr_reader :spriteset           end
  804. if $BlizzABS != nil
  805. class BlizzABS::Processor
  806.  
  807.   def pixel
  808.     return 1
  809.   end
  810.  
  811. end
  812. end
RAW Paste Data