设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 3577|回复: 9
打印 上一主题 下一主题

[已经解决] 像素行走不按格子怎么做

[复制链接]

Lv1.梦旅人

小黑

梦石
0
星屑
50
在线时间
140 小时
注册时间
2011-8-23
帖子
536
跳转到指定楼层
1
发表于 2012-8-12 00:40:13 | 只看该作者 |只看大图 回帖奖励 |正序浏览 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有帐号?注册会员

x
本帖最后由 咚小黑 于 2012-8-13 02:53 编辑

不按照格子行走的脚本。VA的有木有。





这是VX的像素移动,待高手把他转成VA的
  1. =begin
  2. ================================================================================
  3. Amethyst Custom Movement - v1.2 RMVX - 25/03/2010
  4. ================================================================================

  5. --------------------------------------------------------------------------------
  6. Credits\Terms of Use
  7. --------------------------------------------------------------------------------
  8. Created by Khas ([email protected])
  9. All Amethyst Scripts are licensed under a Creative Commons license
  10. All Amethyst Scripts are for non-commercial projects, if you need
  11. them for a commercial game, please send a email to [email protected]

  12. --------------------------------------------------------------------------------
  13. Features
  14. --------------------------------------------------------------------------------
  15. This script creates an advanced movement, including "half-tile" step,
  16. diagonal movement and an advanced touch trigger feature.
  17. ACM is also compatible with RMVX vehicles

  18. --------------------------------------------------------------------------------
  19. Configuration
  20. --------------------------------------------------------------------------------
  21. =end
  22. module Amcm_Config
  23.   # Enable Diagonal movement for Player?
  24.   Enable_Player_Diagonal = true
  25.   # Enable Diagonal movement for events?
  26.   Enable_Event_Diagonal = true
  27.   # Enable "half-tile" step for events?
  28.   Enable_Event_Movement = true
  29.   # Enable Advanced Trigger Touch feature?
  30.   Enable_Advanced_Touch = true
  31. end
  32. #-------------------------------------------------------------------------------

  33. $Amethyst_Scripts = {} if $Amethyst_Scripts.nil?
  34. $Amethyst_Scripts["Am Custom Movement"] = ["1.2","25/03/2010"]

  35. class Game_Character
  36.   def amcm_integer?(value)
  37.     i = value.to_i; return value == i
  38.   end
  39.   def pos?(x, y)
  40.     if amcm_integer?(@x)
  41.       if amcm_integer?(@y)
  42.         return (@x == x and @y == y)
  43.       else
  44.         return (@x == x and (@y.to_i == y or @y.to_i+1 == y))
  45.       end
  46.     elsif amcm_integer?(@y)
  47.       return ((@x.to_i == x or @x.to_i+1 == x) and @y == y)
  48.     else
  49.       return ((@x.to_i == x or @x.to_i+1 == x)and(@y.to_i == y or @y.to_i+1 == y))
  50.     end
  51.   end
  52.   if Amcm_Config::Enable_Event_Diagonal
  53.     def move_random
  54.       case rand(8)
  55.       when 0; move_down(false)
  56.       when 1; move_left(false)
  57.       when 2; move_right(false)
  58.       when 3; move_up(false)
  59.       when 4; move_lower_left
  60.       when 5; move_lower_right
  61.       when 6; move_upper_left
  62.       when 7; move_upper_right
  63.       end
  64.     end
  65.   end
  66.   if Amcm_Config::Enable_Event_Movement
  67.     def move_down(turn_ok = true)
  68.       if amcm_integer?(@x)
  69.         if amcm_integer?(@y)
  70.           if passable?(@x, @y+1)
  71.             turn_down
  72.             @y = $game_map.round_y(@y+0.5)
  73.             @real_y = (@y-0.5)*256
  74.             increase_steps
  75.             @move_failed = false
  76.           else
  77.             turn_down if turn_ok
  78.             check_event_trigger_touch(@x, @y+1)
  79.             @move_failed = true
  80.           end
  81.         else
  82.           turn_down
  83.           @y = $game_map.round_y(@y+0.5)
  84.           @real_y = (@y-0.5)*256
  85.           increase_steps
  86.           @move_failed = false
  87.         end
  88.       elsif amcm_integer?(@y)
  89.         if passable?(@x.to_i, @y+1) and passable?(@x.to_i+1, @y+1)
  90.           turn_down
  91.           @y = $game_map.round_y(@y+0.5)
  92.           @real_y = (@y-0.5)*256
  93.           increase_steps
  94.           @move_failed = false
  95.         else
  96.           turn_down if turn_ok
  97.           check_event_trigger_touch(@x.to_i+1, @y+1)
  98.           check_event_trigger_touch(@x.to_i, @y+1)
  99.           @move_failed = true
  100.         end
  101.       else
  102.         turn_down
  103.         @y = $game_map.round_y(@y+0.5)
  104.         @real_y = (@y-0.5)*256
  105.         increase_steps
  106.         @move_failed = false
  107.       end
  108.     end
  109.     def move_up(turn_ok = true)
  110.       if amcm_integer?(@x)
  111.         if amcm_integer?(@y)
  112.           if passable?(@x, @y-1)
  113.             turn_up
  114.             @y = $game_map.round_y(@y-0.5)
  115.             @real_y = (@y+0.5)*256
  116.             increase_steps
  117.             @move_failed = false
  118.           else
  119.             turn_up if turn_ok
  120.             check_event_trigger_touch(@x, @y-1)
  121.             @move_failed = true
  122.           end
  123.         else
  124.           turn_up
  125.           @y = $game_map.round_y(@y-0.5)
  126.           @real_y = (@y+0.5)*256
  127.           increase_steps
  128.           @move_failed = false
  129.         end
  130.       elsif amcm_integer?(@y)
  131.         if passable?(@x.to_i, @y-1) and passable?(@x.to_i+1, @y-1)
  132.           turn_up
  133.           @y = $game_map.round_y(@y-0.5)
  134.           @real_y = (@y+0.5)*256
  135.           increase_steps
  136.           @move_failed = false
  137.         else
  138.           turn_up if turn_ok
  139.           check_event_trigger_touch(@x.to_i, @y-1)
  140.           check_event_trigger_touch(@x.to_i+1, @y-1)
  141.           @move_failed = true
  142.         end
  143.       else
  144.         turn_up
  145.         @y = $game_map.round_y(@y-0.5)
  146.         @real_y = (@y+0.5)*256
  147.         increase_steps
  148.         @move_failed = false
  149.       end
  150.     end
  151.     def move_left(turn_ok = true)
  152.       if amcm_integer?(@y)
  153.         if amcm_integer?(@x)
  154.           if passable?(@x-1, @y)
  155.             turn_left
  156.             @x = $game_map.round_x(@x-0.5)
  157.             @real_x = (@x+0.5)*256
  158.             increase_steps
  159.             @move_failed = false
  160.           else
  161.             turn_left if turn_ok
  162.             check_event_trigger_touch(@x-1, @y)
  163.             @move_failed = true
  164.           end
  165.         else
  166.           turn_left
  167.           @x = $game_map.round_x(@x-0.5)
  168.           @real_x = (@x+0.5)*256
  169.           increase_steps
  170.           @move_failed = false
  171.         end
  172.       elsif amcm_integer?(@x)
  173.         if passable?(@x-1,@y.to_i) and passable?(@x-1,@y.to_i+1)
  174.           turn_left
  175.           @x = $game_map.round_x(@x-0.5)
  176.           @real_x = (@x+0.5)*256
  177.           increase_steps
  178.           @move_failed = false
  179.         else
  180.           turn_left if turn_ok
  181.           check_event_trigger_touch(@x-1, @y.to_i)
  182.           check_event_trigger_touch(@x-1, @y.to_i+1)
  183.           @move_failed = true
  184.         end
  185.       else
  186.         turn_left
  187.         @x = $game_map.round_x(@x-0.5)
  188.         @real_x = (@x+0.5)*256
  189.         increase_steps
  190.         @move_failed = false
  191.       end
  192.     end
  193.     def move_right(turn_ok = true)
  194.       if amcm_integer?(@y)
  195.         if amcm_integer?(@x)
  196.           if passable?(@x+1, @y)
  197.             turn_right
  198.             @x = $game_map.round_x(@x+0.5)
  199.             @real_x = (@x-0.5)*256
  200.             increase_steps
  201.             @move_failed = false
  202.           else
  203.             turn_right if turn_ok
  204.             check_event_trigger_touch(@x+1, @y)
  205.             @move_failed = true
  206.           end
  207.         else
  208.           turn_right
  209.           @x = $game_map.round_x(@x+0.5)
  210.           @real_x = (@x-0.5)*256
  211.           increase_steps
  212.           @move_failed = false
  213.         end
  214.       elsif amcm_integer?(@x)
  215.         if passable?(@x+1,@y.to_i) and passable?(@x+1,@y.to_i+1)
  216.           turn_right
  217.           @x = $game_map.round_x(@x+0.5)
  218.           @real_x = (@x-0.5)*256
  219.           increase_steps
  220.           @move_failed = false
  221.         else
  222.           turn_right if turn_ok
  223.           check_event_trigger_touch(@x+1, @y.to_i)
  224.           check_event_trigger_touch(@x+1, @y.to_i+1)
  225.           @move_failed = true
  226.         end
  227.       else
  228.         turn_right
  229.         @x = $game_map.round_x(@x+0.5)
  230.         @real_x = (@x-0.5)*256
  231.         increase_steps
  232.         @move_failed = false
  233.       end
  234.     end
  235.     def move_lower_left
  236.       unless @direction_fix
  237.         @direction = (@direction == 6 ? 4 : @direction == 8 ? 2 : @direction)
  238.       end
  239.       if amcm_integer?(@x)
  240.         if amcm_integer?(@y)
  241.           if passable?(@x-1,@y) and passable?(@x-1,@y+1) and passable?(@x,@y+1)
  242.             @x -= 0.5
  243.             @y += 0.5
  244.             increase_steps
  245.             @move_failed = false
  246.           else
  247.             @move_failed = true
  248.           end
  249.         else
  250.           if passable?(@x-1,@y.to_i+1)
  251.             @x -= 0.5
  252.             @y += 0.5
  253.             increase_steps
  254.             @move_failed = false
  255.           else
  256.             @move_failed = true
  257.           end
  258.         end
  259.       elsif amcm_integer?(@y)
  260.         if passable?(@x.to_i,@y+1)
  261.           @x -= 0.5
  262.           @y += 0.5
  263.           increase_steps
  264.           @move_failed = false
  265.         else
  266.           @move_failed = true
  267.         end
  268.       else
  269.         @x -= 0.5
  270.         @y += 0.5
  271.         increase_steps
  272.         @move_failed = false
  273.       end
  274.     end
  275.     def move_lower_right
  276.       unless @direction_fix
  277.         @direction = (@direction == 4 ? 6 : @direction == 8 ? 2 : @direction)
  278.       end
  279.       if amcm_integer?(@x)
  280.         if amcm_integer?(@y)
  281.           if passable?(@x+1,@y) and passable?(@x+1,@y+1) and passable?(@x,@y+1)
  282.             @x += 0.5
  283.             @y += 0.5
  284.             increase_steps
  285.             @move_failed = false
  286.           else
  287.             @move_failed = true
  288.           end
  289.         else
  290.           if passable?(@x+1,@y.to_i+1)
  291.             @x += 0.5
  292.             @y += 0.5
  293.             increase_steps
  294.             @move_failed = false
  295.           else
  296.             @move_failed = true
  297.           end
  298.         end
  299.       elsif amcm_integer?(@y)
  300.         if passable?(@x.to_i+1,@y+1)
  301.           @x += 0.5
  302.           @y += 0.5
  303.           increase_steps
  304.           @move_failed = false
  305.         else
  306.           @move_failed = true
  307.         end
  308.       else
  309.         @x += 0.5
  310.         @y += 0.5
  311.         increase_steps
  312.         @move_failed = false
  313.       end
  314.     end
  315.     def move_upper_left
  316.       unless @direction_fix
  317.         @direction = (@direction == 6 ? 4 : @direction == 2 ? 8 : @direction)
  318.       end
  319.       if amcm_integer?(@x)
  320.         if amcm_integer?(@y)
  321.           if passable?(@x-1,@y) and passable?(@x-1,@y-1) and passable?(@x,@y-1)
  322.             @x -= 0.5
  323.             @y -= 0.5
  324.             increase_steps
  325.             @move_failed = false
  326.           else
  327.             @move_failed = true
  328.           end
  329.         else
  330.           if passable?(@x-1,@y.to_i)
  331.             @x -= 0.5
  332.             @y -= 0.5
  333.             increase_steps
  334.             @move_failed = false
  335.           else
  336.             @move_failed = true
  337.           end
  338.         end
  339.       elsif amcm_integer?(@y)
  340.         if passable?(@x.to_i,@y-1)
  341.           @x -= 0.5
  342.           @y -= 0.5
  343.           increase_steps
  344.           @move_failed = false
  345.         else
  346.           @move_failed = true
  347.         end
  348.       else
  349.         @x -= 0.5
  350.         @y -= 0.5
  351.         increase_steps
  352.         @move_failed = false
  353.       end
  354.     end
  355.     def move_upper_right
  356.       unless @direction_fix
  357.         @direction = (@direction == 4 ? 6 : @direction == 2 ? 8 : @direction)
  358.       end
  359.       if amcm_integer?(@x)
  360.         if amcm_integer?(@y)
  361.           if passable?(@x+1,@y) and passable?(@x+1,@y-1) and passable?(@x,@y-1)
  362.             @x += 0.5
  363.             @y -= 0.5
  364.             increase_steps
  365.             @move_failed = false
  366.           else
  367.             @move_failed = true
  368.           end
  369.         else
  370.           if passable?(@x+1,@y.to_i)
  371.             @x += 0.5
  372.             @y -= 0.5
  373.             increase_steps
  374.             @move_failed = false
  375.           else
  376.             @move_failed = true
  377.           end
  378.         end
  379.       elsif amcm_integer?(@y)
  380.         if passable?(@x.to_i+1,@y-1)
  381.           @x += 0.5
  382.           @y -= 0.5
  383.           increase_steps
  384.           @move_failed = false
  385.         else
  386.           @move_failed = true
  387.         end
  388.       else
  389.         @x += 0.5
  390.         @y -= 0.5
  391.         increase_steps
  392.         @move_failed = false
  393.       end
  394.     end
  395.   end
  396. end

  397. class Game_Player < Game_Character
  398.   if Amcm_Config::Enable_Player_Diagonal
  399.     def move_by_input
  400.       @run_event = false
  401.       return unless movable?
  402.       return if $game_map.interpreter.running?
  403.       case Input.dir8
  404.       when 1; move_lower_left
  405.       when 2; move_down
  406.       when 3; move_lower_right  
  407.       when 4; move_left
  408.       when 6; move_right
  409.       when 7; move_upper_left
  410.       when 8; move_up
  411.       when 9; move_upper_right
  412.       end
  413.     end
  414.   end
  415.   def get_amx(plus=false)
  416.     if plus
  417.       case @direction
  418.       when 2; amcm_integer?(@x) ? i = @x : i = false
  419.       when 4; amcm_integer?(@x) ? i = @x-1 : i = false
  420.       when 6; amcm_integer?(@x) ? i = @x+1 : i = false
  421.       when 8; amcm_integer?(@x) ? i = @x : i = false
  422.       end
  423.       return i
  424.     else
  425.       amcm_integer?(@x) ? i = @x : i = [@x.to_i,@x.to_i+1]; return i
  426.     end
  427.   end
  428.   def get_amy(plus=false)
  429.     if plus
  430.       case @direction
  431.       when 2; amcm_integer?(@y) ? i = @y+1 : i = false
  432.       when 4; amcm_integer?(@y) ? i = @y : i = false
  433.       when 6; amcm_integer?(@y) ? i = @y : i = false
  434.       when 8; amcm_integer?(@y) ? i = @y-1 : i = false
  435.       end
  436.       return i
  437.     else
  438.       amcm_integer?(@y) ? i = @y : i = [@y.to_i,@y.to_i+1]; return i
  439.     end
  440.   end
  441.   if Amcm_Config::Enable_Advanced_Touch
  442.     def check_event_trigger_here(triggers)
  443.       return false if $game_map.interpreter.running?
  444.       result = false
  445.       ax = get_amx
  446.       ay = get_amy
  447.       if ax.is_a?(Array)
  448.         if ay.is_a?(Array)
  449.           for event in $game_map.events_xy(ax[0],ay[0])
  450.             if triggers.include?(event.trigger) and event.priority_type != 1
  451.               event.start
  452.               return true if event.starting
  453.             end
  454.           end
  455.           for event in $game_map.events_xy(ax[0],ay[1])
  456.             if triggers.include?(event.trigger) and event.priority_type != 1
  457.               event.start
  458.               return true if event.starting
  459.             end
  460.           end
  461.           for event in $game_map.events_xy(ax[1],ay[0])
  462.             if triggers.include?(event.trigger) and event.priority_type != 1
  463.               event.start
  464.               return true if event.starting
  465.             end
  466.           end
  467.           for event in $game_map.events_xy(ax[1],ay[1])
  468.             if triggers.include?(event.trigger) and event.priority_type != 1
  469.               event.start
  470.               return true if event.starting
  471.             end
  472.           end
  473.         else
  474.           for event in $game_map.events_xy(ax[0],ay)
  475.             if triggers.include?(event.trigger) and event.priority_type != 1
  476.               event.start
  477.               return true if event.starting
  478.             end
  479.           end
  480.           for event in $game_map.events_xy(ax[1],ay)
  481.             if triggers.include?(event.trigger) and event.priority_type != 1
  482.               event.start
  483.               return true if event.starting
  484.             end
  485.           end
  486.         end
  487.       elsif ay.is_a?(Array)
  488.         for event in $game_map.events_xy(ax,ay[0])
  489.           if triggers.include?(event.trigger) and event.priority_type != 1
  490.             event.start
  491.             return true if event.starting
  492.           end
  493.         end
  494.         for event in $game_map.events_xy(ax,ay[1])
  495.           if triggers.include?(event.trigger) and event.priority_type != 1
  496.             event.start
  497.             return true if event.starting
  498.           end
  499.         end
  500.       else
  501.         for event in $game_map.events_xy(ax,ay)
  502.           if triggers.include?(event.trigger) and event.priority_type != 1
  503.             event.start
  504.             return true if event.starting
  505.           end
  506.         end
  507.       end
  508.       return result
  509.     end
  510.   else
  511.     def check_event_trigger_here(triggers)
  512.       return false if $game_map.interpreter.running?
  513.       result = false
  514.       for event in $game_map.events_xy(@x, @y)
  515.         if triggers.include?(event.trigger) and event.priority_type != 1
  516.           event.start
  517.           result = true if event.starting
  518.         end
  519.       end
  520.       return result
  521.     end
  522.   end
  523.   def check_event_trigger_there(triggers)
  524.     return false if $game_map.interpreter.running?
  525.     result = false
  526.     front_x = get_amx(true)
  527.     front_y = get_amy(true)
  528.     return if !front_x or !front_y
  529.     for event in $game_map.events_xy(front_x, front_y)
  530.       if triggers.include?(event.trigger) and event.priority_type == 1
  531.         event.start
  532.         result = true
  533.       end
  534.     end
  535.     if result == false and $game_map.counter?(front_x, front_y)
  536.       front_x = $game_map.x_with_direction(front_x, @direction)
  537.       front_y = $game_map.y_with_direction(front_y, @direction)
  538.       for event in $game_map.events_xy(front_x, front_y)
  539.         if triggers.include?(event.trigger) and event.priority_type == 1
  540.           event.start
  541.           result = true
  542.         end
  543.       end
  544.     end
  545.     return result
  546.   end
  547.   def get_on_vehicle
  548.     front_x = get_amx(true)
  549.     front_y = get_amy(true)
  550.     if $game_map.airship.pos?(@x, @y)
  551.       get_on_airship
  552.       return true
  553.     elsif $game_map.ship.pos?(front_x, front_y)
  554.       get_on_ship
  555.       return true
  556.     elsif $game_map.boat.pos?(front_x, front_y)
  557.       get_on_boat
  558.       return true
  559.     end
  560.     return false
  561.   end
  562.   def force_vland
  563.     if amcm_integer?(@x)
  564.       if amcm_integer?(@y)
  565.         return
  566.       else
  567.         case @direction
  568.         when 2; move_forward
  569.         when 8; move_forward
  570.         else
  571.           case rand(2)
  572.           when 0; move_up
  573.           when 1; move_down
  574.           end
  575.         end
  576.       end
  577.     elsif amcm_integer?(@y)
  578.       case @direction
  579.       when 4; move_forward
  580.       when 6; move_forward
  581.       else
  582.         case rand(2)
  583.         when 0; move_left
  584.         when 1; move_right
  585.         end
  586.       end
  587.     else
  588.       case @direction
  589.       when 2;
  590.         case rand(2)
  591.         when 0; move_lower_right
  592.         when 1; move_lower_left
  593.         end
  594.       when 4;
  595.         case rand(2)
  596.         when 0; move_lower_left
  597.         when 1; move_upper_left
  598.         end
  599.       when 6;
  600.         case rand(2)
  601.         when 0; move_lower_right
  602.         when 1; move_upper_right
  603.         end
  604.       when 8;
  605.         case rand(2)
  606.         when 0; move_upper_right
  607.         when 1; move_upper_left
  608.         end
  609.       end
  610.     end
  611.     return (amcm_integer?(@x) and amcm_integer?(@y))
  612.   end
  613.   def force_move_forward
  614.     @through = true
  615.     move_forward
  616.     move_forward if in_vehicle?
  617.     @through = false
  618.   end
  619.   def get_off_vehicle
  620.     if in_airship?
  621.       return if force_vland
  622.       return unless airship_land_ok?(@x, @y)
  623.     else
  624.       return if force_vland
  625.       front_x = get_amx(true)
  626.       front_y = get_amy(true)
  627.       return unless can_walk?(front_x, front_y)
  628.     end
  629.     $game_map.vehicles[@vehicle_type].get_off
  630.     if in_airship?
  631.       @direction = 2
  632.     else
  633.       force_move_forward
  634.       @transparent = false
  635.     end
  636.     @vehicle_getting_off = true
  637.     @move_speed = 4
  638.     @through = false
  639.     @walking_bgm.play
  640.     make_encounter_count
  641.   end
  642.   if not Amcm_Config::Enable_Event_Movement
  643.     def move_down(turn_ok = true)
  644.       if amcm_integer?(@x)
  645.         if amcm_integer?(@y)
  646.           if passable?(@x, @y+1)
  647.             turn_down
  648.             @y = $game_map.round_y(@y+0.5)
  649.             @real_y = (@y-0.5)*256
  650.             increase_steps
  651.             @move_failed = false
  652.           else
  653.             turn_down if turn_ok
  654.             check_event_trigger_touch(@x, @y+1)
  655.             @move_failed = true
  656.           end
  657.         else
  658.           turn_down
  659.           @y = $game_map.round_y(@y+0.5)
  660.           @real_y = (@y-0.5)*256
  661.           increase_steps
  662.           @move_failed = false
  663.         end
  664.       elsif amcm_integer?(@y)
  665.         if passable?(@x.to_i, @y+1) and passable?(@x.to_i+1, @y+1)
  666.           turn_down
  667.           @y = $game_map.round_y(@y+0.5)
  668.           @real_y = (@y-0.5)*256
  669.           increase_steps
  670.           @move_failed = false
  671.         else
  672.           turn_down if turn_ok
  673.           check_event_trigger_touch(@x.to_i+1, @y+1)
  674.           check_event_trigger_touch(@x.to_i, @y+1)
  675.           @move_failed = true
  676.         end
  677.       else
  678.         turn_down
  679.         @y = $game_map.round_y(@y+0.5)
  680.         @real_y = (@y-0.5)*256
  681.         increase_steps
  682.         @move_failed = false
  683.       end
  684.     end
  685.     def move_up(turn_ok = true)
  686.       if amcm_integer?(@x)
  687.         if amcm_integer?(@y)
  688.           if passable?(@x, @y-1)
  689.             turn_up
  690.             @y = $game_map.round_y(@y-0.5)
  691.             @real_y = (@y+0.5)*256
  692.             increase_steps
  693.             @move_failed = false
  694.           else
  695.             turn_up if turn_ok
  696.             check_event_trigger_touch(@x, @y-1)
  697.             @move_failed = true
  698.           end
  699.         else
  700.           turn_up
  701.           @y = $game_map.round_y(@y-0.5)
  702.           @real_y = (@y+0.5)*256
  703.           increase_steps
  704.           @move_failed = false
  705.         end
  706.       elsif amcm_integer?(@y)
  707.         if passable?(@x.to_i, @y-1) and passable?(@x.to_i+1, @y-1)
  708.           turn_up
  709.           @y = $game_map.round_y(@y-0.5)
  710.           @real_y = (@y+0.5)*256
  711.           increase_steps
  712.           @move_failed = false
  713.         else
  714.           turn_up if turn_ok
  715.           check_event_trigger_touch(@x.to_i, @y-1)
  716.           check_event_trigger_touch(@x.to_i+1, @y-1)
  717.           @move_failed = true
  718.         end
  719.       else
  720.         turn_up
  721.         @y = $game_map.round_y(@y-0.5)
  722.         @real_y = (@y+0.5)*256
  723.         increase_steps
  724.         @move_failed = false
  725.       end
  726.     end
  727.     def move_left(turn_ok = true)
  728.       if amcm_integer?(@y)
  729.         if amcm_integer?(@x)
  730.           if passable?(@x-1, @y)
  731.             turn_left
  732.             @x = $game_map.round_x(@x-0.5)
  733.             @real_x = (@x+0.5)*256
  734.             increase_steps
  735.             @move_failed = false
  736.           else
  737.             turn_left if turn_ok
  738.             check_event_trigger_touch(@x-1, @y)
  739.             @move_failed = true
  740.           end
  741.         else
  742.           turn_left
  743.           @x = $game_map.round_x(@x-0.5)
  744.           @real_x = (@x+0.5)*256
  745.           increase_steps
  746.           @move_failed = false
  747.         end
  748.       elsif amcm_integer?(@x)
  749.         if passable?(@x-1,@y.to_i) and passable?(@x-1,@y.to_i+1)
  750.           turn_left
  751.           @x = $game_map.round_x(@x-0.5)
  752.           @real_x = (@x+0.5)*256
  753.           increase_steps
  754.           @move_failed = false
  755.         else
  756.           turn_left if turn_ok
  757.           check_event_trigger_touch(@x-1, @y.to_i)
  758.           check_event_trigger_touch(@x-1, @y.to_i+1)
  759.           @move_failed = true
  760.         end
  761.       else
  762.         turn_left
  763.         @x = $game_map.round_x(@x-0.5)
  764.         @real_x = (@x+0.5)*256
  765.         increase_steps
  766.         @move_failed = false
  767.       end
  768.     end
  769.     def move_right(turn_ok = true)
  770.       if amcm_integer?(@y)
  771.         if amcm_integer?(@x)
  772.           if passable?(@x+1, @y)
  773.             turn_right
  774.             @x = $game_map.round_x(@x+0.5)
  775.             @real_x = (@x-0.5)*256
  776.             increase_steps
  777.             @move_failed = false
  778.           else
  779.             turn_right if turn_ok
  780.             check_event_trigger_touch(@x+1, @y)
  781.             @move_failed = true
  782.           end
  783.         else
  784.           turn_right
  785.           @x = $game_map.round_x(@x+0.5)
  786.           @real_x = (@x-0.5)*256
  787.           increase_steps
  788.           @move_failed = false
  789.         end
  790.       elsif amcm_integer?(@x)
  791.         if passable?(@x+1,@y.to_i) and passable?(@x+1,@y.to_i+1)
  792.           turn_right
  793.           @x = $game_map.round_x(@x+0.5)
  794.           @real_x = (@x-0.5)*256
  795.           increase_steps
  796.           @move_failed = false
  797.         else
  798.           turn_right if turn_ok
  799.           check_event_trigger_touch(@x+1, @y.to_i)
  800.           check_event_trigger_touch(@x+1, @y.to_i+1)
  801.           @move_failed = true
  802.         end
  803.       else
  804.         turn_right
  805.         @x = $game_map.round_x(@x+0.5)
  806.         @real_x = (@x-0.5)*256
  807.         increase_steps
  808.         @move_failed = false
  809.       end
  810.     end
  811.     def move_lower_left
  812.       unless @direction_fix
  813.         @direction = (@direction == 6 ? 4 : @direction == 8 ? 2 : @direction)
  814.       end
  815.       if amcm_integer?(@x)
  816.         if amcm_integer?(@y)
  817.           if passable?(@x-1,@y) and passable?(@x-1,@y+1) and passable?(@x,@y+1)
  818.             @x -= 0.5
  819.             @y += 0.5
  820.             increase_steps
  821.             @move_failed = false
  822.           else
  823.             @move_failed = true
  824.           end
  825.         else
  826.           if passable?(@x-1,@y.to_i+1)
  827.             @x -= 0.5
  828.             @y += 0.5
  829.             increase_steps
  830.             @move_failed = false
  831.           else
  832.             @move_failed = true
  833.           end
  834.         end
  835.       elsif amcm_integer?(@y)
  836.         if passable?(@x.to_i,@y+1)
  837.           @x -= 0.5
  838.           @y += 0.5
  839.           increase_steps
  840.           @move_failed = false
  841.         else
  842.           @move_failed = true
  843.         end
  844.       else
  845.         @x -= 0.5
  846.         @y += 0.5
  847.         increase_steps
  848.         @move_failed = false
  849.       end
  850.     end
  851.     def move_lower_right
  852.       unless @direction_fix
  853.         @direction = (@direction == 4 ? 6 : @direction == 8 ? 2 : @direction)
  854.       end
  855.       if amcm_integer?(@x)
  856.         if amcm_integer?(@y)
  857.           if passable?(@x+1,@y) and passable?(@x+1,@y+1) and passable?(@x,@y+1)
  858.             @x += 0.5
  859.             @y += 0.5
  860.             increase_steps
  861.             @move_failed = false
  862.           else
  863.             @move_failed = true
  864.           end
  865.         else
  866.           if passable?(@x+1,@y.to_i+1)
  867.             @x += 0.5
  868.             @y += 0.5
  869.             increase_steps
  870.             @move_failed = false
  871.           else
  872.             @move_failed = true
  873.           end
  874.         end
  875.       elsif amcm_integer?(@y)
  876.         if passable?(@x.to_i+1,@y+1)
  877.           @x += 0.5
  878.           @y += 0.5
  879.           increase_steps
  880.           @move_failed = false
  881.         else
  882.           @move_failed = true
  883.         end
  884.       else
  885.         @x += 0.5
  886.         @y += 0.5
  887.         increase_steps
  888.         @move_failed = false
  889.       end
  890.     end
  891.     def move_upper_left
  892.       unless @direction_fix
  893.         @direction = (@direction == 6 ? 4 : @direction == 2 ? 8 : @direction)
  894.       end
  895.       if amcm_integer?(@x)
  896.         if amcm_integer?(@y)
  897.           if passable?(@x-1,@y) and passable?(@x-1,@y-1) and passable?(@x,@y-1)
  898.             @x -= 0.5
  899.             @y -= 0.5
  900.             increase_steps
  901.             @move_failed = false
  902.           else
  903.             @move_failed = true
  904.           end
  905.         else
  906.           if passable?(@x-1,@y.to_i)
  907.             @x -= 0.5
  908.             @y -= 0.5
  909.             increase_steps
  910.             @move_failed = false
  911.           else
  912.             @move_failed = true
  913.           end
  914.         end
  915.       elsif amcm_integer?(@y)
  916.         if passable?(@x.to_i,@y-1)
  917.           @x -= 0.5
  918.           @y -= 0.5
  919.           increase_steps
  920.           @move_failed = false
  921.         else
  922.           @move_failed = true
  923.         end
  924.       else
  925.         @x -= 0.5
  926.         @y -= 0.5
  927.         increase_steps
  928.         @move_failed = false
  929.       end
  930.     end
  931.     def move_upper_right
  932.       unless @direction_fix
  933.         @direction = (@direction == 4 ? 6 : @direction == 2 ? 8 : @direction)
  934.       end
  935.       if amcm_integer?(@x)
  936.         if amcm_integer?(@y)
  937.           if passable?(@x+1,@y) and passable?(@x+1,@y-1) and passable?(@x,@y-1)
  938.             @x += 0.5
  939.             @y -= 0.5
  940.             increase_steps
  941.             @move_failed = false
  942.           else
  943.             @move_failed = true
  944.           end
  945.         else
  946.           if passable?(@x+1,@y.to_i)
  947.             @x += 0.5
  948.             @y -= 0.5
  949.             increase_steps
  950.             @move_failed = false
  951.           else
  952.             @move_failed = true
  953.           end
  954.         end
  955.       elsif amcm_integer?(@y)
  956.         if passable?(@x.to_i+1,@y-1)
  957.           @x += 0.5
  958.           @y -= 0.5
  959.           increase_steps
  960.           @move_failed = false
  961.         else
  962.           @move_failed = true
  963.         end
  964.       else
  965.         @x += 0.5
  966.         @y -= 0.5
  967.         increase_steps
  968.         @move_failed = false
  969.       end
  970.     end
  971.   end
  972. end
复制代码
起码对得起自己。

Lv2.观梦者

梦石
0
星屑
812
在线时间
121 小时
注册时间
2013-10-2
帖子
33
10
发表于 2015-9-10 16:49:32 | 只看该作者
这是什么情况

未命名.PNG (302.71 KB, 下载次数: 24)

未命名.PNG

点评

请勿挖坟,有问题请开新帖  发表于 2015-9-10 19:11
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
366 小时
注册时间
2009-7-14
帖子
124
9
发表于 2012-8-17 08:32:00 | 只看该作者
用LS的剧本的确可以按像素行走,不过事件触发判断存在严重问题啊,死活打不开商店,弊大于利

点评

我是直接用他那个工程试的,的确打不开,而且玩家接触和事件接触这一类的事件也存在判定问题。  发表于 2012-8-17 15:06
为何打不开,我能打开  发表于 2012-8-17 08:41
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
48
在线时间
543 小时
注册时间
2011-6-25
帖子
441
8
发表于 2012-8-16 12:23:28 | 只看该作者
DLL太大了
Project1.rar (315.83 KB, 下载次数: 71)

点评

非常感谢!脚本非常好,没问题。楼下可能是和其他脚本冲突了。收藏了。  发表于 2014-2-2 23:17
好可惜不能斜着走  发表于 2012-8-17 08:39


------------------------------------------我只放我看中的遊戲-----------------------------------------------
臉書:http://www.facebook.com/brian.lee.52643821
  音速君的論壇
回复 支持 反对

使用道具 举报

Lv1.梦旅人

小黑

梦石
0
星屑
50
在线时间
140 小时
注册时间
2011-8-23
帖子
536
7
 楼主| 发表于 2012-8-16 03:26:26 | 只看该作者
poiuy12348609 发表于 2012-8-15 18:14
[        DISCUZ_CODE_1        ])
      @cw = bitmap.width / @character.frames
      @ch = bitmap.height / 4

发现里面混合了很多个脚本啊

点评

有兩個腳本哦 等等我上專案  发表于 2012-8-16 12:07
起码对得起自己。
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
48
在线时间
543 小时
注册时间
2011-6-25
帖子
441
6
发表于 2012-8-15 18:14:20 | 只看该作者
  1. #==============================================================================
  2. # ** Victor Engine - Pixel Movement
  3. #------------------------------------------------------------------------------
  4. # Author : Victor Sant
  5. #
  6. # Version History:
  7. #  v 1.00 - 2012.05.29 > First relase
  8. #  v 1.01 - 2012.05.29 > Compatibility with Terrain States
  9. #  v 1.02 - 2012.07.03 > Compatibility with Basic Module 1.23
  10. #  v 1.03 - 2012.07.05 > Added 'over event' tag for objects over blocked tiles
  11. #                      > Added Steps settings for events
  12. #  v 1.04 - 2012.07.24 > Compatibility with Moving Platform
  13. #                      > Added <each step trigger> tag for events
  14. #  v 1.05 - 2012.07.30 > Fixed issue when characters moves toward the same spot
  15. #  v 1.06 - 2012.08.03 > Compatibility with Anti Lag
  16. #  v 1.07 - 2012.08.03 > Fixed collision with tile graphics events
  17. #------------------------------------------------------------------------------
  18. #  This script allows to replace the tile based movement where the player
  19. # walks a whole 32 pixel tile each step with one that he walks only 4 pixels.
  20. # It also give a better collision system for events.
  21. #------------------------------------------------------------------------------
  22. # Compatibility
  23. #   Requires the script 'Victor Engine - Basic Module' v 1.25 or higher
  24. #   If used with 'Victor Engine - Animated Battle' place this bellow it.
  25. #   If used with 'Victor Engine - Follower Control' place this bellow it.
  26. #   If used with 'Victor Engine - Follower Options' place this bellow it.
  27. #
  28. # * Overwrite methods
  29. #   class Game_Actor < Game_Battler
  30. #     def turn_end_on_map
  31. #
  32. #   class Game_Map
  33. #     def layered_tiles(x, y)
  34. #     def events_xy(x, y)
  35. #     def events_xy_nt(x, y)
  36. #     def x_with_direction(x, d, times = 1)
  37. #     def y_with_direction(y, d, times = 1)
  38. #     def round_x_with_direction(x, d)
  39. #     def round_y_with_direction
  40. #
  41. #   class Game_CharacterBase
  42. #     def region_id
  43. #     def move_straight(d, turn_ok = true)
  44. #     def move_diagonal(horz, vert)
  45. #     def collide_with_events?(x, y)
  46. #     def collide_with_vehicles?(x, y)
  47. #
  48. #   class Game_Player < Game_Character
  49. #     def check_event_trigger_there(triggers)
  50. #     def start_map_event(x, y, triggers, normal)
  51. #     def update_nonmoving(last_moving)
  52. #     def get_on_vehicle
  53. #     def increase_steps
  54. #
  55. #   class Game_Follower < Game_Character
  56. #     def chase_preceding_character
  57. #
  58. #   class Game_Event < Game_Character
  59. #     def collide_with_player_characters?(x, y)
  60. #
  61. #   class Game_Vehicle < Game_Character
  62. #     def land_ok?(x, y, d)
  63. #
  64. # * Alias methods
  65. #   class Game_Actor < Game_Battler
  66. #     def check_floor_effect
  67. #
  68. #   class Game_CharacterBase
  69. #     def init_public_members
  70. #     def update
  71. #
  72. #   class Game_Character < Game_CharacterBase
  73. #     def move_toward_character(character)
  74. #     def move_toward_position(x, y)
  75. #
  76. #   class Game_Event < Game_Character
  77. #     def start
  78. #
  79. #   class Game_Player < Game_Character
  80. #     def get_off_vehicle
  81. #     def clear_transfer_info
  82. #     def update
  83. #
  84. #   class Game_Event < Game_Character
  85. #     def start
  86. #
  87. #------------------------------------------------------------------------------
  88. # Instructions:
  89. #  To instal the script, open you script editor and paste this script on
  90. #  a new section bellow the Materials section. This script must also
  91. #  be bellow the script 'Victor Engine - Basic'
  92. #
  93. #------------------------------------------------------------------------------
  94. # Event Comment boxes note tags:
  95. #   Tags to be used on events Comment boxes.
  96. #
  97. #  <move steps: x>
  98. #   Setup the number of steps each "Move" command will execute. The default
  99. #   value is 8 (1 tile)
  100. #     x : number of steps
  101. #
  102. #  <event size: x, y>
  103. #   Collision area size, in pixels for event collisions.
  104. #     x : collision area width
  105. #     y : collision area height
  106. #
  107. #  <front collision>
  108. #   Events with this tag won't start if the the collision between events and
  109. #   the player occur between their edges.
  110. #
  111. #  <no side collision fix>
  112. #   Events with this tag won't have the "slide" effect when the edges of the
  113. #   events collide with the player
  114. #
  115. #  <over tile>
  116. #   Events with this tag will start even when placed over blocked tiles.
  117. #   By default, if the passage is blocked the event don't stat.
  118. #
  119. #  <each step trigger>
  120. #   By default, events with through or bellow character priority triggers
  121. #   only one time for each 8 steps above them. With this tag though, the
  122. #   event will trigger every step.
  123. #
  124. #------------------------------------------------------------------------------
  125. # Additional instructions:
  126. #
  127. #  All events and tiles have a "slide" effect when the player faces the edge
  128. #  of a tile or event. I added this function since it would be a pain to
  129. #  be in the exact position to go throug a narrow path.
  130. #  This can be disabled for events, but not for tiles.
  131. #
  132. #==============================================================================

  133. #==============================================================================
  134. # ** Victor Engine
  135. #------------------------------------------------------------------------------
  136. #   Setting module for the Victor Engine
  137. #==============================================================================

  138. module Victor_Engine
  139.   #--------------------------------------------------------------------------
  140.   # * Player collision area
  141.   #   Different from events, player collision don't rely on the graphic size
  142.   #   Player collision area can be of 2 types:
  143.   #   - 32 x 32 box if VE_PLAYER_BIG_COLLISION = true
  144.   #   - 24 x 24 box if VE_PLAYER_BIG_COLLISION = false
  145.   #--------------------------------------------------------------------------
  146.   VE_PLAYER_BIG_COLLISION = true
  147.   #--------------------------------------------------------------------------
  148.   # * required
  149.   #   This method checks for the existance of the basic module and other
  150.   #   VE scripts required for this script to work, don't edit this
  151.   #--------------------------------------------------------------------------
  152.   def self.required(name, req, version, type = nil)
  153.     if !$imported[:ve_basic_module]
  154.       msg = "The script '%s' requires the script\n"
  155.       msg += "'VE - Basic Module' v%s or higher above it to work properly\n"
  156.       msg += "Go to http://victorscripts.wordpress.com/ to download this script."
  157.       msgbox(sprintf(msg, self.script_name(name), version))
  158.       exit
  159.     else
  160.       self.required_script(name, req, version, type)
  161.     end
  162.   end
  163.   #--------------------------------------------------------------------------
  164.   # * script_name
  165.   #   Get the script name base on the imported value
  166.   #--------------------------------------------------------------------------
  167.   def self.script_name(name, ext = "VE")
  168.     name = name.to_s.gsub("_", " ").upcase.split
  169.     name.collect! {|char| char == ext ? "#{char} -" : char.capitalize }
  170.     name.join(" ")
  171.   end
  172. end

  173. $imported ||= {}
  174. $imported[:ve_pixel_movement] = 1.07
  175. Victor_Engine.required(:ve_pixel_movement, :ve_basic_module, 1.25, :above)
  176. Victor_Engine.required(:ve_pixel_movement, :ve_map_battle, 1.00, :bellow)
  177. Victor_Engine.required(:ve_pixel_movement, :ve_diagonal_move, 1.00, :bellow)

  178. #==============================================================================
  179. # ** Game_Actor
  180. #------------------------------------------------------------------------------
  181. #  This class handles actors. It's used within the Game_Actors class
  182. # ($game_actors) and referenced by the Game_Party class ($game_party).
  183. #==============================================================================

  184. class Game_Actor < Game_Battler
  185.   #--------------------------------------------------------------------------
  186.   # * Overwrite method: turn_end_on_map
  187.   #--------------------------------------------------------------------------
  188.   def turn_end_on_map
  189.     if $game_player.steps % (steps_for_turn * 8) == 0
  190.       on_turn_end
  191.       perform_map_damage_effect if @result.hp_damage > 0
  192.     end
  193.   end
  194.   #--------------------------------------------------------------------------
  195.   # * Alias method: init_public_members
  196.   #--------------------------------------------------------------------------
  197.   alias :check_floor_effect_ve_pixel_movement :check_floor_effect
  198.   def check_floor_effect
  199.     return if check_damage_floor
  200.     check_floor_effect_ve_pixel_movement
  201.   end
  202.   #--------------------------------------------------------------------------
  203.   # * New method: check_damage_floor
  204.   #--------------------------------------------------------------------------
  205.   def check_damage_floor
  206.     $game_player.damage_floor % 8 != 0
  207.   end
  208. end

  209. #==============================================================================
  210. # ** Game_Map
  211. #------------------------------------------------------------------------------
  212. #  This class handles maps. It includes scrolling and passage determination
  213. # functions. The instance of this class is referenced by $game_map.
  214. #==============================================================================

  215. class Game_Map
  216.   #--------------------------------------------------------------------------
  217.   # * Overwrite method: layered_tiles
  218.   #--------------------------------------------------------------------------
  219.   def layered_tiles(x, y)
  220.     x2 = (x - 0.5).ceil
  221.     y2 = (y - 0.125).ceil
  222.     [2, 1, 0].collect {|z| tile_id(x2, y2, z) }
  223.   end
  224.   #--------------------------------------------------------------------------
  225.   # * Overwrite method: events_xy
  226.   #--------------------------------------------------------------------------
  227.   def events_xy(x, y)
  228.     event_list.select {|event| event.near?(x, y) }
  229.   end
  230.   #--------------------------------------------------------------------------
  231.   # * Overwrite method: events_xy_nt
  232.   #--------------------------------------------------------------------------
  233.   def events_xy_nt(x, y)
  234.     event_list.select {|event| event.near_nt?(x, y) }
  235.   end
  236.   #--------------------------------------------------------------------------
  237.   # * Overwrite method: x_with_direction
  238.   #--------------------------------------------------------------------------
  239.   def x_with_direction(x, d, times = 1)
  240.     x + (d == 6 ? times * 0.125 : d == 4 ? -times * 0.125 : 0)
  241.   end
  242.   #--------------------------------------------------------------------------
  243.   # * Overwrite method: y_with_direction
  244.   #--------------------------------------------------------------------------
  245.   def y_with_direction(y, d, times = 1)
  246.     y + (d == 2 ? times * 0.125 : d == 8 ? -times * 0.125 : 0)
  247.   end
  248.   #--------------------------------------------------------------------------
  249.   # * Overwrite method: round_x_with_direction
  250.   #--------------------------------------------------------------------------
  251.   def round_x_with_direction(x, d)
  252.     round_x(x + (d == 6 ? 0.125 : d == 4 ? -0.125 : 0))
  253.   end
  254.   #--------------------------------------------------------------------------
  255.   # * Overwrite method: round_y_with_direction
  256.   #--------------------------------------------------------------------------
  257.   def round_y_with_direction(y, d)
  258.     round_y(y + (d == 2 ? 0.125 : d == 8 ? -0.125 : 0))
  259.   end
  260.   #--------------------------------------------------------------------------
  261.   # * New method: check_x_with_direction
  262.   #--------------------------------------------------------------------------
  263.   def check_x_with_direction(x, d)
  264.     round_x(x + (d == 6 ? 1 : d == 4 ? -1 : 0))
  265.   end
  266.   #--------------------------------------------------------------------------
  267.   # * New method: check_y_with_direction
  268.   #--------------------------------------------------------------------------
  269.   def check_y_with_direction(y, d)
  270.     round_y(y + (d == 2 ? 1 : d == 8 ? -1 : 0))
  271.   end
  272. end

  273. #==============================================================================
  274. # ** Game_CharacterBase
  275. #------------------------------------------------------------------------------
  276. #  This class deals with characters. Common to all characters, stores basic
  277. # data, such as coordinates and graphics. It's used as a superclass of the
  278. # Game_Character class.
  279. #==============================================================================

  280. class Game_CharacterBase
  281.   #--------------------------------------------------------------------------
  282.   # * Public Instance Variables
  283.   #--------------------------------------------------------------------------
  284.   attr_accessor :next_movement
  285.   attr_accessor :side_collision
  286.   attr_accessor :damage_floor
  287.   attr_accessor :steps
  288.   #--------------------------------------------------------------------------
  289.   # * Overwrite method: region_id
  290.   #--------------------------------------------------------------------------
  291.   def region_id
  292.     $game_map.region_id((@x - 0.5).ceil, (@y - 0.125).ceil)
  293.   end
  294.   #--------------------------------------------------------------------------
  295.   # * Overwrite method: collide_with_events?
  296.   #--------------------------------------------------------------------------
  297.   def collide_with_events?(x, y)
  298.     $game_map.events_xy_nt(x, y).any? do |event|
  299.       event.collision_condition?(x, y, bw, bh, event?, @id, @side_collision)
  300.     end
  301.   end
  302.   #--------------------------------------------------------------------------
  303.   # * Overwrite method: collide_with_vehicles?
  304.   #--------------------------------------------------------------------------
  305.   def collide_with_vehicles?(x, y)
  306.     $game_map.vehicles.compact.any? do |vehicle|
  307.       next if vehicle.map_id != $game_map.map_id
  308.       vehicle.vehicle_collision?(x, y, bw, bh, self)
  309.     end
  310.   end
  311.   #--------------------------------------------------------------------------
  312.   # * Overwrite method: move_straight
  313.   #--------------------------------------------------------------------------
  314.   def move_straight(d, turn_ok = true)
  315.     @move_list += [{d: [d], turn: turn_ok}] * step_times
  316.   end
  317.   #--------------------------------------------------------------------------
  318.   # * Overwrite method: move_straight
  319.   #--------------------------------------------------------------------------
  320.   def move_diagonal(horz, vert)
  321.     @move_list += [{d: [horz, vert], turn: true}] * step_times
  322.   end
  323.   #--------------------------------------------------------------------------
  324.   # * Alias method: init_public_members
  325.   #--------------------------------------------------------------------------
  326.   alias :init_public_members_ve_pixel_movement :init_public_members
  327.   def init_public_members
  328.     init_public_members_ve_pixel_movement
  329.     @move_list     = []
  330.     @next_movement = []
  331.     @over_event    = 0
  332.     @damage_floor  = 0
  333.     @steps         = 0
  334.   end
  335.   #--------------------------------------------------------------------------
  336.   # * Alias method: update
  337.   #--------------------------------------------------------------------------
  338.   alias :update_ve_pixel_movement :update
  339.   def update
  340.     update_move_straight
  341.     update_move_diagonal
  342.     update_ve_pixel_movement
  343.   end
  344.   #--------------------------------------------------------------------------
  345.   # * New method: update_move_straight
  346.   #--------------------------------------------------------------------------
  347.   def update_move_straight
  348.     return if moving? || @move_list.empty?
  349.     return if @move_list.first[:d].size > 1
  350.     move = @move_list.shift
  351.     d    = move[:d].first
  352.     if passable?(@x, @y, d)
  353.       @diagonal_move = false
  354.       setup_movement(d, d)
  355.       @real_x = $game_map.x_with_direction(@x, reverse_dir(d))
  356.       @real_y = $game_map.y_with_direction(@y, reverse_dir(d))
  357.       @moved  = player?
  358.     elsif move[:turn]
  359.       check_event_trigger_move(d)
  360.     end
  361.   end
  362.   #--------------------------------------------------------------------------
  363.   # * Overwrite method: update_move_diagonal
  364.   #--------------------------------------------------------------------------
  365.   def update_move_diagonal
  366.     return if moving? || @move_list.empty?
  367.     return if @move_list.first[:d].size < 2
  368.     move = @move_list.shift
  369.     horz = move[:d].first
  370.     vert = move[:d].last
  371.     if diagonal_passable?(x, y, horz, vert)
  372.       @diagonal_move = true
  373.       setup_movement(horz, vert)
  374.       @real_x = $game_map.x_with_direction(@x, reverse_dir(horz))
  375.       @real_y = $game_map.y_with_direction(@y, reverse_dir(vert))
  376.       @moved = player?
  377.     end
  378.   end
  379.   #--------------------------------------------------------------------------
  380.   # * New method: character_collision?
  381.   #--------------------------------------------------------------------------
  382.   def character_collision?(x, y, d)
  383.     x2 = $game_map.round_x_with_direction(x, d)
  384.     y2 = $game_map.round_y_with_direction(y, d)
  385.     !collide_with_characters?(x2, y2) || @through || debug_through?
  386.   end
  387.   #--------------------------------------------------------------------------
  388.   # * New method: step_times
  389.   #--------------------------------------------------------------------------
  390.   def step_times
  391.     return 8
  392.   end
  393.   #--------------------------------------------------------------------------
  394.   # * New method: near_nt?
  395.   #--------------------------------------------------------------------------
  396.   def near_nt?(x, y)
  397.     near?(x, y) && !@through
  398.   end
  399.   #--------------------------------------------------------------------------
  400.   # * New method: near?
  401.   #--------------------------------------------------------------------------
  402.   def near?(x, y)
  403.     w = step_over? ? [bw * 0.625, 0.5].max : [bw, 1.0].max
  404.     h = step_over? ? [bh * 0.625, 0.5].max : [bh, 1.0].max
  405.     @real_x > x - w && @real_x < x + w && @real_y > y - h && @real_y < y + h
  406.   end
  407.   #--------------------------------------------------------------------------
  408.   # * New method: setup_movement
  409.   #--------------------------------------------------------------------------
  410.   def setup_movement(horz, vert)
  411.     @x = $game_map.round_x_with_direction(@x, horz)
  412.     @y = $game_map.round_y_with_direction(@y, vert)
  413.     add_next_movement(horz == vert ? horz : [horz, vert])
  414.     set_direction(horz) if @direction == reverse_dir(horz) || horz == vert
  415.     set_direction(vert) if @direction == reverse_dir(vert) && horz != vert
  416.     follower_control_move_update(horz, vert)
  417.     increase_steps
  418.   end
  419.   #--------------------------------------------------------------------------
  420.   # * New method: check_event_trigger_move
  421.   #--------------------------------------------------------------------------
  422.   def check_event_trigger_move(d)
  423.     set_direction(d)
  424.     check_event_trigger_touch_front
  425.   end
  426.   #--------------------------------------------------------------------------
  427.   # * New method: collision_condition?
  428.   #--------------------------------------------------------------------------
  429.   def collision_condition?(x, y, bw, bh, event, event_id, side)
  430.     return false if event && self.id == event_id
  431.     return false unless collision?(x, y, bw, bh)
  432.     return false unless normal_priority? || event
  433.     return false if side && !side_collision?
  434.     return true
  435.   end
  436.   #--------------------------------------------------------------------------
  437.   # * New method: follower_control_move_update
  438.   #--------------------------------------------------------------------------
  439.   def follower_control_move_update(horz, vert)
  440.     return unless $imported[:ve_followers_options]
  441.     return unless player? || follower?
  442.     add_move_update(horz == vert ? [horz] : [horz, vert])
  443.   end
  444.   #--------------------------------------------------------------------------
  445.   # * New method: passable?
  446.   #--------------------------------------------------------------------------
  447.   def passable?(x, y, d)
  448.     x = fix_position(x)
  449.     y = fix_position(y)
  450.     passable1 = passable_tile?(x, y, d)
  451.     passable2 = character_collision?(x, y, d)
  452.     fix_movement(x, y, d)  if player? && !passable1 && passable2
  453.     fix_collision(x, y, d) if player? && !passable2 && passable1
  454.     passable1 && passable2
  455.   end
  456.   #--------------------------------------------------------------------------
  457.   # * New method: passable_tile?
  458.   #--------------------------------------------------------------------------
  459.   def passable_tile?(x, y, d)
  460.     result = true
  461.     result = passable_down?(x, y)  if d == 2
  462.     result = passable_left?(x, y)  if d == 4
  463.     result = passable_right?(x, y) if d == 6
  464.     result = passable_up?(x, y)    if d == 8
  465.     result
  466.   end
  467.   #--------------------------------------------------------------------------
  468.   # * New method: locked_tile?
  469.   #--------------------------------------------------------------------------
  470.   def locked_tile?(x, y, d = 0)
  471.     list = [2, 4, 6, 8] - [d]
  472.     list.all? {|d| !map_passable?(x, y, d) }
  473.   end
  474.   #--------------------------------------------------------------------------
  475.   # * New method: locked_move?
  476.   #--------------------------------------------------------------------------
  477.   def locked_move?(x, y)
  478.     !passable_down?(x, y)  && !passable_left?(x, y)
  479.     !passable_right?(x, y) && !passable_up?(x, y)
  480.   end
  481.   #--------------------------------------------------------------------------
  482.   # * New method: passable_down?
  483.   #--------------------------------------------------------------------------
  484.   def passable_down?(x, y)
  485.     passable_normal?(x.ceil, y.to_i, 2, 4, x.ceil?) &&
  486.     passable_normal?(x.to_i, y.to_i, 2, 6, x.ceil?)
  487.   end
  488.   #--------------------------------------------------------------------------
  489.   # * New method: passable_left?
  490.   #--------------------------------------------------------------------------
  491.   def passable_left?(x, y)
  492.     passable_normal?(x.ceil, y.ceil, 4, 8, y.ceil?) &&
  493.     passable_normal?(x.ceil, y.to_i, 4, 2, y.ceil?)
  494.   end
  495.   #--------------------------------------------------------------------------
  496.   # * New method: passable_right?
  497.   #--------------------------------------------------------------------------
  498.   def passable_right?(x, y)
  499.     passable_normal?(x.to_i, y.ceil, 6, 8, y.ceil?) &&
  500.     passable_normal?(x.to_i, y.to_i, 6, 2, y.ceil?)
  501.   end
  502.   #--------------------------------------------------------------------------
  503.   # * New method: passable_up?
  504.   #--------------------------------------------------------------------------
  505.   def passable_up?(x, y)
  506.     passable_normal?(x.ceil, y.ceil, 8, 4, x.ceil?) &&
  507.     passable_normal?(x.to_i, y.ceil, 8, 6, x.ceil?)
  508.   end
  509.   #--------------------------------------------------------------------------
  510.   # * New method: passable_normal?
  511.   #--------------------------------------------------------------------------
  512.   def passable_normal?(x, y, d, d2, ceil = false)
  513.     x1 = $game_map.round_x(x)
  514.     y1 = $game_map.round_y(y)
  515.     x2 = $game_map.check_x_with_direction(x1, d)
  516.     y2 = $game_map.check_y_with_direction(y1, d)
  517.     x3 = $game_map.round_x_with_direction(x1, d)
  518.     y3 = $game_map.round_y_with_direction(y1, d)
  519.     return false unless $game_map.valid?(x3, y3)
  520.     return true  if @through || debug_through?
  521.     return false unless map_passable?(x2, y2, d2) || !ceil
  522.     return false unless move_passable1?(x1, y1, x2, y2, d)
  523.     return false unless move_passable2?(x1, y1, x2, y2, d)
  524.     return true
  525.   end
  526.   #--------------------------------------------------------------------------
  527.   # * New method: move_passable1?
  528.   #--------------------------------------------------------------------------
  529.   def move_passable1?(x1, y1, x2, y2, d)
  530.     map_passable?(x1, y1, d) || map_passable?(x2, y2, d)
  531.   end
  532.   #--------------------------------------------------------------------------
  533.   # * New method: move_passable?
  534.   #--------------------------------------------------------------------------
  535.   def move_passable2?(x1, y1, x2, y2, d)
  536.     map_passable?(x2, y2, reverse_dir(d)) && (map_passable?(x1, y1, d) ||
  537.     locked_tile?(x1, y1))
  538.   end
  539.   #--------------------------------------------------------------------------
  540.   # * New method: fix_movement
  541.   #--------------------------------------------------------------------------
  542.   def fix_movement(x, y, d)
  543.     return if (@diagonal && @diagonal != 0) || @diagonal_move
  544.     fix_movement_horiz(x, y, d) if (d == 2 || d == 8) && x.ceil?
  545.     fix_movement_vert(x, y, d)  if (d == 4 || d == 6) && y.ceil?
  546.   end
  547.   #--------------------------------------------------------------------------
  548.   # * New method: fix_movement_horiz
  549.   #--------------------------------------------------------------------------
  550.   def fix_movement_horiz(x, y, d)
  551.     adjust = x - x.to_i
  552.     fix_move_straight(4) if fix_movement_left?(x, y, d)  && adjust < 0.5
  553.     fix_move_straight(6) if fix_movement_right?(x, y, d) && adjust > 0.5
  554.   end
  555.   #--------------------------------------------------------------------------
  556.   # * New method: fix_movement_ver
  557.   #--------------------------------------------------------------------------
  558.   def fix_movement_vert(x, y, d)
  559.     adjust = y - y.to_i
  560.     fix_move_straight(2) if fix_movement_down?(x, y, d) && adjust > 0.5
  561.     fix_move_straight(8) if fix_movement_up?(x, y, d)   && adjust < 0.5
  562.   end
  563.   #--------------------------------------------------------------------------
  564.   # * New method: fix_movement_down?
  565.   #--------------------------------------------------------------------------
  566.   def fix_movement_down?(x, y, d)
  567.     passable_normal?(x.to_i, y.ceil, d, 0, false) && movement_fix?(x, y, 2)
  568.   end
  569.   #--------------------------------------------------------------------------
  570.   # * New method: fix_movement_left?
  571.   #--------------------------------------------------------------------------
  572.   def fix_movement_left?(x, y, d)
  573.     passable_normal?(x.to_i, y.to_i, d, 0, false) && movement_fix?(x, y, 4)
  574.   end
  575.   #--------------------------------------------------------------------------
  576.   # * New method: fix_movement_right?
  577.   #--------------------------------------------------------------------------
  578.   def fix_movement_right?(x, y, d)
  579.     passable_normal?(x.ceil, y.to_i, d, 0, false) && movement_fix?(x, y, 6)
  580.   end
  581.   #--------------------------------------------------------------------------
  582.   # * New method: fix_movement_up?
  583.   #--------------------------------------------------------------------------
  584.   def fix_movement_up?(x, y, d)
  585.     passable_normal?(x.to_i, y.to_i, d, 0, false) && movement_fix?(x, y, 8)
  586.   end
  587.   #--------------------------------------------------------------------------
  588.   # * New method: movement_fix?
  589.   #--------------------------------------------------------------------------
  590.   def movement_fix?(x, y, d)
  591.     passable_tile?(x, y, d) && character_collision?(x, y, d)
  592.   end
  593.   #--------------------------------------------------------------------------
  594.   # * New method: fix_collision
  595.   #--------------------------------------------------------------------------
  596.   def fix_collision(x, y, d)
  597.     return if (@diagonal && @diagonal != 0) || @diagonal_move
  598.     @side_collision = true
  599.     fix_collision_horiz(x, y, d) if (d == 2 || d == 8)
  600.     fix_collision_vert(x, y, d)  if (d == 4 || d == 6)
  601.     @side_collision = false
  602.   end
  603.   #--------------------------------------------------------------------------
  604.   # * New method: fix_collision_horiz
  605.   #--------------------------------------------------------------------------
  606.   def fix_collision_horiz(x, y, d)
  607.     fix_move_straight(4) if fix_collision_left?(x, y, d)
  608.     fix_move_straight(6) if fix_collision_right?(x, y, d)
  609.   end
  610.   #--------------------------------------------------------------------------
  611.   # * New method: fix_collision_vert
  612.   #--------------------------------------------------------------------------
  613.   def fix_collision_vert(x, y, d)
  614.     fix_move_straight(2) if fix_collision_down?(x, y, d)
  615.     fix_move_straight(8) if fix_collision_up?(x, y, d)
  616.   end
  617.   #--------------------------------------------------------------------------
  618.   # * New method: fix_collision_down?
  619.   #--------------------------------------------------------------------------
  620.   def fix_collision_down?(x, y, d)
  621.     !character_collision?(x, y, d) && collision_fix?(x, y, d, 2)
  622.   end
  623.   #--------------------------------------------------------------------------
  624.   # * New method: fix_collision_left?
  625.   #--------------------------------------------------------------------------
  626.   def fix_collision_left?(x, y, d)
  627.     !character_collision?(x, y, d) && collision_fix?(x, y, d,  4)
  628.   end
  629.   #--------------------------------------------------------------------------
  630.   # * New method: fix_collision_right?
  631.   #--------------------------------------------------------------------------
  632.   def fix_collision_right?(x, y, d)
  633.     !character_collision?(x, y, d) && collision_fix?(x, y, d, 6)
  634.   end
  635.   #--------------------------------------------------------------------------
  636.   # * New method: fix_collision_up?
  637.   #--------------------------------------------------------------------------
  638.   def fix_collision_up?(x, y, d)
  639.     !character_collision?(x, y, d) && collision_fix?(x, y, d, 8)
  640.   end
  641.   #--------------------------------------------------------------------------
  642.   # * New method: collision_fix?
  643.   #--------------------------------------------------------------------------
  644.   def collision_fix?(x, y, d, d2)
  645.     side_collision_fix?(x, y, d, d2, 2) && side_fix?(x, y, d2)
  646.   end
  647.   #--------------------------------------------------------------------------
  648.   # * New method: side_collision_fix?
  649.   #--------------------------------------------------------------------------
  650.   def side_collision_fix?(x, y, d, d2, t)
  651.     t.times.any? do |i|
  652.       x2, y2 = x, y
  653.       y2 += (t - i) * 0.125 if d2 == 2
  654.       x2 -= (t - i) * 0.125 if d2 == 4
  655.       x2 += (t - i) * 0.125 if d2 == 6
  656.       y2 -= (t - i) * 0.125 if d2 == 8
  657.       character_collision?(x2, y2, d)
  658.     end
  659.   end
  660.   #--------------------------------------------------------------------------
  661.   # * New method: side_fix?
  662.   #--------------------------------------------------------------------------
  663.   def side_fix?(x, y, d)
  664.     passable_tile?(x, y, d) && character_collision?(x, y, d)
  665.   end
  666.   #--------------------------------------------------------------------------
  667.   # * New method: fix_move_straight
  668.   #--------------------------------------------------------------------------
  669.   def fix_move_straight(d)
  670.     return if moving?
  671.     @x = $game_map.round_x_with_direction(@x, d)
  672.     @y = $game_map.round_y_with_direction(@y, d)
  673.     follower_control_move_update(d, d)
  674.     add_next_movement(d)
  675.     increase_steps
  676.     @moved = player?
  677.   end
  678.   #--------------------------------------------------------------------------
  679.   # * New method: add_next_movement
  680.   #--------------------------------------------------------------------------
  681.   def add_next_movement(d)
  682.     return unless follower? || player?
  683.     return if $imported[:ve_followers_control] && follower_control_block
  684.     return if $game_player.followers.gathering?
  685.     @next_movement.push(d)
  686.   end
  687.   #--------------------------------------------------------------------------
  688.   # * New method: follower_control_block
  689.   #--------------------------------------------------------------------------
  690.   def follower_control_block
  691.     return true if follower? && origin_position
  692.     return true if $game_player.followers.gathering_origin?
  693.     return false
  694.   end
  695.   #--------------------------------------------------------------------------
  696.   # * New method: front_collision?
  697.   #--------------------------------------------------------------------------
  698.   def front_collision?(x, y, d)
  699.     return false if (@diagonal && @diagonal != 0) || @diagonal_move
  700.     result = !front_collision_horiz(x, y, d) if (d == 2 || d == 8)
  701.     result = !front_collision_vert(x, y, d)  if (d == 4 || d == 6)
  702.     result
  703.   end
  704.   #--------------------------------------------------------------------------
  705.   # * New method: front_collision_horiz
  706.   #--------------------------------------------------------------------------
  707.   def front_collision_horiz(x, y, d)
  708.     side_collision_fix?(x, y, d, 4, 4) || side_collision_fix?(x, y, d, 6, 4)
  709.   end
  710.   #--------------------------------------------------------------------------
  711.   # * New method: front_collision_vert
  712.   #--------------------------------------------------------------------------
  713.   def front_collision_vert(x, y, d)
  714.     side_collision_fix?(x, y, d, 2, 4) || side_collision_fix?(x, y, d, 8, 4)
  715.   end
  716.   #--------------------------------------------------------------------------
  717.   # * New method: step_over?
  718.   #--------------------------------------------------------------------------
  719.   def step_over?
  720.     @through
  721.   end
  722.   #--------------------------------------------------------------------------
  723.   # * New method: bw
  724.   #--------------------------------------------------------------------------
  725.   def bw
  726.     setup_bitmap_dimension unless @bw && character_name == @character_name_wh
  727.     @bw
  728.   end
  729.   #--------------------------------------------------------------------------
  730.   # * New method: bh
  731.   #--------------------------------------------------------------------------
  732.   def bh
  733.     setup_bitmap_dimension unless @bh && character_name == @character_name_wh
  734.     @bh
  735.   end
  736.   #--------------------------------------------------------------------------
  737.   # * New method: setup_bitmap_dimension
  738.   #--------------------------------------------------------------------------
  739.   def setup_bitmap_dimension
  740.     @character_name_wh = character_name
  741.     bitmap = Cache.character(character_name).clone
  742.     sign = @character_name[/^[\!\$]./]
  743.     if character_name != "" && @tile_id == 0 && sign && sign.include?('[code]#==============================================================================
  744. # ** Victor Engine - Basic Module
  745. #------------------------------------------------------------------------------
  746. # Author : Victor Sant
  747. #
  748. # Version History:
  749. #  v 1.00 - 2011.12.19 > First relase
  750. #  v 1.01 - 2011.12.21 > Added Event Troop notes
  751. #  v 1.02 - 2011.12.22 > Added character frames value
  752. #  v 1.03 - 2011.12.30 > Added Actor and Enemy notes
  753. #  v 1.04 - 2012.01.01 > Added party average level and map actors
  754. #  v 1.05 - 2012.01.04 > Compatibility with Characters Scripts
  755. #  v 1.06 - 2012.01.07 > Compatibility with Fog and Light Effect
  756. #                      > Added new Sprite Character functions
  757. #  v 1.07 - 2012.01.11 > Compatibility with Control Text and Codes
  758. #  v 1.08 - 2012.01.13 > Compatibility with Trait Control
  759. #  v 1.09 - 2012.01.15 > Fixed the Regular Expressions problem with "" and “”
  760. #  v 1.10 - 2012.01.18 > Compatibility with Automatic Battlers
  761. #  v 1.11 - 2012.01.26 > Compatibility with Followers Options
  762. #                        Compatibility with Animated Battle beta
  763. #  v 1.12 - 2012.02.08 > Compatibility with Animated Battle
  764. #  v 1.13 - 2012.02.18 > Fix for non RTP dependant encrypted projects
  765. #  v 1.14 - 2012.03.11 > Better version handling and required messages
  766. #  v 1.15 - 2012.03.11 > Added level variable for enemies (to avoid crashes)
  767. #  v 1.16 - 2012.03.21 > Compatibility with Follower Control
  768. #  v 1.17 - 2012.03.22 > Compatibility with Follower Control new method
  769. #  v 1.18 - 2012.03.22 > Added Battler Types tag support
  770. #  v 1.19 - 2012.05.20 > Compatibility with Map Turn Battle
  771. #  v 1.20 - 2012.05.21 > Fix for older RMVXa versions
  772. #  v 1.21 - 2012.05.29 > Compatibility with Pixel Movement
  773. #  v 1.22 - 2012.07.02 > Compatibility with Terrain States
  774. #  v 1.23 - 2012.07.03 > Fix for Pixel Movement
  775. #  v 1.24 - 2012.07.17 > Compatibility with Critical Hit Effects
  776. #  v 1.25 - 2012.07.24 > Compatibility with Moving Plaforms
  777. #  v 1.26 - 2012.07.30 > Compatibility with Automatic Battlers
  778. #  v 1.27 - 2012.08.01 > Compatibility with Custom Slip Effect
  779. #  v 1.28 - 2012.08.03 > Compatibility with Custom Slip Effect v 1.01
  780. #------------------------------------------------------------------------------
  781. #   This is the basic script for the system from Victory Engine and is
  782. # required to use the scripts from the engine. This script offer some new
  783. # functions to be used within many scripts of the engine.
  784. #------------------------------------------------------------------------------
  785. # Compatibility
  786. #   Required for the Victor Engine
  787. #
  788. # * Overwrite methods
  789. #   class << Cache
  790. #     def self.character(filename)
  791. #
  792. #   class Sprite_Character < Sprite_Base
  793. #     def set_character_bitmap
  794. #
  795. # * Alias methods
  796. #   class Game_Interpreter
  797. #     def command_108
  798. #
  799. #   class Window_Base < Window
  800. #     def convert_escape_characters(text)
  801. #
  802. #------------------------------------------------------------------------------
  803. # Instructions:
  804. #  To instal the script, open you script editor and paste this script on
  805. #  a new section bellow the Materials section.
  806. #
  807. #------------------------------------------------------------------------------
  808. # New functions
  809. #
  810. # * Random number between two vales
  811. #   rand_between(min, max)
  812. #    min : min value
  813. #    max : max value
  814. #   Can be called from any class, this method return an random value between
  815. #   two specific numbers
  816. #
  817. # * Random array value
  818. #   <Array>.random
  819. #   <Array>.random!
  820. #   Returns a random object from the array, the method .random! is destructive,
  821. #   removing the value returned from the array.
  822. #
  823. # * Sum of the numeric values of a array
  824. #   <Array>.sum
  825. #   Returns the sum of all numeric values
  826. #
  827. # * Average of all numeric values from the array
  828. #   <Array>.average(float = false)
  829. #    float : float flag
  830. #   Returns the average of all numeric values, if floa is true, the value
  831. #   returned is a float, otherwise it's a integer.
  832. #
  833. # * Note for events
  834. #   <Event>.note
  835. #   By default, events doesn't have note boxes. This command allows to use
  836. #   comments as note boxes, following the same format as the ones on the
  837. #   database. Returns all comments on the active page of the event.
  838. #
  839. # * Comment calls
  840. #   <Event>.comment_call
  841. #   Another function for comment boxes, by default, they have absolutely no
  842. #   effect in game when called. But this method allows to make the comment
  843. #   box to behave like an script call, but with the versatility of the
  844. #   note boxes. Remember that the commands will only take effect if there
  845. #   is scripts to respond to the comment code.
  846. #
  847. #==============================================================================

  848. #==============================================================================
  849. # ** Victor Engine
  850. #------------------------------------------------------------------------------
  851. #   Setting module for the Victor Engine
  852. #==============================================================================

  853. module Victor_Engine
  854.   #--------------------------------------------------------------------------
  855.   # * New method: required_script
  856.   #--------------------------------------------------------------------------
  857.   def self.required_script(name, req, version, type = 0)
  858.     if type != :bellow && (!$imported[req] || $imported[req] < version)
  859.       msg = "The script '%s' requires the script\n"
  860.       case type
  861.       when :above
  862.         msg += "'%s' v%s or higher above it to work properly\n"
  863.       else
  864.         msg += "'%s' v%s or higher to work properly\n"
  865.       end
  866.       msg += "Go to http://victorscripts.wordpress.com/ to download this script."
  867.       self.exit_message(msg, name, req, version)
  868.     elsif type == :bellow && $imported[req]
  869.       msg =  "The script '%s' requires the script\n"
  870.       msg += "'%s' to be put bellow it\n"
  871.       msg += "move the scripts to the proper position"
  872.       self.exit_message(msg, name, req, version)
  873.     end
  874.   end
  875.   #--------------------------------------------------------------------------
  876.   # * New method: exit_message
  877.   #--------------------------------------------------------------------------
  878.   def self.exit_message(message, name, req, version)
  879.     name = self.script_name(name)
  880.     req  = self.script_name(req)
  881.     msgbox(sprintf(message, name, req, version))
  882.     exit
  883.   end
  884.   #--------------------------------------------------------------------------
  885.   # * New method: script_name
  886.   #--------------------------------------------------------------------------
  887.   def self.script_name(name, ext = "VE")
  888.     name = name.to_s.gsub("_", " ").upcase.split
  889.     name.collect! {|char| char == ext ? "#{char} -" : char.capitalize }
  890.     name.join(" ")
  891.   end
  892. end

  893. $imported ||= {}
  894. $imported[:ve_basic_module] = 1.28

  895. #==============================================================================
  896. # ** Object
  897. #------------------------------------------------------------------------------
  898. #  This class is the superclass of all other classes.
  899. #==============================================================================

  900. class Object
  901.   #--------------------------------------------------------------------------
  902.   # * Include setting module
  903.   #--------------------------------------------------------------------------
  904.   include Victor_Engine
  905.   #-------------------------------------------------------------------------
  906.   # * New method: rand_between
  907.   #-------------------------------------------------------------------------
  908.   def rand_between(min, max)
  909.     min + rand(max - min + 1)
  910.   end
  911.   #--------------------------------------------------------------------------
  912.   # * New method: numeric?
  913.   #--------------------------------------------------------------------------
  914.   def numeric?
  915.     return false
  916.   end
  917.   #--------------------------------------------------------------------------
  918.   # * New method: string?
  919.   #--------------------------------------------------------------------------
  920.   def string?
  921.     return false
  922.   end
  923.   #--------------------------------------------------------------------------
  924.   # * New method: array?
  925.   #--------------------------------------------------------------------------
  926.   def array?
  927.     return false
  928.   end
  929.   #--------------------------------------------------------------------------
  930.   # * New method: float?
  931.   #--------------------------------------------------------------------------
  932.   def float?
  933.     return false
  934.   end
  935.   #--------------------------------------------------------------------------
  936.   # * New method: item?
  937.   #--------------------------------------------------------------------------
  938.   def item?
  939.     return false
  940.   end
  941.   #--------------------------------------------------------------------------
  942.   # * New method: skill?
  943.   #--------------------------------------------------------------------------
  944.   def skill?
  945.     return false
  946.   end
  947.   #--------------------------------------------------------------------------
  948.   # * New method: file_exist?
  949.   #--------------------------------------------------------------------------
  950.   def file_exist?(path, filename)
  951.     $file_list ||= {}
  952.     $file_list[path + filename] ||= file_test(path, filename)
  953.     $file_list[path + filename]
  954.   end
  955.   #--------------------------------------------------------------------------
  956.   # * New method: get_file_list
  957.   #--------------------------------------------------------------------------
  958.   def file_test(path, filename)
  959.     bitmap = Cache.load_bitmap(path, filename) rescue nil
  960.     bitmap ? true : false
  961.   end
  962.   #--------------------------------------------------------------------------
  963.   # * New method: character_exist?
  964.   #--------------------------------------------------------------------------
  965.   def character_exist?(filename)
  966.     file_exist?("Graphics/Characters/", filename)
  967.   end
  968.   #--------------------------------------------------------------------------
  969.   # * New method: battler_exist?
  970.   #--------------------------------------------------------------------------
  971.   def battler_exist?(filename)
  972.     file_exist?("Graphics/Battlers/", filename)
  973.   end
  974.   #--------------------------------------------------------------------------
  975.   # * New method: get_filename
  976.   #--------------------------------------------------------------------------
  977.   def get_filename
  978.     "[\"'“‘]([^\"'”‘”’]+)[\"'”’]"
  979.   end
  980.   #--------------------------------------------------------------------------
  981.   # * New method: get_all_values
  982.   #--------------------------------------------------------------------------
  983.   def get_all_values(value1, value2 = nil)
  984.     value2 = value1 unless value2
  985.     /<#{value1}>((?:[^<]|<[^\/])*)<\/#{value2}>/im
  986.   end
  987.   #--------------------------------------------------------------------------
  988.   # * New method: make_symbol
  989.   #--------------------------------------------------------------------------
  990.   def make_symbol(string)
  991.     string.downcase.gsub(" ", "_").to_sym
  992.   end
  993.   #--------------------------------------------------------------------------
  994.   # * New method: make_string
  995.   #--------------------------------------------------------------------------
  996.   def make_string(symbol)
  997.     symbol.to_s.gsub("_", " ").upcase
  998.   end
  999.   #--------------------------------------------------------------------------
  1000.   # * New method: returing_value
  1001.   #--------------------------------------------------------------------------
  1002.   def returing_value(i, x)
  1003.     i % (x * 2) >= x ? (x * 2) - i % (x * 2) : i % (x * 2)
  1004.   end
  1005.   #--------------------------------------------------------------------------
  1006.   # New method: in_rect?
  1007.   #--------------------------------------------------------------------------
  1008.   def in_rect?(w, h, x1, y1, x2, y2, fx = 0)
  1009.     aw, ah, ax, ay, bx, by = setup_area(w, h, x1, y1, x2, y2, fx)
  1010.     bx > ax - aw && bx < ax + aw && by > ay - ah && by < ay + ah
  1011.   end
  1012.   #--------------------------------------------------------------------------
  1013.   # New method: in_radius?
  1014.   #--------------------------------------------------------------------------
  1015.   def in_radius?(w, h, x1, y1, x2, y2, fx = 0)
  1016.     aw, ah, ax, ay, bx, by = setup_area(w, h, x1, y1, x2, y2, fx)
  1017.     ((bx - ax) ** 2 / aw ** 2) + ((by - ay) ** 2 / ah ** 2) <= 1
  1018.   end
  1019.   #--------------------------------------------------------------------------
  1020.   # New method: setup_area
  1021.   #--------------------------------------------------------------------------
  1022.   def setup_area(w, h, x1, y1, x2, y2, fx)
  1023.     aw = w
  1024.     ah = h * aw
  1025.     ax = x1
  1026.     ay = y1
  1027.     bx = x2
  1028.     by = y2
  1029.     bx += fx / 4 if ax > bx
  1030.     bx -= fx / 4 if ax < bx
  1031.     [aw, ah, ax, ay, bx, by]
  1032.   end
  1033. end

  1034. #==============================================================================
  1035. # ** String
  1036. #------------------------------------------------------------------------------
  1037. # The string class. Can handle character sequences of arbitrary lengths.
  1038. #==============================================================================

  1039. class String
  1040.   #--------------------------------------------------------------------------
  1041.   # * New method: string?
  1042.   #--------------------------------------------------------------------------
  1043.   def string?
  1044.     return true
  1045.   end
  1046. end

  1047. #==============================================================================
  1048. # ** Numeric
  1049. #------------------------------------------------------------------------------
  1050. #  This is the abstract class for numbers.
  1051. #==============================================================================

  1052. class Numeric
  1053.   #--------------------------------------------------------------------------
  1054.   # * New method: numeric?
  1055.   #--------------------------------------------------------------------------
  1056.   def numeric?
  1057.     return true
  1058.   end
  1059.   #--------------------------------------------------------------------------
  1060.   # * New method: ceil?
  1061.   #--------------------------------------------------------------------------
  1062.   def ceil?
  1063.     return false
  1064.   end
  1065. end

  1066. #==============================================================================
  1067. # ** Float
  1068. #------------------------------------------------------------------------------
  1069. #  This is the abstract class for the floating point values.
  1070. #==============================================================================

  1071. class Float
  1072.   #--------------------------------------------------------------------------
  1073.   # * New method: float?
  1074.   #--------------------------------------------------------------------------
  1075.   def float?
  1076.     return true
  1077.   end
  1078.   #--------------------------------------------------------------------------
  1079.   # * New method: ceil?
  1080.   #--------------------------------------------------------------------------
  1081.   def ceil?
  1082.     self != self.ceil
  1083.   end
  1084. end

  1085. #==============================================================================
  1086. # ** Array     
  1087. #------------------------------------------------------------------------------
  1088. #  This class store arbitrary Ruby objects.
  1089. #==============================================================================

  1090. class Array
  1091.   #--------------------------------------------------------------------------
  1092.   # * New method: array?
  1093.   #--------------------------------------------------------------------------
  1094.   def array?
  1095.     return true
  1096.   end
  1097.   #-------------------------------------------------------------------------
  1098.   # * New method: random
  1099.   #-------------------------------------------------------------------------
  1100.   def random
  1101.     self[rand(size)]
  1102.   end
  1103.   #-------------------------------------------------------------------------
  1104.   # * New method: random!
  1105.   #-------------------------------------------------------------------------
  1106.   def random!
  1107.     self.delete_at(rand(size))
  1108.   end
  1109.   #---------------------------------------------------------------------------
  1110.   # * New method: sum
  1111.   #---------------------------------------------------------------------------
  1112.   def sum
  1113.     self.inject(0) {|r, n| r += (n.numeric? ? n : 0)}
  1114.   end
  1115.   #---------------------------------------------------------------------------
  1116.   # * New method: average
  1117.   #---------------------------------------------------------------------------
  1118.   def average(float = false)
  1119.     self.sum / [(float ? size.to_f : size.to_i), 1].max
  1120.   end
  1121.   #---------------------------------------------------------------------------
  1122.   # * New method: next_item
  1123.   #---------------------------------------------------------------------------
  1124.   def next_item
  1125.     item = self.shift
  1126.     self.push(item)
  1127.     item
  1128.   end
  1129.   #---------------------------------------------------------------------------
  1130.   # * New method: previous_item
  1131.   #---------------------------------------------------------------------------
  1132.   def previous_item
  1133.     item = self.pop
  1134.     self.unshift(item)
  1135.     item
  1136.   end
  1137. end

  1138. #==============================================================================
  1139. # ** RPG::Troop::Page
  1140. #------------------------------------------------------------------------------
  1141. #  This is the data class for battle events (pages).
  1142. #==============================================================================

  1143. class RPG::Troop::Page
  1144.   #--------------------------------------------------------------------------
  1145.   # * New method: note
  1146.   #--------------------------------------------------------------------------
  1147.   def note
  1148.     return "" if !@list || @list.size <= 0
  1149.     comment_list = []
  1150.     @list.each do |item|
  1151.       next unless item && (item.code == 108 || item.code == 408)
  1152.       comment_list.push(item.parameters[0])
  1153.     end
  1154.     comment_list.join("\r\n")
  1155.   end
  1156. end

  1157. #==============================================================================
  1158. # ** RPG::UsableItem
  1159. #------------------------------------------------------------------------------
  1160. #  This is the superclass for skills and items.
  1161. #==============================================================================

  1162. class RPG::UsableItem < RPG::BaseItem
  1163.   #--------------------------------------------------------------------------
  1164.   # * New method: for_all_targets?
  1165.   #--------------------------------------------------------------------------
  1166.   def for_all_targets?
  1167.     return false
  1168.   end
  1169. end

  1170. #==============================================================================
  1171. # ** RPG::Skill
  1172. #------------------------------------------------------------------------------
  1173. #  This is the data class for skills.
  1174. #==============================================================================

  1175. class RPG::Skill < RPG::UsableItem
  1176.   #--------------------------------------------------------------------------
  1177.   # * New method: item?
  1178.   #--------------------------------------------------------------------------
  1179.   def item?
  1180.     return false
  1181.   end
  1182.   #--------------------------------------------------------------------------
  1183.   # * New method: skill?
  1184.   #--------------------------------------------------------------------------
  1185.   def skill?
  1186.     return true
  1187.   end
  1188.   #--------------------------------------------------------------------------
  1189.   # * New method: type_set
  1190.   #--------------------------------------------------------------------------
  1191.   def type_set
  1192.     [stype_id]
  1193.   end  
  1194. end

  1195. #==============================================================================
  1196. # ** RPG::Item
  1197. #------------------------------------------------------------------------------
  1198. #  This is the data class for items.
  1199. #==============================================================================

  1200. class RPG::Item < RPG::UsableItem
  1201.   #--------------------------------------------------------------------------
  1202.   # * New method: item?
  1203.   #--------------------------------------------------------------------------
  1204.   def item?
  1205.     return true
  1206.   end
  1207.   #--------------------------------------------------------------------------
  1208.   # * New method: skill?
  1209.   #--------------------------------------------------------------------------
  1210.   def skill?
  1211.     return false
  1212.   end
  1213.   #--------------------------------------------------------------------------
  1214.   # * New method: type_set
  1215.   #--------------------------------------------------------------------------
  1216.   def type_set
  1217.     [itype_id]
  1218.   end  
  1219. end

  1220. #==============================================================================
  1221. # ** Cache
  1222. #------------------------------------------------------------------------------
  1223. #  This module loads each of graphics, creates a Bitmap object, and retains it.
  1224. # To speed up load times and conserve memory, this module holds the created
  1225. # Bitmap object in the internal hash, allowing the program to return
  1226. # preexisting objects when the same bitmap is requested again.
  1227. #==============================================================================

  1228. class << Cache
  1229.   #--------------------------------------------------------------------------
  1230.   # * Overwrite method: character
  1231.   #--------------------------------------------------------------------------
  1232.   def character(filename, hue = 0)
  1233.     load_bitmap("Graphics/Characters/", filename, hue)
  1234.   end
  1235.   #--------------------------------------------------------------------------
  1236.   # * New method: cache
  1237.   #--------------------------------------------------------------------------
  1238.   def cache
  1239.     @cache
  1240.   end
  1241. end

  1242. #==============================================================================
  1243. # ** Game_BattlerBase
  1244. #------------------------------------------------------------------------------
  1245. #  This class handles battlers. It's used as a superclass of the Game_Battler
  1246. # classes.
  1247. #==============================================================================

  1248. class Game_BattlerBase
  1249.   #--------------------------------------------------------------------------
  1250.   # * Public Instance Variables
  1251.   #--------------------------------------------------------------------------
  1252.   attr_reader   :buffs
  1253.   #--------------------------------------------------------------------------
  1254.   # * New method: get_cond
  1255.   #--------------------------------------------------------------------------
  1256.   def get_cond(text)
  1257.     case text.upcase
  1258.     when "HIGHER"    then ">"
  1259.     when "LOWER"     then "<"
  1260.     when "EQUAL"     then "=="
  1261.     when "DIFFERENT" then "!="
  1262.     else "!="
  1263.     end
  1264.   end
  1265.   #--------------------------------------------------------------------------
  1266.   # * New method: get_param
  1267.   #--------------------------------------------------------------------------
  1268.   def get_param(text)
  1269.     case text.upcase
  1270.     when "MAXHP" then self.mhp
  1271.     when "MAXMP" then self.mmp
  1272.     when "MAXTP" then self.max_tp
  1273.     else eval("self.#{text.downcase}")
  1274.     end
  1275.   end
  1276.   #--------------------------------------------------------------------------
  1277.   # * New method: get_param_id
  1278.   #--------------------------------------------------------------------------
  1279.   def get_param_id(text)
  1280.     case text.upcase
  1281.     when "MAXHP", "HP" then 0
  1282.     when "MAXMP", "MP" then 1
  1283.     when "ATK" then 2
  1284.     when "DEF" then 3
  1285.     when "MAT" then 4
  1286.     when "MDF" then 5
  1287.     when "AGI" then 6
  1288.     when "LUK" then 7
  1289.     end
  1290.   end
  1291.   #--------------------------------------------------------------------------
  1292.   # * New method: type
  1293.   #--------------------------------------------------------------------------
  1294.   def type
  1295.     list = []
  1296.     get_all_notes.scan(/<BATTLER TYPE: ((?:\w+ *,? *)+)>/i) do
  1297.       $1.scan(/(\d+)/i) { list.push(make_symbol($1)) }
  1298.     end
  1299.     list.uniq
  1300.   end
  1301.   #--------------------------------------------------------------------------
  1302.   # * New method: danger?
  1303.   #--------------------------------------------------------------------------
  1304.   def danger?
  1305.     hp < mhp * 25 / 100
  1306.   end
  1307.   #--------------------------------------------------------------------------
  1308.   # * New method: sprite
  1309.   #--------------------------------------------------------------------------
  1310.   def sprite
  1311.     valid = SceneManager.scene_is?(Scene_Battle) && SceneManager.scene.spriteset
  1312.     valid ? SceneManager.scene.spriteset.sprite(self) : nil
  1313.   end
  1314.   #--------------------------------------------------------------------------
  1315.   # * New method:
  1316.   #--------------------------------------------------------------------------
  1317.   def element_set(item)
  1318.     element_set  = [item.damage.element_id]
  1319.     element_set += atk_elements if item.damage.element_id < 0
  1320.     element_set.compact
  1321.   end
  1322.   #--------------------------------------------------------------------------
  1323.   # * New method: add_state_normal
  1324.   #--------------------------------------------------------------------------
  1325.   def add_state_normal(state_id, rate = 1, user = self)
  1326.     chance  = rate
  1327.     chance *= state_rate(state_id)
  1328.     chance *= luk_effect_rate(user)
  1329.     add_state(state_id) if rand < state_rate(state_id)
  1330.   end
  1331.   #--------------------------------------------------------------------------
  1332.   # * New method: damaged?
  1333.   #--------------------------------------------------------------------------
  1334.   def damaged?
  1335.     @result.hp_damage != 0 || @result.mp_damage != 0 || @result.tp_damage != 0
  1336.   end
  1337.   #--------------------------------------------------------------------------
  1338.   # * New method: mtp
  1339.   #--------------------------------------------------------------------------
  1340.   def mtp
  1341.     return 100
  1342.   end
  1343. end

  1344. #==============================================================================
  1345. # ** Game_Battler
  1346. #------------------------------------------------------------------------------
  1347. #  This class deals with battlers. It's used as a superclass of the Game_Actor
  1348. # and Game_Enemy classes.
  1349. #==============================================================================

  1350. class Game_Battler < Game_BattlerBase
  1351.   #--------------------------------------------------------------------------
  1352.   # * New method: cri_rate
  1353.   #--------------------------------------------------------------------------
  1354.   def cri_rate(user, item)
  1355.     user.cri
  1356.   end
  1357.   #--------------------------------------------------------------------------
  1358.   # * New method: cri_eva
  1359.   #--------------------------------------------------------------------------
  1360.   def cri_eva(user, item)
  1361.     cev
  1362.   end
  1363.   #--------------------------------------------------------------------------
  1364.   # * New method: setup_critical
  1365.   #--------------------------------------------------------------------------
  1366.   def setup_critical(user, item)
  1367.     cri_rate(user, item) * (1 - cri_eva(user, item))
  1368.   end
  1369. end

  1370. #==============================================================================
  1371. # ** Game_Enemy
  1372. #------------------------------------------------------------------------------
  1373. #  This class handles enemy characters. It's used within the Game_Troop class
  1374. # ($game_troop).
  1375. #==============================================================================

  1376. class Game_Enemy < Game_Battler
  1377.   #--------------------------------------------------------------------------
  1378.   # * New method: note
  1379.   #--------------------------------------------------------------------------
  1380.   def note
  1381.     enemy ? enemy.note : ""
  1382.   end
  1383.   #--------------------------------------------------------------------------
  1384.   # * New method: get_all_notes
  1385.   #--------------------------------------------------------------------------
  1386.   def get_all_notes(*args)
  1387.     notes  = ""
  1388.     notes += note if !args.include?(:self)
  1389.     states.compact.each {|state| notes += state.note } if !args.include?(:state)
  1390.     notes
  1391.   end
  1392.   #--------------------------------------------------------------------------
  1393.   # * New method: get_all_objects
  1394.   #--------------------------------------------------------------------------
  1395.   def get_all_objects(*args)
  1396.     result = []
  1397.     result += [self] if !args.include?(:self)
  1398.     result += states.compact if !args.include?(:state)
  1399.     result
  1400.   end
  1401.   #--------------------------------------------------------------------------
  1402.   # * New method: level
  1403.   #--------------------------------------------------------------------------
  1404.   def level
  1405.     return 1
  1406.   end
  1407.   #--------------------------------------------------------------------------
  1408.   # * New method: skill_learn?
  1409.   #--------------------------------------------------------------------------
  1410.   def skill_learn?(skill)
  1411.     skill.skill? && skills.include?(skill)
  1412.   end
  1413.   #--------------------------------------------------------------------------
  1414.   # * New method: skills
  1415.   #--------------------------------------------------------------------------
  1416.   def skills
  1417.     enemy.actions.collect {|action| $data_skills[action.skill_id] }
  1418.   end
  1419. end

  1420. #==============================================================================
  1421. # ** Game_Actor
  1422. #------------------------------------------------------------------------------
  1423. #  This class handles actors. It's used within the Game_Actors class
  1424. # ($game_actors) and referenced by the Game_Party class ($game_party).
  1425. #==============================================================================

  1426. class Game_Actor < Game_Battler
  1427.   #--------------------------------------------------------------------------
  1428.   # * New method: note
  1429.   #--------------------------------------------------------------------------
  1430.   def note
  1431.     actor ? actor.note : ""
  1432.   end
  1433.   #--------------------------------------------------------------------------
  1434.   # * New method: hue
  1435.   #--------------------------------------------------------------------------
  1436.   def hue
  1437.     @hue ? @hue : 0
  1438.   end
  1439.   #--------------------------------------------------------------------------
  1440.   # * New method: get_all_notes
  1441.   #--------------------------------------------------------------------------
  1442.   def get_all_notes(*args)
  1443.     notes = ""
  1444.     notes += note if !args.include?(:self)
  1445.     notes += self.class.note if !args.include?(:class)
  1446.     equips.compact.each {|equip| notes += equip.note } if !args.include?(:equip)
  1447.     states.compact.each {|state| notes += state.note } if !args.include?(:state)
  1448.     notes
  1449.   end
  1450.   #--------------------------------------------------------------------------
  1451.   # * New method: get_all_objects
  1452.   #--------------------------------------------------------------------------
  1453.   def get_all_objects(*args)
  1454.     result = []
  1455.     result += [self] if !args.include?(:self)
  1456.     result += [self.class]   if !args.include?(:self)
  1457.     result += equips.compact if !args.include?(:equip)
  1458.     result += states.compact if !args.include?(:state)
  1459.     result
  1460.   end
  1461.   #--------------------------------------------------------------------------
  1462.   # * New method: in_active_party?
  1463.   #--------------------------------------------------------------------------
  1464.   def in_active_party?
  1465.     $game_party.battle_members.include?(self)
  1466.   end
  1467.   #--------------------------------------------------------------------------
  1468.   # * New method: in_reserve_party?
  1469.   #--------------------------------------------------------------------------
  1470.   def in_reserve_party?
  1471.     $game_party.reserve_members.include?(self)
  1472.   end
  1473.   #--------------------------------------------------------------------------
  1474.   # * New method: in_party?
  1475.   #--------------------------------------------------------------------------
  1476.   def in_party?
  1477.     $game_party.all_members.include?(self)
  1478.   end
  1479.   #--------------------------------------------------------------------------
  1480.   # * New method: map_animation
  1481.   #--------------------------------------------------------------------------
  1482.   def map_animation(id)
  1483.     $game_map.actors.each do |member|
  1484.       member.animation_id = id if member.actor == self
  1485.     end
  1486.   end
  1487.   #--------------------------------------------------------------------------
  1488.   # * New method: on_damage_floor
  1489.   #--------------------------------------------------------------------------
  1490.   def on_damage_floor?
  1491.     $game_player.on_damage_floor?
  1492.   end
  1493. end

  1494. #==============================================================================
  1495. # ** Game_Unit
  1496. #------------------------------------------------------------------------------
  1497. #  This class handles units. It's used as a superclass of the Game_Party and
  1498. # Game_Troop classes.
  1499. #==============================================================================

  1500. class Game_Unit
  1501.   #--------------------------------------------------------------------------
  1502.   # * New method: refresh
  1503.   #--------------------------------------------------------------------------
  1504.   def refresh
  1505.     members.each {|member| member.refresh }
  1506.   end
  1507. end

  1508. #==============================================================================
  1509. # ** Game_Party
  1510. #------------------------------------------------------------------------------
  1511. #  This class handles the party. It includes information on amount of gold
  1512. # and items. The instance of this class is referenced by $game_party.
  1513. #==============================================================================

  1514. class Game_Party < Game_Unit
  1515.   #--------------------------------------------------------------------------
  1516.   # * New method: average_level
  1517.   #--------------------------------------------------------------------------
  1518.   def average_level
  1519.     battle_members.collect {|actor| actor.level }.average
  1520.   end
  1521.   #--------------------------------------------------------------------------
  1522.   # * New method: reserve_members
  1523.   #--------------------------------------------------------------------------
  1524.   def reserve_members
  1525.     all_members - battle_members
  1526.   end
  1527. end

  1528. #==============================================================================
  1529. # ** Game_Map
  1530. #------------------------------------------------------------------------------
  1531. #  This class handles maps. It includes scrolling and passage determination
  1532. # functions. The instance of this class is referenced by $game_map.
  1533. #==============================================================================

  1534. class Game_Map
  1535.   #--------------------------------------------------------------------------
  1536.   # * New method: event_list
  1537.   #--------------------------------------------------------------------------
  1538.   def event_list
  1539.     events.values
  1540.   end
  1541.   #--------------------------------------------------------------------------
  1542.   # * New method: note
  1543.   #--------------------------------------------------------------------------
  1544.   def note
  1545.     @map ? @map.note : ""
  1546.   end
  1547.   #--------------------------------------------------------------------------
  1548.   # * New method: vehicles
  1549.   #--------------------------------------------------------------------------
  1550.   def vehicles
  1551.     @vehicles
  1552.   end
  1553.   #--------------------------------------------------------------------------
  1554.   # * New method: map_events
  1555.   #--------------------------------------------------------------------------
  1556.   def map_events
  1557.     @map.events
  1558.   end
  1559.   #--------------------------------------------------------------------------
  1560.   # * New method: actors
  1561.   #--------------------------------------------------------------------------
  1562.   def actors
  1563.     [$game_player] + $game_player.followers.visible_followers
  1564.   end
  1565. end

  1566. #==============================================================================
  1567. # ** Game_CharacterBase
  1568. #------------------------------------------------------------------------------
  1569. #  This class deals with characters. Common to all characters, stores basic
  1570. # data, such as coordinates and graphics. It's used as a superclass of the
  1571. # Game_Character class.
  1572. #==============================================================================

  1573. class Game_CharacterBase
  1574.   #--------------------------------------------------------------------------
  1575.   # * Public Instance Variables
  1576.   #--------------------------------------------------------------------------
  1577.   attr_accessor :move_speed
  1578.   attr_accessor :move_frequency
  1579.   #--------------------------------------------------------------------------
  1580.   # * New method: player?
  1581.   #--------------------------------------------------------------------------
  1582.   def player?
  1583.     return false
  1584.   end
  1585.   #--------------------------------------------------------------------------
  1586.   # * New method: event?
  1587.   #--------------------------------------------------------------------------
  1588.   def event?
  1589.     return false
  1590.   end
  1591.   #--------------------------------------------------------------------------
  1592.   # * New method: follower?
  1593.   #--------------------------------------------------------------------------
  1594.   def follower?
  1595.     return false
  1596.   end
  1597.   #--------------------------------------------------------------------------
  1598.   # * New method: vehicle?
  1599.   #--------------------------------------------------------------------------
  1600.   def vehicle?
  1601.     return false
  1602.   end
  1603.   #--------------------------------------------------------------------------
  1604.   # * New method: frames
  1605.   #--------------------------------------------------------------------------
  1606.   def frames
  1607.     return 3
  1608.   end
  1609.   #--------------------------------------------------------------------------
  1610.   # * New method: hue
  1611.   #--------------------------------------------------------------------------
  1612.   def hue
  1613.     @hue ? @hue : 0
  1614.   end
  1615. end

  1616. #==============================================================================
  1617. # ** Game_Character
  1618. #------------------------------------------------------------------------------
  1619. #  This class deals with characters. It's used as a superclass of the
  1620. # Game_Player and Game_Event classes.
  1621. #==============================================================================

  1622. class Game_Character < Game_CharacterBase
  1623.   #--------------------------------------------------------------------------
  1624.   # * New method: move_toward_position
  1625.   #--------------------------------------------------------------------------
  1626.   def move_toward_position(x, y)
  1627.     sx = distance_x_from(x)
  1628.     sy = distance_y_from(y)
  1629.     if sx.abs > sy.abs
  1630.       move_straight(sx > 0 ? 4 : 6)
  1631.       move_straight(sy > 0 ? 8 : 2) if !@move_succeed && sy != 0
  1632.     elsif sy != 0
  1633.       move_straight(sy > 0 ? 8 : 2)
  1634.       move_straight(sx > 0 ? 4 : 6) if !@move_succeed && sx != 0
  1635.     end
  1636.   end
  1637.   #--------------------------------------------------------------------------
  1638.   # * New method: move_toward_position
  1639.   #--------------------------------------------------------------------------
  1640.   def turn_toward_position(x, y)
  1641.     sx = distance_x_from(x)
  1642.     sy = distance_y_from(y)
  1643.     if sx.abs > sy.abs
  1644.       set_direction(sx > 0 ? 4 : 6)
  1645.     elsif sy != 0
  1646.       set_direction(sy > 0 ? 8 : 2)
  1647.     end
  1648.   end
  1649. end

  1650. #==============================================================================
  1651. # ** Game_Player
  1652. #------------------------------------------------------------------------------
  1653. #  This class handles the player.
  1654. # The instance of this class is referenced by $game_map.
  1655. #==============================================================================

  1656. class Game_Player < Game_Character
  1657.   #--------------------------------------------------------------------------
  1658.   # * New method: player?
  1659.   #--------------------------------------------------------------------------
  1660.   def player?
  1661.     return true
  1662.   end
  1663.   #--------------------------------------------------------------------------
  1664.   # * New method: perform_transfer
  1665.   #--------------------------------------------------------------------------
  1666.   def new_map_id
  1667.     @new_map_id
  1668.   end
  1669.   #--------------------------------------------------------------------------
  1670.   # * New method: hue
  1671.   #--------------------------------------------------------------------------
  1672.   def hue
  1673.     actor ? actor.hue : 0
  1674.   end
  1675. end

  1676. #==============================================================================
  1677. # ** Game_Follower
  1678. #------------------------------------------------------------------------------
  1679. #  This class handles the followers. Followers are the actors of the party
  1680. # that follows the leader in a line. It's used within the Game_Followers class.
  1681. #==============================================================================

  1682. class Game_Follower < Game_Character
  1683.   #--------------------------------------------------------------------------
  1684.   # * New method: follower?
  1685.   #--------------------------------------------------------------------------
  1686.   def follower?
  1687.     return true
  1688.   end
  1689.   #--------------------------------------------------------------------------
  1690.   # * New method: index
  1691.   #--------------------------------------------------------------------------
  1692.   def index
  1693.     @member_index
  1694.   end
  1695.   #--------------------------------------------------------------------------
  1696.   # * New method: gathering?
  1697.   #--------------------------------------------------------------------------
  1698.   def gathering?
  1699.     $game_player.followers.gathering? && !gather?
  1700.   end
  1701. end

  1702. #==============================================================================
  1703. # ** Game_Followers
  1704. #------------------------------------------------------------------------------
  1705. #  This class handles the followers. It's a wrapper for the built-in class
  1706. # "Array." It's used within the Game_Player class.
  1707. #==============================================================================

  1708. class Game_Followers
  1709.   #--------------------------------------------------------------------------
  1710.   # * New method: get_actor
  1711.   #--------------------------------------------------------------------------
  1712.   def get_actor(id)
  1713.     list = [$game_player] + visible_followers
  1714.     list.select {|follower| follower.actor && follower.actor.id == id }.first
  1715.   end
  1716.   #--------------------------------------------------------------------------
  1717.   # * Method fix: visble_folloers
  1718.   #--------------------------------------------------------------------------
  1719.   unless method_defined?(:visible_followers)
  1720.     def visible_followers; visible_folloers; end
  1721.   end
  1722. end

  1723. #==============================================================================
  1724. # ** Game_Vehicle
  1725. #------------------------------------------------------------------------------
  1726. #  This class handles vehicles. It's used within the Game_Map class. If there
  1727. # are no vehicles on the current map, the coordinates is set to (-1,-1).
  1728. #==============================================================================

  1729. class Game_Vehicle < Game_Character
  1730.   #--------------------------------------------------------------------------
  1731.   # * New method: vehicle?
  1732.   #--------------------------------------------------------------------------
  1733.   def vehicle?
  1734.     return true
  1735.   end
  1736.   #--------------------------------------------------------------------------
  1737.   # * New method: map_id
  1738.   #--------------------------------------------------------------------------
  1739.   def map_id
  1740.     @map_id
  1741.   end
  1742.   #--------------------------------------------------------------------------
  1743.   # * New method: type
  1744.   #--------------------------------------------------------------------------
  1745.   def type
  1746.     @type
  1747.   end
  1748.   #--------------------------------------------------------------------------
  1749.   # * New method: aerial?
  1750.   #--------------------------------------------------------------------------
  1751.   def aerial?
  1752.     type == :airship
  1753.   end
  1754.   #--------------------------------------------------------------------------
  1755.   # * New method: above?
  1756.   #--------------------------------------------------------------------------
  1757.   def above?
  1758.     aerial?
  1759.   end
  1760. end

  1761. #==============================================================================
  1762. # ** Game_Event
  1763. #------------------------------------------------------------------------------
  1764. #  This class deals with events. It handles functions including event page
  1765. # switching via condition determinants, and running parallel process events.
  1766. # It's used within the Game_Map class.
  1767. #==============================================================================

  1768. class Game_Event < Game_Character
  1769.   #--------------------------------------------------------------------------
  1770.   # * New method: name
  1771.   #--------------------------------------------------------------------------
  1772.   def name
  1773.     @event.name
  1774.   end
  1775.   #--------------------------------------------------------------------------
  1776.   # * New method: event?
  1777.   #--------------------------------------------------------------------------
  1778.   def event?
  1779.     return true
  1780.   end
  1781.   #--------------------------------------------------------------------------
  1782.   # * New method: erased?
  1783.   #--------------------------------------------------------------------------
  1784.   def erased?
  1785.     @erased
  1786.   end
  1787.   #--------------------------------------------------------------------------
  1788.   # * New method: note
  1789.   #--------------------------------------------------------------------------
  1790.   def note
  1791.     return ""     if !@page || [email protected] || @page.list.size <= 0
  1792.     return @notes if @notes && @page.list == @note_page
  1793.     @note_page = @page.list.dup
  1794.     comment_list = []
  1795.     @page.list.each do |item|
  1796.       next unless item && (item.code == 108 || item.code == 408)
  1797.       comment_list.push(item.parameters[0])
  1798.     end
  1799.     @notes = comment_list.join("\r\n")
  1800.     @notes
  1801.   end  
  1802. end

  1803. #==============================================================================
  1804. # ** Game_Interpreter
  1805. #------------------------------------------------------------------------------
  1806. #  An interpreter for executing event commands. This class is used within the
  1807. # Game_Map, Game_Troop, and Game_Event classes.
  1808. #==============================================================================

  1809. class Game_Interpreter
  1810.   #--------------------------------------------------------------------------
  1811.   # * Alias method: command_108
  1812.   #--------------------------------------------------------------------------
  1813.   alias :command_108_ve_basic_module :command_108
  1814.   def command_108
  1815.     command_108_ve_basic_module
  1816.     comment_call
  1817.   end
  1818.   #--------------------------------------------------------------------------
  1819.   # * New method: comment_call
  1820.   #--------------------------------------------------------------------------
  1821.   def comment_call
  1822.   end
  1823.   #--------------------------------------------------------------------------
  1824.   # * New method: note
  1825.   #--------------------------------------------------------------------------
  1826.   def note
  1827.     @comments ? @comments.join("\r\n") : ""
  1828.   end
  1829. end

  1830. #==============================================================================
  1831. # ** Sprite_Character
  1832. #------------------------------------------------------------------------------
  1833. #  This sprite is used to display characters. It observes a instance of the
  1834. # Game_Character class and automatically changes sprite conditions.
  1835. #==============================================================================

  1836. class Sprite_Character < Sprite_Base
  1837.   #--------------------------------------------------------------------------
  1838.   # * Overwrite method: set_character_bitmap
  1839.   #--------------------------------------------------------------------------
  1840.   def set_character_bitmap
  1841.     update_character_info
  1842.     set_bitmap
  1843.     set_bitmap_position
  1844.   end
  1845.   #--------------------------------------------------------------------------
  1846.   # * New method: center_y
  1847.   #--------------------------------------------------------------------------
  1848.   def actor?
  1849.     @character.is_a?(Game_Player) || @character.is_a?(Game_Follower)
  1850.   end
  1851.   #--------------------------------------------------------------------------
  1852.   # * New method: center_y
  1853.   #--------------------------------------------------------------------------
  1854.   def actor
  1855.     actor? ? @character.actor : nil
  1856.   end
  1857.   #--------------------------------------------------------------------------
  1858.   # * New method: update_character_info
  1859.   #--------------------------------------------------------------------------
  1860.   def update_character_info
  1861.   end
  1862.   #--------------------------------------------------------------------------
  1863.   # * New method: hue
  1864.   #--------------------------------------------------------------------------
  1865.   def hue
  1866.     @character.hue
  1867.   end
  1868.   #--------------------------------------------------------------------------
  1869.   # * New method: set_bitmap
  1870.   #--------------------------------------------------------------------------
  1871.   def set_bitmap
  1872.     self.bitmap = Cache.character(set_bitmap_name, hue)
  1873.   end
  1874.   #--------------------------------------------------------------------------
  1875.   # * New method: set_bitmap_name
  1876.   #--------------------------------------------------------------------------
  1877.   def set_bitmap_name
  1878.     @character_name
  1879.   end
  1880.   #--------------------------------------------------------------------------
  1881.   # * New method: set_bitmap_position
  1882.   #--------------------------------------------------------------------------
  1883.   def set_bitmap_position
  1884.     sign = get_sign
  1885.     if sign && sign.include?(')
  1886.       @bw = bitmap.width  / 32.0 / frames
  1887.       @bh = bitmap.height / 32.0 / 4
  1888.     elsif character_name != "" && @tile_id == 0
  1889.       @bw = bitmap.width  / 32.0 / (frames * 4)
  1890.       @bh = bitmap.height / 32.0 / 8
  1891.     else
  1892.       @bw = 1.0
  1893.       @bh = 1.0
  1894.     end
  1895.     bitmap.dispose
  1896.   end
  1897.   #--------------------------------------------------------------------------
  1898.   # * New method: collision?
  1899.   #--------------------------------------------------------------------------
  1900.   def collision?(x, y, w, h)
  1901.     ax1, ay1, ax2, ay2 = setup_rect(x, y, w, h)
  1902.     bx1, by1, bx2, by2 = setup_rect(@x, @y, bw, bh)
  1903.     ax2 > bx1 && ax1 < bx2 && ay2 > by1 && ay1 < by2
  1904.   end
  1905.   #--------------------------------------------------------------------------
  1906.   # * New method: over?
  1907.   #--------------------------------------------------------------------------
  1908.   def over?(x, y)
  1909.     ax1, ay1, ax2, ay2 = setup_rect(x, y - 0.125, 0, 0)
  1910.     bx1, by1, bx2, by2 = setup_rect(@real_x, @real_y, bw, bh - 0.125)
  1911.     ax2 >= bx1 && ax1 <= bx2 && ay2 >= by1 && ay1 <= by2
  1912.   end
  1913.   #--------------------------------------------------------------------------
  1914.   # * New method: setup_rect
  1915.   #--------------------------------------------------------------------------
  1916.   def setup_rect(x, y, w, h)
  1917.     x1 = x - w / 2.0
  1918.     y1 = y - h
  1919.     x2 = x1 + w
  1920.     y2 = y1 + h
  1921.     [x1, y1, x2, y2]
  1922.   end
  1923.   #--------------------------------------------------------------------------
  1924.   # * New method: align_with
  1925.   #--------------------------------------------------------------------------
  1926.   def align_with(x, y)
  1927.     d  = @direction
  1928.     @x = $game_map.round_x_with_direction(x, 0) if d == 2 || d == 8
  1929.     @y = $game_map.round_y_with_direction(y, 0) if d == 6 || d == 4
  1930.     dx = (d == 2 || d == 8) ? (@x - @real_x) / 0.125 : 0
  1931.     dy = (d == 4 || d == 6) ? (@y - @real_y) / 0.125 : 0
  1932.     set_direction(dx > 0 ? 6 : dx < 0 ? 4 : dy > 0 ? 2 : dy < 0 ? 8 : d)
  1933.     @real_x = $game_map.x_with_direction(@x, reverse_dir(@direction), dx.abs)
  1934.     @real_y = $game_map.y_with_direction(@y, reverse_dir(@direction), dy.abs)
  1935.     update_for_align while moving?
  1936.     @direction = d
  1937.   end
  1938.   #--------------------------------------------------------------------------
  1939.   # * New method: update_for_align
  1940.   #--------------------------------------------------------------------------
  1941.   def update_for_align
  1942.     SceneManager.scene.update_basic
  1943.     SceneManager.scene.spriteset.update
  1944.     $game_map.update(true)
  1945.     $game_timer.update
  1946.     update_animation
  1947.     update_move
  1948.   end
  1949.   #--------------------------------------------------------------------------
  1950.   # * New method: fix_position
  1951.   #--------------------------------------------------------------------------
  1952.   def fix_position(n)
  1953.     (n * 64 / 8).round / 8.0
  1954.   end
  1955. end

  1956. #==============================================================================
  1957. # ** Game_Character
  1958. #------------------------------------------------------------------------------
  1959. #  This class deals with characters. It's used as a superclass of the
  1960. # Game_Player and Game_Event classes.
  1961. #==============================================================================

  1962. class Game_Character < Game_CharacterBase
  1963.   #--------------------------------------------------------------------------
  1964.   # * Alias method: move_toward_character
  1965.   #--------------------------------------------------------------------------
  1966.   alias :move_toward_character_ve_pixel_movement :move_toward_character
  1967.   def move_toward_character(character)
  1968.     sx = distance_x_from(character.x)
  1969.     sy = distance_y_from(character.y)
  1970.     move_toward_character_ve_pixel_movement(character)
  1971.     @x = character.x if sx.abs < 1
  1972.     @y = character.y if sy.abs < 1
  1973.   end
  1974.   #--------------------------------------------------------------------------
  1975.   # * Alias method: move_toward_position
  1976.   #--------------------------------------------------------------------------
  1977.   alias :move_toward_position_ve_pixel_movement :move_toward_position
  1978.   def move_toward_position(x, y)
  1979.     sx = distance_x_from(x)
  1980.     sy = distance_y_from(y)
  1981.     move_toward_position_ve_pixel_movement(x, y)
  1982.     @x = x if sx.abs < 1
  1983.     @y = y if sy.abs < 1
  1984.   end
  1985. end

  1986. #==============================================================================
  1987. # ** Game_Player
  1988. #------------------------------------------------------------------------------
  1989. #  This class handles maps. It includes event starting determinants and map
  1990. # scrolling functions. The instance of this class is referenced by $game_map.
  1991. #==============================================================================

  1992. class Game_Player < Game_Character
  1993.   #--------------------------------------------------------------------------
  1994.   # * Public Instance Variables
  1995.   #--------------------------------------------------------------------------
  1996.   attr_accessor :over_event
  1997.   attr_accessor :land_test
  1998.   #--------------------------------------------------------------------------
  1999.   # * Overwrite method: check_event_trigger_there
  2000.   #--------------------------------------------------------------------------
  2001.   def check_event_trigger_there(triggers)
  2002.     x2 = $game_map.round_x_with_direction(@x, @direction)
  2003.     y2 = $game_map.round_y_with_direction(@y, @direction)
  2004.     start_map_event(x2, y2, triggers, true)
  2005.     return if $game_map.any_event_starting?
  2006.     return unless counter_tile?
  2007.     x3 = $game_map.check_x_with_direction(x2, @direction)
  2008.     y3 = $game_map.check_y_with_direction(y2, @direction)
  2009.     start_map_event(x3, y3, triggers, true)
  2010.   end
  2011.   #--------------------------------------------------------------------------
  2012.   # * Overwrite method: start_map_event
  2013.   #--------------------------------------------------------------------------
  2014.   def start_map_event(x, y, triggers, normal)
  2015.     return if $game_map.interpreter.running?
  2016.     $game_map.events_xy(x, y).each do |event|
  2017.       event.start if check_event_contiontion(x, y, event, triggers, normal)
  2018.     end
  2019.   end
  2020.   #--------------------------------------------------------------------------
  2021.   # * Overwrite method: update_nonmoving
  2022.   #--------------------------------------------------------------------------
  2023.   def update_nonmoving(last_moving)
  2024.     return if $game_map.interpreter.running?
  2025.     moved  = @moved
  2026.     @moved = false
  2027.     if last_moving || moved
  2028.       $game_party.on_player_walk
  2029.       return if check_touch_event
  2030.     end
  2031.     if movable? && Input.trigger?(:C)
  2032.       return if get_on_off_vehicle
  2033.       return if check_action_event
  2034.     end
  2035.     @over_event -= 1 if @over_event > 0 && (last_moving || moved)
  2036.     update_encounter if last_moving || moved
  2037.   end
  2038.   #--------------------------------------------------------------------------
  2039.   # * Overwrite method: get_on_vehicle
  2040.   #--------------------------------------------------------------------------
  2041.   def get_on_vehicle
  2042.     setup_vehicle
  2043.     enter_vehicle if vehicle
  2044.     @vehicle_getting_on
  2045.   end
  2046.   #--------------------------------------------------------------------------
  2047.   # * Overwrite method: increase_steps
  2048.   #--------------------------------------------------------------------------
  2049.   def increase_steps
  2050.     super
  2051.     if normal_walk?
  2052.       @steps += 1
  2053.       $game_player.damage_floor  = 0 unless on_damage_floor?
  2054.       $game_player.damage_floor += 1
  2055.       $game_party.increase_steps if @steps % 8 == 0
  2056.     end
  2057.   end
  2058.   #--------------------------------------------------------------------------
  2059.   # * Alias method: get_off_vehicle
  2060.   #--------------------------------------------------------------------------
  2061.   alias :get_off_vehicle_ve_pixel_movement :get_off_vehicle
  2062.   def get_off_vehicle
  2063.     clear_next_movement if vehicle.land_ok?(@x, @y, @direction)
  2064.     get_off_vehicle_ve_pixel_movement
  2065.   end
  2066.   #--------------------------------------------------------------------------
  2067.   # * Alias method: clear_transfer_info
  2068.   #--------------------------------------------------------------------------
  2069.   alias :clear_transfer_info_ve_pixel_movement :clear_transfer_info
  2070.   def clear_transfer_info
  2071.     clear_transfer_info_ve_pixel_movement
  2072.     clear_next_movement
  2073.   end
  2074.   #--------------------------------------------------------------------------
  2075.   # * Alias method: update
  2076.   #--------------------------------------------------------------------------
  2077.   alias :update_ve_gp_pixel_movement :update
  2078.   def update
  2079.     @followers.move unless $imported[:ve_followers_options]
  2080.     update_ve_gp_pixel_movement
  2081.   end
  2082.   #--------------------------------------------------------------------------
  2083.   # * New method: check_event_contiontion
  2084.   #--------------------------------------------------------------------------
  2085.   def check_event_contiontion(x, y, event, triggers, normal)
  2086.     passable = passable_tile?(@x, @y, @direction)
  2087.     w = (counter_tile? || !passable) ? 1.0 : bw
  2088.     h = (counter_tile? || !passable) ? 1.0 : bh
  2089.     return false unless event.trigger_in?(triggers)
  2090.     return false unless event.event_priority?(normal)
  2091.     return false unless passable || event.over_tile? || counter_tile?
  2092.     return false unless event.collision?(x, y, w, h) || !jumping?
  2093.     return false unless !event.in_front? || front_collision?(x, y, @direction)
  2094.     return true
  2095.   end
  2096.   #--------------------------------------------------------------------------
  2097.   # * New method: counter_tile?
  2098.   #--------------------------------------------------------------------------
  2099.   def counter_tile?
  2100.     x = $game_map.check_x_with_direction(@x, @direction)
  2101.     y = $game_map.check_y_with_direction(@y, @direction)
  2102.     $game_map.counter?(x, y)
  2103.   end
  2104.   #--------------------------------------------------------------------------
  2105.   # * New method: setup_vehicle
  2106.   #--------------------------------------------------------------------------
  2107.   def setup_vehicle
  2108.     $game_map.vehicles.compact.each do |vehicle|
  2109.       next unless vehicle.enter_vechicle?(@x, @y, @direction)
  2110.       @vehicle_type = vehicle.type
  2111.       break if vehicle
  2112.     end
  2113.   end
  2114.   #--------------------------------------------------------------------------
  2115.   # * New method: enter_vehicle
  2116.   #--------------------------------------------------------------------------
  2117.   def enter_vehicle
  2118.     align_with(vehicle.x, vehicle.y) unless in_airship?
  2119.     @vehicle_getting_on = true
  2120.     force_move_forward unless in_airship?
  2121.     @followers.gather
  2122.   end
  2123.   #--------------------------------------------------------------------------
  2124.   # * New method: clear_next_movement
  2125.   #--------------------------------------------------------------------------
  2126.   def clear_next_movement
  2127.     @next_movement.clear
  2128.     @followers.clear_next_movement
  2129.   end
  2130.   #--------------------------------------------------------------------------
  2131.   # * New method: step_times
  2132.   #--------------------------------------------------------------------------
  2133.   def step_times
  2134.     (move_route_forcing || not_driving?) ? super : 1
  2135.   end
  2136.   #--------------------------------------------------------------------------
  2137.   # * New method: not_driving?
  2138.   #--------------------------------------------------------------------------
  2139.   def not_driving?
  2140.     vehicle && !vehicle.driving
  2141.   end
  2142.   #--------------------------------------------------------------------------
  2143.   # * New method: move_straight
  2144.   #--------------------------------------------------------------------------
  2145.   def move_straight(d, turn_ok = true)
  2146.     super
  2147.   end
  2148.   #--------------------------------------------------------------------------
  2149.   # * New method: move_diagonal
  2150.   #--------------------------------------------------------------------------
  2151.   def move_diagonal(horz, vert)
  2152.     super
  2153.   end
  2154.   #--------------------------------------------------------------------------
  2155.   # * New method: setup_bitmap_dimension
  2156.   #--------------------------------------------------------------------------
  2157.   def setup_bitmap_dimension
  2158.     @bw = VE_PLAYER_BIG_COLLISION ? 1.0 : 0.75
  2159.     @bh = VE_PLAYER_BIG_COLLISION ? 1.0 : 0.75
  2160.   end
  2161. end

  2162. #==============================================================================
  2163. # ** Game_Follower
  2164. #------------------------------------------------------------------------------
  2165. #  This class handles the followers. Followers are the actors of the party
  2166. # that follows the leader in a line. It's used within the Game_Followers class.
  2167. #==============================================================================

  2168. class Game_Follower < Game_Character
  2169.   #--------------------------------------------------------------------------
  2170.   # * Overwrite method: chase_preceding_character
  2171.   #--------------------------------------------------------------------------
  2172.   def chase_preceding_character
  2173.     return if $imported[:ve_followers_control] && cant_follow_character
  2174.     unless moving?
  2175.       if @preceding_character.next_movement.size >= 8 && !gathering?
  2176.         next_move = @preceding_character.next_movement.shift
  2177.         move_straight(next_move)  if next_move.numeric?
  2178.         move_diagonal(*next_move) if next_move.array?
  2179.       elsif gathering?
  2180.         @preceding_character.next_movement.clear
  2181.         move_toward_player
  2182.       end
  2183.     end
  2184.   end
  2185.   #--------------------------------------------------------------------------
  2186.   # * New method: move_straight
  2187.   #--------------------------------------------------------------------------
  2188.   def move_straight(d, turn_ok = true)
  2189.     super
  2190.   end
  2191.   #--------------------------------------------------------------------------
  2192.   # * New method: move_diagonal
  2193.   #--------------------------------------------------------------------------
  2194.   def move_diagonal(horz, vert)
  2195.     super
  2196.   end
  2197.   #--------------------------------------------------------------------------
  2198.   # * New method: movement_size
  2199.   #--------------------------------------------------------------------------
  2200.   def movement_size
  2201.     return 8
  2202.   end
  2203.   #--------------------------------------------------------------------------
  2204.   # * New method: step_times
  2205.   #--------------------------------------------------------------------------
  2206.   def step_times
  2207.     (move_route_forcing || not_driving? || gathering?) ? super : 1
  2208.   end
  2209.   #--------------------------------------------------------------------------
  2210.   # * New method: not_driving?
  2211.   #--------------------------------------------------------------------------
  2212.   def not_driving?
  2213.     $game_player.not_driving?
  2214.   end
  2215.   #--------------------------------------------------------------------------
  2216.   # * New method: setup_bitmap_dimension
  2217.   #--------------------------------------------------------------------------
  2218.   def setup_bitmap_dimension
  2219.     @bw = VE_PLAYER_BIG_COLLISION ? 1.0 : 0.75
  2220.     @bh = VE_PLAYER_BIG_COLLISION ? 1.0 : 0.75
  2221.   end
  2222. end

  2223. #==============================================================================
  2224. # ** Game_Followers
  2225. #------------------------------------------------------------------------------
  2226. #  This class handles the followers. It's a wrapper for the built-in class
  2227. # "Array." It's used within the Game_Player class.
  2228. #==============================================================================

  2229. class Game_Followers
  2230.   #--------------------------------------------------------------------------
  2231.   # * New method: clear_next_movement
  2232.   #--------------------------------------------------------------------------
  2233.   def clear_next_movement
  2234.     each {|follower| follower.next_movement.clear }
  2235.   end
  2236. end

  2237. #==============================================================================
  2238. # ** Game_Event
  2239. #------------------------------------------------------------------------------
  2240. #  This class deals with events. It handles functions including event page
  2241. # switching via condition determinants, and running parallel process events.
  2242. # It's used within the Game_Map class.
  2243. #==============================================================================

  2244. class Game_Event < Game_Character
  2245.   #--------------------------------------------------------------------------
  2246.   # * Overwrite method: collide_with_player_characters?
  2247.   #--------------------------------------------------------------------------
  2248.   def collide_with_player_characters?(x, y)
  2249.     normal_priority? && player_collision?(x, y)
  2250.   end
  2251.   #--------------------------------------------------------------------------
  2252.   # * Alias method: start
  2253.   #--------------------------------------------------------------------------
  2254.   alias :start_ve_pixel_movement :start
  2255.   def start
  2256.     start_ve_pixel_movement
  2257.     $game_player.over_event = 8 if step_over? && !step_trigger?
  2258.   end
  2259.   #--------------------------------------------------------------------------
  2260.   # * Alias method: setup_page_settings
  2261.   #--------------------------------------------------------------------------
  2262.   alias :setup_page_settings_ve_pixel_movement :setup_page_settings
  2263.   def setup_page_settings_ve_pixel_movement
  2264.     setup_page_settings_ve_anti_lag
  2265.     @move_steps   = note =~ /<MOVE STEPS: (\d+)>/i ? $1.to_i : nil
  2266.     @step_trigger = note =~ /<EACH STEP TRIGGER>/i ? true : false
  2267.     @in_front     = note =~ /<FRONT COLLISION>/i   ? true : false
  2268.     @over_tile    = note =~ /<OVER TILE>/i         ? true : false
  2269.     @side_fix     = note =~ /<NO SIDE COLLISION FIX>/i ? false : true
  2270.   end
  2271.   #--------------------------------------------------------------------------
  2272.   # * New method: player_collision?
  2273.   #--------------------------------------------------------------------------
  2274.   def player_collision?(x, y)
  2275.     $game_map.actors.any? {|actor| actor.collision?(x, y, bh, bw)}
  2276.   end  
  2277.   #--------------------------------------------------------------------------
  2278.   # * New method: event_priority?
  2279.   #--------------------------------------------------------------------------
  2280.   def event_priority?(normal)
  2281.     (normal_priority? == normal || (@through && !normal)) &&
  2282.     (normal_priority? || @trigger == 0 || $game_player.over_event == 0)
  2283.   end
  2284.   #--------------------------------------------------------------------------
  2285.   # * New method: check_event_trigger_touch
  2286.   #--------------------------------------------------------------------------
  2287.   def check_event_trigger_touch(x, y)
  2288.     return if $game_map.interpreter.running?
  2289.     if @trigger == 2 && $game_player.collision?(x, y, bh, bw)
  2290.       start if !jumping? && normal_priority?
  2291.     end
  2292.   end
  2293.   #--------------------------------------------------------------------------
  2294.   # * New method: step_over?
  2295.   #--------------------------------------------------------------------------
  2296.   def step_over?
  2297.     super || (@character_name == "" && @tile_id == 0) || @priority_type == 0
  2298.   end
  2299.   #--------------------------------------------------------------------------
  2300.   # * New method: step_times
  2301.   #--------------------------------------------------------------------------
  2302.   def step_times
  2303.     @move_steps ? @move_steps : super
  2304.   end
  2305.   #--------------------------------------------------------------------------
  2306.   # * New method: step_trigger?
  2307.   #--------------------------------------------------------------------------
  2308.   def step_trigger?
  2309.     @step_trigger
  2310.   end
  2311.   #--------------------------------------------------------------------------
  2312.   # * New method: in_front?
  2313.   #--------------------------------------------------------------------------
  2314.   def in_front?
  2315.     @in_front
  2316.   end
  2317.   #--------------------------------------------------------------------------
  2318.   # * New method: over_tile?
  2319.   #--------------------------------------------------------------------------
  2320.   def over_tile?
  2321.     @over_tile
  2322.   end
  2323.   #--------------------------------------------------------------------------
  2324.   # * New method: side_collision?
  2325.   #--------------------------------------------------------------------------
  2326.   def side_collision?
  2327.     @side_fix
  2328.   end
  2329.   #--------------------------------------------------------------------------
  2330.   # * New method: setup_bitmap_dimension
  2331.   #--------------------------------------------------------------------------
  2332.   def setup_bitmap_dimension
  2333.     regexp = /<EVENT SIZE: (\d+), (\d+)>/i
  2334.     note   =~ regexp ? setup_custom_dimension($1.to_i, $2.to_i) : super
  2335.   end
  2336.   #--------------------------------------------------------------------------
  2337.   # * New method: setup_custom_dimension
  2338.   #--------------------------------------------------------------------------
  2339.   def setup_custom_dimension(x, y)
  2340.     x1 = (x / 8).to_i
  2341.     y1 = (y / 8).to_i
  2342.     @bw = x1 / 4.0
  2343.     @bh = y1 / 4.0
  2344.   end
  2345. end

  2346. #==============================================================================
  2347. # ** Game_Vehicle
  2348. #------------------------------------------------------------------------------
  2349. #  This class handles vehicles. It's used within the Game_Map class. If there
  2350. # are no vehicles on the current map, the coordinates is set to (-1,-1).
  2351. #==============================================================================

  2352. class Game_Vehicle < Game_Character
  2353.   #--------------------------------------------------------------------------
  2354.   # * Overwrite method: land_ok?
  2355.   #--------------------------------------------------------------------------
  2356.   def land_ok?(x, y, d)
  2357.     @type == :airship ? airship_landable?(x, y) : check_landable?(x, y, d)
  2358.   end
  2359.   #--------------------------------------------------------------------------
  2360.   # * New method: land_test
  2361.   #--------------------------------------------------------------------------
  2362.   def land_test
  2363.     @land_test
  2364.   end
  2365.   #--------------------------------------------------------------------------
  2366.   # * New method: step_over?
  2367.   #--------------------------------------------------------------------------
  2368.   def step_over?
  2369.     above? || super
  2370.   end
  2371.   #--------------------------------------------------------------------------
  2372.   # * New method: check_landable?
  2373.   #--------------------------------------------------------------------------
  2374.   def check_landable?(x, y, d)
  2375.     x2 = $game_map.check_x_with_direction(x, d)
  2376.     y2 = $game_map.check_y_with_direction(y, d)
  2377.     @land_test = true
  2378.     result = passable?(x2, y2, d)
  2379.     @land_test = false
  2380.     result
  2381.   end
  2382.   #--------------------------------------------------------------------------
  2383.   # * New method: airship_landable?
  2384.   #--------------------------------------------------------------------------
  2385.   def airship_landable?(x, y)
  2386.     [2, 4, 6, 8].any? {|d| passable?(x, y, d) }
  2387.   end
  2388.   #--------------------------------------------------------------------------
  2389.   # * New method: passable_normal?
  2390.   #--------------------------------------------------------------------------
  2391.   def passable_normal?(x, y, d ,d2, ceil = false)
  2392.     @land_test ? landable_normal?(x, y, d ,d2, ceil) : super(x, y, d ,d2, ceil)
  2393.   end
  2394.   #--------------------------------------------------------------------------
  2395.   # * New method: landable_normal?
  2396.   #--------------------------------------------------------------------------
  2397.   def landable_normal?(x, y, d ,d2, ceil)
  2398.     x1 = $game_map.round_x(x)
  2399.     y1 = $game_map.round_y(y)
  2400.     return false unless $game_map.valid?(x1, y1)
  2401.     return true if @through || debug_through?
  2402.     return false unless map_passable?(x1, y1, d)
  2403.     return false unless map_passable?(x1, y1, d2) || !ceil
  2404.     return false unless map_passable?(x1, y1, reverse_dir(d))
  2405.     return true
  2406.   end
  2407.   #--------------------------------------------------------------------------
  2408.   # * New method: enter_vechicle?
  2409.   #--------------------------------------------------------------------------
  2410.   def enter_vechicle?(x, y, d)
  2411.     return false if @map_id != $game_map.map_id
  2412.     x2 = $game_map.round_x_with_direction(x, d)
  2413.     y2 = $game_map.round_y_with_direction(y, d)
  2414.     x3 = $game_map.check_x_with_direction(@x, reverse_dir(d))
  2415.     y3 = $game_map.check_y_with_direction(@y, reverse_dir(d))
  2416.     ( above? && collision?(x, y - 0.125, bw * 0.75, bh * 0.75)) ||
  2417.     (!above? && collision?(x2, y2, bw, bh) && map_passable?(x3, y3, d))
  2418.   end
  2419.   #--------------------------------------------------------------------------
  2420.   # * New method: vehicle_collision?
  2421.   #--------------------------------------------------------------------------
  2422.   def vehicle_collision?(x, y, bw, bh, player)
  2423.     return false if step_over?
  2424.     return false if player.player? && self == player.vehicle
  2425.     return false if !collision?(x, y, bw, bh)
  2426.     return true
  2427.   end
  2428. end
复制代码
  1. #==============================================================================
  2. # ** Victor Engine - Pixel Movement
  3. #------------------------------------------------------------------------------
  4. # Author : Victor Sant
  5. #
  6. # Version History:
  7. #  v 1.00 - 2012.05.29 > First relase
  8. #  v 1.01 - 2012.05.29 > Compatibility with Terrain States
  9. #  v 1.02 - 2012.07.03 > Compatibility with Basic Module 1.23
  10. #  v 1.03 - 2012.07.05 > Added 'over event' tag for objects over blocked tiles
  11. #                      > Added Steps settings for events
  12. #  v 1.04 - 2012.07.24 > Compatibility with Moving Platform
  13. #                      > Added <each step trigger> tag for events
  14. #  v 1.05 - 2012.07.30 > Fixed issue when characters moves toward the same spot
  15. #  v 1.06 - 2012.08.03 > Compatibility with Anti Lag
  16. #  v 1.07 - 2012.08.03 > Fixed collision with tile graphics events
  17. #------------------------------------------------------------------------------
  18. #  This script allows to replace the tile based movement where the player
  19. # walks a whole 32 pixel tile each step with one that he walks only 4 pixels.
  20. # It also give a better collision system for events.
  21. #------------------------------------------------------------------------------
  22. # Compatibility
  23. #   Requires the script 'Victor Engine - Basic Module' v 1.25 or higher
  24. #   If used with 'Victor Engine - Animated Battle' place this bellow it.
  25. #   If used with 'Victor Engine - Follower Control' place this bellow it.
  26. #   If used with 'Victor Engine - Follower Options' place this bellow it.
  27. #
  28. # * Overwrite methods
  29. #   class Game_Actor < Game_Battler
  30. #     def turn_end_on_map
  31. #
  32. #   class Game_Map
  33. #     def layered_tiles(x, y)
  34. #     def events_xy(x, y)
  35. #     def events_xy_nt(x, y)
  36. #     def x_with_direction(x, d, times = 1)
  37. #     def y_with_direction(y, d, times = 1)
  38. #     def round_x_with_direction(x, d)
  39. #     def round_y_with_direction
  40. #
  41. #   class Game_CharacterBase
  42. #     def region_id
  43. #     def move_straight(d, turn_ok = true)
  44. #     def move_diagonal(horz, vert)
  45. #     def collide_with_events?(x, y)
  46. #     def collide_with_vehicles?(x, y)
  47. #
  48. #   class Game_Player < Game_Character
  49. #     def check_event_trigger_there(triggers)
  50. #     def start_map_event(x, y, triggers, normal)
  51. #     def update_nonmoving(last_moving)
  52. #     def get_on_vehicle
  53. #     def increase_steps
  54. #
  55. #   class Game_Follower < Game_Character
  56. #     def chase_preceding_character
  57. #
  58. #   class Game_Event < Game_Character
  59. #     def collide_with_player_characters?(x, y)
  60. #
  61. #   class Game_Vehicle < Game_Character
  62. #     def land_ok?(x, y, d)
  63. #
  64. # * Alias methods
  65. #   class Game_Actor < Game_Battler
  66. #     def check_floor_effect
  67. #
  68. #   class Game_CharacterBase
  69. #     def init_public_members
  70. #     def update
  71. #
  72. #   class Game_Character < Game_CharacterBase
  73. #     def move_toward_character(character)
  74. #     def move_toward_position(x, y)
  75. #
  76. #   class Game_Event < Game_Character
  77. #     def start
  78. #
  79. #   class Game_Player < Game_Character
  80. #     def get_off_vehicle
  81. #     def clear_transfer_info
  82. #     def update
  83. #
  84. #   class Game_Event < Game_Character
  85. #     def start
  86. #
  87. #------------------------------------------------------------------------------
  88. # Instructions:
  89. #  To instal the script, open you script editor and paste this script on
  90. #  a new section bellow the Materials section. This script must also
  91. #  be bellow the script 'Victor Engine - Basic'
  92. #
  93. #------------------------------------------------------------------------------
  94. # Event Comment boxes note tags:
  95. #   Tags to be used on events Comment boxes.
  96. #
  97. #  <move steps: x>
  98. #   Setup the number of steps each "Move" command will execute. The default
  99. #   value is 8 (1 tile)
  100. #     x : number of steps
  101. #
  102. #  <event size: x, y>
  103. #   Collision area size, in pixels for event collisions.
  104. #     x : collision area width
  105. #     y : collision area height
  106. #
  107. #  <front collision>
  108. #   Events with this tag won't start if the the collision between events and
  109. #   the player occur between their edges.
  110. #
  111. #  <no side collision fix>
  112. #   Events with this tag won't have the "slide" effect when the edges of the
  113. #   events collide with the player
  114. #
  115. #  <over tile>
  116. #   Events with this tag will start even when placed over blocked tiles.
  117. #   By default, if the passage is blocked the event don't stat.
  118. #
  119. #  <each step trigger>
  120. #   By default, events with through or bellow character priority triggers
  121. #   only one time for each 8 steps above them. With this tag though, the
  122. #   event will trigger every step.
  123. #
  124. #------------------------------------------------------------------------------
  125. # Additional instructions:
  126. #
  127. #  All events and tiles have a "slide" effect when the player faces the edge
  128. #  of a tile or event. I added this function since it would be a pain to
  129. #  be in the exact position to go throug a narrow path.
  130. #  This can be disabled for events, but not for tiles.
  131. #
  132. #==============================================================================

  133. #==============================================================================
  134. # ** Victor Engine
  135. #------------------------------------------------------------------------------
  136. #   Setting module for the Victor Engine
  137. #==============================================================================

  138. module Victor_Engine
  139.   #--------------------------------------------------------------------------
  140.   # * Player collision area
  141.   #   Different from events, player collision don't rely on the graphic size
  142.   #   Player collision area can be of 2 types:
  143.   #   - 32 x 32 box if VE_PLAYER_BIG_COLLISION = true
  144.   #   - 24 x 24 box if VE_PLAYER_BIG_COLLISION = false
  145.   #--------------------------------------------------------------------------
  146.   VE_PLAYER_BIG_COLLISION = true
  147.   #--------------------------------------------------------------------------
  148.   # * required
  149.   #   This method checks for the existance of the basic module and other
  150.   #   VE scripts required for this script to work, don't edit this
  151.   #--------------------------------------------------------------------------
  152.   def self.required(name, req, version, type = nil)
  153.     if !$imported[:ve_basic_module]
  154.       msg = "The script '%s' requires the script\n"
  155.       msg += "'VE - Basic Module' v%s or higher above it to work properly\n"
  156.       msg += "Go to http://victorscripts.wordpress.com/ to download this script."
  157.       msgbox(sprintf(msg, self.script_name(name), version))
  158.       exit
  159.     else
  160.       self.required_script(name, req, version, type)
  161.     end
  162.   end
  163.   #--------------------------------------------------------------------------
  164.   # * script_name
  165.   #   Get the script name base on the imported value
  166.   #--------------------------------------------------------------------------
  167.   def self.script_name(name, ext = "VE")
  168.     name = name.to_s.gsub("_", " ").upcase.split
  169.     name.collect! {|char| char == ext ? "#{char} -" : char.capitalize }
  170.     name.join(" ")
  171.   end
  172. end

  173. $imported ||= {}
  174. $imported[:ve_pixel_movement] = 1.07
  175. Victor_Engine.required(:ve_pixel_movement, :ve_basic_module, 1.25, :above)
  176. Victor_Engine.required(:ve_pixel_movement, :ve_map_battle, 1.00, :bellow)
  177. Victor_Engine.required(:ve_pixel_movement, :ve_diagonal_move, 1.00, :bellow)

  178. #==============================================================================
  179. # ** Game_Actor
  180. #------------------------------------------------------------------------------
  181. #  This class handles actors. It's used within the Game_Actors class
  182. # ($game_actors) and referenced by the Game_Party class ($game_party).
  183. #==============================================================================

  184. class Game_Actor < Game_Battler
  185.   #--------------------------------------------------------------------------
  186.   # * Overwrite method: turn_end_on_map
  187.   #--------------------------------------------------------------------------
  188.   def turn_end_on_map
  189.     if $game_player.steps % (steps_for_turn * 8) == 0
  190.       on_turn_end
  191.       perform_map_damage_effect if @result.hp_damage > 0
  192.     end
  193.   end
  194.   #--------------------------------------------------------------------------
  195.   # * Alias method: init_public_members
  196.   #--------------------------------------------------------------------------
  197.   alias :check_floor_effect_ve_pixel_movement :check_floor_effect
  198.   def check_floor_effect
  199.     return if check_damage_floor
  200.     check_floor_effect_ve_pixel_movement
  201.   end
  202.   #--------------------------------------------------------------------------
  203.   # * New method: check_damage_floor
  204.   #--------------------------------------------------------------------------
  205.   def check_damage_floor
  206.     $game_player.damage_floor % 8 != 0
  207.   end
  208. end

  209. #==============================================================================
  210. # ** Game_Map
  211. #------------------------------------------------------------------------------
  212. #  This class handles maps. It includes scrolling and passage determination
  213. # functions. The instance of this class is referenced by $game_map.
  214. #==============================================================================

  215. class Game_Map
  216.   #--------------------------------------------------------------------------
  217.   # * Overwrite method: layered_tiles
  218.   #--------------------------------------------------------------------------
  219.   def layered_tiles(x, y)
  220.     x2 = (x - 0.5).ceil
  221.     y2 = (y - 0.125).ceil
  222.     [2, 1, 0].collect {|z| tile_id(x2, y2, z) }
  223.   end
  224.   #--------------------------------------------------------------------------
  225.   # * Overwrite method: events_xy
  226.   #--------------------------------------------------------------------------
  227.   def events_xy(x, y)
  228.     event_list.select {|event| event.near?(x, y) }
  229.   end
  230.   #--------------------------------------------------------------------------
  231.   # * Overwrite method: events_xy_nt
  232.   #--------------------------------------------------------------------------
  233.   def events_xy_nt(x, y)
  234.     event_list.select {|event| event.near_nt?(x, y) }
  235.   end
  236.   #--------------------------------------------------------------------------
  237.   # * Overwrite method: x_with_direction
  238.   #--------------------------------------------------------------------------
  239.   def x_with_direction(x, d, times = 1)
  240.     x + (d == 6 ? times * 0.125 : d == 4 ? -times * 0.125 : 0)
  241.   end
  242.   #--------------------------------------------------------------------------
  243.   # * Overwrite method: y_with_direction
  244.   #--------------------------------------------------------------------------
  245.   def y_with_direction(y, d, times = 1)
  246.     y + (d == 2 ? times * 0.125 : d == 8 ? -times * 0.125 : 0)
  247.   end
  248.   #--------------------------------------------------------------------------
  249.   # * Overwrite method: round_x_with_direction
  250.   #--------------------------------------------------------------------------
  251.   def round_x_with_direction(x, d)
  252.     round_x(x + (d == 6 ? 0.125 : d == 4 ? -0.125 : 0))
  253.   end
  254.   #--------------------------------------------------------------------------
  255.   # * Overwrite method: round_y_with_direction
  256.   #--------------------------------------------------------------------------
  257.   def round_y_with_direction(y, d)
  258.     round_y(y + (d == 2 ? 0.125 : d == 8 ? -0.125 : 0))
  259.   end
  260.   #--------------------------------------------------------------------------
  261.   # * New method: check_x_with_direction
  262.   #--------------------------------------------------------------------------
  263.   def check_x_with_direction(x, d)
  264.     round_x(x + (d == 6 ? 1 : d == 4 ? -1 : 0))
  265.   end
  266.   #--------------------------------------------------------------------------
  267.   # * New method: check_y_with_direction
  268.   #--------------------------------------------------------------------------
  269.   def check_y_with_direction(y, d)
  270.     round_y(y + (d == 2 ? 1 : d == 8 ? -1 : 0))
  271.   end
  272. end

  273. #==============================================================================
  274. # ** Game_CharacterBase
  275. #------------------------------------------------------------------------------
  276. #  This class deals with characters. Common to all characters, stores basic
  277. # data, such as coordinates and graphics. It's used as a superclass of the
  278. # Game_Character class.
  279. #==============================================================================

  280. class Game_CharacterBase
  281.   #--------------------------------------------------------------------------
  282.   # * Public Instance Variables
  283.   #--------------------------------------------------------------------------
  284.   attr_accessor :next_movement
  285.   attr_accessor :side_collision
  286.   attr_accessor :damage_floor
  287.   attr_accessor :steps
  288.   #--------------------------------------------------------------------------
  289.   # * Overwrite method: region_id
  290.   #--------------------------------------------------------------------------
  291.   def region_id
  292.     $game_map.region_id((@x - 0.5).ceil, (@y - 0.125).ceil)
  293.   end
  294.   #--------------------------------------------------------------------------
  295.   # * Overwrite method: collide_with_events?
  296.   #--------------------------------------------------------------------------
  297.   def collide_with_events?(x, y)
  298.     $game_map.events_xy_nt(x, y).any? do |event|
  299.       event.collision_condition?(x, y, bw, bh, event?, @id, @side_collision)
  300.     end
  301.   end
  302.   #--------------------------------------------------------------------------
  303.   # * Overwrite method: collide_with_vehicles?
  304.   #--------------------------------------------------------------------------
  305.   def collide_with_vehicles?(x, y)
  306.     $game_map.vehicles.compact.any? do |vehicle|
  307.       next if vehicle.map_id != $game_map.map_id
  308.       vehicle.vehicle_collision?(x, y, bw, bh, self)
  309.     end
  310.   end
  311.   #--------------------------------------------------------------------------
  312.   # * Overwrite method: move_straight
  313.   #--------------------------------------------------------------------------
  314.   def move_straight(d, turn_ok = true)
  315.     @move_list += [{d: [d], turn: turn_ok}] * step_times
  316.   end
  317.   #--------------------------------------------------------------------------
  318.   # * Overwrite method: move_straight
  319.   #--------------------------------------------------------------------------
  320.   def move_diagonal(horz, vert)
  321.     @move_list += [{d: [horz, vert], turn: true}] * step_times
  322.   end
  323.   #--------------------------------------------------------------------------
  324.   # * Alias method: init_public_members
  325.   #--------------------------------------------------------------------------
  326.   alias :init_public_members_ve_pixel_movement :init_public_members
  327.   def init_public_members
  328.     init_public_members_ve_pixel_movement
  329.     @move_list     = []
  330.     @next_movement = []
  331.     @over_event    = 0
  332.     @damage_floor  = 0
  333.     @steps         = 0
  334.   end
  335.   #--------------------------------------------------------------------------
  336.   # * Alias method: update
  337.   #--------------------------------------------------------------------------
  338.   alias :update_ve_pixel_movement :update
  339.   def update
  340.     update_move_straight
  341.     update_move_diagonal
  342.     update_ve_pixel_movement
  343.   end
  344.   #--------------------------------------------------------------------------
  345.   # * New method: update_move_straight
  346.   #--------------------------------------------------------------------------
  347.   def update_move_straight
  348.     return if moving? || @move_list.empty?
  349.     return if @move_list.first[:d].size > 1
  350.     move = @move_list.shift
  351.     d    = move[:d].first
  352.     if passable?(@x, @y, d)
  353.       @diagonal_move = false
  354.       setup_movement(d, d)
  355.       @real_x = $game_map.x_with_direction(@x, reverse_dir(d))
  356.       @real_y = $game_map.y_with_direction(@y, reverse_dir(d))
  357.       @moved  = player?
  358.     elsif move[:turn]
  359.       check_event_trigger_move(d)
  360.     end
  361.   end
  362.   #--------------------------------------------------------------------------
  363.   # * Overwrite method: update_move_diagonal
  364.   #--------------------------------------------------------------------------
  365.   def update_move_diagonal
  366.     return if moving? || @move_list.empty?
  367.     return if @move_list.first[:d].size < 2
  368.     move = @move_list.shift
  369.     horz = move[:d].first
  370.     vert = move[:d].last
  371.     if diagonal_passable?(x, y, horz, vert)
  372.       @diagonal_move = true
  373.       setup_movement(horz, vert)
  374.       @real_x = $game_map.x_with_direction(@x, reverse_dir(horz))
  375.       @real_y = $game_map.y_with_direction(@y, reverse_dir(vert))
  376.       @moved = player?
  377.     end
  378.   end
  379.   #--------------------------------------------------------------------------
  380.   # * New method: character_collision?
  381.   #--------------------------------------------------------------------------
  382.   def character_collision?(x, y, d)
  383.     x2 = $game_map.round_x_with_direction(x, d)
  384.     y2 = $game_map.round_y_with_direction(y, d)
  385.     !collide_with_characters?(x2, y2) || @through || debug_through?
  386.   end
  387.   #--------------------------------------------------------------------------
  388.   # * New method: step_times
  389.   #--------------------------------------------------------------------------
  390.   def step_times
  391.     return 8
  392.   end
  393.   #--------------------------------------------------------------------------
  394.   # * New method: near_nt?
  395.   #--------------------------------------------------------------------------
  396.   def near_nt?(x, y)
  397.     near?(x, y) && !@through
  398.   end
  399.   #--------------------------------------------------------------------------
  400.   # * New method: near?
  401.   #--------------------------------------------------------------------------
  402.   def near?(x, y)
  403.     w = step_over? ? [bw * 0.625, 0.5].max : [bw, 1.0].max
  404.     h = step_over? ? [bh * 0.625, 0.5].max : [bh, 1.0].max
  405.     @real_x > x - w && @real_x < x + w && @real_y > y - h && @real_y < y + h
  406.   end
  407.   #--------------------------------------------------------------------------
  408.   # * New method: setup_movement
  409.   #--------------------------------------------------------------------------
  410.   def setup_movement(horz, vert)
  411.     @x = $game_map.round_x_with_direction(@x, horz)
  412.     @y = $game_map.round_y_with_direction(@y, vert)
  413.     add_next_movement(horz == vert ? horz : [horz, vert])
  414.     set_direction(horz) if @direction == reverse_dir(horz) || horz == vert
  415.     set_direction(vert) if @direction == reverse_dir(vert) && horz != vert
  416.     follower_control_move_update(horz, vert)
  417.     increase_steps
  418.   end
  419.   #--------------------------------------------------------------------------
  420.   # * New method: check_event_trigger_move
  421.   #--------------------------------------------------------------------------
  422.   def check_event_trigger_move(d)
  423.     set_direction(d)
  424.     check_event_trigger_touch_front
  425.   end
  426.   #--------------------------------------------------------------------------
  427.   # * New method: collision_condition?
  428.   #--------------------------------------------------------------------------
  429.   def collision_condition?(x, y, bw, bh, event, event_id, side)
  430.     return false if event && self.id == event_id
  431.     return false unless collision?(x, y, bw, bh)
  432.     return false unless normal_priority? || event
  433.     return false if side && !side_collision?
  434.     return true
  435.   end
  436.   #--------------------------------------------------------------------------
  437.   # * New method: follower_control_move_update
  438.   #--------------------------------------------------------------------------
  439.   def follower_control_move_update(horz, vert)
  440.     return unless $imported[:ve_followers_options]
  441.     return unless player? || follower?
  442.     add_move_update(horz == vert ? [horz] : [horz, vert])
  443.   end
  444.   #--------------------------------------------------------------------------
  445.   # * New method: passable?
  446.   #--------------------------------------------------------------------------
  447.   def passable?(x, y, d)
  448.     x = fix_position(x)
  449.     y = fix_position(y)
  450.     passable1 = passable_tile?(x, y, d)
  451.     passable2 = character_collision?(x, y, d)
  452.     fix_movement(x, y, d)  if player? && !passable1 && passable2
  453.     fix_collision(x, y, d) if player? && !passable2 && passable1
  454.     passable1 && passable2
  455.   end
  456.   #--------------------------------------------------------------------------
  457.   # * New method: passable_tile?
  458.   #--------------------------------------------------------------------------
  459.   def passable_tile?(x, y, d)
  460.     result = true
  461.     result = passable_down?(x, y)  if d == 2
  462.     result = passable_left?(x, y)  if d == 4
  463.     result = passable_right?(x, y) if d == 6
  464.     result = passable_up?(x, y)    if d == 8
  465.     result
  466.   end
  467.   #--------------------------------------------------------------------------
  468.   # * New method: locked_tile?
  469.   #--------------------------------------------------------------------------
  470.   def locked_tile?(x, y, d = 0)
  471.     list = [2, 4, 6, 8] - [d]
  472.     list.all? {|d| !map_passable?(x, y, d) }
  473.   end
  474.   #--------------------------------------------------------------------------
  475.   # * New method: locked_move?
  476.   #--------------------------------------------------------------------------
  477.   def locked_move?(x, y)
  478.     !passable_down?(x, y)  && !passable_left?(x, y)
  479.     !passable_right?(x, y) && !passable_up?(x, y)
  480.   end
  481.   #--------------------------------------------------------------------------
  482.   # * New method: passable_down?
  483.   #--------------------------------------------------------------------------
  484.   def passable_down?(x, y)
  485.     passable_normal?(x.ceil, y.to_i, 2, 4, x.ceil?) &&
  486.     passable_normal?(x.to_i, y.to_i, 2, 6, x.ceil?)
  487.   end
  488.   #--------------------------------------------------------------------------
  489.   # * New method: passable_left?
  490.   #--------------------------------------------------------------------------
  491.   def passable_left?(x, y)
  492.     passable_normal?(x.ceil, y.ceil, 4, 8, y.ceil?) &&
  493.     passable_normal?(x.ceil, y.to_i, 4, 2, y.ceil?)
  494.   end
  495.   #--------------------------------------------------------------------------
  496.   # * New method: passable_right?
  497.   #--------------------------------------------------------------------------
  498.   def passable_right?(x, y)
  499.     passable_normal?(x.to_i, y.ceil, 6, 8, y.ceil?) &&
  500.     passable_normal?(x.to_i, y.to_i, 6, 2, y.ceil?)
  501.   end
  502.   #--------------------------------------------------------------------------
  503.   # * New method: passable_up?
  504.   #--------------------------------------------------------------------------
  505.   def passable_up?(x, y)
  506.     passable_normal?(x.ceil, y.ceil, 8, 4, x.ceil?) &&
  507.     passable_normal?(x.to_i, y.ceil, 8, 6, x.ceil?)
  508.   end
  509.   #--------------------------------------------------------------------------
  510.   # * New method: passable_normal?
  511.   #--------------------------------------------------------------------------
  512.   def passable_normal?(x, y, d, d2, ceil = false)
  513.     x1 = $game_map.round_x(x)
  514.     y1 = $game_map.round_y(y)
  515.     x2 = $game_map.check_x_with_direction(x1, d)
  516.     y2 = $game_map.check_y_with_direction(y1, d)
  517.     x3 = $game_map.round_x_with_direction(x1, d)
  518.     y3 = $game_map.round_y_with_direction(y1, d)
  519.     return false unless $game_map.valid?(x3, y3)
  520.     return true  if @through || debug_through?
  521.     return false unless map_passable?(x2, y2, d2) || !ceil
  522.     return false unless move_passable1?(x1, y1, x2, y2, d)
  523.     return false unless move_passable2?(x1, y1, x2, y2, d)
  524.     return true
  525.   end
  526.   #--------------------------------------------------------------------------
  527.   # * New method: move_passable1?
  528.   #--------------------------------------------------------------------------
  529.   def move_passable1?(x1, y1, x2, y2, d)
  530.     map_passable?(x1, y1, d) || map_passable?(x2, y2, d)
  531.   end
  532.   #--------------------------------------------------------------------------
  533.   # * New method: move_passable?
  534.   #--------------------------------------------------------------------------
  535.   def move_passable2?(x1, y1, x2, y2, d)
  536.     map_passable?(x2, y2, reverse_dir(d)) && (map_passable?(x1, y1, d) ||
  537.     locked_tile?(x1, y1))
  538.   end
  539.   #--------------------------------------------------------------------------
  540.   # * New method: fix_movement
  541.   #--------------------------------------------------------------------------
  542.   def fix_movement(x, y, d)
  543.     return if (@diagonal && @diagonal != 0) || @diagonal_move
  544.     fix_movement_horiz(x, y, d) if (d == 2 || d == 8) && x.ceil?
  545.     fix_movement_vert(x, y, d)  if (d == 4 || d == 6) && y.ceil?
  546.   end
  547.   #--------------------------------------------------------------------------
  548.   # * New method: fix_movement_horiz
  549.   #--------------------------------------------------------------------------
  550.   def fix_movement_horiz(x, y, d)
  551.     adjust = x - x.to_i
  552.     fix_move_straight(4) if fix_movement_left?(x, y, d)  && adjust < 0.5
  553.     fix_move_straight(6) if fix_movement_right?(x, y, d) && adjust > 0.5
  554.   end
  555.   #--------------------------------------------------------------------------
  556.   # * New method: fix_movement_ver
  557.   #--------------------------------------------------------------------------
  558.   def fix_movement_vert(x, y, d)
  559.     adjust = y - y.to_i
  560.     fix_move_straight(2) if fix_movement_down?(x, y, d) && adjust > 0.5
  561.     fix_move_straight(8) if fix_movement_up?(x, y, d)   && adjust < 0.5
  562.   end
  563.   #--------------------------------------------------------------------------
  564.   # * New method: fix_movement_down?
  565.   #--------------------------------------------------------------------------
  566.   def fix_movement_down?(x, y, d)
  567.     passable_normal?(x.to_i, y.ceil, d, 0, false) && movement_fix?(x, y, 2)
  568.   end
  569.   #--------------------------------------------------------------------------
  570.   # * New method: fix_movement_left?
  571.   #--------------------------------------------------------------------------
  572.   def fix_movement_left?(x, y, d)
  573.     passable_normal?(x.to_i, y.to_i, d, 0, false) && movement_fix?(x, y, 4)
  574.   end
  575.   #--------------------------------------------------------------------------
  576.   # * New method: fix_movement_right?
  577.   #--------------------------------------------------------------------------
  578.   def fix_movement_right?(x, y, d)
  579.     passable_normal?(x.ceil, y.to_i, d, 0, false) && movement_fix?(x, y, 6)
  580.   end
  581.   #--------------------------------------------------------------------------
  582.   # * New method: fix_movement_up?
  583.   #--------------------------------------------------------------------------
  584.   def fix_movement_up?(x, y, d)
  585.     passable_normal?(x.to_i, y.to_i, d, 0, false) && movement_fix?(x, y, 8)
  586.   end
  587.   #--------------------------------------------------------------------------
  588.   # * New method: movement_fix?
  589.   #--------------------------------------------------------------------------
  590.   def movement_fix?(x, y, d)
  591.     passable_tile?(x, y, d) && character_collision?(x, y, d)
  592.   end
  593.   #--------------------------------------------------------------------------
  594.   # * New method: fix_collision
  595.   #--------------------------------------------------------------------------
  596.   def fix_collision(x, y, d)
  597.     return if (@diagonal && @diagonal != 0) || @diagonal_move
  598.     @side_collision = true
  599.     fix_collision_horiz(x, y, d) if (d == 2 || d == 8)
  600.     fix_collision_vert(x, y, d)  if (d == 4 || d == 6)
  601.     @side_collision = false
  602.   end
  603.   #--------------------------------------------------------------------------
  604.   # * New method: fix_collision_horiz
  605.   #--------------------------------------------------------------------------
  606.   def fix_collision_horiz(x, y, d)
  607.     fix_move_straight(4) if fix_collision_left?(x, y, d)
  608.     fix_move_straight(6) if fix_collision_right?(x, y, d)
  609.   end
  610.   #--------------------------------------------------------------------------
  611.   # * New method: fix_collision_vert
  612.   #--------------------------------------------------------------------------
  613.   def fix_collision_vert(x, y, d)
  614.     fix_move_straight(2) if fix_collision_down?(x, y, d)
  615.     fix_move_straight(8) if fix_collision_up?(x, y, d)
  616.   end
  617.   #--------------------------------------------------------------------------
  618.   # * New method: fix_collision_down?
  619.   #--------------------------------------------------------------------------
  620.   def fix_collision_down?(x, y, d)
  621.     !character_collision?(x, y, d) && collision_fix?(x, y, d, 2)
  622.   end
  623.   #--------------------------------------------------------------------------
  624.   # * New method: fix_collision_left?
  625.   #--------------------------------------------------------------------------
  626.   def fix_collision_left?(x, y, d)
  627.     !character_collision?(x, y, d) && collision_fix?(x, y, d,  4)
  628.   end
  629.   #--------------------------------------------------------------------------
  630.   # * New method: fix_collision_right?
  631.   #--------------------------------------------------------------------------
  632.   def fix_collision_right?(x, y, d)
  633.     !character_collision?(x, y, d) && collision_fix?(x, y, d, 6)
  634.   end
  635.   #--------------------------------------------------------------------------
  636.   # * New method: fix_collision_up?
  637.   #--------------------------------------------------------------------------
  638.   def fix_collision_up?(x, y, d)
  639.     !character_collision?(x, y, d) && collision_fix?(x, y, d, 8)
  640.   end
  641.   #--------------------------------------------------------------------------
  642.   # * New method: collision_fix?
  643.   #--------------------------------------------------------------------------
  644.   def collision_fix?(x, y, d, d2)
  645.     side_collision_fix?(x, y, d, d2, 2) && side_fix?(x, y, d2)
  646.   end
  647.   #--------------------------------------------------------------------------
  648.   # * New method: side_collision_fix?
  649.   #--------------------------------------------------------------------------
  650.   def side_collision_fix?(x, y, d, d2, t)
  651.     t.times.any? do |i|
  652.       x2, y2 = x, y
  653.       y2 += (t - i) * 0.125 if d2 == 2
  654.       x2 -= (t - i) * 0.125 if d2 == 4
  655.       x2 += (t - i) * 0.125 if d2 == 6
  656.       y2 -= (t - i) * 0.125 if d2 == 8
  657.       character_collision?(x2, y2, d)
  658.     end
  659.   end
  660.   #--------------------------------------------------------------------------
  661.   # * New method: side_fix?
  662.   #--------------------------------------------------------------------------
  663.   def side_fix?(x, y, d)
  664.     passable_tile?(x, y, d) && character_collision?(x, y, d)
  665.   end
  666.   #--------------------------------------------------------------------------
  667.   # * New method: fix_move_straight
  668.   #--------------------------------------------------------------------------
  669.   def fix_move_straight(d)
  670.     return if moving?
  671.     @x = $game_map.round_x_with_direction(@x, d)
  672.     @y = $game_map.round_y_with_direction(@y, d)
  673.     follower_control_move_update(d, d)
  674.     add_next_movement(d)
  675.     increase_steps
  676.     @moved = player?
  677.   end
  678.   #--------------------------------------------------------------------------
  679.   # * New method: add_next_movement
  680.   #--------------------------------------------------------------------------
  681.   def add_next_movement(d)
  682.     return unless follower? || player?
  683.     return if $imported[:ve_followers_control] && follower_control_block
  684.     return if $game_player.followers.gathering?
  685.     @next_movement.push(d)
  686.   end
  687.   #--------------------------------------------------------------------------
  688.   # * New method: follower_control_block
  689.   #--------------------------------------------------------------------------
  690.   def follower_control_block
  691.     return true if follower? && origin_position
  692.     return true if $game_player.followers.gathering_origin?
  693.     return false
  694.   end
  695.   #--------------------------------------------------------------------------
  696.   # * New method: front_collision?
  697.   #--------------------------------------------------------------------------
  698.   def front_collision?(x, y, d)
  699.     return false if (@diagonal && @diagonal != 0) || @diagonal_move
  700.     result = !front_collision_horiz(x, y, d) if (d == 2 || d == 8)
  701.     result = !front_collision_vert(x, y, d)  if (d == 4 || d == 6)
  702.     result
  703.   end
  704.   #--------------------------------------------------------------------------
  705.   # * New method: front_collision_horiz
  706.   #--------------------------------------------------------------------------
  707.   def front_collision_horiz(x, y, d)
  708.     side_collision_fix?(x, y, d, 4, 4) || side_collision_fix?(x, y, d, 6, 4)
  709.   end
  710.   #--------------------------------------------------------------------------
  711.   # * New method: front_collision_vert
  712.   #--------------------------------------------------------------------------
  713.   def front_collision_vert(x, y, d)
  714.     side_collision_fix?(x, y, d, 2, 4) || side_collision_fix?(x, y, d, 8, 4)
  715.   end
  716.   #--------------------------------------------------------------------------
  717.   # * New method: step_over?
  718.   #--------------------------------------------------------------------------
  719.   def step_over?
  720.     @through
  721.   end
  722.   #--------------------------------------------------------------------------
  723.   # * New method: bw
  724.   #--------------------------------------------------------------------------
  725.   def bw
  726.     setup_bitmap_dimension unless @bw && character_name == @character_name_wh
  727.     @bw
  728.   end
  729.   #--------------------------------------------------------------------------
  730.   # * New method: bh
  731.   #--------------------------------------------------------------------------
  732.   def bh
  733.     setup_bitmap_dimension unless @bh && character_name == @character_name_wh
  734.     @bh
  735.   end
  736.   #--------------------------------------------------------------------------
  737.   # * New method: setup_bitmap_dimension
  738.   #--------------------------------------------------------------------------
  739.   def setup_bitmap_dimension
  740.     @character_name_wh = character_name
  741.     bitmap = Cache.character(character_name).clone
  742.     sign = @character_name[/^[\!\$]./]
  743.     if character_name != "" && @tile_id == 0 && sign && sign.include?('[code]#==============================================================================
  744. # ** Victor Engine - Basic Module
  745. #------------------------------------------------------------------------------
  746. # Author : Victor Sant
  747. #
  748. # Version History:
  749. #  v 1.00 - 2011.12.19 > First relase
  750. #  v 1.01 - 2011.12.21 > Added Event Troop notes
  751. #  v 1.02 - 2011.12.22 > Added character frames value
  752. #  v 1.03 - 2011.12.30 > Added Actor and Enemy notes
  753. #  v 1.04 - 2012.01.01 > Added party average level and map actors
  754. #  v 1.05 - 2012.01.04 > Compatibility with Characters Scripts
  755. #  v 1.06 - 2012.01.07 > Compatibility with Fog and Light Effect
  756. #                      > Added new Sprite Character functions
  757. #  v 1.07 - 2012.01.11 > Compatibility with Control Text and Codes
  758. #  v 1.08 - 2012.01.13 > Compatibility with Trait Control
  759. #  v 1.09 - 2012.01.15 > Fixed the Regular Expressions problem with "" and “”
  760. #  v 1.10 - 2012.01.18 > Compatibility with Automatic Battlers
  761. #  v 1.11 - 2012.01.26 > Compatibility with Followers Options
  762. #                        Compatibility with Animated Battle beta
  763. #  v 1.12 - 2012.02.08 > Compatibility with Animated Battle
  764. #  v 1.13 - 2012.02.18 > Fix for non RTP dependant encrypted projects
  765. #  v 1.14 - 2012.03.11 > Better version handling and required messages
  766. #  v 1.15 - 2012.03.11 > Added level variable for enemies (to avoid crashes)
  767. #  v 1.16 - 2012.03.21 > Compatibility with Follower Control
  768. #  v 1.17 - 2012.03.22 > Compatibility with Follower Control new method
  769. #  v 1.18 - 2012.03.22 > Added Battler Types tag support
  770. #  v 1.19 - 2012.05.20 > Compatibility with Map Turn Battle
  771. #  v 1.20 - 2012.05.21 > Fix for older RMVXa versions
  772. #  v 1.21 - 2012.05.29 > Compatibility with Pixel Movement
  773. #  v 1.22 - 2012.07.02 > Compatibility with Terrain States
  774. #  v 1.23 - 2012.07.03 > Fix for Pixel Movement
  775. #  v 1.24 - 2012.07.17 > Compatibility with Critical Hit Effects
  776. #  v 1.25 - 2012.07.24 > Compatibility with Moving Plaforms
  777. #  v 1.26 - 2012.07.30 > Compatibility with Automatic Battlers
  778. #  v 1.27 - 2012.08.01 > Compatibility with Custom Slip Effect
  779. #  v 1.28 - 2012.08.03 > Compatibility with Custom Slip Effect v 1.01
  780. #------------------------------------------------------------------------------
  781. #   This is the basic script for the system from Victory Engine and is
  782. # required to use the scripts from the engine. This script offer some new
  783. # functions to be used within many scripts of the engine.
  784. #------------------------------------------------------------------------------
  785. # Compatibility
  786. #   Required for the Victor Engine
  787. #
  788. # * Overwrite methods
  789. #   class << Cache
  790. #     def self.character(filename)
  791. #
  792. #   class Sprite_Character < Sprite_Base
  793. #     def set_character_bitmap
  794. #
  795. # * Alias methods
  796. #   class Game_Interpreter
  797. #     def command_108
  798. #
  799. #   class Window_Base < Window
  800. #     def convert_escape_characters(text)
  801. #
  802. #------------------------------------------------------------------------------
  803. # Instructions:
  804. #  To instal the script, open you script editor and paste this script on
  805. #  a new section bellow the Materials section.
  806. #
  807. #------------------------------------------------------------------------------
  808. # New functions
  809. #
  810. # * Random number between two vales
  811. #   rand_between(min, max)
  812. #    min : min value
  813. #    max : max value
  814. #   Can be called from any class, this method return an random value between
  815. #   two specific numbers
  816. #
  817. # * Random array value
  818. #   <Array>.random
  819. #   <Array>.random!
  820. #   Returns a random object from the array, the method .random! is destructive,
  821. #   removing the value returned from the array.
  822. #
  823. # * Sum of the numeric values of a array
  824. #   <Array>.sum
  825. #   Returns the sum of all numeric values
  826. #
  827. # * Average of all numeric values from the array
  828. #   <Array>.average(float = false)
  829. #    float : float flag
  830. #   Returns the average of all numeric values, if floa is true, the value
  831. #   returned is a float, otherwise it's a integer.
  832. #
  833. # * Note for events
  834. #   <Event>.note
  835. #   By default, events doesn't have note boxes. This command allows to use
  836. #   comments as note boxes, following the same format as the ones on the
  837. #   database. Returns all comments on the active page of the event.
  838. #
  839. # * Comment calls
  840. #   <Event>.comment_call
  841. #   Another function for comment boxes, by default, they have absolutely no
  842. #   effect in game when called. But this method allows to make the comment
  843. #   box to behave like an script call, but with the versatility of the
  844. #   note boxes. Remember that the commands will only take effect if there
  845. #   is scripts to respond to the comment code.
  846. #
  847. #==============================================================================

  848. #==============================================================================
  849. # ** Victor Engine
  850. #------------------------------------------------------------------------------
  851. #   Setting module for the Victor Engine
  852. #==============================================================================

  853. module Victor_Engine
  854.   #--------------------------------------------------------------------------
  855.   # * New method: required_script
  856.   #--------------------------------------------------------------------------
  857.   def self.required_script(name, req, version, type = 0)
  858.     if type != :bellow && (!$imported[req] || $imported[req] < version)
  859.       msg = "The script '%s' requires the script\n"
  860.       case type
  861.       when :above
  862.         msg += "'%s' v%s or higher above it to work properly\n"
  863.       else
  864.         msg += "'%s' v%s or higher to work properly\n"
  865.       end
  866.       msg += "Go to http://victorscripts.wordpress.com/ to download this script."
  867.       self.exit_message(msg, name, req, version)
  868.     elsif type == :bellow && $imported[req]
  869.       msg =  "The script '%s' requires the script\n"
  870.       msg += "'%s' to be put bellow it\n"
  871.       msg += "move the scripts to the proper position"
  872.       self.exit_message(msg, name, req, version)
  873.     end
  874.   end
  875.   #--------------------------------------------------------------------------
  876.   # * New method: exit_message
  877.   #--------------------------------------------------------------------------
  878.   def self.exit_message(message, name, req, version)
  879.     name = self.script_name(name)
  880.     req  = self.script_name(req)
  881.     msgbox(sprintf(message, name, req, version))
  882.     exit
  883.   end
  884.   #--------------------------------------------------------------------------
  885.   # * New method: script_name
  886.   #--------------------------------------------------------------------------
  887.   def self.script_name(name, ext = "VE")
  888.     name = name.to_s.gsub("_", " ").upcase.split
  889.     name.collect! {|char| char == ext ? "#{char} -" : char.capitalize }
  890.     name.join(" ")
  891.   end
  892. end

  893. $imported ||= {}
  894. $imported[:ve_basic_module] = 1.28

  895. #==============================================================================
  896. # ** Object
  897. #------------------------------------------------------------------------------
  898. #  This class is the superclass of all other classes.
  899. #==============================================================================

  900. class Object
  901.   #--------------------------------------------------------------------------
  902.   # * Include setting module
  903.   #--------------------------------------------------------------------------
  904.   include Victor_Engine
  905.   #-------------------------------------------------------------------------
  906.   # * New method: rand_between
  907.   #-------------------------------------------------------------------------
  908.   def rand_between(min, max)
  909.     min + rand(max - min + 1)
  910.   end
  911.   #--------------------------------------------------------------------------
  912.   # * New method: numeric?
  913.   #--------------------------------------------------------------------------
  914.   def numeric?
  915.     return false
  916.   end
  917.   #--------------------------------------------------------------------------
  918.   # * New method: string?
  919.   #--------------------------------------------------------------------------
  920.   def string?
  921.     return false
  922.   end
  923.   #--------------------------------------------------------------------------
  924.   # * New method: array?
  925.   #--------------------------------------------------------------------------
  926.   def array?
  927.     return false
  928.   end
  929.   #--------------------------------------------------------------------------
  930.   # * New method: float?
  931.   #--------------------------------------------------------------------------
  932.   def float?
  933.     return false
  934.   end
  935.   #--------------------------------------------------------------------------
  936.   # * New method: item?
  937.   #--------------------------------------------------------------------------
  938.   def item?
  939.     return false
  940.   end
  941.   #--------------------------------------------------------------------------
  942.   # * New method: skill?
  943.   #--------------------------------------------------------------------------
  944.   def skill?
  945.     return false
  946.   end
  947.   #--------------------------------------------------------------------------
  948.   # * New method: file_exist?
  949.   #--------------------------------------------------------------------------
  950.   def file_exist?(path, filename)
  951.     $file_list ||= {}
  952.     $file_list[path + filename] ||= file_test(path, filename)
  953.     $file_list[path + filename]
  954.   end
  955.   #--------------------------------------------------------------------------
  956.   # * New method: get_file_list
  957.   #--------------------------------------------------------------------------
  958.   def file_test(path, filename)
  959.     bitmap = Cache.load_bitmap(path, filename) rescue nil
  960.     bitmap ? true : false
  961.   end
  962.   #--------------------------------------------------------------------------
  963.   # * New method: character_exist?
  964.   #--------------------------------------------------------------------------
  965.   def character_exist?(filename)
  966.     file_exist?("Graphics/Characters/", filename)
  967.   end
  968.   #--------------------------------------------------------------------------
  969.   # * New method: battler_exist?
  970.   #--------------------------------------------------------------------------
  971.   def battler_exist?(filename)
  972.     file_exist?("Graphics/Battlers/", filename)
  973.   end
  974.   #--------------------------------------------------------------------------
  975.   # * New method: get_filename
  976.   #--------------------------------------------------------------------------
  977.   def get_filename
  978.     "[\"'“‘]([^\"'”‘”’]+)[\"'”’]"
  979.   end
  980.   #--------------------------------------------------------------------------
  981.   # * New method: get_all_values
  982.   #--------------------------------------------------------------------------
  983.   def get_all_values(value1, value2 = nil)
  984.     value2 = value1 unless value2
  985.     /<#{value1}>((?:[^<]|<[^\/])*)<\/#{value2}>/im
  986.   end
  987.   #--------------------------------------------------------------------------
  988.   # * New method: make_symbol
  989.   #--------------------------------------------------------------------------
  990.   def make_symbol(string)
  991.     string.downcase.gsub(" ", "_").to_sym
  992.   end
  993.   #--------------------------------------------------------------------------
  994.   # * New method: make_string
  995.   #--------------------------------------------------------------------------
  996.   def make_string(symbol)
  997.     symbol.to_s.gsub("_", " ").upcase
  998.   end
  999.   #--------------------------------------------------------------------------
  1000.   # * New method: returing_value
  1001.   #--------------------------------------------------------------------------
  1002.   def returing_value(i, x)
  1003.     i % (x * 2) >= x ? (x * 2) - i % (x * 2) : i % (x * 2)
  1004.   end
  1005.   #--------------------------------------------------------------------------
  1006.   # New method: in_rect?
  1007.   #--------------------------------------------------------------------------
  1008.   def in_rect?(w, h, x1, y1, x2, y2, fx = 0)
  1009.     aw, ah, ax, ay, bx, by = setup_area(w, h, x1, y1, x2, y2, fx)
  1010.     bx > ax - aw && bx < ax + aw && by > ay - ah && by < ay + ah
  1011.   end
  1012.   #--------------------------------------------------------------------------
  1013.   # New method: in_radius?
  1014.   #--------------------------------------------------------------------------
  1015.   def in_radius?(w, h, x1, y1, x2, y2, fx = 0)
  1016.     aw, ah, ax, ay, bx, by = setup_area(w, h, x1, y1, x2, y2, fx)
  1017.     ((bx - ax) ** 2 / aw ** 2) + ((by - ay) ** 2 / ah ** 2) <= 1
  1018.   end
  1019.   #--------------------------------------------------------------------------
  1020.   # New method: setup_area
  1021.   #--------------------------------------------------------------------------
  1022.   def setup_area(w, h, x1, y1, x2, y2, fx)
  1023.     aw = w
  1024.     ah = h * aw
  1025.     ax = x1
  1026.     ay = y1
  1027.     bx = x2
  1028.     by = y2
  1029.     bx += fx / 4 if ax > bx
  1030.     bx -= fx / 4 if ax < bx
  1031.     [aw, ah, ax, ay, bx, by]
  1032.   end
  1033. end

  1034. #==============================================================================
  1035. # ** String
  1036. #------------------------------------------------------------------------------
  1037. # The string class. Can handle character sequences of arbitrary lengths.
  1038. #==============================================================================

  1039. class String
  1040.   #--------------------------------------------------------------------------
  1041.   # * New method: string?
  1042.   #--------------------------------------------------------------------------
  1043.   def string?
  1044.     return true
  1045.   end
  1046. end

  1047. #==============================================================================
  1048. # ** Numeric
  1049. #------------------------------------------------------------------------------
  1050. #  This is the abstract class for numbers.
  1051. #==============================================================================

  1052. class Numeric
  1053.   #--------------------------------------------------------------------------
  1054.   # * New method: numeric?
  1055.   #--------------------------------------------------------------------------
  1056.   def numeric?
  1057.     return true
  1058.   end
  1059.   #--------------------------------------------------------------------------
  1060.   # * New method: ceil?
  1061.   #--------------------------------------------------------------------------
  1062.   def ceil?
  1063.     return false
  1064.   end
  1065. end

  1066. #==============================================================================
  1067. # ** Float
  1068. #------------------------------------------------------------------------------
  1069. #  This is the abstract class for the floating point values.
  1070. #==============================================================================

  1071. class Float
  1072.   #--------------------------------------------------------------------------
  1073.   # * New method: float?
  1074.   #--------------------------------------------------------------------------
  1075.   def float?
  1076.     return true
  1077.   end
  1078.   #--------------------------------------------------------------------------
  1079.   # * New method: ceil?
  1080.   #--------------------------------------------------------------------------
  1081.   def ceil?
  1082.     self != self.ceil
  1083.   end
  1084. end

  1085. #==============================================================================
  1086. # ** Array     
  1087. #------------------------------------------------------------------------------
  1088. #  This class store arbitrary Ruby objects.
  1089. #==============================================================================

  1090. class Array
  1091.   #--------------------------------------------------------------------------
  1092.   # * New method: array?
  1093.   #--------------------------------------------------------------------------
  1094.   def array?
  1095.     return true
  1096.   end
  1097.   #-------------------------------------------------------------------------
  1098.   # * New method: random
  1099.   #-------------------------------------------------------------------------
  1100.   def random
  1101.     self[rand(size)]
  1102.   end
  1103.   #-------------------------------------------------------------------------
  1104.   # * New method: random!
  1105.   #-------------------------------------------------------------------------
  1106.   def random!
  1107.     self.delete_at(rand(size))
  1108.   end
  1109.   #---------------------------------------------------------------------------
  1110.   # * New method: sum
  1111.   #---------------------------------------------------------------------------
  1112.   def sum
  1113.     self.inject(0) {|r, n| r += (n.numeric? ? n : 0)}
  1114.   end
  1115.   #---------------------------------------------------------------------------
  1116.   # * New method: average
  1117.   #---------------------------------------------------------------------------
  1118.   def average(float = false)
  1119.     self.sum / [(float ? size.to_f : size.to_i), 1].max
  1120.   end
  1121.   #---------------------------------------------------------------------------
  1122.   # * New method: next_item
  1123.   #---------------------------------------------------------------------------
  1124.   def next_item
  1125.     item = self.shift
  1126.     self.push(item)
  1127.     item
  1128.   end
  1129.   #---------------------------------------------------------------------------
  1130.   # * New method: previous_item
  1131.   #---------------------------------------------------------------------------
  1132.   def previous_item
  1133.     item = self.pop
  1134.     self.unshift(item)
  1135.     item
  1136.   end
  1137. end

  1138. #==============================================================================
  1139. # ** RPG::Troop::Page
  1140. #------------------------------------------------------------------------------
  1141. #  This is the data class for battle events (pages).
  1142. #==============================================================================

  1143. class RPG::Troop::Page
  1144.   #--------------------------------------------------------------------------
  1145.   # * New method: note
  1146.   #--------------------------------------------------------------------------
  1147.   def note
  1148.     return "" if !@list || @list.size <= 0
  1149.     comment_list = []
  1150.     @list.each do |item|
  1151.       next unless item && (item.code == 108 || item.code == 408)
  1152.       comment_list.push(item.parameters[0])
  1153.     end
  1154.     comment_list.join("\r\n")
  1155.   end
  1156. end

  1157. #==============================================================================
  1158. # ** RPG::UsableItem
  1159. #------------------------------------------------------------------------------
  1160. #  This is the superclass for skills and items.
  1161. #==============================================================================

  1162. class RPG::UsableItem < RPG::BaseItem
  1163.   #--------------------------------------------------------------------------
  1164.   # * New method: for_all_targets?
  1165.   #--------------------------------------------------------------------------
  1166.   def for_all_targets?
  1167.     return false
  1168.   end
  1169. end

  1170. #==============================================================================
  1171. # ** RPG::Skill
  1172. #------------------------------------------------------------------------------
  1173. #  This is the data class for skills.
  1174. #==============================================================================

  1175. class RPG::Skill < RPG::UsableItem
  1176.   #--------------------------------------------------------------------------
  1177.   # * New method: item?
  1178.   #--------------------------------------------------------------------------
  1179.   def item?
  1180.     return false
  1181.   end
  1182.   #--------------------------------------------------------------------------
  1183.   # * New method: skill?
  1184.   #--------------------------------------------------------------------------
  1185.   def skill?
  1186.     return true
  1187.   end
  1188.   #--------------------------------------------------------------------------
  1189.   # * New method: type_set
  1190.   #--------------------------------------------------------------------------
  1191.   def type_set
  1192.     [stype_id]
  1193.   end  
  1194. end

  1195. #==============================================================================
  1196. # ** RPG::Item
  1197. #------------------------------------------------------------------------------
  1198. #  This is the data class for items.
  1199. #==============================================================================

  1200. class RPG::Item < RPG::UsableItem
  1201.   #--------------------------------------------------------------------------
  1202.   # * New method: item?
  1203.   #--------------------------------------------------------------------------
  1204.   def item?
  1205.     return true
  1206.   end
  1207.   #--------------------------------------------------------------------------
  1208.   # * New method: skill?
  1209.   #--------------------------------------------------------------------------
  1210.   def skill?
  1211.     return false
  1212.   end
  1213.   #--------------------------------------------------------------------------
  1214.   # * New method: type_set
  1215.   #--------------------------------------------------------------------------
  1216.   def type_set
  1217.     [itype_id]
  1218.   end  
  1219. end

  1220. #==============================================================================
  1221. # ** Cache
  1222. #------------------------------------------------------------------------------
  1223. #  This module loads each of graphics, creates a Bitmap object, and retains it.
  1224. # To speed up load times and conserve memory, this module holds the created
  1225. # Bitmap object in the internal hash, allowing the program to return
  1226. # preexisting objects when the same bitmap is requested again.
  1227. #==============================================================================

  1228. class << Cache
  1229.   #--------------------------------------------------------------------------
  1230.   # * Overwrite method: character
  1231.   #--------------------------------------------------------------------------
  1232.   def character(filename, hue = 0)
  1233.     load_bitmap("Graphics/Characters/", filename, hue)
  1234.   end
  1235.   #--------------------------------------------------------------------------
  1236.   # * New method: cache
  1237.   #--------------------------------------------------------------------------
  1238.   def cache
  1239.     @cache
  1240.   end
  1241. end

  1242. #==============================================================================
  1243. # ** Game_BattlerBase
  1244. #------------------------------------------------------------------------------
  1245. #  This class handles battlers. It's used as a superclass of the Game_Battler
  1246. # classes.
  1247. #==============================================================================

  1248. class Game_BattlerBase
  1249.   #--------------------------------------------------------------------------
  1250.   # * Public Instance Variables
  1251.   #--------------------------------------------------------------------------
  1252.   attr_reader   :buffs
  1253.   #--------------------------------------------------------------------------
  1254.   # * New method: get_cond
  1255.   #--------------------------------------------------------------------------
  1256.   def get_cond(text)
  1257.     case text.upcase
  1258.     when "HIGHER"    then ">"
  1259.     when "LOWER"     then "<"
  1260.     when "EQUAL"     then "=="
  1261.     when "DIFFERENT" then "!="
  1262.     else "!="
  1263.     end
  1264.   end
  1265.   #--------------------------------------------------------------------------
  1266.   # * New method: get_param
  1267.   #--------------------------------------------------------------------------
  1268.   def get_param(text)
  1269.     case text.upcase
  1270.     when "MAXHP" then self.mhp
  1271.     when "MAXMP" then self.mmp
  1272.     when "MAXTP" then self.max_tp
  1273.     else eval("self.#{text.downcase}")
  1274.     end
  1275.   end
  1276.   #--------------------------------------------------------------------------
  1277.   # * New method: get_param_id
  1278.   #--------------------------------------------------------------------------
  1279.   def get_param_id(text)
  1280.     case text.upcase
  1281.     when "MAXHP", "HP" then 0
  1282.     when "MAXMP", "MP" then 1
  1283.     when "ATK" then 2
  1284.     when "DEF" then 3
  1285.     when "MAT" then 4
  1286.     when "MDF" then 5
  1287.     when "AGI" then 6
  1288.     when "LUK" then 7
  1289.     end
  1290.   end
  1291.   #--------------------------------------------------------------------------
  1292.   # * New method: type
  1293.   #--------------------------------------------------------------------------
  1294.   def type
  1295.     list = []
  1296.     get_all_notes.scan(/<BATTLER TYPE: ((?:\w+ *,? *)+)>/i) do
  1297.       $1.scan(/(\d+)/i) { list.push(make_symbol($1)) }
  1298.     end
  1299.     list.uniq
  1300.   end
  1301.   #--------------------------------------------------------------------------
  1302.   # * New method: danger?
  1303.   #--------------------------------------------------------------------------
  1304.   def danger?
  1305.     hp < mhp * 25 / 100
  1306.   end
  1307.   #--------------------------------------------------------------------------
  1308.   # * New method: sprite
  1309.   #--------------------------------------------------------------------------
  1310.   def sprite
  1311.     valid = SceneManager.scene_is?(Scene_Battle) && SceneManager.scene.spriteset
  1312.     valid ? SceneManager.scene.spriteset.sprite(self) : nil
  1313.   end
  1314.   #--------------------------------------------------------------------------
  1315.   # * New method:
  1316.   #--------------------------------------------------------------------------
  1317.   def element_set(item)
  1318.     element_set  = [item.damage.element_id]
  1319.     element_set += atk_elements if item.damage.element_id < 0
  1320.     element_set.compact
  1321.   end
  1322.   #--------------------------------------------------------------------------
  1323.   # * New method: add_state_normal
  1324.   #--------------------------------------------------------------------------
  1325.   def add_state_normal(state_id, rate = 1, user = self)
  1326.     chance  = rate
  1327.     chance *= state_rate(state_id)
  1328.     chance *= luk_effect_rate(user)
  1329.     add_state(state_id) if rand < state_rate(state_id)
  1330.   end
  1331.   #--------------------------------------------------------------------------
  1332.   # * New method: damaged?
  1333.   #--------------------------------------------------------------------------
  1334.   def damaged?
  1335.     @result.hp_damage != 0 || @result.mp_damage != 0 || @result.tp_damage != 0
  1336.   end
  1337.   #--------------------------------------------------------------------------
  1338.   # * New method: mtp
  1339.   #--------------------------------------------------------------------------
  1340.   def mtp
  1341.     return 100
  1342.   end
  1343. end

  1344. #==============================================================================
  1345. # ** Game_Battler
  1346. #------------------------------------------------------------------------------
  1347. #  This class deals with battlers. It's used as a superclass of the Game_Actor
  1348. # and Game_Enemy classes.
  1349. #==============================================================================

  1350. class Game_Battler < Game_BattlerBase
  1351.   #--------------------------------------------------------------------------
  1352.   # * New method: cri_rate
  1353.   #--------------------------------------------------------------------------
  1354.   def cri_rate(user, item)
  1355.     user.cri
  1356.   end
  1357.   #--------------------------------------------------------------------------
  1358.   # * New method: cri_eva
  1359.   #--------------------------------------------------------------------------
  1360.   def cri_eva(user, item)
  1361.     cev
  1362.   end
  1363.   #--------------------------------------------------------------------------
  1364.   # * New method: setup_critical
  1365.   #--------------------------------------------------------------------------
  1366.   def setup_critical(user, item)
  1367.     cri_rate(user, item) * (1 - cri_eva(user, item))
  1368.   end
  1369. end

  1370. #==============================================================================
  1371. # ** Game_Enemy
  1372. #------------------------------------------------------------------------------
  1373. #  This class handles enemy characters. It's used within the Game_Troop class
  1374. # ($game_troop).
  1375. #==============================================================================

  1376. class Game_Enemy < Game_Battler
  1377.   #--------------------------------------------------------------------------
  1378.   # * New method: note
  1379.   #--------------------------------------------------------------------------
  1380.   def note
  1381.     enemy ? enemy.note : ""
  1382.   end
  1383.   #--------------------------------------------------------------------------
  1384.   # * New method: get_all_notes
  1385.   #--------------------------------------------------------------------------
  1386.   def get_all_notes(*args)
  1387.     notes  = ""
  1388.     notes += note if !args.include?(:self)
  1389.     states.compact.each {|state| notes += state.note } if !args.include?(:state)
  1390.     notes
  1391.   end
  1392.   #--------------------------------------------------------------------------
  1393.   # * New method: get_all_objects
  1394.   #--------------------------------------------------------------------------
  1395.   def get_all_objects(*args)
  1396.     result = []
  1397.     result += [self] if !args.include?(:self)
  1398.     result += states.compact if !args.include?(:state)
  1399.     result
  1400.   end
  1401.   #--------------------------------------------------------------------------
  1402.   # * New method: level
  1403.   #--------------------------------------------------------------------------
  1404.   def level
  1405.     return 1
  1406.   end
  1407.   #--------------------------------------------------------------------------
  1408.   # * New method: skill_learn?
  1409.   #--------------------------------------------------------------------------
  1410.   def skill_learn?(skill)
  1411.     skill.skill? && skills.include?(skill)
  1412.   end
  1413.   #--------------------------------------------------------------------------
  1414.   # * New method: skills
  1415.   #--------------------------------------------------------------------------
  1416.   def skills
  1417.     enemy.actions.collect {|action| $data_skills[action.skill_id] }
  1418.   end
  1419. end

  1420. #==============================================================================
  1421. # ** Game_Actor
  1422. #------------------------------------------------------------------------------
  1423. #  This class handles actors. It's used within the Game_Actors class
  1424. # ($game_actors) and referenced by the Game_Party class ($game_party).
  1425. #==============================================================================

  1426. class Game_Actor < Game_Battler
  1427.   #--------------------------------------------------------------------------
  1428.   # * New method: note
  1429.   #--------------------------------------------------------------------------
  1430.   def note
  1431.     actor ? actor.note : ""
  1432.   end
  1433.   #--------------------------------------------------------------------------
  1434.   # * New method: hue
  1435.   #--------------------------------------------------------------------------
  1436.   def hue
  1437.     @hue ? @hue : 0
  1438.   end
  1439.   #--------------------------------------------------------------------------
  1440.   # * New method: get_all_notes
  1441.   #--------------------------------------------------------------------------
  1442.   def get_all_notes(*args)
  1443.     notes = ""
  1444.     notes += note if !args.include?(:self)
  1445.     notes += self.class.note if !args.include?(:class)
  1446.     equips.compact.each {|equip| notes += equip.note } if !args.include?(:equip)
  1447.     states.compact.each {|state| notes += state.note } if !args.include?(:state)
  1448.     notes
  1449.   end
  1450.   #--------------------------------------------------------------------------
  1451.   # * New method: get_all_objects
  1452.   #--------------------------------------------------------------------------
  1453.   def get_all_objects(*args)
  1454.     result = []
  1455.     result += [self] if !args.include?(:self)
  1456.     result += [self.class]   if !args.include?(:self)
  1457.     result += equips.compact if !args.include?(:equip)
  1458.     result += states.compact if !args.include?(:state)
  1459.     result
  1460.   end
  1461.   #--------------------------------------------------------------------------
  1462.   # * New method: in_active_party?
  1463.   #--------------------------------------------------------------------------
  1464.   def in_active_party?
  1465.     $game_party.battle_members.include?(self)
  1466.   end
  1467.   #--------------------------------------------------------------------------
  1468.   # * New method: in_reserve_party?
  1469.   #--------------------------------------------------------------------------
  1470.   def in_reserve_party?
  1471.     $game_party.reserve_members.include?(self)
  1472.   end
  1473.   #--------------------------------------------------------------------------
  1474.   # * New method: in_party?
  1475.   #--------------------------------------------------------------------------
  1476.   def in_party?
  1477.     $game_party.all_members.include?(self)
  1478.   end
  1479.   #--------------------------------------------------------------------------
  1480.   # * New method: map_animation
  1481.   #--------------------------------------------------------------------------
  1482.   def map_animation(id)
  1483.     $game_map.actors.each do |member|
  1484.       member.animation_id = id if member.actor == self
  1485.     end
  1486.   end
  1487.   #--------------------------------------------------------------------------
  1488.   # * New method: on_damage_floor
  1489.   #--------------------------------------------------------------------------
  1490.   def on_damage_floor?
  1491.     $game_player.on_damage_floor?
  1492.   end
  1493. end

  1494. #==============================================================================
  1495. # ** Game_Unit
  1496. #------------------------------------------------------------------------------
  1497. #  This class handles units. It's used as a superclass of the Game_Party and
  1498. # Game_Troop classes.
  1499. #==============================================================================

  1500. class Game_Unit
  1501.   #--------------------------------------------------------------------------
  1502.   # * New method: refresh
  1503.   #--------------------------------------------------------------------------
  1504.   def refresh
  1505.     members.each {|member| member.refresh }
  1506.   end
  1507. end

  1508. #==============================================================================
  1509. # ** Game_Party
  1510. #------------------------------------------------------------------------------
  1511. #  This class handles the party. It includes information on amount of gold
  1512. # and items. The instance of this class is referenced by $game_party.
  1513. #==============================================================================

  1514. class Game_Party < Game_Unit
  1515.   #--------------------------------------------------------------------------
  1516.   # * New method: average_level
  1517.   #--------------------------------------------------------------------------
  1518.   def average_level
  1519.     battle_members.collect {|actor| actor.level }.average
  1520.   end
  1521.   #--------------------------------------------------------------------------
  1522.   # * New method: reserve_members
  1523.   #--------------------------------------------------------------------------
  1524.   def reserve_members
  1525.     all_members - battle_members
  1526.   end
  1527. end

  1528. #==============================================================================
  1529. # ** Game_Map
  1530. #------------------------------------------------------------------------------
  1531. #  This class handles maps. It includes scrolling and passage determination
  1532. # functions. The instance of this class is referenced by $game_map.
  1533. #==============================================================================

  1534. class Game_Map
  1535.   #--------------------------------------------------------------------------
  1536.   # * New method: event_list
  1537.   #--------------------------------------------------------------------------
  1538.   def event_list
  1539.     events.values
  1540.   end
  1541.   #--------------------------------------------------------------------------
  1542.   # * New method: note
  1543.   #--------------------------------------------------------------------------
  1544.   def note
  1545.     @map ? @map.note : ""
  1546.   end
  1547.   #--------------------------------------------------------------------------
  1548.   # * New method: vehicles
  1549.   #--------------------------------------------------------------------------
  1550.   def vehicles
  1551.     @vehicles
  1552.   end
  1553.   #--------------------------------------------------------------------------
  1554.   # * New method: map_events
  1555.   #--------------------------------------------------------------------------
  1556.   def map_events
  1557.     @map.events
  1558.   end
  1559.   #--------------------------------------------------------------------------
  1560.   # * New method: actors
  1561.   #--------------------------------------------------------------------------
  1562.   def actors
  1563.     [$game_player] + $game_player.followers.visible_followers
  1564.   end
  1565. end

  1566. #==============================================================================
  1567. # ** Game_CharacterBase
  1568. #------------------------------------------------------------------------------
  1569. #  This class deals with characters. Common to all characters, stores basic
  1570. # data, such as coordinates and graphics. It's used as a superclass of the
  1571. # Game_Character class.
  1572. #==============================================================================

  1573. class Game_CharacterBase
  1574.   #--------------------------------------------------------------------------
  1575.   # * Public Instance Variables
  1576.   #--------------------------------------------------------------------------
  1577.   attr_accessor :move_speed
  1578.   attr_accessor :move_frequency
  1579.   #--------------------------------------------------------------------------
  1580.   # * New method: player?
  1581.   #--------------------------------------------------------------------------
  1582.   def player?
  1583.     return false
  1584.   end
  1585.   #--------------------------------------------------------------------------
  1586.   # * New method: event?
  1587.   #--------------------------------------------------------------------------
  1588.   def event?
  1589.     return false
  1590.   end
  1591.   #--------------------------------------------------------------------------
  1592.   # * New method: follower?
  1593.   #--------------------------------------------------------------------------
  1594.   def follower?
  1595.     return false
  1596.   end
  1597.   #--------------------------------------------------------------------------
  1598.   # * New method: vehicle?
  1599.   #--------------------------------------------------------------------------
  1600.   def vehicle?
  1601.     return false
  1602.   end
  1603.   #--------------------------------------------------------------------------
  1604.   # * New method: frames
  1605.   #--------------------------------------------------------------------------
  1606.   def frames
  1607.     return 3
  1608.   end
  1609.   #--------------------------------------------------------------------------
  1610.   # * New method: hue
  1611.   #--------------------------------------------------------------------------
  1612.   def hue
  1613.     @hue ? @hue : 0
  1614.   end
  1615. end

  1616. #==============================================================================
  1617. # ** Game_Character
  1618. #------------------------------------------------------------------------------
  1619. #  This class deals with characters. It's used as a superclass of the
  1620. # Game_Player and Game_Event classes.
  1621. #==============================================================================

  1622. class Game_Character < Game_CharacterBase
  1623.   #--------------------------------------------------------------------------
  1624.   # * New method: move_toward_position
  1625.   #--------------------------------------------------------------------------
  1626.   def move_toward_position(x, y)
  1627.     sx = distance_x_from(x)
  1628.     sy = distance_y_from(y)
  1629.     if sx.abs > sy.abs
  1630.       move_straight(sx > 0 ? 4 : 6)
  1631.       move_straight(sy > 0 ? 8 : 2) if !@move_succeed && sy != 0
  1632.     elsif sy != 0
  1633.       move_straight(sy > 0 ? 8 : 2)
  1634.       move_straight(sx > 0 ? 4 : 6) if !@move_succeed && sx != 0
  1635.     end
  1636.   end
  1637.   #--------------------------------------------------------------------------
  1638.   # * New method: move_toward_position
  1639.   #--------------------------------------------------------------------------
  1640.   def turn_toward_position(x, y)
  1641.     sx = distance_x_from(x)
  1642.     sy = distance_y_from(y)
  1643.     if sx.abs > sy.abs
  1644.       set_direction(sx > 0 ? 4 : 6)
  1645.     elsif sy != 0
  1646.       set_direction(sy > 0 ? 8 : 2)
  1647.     end
  1648.   end
  1649. end

  1650. #==============================================================================
  1651. # ** Game_Player
  1652. #------------------------------------------------------------------------------
  1653. #  This class handles the player.
  1654. # The instance of this class is referenced by $game_map.
  1655. #==============================================================================

  1656. class Game_Player < Game_Character
  1657.   #--------------------------------------------------------------------------
  1658.   # * New method: player?
  1659.   #--------------------------------------------------------------------------
  1660.   def player?
  1661.     return true
  1662.   end
  1663.   #--------------------------------------------------------------------------
  1664.   # * New method: perform_transfer
  1665.   #--------------------------------------------------------------------------
  1666.   def new_map_id
  1667.     @new_map_id
  1668.   end
  1669.   #--------------------------------------------------------------------------
  1670.   # * New method: hue
  1671.   #--------------------------------------------------------------------------
  1672.   def hue
  1673.     actor ? actor.hue : 0
  1674.   end
  1675. end

  1676. #==============================================================================
  1677. # ** Game_Follower
  1678. #------------------------------------------------------------------------------
  1679. #  This class handles the followers. Followers are the actors of the party
  1680. # that follows the leader in a line. It's used within the Game_Followers class.
  1681. #==============================================================================

  1682. class Game_Follower < Game_Character
  1683.   #--------------------------------------------------------------------------
  1684.   # * New method: follower?
  1685.   #--------------------------------------------------------------------------
  1686.   def follower?
  1687.     return true
  1688.   end
  1689.   #--------------------------------------------------------------------------
  1690.   # * New method: index
  1691.   #--------------------------------------------------------------------------
  1692.   def index
  1693.     @member_index
  1694.   end
  1695.   #--------------------------------------------------------------------------
  1696.   # * New method: gathering?
  1697.   #--------------------------------------------------------------------------
  1698.   def gathering?
  1699.     $game_player.followers.gathering? && !gather?
  1700.   end
  1701. end

  1702. #==============================================================================
  1703. # ** Game_Followers
  1704. #------------------------------------------------------------------------------
  1705. #  This class handles the followers. It's a wrapper for the built-in class
  1706. # "Array." It's used within the Game_Player class.
  1707. #==============================================================================

  1708. class Game_Followers
  1709.   #--------------------------------------------------------------------------
  1710.   # * New method: get_actor
  1711.   #--------------------------------------------------------------------------
  1712.   def get_actor(id)
  1713.     list = [$game_player] + visible_followers
  1714.     list.select {|follower| follower.actor && follower.actor.id == id }.first
  1715.   end
  1716.   #--------------------------------------------------------------------------
  1717.   # * Method fix: visble_folloers
  1718.   #--------------------------------------------------------------------------
  1719.   unless method_defined?(:visible_followers)
  1720.     def visible_followers; visible_folloers; end
  1721.   end
  1722. end

  1723. #==============================================================================
  1724. # ** Game_Vehicle
  1725. #------------------------------------------------------------------------------
  1726. #  This class handles vehicles. It's used within the Game_Map class. If there
  1727. # are no vehicles on the current map, the coordinates is set to (-1,-1).
  1728. #==============================================================================

  1729. class Game_Vehicle < Game_Character
  1730.   #--------------------------------------------------------------------------
  1731.   # * New method: vehicle?
  1732.   #--------------------------------------------------------------------------
  1733.   def vehicle?
  1734.     return true
  1735.   end
  1736.   #--------------------------------------------------------------------------
  1737.   # * New method: map_id
  1738.   #--------------------------------------------------------------------------
  1739.   def map_id
  1740.     @map_id
  1741.   end
  1742.   #--------------------------------------------------------------------------
  1743.   # * New method: type
  1744.   #--------------------------------------------------------------------------
  1745.   def type
  1746.     @type
  1747.   end
  1748.   #--------------------------------------------------------------------------
  1749.   # * New method: aerial?
  1750.   #--------------------------------------------------------------------------
  1751.   def aerial?
  1752.     type == :airship
  1753.   end
  1754.   #--------------------------------------------------------------------------
  1755.   # * New method: above?
  1756.   #--------------------------------------------------------------------------
  1757.   def above?
  1758.     aerial?
  1759.   end
  1760. end

  1761. #==============================================================================
  1762. # ** Game_Event
  1763. #------------------------------------------------------------------------------
  1764. #  This class deals with events. It handles functions including event page
  1765. # switching via condition determinants, and running parallel process events.
  1766. # It's used within the Game_Map class.
  1767. #==============================================================================

  1768. class Game_Event < Game_Character
  1769.   #--------------------------------------------------------------------------
  1770.   # * New method: name
  1771.   #--------------------------------------------------------------------------
  1772.   def name
  1773.     @event.name
  1774.   end
  1775.   #--------------------------------------------------------------------------
  1776.   # * New method: event?
  1777.   #--------------------------------------------------------------------------
  1778.   def event?
  1779.     return true
  1780.   end
  1781.   #--------------------------------------------------------------------------
  1782.   # * New method: erased?
  1783.   #--------------------------------------------------------------------------
  1784.   def erased?
  1785.     @erased
  1786.   end
  1787.   #--------------------------------------------------------------------------
  1788.   # * New method: note
  1789.   #--------------------------------------------------------------------------
  1790.   def note
  1791.     return ""     if !@page || [email protected] || @page.list.size <= 0
  1792.     return @notes if @notes && @page.list == @note_page
  1793.     @note_page = @page.list.dup
  1794.     comment_list = []
  1795.     @page.list.each do |item|
  1796.       next unless item && (item.code == 108 || item.code == 408)
  1797.       comment_list.push(item.parameters[0])
  1798.     end
  1799.     @notes = comment_list.join("\r\n")
  1800.     @notes
  1801.   end  
  1802. end

  1803. #==============================================================================
  1804. # ** Game_Interpreter
  1805. #------------------------------------------------------------------------------
  1806. #  An interpreter for executing event commands. This class is used within the
  1807. # Game_Map, Game_Troop, and Game_Event classes.
  1808. #==============================================================================

  1809. class Game_Interpreter
  1810.   #--------------------------------------------------------------------------
  1811.   # * Alias method: command_108
  1812.   #--------------------------------------------------------------------------
  1813.   alias :command_108_ve_basic_module :command_108
  1814.   def command_108
  1815.     command_108_ve_basic_module
  1816.     comment_call
  1817.   end
  1818.   #--------------------------------------------------------------------------
  1819.   # * New method: comment_call
  1820.   #--------------------------------------------------------------------------
  1821.   def comment_call
  1822.   end
  1823.   #--------------------------------------------------------------------------
  1824.   # * New method: note
  1825.   #--------------------------------------------------------------------------
  1826.   def note
  1827.     @comments ? @comments.join("\r\n") : ""
  1828.   end
  1829. end

  1830. #==============================================================================
  1831. # ** Sprite_Character
  1832. #------------------------------------------------------------------------------
  1833. #  This sprite is used to display characters. It observes a instance of the
  1834. # Game_Character class and automatically changes sprite conditions.
  1835. #==============================================================================

  1836. class Sprite_Character < Sprite_Base
  1837.   #--------------------------------------------------------------------------
  1838.   # * Overwrite method: set_character_bitmap
  1839.   #--------------------------------------------------------------------------
  1840.   def set_character_bitmap
  1841.     update_character_info
  1842.     set_bitmap
  1843.     set_bitmap_position
  1844.   end
  1845.   #--------------------------------------------------------------------------
  1846.   # * New method: center_y
  1847.   #--------------------------------------------------------------------------
  1848.   def actor?
  1849.     @character.is_a?(Game_Player) || @character.is_a?(Game_Follower)
  1850.   end
  1851.   #--------------------------------------------------------------------------
  1852.   # * New method: center_y
  1853.   #--------------------------------------------------------------------------
  1854.   def actor
  1855.     actor? ? @character.actor : nil
  1856.   end
  1857.   #--------------------------------------------------------------------------
  1858.   # * New method: update_character_info
  1859.   #--------------------------------------------------------------------------
  1860.   def update_character_info
  1861.   end
  1862.   #--------------------------------------------------------------------------
  1863.   # * New method: hue
  1864.   #--------------------------------------------------------------------------
  1865.   def hue
  1866.     @character.hue
  1867.   end
  1868.   #--------------------------------------------------------------------------
  1869.   # * New method: set_bitmap
  1870.   #--------------------------------------------------------------------------
  1871.   def set_bitmap
  1872.     self.bitmap = Cache.character(set_bitmap_name, hue)
  1873.   end
  1874.   #--------------------------------------------------------------------------
  1875.   # * New method: set_bitmap_name
  1876.   #--------------------------------------------------------------------------
  1877.   def set_bitmap_name
  1878.     @character_name
  1879.   end
  1880.   #--------------------------------------------------------------------------
  1881.   # * New method: set_bitmap_position
  1882.   #--------------------------------------------------------------------------
  1883.   def set_bitmap_position
  1884.     sign = get_sign
  1885.     if sign && sign.include?(')
  1886.       @bw = bitmap.width  / 32.0 / frames
  1887.       @bh = bitmap.height / 32.0 / 4
  1888.     elsif character_name != "" && @tile_id == 0
  1889.       @bw = bitmap.width  / 32.0 / (frames * 4)
  1890.       @bh = bitmap.height / 32.0 / 8
  1891.     else
  1892.       @bw = 1.0
  1893.       @bh = 1.0
  1894.     end
  1895.     bitmap.dispose
  1896.   end
  1897.   #--------------------------------------------------------------------------
  1898.   # * New method: collision?
  1899.   #--------------------------------------------------------------------------
  1900.   def collision?(x, y, w, h)
  1901.     ax1, ay1, ax2, ay2 = setup_rect(x, y, w, h)
  1902.     bx1, by1, bx2, by2 = setup_rect(@x, @y, bw, bh)
  1903.     ax2 > bx1 && ax1 < bx2 && ay2 > by1 && ay1 < by2
  1904.   end
  1905.   #--------------------------------------------------------------------------
  1906.   # * New method: over?
  1907.   #--------------------------------------------------------------------------
  1908.   def over?(x, y)
  1909.     ax1, ay1, ax2, ay2 = setup_rect(x, y - 0.125, 0, 0)
  1910.     bx1, by1, bx2, by2 = setup_rect(@real_x, @real_y, bw, bh - 0.125)
  1911.     ax2 >= bx1 && ax1 <= bx2 && ay2 >= by1 && ay1 <= by2
  1912.   end
  1913.   #--------------------------------------------------------------------------
  1914.   # * New method: setup_rect
  1915.   #--------------------------------------------------------------------------
  1916.   def setup_rect(x, y, w, h)
  1917.     x1 = x - w / 2.0
  1918.     y1 = y - h
  1919.     x2 = x1 + w
  1920.     y2 = y1 + h
  1921.     [x1, y1, x2, y2]
  1922.   end
  1923.   #--------------------------------------------------------------------------
  1924.   # * New method: align_with
  1925.   #--------------------------------------------------------------------------
  1926.   def align_with(x, y)
  1927.     d  = @direction
  1928.     @x = $game_map.round_x_with_direction(x, 0) if d == 2 || d == 8
  1929.     @y = $game_map.round_y_with_direction(y, 0) if d == 6 || d == 4
  1930.     dx = (d == 2 || d == 8) ? (@x - @real_x) / 0.125 : 0
  1931.     dy = (d == 4 || d == 6) ? (@y - @real_y) / 0.125 : 0
  1932.     set_direction(dx > 0 ? 6 : dx < 0 ? 4 : dy > 0 ? 2 : dy < 0 ? 8 : d)
  1933.     @real_x = $game_map.x_with_direction(@x, reverse_dir(@direction), dx.abs)
  1934.     @real_y = $game_map.y_with_direction(@y, reverse_dir(@direction), dy.abs)
  1935.     update_for_align while moving?
  1936.     @direction = d
  1937.   end
  1938.   #--------------------------------------------------------------------------
  1939.   # * New method: update_for_align
  1940.   #--------------------------------------------------------------------------
  1941.   def update_for_align
  1942.     SceneManager.scene.update_basic
  1943.     SceneManager.scene.spriteset.update
  1944.     $game_map.update(true)
  1945.     $game_timer.update
  1946.     update_animation
  1947.     update_move
  1948.   end
  1949.   #--------------------------------------------------------------------------
  1950.   # * New method: fix_position
  1951.   #--------------------------------------------------------------------------
  1952.   def fix_position(n)
  1953.     (n * 64 / 8).round / 8.0
  1954.   end
  1955. end

  1956. #==============================================================================
  1957. # ** Game_Character
  1958. #------------------------------------------------------------------------------
  1959. #  This class deals with characters. It's used as a superclass of the
  1960. # Game_Player and Game_Event classes.
  1961. #==============================================================================

  1962. class Game_Character < Game_CharacterBase
  1963.   #--------------------------------------------------------------------------
  1964.   # * Alias method: move_toward_character
  1965.   #--------------------------------------------------------------------------
  1966.   alias :move_toward_character_ve_pixel_movement :move_toward_character
  1967.   def move_toward_character(character)
  1968.     sx = distance_x_from(character.x)
  1969.     sy = distance_y_from(character.y)
  1970.     move_toward_character_ve_pixel_movement(character)
  1971.     @x = character.x if sx.abs < 1
  1972.     @y = character.y if sy.abs < 1
  1973.   end
  1974.   #--------------------------------------------------------------------------
  1975.   # * Alias method: move_toward_position
  1976.   #--------------------------------------------------------------------------
  1977.   alias :move_toward_position_ve_pixel_movement :move_toward_position
  1978.   def move_toward_position(x, y)
  1979.     sx = distance_x_from(x)
  1980.     sy = distance_y_from(y)
  1981.     move_toward_position_ve_pixel_movement(x, y)
  1982.     @x = x if sx.abs < 1
  1983.     @y = y if sy.abs < 1
  1984.   end
  1985. end

  1986. #==============================================================================
  1987. # ** Game_Player
  1988. #------------------------------------------------------------------------------
  1989. #  This class handles maps. It includes event starting determinants and map
  1990. # scrolling functions. The instance of this class is referenced by $game_map.
  1991. #==============================================================================

  1992. class Game_Player < Game_Character
  1993.   #--------------------------------------------------------------------------
  1994.   # * Public Instance Variables
  1995.   #--------------------------------------------------------------------------
  1996.   attr_accessor :over_event
  1997.   attr_accessor :land_test
  1998.   #--------------------------------------------------------------------------
  1999.   # * Overwrite method: check_event_trigger_there
  2000.   #--------------------------------------------------------------------------
  2001.   def check_event_trigger_there(triggers)
  2002.     x2 = $game_map.round_x_with_direction(@x, @direction)
  2003.     y2 = $game_map.round_y_with_direction(@y, @direction)
  2004.     start_map_event(x2, y2, triggers, true)
  2005.     return if $game_map.any_event_starting?
  2006.     return unless counter_tile?
  2007.     x3 = $game_map.check_x_with_direction(x2, @direction)
  2008.     y3 = $game_map.check_y_with_direction(y2, @direction)
  2009.     start_map_event(x3, y3, triggers, true)
  2010.   end
  2011.   #--------------------------------------------------------------------------
  2012.   # * Overwrite method: start_map_event
  2013.   #--------------------------------------------------------------------------
  2014.   def start_map_event(x, y, triggers, normal)
  2015.     return if $game_map.interpreter.running?
  2016.     $game_map.events_xy(x, y).each do |event|
  2017.       event.start if check_event_contiontion(x, y, event, triggers, normal)
  2018.     end
  2019.   end
  2020.   #--------------------------------------------------------------------------
  2021.   # * Overwrite method: update_nonmoving
  2022.   #--------------------------------------------------------------------------
  2023.   def update_nonmoving(last_moving)
  2024.     return if $game_map.interpreter.running?
  2025.     moved  = @moved
  2026.     @moved = false
  2027.     if last_moving || moved
  2028.       $game_party.on_player_walk
  2029.       return if check_touch_event
  2030.     end
  2031.     if movable? && Input.trigger?(:C)
  2032.       return if get_on_off_vehicle
  2033.       return if check_action_event
  2034.     end
  2035.     @over_event -= 1 if @over_event > 0 && (last_moving || moved)
  2036.     update_encounter if last_moving || moved
  2037.   end
  2038.   #--------------------------------------------------------------------------
  2039.   # * Overwrite method: get_on_vehicle
  2040.   #--------------------------------------------------------------------------
  2041.   def get_on_vehicle
  2042.     setup_vehicle
  2043.     enter_vehicle if vehicle
  2044.     @vehicle_getting_on
  2045.   end
  2046.   #--------------------------------------------------------------------------
  2047.   # * Overwrite method: increase_steps
  2048.   #--------------------------------------------------------------------------
  2049.   def increase_steps
  2050.     super
  2051.     if normal_walk?
  2052.       @steps += 1
  2053.       $game_player.damage_floor  = 0 unless on_damage_floor?
  2054.       $game_player.damage_floor += 1
  2055.       $game_party.increase_steps if @steps % 8 == 0
  2056.     end
  2057.   end
  2058.   #--------------------------------------------------------------------------
  2059.   # * Alias method: get_off_vehicle
  2060.   #--------------------------------------------------------------------------
  2061.   alias :get_off_vehicle_ve_pixel_movement :get_off_vehicle
  2062.   def get_off_vehicle
  2063.     clear_next_movement if vehicle.land_ok?(@x, @y, @direction)
  2064.     get_off_vehicle_ve_pixel_movement
  2065.   end
  2066.   #--------------------------------------------------------------------------
  2067.   # * Alias method: clear_transfer_info
  2068.   #--------------------------------------------------------------------------
  2069.   alias :clear_transfer_info_ve_pixel_movement :clear_transfer_info
  2070.   def clear_transfer_info
  2071.     clear_transfer_info_ve_pixel_movement
  2072.     clear_next_movement
  2073.   end
  2074.   #--------------------------------------------------------------------------
  2075.   # * Alias method: update
  2076.   #--------------------------------------------------------------------------
  2077.   alias :update_ve_gp_pixel_movement :update
  2078.   def update
  2079.     @followers.move unless $imported[:ve_followers_options]
  2080.     update_ve_gp_pixel_movement
  2081.   end
  2082.   #--------------------------------------------------------------------------
  2083.   # * New method: check_event_contiontion
  2084.   #--------------------------------------------------------------------------
  2085.   def check_event_contiontion(x, y, event, triggers, normal)
  2086.     passable = passable_tile?(@x, @y, @direction)
  2087.     w = (counter_tile? || !passable) ? 1.0 : bw
  2088.     h = (counter_tile? || !passable) ? 1.0 : bh
  2089.     return false unless event.trigger_in?(triggers)
  2090.     return false unless event.event_priority?(normal)
  2091.     return false unless passable || event.over_tile? || counter_tile?
  2092.     return false unless event.collision?(x, y, w, h) || !jumping?
  2093.     return false unless !event.in_front? || front_collision?(x, y, @direction)
  2094.     return true
  2095.   end
  2096.   #--------------------------------------------------------------------------
  2097.   # * New method: counter_tile?
  2098.   #--------------------------------------------------------------------------
  2099.   def counter_tile?
  2100.     x = $game_map.check_x_with_direction(@x, @direction)
  2101.     y = $game_map.check_y_with_direction(@y, @direction)
  2102.     $game_map.counter?(x, y)
  2103.   end
  2104.   #--------------------------------------------------------------------------
  2105.   # * New method: setup_vehicle
  2106.   #--------------------------------------------------------------------------
  2107.   def setup_vehicle
  2108.     $game_map.vehicles.compact.each do |vehicle|
  2109.       next unless vehicle.enter_vechicle?(@x, @y, @direction)
  2110.       @vehicle_type = vehicle.type
  2111.       break if vehicle
  2112.     end
  2113.   end
  2114.   #--------------------------------------------------------------------------
  2115.   # * New method: enter_vehicle
  2116.   #--------------------------------------------------------------------------
  2117.   def enter_vehicle
  2118.     align_with(vehicle.x, vehicle.y) unless in_airship?
  2119.     @vehicle_getting_on = true
  2120.     force_move_forward unless in_airship?
  2121.     @followers.gather
  2122.   end
  2123.   #--------------------------------------------------------------------------
  2124.   # * New method: clear_next_movement
  2125.   #--------------------------------------------------------------------------
  2126.   def clear_next_movement
  2127.     @next_movement.clear
  2128.     @followers.clear_next_movement
  2129.   end
  2130.   #--------------------------------------------------------------------------
  2131.   # * New method: step_times
  2132.   #--------------------------------------------------------------------------
  2133.   def step_times
  2134.     (move_route_forcing || not_driving?) ? super : 1
  2135.   end
  2136.   #--------------------------------------------------------------------------
  2137.   # * New method: not_driving?
  2138.   #--------------------------------------------------------------------------
  2139.   def not_driving?
  2140.     vehicle && !vehicle.driving
  2141.   end
  2142.   #--------------------------------------------------------------------------
  2143.   # * New method: move_straight
  2144.   #--------------------------------------------------------------------------
  2145.   def move_straight(d, turn_ok = true)
  2146.     super
  2147.   end
  2148.   #--------------------------------------------------------------------------
  2149.   # * New method: move_diagonal
  2150.   #--------------------------------------------------------------------------
  2151.   def move_diagonal(horz, vert)
  2152.     super
  2153.   end
  2154.   #--------------------------------------------------------------------------
  2155.   # * New method: setup_bitmap_dimension
  2156.   #--------------------------------------------------------------------------
  2157.   def setup_bitmap_dimension
  2158.     @bw = VE_PLAYER_BIG_COLLISION ? 1.0 : 0.75
  2159.     @bh = VE_PLAYER_BIG_COLLISION ? 1.0 : 0.75
  2160.   end
  2161. end

  2162. #==============================================================================
  2163. # ** Game_Follower
  2164. #------------------------------------------------------------------------------
  2165. #  This class handles the followers. Followers are the actors of the party
  2166. # that follows the leader in a line. It's used within the Game_Followers class.
  2167. #==============================================================================

  2168. class Game_Follower < Game_Character
  2169.   #--------------------------------------------------------------------------
  2170.   # * Overwrite method: chase_preceding_character
  2171.   #--------------------------------------------------------------------------
  2172.   def chase_preceding_character
  2173.     return if $imported[:ve_followers_control] && cant_follow_character
  2174.     unless moving?
  2175.       if @preceding_character.next_movement.size >= 8 && !gathering?
  2176.         next_move = @preceding_character.next_movement.shift
  2177.         move_straight(next_move)  if next_move.numeric?
  2178.         move_diagonal(*next_move) if next_move.array?
  2179.       elsif gathering?
  2180.         @preceding_character.next_movement.clear
  2181.         move_toward_player
  2182.       end
  2183.     end
  2184.   end
  2185.   #--------------------------------------------------------------------------
  2186.   # * New method: move_straight
  2187.   #--------------------------------------------------------------------------
  2188.   def move_straight(d, turn_ok = true)
  2189.     super
  2190.   end
  2191.   #--------------------------------------------------------------------------
  2192.   # * New method: move_diagonal
  2193.   #--------------------------------------------------------------------------
  2194.   def move_diagonal(horz, vert)
  2195.     super
  2196.   end
  2197.   #--------------------------------------------------------------------------
  2198.   # * New method: movement_size
  2199.   #--------------------------------------------------------------------------
  2200.   def movement_size
  2201.     return 8
  2202.   end
  2203.   #--------------------------------------------------------------------------
  2204.   # * New method: step_times
  2205.   #--------------------------------------------------------------------------
  2206.   def step_times
  2207.     (move_route_forcing || not_driving? || gathering?) ? super : 1
  2208.   end
  2209.   #--------------------------------------------------------------------------
  2210.   # * New method: not_driving?
  2211.   #--------------------------------------------------------------------------
  2212.   def not_driving?
  2213.     $game_player.not_driving?
  2214.   end
  2215.   #--------------------------------------------------------------------------
  2216.   # * New method: setup_bitmap_dimension
  2217.   #--------------------------------------------------------------------------
  2218.   def setup_bitmap_dimension
  2219.     @bw = VE_PLAYER_BIG_COLLISION ? 1.0 : 0.75
  2220.     @bh = VE_PLAYER_BIG_COLLISION ? 1.0 : 0.75
  2221.   end
  2222. end

  2223. #==============================================================================
  2224. # ** Game_Followers
  2225. #------------------------------------------------------------------------------
  2226. #  This class handles the followers. It's a wrapper for the built-in class
  2227. # "Array." It's used within the Game_Player class.
  2228. #==============================================================================

  2229. class Game_Followers
  2230.   #--------------------------------------------------------------------------
  2231.   # * New method: clear_next_movement
  2232.   #--------------------------------------------------------------------------
  2233.   def clear_next_movement
  2234.     each {|follower| follower.next_movement.clear }
  2235.   end
  2236. end

  2237. #==============================================================================
  2238. # ** Game_Event
  2239. #------------------------------------------------------------------------------
  2240. #  This class deals with events. It handles functions including event page
  2241. # switching via condition determinants, and running parallel process events.
  2242. # It's used within the Game_Map class.
  2243. #==============================================================================

  2244. class Game_Event < Game_Character
  2245.   #--------------------------------------------------------------------------
  2246.   # * Overwrite method: collide_with_player_characters?
  2247.   #--------------------------------------------------------------------------
  2248.   def collide_with_player_characters?(x, y)
  2249.     normal_priority? && player_collision?(x, y)
  2250.   end
  2251.   #--------------------------------------------------------------------------
  2252.   # * Alias method: start
  2253.   #--------------------------------------------------------------------------
  2254.   alias :start_ve_pixel_movement :start
  2255.   def start
  2256.     start_ve_pixel_movement
  2257.     $game_player.over_event = 8 if step_over? && !step_trigger?
  2258.   end
  2259.   #--------------------------------------------------------------------------
  2260.   # * Alias method: setup_page_settings
  2261.   #--------------------------------------------------------------------------
  2262.   alias :setup_page_settings_ve_pixel_movement :setup_page_settings
  2263.   def setup_page_settings_ve_pixel_movement
  2264.     setup_page_settings_ve_anti_lag
  2265.     @move_steps   = note =~ /<MOVE STEPS: (\d+)>/i ? $1.to_i : nil
  2266.     @step_trigger = note =~ /<EACH STEP TRIGGER>/i ? true : false
  2267.     @in_front     = note =~ /<FRONT COLLISION>/i   ? true : false
  2268.     @over_tile    = note =~ /<OVER TILE>/i         ? true : false
  2269.     @side_fix     = note =~ /<NO SIDE COLLISION FIX>/i ? false : true
  2270.   end
  2271.   #--------------------------------------------------------------------------
  2272.   # * New method: player_collision?
  2273.   #--------------------------------------------------------------------------
  2274.   def player_collision?(x, y)
  2275.     $game_map.actors.any? {|actor| actor.collision?(x, y, bh, bw)}
  2276.   end  
  2277.   #--------------------------------------------------------------------------
  2278.   # * New method: event_priority?
  2279.   #--------------------------------------------------------------------------
  2280.   def event_priority?(normal)
  2281.     (normal_priority? == normal || (@through && !normal)) &&
  2282.     (normal_priority? || @trigger == 0 || $game_player.over_event == 0)
  2283.   end
  2284.   #--------------------------------------------------------------------------
  2285.   # * New method: check_event_trigger_touch
  2286.   #--------------------------------------------------------------------------
  2287.   def check_event_trigger_touch(x, y)
  2288.     return if $game_map.interpreter.running?
  2289.     if @trigger == 2 && $game_player.collision?(x, y, bh, bw)
  2290.       start if !jumping? && normal_priority?
  2291.     end
  2292.   end
  2293.   #--------------------------------------------------------------------------
  2294.   # * New method: step_over?
  2295.   #--------------------------------------------------------------------------
  2296.   def step_over?
  2297.     super || (@character_name == "" && @tile_id == 0) || @priority_type == 0
  2298.   end
  2299.   #--------------------------------------------------------------------------
  2300.   # * New method: step_times
  2301.   #--------------------------------------------------------------------------
  2302.   def step_times
  2303.     @move_steps ? @move_steps : super
  2304.   end
  2305.   #--------------------------------------------------------------------------
  2306.   # * New method: step_trigger?
  2307.   #--------------------------------------------------------------------------
  2308.   def step_trigger?
  2309.     @step_trigger
  2310.   end
  2311.   #--------------------------------------------------------------------------
  2312.   # * New method: in_front?
  2313.   #--------------------------------------------------------------------------
  2314.   def in_front?
  2315.     @in_front
  2316.   end
  2317.   #--------------------------------------------------------------------------
  2318.   # * New method: over_tile?
  2319.   #--------------------------------------------------------------------------
  2320.   def over_tile?
  2321.     @over_tile
  2322.   end
  2323.   #--------------------------------------------------------------------------
  2324.   # * New method: side_collision?
  2325.   #--------------------------------------------------------------------------
  2326.   def side_collision?
  2327.     @side_fix
  2328.   end
  2329.   #--------------------------------------------------------------------------
  2330.   # * New method: setup_bitmap_dimension
  2331.   #--------------------------------------------------------------------------
  2332.   def setup_bitmap_dimension
  2333.     regexp = /<EVENT SIZE: (\d+), (\d+)>/i
  2334.     note   =~ regexp ? setup_custom_dimension($1.to_i, $2.to_i) : super
  2335.   end
  2336.   #--------------------------------------------------------------------------
  2337.   # * New method: setup_custom_dimension
  2338.   #--------------------------------------------------------------------------
  2339.   def setup_custom_dimension(x, y)
  2340.     x1 = (x / 8).to_i
  2341.     y1 = (y / 8).to_i
  2342.     @bw = x1 / 4.0
  2343.     @bh = y1 / 4.0
  2344.   end
  2345. end

  2346. #==============================================================================
  2347. # ** Game_Vehicle
  2348. #------------------------------------------------------------------------------
  2349. #  This class handles vehicles. It's used within the Game_Map class. If there
  2350. # are no vehicles on the current map, the coordinates is set to (-1,-1).
  2351. #==============================================================================

  2352. class Game_Vehicle < Game_Character
  2353.   #--------------------------------------------------------------------------
  2354.   # * Overwrite method: land_ok?
  2355.   #--------------------------------------------------------------------------
  2356.   def land_ok?(x, y, d)
  2357.     @type == :airship ? airship_landable?(x, y) : check_landable?(x, y, d)
  2358.   end
  2359.   #--------------------------------------------------------------------------
  2360.   # * New method: land_test
  2361.   #--------------------------------------------------------------------------
  2362.   def land_test
  2363.     @land_test
  2364.   end
  2365.   #--------------------------------------------------------------------------
  2366.   # * New method: step_over?
  2367.   #--------------------------------------------------------------------------
  2368.   def step_over?
  2369.     above? || super
  2370.   end
  2371.   #--------------------------------------------------------------------------
  2372.   # * New method: check_landable?
  2373.   #--------------------------------------------------------------------------
  2374.   def check_landable?(x, y, d)
  2375.     x2 = $game_map.check_x_with_direction(x, d)
  2376.     y2 = $game_map.check_y_with_direction(y, d)
  2377.     @land_test = true
  2378.     result = passable?(x2, y2, d)
  2379.     @land_test = false
  2380.     result
  2381.   end
  2382.   #--------------------------------------------------------------------------
  2383.   # * New method: airship_landable?
  2384.   #--------------------------------------------------------------------------
  2385.   def airship_landable?(x, y)
  2386.     [2, 4, 6, 8].any? {|d| passable?(x, y, d) }
  2387.   end
  2388.   #--------------------------------------------------------------------------
  2389.   # * New method: passable_normal?
  2390.   #--------------------------------------------------------------------------
  2391.   def passable_normal?(x, y, d ,d2, ceil = false)
  2392.     @land_test ? landable_normal?(x, y, d ,d2, ceil) : super(x, y, d ,d2, ceil)
  2393.   end
  2394.   #--------------------------------------------------------------------------
  2395.   # * New method: landable_normal?
  2396.   #--------------------------------------------------------------------------
  2397.   def landable_normal?(x, y, d ,d2, ceil)
  2398.     x1 = $game_map.round_x(x)
  2399.     y1 = $game_map.round_y(y)
  2400.     return false unless $game_map.valid?(x1, y1)
  2401.     return true if @through || debug_through?
  2402.     return false unless map_passable?(x1, y1, d)
  2403.     return false unless map_passable?(x1, y1, d2) || !ceil
  2404.     return false unless map_passable?(x1, y1, reverse_dir(d))
  2405.     return true
  2406.   end
  2407.   #--------------------------------------------------------------------------
  2408.   # * New method: enter_vechicle?
  2409.   #--------------------------------------------------------------------------
  2410.   def enter_vechicle?(x, y, d)
  2411.     return false if @map_id != $game_map.map_id
  2412.     x2 = $game_map.round_x_with_direction(x, d)
  2413.     y2 = $game_map.round_y_with_direction(y, d)
  2414.     x3 = $game_map.check_x_with_direction(@x, reverse_dir(d))
  2415.     y3 = $game_map.check_y_with_direction(@y, reverse_dir(d))
  2416.     ( above? && collision?(x, y - 0.125, bw * 0.75, bh * 0.75)) ||
  2417.     (!above? && collision?(x2, y2, bw, bh) && map_passable?(x3, y3, d))
  2418.   end
  2419.   #--------------------------------------------------------------------------
  2420.   # * New method: vehicle_collision?
  2421.   #--------------------------------------------------------------------------
  2422.   def vehicle_collision?(x, y, bw, bh, player)
  2423.     return false if step_over?
  2424.     return false if player.player? && self == player.vehicle
  2425.     return false if !collision?(x, y, bw, bh)
  2426.     return true
  2427.   end
  2428. end
复制代码
)
      @cw = bitmap.width / @character.frames
      @ch = bitmap.height / 4
    else
      @cw = bitmap.width / (@character.frames * 4)
      @ch = bitmap.height / 8
    end
    self.ox = @cw / 2
    self.oy = @ch
  end
  #--------------------------------------------------------------------------
  # * New method: get_sign
  #--------------------------------------------------------------------------
  def get_sign
    @character_name[/^[\!\$]./]
  end
end

#==============================================================================
# ** Sprite_Battler
#------------------------------------------------------------------------------
#  This sprite is used to display battlers. It observes a instance of the
# Game_Battler class and automatically changes sprite conditions.
#==============================================================================

class Sprite_Battler < Sprite_Base
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_accessor :dmg_mirror
  #--------------------------------------------------------------------------
  # * New method: center_x
  #--------------------------------------------------------------------------
  def center_x
    self.ox
  end
  #--------------------------------------------------------------------------
  # * New method: center_y
  #--------------------------------------------------------------------------
  def center_y
    self.oy / 2
  end
end

#==============================================================================
# ** Spriteset_Battle
#------------------------------------------------------------------------------
#  This class brings together battle screen sprites. It's used within the
# Scene_Battle class.
#==============================================================================

class Spriteset_Battle
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_reader   :viewport1
  #--------------------------------------------------------------------------
  # * New method: sprite
  #--------------------------------------------------------------------------
  def sprite(subject)
    battler_sprites.compact.select {|sprite| sprite.battler == subject }.first
  end
end

#==============================================================================
# ** Window_Base
#------------------------------------------------------------------------------
#  This is a superclass of all windows in the game.
#==============================================================================

class Window_Base < Window
  #--------------------------------------------------------------------------
  # * Alias method: convert_escape_characters
  #--------------------------------------------------------------------------
  alias :convert_escape_ve_basic_module :convert_escape_characters
  def convert_escape_characters(text)
    result = text.to_s.clone
    result = text_replace(result)
    result = convert_escape_ve_basic_module(text)
    result
  end
  #--------------------------------------------------------------------------
  # * New method: text_replace
  #--------------------------------------------------------------------------
  def text_replace(result)
    result.gsub!(/\r/) { "" }
    result.gsub!(/\\/) { "\e" }
    result
  end
end

#==============================================================================
# ** Scene_Battle
#------------------------------------------------------------------------------
#  This class performs battle screen processing.
#==============================================================================

class Scene_Battle < Scene_Base
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_reader   :subject
  attr_reader   :spriteset
end

#==============================================================================
# ** Scene_Battle
#------------------------------------------------------------------------------
#  This class performs map screen processing.
#==============================================================================

class Scene_Map < Scene_Base
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_reader   :spriteset
end[/code])
      @bw = bitmap.width  / 32.0 / frames
      @bh = bitmap.height / 32.0 / 4
    elsif character_name != "" && @tile_id == 0
      @bw = bitmap.width  / 32.0 / (frames * 4)
      @bh = bitmap.height / 32.0 / 8
    else
      @bw = 1.0
      @bh = 1.0
    end
    bitmap.dispose
  end
  #--------------------------------------------------------------------------
  # * New method: collision?
  #--------------------------------------------------------------------------
  def collision?(x, y, w, h)
    ax1, ay1, ax2, ay2 = setup_rect(x, y, w, h)
    bx1, by1, bx2, by2 = setup_rect(@x, @y, bw, bh)
    ax2 > bx1 && ax1 < bx2 && ay2 > by1 && ay1 < by2
  end
  #--------------------------------------------------------------------------
  # * New method: over?
  #--------------------------------------------------------------------------
  def over?(x, y)
    ax1, ay1, ax2, ay2 = setup_rect(x, y - 0.125, 0, 0)
    bx1, by1, bx2, by2 = setup_rect(@real_x, @real_y, bw, bh - 0.125)
    ax2 >= bx1 && ax1 <= bx2 && ay2 >= by1 && ay1 <= by2
  end
  #--------------------------------------------------------------------------
  # * New method: setup_rect
  #--------------------------------------------------------------------------
  def setup_rect(x, y, w, h)
    x1 = x - w / 2.0
    y1 = y - h
    x2 = x1 + w
    y2 = y1 + h
    [x1, y1, x2, y2]
  end
  #--------------------------------------------------------------------------
  # * New method: align_with
  #--------------------------------------------------------------------------
  def align_with(x, y)
    d  = @direction
    @x = $game_map.round_x_with_direction(x, 0) if d == 2 || d == 8
    @y = $game_map.round_y_with_direction(y, 0) if d == 6 || d == 4
    dx = (d == 2 || d == 8) ? (@x - @real_x) / 0.125 : 0
    dy = (d == 4 || d == 6) ? (@y - @real_y) / 0.125 : 0
    set_direction(dx > 0 ? 6 : dx < 0 ? 4 : dy > 0 ? 2 : dy < 0 ? 8 : d)
    @real_x = $game_map.x_with_direction(@x, reverse_dir(@direction), dx.abs)
    @real_y = $game_map.y_with_direction(@y, reverse_dir(@direction), dy.abs)
    update_for_align while moving?
    @direction = d
  end
  #--------------------------------------------------------------------------
  # * New method: update_for_align
  #--------------------------------------------------------------------------
  def update_for_align
    SceneManager.scene.update_basic
    SceneManager.scene.spriteset.update
    $game_map.update(true)
    $game_timer.update
    update_animation
    update_move
  end
  #--------------------------------------------------------------------------
  # * New method: fix_position
  #--------------------------------------------------------------------------
  def fix_position(n)
    (n * 64 / 8).round / 8.0
  end
end

#==============================================================================
# ** Game_Character
#------------------------------------------------------------------------------
#  This class deals with characters. It's used as a superclass of the
# Game_Player and Game_Event classes.
#==============================================================================

class Game_Character < Game_CharacterBase
  #--------------------------------------------------------------------------
  # * Alias method: move_toward_character
  #--------------------------------------------------------------------------
  alias :move_toward_character_ve_pixel_movement :move_toward_character
  def move_toward_character(character)
    sx = distance_x_from(character.x)
    sy = distance_y_from(character.y)
    move_toward_character_ve_pixel_movement(character)
    @x = character.x if sx.abs < 1
    @y = character.y if sy.abs < 1
  end
  #--------------------------------------------------------------------------
  # * Alias method: move_toward_position
  #--------------------------------------------------------------------------
  alias :move_toward_position_ve_pixel_movement :move_toward_position
  def move_toward_position(x, y)
    sx = distance_x_from(x)
    sy = distance_y_from(y)
    move_toward_position_ve_pixel_movement(x, y)
    @x = x if sx.abs < 1
    @y = y if sy.abs < 1
  end
end

#==============================================================================
# ** Game_Player
#------------------------------------------------------------------------------
#  This class handles maps. It includes event starting determinants and map
# scrolling functions. The instance of this class is referenced by $game_map.
#==============================================================================

class Game_Player < Game_Character
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_accessor :over_event
  attr_accessor :land_test
  #--------------------------------------------------------------------------
  # * Overwrite method: check_event_trigger_there
  #--------------------------------------------------------------------------
  def check_event_trigger_there(triggers)
    x2 = $game_map.round_x_with_direction(@x, @direction)
    y2 = $game_map.round_y_with_direction(@y, @direction)
    start_map_event(x2, y2, triggers, true)
    return if $game_map.any_event_starting?
    return unless counter_tile?
    x3 = $game_map.check_x_with_direction(x2, @direction)
    y3 = $game_map.check_y_with_direction(y2, @direction)
    start_map_event(x3, y3, triggers, true)
  end
  #--------------------------------------------------------------------------
  # * Overwrite method: start_map_event
  #--------------------------------------------------------------------------
  def start_map_event(x, y, triggers, normal)
    return if $game_map.interpreter.running?
    $game_map.events_xy(x, y).each do |event|
      event.start if check_event_contiontion(x, y, event, triggers, normal)
    end
  end
  #--------------------------------------------------------------------------
  # * Overwrite method: update_nonmoving
  #--------------------------------------------------------------------------
  def update_nonmoving(last_moving)
    return if $game_map.interpreter.running?
    moved  = @moved
    @moved = false
    if last_moving || moved
      $game_party.on_player_walk
      return if check_touch_event
    end
    if movable? && Input.trigger?(:C)
      return if get_on_off_vehicle
      return if check_action_event
    end
    @over_event -= 1 if @over_event > 0 && (last_moving || moved)
    update_encounter if last_moving || moved
  end
  #--------------------------------------------------------------------------
  # * Overwrite method: get_on_vehicle
  #--------------------------------------------------------------------------
  def get_on_vehicle
    setup_vehicle
    enter_vehicle if vehicle
    @vehicle_getting_on
  end
  #--------------------------------------------------------------------------
  # * Overwrite method: increase_steps
  #--------------------------------------------------------------------------
  def increase_steps
    super
    if normal_walk?
      @steps += 1
      $game_player.damage_floor  = 0 unless on_damage_floor?
      $game_player.damage_floor += 1
      $game_party.increase_steps if @steps % 8 == 0
    end
  end
  #--------------------------------------------------------------------------
  # * Alias method: get_off_vehicle
  #--------------------------------------------------------------------------
  alias :get_off_vehicle_ve_pixel_movement :get_off_vehicle
  def get_off_vehicle
    clear_next_movement if vehicle.land_ok?(@x, @y, @direction)
    get_off_vehicle_ve_pixel_movement
  end
  #--------------------------------------------------------------------------
  # * Alias method: clear_transfer_info
  #--------------------------------------------------------------------------
  alias :clear_transfer_info_ve_pixel_movement :clear_transfer_info
  def clear_transfer_info
    clear_transfer_info_ve_pixel_movement
    clear_next_movement
  end
  #--------------------------------------------------------------------------
  # * Alias method: update
  #--------------------------------------------------------------------------
  alias :update_ve_gp_pixel_movement :update
  def update
    @followers.move unless $imported[:ve_followers_options]
    update_ve_gp_pixel_movement
  end
  #--------------------------------------------------------------------------
  # * New method: check_event_contiontion
  #--------------------------------------------------------------------------
  def check_event_contiontion(x, y, event, triggers, normal)
    passable = passable_tile?(@x, @y, @direction)
    w = (counter_tile? || !passable) ? 1.0 : bw
    h = (counter_tile? || !passable) ? 1.0 : bh
    return false unless event.trigger_in?(triggers)
    return false unless event.event_priority?(normal)
    return false unless passable || event.over_tile? || counter_tile?
    return false unless event.collision?(x, y, w, h) || !jumping?
    return false unless !event.in_front? || front_collision?(x, y, @direction)
    return true
  end
  #--------------------------------------------------------------------------
  # * New method: counter_tile?
  #--------------------------------------------------------------------------
  def counter_tile?
    x = $game_map.check_x_with_direction(@x, @direction)
    y = $game_map.check_y_with_direction(@y, @direction)
    $game_map.counter?(x, y)
  end
  #--------------------------------------------------------------------------
  # * New method: setup_vehicle
  #--------------------------------------------------------------------------
  def setup_vehicle
    $game_map.vehicles.compact.each do |vehicle|
      next unless vehicle.enter_vechicle?(@x, @y, @direction)
      @vehicle_type = vehicle.type
      break if vehicle
    end
  end
  #--------------------------------------------------------------------------
  # * New method: enter_vehicle
  #--------------------------------------------------------------------------
  def enter_vehicle
    align_with(vehicle.x, vehicle.y) unless in_airship?
    @vehicle_getting_on = true
    force_move_forward unless in_airship?
    @followers.gather
  end
  #--------------------------------------------------------------------------
  # * New method: clear_next_movement
  #--------------------------------------------------------------------------
  def clear_next_movement
    @next_movement.clear
    @followers.clear_next_movement
  end
  #--------------------------------------------------------------------------
  # * New method: step_times
  #--------------------------------------------------------------------------
  def step_times
    (move_route_forcing || not_driving?) ? super : 1
  end
  #--------------------------------------------------------------------------
  # * New method: not_driving?
  #--------------------------------------------------------------------------
  def not_driving?
    vehicle && !vehicle.driving
  end
  #--------------------------------------------------------------------------
  # * New method: move_straight
  #--------------------------------------------------------------------------
  def move_straight(d, turn_ok = true)
    super
  end
  #--------------------------------------------------------------------------
  # * New method: move_diagonal
  #--------------------------------------------------------------------------
  def move_diagonal(horz, vert)
    super
  end
  #--------------------------------------------------------------------------
  # * New method: setup_bitmap_dimension
  #--------------------------------------------------------------------------
  def setup_bitmap_dimension
    @bw = VE_PLAYER_BIG_COLLISION ? 1.0 : 0.75
    @bh = VE_PLAYER_BIG_COLLISION ? 1.0 : 0.75
  end
end

#==============================================================================
# ** Game_Follower
#------------------------------------------------------------------------------
#  This class handles the followers. Followers are the actors of the party
# that follows the leader in a line. It's used within the Game_Followers class.
#==============================================================================

class Game_Follower < Game_Character
  #--------------------------------------------------------------------------
  # * Overwrite method: chase_preceding_character
  #--------------------------------------------------------------------------
  def chase_preceding_character
    return if $imported[:ve_followers_control] && cant_follow_character
    unless moving?
      if @preceding_character.next_movement.size >= 8 && !gathering?
        next_move = @preceding_character.next_movement.shift
        move_straight(next_move)  if next_move.numeric?
        move_diagonal(*next_move) if next_move.array?
      elsif gathering?
        @preceding_character.next_movement.clear
        move_toward_player
      end
    end
  end
  #--------------------------------------------------------------------------
  # * New method: move_straight
  #--------------------------------------------------------------------------
  def move_straight(d, turn_ok = true)
    super
  end
  #--------------------------------------------------------------------------
  # * New method: move_diagonal
  #--------------------------------------------------------------------------
  def move_diagonal(horz, vert)
    super
  end
  #--------------------------------------------------------------------------
  # * New method: movement_size
  #--------------------------------------------------------------------------
  def movement_size
    return 8
  end
  #--------------------------------------------------------------------------
  # * New method: step_times
  #--------------------------------------------------------------------------
  def step_times
    (move_route_forcing || not_driving? || gathering?) ? super : 1
  end
  #--------------------------------------------------------------------------
  # * New method: not_driving?
  #--------------------------------------------------------------------------
  def not_driving?
    $game_player.not_driving?
  end
  #--------------------------------------------------------------------------
  # * New method: setup_bitmap_dimension
  #--------------------------------------------------------------------------
  def setup_bitmap_dimension
    @bw = VE_PLAYER_BIG_COLLISION ? 1.0 : 0.75
    @bh = VE_PLAYER_BIG_COLLISION ? 1.0 : 0.75
  end
end

#==============================================================================
# ** Game_Followers
#------------------------------------------------------------------------------
#  This class handles the followers. It's a wrapper for the built-in class
# "Array." It's used within the Game_Player class.
#==============================================================================

class Game_Followers
  #--------------------------------------------------------------------------
  # * New method: clear_next_movement
  #--------------------------------------------------------------------------
  def clear_next_movement
    each {|follower| follower.next_movement.clear }
  end
end

#==============================================================================
# ** Game_Event
#------------------------------------------------------------------------------
#  This class deals with events. It handles functions including event page
# switching via condition determinants, and running parallel process events.
# It's used within the Game_Map class.
#==============================================================================

class Game_Event < Game_Character
  #--------------------------------------------------------------------------
  # * Overwrite method: collide_with_player_characters?
  #--------------------------------------------------------------------------
  def collide_with_player_characters?(x, y)
    normal_priority? && player_collision?(x, y)
  end
  #--------------------------------------------------------------------------
  # * Alias method: start
  #--------------------------------------------------------------------------
  alias :start_ve_pixel_movement :start
  def start
    start_ve_pixel_movement
    $game_player.over_event = 8 if step_over? && !step_trigger?
  end
  #--------------------------------------------------------------------------
  # * Alias method: setup_page_settings
  #--------------------------------------------------------------------------
  alias :setup_page_settings_ve_pixel_movement :setup_page_settings
  def setup_page_settings_ve_pixel_movement
    setup_page_settings_ve_anti_lag
    @move_steps   = note =~ /<MOVE STEPS: (\d+)>/i ? $1.to_i : nil
    @step_trigger = note =~ /<EACH STEP TRIGGER>/i ? true : false
    @in_front     = note =~ /<FRONT COLLISION>/i   ? true : false
    @over_tile    = note =~ /<OVER TILE>/i         ? true : false
    @side_fix     = note =~ /<NO SIDE COLLISION FIX>/i ? false : true
  end
  #--------------------------------------------------------------------------
  # * New method: player_collision?
  #--------------------------------------------------------------------------
  def player_collision?(x, y)
    $game_map.actors.any? {|actor| actor.collision?(x, y, bh, bw)}
  end  
  #--------------------------------------------------------------------------
  # * New method: event_priority?
  #--------------------------------------------------------------------------
  def event_priority?(normal)
    (normal_priority? == normal || (@through && !normal)) &&
    (normal_priority? || @trigger == 0 || $game_player.over_event == 0)
  end
  #--------------------------------------------------------------------------
  # * New method: check_event_trigger_touch
  #--------------------------------------------------------------------------
  def check_event_trigger_touch(x, y)
    return if $game_map.interpreter.running?
    if @trigger == 2 && $game_player.collision?(x, y, bh, bw)
      start if !jumping? && normal_priority?
    end
  end
  #--------------------------------------------------------------------------
  # * New method: step_over?
  #--------------------------------------------------------------------------
  def step_over?
    super || (@character_name == "" && @tile_id == 0) || @priority_type == 0
  end
  #--------------------------------------------------------------------------
  # * New method: step_times
  #--------------------------------------------------------------------------
  def step_times
    @move_steps ? @move_steps : super
  end
  #--------------------------------------------------------------------------
  # * New method: step_trigger?
  #--------------------------------------------------------------------------
  def step_trigger?
    @step_trigger
  end
  #--------------------------------------------------------------------------
  # * New method: in_front?
  #--------------------------------------------------------------------------
  def in_front?
    @in_front
  end
  #--------------------------------------------------------------------------
  # * New method: over_tile?
  #--------------------------------------------------------------------------
  def over_tile?
    @over_tile
  end
  #--------------------------------------------------------------------------
  # * New method: side_collision?
  #--------------------------------------------------------------------------
  def side_collision?
    @side_fix
  end
  #--------------------------------------------------------------------------
  # * New method: setup_bitmap_dimension
  #--------------------------------------------------------------------------
  def setup_bitmap_dimension
    regexp = /<EVENT SIZE: (\d+), (\d+)>/i
    note   =~ regexp ? setup_custom_dimension($1.to_i, $2.to_i) : super
  end
  #--------------------------------------------------------------------------
  # * New method: setup_custom_dimension
  #--------------------------------------------------------------------------
  def setup_custom_dimension(x, y)
    x1 = (x / 8).to_i
    y1 = (y / 8).to_i
    @bw = x1 / 4.0
    @bh = y1 / 4.0
  end
end

#==============================================================================
# ** Game_Vehicle
#------------------------------------------------------------------------------
#  This class handles vehicles. It's used within the Game_Map class. If there
# are no vehicles on the current map, the coordinates is set to (-1,-1).
#==============================================================================

class Game_Vehicle < Game_Character
  #--------------------------------------------------------------------------
  # * Overwrite method: land_ok?
  #--------------------------------------------------------------------------
  def land_ok?(x, y, d)
    @type == :airship ? airship_landable?(x, y) : check_landable?(x, y, d)
  end
  #--------------------------------------------------------------------------
  # * New method: land_test
  #--------------------------------------------------------------------------
  def land_test
    @land_test
  end
  #--------------------------------------------------------------------------
  # * New method: step_over?
  #--------------------------------------------------------------------------
  def step_over?
    above? || super
  end
  #--------------------------------------------------------------------------
  # * New method: check_landable?
  #--------------------------------------------------------------------------
  def check_landable?(x, y, d)
    x2 = $game_map.check_x_with_direction(x, d)
    y2 = $game_map.check_y_with_direction(y, d)
    @land_test = true
    result = passable?(x2, y2, d)
    @land_test = false
    result
  end
  #--------------------------------------------------------------------------
  # * New method: airship_landable?
  #--------------------------------------------------------------------------
  def airship_landable?(x, y)
    [2, 4, 6, 8].any? {|d| passable?(x, y, d) }
  end
  #--------------------------------------------------------------------------
  # * New method: passable_normal?
  #--------------------------------------------------------------------------
  def passable_normal?(x, y, d ,d2, ceil = false)
    @land_test ? landable_normal?(x, y, d ,d2, ceil) : super(x, y, d ,d2, ceil)
  end
  #--------------------------------------------------------------------------
  # * New method: landable_normal?
  #--------------------------------------------------------------------------
  def landable_normal?(x, y, d ,d2, ceil)
    x1 = $game_map.round_x(x)
    y1 = $game_map.round_y(y)
    return false unless $game_map.valid?(x1, y1)
    return true if @through || debug_through?
    return false unless map_passable?(x1, y1, d)
    return false unless map_passable?(x1, y1, d2) || !ceil
    return false unless map_passable?(x1, y1, reverse_dir(d))
    return true
  end
  #--------------------------------------------------------------------------
  # * New method: enter_vechicle?
  #--------------------------------------------------------------------------
  def enter_vechicle?(x, y, d)
    return false if @map_id != $game_map.map_id
    x2 = $game_map.round_x_with_direction(x, d)
    y2 = $game_map.round_y_with_direction(y, d)
    x3 = $game_map.check_x_with_direction(@x, reverse_dir(d))
    y3 = $game_map.check_y_with_direction(@y, reverse_dir(d))
    ( above? && collision?(x, y - 0.125, bw * 0.75, bh * 0.75)) ||
    (!above? && collision?(x2, y2, bw, bh) && map_passable?(x3, y3, d))
  end
  #--------------------------------------------------------------------------
  # * New method: vehicle_collision?
  #--------------------------------------------------------------------------
  def vehicle_collision?(x, y, bw, bh, player)
    return false if step_over?
    return false if player.player? && self == player.vehicle
    return false if !collision?(x, y, bw, bh)
    return true
  end
end[/code]
  1. #==============================================================================
  2. # ** Victor Engine - Pixel Movement
  3. #------------------------------------------------------------------------------
  4. # Author : Victor Sant
  5. #
  6. # Version History:
  7. #  v 1.00 - 2012.05.29 > First relase
  8. #  v 1.01 - 2012.05.29 > Compatibility with Terrain States
  9. #  v 1.02 - 2012.07.03 > Compatibility with Basic Module 1.23
  10. #  v 1.03 - 2012.07.05 > Added 'over event' tag for objects over blocked tiles
  11. #                      > Added Steps settings for events
  12. #  v 1.04 - 2012.07.24 > Compatibility with Moving Platform
  13. #                      > Added <each step trigger> tag for events
  14. #  v 1.05 - 2012.07.30 > Fixed issue when characters moves toward the same spot
  15. #  v 1.06 - 2012.08.03 > Compatibility with Anti Lag
  16. #  v 1.07 - 2012.08.03 > Fixed collision with tile graphics events
  17. #------------------------------------------------------------------------------
  18. #  This script allows to replace the tile based movement where the player
  19. # walks a whole 32 pixel tile each step with one that he walks only 4 pixels.
  20. # It also give a better collision system for events.
  21. #------------------------------------------------------------------------------
  22. # Compatibility
  23. #   Requires the script 'Victor Engine - Basic Module' v 1.25 or higher
  24. #   If used with 'Victor Engine - Animated Battle' place this bellow it.
  25. #   If used with 'Victor Engine - Follower Control' place this bellow it.
  26. #   If used with 'Victor Engine - Follower Options' place this bellow it.
  27. #
  28. # * Overwrite methods
  29. #   class Game_Actor < Game_Battler
  30. #     def turn_end_on_map
  31. #
  32. #   class Game_Map
  33. #     def layered_tiles(x, y)
  34. #     def events_xy(x, y)
  35. #     def events_xy_nt(x, y)
  36. #     def x_with_direction(x, d, times = 1)
  37. #     def y_with_direction(y, d, times = 1)
  38. #     def round_x_with_direction(x, d)
  39. #     def round_y_with_direction
  40. #
  41. #   class Game_CharacterBase
  42. #     def region_id
  43. #     def move_straight(d, turn_ok = true)
  44. #     def move_diagonal(horz, vert)
  45. #     def collide_with_events?(x, y)
  46. #     def collide_with_vehicles?(x, y)
  47. #
  48. #   class Game_Player < Game_Character
  49. #     def check_event_trigger_there(triggers)
  50. #     def start_map_event(x, y, triggers, normal)
  51. #     def update_nonmoving(last_moving)
  52. #     def get_on_vehicle
  53. #     def increase_steps
  54. #
  55. #   class Game_Follower < Game_Character
  56. #     def chase_preceding_character
  57. #
  58. #   class Game_Event < Game_Character
  59. #     def collide_with_player_characters?(x, y)
  60. #
  61. #   class Game_Vehicle < Game_Character
  62. #     def land_ok?(x, y, d)
  63. #
  64. # * Alias methods
  65. #   class Game_Actor < Game_Battler
  66. #     def check_floor_effect
  67. #
  68. #   class Game_CharacterBase
  69. #     def init_public_members
  70. #     def update
  71. #
  72. #   class Game_Character < Game_CharacterBase
  73. #     def move_toward_character(character)
  74. #     def move_toward_position(x, y)
  75. #
  76. #   class Game_Event < Game_Character
  77. #     def start
  78. #
  79. #   class Game_Player < Game_Character
  80. #     def get_off_vehicle
  81. #     def clear_transfer_info
  82. #     def update
  83. #
  84. #   class Game_Event < Game_Character
  85. #     def start
  86. #
  87. #------------------------------------------------------------------------------
  88. # Instructions:
  89. #  To instal the script, open you script editor and paste this script on
  90. #  a new section bellow the Materials section. This script must also
  91. #  be bellow the script 'Victor Engine - Basic'
  92. #
  93. #------------------------------------------------------------------------------
  94. # Event Comment boxes note tags:
  95. #   Tags to be used on events Comment boxes.
  96. #
  97. #  <move steps: x>
  98. #   Setup the number of steps each "Move" command will execute. The default
  99. #   value is 8 (1 tile)
  100. #     x : number of steps
  101. #
  102. #  <event size: x, y>
  103. #   Collision area size, in pixels for event collisions.
  104. #     x : collision area width
  105. #     y : collision area height
  106. #
  107. #  <front collision>
  108. #   Events with this tag won't start if the the collision between events and
  109. #   the player occur between their edges.
  110. #
  111. #  <no side collision fix>
  112. #   Events with this tag won't have the "slide" effect when the edges of the
  113. #   events collide with the player
  114. #
  115. #  <over tile>
  116. #   Events with this tag will start even when placed over blocked tiles.
  117. #   By default, if the passage is blocked the event don't stat.
  118. #
  119. #  <each step trigger>
  120. #   By default, events with through or bellow character priority triggers
  121. #   only one time for each 8 steps above them. With this tag though, the
  122. #   event will trigger every step.
  123. #
  124. #------------------------------------------------------------------------------
  125. # Additional instructions:
  126. #
  127. #  All events and tiles have a "slide" effect when the player faces the edge
  128. #  of a tile or event. I added this function since it would be a pain to
  129. #  be in the exact position to go throug a narrow path.
  130. #  This can be disabled for events, but not for tiles.
  131. #
  132. #==============================================================================

  133. #==============================================================================
  134. # ** Victor Engine
  135. #------------------------------------------------------------------------------
  136. #   Setting module for the Victor Engine
  137. #==============================================================================

  138. module Victor_Engine
  139.   #--------------------------------------------------------------------------
  140.   # * Player collision area
  141.   #   Different from events, player collision don't rely on the graphic size
  142.   #   Player collision area can be of 2 types:
  143.   #   - 32 x 32 box if VE_PLAYER_BIG_COLLISION = true
  144.   #   - 24 x 24 box if VE_PLAYER_BIG_COLLISION = false
  145.   #--------------------------------------------------------------------------
  146.   VE_PLAYER_BIG_COLLISION = true
  147.   #--------------------------------------------------------------------------
  148.   # * required
  149.   #   This method checks for the existance of the basic module and other
  150.   #   VE scripts required for this script to work, don't edit this
  151.   #--------------------------------------------------------------------------
  152.   def self.required(name, req, version, type = nil)
  153.     if !$imported[:ve_basic_module]
  154.       msg = "The script '%s' requires the script\n"
  155.       msg += "'VE - Basic Module' v%s or higher above it to work properly\n"
  156.       msg += "Go to http://victorscripts.wordpress.com/ to download this script."
  157.       msgbox(sprintf(msg, self.script_name(name), version))
  158.       exit
  159.     else
  160.       self.required_script(name, req, version, type)
  161.     end
  162.   end
  163.   #--------------------------------------------------------------------------
  164.   # * script_name
  165.   #   Get the script name base on the imported value
  166.   #--------------------------------------------------------------------------
  167.   def self.script_name(name, ext = "VE")
  168.     name = name.to_s.gsub("_", " ").upcase.split
  169.     name.collect! {|char| char == ext ? "#{char} -" : char.capitalize }
  170.     name.join(" ")
  171.   end
  172. end

  173. $imported ||= {}
  174. $imported[:ve_pixel_movement] = 1.07
  175. Victor_Engine.required(:ve_pixel_movement, :ve_basic_module, 1.25, :above)
  176. Victor_Engine.required(:ve_pixel_movement, :ve_map_battle, 1.00, :bellow)
  177. Victor_Engine.required(:ve_pixel_movement, :ve_diagonal_move, 1.00, :bellow)

  178. #==============================================================================
  179. # ** Game_Actor
  180. #------------------------------------------------------------------------------
  181. #  This class handles actors. It's used within the Game_Actors class
  182. # ($game_actors) and referenced by the Game_Party class ($game_party).
  183. #==============================================================================

  184. class Game_Actor < Game_Battler
  185.   #--------------------------------------------------------------------------
  186.   # * Overwrite method: turn_end_on_map
  187.   #--------------------------------------------------------------------------
  188.   def turn_end_on_map
  189.     if $game_player.steps % (steps_for_turn * 8) == 0
  190.       on_turn_end
  191.       perform_map_damage_effect if @result.hp_damage > 0
  192.     end
  193.   end
  194.   #--------------------------------------------------------------------------
  195.   # * Alias method: init_public_members
  196.   #--------------------------------------------------------------------------
  197.   alias :check_floor_effect_ve_pixel_movement :check_floor_effect
  198.   def check_floor_effect
  199.     return if check_damage_floor
  200.     check_floor_effect_ve_pixel_movement
  201.   end
  202.   #--------------------------------------------------------------------------
  203.   # * New method: check_damage_floor
  204.   #--------------------------------------------------------------------------
  205.   def check_damage_floor
  206.     $game_player.damage_floor % 8 != 0
  207.   end
  208. end

  209. #==============================================================================
  210. # ** Game_Map
  211. #------------------------------------------------------------------------------
  212. #  This class handles maps. It includes scrolling and passage determination
  213. # functions. The instance of this class is referenced by $game_map.
  214. #==============================================================================

  215. class Game_Map
  216.   #--------------------------------------------------------------------------
  217.   # * Overwrite method: layered_tiles
  218.   #--------------------------------------------------------------------------
  219.   def layered_tiles(x, y)
  220.     x2 = (x - 0.5).ceil
  221.     y2 = (y - 0.125).ceil
  222.     [2, 1, 0].collect {|z| tile_id(x2, y2, z) }
  223.   end
  224.   #--------------------------------------------------------------------------
  225.   # * Overwrite method: events_xy
  226.   #--------------------------------------------------------------------------
  227.   def events_xy(x, y)
  228.     event_list.select {|event| event.near?(x, y) }
  229.   end
  230.   #--------------------------------------------------------------------------
  231.   # * Overwrite method: events_xy_nt
  232.   #--------------------------------------------------------------------------
  233.   def events_xy_nt(x, y)
  234.     event_list.select {|event| event.near_nt?(x, y) }
  235.   end
  236.   #--------------------------------------------------------------------------
  237.   # * Overwrite method: x_with_direction
  238.   #--------------------------------------------------------------------------
  239.   def x_with_direction(x, d, times = 1)
  240.     x + (d == 6 ? times * 0.125 : d == 4 ? -times * 0.125 : 0)
  241.   end
  242.   #--------------------------------------------------------------------------
  243.   # * Overwrite method: y_with_direction
  244.   #--------------------------------------------------------------------------
  245.   def y_with_direction(y, d, times = 1)
  246.     y + (d == 2 ? times * 0.125 : d == 8 ? -times * 0.125 : 0)
  247.   end
  248.   #--------------------------------------------------------------------------
  249.   # * Overwrite method: round_x_with_direction
  250.   #--------------------------------------------------------------------------
  251.   def round_x_with_direction(x, d)
  252.     round_x(x + (d == 6 ? 0.125 : d == 4 ? -0.125 : 0))
  253.   end
  254.   #--------------------------------------------------------------------------
  255.   # * Overwrite method: round_y_with_direction
  256.   #--------------------------------------------------------------------------
  257.   def round_y_with_direction(y, d)
  258.     round_y(y + (d == 2 ? 0.125 : d == 8 ? -0.125 : 0))
  259.   end
  260.   #--------------------------------------------------------------------------
  261.   # * New method: check_x_with_direction
  262.   #--------------------------------------------------------------------------
  263.   def check_x_with_direction(x, d)
  264.     round_x(x + (d == 6 ? 1 : d == 4 ? -1 : 0))
  265.   end
  266.   #--------------------------------------------------------------------------
  267.   # * New method: check_y_with_direction
  268.   #--------------------------------------------------------------------------
  269.   def check_y_with_direction(y, d)
  270.     round_y(y + (d == 2 ? 1 : d == 8 ? -1 : 0))
  271.   end
  272. end

  273. #==============================================================================
  274. # ** Game_CharacterBase
  275. #------------------------------------------------------------------------------
  276. #  This class deals with characters. Common to all characters, stores basic
  277. # data, such as coordinates and graphics. It's used as a superclass of the
  278. # Game_Character class.
  279. #==============================================================================

  280. class Game_CharacterBase
  281.   #--------------------------------------------------------------------------
  282.   # * Public Instance Variables
  283.   #--------------------------------------------------------------------------
  284.   attr_accessor :next_movement
  285.   attr_accessor :side_collision
  286.   attr_accessor :damage_floor
  287.   attr_accessor :steps
  288.   #--------------------------------------------------------------------------
  289.   # * Overwrite method: region_id
  290.   #--------------------------------------------------------------------------
  291.   def region_id
  292.     $game_map.region_id((@x - 0.5).ceil, (@y - 0.125).ceil)
  293.   end
  294.   #--------------------------------------------------------------------------
  295.   # * Overwrite method: collide_with_events?
  296.   #--------------------------------------------------------------------------
  297.   def collide_with_events?(x, y)
  298.     $game_map.events_xy_nt(x, y).any? do |event|
  299.       event.collision_condition?(x, y, bw, bh, event?, @id, @side_collision)
  300.     end
  301.   end
  302.   #--------------------------------------------------------------------------
  303.   # * Overwrite method: collide_with_vehicles?
  304.   #--------------------------------------------------------------------------
  305.   def collide_with_vehicles?(x, y)
  306.     $game_map.vehicles.compact.any? do |vehicle|
  307.       next if vehicle.map_id != $game_map.map_id
  308.       vehicle.vehicle_collision?(x, y, bw, bh, self)
  309.     end
  310.   end
  311.   #--------------------------------------------------------------------------
  312.   # * Overwrite method: move_straight
  313.   #--------------------------------------------------------------------------
  314.   def move_straight(d, turn_ok = true)
  315.     @move_list += [{d: [d], turn: turn_ok}] * step_times
  316.   end
  317.   #--------------------------------------------------------------------------
  318.   # * Overwrite method: move_straight
  319.   #--------------------------------------------------------------------------
  320.   def move_diagonal(horz, vert)
  321.     @move_list += [{d: [horz, vert], turn: true}] * step_times
  322.   end
  323.   #--------------------------------------------------------------------------
  324.   # * Alias method: init_public_members
  325.   #--------------------------------------------------------------------------
  326.   alias :init_public_members_ve_pixel_movement :init_public_members
  327.   def init_public_members
  328.     init_public_members_ve_pixel_movement
  329.     @move_list     = []
  330.     @next_movement = []
  331.     @over_event    = 0
  332.     @damage_floor  = 0
  333.     @steps         = 0
  334.   end
  335.   #--------------------------------------------------------------------------
  336.   # * Alias method: update
  337.   #--------------------------------------------------------------------------
  338.   alias :update_ve_pixel_movement :update
  339.   def update
  340.     update_move_straight
  341.     update_move_diagonal
  342.     update_ve_pixel_movement
  343.   end
  344.   #--------------------------------------------------------------------------
  345.   # * New method: update_move_straight
  346.   #--------------------------------------------------------------------------
  347.   def update_move_straight
  348.     return if moving? || @move_list.empty?
  349.     return if @move_list.first[:d].size > 1
  350.     move = @move_list.shift
  351.     d    = move[:d].first
  352.     if passable?(@x, @y, d)
  353.       @diagonal_move = false
  354.       setup_movement(d, d)
  355.       @real_x = $game_map.x_with_direction(@x, reverse_dir(d))
  356.       @real_y = $game_map.y_with_direction(@y, reverse_dir(d))
  357.       @moved  = player?
  358.     elsif move[:turn]
  359.       check_event_trigger_move(d)
  360.     end
  361.   end
  362.   #--------------------------------------------------------------------------
  363.   # * Overwrite method: update_move_diagonal
  364.   #--------------------------------------------------------------------------
  365.   def update_move_diagonal
  366.     return if moving? || @move_list.empty?
  367.     return if @move_list.first[:d].size < 2
  368.     move = @move_list.shift
  369.     horz = move[:d].first
  370.     vert = move[:d].last
  371.     if diagonal_passable?(x, y, horz, vert)
  372.       @diagonal_move = true
  373.       setup_movement(horz, vert)
  374.       @real_x = $game_map.x_with_direction(@x, reverse_dir(horz))
  375.       @real_y = $game_map.y_with_direction(@y, reverse_dir(vert))
  376.       @moved = player?
  377.     end
  378.   end
  379.   #--------------------------------------------------------------------------
  380.   # * New method: character_collision?
  381.   #--------------------------------------------------------------------------
  382.   def character_collision?(x, y, d)
  383.     x2 = $game_map.round_x_with_direction(x, d)
  384.     y2 = $game_map.round_y_with_direction(y, d)
  385.     !collide_with_characters?(x2, y2) || @through || debug_through?
  386.   end
  387.   #--------------------------------------------------------------------------
  388.   # * New method: step_times
  389.   #--------------------------------------------------------------------------
  390.   def step_times
  391.     return 8
  392.   end
  393.   #--------------------------------------------------------------------------
  394.   # * New method: near_nt?
  395.   #--------------------------------------------------------------------------
  396.   def near_nt?(x, y)
  397.     near?(x, y) && !@through
  398.   end
  399.   #--------------------------------------------------------------------------
  400.   # * New method: near?
  401.   #--------------------------------------------------------------------------
  402.   def near?(x, y)
  403.     w = step_over? ? [bw * 0.625, 0.5].max : [bw, 1.0].max
  404.     h = step_over? ? [bh * 0.625, 0.5].max : [bh, 1.0].max
  405.     @real_x > x - w && @real_x < x + w && @real_y > y - h && @real_y < y + h
  406.   end
  407.   #--------------------------------------------------------------------------
  408.   # * New method: setup_movement
  409.   #--------------------------------------------------------------------------
  410.   def setup_movement(horz, vert)
  411.     @x = $game_map.round_x_with_direction(@x, horz)
  412.     @y = $game_map.round_y_with_direction(@y, vert)
  413.     add_next_movement(horz == vert ? horz : [horz, vert])
  414.     set_direction(horz) if @direction == reverse_dir(horz) || horz == vert
  415.     set_direction(vert) if @direction == reverse_dir(vert) && horz != vert
  416.     follower_control_move_update(horz, vert)
  417.     increase_steps
  418.   end
  419.   #--------------------------------------------------------------------------
  420.   # * New method: check_event_trigger_move
  421.   #--------------------------------------------------------------------------
  422.   def check_event_trigger_move(d)
  423.     set_direction(d)
  424.     check_event_trigger_touch_front
  425.   end
  426.   #--------------------------------------------------------------------------
  427.   # * New method: collision_condition?
  428.   #--------------------------------------------------------------------------
  429.   def collision_condition?(x, y, bw, bh, event, event_id, side)
  430.     return false if event && self.id == event_id
  431.     return false unless collision?(x, y, bw, bh)
  432.     return false unless normal_priority? || event
  433.     return false if side && !side_collision?
  434.     return true
  435.   end
  436.   #--------------------------------------------------------------------------
  437.   # * New method: follower_control_move_update
  438.   #--------------------------------------------------------------------------
  439.   def follower_control_move_update(horz, vert)
  440.     return unless $imported[:ve_followers_options]
  441.     return unless player? || follower?
  442.     add_move_update(horz == vert ? [horz] : [horz, vert])
  443.   end
  444.   #--------------------------------------------------------------------------
  445.   # * New method: passable?
  446.   #--------------------------------------------------------------------------
  447.   def passable?(x, y, d)
  448.     x = fix_position(x)
  449.     y = fix_position(y)
  450.     passable1 = passable_tile?(x, y, d)
  451.     passable2 = character_collision?(x, y, d)
  452.     fix_movement(x, y, d)  if player? && !passable1 && passable2
  453.     fix_collision(x, y, d) if player? && !passable2 && passable1
  454.     passable1 && passable2
  455.   end
  456.   #--------------------------------------------------------------------------
  457.   # * New method: passable_tile?
  458.   #--------------------------------------------------------------------------
  459.   def passable_tile?(x, y, d)
  460.     result = true
  461.     result = passable_down?(x, y)  if d == 2
  462.     result = passable_left?(x, y)  if d == 4
  463.     result = passable_right?(x, y) if d == 6
  464.     result = passable_up?(x, y)    if d == 8
  465.     result
  466.   end
  467.   #--------------------------------------------------------------------------
  468.   # * New method: locked_tile?
  469.   #--------------------------------------------------------------------------
  470.   def locked_tile?(x, y, d = 0)
  471.     list = [2, 4, 6, 8] - [d]
  472.     list.all? {|d| !map_passable?(x, y, d) }
  473.   end
  474.   #--------------------------------------------------------------------------
  475.   # * New method: locked_move?
  476.   #--------------------------------------------------------------------------
  477.   def locked_move?(x, y)
  478.     !passable_down?(x, y)  && !passable_left?(x, y)
  479.     !passable_right?(x, y) && !passable_up?(x, y)
  480.   end
  481.   #--------------------------------------------------------------------------
  482.   # * New method: passable_down?
  483.   #--------------------------------------------------------------------------
  484.   def passable_down?(x, y)
  485.     passable_normal?(x.ceil, y.to_i, 2, 4, x.ceil?) &&
  486.     passable_normal?(x.to_i, y.to_i, 2, 6, x.ceil?)
  487.   end
  488.   #--------------------------------------------------------------------------
  489.   # * New method: passable_left?
  490.   #--------------------------------------------------------------------------
  491.   def passable_left?(x, y)
  492.     passable_normal?(x.ceil, y.ceil, 4, 8, y.ceil?) &&
  493.     passable_normal?(x.ceil, y.to_i, 4, 2, y.ceil?)
  494.   end
  495.   #--------------------------------------------------------------------------
  496.   # * New method: passable_right?
  497.   #--------------------------------------------------------------------------
  498.   def passable_right?(x, y)
  499.     passable_normal?(x.to_i, y.ceil, 6, 8, y.ceil?) &&
  500.     passable_normal?(x.to_i, y.to_i, 6, 2, y.ceil?)
  501.   end
  502.   #--------------------------------------------------------------------------
  503.   # * New method: passable_up?
  504.   #--------------------------------------------------------------------------
  505.   def passable_up?(x, y)
  506.     passable_normal?(x.ceil, y.ceil, 8, 4, x.ceil?) &&
  507.     passable_normal?(x.to_i, y.ceil, 8, 6, x.ceil?)
  508.   end
  509.   #--------------------------------------------------------------------------
  510.   # * New method: passable_normal?
  511.   #--------------------------------------------------------------------------
  512.   def passable_normal?(x, y, d, d2, ceil = false)
  513.     x1 = $game_map.round_x(x)
  514.     y1 = $game_map.round_y(y)
  515.     x2 = $game_map.check_x_with_direction(x1, d)
  516.     y2 = $game_map.check_y_with_direction(y1, d)
  517.     x3 = $game_map.round_x_with_direction(x1, d)
  518.     y3 = $game_map.round_y_with_direction(y1, d)
  519.     return false unless $game_map.valid?(x3, y3)
  520.     return true  if @through || debug_through?
  521.     return false unless map_passable?(x2, y2, d2) || !ceil
  522.     return false unless move_passable1?(x1, y1, x2, y2, d)
  523.     return false unless move_passable2?(x1, y1, x2, y2, d)
  524.     return true
  525.   end
  526.   #--------------------------------------------------------------------------
  527.   # * New method: move_passable1?
  528.   #--------------------------------------------------------------------------
  529.   def move_passable1?(x1, y1, x2, y2, d)
  530.     map_passable?(x1, y1, d) || map_passable?(x2, y2, d)
  531.   end
  532.   #--------------------------------------------------------------------------
  533.   # * New method: move_passable?
  534.   #--------------------------------------------------------------------------
  535.   def move_passable2?(x1, y1, x2, y2, d)
  536.     map_passable?(x2, y2, reverse_dir(d)) && (map_passable?(x1, y1, d) ||
  537.     locked_tile?(x1, y1))
  538.   end
  539.   #--------------------------------------------------------------------------
  540.   # * New method: fix_movement
  541.   #--------------------------------------------------------------------------
  542.   def fix_movement(x, y, d)
  543.     return if (@diagonal && @diagonal != 0) || @diagonal_move
  544.     fix_movement_horiz(x, y, d) if (d == 2 || d == 8) && x.ceil?
  545.     fix_movement_vert(x, y, d)  if (d == 4 || d == 6) && y.ceil?
  546.   end
  547.   #--------------------------------------------------------------------------
  548.   # * New method: fix_movement_horiz
  549.   #--------------------------------------------------------------------------
  550.   def fix_movement_horiz(x, y, d)
  551.     adjust = x - x.to_i
  552.     fix_move_straight(4) if fix_movement_left?(x, y, d)  && adjust < 0.5
  553.     fix_move_straight(6) if fix_movement_right?(x, y, d) && adjust > 0.5
  554.   end
  555.   #--------------------------------------------------------------------------
  556.   # * New method: fix_movement_ver
  557.   #--------------------------------------------------------------------------
  558.   def fix_movement_vert(x, y, d)
  559.     adjust = y - y.to_i
  560.     fix_move_straight(2) if fix_movement_down?(x, y, d) && adjust > 0.5
  561.     fix_move_straight(8) if fix_movement_up?(x, y, d)   && adjust < 0.5
  562.   end
  563.   #--------------------------------------------------------------------------
  564.   # * New method: fix_movement_down?
  565.   #--------------------------------------------------------------------------
  566.   def fix_movement_down?(x, y, d)
  567.     passable_normal?(x.to_i, y.ceil, d, 0, false) && movement_fix?(x, y, 2)
  568.   end
  569.   #--------------------------------------------------------------------------
  570.   # * New method: fix_movement_left?
  571.   #--------------------------------------------------------------------------
  572.   def fix_movement_left?(x, y, d)
  573.     passable_normal?(x.to_i, y.to_i, d, 0, false) && movement_fix?(x, y, 4)
  574.   end
  575.   #--------------------------------------------------------------------------
  576.   # * New method: fix_movement_right?
  577.   #--------------------------------------------------------------------------
  578.   def fix_movement_right?(x, y, d)
  579.     passable_normal?(x.ceil, y.to_i, d, 0, false) && movement_fix?(x, y, 6)
  580.   end
  581.   #--------------------------------------------------------------------------
  582.   # * New method: fix_movement_up?
  583.   #--------------------------------------------------------------------------
  584.   def fix_movement_up?(x, y, d)
  585.     passable_normal?(x.to_i, y.to_i, d, 0, false) && movement_fix?(x, y, 8)
  586.   end
  587.   #--------------------------------------------------------------------------
  588.   # * New method: movement_fix?
  589.   #--------------------------------------------------------------------------
  590.   def movement_fix?(x, y, d)
  591.     passable_tile?(x, y, d) && character_collision?(x, y, d)
  592.   end
  593.   #--------------------------------------------------------------------------
  594.   # * New method: fix_collision
  595.   #--------------------------------------------------------------------------
  596.   def fix_collision(x, y, d)
  597.     return if (@diagonal && @diagonal != 0) || @diagonal_move
  598.     @side_collision = true
  599.     fix_collision_horiz(x, y, d) if (d == 2 || d == 8)
  600.     fix_collision_vert(x, y, d)  if (d == 4 || d == 6)
  601.     @side_collision = false
  602.   end
  603.   #--------------------------------------------------------------------------
  604.   # * New method: fix_collision_horiz
  605.   #--------------------------------------------------------------------------
  606.   def fix_collision_horiz(x, y, d)
  607.     fix_move_straight(4) if fix_collision_left?(x, y, d)
  608.     fix_move_straight(6) if fix_collision_right?(x, y, d)
  609.   end
  610.   #--------------------------------------------------------------------------
  611.   # * New method: fix_collision_vert
  612.   #--------------------------------------------------------------------------
  613.   def fix_collision_vert(x, y, d)
  614.     fix_move_straight(2) if fix_collision_down?(x, y, d)
  615.     fix_move_straight(8) if fix_collision_up?(x, y, d)
  616.   end
  617.   #--------------------------------------------------------------------------
  618.   # * New method: fix_collision_down?
  619.   #--------------------------------------------------------------------------
  620.   def fix_collision_down?(x, y, d)
  621.     !character_collision?(x, y, d) && collision_fix?(x, y, d, 2)
  622.   end
  623.   #--------------------------------------------------------------------------
  624.   # * New method: fix_collision_left?
  625.   #--------------------------------------------------------------------------
  626.   def fix_collision_left?(x, y, d)
  627.     !character_collision?(x, y, d) && collision_fix?(x, y, d,  4)
  628.   end
  629.   #--------------------------------------------------------------------------
  630.   # * New method: fix_collision_right?
  631.   #--------------------------------------------------------------------------
  632.   def fix_collision_right?(x, y, d)
  633.     !character_collision?(x, y, d) && collision_fix?(x, y, d, 6)
  634.   end
  635.   #--------------------------------------------------------------------------
  636.   # * New method: fix_collision_up?
  637.   #--------------------------------------------------------------------------
  638.   def fix_collision_up?(x, y, d)
  639.     !character_collision?(x, y, d) && collision_fix?(x, y, d, 8)
  640.   end
  641.   #--------------------------------------------------------------------------
  642.   # * New method: collision_fix?
  643.   #--------------------------------------------------------------------------
  644.   def collision_fix?(x, y, d, d2)
  645.     side_collision_fix?(x, y, d, d2, 2) && side_fix?(x, y, d2)
  646.   end
  647.   #--------------------------------------------------------------------------
  648.   # * New method: side_collision_fix?
  649.   #--------------------------------------------------------------------------
  650.   def side_collision_fix?(x, y, d, d2, t)
  651.     t.times.any? do |i|
  652.       x2, y2 = x, y
  653.       y2 += (t - i) * 0.125 if d2 == 2
  654.       x2 -= (t - i) * 0.125 if d2 == 4
  655.       x2 += (t - i) * 0.125 if d2 == 6
  656.       y2 -= (t - i) * 0.125 if d2 == 8
  657.       character_collision?(x2, y2, d)
  658.     end
  659.   end
  660.   #--------------------------------------------------------------------------
  661.   # * New method: side_fix?
  662.   #--------------------------------------------------------------------------
  663.   def side_fix?(x, y, d)
  664.     passable_tile?(x, y, d) && character_collision?(x, y, d)
  665.   end
  666.   #--------------------------------------------------------------------------
  667.   # * New method: fix_move_straight
  668.   #--------------------------------------------------------------------------
  669.   def fix_move_straight(d)
  670.     return if moving?
  671.     @x = $game_map.round_x_with_direction(@x, d)
  672.     @y = $game_map.round_y_with_direction(@y, d)
  673.     follower_control_move_update(d, d)
  674.     add_next_movement(d)
  675.     increase_steps
  676.     @moved = player?
  677.   end
  678.   #--------------------------------------------------------------------------
  679.   # * New method: add_next_movement
  680.   #--------------------------------------------------------------------------
  681.   def add_next_movement(d)
  682.     return unless follower? || player?
  683.     return if $imported[:ve_followers_control] && follower_control_block
  684.     return if $game_player.followers.gathering?
  685.     @next_movement.push(d)
  686.   end
  687.   #--------------------------------------------------------------------------
  688.   # * New method: follower_control_block
  689.   #--------------------------------------------------------------------------
  690.   def follower_control_block
  691.     return true if follower? && origin_position
  692.     return true if $game_player.followers.gathering_origin?
  693.     return false
  694.   end
  695.   #--------------------------------------------------------------------------
  696.   # * New method: front_collision?
  697.   #--------------------------------------------------------------------------
  698.   def front_collision?(x, y, d)
  699.     return false if (@diagonal && @diagonal != 0) || @diagonal_move
  700.     result = !front_collision_horiz(x, y, d) if (d == 2 || d == 8)
  701.     result = !front_collision_vert(x, y, d)  if (d == 4 || d == 6)
  702.     result
  703.   end
  704.   #--------------------------------------------------------------------------
  705.   # * New method: front_collision_horiz
  706.   #--------------------------------------------------------------------------
  707.   def front_collision_horiz(x, y, d)
  708.     side_collision_fix?(x, y, d, 4, 4) || side_collision_fix?(x, y, d, 6, 4)
  709.   end
  710.   #--------------------------------------------------------------------------
  711.   # * New method: front_collision_vert
  712.   #--------------------------------------------------------------------------
  713.   def front_collision_vert(x, y, d)
  714.     side_collision_fix?(x, y, d, 2, 4) || side_collision_fix?(x, y, d, 8, 4)
  715.   end
  716.   #--------------------------------------------------------------------------
  717.   # * New method: step_over?
  718.   #--------------------------------------------------------------------------
  719.   def step_over?
  720.     @through
  721.   end
  722.   #--------------------------------------------------------------------------
  723.   # * New method: bw
  724.   #--------------------------------------------------------------------------
  725.   def bw
  726.     setup_bitmap_dimension unless @bw && character_name == @character_name_wh
  727.     @bw
  728.   end
  729.   #--------------------------------------------------------------------------
  730.   # * New method: bh
  731.   #--------------------------------------------------------------------------
  732.   def bh
  733.     setup_bitmap_dimension unless @bh && character_name == @character_name_wh
  734.     @bh
  735.   end
  736.   #--------------------------------------------------------------------------
  737.   # * New method: setup_bitmap_dimension
  738.   #--------------------------------------------------------------------------
  739.   def setup_bitmap_dimension
  740.     @character_name_wh = character_name
  741.     bitmap = Cache.character(character_name).clone
  742.     sign = @character_name[/^[\!\$]./]
  743.     if character_name != "" && @tile_id == 0 && sign && sign.include?('[code]#==============================================================================
  744. # ** Victor Engine - Basic Module
  745. #------------------------------------------------------------------------------
  746. # Author : Victor Sant
  747. #
  748. # Version History:
  749. #  v 1.00 - 2011.12.19 > First relase
  750. #  v 1.01 - 2011.12.21 > Added Event Troop notes
  751. #  v 1.02 - 2011.12.22 > Added character frames value
  752. #  v 1.03 - 2011.12.30 > Added Actor and Enemy notes
  753. #  v 1.04 - 2012.01.01 > Added party average level and map actors
  754. #  v 1.05 - 2012.01.04 > Compatibility with Characters Scripts
  755. #  v 1.06 - 2012.01.07 > Compatibility with Fog and Light Effect
  756. #                      > Added new Sprite Character functions
  757. #  v 1.07 - 2012.01.11 > Compatibility with Control Text and Codes
  758. #  v 1.08 - 2012.01.13 > Compatibility with Trait Control
  759. #  v 1.09 - 2012.01.15 > Fixed the Regular Expressions problem with "" and “”
  760. #  v 1.10 - 2012.01.18 > Compatibility with Automatic Battlers
  761. #  v 1.11 - 2012.01.26 > Compatibility with Followers Options
  762. #                        Compatibility with Animated Battle beta
  763. #  v 1.12 - 2012.02.08 > Compatibility with Animated Battle
  764. #  v 1.13 - 2012.02.18 > Fix for non RTP dependant encrypted projects
  765. #  v 1.14 - 2012.03.11 > Better version handling and required messages
  766. #  v 1.15 - 2012.03.11 > Added level variable for enemies (to avoid crashes)
  767. #  v 1.16 - 2012.03.21 > Compatibility with Follower Control
  768. #  v 1.17 - 2012.03.22 > Compatibility with Follower Control new method
  769. #  v 1.18 - 2012.03.22 > Added Battler Types tag support
  770. #  v 1.19 - 2012.05.20 > Compatibility with Map Turn Battle
  771. #  v 1.20 - 2012.05.21 > Fix for older RMVXa versions
  772. #  v 1.21 - 2012.05.29 > Compatibility with Pixel Movement
  773. #  v 1.22 - 2012.07.02 > Compatibility with Terrain States
  774. #  v 1.23 - 2012.07.03 > Fix for Pixel Movement
  775. #  v 1.24 - 2012.07.17 > Compatibility with Critical Hit Effects
  776. #  v 1.25 - 2012.07.24 > Compatibility with Moving Plaforms
  777. #  v 1.26 - 2012.07.30 > Compatibility with Automatic Battlers
  778. #  v 1.27 - 2012.08.01 > Compatibility with Custom Slip Effect
  779. #  v 1.28 - 2012.08.03 > Compatibility with Custom Slip Effect v 1.01
  780. #------------------------------------------------------------------------------
  781. #   This is the basic script for the system from Victory Engine and is
  782. # required to use the scripts from the engine. This script offer some new
  783. # functions to be used within many scripts of the engine.
  784. #------------------------------------------------------------------------------
  785. # Compatibility
  786. #   Required for the Victor Engine
  787. #
  788. # * Overwrite methods
  789. #   class << Cache
  790. #     def self.character(filename)
  791. #
  792. #   class Sprite_Character < Sprite_Base
  793. #     def set_character_bitmap
  794. #
  795. # * Alias methods
  796. #   class Game_Interpreter
  797. #     def command_108
  798. #
  799. #   class Window_Base < Window
  800. #     def convert_escape_characters(text)
  801. #
  802. #------------------------------------------------------------------------------
  803. # Instructions:
  804. #  To instal the script, open you script editor and paste this script on
  805. #  a new section bellow the Materials section.
  806. #
  807. #------------------------------------------------------------------------------
  808. # New functions
  809. #
  810. # * Random number between two vales
  811. #   rand_between(min, max)
  812. #    min : min value
  813. #    max : max value
  814. #   Can be called from any class, this method return an random value between
  815. #   two specific numbers
  816. #
  817. # * Random array value
  818. #   <Array>.random
  819. #   <Array>.random!
  820. #   Returns a random object from the array, the method .random! is destructive,
  821. #   removing the value returned from the array.
  822. #
  823. # * Sum of the numeric values of a array
  824. #   <Array>.sum
  825. #   Returns the sum of all numeric values
  826. #
  827. # * Average of all numeric values from the array
  828. #   <Array>.average(float = false)
  829. #    float : float flag
  830. #   Returns the average of all numeric values, if floa is true, the value
  831. #   returned is a float, otherwise it's a integer.
  832. #
  833. # * Note for events
  834. #   <Event>.note
  835. #   By default, events doesn't have note boxes. This command allows to use
  836. #   comments as note boxes, following the same format as the ones on the
  837. #   database. Returns all comments on the active page of the event.
  838. #
  839. # * Comment calls
  840. #   <Event>.comment_call
  841. #   Another function for comment boxes, by default, they have absolutely no
  842. #   effect in game when called. But this method allows to make the comment
  843. #   box to behave like an script call, but with the versatility of the
  844. #   note boxes. Remember that the commands will only take effect if there
  845. #   is scripts to respond to the comment code.
  846. #
  847. #==============================================================================

  848. #==============================================================================
  849. # ** Victor Engine
  850. #------------------------------------------------------------------------------
  851. #   Setting module for the Victor Engine
  852. #==============================================================================

  853. module Victor_Engine
  854.   #--------------------------------------------------------------------------
  855.   # * New method: required_script
  856.   #--------------------------------------------------------------------------
  857.   def self.required_script(name, req, version, type = 0)
  858.     if type != :bellow && (!$imported[req] || $imported[req] < version)
  859.       msg = "The script '%s' requires the script\n"
  860.       case type
  861.       when :above
  862.         msg += "'%s' v%s or higher above it to work properly\n"
  863.       else
  864.         msg += "'%s' v%s or higher to work properly\n"
  865.       end
  866.       msg += "Go to http://victorscripts.wordpress.com/ to download this script."
  867.       self.exit_message(msg, name, req, version)
  868.     elsif type == :bellow && $imported[req]
  869.       msg =  "The script '%s' requires the script\n"
  870.       msg += "'%s' to be put bellow it\n"
  871.       msg += "move the scripts to the proper position"
  872.       self.exit_message(msg, name, req, version)
  873.     end
  874.   end
  875.   #--------------------------------------------------------------------------
  876.   # * New method: exit_message
  877.   #--------------------------------------------------------------------------
  878.   def self.exit_message(message, name, req, version)
  879.     name = self.script_name(name)
  880.     req  = self.script_name(req)
  881.     msgbox(sprintf(message, name, req, version))
  882.     exit
  883.   end
  884.   #--------------------------------------------------------------------------
  885.   # * New method: script_name
  886.   #--------------------------------------------------------------------------
  887.   def self.script_name(name, ext = "VE")
  888.     name = name.to_s.gsub("_", " ").upcase.split
  889.     name.collect! {|char| char == ext ? "#{char} -" : char.capitalize }
  890.     name.join(" ")
  891.   end
  892. end

  893. $imported ||= {}
  894. $imported[:ve_basic_module] = 1.28

  895. #==============================================================================
  896. # ** Object
  897. #------------------------------------------------------------------------------
  898. #  This class is the superclass of all other classes.
  899. #==============================================================================

  900. class Object
  901.   #--------------------------------------------------------------------------
  902.   # * Include setting module
  903.   #--------------------------------------------------------------------------
  904.   include Victor_Engine
  905.   #-------------------------------------------------------------------------
  906.   # * New method: rand_between
  907.   #-------------------------------------------------------------------------
  908.   def rand_between(min, max)
  909.     min + rand(max - min + 1)
  910.   end
  911.   #--------------------------------------------------------------------------
  912.   # * New method: numeric?
  913.   #--------------------------------------------------------------------------
  914.   def numeric?
  915.     return false
  916.   end
  917.   #--------------------------------------------------------------------------
  918.   # * New method: string?
  919.   #--------------------------------------------------------------------------
  920.   def string?
  921.     return false
  922.   end
  923.   #--------------------------------------------------------------------------
  924.   # * New method: array?
  925.   #--------------------------------------------------------------------------
  926.   def array?
  927.     return false
  928.   end
  929.   #--------------------------------------------------------------------------
  930.   # * New method: float?
  931.   #--------------------------------------------------------------------------
  932.   def float?
  933.     return false
  934.   end
  935.   #--------------------------------------------------------------------------
  936.   # * New method: item?
  937.   #--------------------------------------------------------------------------
  938.   def item?
  939.     return false
  940.   end
  941.   #--------------------------------------------------------------------------
  942.   # * New method: skill?
  943.   #--------------------------------------------------------------------------
  944.   def skill?
  945.     return false
  946.   end
  947.   #--------------------------------------------------------------------------
  948.   # * New method: file_exist?
  949.   #--------------------------------------------------------------------------
  950.   def file_exist?(path, filename)
  951.     $file_list ||= {}
  952.     $file_list[path + filename] ||= file_test(path, filename)
  953.     $file_list[path + filename]
  954.   end
  955.   #--------------------------------------------------------------------------
  956.   # * New method: get_file_list
  957.   #--------------------------------------------------------------------------
  958.   def file_test(path, filename)
  959.     bitmap = Cache.load_bitmap(path, filename) rescue nil
  960.     bitmap ? true : false
  961.   end
  962.   #--------------------------------------------------------------------------
  963.   # * New method: character_exist?
  964.   #--------------------------------------------------------------------------
  965.   def character_exist?(filename)
  966.     file_exist?("Graphics/Characters/", filename)
  967.   end
  968.   #--------------------------------------------------------------------------
  969.   # * New method: battler_exist?
  970.   #--------------------------------------------------------------------------
  971.   def battler_exist?(filename)
  972.     file_exist?("Graphics/Battlers/", filename)
  973.   end
  974.   #--------------------------------------------------------------------------
  975.   # * New method: get_filename
  976.   #--------------------------------------------------------------------------
  977.   def get_filename
  978.     "[\"'“‘]([^\"'”‘”’]+)[\"'”’]"
  979.   end
  980.   #--------------------------------------------------------------------------
  981.   # * New method: get_all_values
  982.   #--------------------------------------------------------------------------
  983.   def get_all_values(value1, value2 = nil)
  984.     value2 = value1 unless value2
  985.     /<#{value1}>((?:[^<]|<[^\/])*)<\/#{value2}>/im
  986.   end
  987.   #--------------------------------------------------------------------------
  988.   # * New method: make_symbol
  989.   #--------------------------------------------------------------------------
  990.   def make_symbol(string)
  991.     string.downcase.gsub(" ", "_").to_sym
  992.   end
  993.   #--------------------------------------------------------------------------
  994.   # * New method: make_string
  995.   #--------------------------------------------------------------------------
  996.   def make_string(symbol)
  997.     symbol.to_s.gsub("_", " ").upcase
  998.   end
  999.   #--------------------------------------------------------------------------
  1000.   # * New method: returing_value
  1001.   #--------------------------------------------------------------------------
  1002.   def returing_value(i, x)
  1003.     i % (x * 2) >= x ? (x * 2) - i % (x * 2) : i % (x * 2)
  1004.   end
  1005.   #--------------------------------------------------------------------------
  1006.   # New method: in_rect?
  1007.   #--------------------------------------------------------------------------
  1008.   def in_rect?(w, h, x1, y1, x2, y2, fx = 0)
  1009.     aw, ah, ax, ay, bx, by = setup_area(w, h, x1, y1, x2, y2, fx)
  1010.     bx > ax - aw && bx < ax + aw && by > ay - ah && by < ay + ah
  1011.   end
  1012.   #--------------------------------------------------------------------------
  1013.   # New method: in_radius?
  1014.   #--------------------------------------------------------------------------
  1015.   def in_radius?(w, h, x1, y1, x2, y2, fx = 0)
  1016.     aw, ah, ax, ay, bx, by = setup_area(w, h, x1, y1, x2, y2, fx)
  1017.     ((bx - ax) ** 2 / aw ** 2) + ((by - ay) ** 2 / ah ** 2) <= 1
  1018.   end
  1019.   #--------------------------------------------------------------------------
  1020.   # New method: setup_area
  1021.   #--------------------------------------------------------------------------
  1022.   def setup_area(w, h, x1, y1, x2, y2, fx)
  1023.     aw = w
  1024.     ah = h * aw
  1025.     ax = x1
  1026.     ay = y1
  1027.     bx = x2
  1028.     by = y2
  1029.     bx += fx / 4 if ax > bx
  1030.     bx -= fx / 4 if ax < bx
  1031.     [aw, ah, ax, ay, bx, by]
  1032.   end
  1033. end

  1034. #==============================================================================
  1035. # ** String
  1036. #------------------------------------------------------------------------------
  1037. # The string class. Can handle character sequences of arbitrary lengths.
  1038. #==============================================================================

  1039. class String
  1040.   #--------------------------------------------------------------------------
  1041.   # * New method: string?
  1042.   #--------------------------------------------------------------------------
  1043.   def string?
  1044.     return true
  1045.   end
  1046. end

  1047. #==============================================================================
  1048. # ** Numeric
  1049. #------------------------------------------------------------------------------
  1050. #  This is the abstract class for numbers.
  1051. #==============================================================================

  1052. class Numeric
  1053.   #--------------------------------------------------------------------------
  1054.   # * New method: numeric?
  1055.   #--------------------------------------------------------------------------
  1056.   def numeric?
  1057.     return true
  1058.   end
  1059.   #--------------------------------------------------------------------------
  1060.   # * New method: ceil?
  1061.   #--------------------------------------------------------------------------
  1062.   def ceil?
  1063.     return false
  1064.   end
  1065. end

  1066. #==============================================================================
  1067. # ** Float
  1068. #------------------------------------------------------------------------------
  1069. #  This is the abstract class for the floating point values.
  1070. #==============================================================================

  1071. class Float
  1072.   #--------------------------------------------------------------------------
  1073.   # * New method: float?
  1074.   #--------------------------------------------------------------------------
  1075.   def float?
  1076.     return true
  1077.   end
  1078.   #--------------------------------------------------------------------------
  1079.   # * New method: ceil?
  1080.   #--------------------------------------------------------------------------
  1081.   def ceil?
  1082.     self != self.ceil
  1083.   end
  1084. end

  1085. #==============================================================================
  1086. # ** Array     
  1087. #------------------------------------------------------------------------------
  1088. #  This class store arbitrary Ruby objects.
  1089. #==============================================================================

  1090. class Array
  1091.   #--------------------------------------------------------------------------
  1092.   # * New method: array?
  1093.   #--------------------------------------------------------------------------
  1094.   def array?
  1095.     return true
  1096.   end
  1097.   #-------------------------------------------------------------------------
  1098.   # * New method: random
  1099.   #-------------------------------------------------------------------------
  1100.   def random
  1101.     self[rand(size)]
  1102.   end
  1103.   #-------------------------------------------------------------------------
  1104.   # * New method: random!
  1105.   #-------------------------------------------------------------------------
  1106.   def random!
  1107.     self.delete_at(rand(size))
  1108.   end
  1109.   #---------------------------------------------------------------------------
  1110.   # * New method: sum
  1111.   #---------------------------------------------------------------------------
  1112.   def sum
  1113.     self.inject(0) {|r, n| r += (n.numeric? ? n : 0)}
  1114.   end
  1115.   #---------------------------------------------------------------------------
  1116.   # * New method: average
  1117.   #---------------------------------------------------------------------------
  1118.   def average(float = false)
  1119.     self.sum / [(float ? size.to_f : size.to_i), 1].max
  1120.   end
  1121.   #---------------------------------------------------------------------------
  1122.   # * New method: next_item
  1123.   #---------------------------------------------------------------------------
  1124.   def next_item
  1125.     item = self.shift
  1126.     self.push(item)
  1127.     item
  1128.   end
  1129.   #---------------------------------------------------------------------------
  1130.   # * New method: previous_item
  1131.   #---------------------------------------------------------------------------
  1132.   def previous_item
  1133.     item = self.pop
  1134.     self.unshift(item)
  1135.     item
  1136.   end
  1137. end

  1138. #==============================================================================
  1139. # ** RPG::Troop::Page
  1140. #------------------------------------------------------------------------------
  1141. #  This is the data class for battle events (pages).
  1142. #==============================================================================

  1143. class RPG::Troop::Page
  1144.   #--------------------------------------------------------------------------
  1145.   # * New method: note
  1146.   #--------------------------------------------------------------------------
  1147.   def note
  1148.     return "" if !@list || @list.size <= 0
  1149.     comment_list = []
  1150.     @list.each do |item|
  1151.       next unless item && (item.code == 108 || item.code == 408)
  1152.       comment_list.push(item.parameters[0])
  1153.     end
  1154.     comment_list.join("\r\n")
  1155.   end
  1156. end

  1157. #==============================================================================
  1158. # ** RPG::UsableItem
  1159. #------------------------------------------------------------------------------
  1160. #  This is the superclass for skills and items.
  1161. #==============================================================================

  1162. class RPG::UsableItem < RPG::BaseItem
  1163.   #--------------------------------------------------------------------------
  1164.   # * New method: for_all_targets?
  1165.   #--------------------------------------------------------------------------
  1166.   def for_all_targets?
  1167.     return false
  1168.   end
  1169. end

  1170. #==============================================================================
  1171. # ** RPG::Skill
  1172. #------------------------------------------------------------------------------
  1173. #  This is the data class for skills.
  1174. #==============================================================================

  1175. class RPG::Skill < RPG::UsableItem
  1176.   #--------------------------------------------------------------------------
  1177.   # * New method: item?
  1178.   #--------------------------------------------------------------------------
  1179.   def item?
  1180.     return false
  1181.   end
  1182.   #--------------------------------------------------------------------------
  1183.   # * New method: skill?
  1184.   #--------------------------------------------------------------------------
  1185.   def skill?
  1186.     return true
  1187.   end
  1188.   #--------------------------------------------------------------------------
  1189.   # * New method: type_set
  1190.   #--------------------------------------------------------------------------
  1191.   def type_set
  1192.     [stype_id]
  1193.   end  
  1194. end

  1195. #==============================================================================
  1196. # ** RPG::Item
  1197. #------------------------------------------------------------------------------
  1198. #  This is the data class for items.
  1199. #==============================================================================

  1200. class RPG::Item < RPG::UsableItem
  1201.   #--------------------------------------------------------------------------
  1202.   # * New method: item?
  1203.   #--------------------------------------------------------------------------
  1204.   def item?
  1205.     return true
  1206.   end
  1207.   #--------------------------------------------------------------------------
  1208.   # * New method: skill?
  1209.   #--------------------------------------------------------------------------
  1210.   def skill?
  1211.     return false
  1212.   end
  1213.   #--------------------------------------------------------------------------
  1214.   # * New method: type_set
  1215.   #--------------------------------------------------------------------------
  1216.   def type_set
  1217.     [itype_id]
  1218.   end  
  1219. end

  1220. #==============================================================================
  1221. # ** Cache
  1222. #------------------------------------------------------------------------------
  1223. #  This module loads each of graphics, creates a Bitmap object, and retains it.
  1224. # To speed up load times and conserve memory, this module holds the created
  1225. # Bitmap object in the internal hash, allowing the program to return
  1226. # preexisting objects when the same bitmap is requested again.
  1227. #==============================================================================

  1228. class << Cache
  1229.   #--------------------------------------------------------------------------
  1230.   # * Overwrite method: character
  1231.   #--------------------------------------------------------------------------
  1232.   def character(filename, hue = 0)
  1233.     load_bitmap("Graphics/Characters/", filename, hue)
  1234.   end
  1235.   #--------------------------------------------------------------------------
  1236.   # * New method: cache
  1237.   #--------------------------------------------------------------------------
  1238.   def cache
  1239.     @cache
  1240.   end
  1241. end

  1242. #==============================================================================
  1243. # ** Game_BattlerBase
  1244. #------------------------------------------------------------------------------
  1245. #  This class handles battlers. It's used as a superclass of the Game_Battler
  1246. # classes.
  1247. #==============================================================================

  1248. class Game_BattlerBase
  1249.   #--------------------------------------------------------------------------
  1250.   # * Public Instance Variables
  1251.   #--------------------------------------------------------------------------
  1252.   attr_reader   :buffs
  1253.   #--------------------------------------------------------------------------
  1254.   # * New method: get_cond
  1255.   #--------------------------------------------------------------------------
  1256.   def get_cond(text)
  1257.     case text.upcase
  1258.     when "HIGHER"    then ">"
  1259.     when "LOWER"     then "<"
  1260.     when "EQUAL"     then "=="
  1261.     when "DIFFERENT" then "!="
  1262.     else "!="
  1263.     end
  1264.   end
  1265.   #--------------------------------------------------------------------------
  1266.   # * New method: get_param
  1267.   #--------------------------------------------------------------------------
  1268.   def get_param(text)
  1269.     case text.upcase
  1270.     when "MAXHP" then self.mhp
  1271.     when "MAXMP" then self.mmp
  1272.     when "MAXTP" then self.max_tp
  1273.     else eval("self.#{text.downcase}")
  1274.     end
  1275.   end
  1276.   #--------------------------------------------------------------------------
  1277.   # * New method: get_param_id
  1278.   #--------------------------------------------------------------------------
  1279.   def get_param_id(text)
  1280.     case text.upcase
  1281.     when "MAXHP", "HP" then 0
  1282.     when "MAXMP", "MP" then 1
  1283.     when "ATK" then 2
  1284.     when "DEF" then 3
  1285.     when "MAT" then 4
  1286.     when "MDF" then 5
  1287.     when "AGI" then 6
  1288.     when "LUK" then 7
  1289.     end
  1290.   end
  1291.   #--------------------------------------------------------------------------
  1292.   # * New method: type
  1293.   #--------------------------------------------------------------------------
  1294.   def type
  1295.     list = []
  1296.     get_all_notes.scan(/<BATTLER TYPE: ((?:\w+ *,? *)+)>/i) do
  1297.       $1.scan(/(\d+)/i) { list.push(make_symbol($1)) }
  1298.     end
  1299.     list.uniq
  1300.   end
  1301.   #--------------------------------------------------------------------------
  1302.   # * New method: danger?
  1303.   #--------------------------------------------------------------------------
  1304.   def danger?
  1305.     hp < mhp * 25 / 100
  1306.   end
  1307.   #--------------------------------------------------------------------------
  1308.   # * New method: sprite
  1309.   #--------------------------------------------------------------------------
  1310.   def sprite
  1311.     valid = SceneManager.scene_is?(Scene_Battle) && SceneManager.scene.spriteset
  1312.     valid ? SceneManager.scene.spriteset.sprite(self) : nil
  1313.   end
  1314.   #--------------------------------------------------------------------------
  1315.   # * New method:
  1316.   #--------------------------------------------------------------------------
  1317.   def element_set(item)
  1318.     element_set  = [item.damage.element_id]
  1319.     element_set += atk_elements if item.damage.element_id < 0
  1320.     element_set.compact
  1321.   end
  1322.   #--------------------------------------------------------------------------
  1323.   # * New method: add_state_normal
  1324.   #--------------------------------------------------------------------------
  1325.   def add_state_normal(state_id, rate = 1, user = self)
  1326.     chance  = rate
  1327.     chance *= state_rate(state_id)
  1328.     chance *= luk_effect_rate(user)
  1329.     add_state(state_id) if rand < state_rate(state_id)
  1330.   end
  1331.   #--------------------------------------------------------------------------
  1332.   # * New method: damaged?
  1333.   #--------------------------------------------------------------------------
  1334.   def damaged?
  1335.     @result.hp_damage != 0 || @result.mp_damage != 0 || @result.tp_damage != 0
  1336.   end
  1337.   #--------------------------------------------------------------------------
  1338.   # * New method: mtp
  1339.   #--------------------------------------------------------------------------
  1340.   def mtp
  1341.     return 100
  1342.   end
  1343. end

  1344. #==============================================================================
  1345. # ** Game_Battler
  1346. #------------------------------------------------------------------------------
  1347. #  This class deals with battlers. It's used as a superclass of the Game_Actor
  1348. # and Game_Enemy classes.
  1349. #==============================================================================

  1350. class Game_Battler < Game_BattlerBase
  1351.   #--------------------------------------------------------------------------
  1352.   # * New method: cri_rate
  1353.   #--------------------------------------------------------------------------
  1354.   def cri_rate(user, item)
  1355.     user.cri
  1356.   end
  1357.   #--------------------------------------------------------------------------
  1358.   # * New method: cri_eva
  1359.   #--------------------------------------------------------------------------
  1360.   def cri_eva(user, item)
  1361.     cev
  1362.   end
  1363.   #--------------------------------------------------------------------------
  1364.   # * New method: setup_critical
  1365.   #--------------------------------------------------------------------------
  1366.   def setup_critical(user, item)
  1367.     cri_rate(user, item) * (1 - cri_eva(user, item))
  1368.   end
  1369. end

  1370. #==============================================================================
  1371. # ** Game_Enemy
  1372. #------------------------------------------------------------------------------
  1373. #  This class handles enemy characters. It's used within the Game_Troop class
  1374. # ($game_troop).
  1375. #==============================================================================

  1376. class Game_Enemy < Game_Battler
  1377.   #--------------------------------------------------------------------------
  1378.   # * New method: note
  1379.   #--------------------------------------------------------------------------
  1380.   def note
  1381.     enemy ? enemy.note : ""
  1382.   end
  1383.   #--------------------------------------------------------------------------
  1384.   # * New method: get_all_notes
  1385.   #--------------------------------------------------------------------------
  1386.   def get_all_notes(*args)
  1387.     notes  = ""
  1388.     notes += note if !args.include?(:self)
  1389.     states.compact.each {|state| notes += state.note } if !args.include?(:state)
  1390.     notes
  1391.   end
  1392.   #--------------------------------------------------------------------------
  1393.   # * New method: get_all_objects
  1394.   #--------------------------------------------------------------------------
  1395.   def get_all_objects(*args)
  1396.     result = []
  1397.     result += [self] if !args.include?(:self)
  1398.     result += states.compact if !args.include?(:state)
  1399.     result
  1400.   end
  1401.   #--------------------------------------------------------------------------
  1402.   # * New method: level
  1403.   #--------------------------------------------------------------------------
  1404.   def level
  1405.     return 1
  1406.   end
  1407.   #--------------------------------------------------------------------------
  1408.   # * New method: skill_learn?
  1409.   #--------------------------------------------------------------------------
  1410.   def skill_learn?(skill)
  1411.     skill.skill? && skills.include?(skill)
  1412.   end
  1413.   #--------------------------------------------------------------------------
  1414.   # * New method: skills
  1415.   #--------------------------------------------------------------------------
  1416.   def skills
  1417.     enemy.actions.collect {|action| $data_skills[action.skill_id] }
  1418.   end
  1419. end

  1420. #==============================================================================
  1421. # ** Game_Actor
  1422. #------------------------------------------------------------------------------
  1423. #  This class handles actors. It's used within the Game_Actors class
  1424. # ($game_actors) and referenced by the Game_Party class ($game_party).
  1425. #==============================================================================

  1426. class Game_Actor < Game_Battler
  1427.   #--------------------------------------------------------------------------
  1428.   # * New method: note
  1429.   #--------------------------------------------------------------------------
  1430.   def note
  1431.     actor ? actor.note : ""
  1432.   end
  1433.   #--------------------------------------------------------------------------
  1434.   # * New method: hue
  1435.   #--------------------------------------------------------------------------
  1436.   def hue
  1437.     @hue ? @hue : 0
  1438.   end
  1439.   #--------------------------------------------------------------------------
  1440.   # * New method: get_all_notes
  1441.   #--------------------------------------------------------------------------
  1442.   def get_all_notes(*args)
  1443.     notes = ""
  1444.     notes += note if !args.include?(:self)
  1445.     notes += self.class.note if !args.include?(:class)
  1446.     equips.compact.each {|equip| notes += equip.note } if !args.include?(:equip)
  1447.     states.compact.each {|state| notes += state.note } if !args.include?(:state)
  1448.     notes
  1449.   end
  1450.   #--------------------------------------------------------------------------
  1451.   # * New method: get_all_objects
  1452.   #--------------------------------------------------------------------------
  1453.   def get_all_objects(*args)
  1454.     result = []
  1455.     result += [self] if !args.include?(:self)
  1456.     result += [self.class]   if !args.include?(:self)
  1457.     result += equips.compact if !args.include?(:equip)
  1458.     result += states.compact if !args.include?(:state)
  1459.     result
  1460.   end
  1461.   #--------------------------------------------------------------------------
  1462.   # * New method: in_active_party?
  1463.   #--------------------------------------------------------------------------
  1464.   def in_active_party?
  1465.     $game_party.battle_members.include?(self)
  1466.   end
  1467.   #--------------------------------------------------------------------------
  1468.   # * New method: in_reserve_party?
  1469.   #--------------------------------------------------------------------------
  1470.   def in_reserve_party?
  1471.     $game_party.reserve_members.include?(self)
  1472.   end
  1473.   #--------------------------------------------------------------------------
  1474.   # * New method: in_party?
  1475.   #--------------------------------------------------------------------------
  1476.   def in_party?
  1477.     $game_party.all_members.include?(self)
  1478.   end
  1479.   #--------------------------------------------------------------------------
  1480.   # * New method: map_animation
  1481.   #--------------------------------------------------------------------------
  1482.   def map_animation(id)
  1483.     $game_map.actors.each do |member|
  1484.       member.animation_id = id if member.actor == self
  1485.     end
  1486.   end
  1487.   #--------------------------------------------------------------------------
  1488.   # * New method: on_damage_floor
  1489.   #--------------------------------------------------------------------------
  1490.   def on_damage_floor?
  1491.     $game_player.on_damage_floor?
  1492.   end
  1493. end

  1494. #==============================================================================
  1495. # ** Game_Unit
  1496. #------------------------------------------------------------------------------
  1497. #  This class handles units. It's used as a superclass of the Game_Party and
  1498. # Game_Troop classes.
  1499. #==============================================================================

  1500. class Game_Unit
  1501.   #--------------------------------------------------------------------------
  1502.   # * New method: refresh
  1503.   #--------------------------------------------------------------------------
  1504.   def refresh
  1505.     members.each {|member| member.refresh }
  1506.   end
  1507. end

  1508. #==============================================================================
  1509. # ** Game_Party
  1510. #------------------------------------------------------------------------------
  1511. #  This class handles the party. It includes information on amount of gold
  1512. # and items. The instance of this class is referenced by $game_party.
  1513. #==============================================================================

  1514. class Game_Party < Game_Unit
  1515.   #--------------------------------------------------------------------------
  1516.   # * New method: average_level
  1517.   #--------------------------------------------------------------------------
  1518.   def average_level
  1519.     battle_members.collect {|actor| actor.level }.average
  1520.   end
  1521.   #--------------------------------------------------------------------------
  1522.   # * New method: reserve_members
  1523.   #--------------------------------------------------------------------------
  1524.   def reserve_members
  1525.     all_members - battle_members
  1526.   end
  1527. end

  1528. #==============================================================================
  1529. # ** Game_Map
  1530. #------------------------------------------------------------------------------
  1531. #  This class handles maps. It includes scrolling and passage determination
  1532. # functions. The instance of this class is referenced by $game_map.
  1533. #==============================================================================

  1534. class Game_Map
  1535.   #--------------------------------------------------------------------------
  1536.   # * New method: event_list
  1537.   #--------------------------------------------------------------------------
  1538.   def event_list
  1539.     events.values
  1540.   end
  1541.   #--------------------------------------------------------------------------
  1542.   # * New method: note
  1543.   #--------------------------------------------------------------------------
  1544.   def note
  1545.     @map ? @map.note : ""
  1546.   end
  1547.   #--------------------------------------------------------------------------
  1548.   # * New method: vehicles
  1549.   #--------------------------------------------------------------------------
  1550.   def vehicles
  1551.     @vehicles
  1552.   end
  1553.   #--------------------------------------------------------------------------
  1554.   # * New method: map_events
  1555.   #--------------------------------------------------------------------------
  1556.   def map_events
  1557.     @map.events
  1558.   end
  1559.   #--------------------------------------------------------------------------
  1560.   # * New method: actors
  1561.   #--------------------------------------------------------------------------
  1562.   def actors
  1563.     [$game_player] + $game_player.followers.visible_followers
  1564.   end
  1565. end

  1566. #==============================================================================
  1567. # ** Game_CharacterBase
  1568. #------------------------------------------------------------------------------
  1569. #  This class deals with characters. Common to all characters, stores basic
  1570. # data, such as coordinates and graphics. It's used as a superclass of the
  1571. # Game_Character class.
  1572. #==============================================================================

  1573. class Game_CharacterBase
  1574.   #--------------------------------------------------------------------------
  1575.   # * Public Instance Variables
  1576.   #--------------------------------------------------------------------------
  1577.   attr_accessor :move_speed
  1578.   attr_accessor :move_frequency
  1579.   #--------------------------------------------------------------------------
  1580.   # * New method: player?
  1581.   #--------------------------------------------------------------------------
  1582.   def player?
  1583.     return false
  1584.   end
  1585.   #--------------------------------------------------------------------------
  1586.   # * New method: event?
  1587.   #--------------------------------------------------------------------------
  1588.   def event?
  1589.     return false
  1590.   end
  1591.   #--------------------------------------------------------------------------
  1592.   # * New method: follower?
  1593.   #--------------------------------------------------------------------------
  1594.   def follower?
  1595.     return false
  1596.   end
  1597.   #--------------------------------------------------------------------------
  1598.   # * New method: vehicle?
  1599.   #--------------------------------------------------------------------------
  1600.   def vehicle?
  1601.     return false
  1602.   end
  1603.   #--------------------------------------------------------------------------
  1604.   # * New method: frames
  1605.   #--------------------------------------------------------------------------
  1606.   def frames
  1607.     return 3
  1608.   end
  1609.   #--------------------------------------------------------------------------
  1610.   # * New method: hue
  1611.   #--------------------------------------------------------------------------
  1612.   def hue
  1613.     @hue ? @hue : 0
  1614.   end
  1615. end

  1616. #==============================================================================
  1617. # ** Game_Character
  1618. #------------------------------------------------------------------------------
  1619. #  This class deals with characters. It's used as a superclass of the
  1620. # Game_Player and Game_Event classes.
  1621. #==============================================================================

  1622. class Game_Character < Game_CharacterBase
  1623.   #--------------------------------------------------------------------------
  1624.   # * New method: move_toward_position
  1625.   #--------------------------------------------------------------------------
  1626.   def move_toward_position(x, y)
  1627.     sx = distance_x_from(x)
  1628.     sy = distance_y_from(y)
  1629.     if sx.abs > sy.abs
  1630.       move_straight(sx > 0 ? 4 : 6)
  1631.       move_straight(sy > 0 ? 8 : 2) if !@move_succeed && sy != 0
  1632.     elsif sy != 0
  1633.       move_straight(sy > 0 ? 8 : 2)
  1634.       move_straight(sx > 0 ? 4 : 6) if !@move_succeed && sx != 0
  1635.     end
  1636.   end
  1637.   #--------------------------------------------------------------------------
  1638.   # * New method: move_toward_position
  1639.   #--------------------------------------------------------------------------
  1640.   def turn_toward_position(x, y)
  1641.     sx = distance_x_from(x)
  1642.     sy = distance_y_from(y)
  1643.     if sx.abs > sy.abs
  1644.       set_direction(sx > 0 ? 4 : 6)
  1645.     elsif sy != 0
  1646.       set_direction(sy > 0 ? 8 : 2)
  1647.     end
  1648.   end
  1649. end

  1650. #==============================================================================
  1651. # ** Game_Player
  1652. #------------------------------------------------------------------------------
  1653. #  This class handles the player.
  1654. # The instance of this class is referenced by $game_map.
  1655. #==============================================================================

  1656. class Game_Player < Game_Character
  1657.   #--------------------------------------------------------------------------
  1658.   # * New method: player?
  1659.   #--------------------------------------------------------------------------
  1660.   def player?
  1661.     return true
  1662.   end
  1663.   #--------------------------------------------------------------------------
  1664.   # * New method: perform_transfer
  1665.   #--------------------------------------------------------------------------
  1666.   def new_map_id
  1667.     @new_map_id
  1668.   end
  1669.   #--------------------------------------------------------------------------
  1670.   # * New method: hue
  1671.   #--------------------------------------------------------------------------
  1672.   def hue
  1673.     actor ? actor.hue : 0
  1674.   end
  1675. end

  1676. #==============================================================================
  1677. # ** Game_Follower
  1678. #------------------------------------------------------------------------------
  1679. #  This class handles the followers. Followers are the actors of the party
  1680. # that follows the leader in a line. It's used within the Game_Followers class.
  1681. #==============================================================================

  1682. class Game_Follower < Game_Character
  1683.   #--------------------------------------------------------------------------
  1684.   # * New method: follower?
  1685.   #--------------------------------------------------------------------------
  1686.   def follower?
  1687.     return true
  1688.   end
  1689.   #--------------------------------------------------------------------------
  1690.   # * New method: index
  1691.   #--------------------------------------------------------------------------
  1692.   def index
  1693.     @member_index
  1694.   end
  1695.   #--------------------------------------------------------------------------
  1696.   # * New method: gathering?
  1697.   #--------------------------------------------------------------------------
  1698.   def gathering?
  1699.     $game_player.followers.gathering? && !gather?
  1700.   end
  1701. end

  1702. #==============================================================================
  1703. # ** Game_Followers
  1704. #------------------------------------------------------------------------------
  1705. #  This class handles the followers. It's a wrapper for the built-in class
  1706. # "Array." It's used within the Game_Player class.
  1707. #==============================================================================

  1708. class Game_Followers
  1709.   #--------------------------------------------------------------------------
  1710.   # * New method: get_actor
  1711.   #--------------------------------------------------------------------------
  1712.   def get_actor(id)
  1713.     list = [$game_player] + visible_followers
  1714.     list.select {|follower| follower.actor && follower.actor.id == id }.first
  1715.   end
  1716.   #--------------------------------------------------------------------------
  1717.   # * Method fix: visble_folloers
  1718.   #--------------------------------------------------------------------------
  1719.   unless method_defined?(:visible_followers)
  1720.     def visible_followers; visible_folloers; end
  1721.   end
  1722. end

  1723. #==============================================================================
  1724. # ** Game_Vehicle
  1725. #------------------------------------------------------------------------------
  1726. #  This class handles vehicles. It's used within the Game_Map class. If there
  1727. # are no vehicles on the current map, the coordinates is set to (-1,-1).
  1728. #==============================================================================

  1729. class Game_Vehicle < Game_Character
  1730.   #--------------------------------------------------------------------------
  1731.   # * New method: vehicle?
  1732.   #--------------------------------------------------------------------------
  1733.   def vehicle?
  1734.     return true
  1735.   end
  1736.   #--------------------------------------------------------------------------
  1737.   # * New method: map_id
  1738.   #--------------------------------------------------------------------------
  1739.   def map_id
  1740.     @map_id
  1741.   end
  1742.   #--------------------------------------------------------------------------
  1743.   # * New method: type
  1744.   #--------------------------------------------------------------------------
  1745.   def type
  1746.     @type
  1747.   end
  1748.   #--------------------------------------------------------------------------
  1749.   # * New method: aerial?
  1750.   #--------------------------------------------------------------------------
  1751.   def aerial?
  1752.     type == :airship
  1753.   end
  1754.   #--------------------------------------------------------------------------
  1755.   # * New method: above?
  1756.   #--------------------------------------------------------------------------
  1757.   def above?
  1758.     aerial?
  1759.   end
  1760. end

  1761. #==============================================================================
  1762. # ** Game_Event
  1763. #------------------------------------------------------------------------------
  1764. #  This class deals with events. It handles functions including event page
  1765. # switching via condition determinants, and running parallel process events.
  1766. # It's used within the Game_Map class.
  1767. #==============================================================================

  1768. class Game_Event < Game_Character
  1769.   #--------------------------------------------------------------------------
  1770.   # * New method: name
  1771.   #--------------------------------------------------------------------------
  1772.   def name
  1773.     @event.name
  1774.   end
  1775.   #--------------------------------------------------------------------------
  1776.   # * New method: event?
  1777.   #--------------------------------------------------------------------------
  1778.   def event?
  1779.     return true
  1780.   end
  1781.   #--------------------------------------------------------------------------
  1782.   # * New method: erased?
  1783.   #--------------------------------------------------------------------------
  1784.   def erased?
  1785.     @erased
  1786.   end
  1787.   #--------------------------------------------------------------------------
  1788.   # * New method: note
  1789.   #--------------------------------------------------------------------------
  1790.   def note
  1791.     return ""     if !@page || [email protected] || @page.list.size <= 0
  1792.     return @notes if @notes && @page.list == @note_page
  1793.     @note_page = @page.list.dup
  1794.     comment_list = []
  1795.     @page.list.each do |item|
  1796.       next unless item && (item.code == 108 || item.code == 408)
  1797.       comment_list.push(item.parameters[0])
  1798.     end
  1799.     @notes = comment_list.join("\r\n")
  1800.     @notes
  1801.   end  
  1802. end

  1803. #==============================================================================
  1804. # ** Game_Interpreter
  1805. #------------------------------------------------------------------------------
  1806. #  An interpreter for executing event commands. This class is used within the
  1807. # Game_Map, Game_Troop, and Game_Event classes.
  1808. #==============================================================================

  1809. class Game_Interpreter
  1810.   #--------------------------------------------------------------------------
  1811.   # * Alias method: command_108
  1812.   #--------------------------------------------------------------------------
  1813.   alias :command_108_ve_basic_module :command_108
  1814.   def command_108
  1815.     command_108_ve_basic_module
  1816.     comment_call
  1817.   end
  1818.   #--------------------------------------------------------------------------
  1819.   # * New method: comment_call
  1820.   #--------------------------------------------------------------------------
  1821.   def comment_call
  1822.   end
  1823.   #--------------------------------------------------------------------------
  1824.   # * New method: note
  1825.   #--------------------------------------------------------------------------
  1826.   def note
  1827.     @comments ? @comments.join("\r\n") : ""
  1828.   end
  1829. end

  1830. #==============================================================================
  1831. # ** Sprite_Character
  1832. #------------------------------------------------------------------------------
  1833. #  This sprite is used to display characters. It observes a instance of the
  1834. # Game_Character class and automatically changes sprite conditions.
  1835. #==============================================================================

  1836. class Sprite_Character < Sprite_Base
  1837.   #--------------------------------------------------------------------------
  1838.   # * Overwrite method: set_character_bitmap
  1839.   #--------------------------------------------------------------------------
  1840.   def set_character_bitmap
  1841.     update_character_info
  1842.     set_bitmap
  1843.     set_bitmap_position
  1844.   end
  1845.   #--------------------------------------------------------------------------
  1846.   # * New method: center_y
  1847.   #--------------------------------------------------------------------------
  1848.   def actor?
  1849.     @character.is_a?(Game_Player) || @character.is_a?(Game_Follower)
  1850.   end
  1851.   #--------------------------------------------------------------------------
  1852.   # * New method: center_y
  1853.   #--------------------------------------------------------------------------
  1854.   def actor
  1855.     actor? ? @character.actor : nil
  1856.   end
  1857.   #--------------------------------------------------------------------------
  1858.   # * New method: update_character_info
  1859.   #--------------------------------------------------------------------------
  1860.   def update_character_info
  1861.   end
  1862.   #--------------------------------------------------------------------------
  1863.   # * New method: hue
  1864.   #--------------------------------------------------------------------------
  1865.   def hue
  1866.     @character.hue
  1867.   end
  1868.   #--------------------------------------------------------------------------
  1869.   # * New method: set_bitmap
  1870.   #--------------------------------------------------------------------------
  1871.   def set_bitmap
  1872.     self.bitmap = Cache.character(set_bitmap_name, hue)
  1873.   end
  1874.   #--------------------------------------------------------------------------
  1875.   # * New method: set_bitmap_name
  1876.   #--------------------------------------------------------------------------
  1877.   def set_bitmap_name
  1878.     @character_name
  1879.   end
  1880.   #--------------------------------------------------------------------------
  1881.   # * New method: set_bitmap_position
  1882.   #--------------------------------------------------------------------------
  1883.   def set_bitmap_position
  1884.     sign = get_sign
  1885.     if sign && sign.include?(')
  1886.       @bw = bitmap.width  / 32.0 / frames
  1887.       @bh = bitmap.height / 32.0 / 4
  1888.     elsif character_name != "" && @tile_id == 0
  1889.       @bw = bitmap.width  / 32.0 / (frames * 4)
  1890.       @bh = bitmap.height / 32.0 / 8
  1891.     else
  1892.       @bw = 1.0
  1893.       @bh = 1.0
  1894.     end
  1895.     bitmap.dispose
  1896.   end
  1897.   #--------------------------------------------------------------------------
  1898.   # * New method: collision?
  1899.   #--------------------------------------------------------------------------
  1900.   def collision?(x, y, w, h)
  1901.     ax1, ay1, ax2, ay2 = setup_rect(x, y, w, h)
  1902.     bx1, by1, bx2, by2 = setup_rect(@x, @y, bw, bh)
  1903.     ax2 > bx1 && ax1 < bx2 && ay2 > by1 && ay1 < by2
  1904.   end
  1905.   #--------------------------------------------------------------------------
  1906.   # * New method: over?
  1907.   #--------------------------------------------------------------------------
  1908.   def over?(x, y)
  1909.     ax1, ay1, ax2, ay2 = setup_rect(x, y - 0.125, 0, 0)
  1910.     bx1, by1, bx2, by2 = setup_rect(@real_x, @real_y, bw, bh - 0.125)
  1911.     ax2 >= bx1 && ax1 <= bx2 && ay2 >= by1 && ay1 <= by2
  1912.   end
  1913.   #--------------------------------------------------------------------------
  1914.   # * New method: setup_rect
  1915.   #--------------------------------------------------------------------------
  1916.   def setup_rect(x, y, w, h)
  1917.     x1 = x - w / 2.0
  1918.     y1 = y - h
  1919.     x2 = x1 + w
  1920.     y2 = y1 + h
  1921.     [x1, y1, x2, y2]
  1922.   end
  1923.   #--------------------------------------------------------------------------
  1924.   # * New method: align_with
  1925.   #--------------------------------------------------------------------------
  1926.   def align_with(x, y)
  1927.     d  = @direction
  1928.     @x = $game_map.round_x_with_direction(x, 0) if d == 2 || d == 8
  1929.     @y = $game_map.round_y_with_direction(y, 0) if d == 6 || d == 4
  1930.     dx = (d == 2 || d == 8) ? (@x - @real_x) / 0.125 : 0
  1931.     dy = (d == 4 || d == 6) ? (@y - @real_y) / 0.125 : 0
  1932.     set_direction(dx > 0 ? 6 : dx < 0 ? 4 : dy > 0 ? 2 : dy < 0 ? 8 : d)
  1933.     @real_x = $game_map.x_with_direction(@x, reverse_dir(@direction), dx.abs)
  1934.     @real_y = $game_map.y_with_direction(@y, reverse_dir(@direction), dy.abs)
  1935.     update_for_align while moving?
  1936.     @direction = d
  1937.   end
  1938.   #--------------------------------------------------------------------------
  1939.   # * New method: update_for_align
  1940.   #--------------------------------------------------------------------------
  1941.   def update_for_align
  1942.     SceneManager.scene.update_basic
  1943.     SceneManager.scene.spriteset.update
  1944.     $game_map.update(true)
  1945.     $game_timer.update
  1946.     update_animation
  1947.     update_move
  1948.   end
  1949.   #--------------------------------------------------------------------------
  1950.   # * New method: fix_position
  1951.   #--------------------------------------------------------------------------
  1952.   def fix_position(n)
  1953.     (n * 64 / 8).round / 8.0
  1954.   end
  1955. end

  1956. #==============================================================================
  1957. # ** Game_Character
  1958. #------------------------------------------------------------------------------
  1959. #  This class deals with characters. It's used as a superclass of the
  1960. # Game_Player and Game_Event classes.
  1961. #==============================================================================

  1962. class Game_Character < Game_CharacterBase
  1963.   #--------------------------------------------------------------------------
  1964.   # * Alias method: move_toward_character
  1965.   #--------------------------------------------------------------------------
  1966.   alias :move_toward_character_ve_pixel_movement :move_toward_character
  1967.   def move_toward_character(character)
  1968.     sx = distance_x_from(character.x)
  1969.     sy = distance_y_from(character.y)
  1970.     move_toward_character_ve_pixel_movement(character)
  1971.     @x = character.x if sx.abs < 1
  1972.     @y = character.y if sy.abs < 1
  1973.   end
  1974.   #--------------------------------------------------------------------------
  1975.   # * Alias method: move_toward_position
  1976.   #--------------------------------------------------------------------------
  1977.   alias :move_toward_position_ve_pixel_movement :move_toward_position
  1978.   def move_toward_position(x, y)
  1979.     sx = distance_x_from(x)
  1980.     sy = distance_y_from(y)
  1981.     move_toward_position_ve_pixel_movement(x, y)
  1982.     @x = x if sx.abs < 1
  1983.     @y = y if sy.abs < 1
  1984.   end
  1985. end

  1986. #==============================================================================
  1987. # ** Game_Player
  1988. #------------------------------------------------------------------------------
  1989. #  This class handles maps. It includes event starting determinants and map
  1990. # scrolling functions. The instance of this class is referenced by $game_map.
  1991. #==============================================================================

  1992. class Game_Player < Game_Character
  1993.   #--------------------------------------------------------------------------
  1994.   # * Public Instance Variables
  1995.   #--------------------------------------------------------------------------
  1996.   attr_accessor :over_event
  1997.   attr_accessor :land_test
  1998.   #--------------------------------------------------------------------------
  1999.   # * Overwrite method: check_event_trigger_there
  2000.   #--------------------------------------------------------------------------
  2001.   def check_event_trigger_there(triggers)
  2002.     x2 = $game_map.round_x_with_direction(@x, @direction)
  2003.     y2 = $game_map.round_y_with_direction(@y, @direction)
  2004.     start_map_event(x2, y2, triggers, true)
  2005.     return if $game_map.any_event_starting?
  2006.     return unless counter_tile?
  2007.     x3 = $game_map.check_x_with_direction(x2, @direction)
  2008.     y3 = $game_map.check_y_with_direction(y2, @direction)
  2009.     start_map_event(x3, y3, triggers, true)
  2010.   end
  2011.   #--------------------------------------------------------------------------
  2012.   # * Overwrite method: start_map_event
  2013.   #--------------------------------------------------------------------------
  2014.   def start_map_event(x, y, triggers, normal)
  2015.     return if $game_map.interpreter.running?
  2016.     $game_map.events_xy(x, y).each do |event|
  2017.       event.start if check_event_contiontion(x, y, event, triggers, normal)
  2018.     end
  2019.   end
  2020.   #--------------------------------------------------------------------------
  2021.   # * Overwrite method: update_nonmoving
  2022.   #--------------------------------------------------------------------------
  2023.   def update_nonmoving(last_moving)
  2024.     return if $game_map.interpreter.running?
  2025.     moved  = @moved
  2026.     @moved = false
  2027.     if last_moving || moved
  2028.       $game_party.on_player_walk
  2029.       return if check_touch_event
  2030.     end
  2031.     if movable? && Input.trigger?(:C)
  2032.       return if get_on_off_vehicle
  2033.       return if check_action_event
  2034.     end
  2035.     @over_event -= 1 if @over_event > 0 && (last_moving || moved)
  2036.     update_encounter if last_moving || moved
  2037.   end
  2038.   #--------------------------------------------------------------------------
  2039.   # * Overwrite method: get_on_vehicle
  2040.   #--------------------------------------------------------------------------
  2041.   def get_on_vehicle
  2042.     setup_vehicle
  2043.     enter_vehicle if vehicle
  2044.     @vehicle_getting_on
  2045.   end
  2046.   #--------------------------------------------------------------------------
  2047.   # * Overwrite method: increase_steps
  2048.   #--------------------------------------------------------------------------
  2049.   def increase_steps
  2050.     super
  2051.     if normal_walk?
  2052.       @steps += 1
  2053.       $game_player.damage_floor  = 0 unless on_damage_floor?
  2054.       $game_player.damage_floor += 1
  2055.       $game_party.increase_steps if @steps % 8 == 0
  2056.     end
  2057.   end
  2058.   #--------------------------------------------------------------------------
  2059.   # * Alias method: get_off_vehicle
  2060.   #--------------------------------------------------------------------------
  2061.   alias :get_off_vehicle_ve_pixel_movement :get_off_vehicle
  2062.   def get_off_vehicle
  2063.     clear_next_movement if vehicle.land_ok?(@x, @y, @direction)
  2064.     get_off_vehicle_ve_pixel_movement
  2065.   end
  2066.   #--------------------------------------------------------------------------
  2067.   # * Alias method: clear_transfer_info
  2068.   #--------------------------------------------------------------------------
  2069.   alias :clear_transfer_info_ve_pixel_movement :clear_transfer_info
  2070.   def clear_transfer_info
  2071.     clear_transfer_info_ve_pixel_movement
  2072.     clear_next_movement
  2073.   end
  2074.   #--------------------------------------------------------------------------
  2075.   # * Alias method: update
  2076.   #--------------------------------------------------------------------------
  2077.   alias :update_ve_gp_pixel_movement :update
  2078.   def update
  2079.     @followers.move unless $imported[:ve_followers_options]
  2080.     update_ve_gp_pixel_movement
  2081.   end
  2082.   #--------------------------------------------------------------------------
  2083.   # * New method: check_event_contiontion
  2084.   #--------------------------------------------------------------------------
  2085.   def check_event_contiontion(x, y, event, triggers, normal)
  2086.     passable = passable_tile?(@x, @y, @direction)
  2087.     w = (counter_tile? || !passable) ? 1.0 : bw
  2088.     h = (counter_tile? || !passable) ? 1.0 : bh
  2089.     return false unless event.trigger_in?(triggers)
  2090.     return false unless event.event_priority?(normal)
  2091.     return false unless passable || event.over_tile? || counter_tile?
  2092.     return false unless event.collision?(x, y, w, h) || !jumping?
  2093.     return false unless !event.in_front? || front_collision?(x, y, @direction)
  2094.     return true
  2095.   end
  2096.   #--------------------------------------------------------------------------
  2097.   # * New method: counter_tile?
  2098.   #--------------------------------------------------------------------------
  2099.   def counter_tile?
  2100.     x = $game_map.check_x_with_direction(@x, @direction)
  2101.     y = $game_map.check_y_with_direction(@y, @direction)
  2102.     $game_map.counter?(x, y)
  2103.   end
  2104.   #--------------------------------------------------------------------------
  2105.   # * New method: setup_vehicle
  2106.   #--------------------------------------------------------------------------
  2107.   def setup_vehicle
  2108.     $game_map.vehicles.compact.each do |vehicle|
  2109.       next unless vehicle.enter_vechicle?(@x, @y, @direction)
  2110.       @vehicle_type = vehicle.type
  2111.       break if vehicle
  2112.     end
  2113.   end
  2114.   #--------------------------------------------------------------------------
  2115.   # * New method: enter_vehicle
  2116.   #--------------------------------------------------------------------------
  2117.   def enter_vehicle
  2118.     align_with(vehicle.x, vehicle.y) unless in_airship?
  2119.     @vehicle_getting_on = true
  2120.     force_move_forward unless in_airship?
  2121.     @followers.gather
  2122.   end
  2123.   #--------------------------------------------------------------------------
  2124.   # * New method: clear_next_movement
  2125.   #--------------------------------------------------------------------------
  2126.   def clear_next_movement
  2127.     @next_movement.clear
  2128.     @followers.clear_next_movement
  2129.   end
  2130.   #--------------------------------------------------------------------------
  2131.   # * New method: step_times
  2132.   #--------------------------------------------------------------------------
  2133.   def step_times
  2134.     (move_route_forcing || not_driving?) ? super : 1
  2135.   end
  2136.   #--------------------------------------------------------------------------
  2137.   # * New method: not_driving?
  2138.   #--------------------------------------------------------------------------
  2139.   def not_driving?
  2140.     vehicle && !vehicle.driving
  2141.   end
  2142.   #--------------------------------------------------------------------------
  2143.   # * New method: move_straight
  2144.   #--------------------------------------------------------------------------
  2145.   def move_straight(d, turn_ok = true)
  2146.     super
  2147.   end
  2148.   #--------------------------------------------------------------------------
  2149.   # * New method: move_diagonal
  2150.   #--------------------------------------------------------------------------
  2151.   def move_diagonal(horz, vert)
  2152.     super
  2153.   end
  2154.   #--------------------------------------------------------------------------
  2155.   # * New method: setup_bitmap_dimension
  2156.   #--------------------------------------------------------------------------
  2157.   def setup_bitmap_dimension
  2158.     @bw = VE_PLAYER_BIG_COLLISION ? 1.0 : 0.75
  2159.     @bh = VE_PLAYER_BIG_COLLISION ? 1.0 : 0.75
  2160.   end
  2161. end

  2162. #==============================================================================
  2163. # ** Game_Follower
  2164. #------------------------------------------------------------------------------
  2165. #  This class handles the followers. Followers are the actors of the party
  2166. # that follows the leader in a line. It's used within the Game_Followers class.
  2167. #==============================================================================

  2168. class Game_Follower < Game_Character
  2169.   #--------------------------------------------------------------------------
  2170.   # * Overwrite method: chase_preceding_character
  2171.   #--------------------------------------------------------------------------
  2172.   def chase_preceding_character
  2173.     return if $imported[:ve_followers_control] && cant_follow_character
  2174.     unless moving?
  2175.       if @preceding_character.next_movement.size >= 8 && !gathering?
  2176.         next_move = @preceding_character.next_movement.shift
  2177.         move_straight(next_move)  if next_move.numeric?
  2178.         move_diagonal(*next_move) if next_move.array?
  2179.       elsif gathering?
  2180.         @preceding_character.next_movement.clear
  2181.         move_toward_player
  2182.       end
  2183.     end
  2184.   end
  2185.   #--------------------------------------------------------------------------
  2186.   # * New method: move_straight
  2187.   #--------------------------------------------------------------------------
  2188.   def move_straight(d, turn_ok = true)
  2189.     super
  2190.   end
  2191.   #--------------------------------------------------------------------------
  2192.   # * New method: move_diagonal
  2193.   #--------------------------------------------------------------------------
  2194.   def move_diagonal(horz, vert)
  2195.     super
  2196.   end
  2197.   #--------------------------------------------------------------------------
  2198.   # * New method: movement_size
  2199.   #--------------------------------------------------------------------------
  2200.   def movement_size
  2201.     return 8
  2202.   end
  2203.   #--------------------------------------------------------------------------
  2204.   # * New method: step_times
  2205.   #--------------------------------------------------------------------------
  2206.   def step_times
  2207.     (move_route_forcing || not_driving? || gathering?) ? super : 1
  2208.   end
  2209.   #--------------------------------------------------------------------------
  2210.   # * New method: not_driving?
  2211.   #--------------------------------------------------------------------------
  2212.   def not_driving?
  2213.     $game_player.not_driving?
  2214.   end
  2215.   #--------------------------------------------------------------------------
  2216.   # * New method: setup_bitmap_dimension
  2217.   #--------------------------------------------------------------------------
  2218.   def setup_bitmap_dimension
  2219.     @bw = VE_PLAYER_BIG_COLLISION ? 1.0 : 0.75
  2220.     @bh = VE_PLAYER_BIG_COLLISION ? 1.0 : 0.75
  2221.   end
  2222. end

  2223. #==============================================================================
  2224. # ** Game_Followers
  2225. #------------------------------------------------------------------------------
  2226. #  This class handles the followers. It's a wrapper for the built-in class
  2227. # "Array." It's used within the Game_Player class.
  2228. #==============================================================================

  2229. class Game_Followers
  2230.   #--------------------------------------------------------------------------
  2231.   # * New method: clear_next_movement
  2232.   #--------------------------------------------------------------------------
  2233.   def clear_next_movement
  2234.     each {|follower| follower.next_movement.clear }
  2235.   end
  2236. end

  2237. #==============================================================================
  2238. # ** Game_Event
  2239. #------------------------------------------------------------------------------
  2240. #  This class deals with events. It handles functions including event page
  2241. # switching via condition determinants, and running parallel process events.
  2242. # It's used within the Game_Map class.
  2243. #==============================================================================

  2244. class Game_Event < Game_Character
  2245.   #--------------------------------------------------------------------------
  2246.   # * Overwrite method: collide_with_player_characters?
  2247.   #--------------------------------------------------------------------------
  2248.   def collide_with_player_characters?(x, y)
  2249.     normal_priority? && player_collision?(x, y)
  2250.   end
  2251.   #--------------------------------------------------------------------------
  2252.   # * Alias method: start
  2253.   #--------------------------------------------------------------------------
  2254.   alias :start_ve_pixel_movement :start
  2255.   def start
  2256.     start_ve_pixel_movement
  2257.     $game_player.over_event = 8 if step_over? && !step_trigger?
  2258.   end
  2259.   #--------------------------------------------------------------------------
  2260.   # * Alias method: setup_page_settings
  2261.   #--------------------------------------------------------------------------
  2262.   alias :setup_page_settings_ve_pixel_movement :setup_page_settings
  2263.   def setup_page_settings_ve_pixel_movement
  2264.     setup_page_settings_ve_anti_lag
  2265.     @move_steps   = note =~ /<MOVE STEPS: (\d+)>/i ? $1.to_i : nil
  2266.     @step_trigger = note =~ /<EACH STEP TRIGGER>/i ? true : false
  2267.     @in_front     = note =~ /<FRONT COLLISION>/i   ? true : false
  2268.     @over_tile    = note =~ /<OVER TILE>/i         ? true : false
  2269.     @side_fix     = note =~ /<NO SIDE COLLISION FIX>/i ? false : true
  2270.   end
  2271.   #--------------------------------------------------------------------------
  2272.   # * New method: player_collision?
  2273.   #--------------------------------------------------------------------------
  2274.   def player_collision?(x, y)
  2275.     $game_map.actors.any? {|actor| actor.collision?(x, y, bh, bw)}
  2276.   end  
  2277.   #--------------------------------------------------------------------------
  2278.   # * New method: event_priority?
  2279.   #--------------------------------------------------------------------------
  2280.   def event_priority?(normal)
  2281.     (normal_priority? == normal || (@through && !normal)) &&
  2282.     (normal_priority? || @trigger == 0 || $game_player.over_event == 0)
  2283.   end
  2284.   #--------------------------------------------------------------------------
  2285.   # * New method: check_event_trigger_touch
  2286.   #--------------------------------------------------------------------------
  2287.   def check_event_trigger_touch(x, y)
  2288.     return if $game_map.interpreter.running?
  2289.     if @trigger == 2 && $game_player.collision?(x, y, bh, bw)
  2290.       start if !jumping? && normal_priority?
  2291.     end
  2292.   end
  2293.   #--------------------------------------------------------------------------
  2294.   # * New method: step_over?
  2295.   #--------------------------------------------------------------------------
  2296.   def step_over?
  2297.     super || (@character_name == "" && @tile_id == 0) || @priority_type == 0
  2298.   end
  2299.   #--------------------------------------------------------------------------
  2300.   # * New method: step_times
  2301.   #--------------------------------------------------------------------------
  2302.   def step_times
  2303.     @move_steps ? @move_steps : super
  2304.   end
  2305.   #--------------------------------------------------------------------------
  2306.   # * New method: step_trigger?
  2307.   #--------------------------------------------------------------------------
  2308.   def step_trigger?
  2309.     @step_trigger
  2310.   end
  2311.   #--------------------------------------------------------------------------
  2312.   # * New method: in_front?
  2313.   #--------------------------------------------------------------------------
  2314.   def in_front?
  2315.     @in_front
  2316.   end
  2317.   #--------------------------------------------------------------------------
  2318.   # * New method: over_tile?
  2319.   #--------------------------------------------------------------------------
  2320.   def over_tile?
  2321.     @over_tile
  2322.   end
  2323.   #--------------------------------------------------------------------------
  2324.   # * New method: side_collision?
  2325.   #--------------------------------------------------------------------------
  2326.   def side_collision?
  2327.     @side_fix
  2328.   end
  2329.   #--------------------------------------------------------------------------
  2330.   # * New method: setup_bitmap_dimension
  2331.   #--------------------------------------------------------------------------
  2332.   def setup_bitmap_dimension
  2333.     regexp = /<EVENT SIZE: (\d+), (\d+)>/i
  2334.     note   =~ regexp ? setup_custom_dimension($1.to_i, $2.to_i) : super
  2335.   end
  2336.   #--------------------------------------------------------------------------
  2337.   # * New method: setup_custom_dimension
  2338.   #--------------------------------------------------------------------------
  2339.   def setup_custom_dimension(x, y)
  2340.     x1 = (x / 8).to_i
  2341.     y1 = (y / 8).to_i
  2342.     @bw = x1 / 4.0
  2343.     @bh = y1 / 4.0
  2344.   end
  2345. end

  2346. #==============================================================================
  2347. # ** Game_Vehicle
  2348. #------------------------------------------------------------------------------
  2349. #  This class handles vehicles. It's used within the Game_Map class. If there
  2350. # are no vehicles on the current map, the coordinates is set to (-1,-1).
  2351. #==============================================================================

  2352. class Game_Vehicle < Game_Character
  2353.   #--------------------------------------------------------------------------
  2354.   # * Overwrite method: land_ok?
  2355.   #--------------------------------------------------------------------------
  2356.   def land_ok?(x, y, d)
  2357.     @type == :airship ? airship_landable?(x, y) : check_landable?(x, y, d)
  2358.   end
  2359.   #--------------------------------------------------------------------------
  2360.   # * New method: land_test
  2361.   #--------------------------------------------------------------------------
  2362.   def land_test
  2363.     @land_test
  2364.   end
  2365.   #--------------------------------------------------------------------------
  2366.   # * New method: step_over?
  2367.   #--------------------------------------------------------------------------
  2368.   def step_over?
  2369.     above? || super
  2370.   end
  2371.   #--------------------------------------------------------------------------
  2372.   # * New method: check_landable?
  2373.   #--------------------------------------------------------------------------
  2374.   def check_landable?(x, y, d)
  2375.     x2 = $game_map.check_x_with_direction(x, d)
  2376.     y2 = $game_map.check_y_with_direction(y, d)
  2377.     @land_test = true
  2378.     result = passable?(x2, y2, d)
  2379.     @land_test = false
  2380.     result
  2381.   end
  2382.   #--------------------------------------------------------------------------
  2383.   # * New method: airship_landable?
  2384.   #--------------------------------------------------------------------------
  2385.   def airship_landable?(x, y)
  2386.     [2, 4, 6, 8].any? {|d| passable?(x, y, d) }
  2387.   end
  2388.   #--------------------------------------------------------------------------
  2389.   # * New method: passable_normal?
  2390.   #--------------------------------------------------------------------------
  2391.   def passable_normal?(x, y, d ,d2, ceil = false)
  2392.     @land_test ? landable_normal?(x, y, d ,d2, ceil) : super(x, y, d ,d2, ceil)
  2393.   end
  2394.   #--------------------------------------------------------------------------
  2395.   # * New method: landable_normal?
  2396.   #--------------------------------------------------------------------------
  2397.   def landable_normal?(x, y, d ,d2, ceil)
  2398.     x1 = $game_map.round_x(x)
  2399.     y1 = $game_map.round_y(y)
  2400.     return false unless $game_map.valid?(x1, y1)
  2401.     return true if @through || debug_through?
  2402.     return false unless map_passable?(x1, y1, d)
  2403.     return false unless map_passable?(x1, y1, d2) || !ceil
  2404.     return false unless map_passable?(x1, y1, reverse_dir(d))
  2405.     return true
  2406.   end
  2407.   #--------------------------------------------------------------------------
  2408.   # * New method: enter_vechicle?
  2409.   #--------------------------------------------------------------------------
  2410.   def enter_vechicle?(x, y, d)
  2411.     return false if @map_id != $game_map.map_id
  2412.     x2 = $game_map.round_x_with_direction(x, d)
  2413.     y2 = $game_map.round_y_with_direction(y, d)
  2414.     x3 = $game_map.check_x_with_direction(@x, reverse_dir(d))
  2415.     y3 = $game_map.check_y_with_direction(@y, reverse_dir(d))
  2416.     ( above? && collision?(x, y - 0.125, bw * 0.75, bh * 0.75)) ||
  2417.     (!above? && collision?(x2, y2, bw, bh) && map_passable?(x3, y3, d))
  2418.   end
  2419.   #--------------------------------------------------------------------------
  2420.   # * New method: vehicle_collision?
  2421.   #--------------------------------------------------------------------------
  2422.   def vehicle_collision?(x, y, bw, bh, player)
  2423.     return false if step_over?
  2424.     return false if player.player? && self == player.vehicle
  2425.     return false if !collision?(x, y, bw, bh)
  2426.     return true
  2427.   end
  2428. end
复制代码

点评

好长,不过出错  发表于 2012-8-16 03:25


------------------------------------------我只放我看中的遊戲-----------------------------------------------
臉書:http://www.facebook.com/brian.lee.52643821
  音速君的論壇
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
52
在线时间
704 小时
注册时间
2011-12-27
帖子
941
5
发表于 2012-8-13 10:13:19 手机端发表。 | 只看该作者
LS!!聖物啊!
我先抱走了!
終於明我的遊戲怪在什麼地方!
回复 支持 反对

使用道具 举报

Lv3.寻梦者

梦石
0
星屑
2991
在线时间
646 小时
注册时间
2009-1-21
帖子
273
4
发表于 2012-8-13 01:37:12 | 只看该作者
本帖最后由 御之嵐 于 2012-8-13 04:04 编辑

是這個嗎?

http://victorscripts.wordpress.c ... pts/pixel-movement/

============================================================

痾....
難不成 現在大多數 國外網站  都會檔 你們的IP嗎...=.=?

搜尋看看這個吧
Pixel Movement

因為他的 腳本 我也看不懂
所以我沒沒辦法  弄個 完整的 腳本給你

我貼他的影片 你看是不是吧
http://youtu.be/xyxgS9eIvVM

点评

打不开  发表于 2012-8-13 02:50

评分

参与人数 1梦石 +2 收起 理由
迷糊的安安 + 2 认可答案 附赠66RPG提供的精美好人卡一张^^.

查看全部评分

回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
108
在线时间
1006 小时
注册时间
2008-11-9
帖子
1658
3
发表于 2012-8-12 12:51:12 | 只看该作者
这个应该没有……RM的系统就已经限制在走格子的模式里= =
但是可以使用八方行走图,可以在技术发布区搜索一下~

点评

RMVX有,可不可以把他VA  发表于 2012-8-13 02:49
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
125
在线时间
352 小时
注册时间
2012-4-8
帖子
530
2
发表于 2012-8-12 05:52:45 | 只看该作者
剛看你的就看著我怎麼点就你就怎麼点吧!

点评

RM的制作已经了解透了,我说的像素移动是事件不按照格子行走  发表于 2012-8-12 07:47
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-11-17 18:49

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表