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

Project1

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

[已经过期] 有没有大师能将这套脚本复刻到VA上面?

[复制链接]

Lv1.梦旅人

梦石
0
星屑
50
在线时间
125 小时
注册时间
2006-7-19
帖子
336
跳转到指定楼层
1
发表于 2015-5-16 15:22:32 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
本帖最后由 天涯孤客 于 2015-5-16 21:56 编辑

RUBY 代码复制
  1. =begin
  2. 待机(面向左)    :00    01    02    03      共 4 张。
  3. 待机(面向右)    :10    11    12    13      共 4 张。
  4. 移动(面向左)    :20    21    22    23      共 4 张。
  5. 移动(面向右)    :30    31    32    33      共 4 张。
  6. 攻击(面向左)    :40    41    42    43      共 4 张。
  7. 攻击(面向右)    :50    51    52    53      共 4 张.
  8. 防御(面向左)    :80                              共 1 张.
  9. 防御(面向右)    :90                              共 1 张.
  10. 挨打(面向左)    :100                            共 1 张.
  11. 挨打(面向右)    :110                            共 1 张.
  12. 死亡(面向左)    :140  141                    共 2 张.
  13. 死亡(面向右)    :150  151                    共 2 张.
  14. =end
  15. #==============================================================================
  16. ###############################################################################
  17. #==============================================================================
  18. # ★全图片单帧播放实现战斗动态效果★  
  19. #==============================================================================
  20. #  by -> 芯☆淡如水
  21. #==============================================================================
  22. ###############################################################################
  23. #==============================================================================
  24. module RPG
  25.   module Cache
  26.     def self.battler(name, filename, hue)
  27.       self.load_bitmap("Graphics/Battlers/"+name+"/", filename, hue)
  28.     end
  29.   end
  30.   class Sprite < ::Sprite
  31.     def initialize(viewport = nil)
  32.       super(viewport)
  33.       @_whiten_duration = 0
  34.       @_appear_duration = 0
  35.       @_escape_duration = 0
  36.       @_collapse_duration = 0
  37.       @_damage_duration = 0
  38.       @_animation_duration = 0
  39.       @_blink = false
  40.       @_tip_duration = 0
  41.     end
  42.     #-----------------------------------------------------------
  43.     alias add_dispose_xdrs dispose
  44.     def dispose
  45.       dispose_tip
  46.       dispose_damage
  47.       dispose_animation
  48.       dispose_loop_animation
  49.       super
  50.     end
  51.     #-----------------------------------------------------------
  52.     def tip(txt, type)
  53.       dispose_tip
  54.       bitmap = Bitmap.new(240, 52)
  55.       bitmap.font.name = (["黑体","宋体","Arial Black"])
  56.       bitmap.font.size = 32
  57.       bitmap.font.bold = true
  58.       if type == 1
  59.         bitmap.font.color.set(255, 0, 255)
  60.         bitmap.draw_text(+1, 6+1, 220, 50, txt, 1)
  61.         bitmap.font.color.set(0, 255, 120)
  62.         bitmap.draw_text(0, 6, 220, 50, txt, 1)
  63.       else
  64.         bitmap.font.color.set(0, 255, 120)
  65.         bitmap.draw_text(+1, 6+1, 220, 50, txt, 1)
  66.         bitmap.font.color.set(255, 0, 255)
  67.         bitmap.draw_text(0, 6, 220, 50, txt, 1)
  68.       end
  69.       @_tip_sprite = ::Sprite.new(self.viewport)
  70.       @_tip_sprite.bitmap = bitmap
  71.       @_tip_sprite.opacity = 0
  72.       @_tip_sprite.ox = 120
  73.       @_tip_sprite.oy = 20
  74.       @_tip_sprite.x = self.x
  75.       @_tip_sprite.y = self.y - self.oy / 2
  76.       @_tip_sprite.z = 3000
  77.       @_tip_duration = 60
  78.     end
  79.     #-----------------------------------------------------------
  80.     def dispose_tip
  81.       if @_tip_sprite != nil
  82.         @_tip_sprite.bitmap.dispose
  83.         @_tip_sprite.dispose
  84.         @_tip_sprite = nil
  85.         @_tip_duration = 0
  86.       end
  87.     end
  88.     def update
  89.       super
  90.       if @_whiten_duration > 0
  91.         @_whiten_duration -= 1
  92.         self.color.alpha = 128 - (16 - @_whiten_duration) * 10
  93.       end
  94.       if @_appear_duration > 0
  95.         @_appear_duration -= 1
  96.         self.opacity = (16 - @_appear_duration) * 16
  97.       end
  98.       if @_escape_duration > 0
  99.         @_escape_duration -= 1
  100.         self.opacity = 256 - (32 - @_escape_duration) * 10
  101.       end
  102.       if @_collapse_duration > 0
  103.         @_collapse_duration -= 1
  104.         self.opacity = 256 - (48 - @_collapse_duration) * 6
  105.       end
  106.       #--------------------------------------------------------
  107.       if @_tip_duration > 0
  108.         @_tip_duration -= 1
  109.         case @_tip_duration
  110.         when 58..59
  111.           @_tip_sprite.opacity += 20
  112.           @_tip_sprite.y -= 4
  113.         when 56..57
  114.           @_tip_sprite.opacity += 40
  115.           @_tip_sprite.y -= 4
  116.         when 54..55
  117.           @_tip_sprite.opacity += 40
  118.           @_tip_sprite.y -= 3
  119.         when 51..53
  120.           @_tip_sprite.opacity += 30
  121.           @_tip_sprite.y -= 3
  122.         when 40..50
  123.           @_tip_sprite.y -= 2
  124.         end
  125.         @_tip_sprite.opacity = 256 - (12 - @_tip_duration) * 32
  126.         if @_tip_duration == 0
  127.           dispose_tip
  128.         end
  129.       end
  130.       if @_damage_duration > 0
  131.         @_damage_duration -= 1
  132.         case @_damage_duration
  133.         when 38..39
  134.           @_damage_sprite.y -= 4
  135.         when 36..37
  136.           @_damage_sprite.y -= 2
  137.         when 34..35
  138.           @_damage_sprite.y += 2
  139.         when 28..33
  140.           @_damage_sprite.y += 4
  141.         end
  142.         @_damage_sprite.opacity = 256 - (12 - @_damage_duration) * 32
  143.         if @_damage_duration == 0
  144.           dispose_damage
  145.         end
  146.       end
  147.       if @_animation != nil and (Graphics.frame_count % 2 == 0)
  148.         @_animation_duration -= 1
  149.         update_animation
  150.       end
  151.       if @_loop_animation != nil and (Graphics.frame_count % 2 == 0)
  152.         update_loop_animation
  153.         @_loop_animation_index += 1
  154.         @_loop_animation_index %= @_loop_animation.frame_max
  155.       end
  156.       if @_blink
  157.         @_blink_count = (@_blink_count + 1) % 32
  158.         if @_blink_count < 16
  159.           alpha = (16 - @_blink_count) * 6
  160.         else
  161.           alpha = (@_blink_count - 16) * 6
  162.         end
  163.         self.color.set(255, 255, 255, alpha)
  164.       end
  165.       @@_animations.clear
  166.     end
  167.   end
  168. end
  169. #==============================================================================
  170. class Game_Temp
  171.   #--------------------------------------------------------------------------
  172.   attr_accessor :show_refresh
  173.   #--------------------------------------------------------------------------
  174.   alias add_initialize_xdrs initialize
  175.   def initialize
  176.     add_initialize_xdrs
  177.     @show_refresh = false
  178.   end
  179. end
  180. #==============================================================================
  181. class Spriteset_Battle
  182.   #--------------------------------------------------------------------------
  183.   attr_reader   :viewport1                # 敌人方的显示端口
  184.   attr_reader   :viewport2                # 角色方的显示端口
  185.   #--------------------------------------------------------------------------
  186.   def initialize
  187.     # 生成显示端口
  188.     @viewport1 = Viewport.new(0, 0, 640, 480)
  189.     @viewport2 = Viewport.new(0, 0, 640, 480)
  190.     @viewport3 = Viewport.new(0, 0, 640, 480)
  191.     @viewport4 = Viewport.new(0, 0, 640, 480)
  192.     @viewport2.z = 101
  193.     @viewport3.z = 200
  194.     @viewport4.z = 5000
  195.     # 生成战斗背景活动块
  196.     @battleback_sprite = Sprite.new(@viewport1)
  197.     # 生成敌人活动块
  198.     @enemy_sprites = []
  199.     for enemy in $game_troop.enemies.reverse
  200.       @enemy_sprites.push(Sprite_Battler.new(@viewport1, enemy))
  201.     end
  202.     # 生成敌人活动块
  203.     @actor_sprites = []
  204.     @actor_sprites.push(Sprite_Battler.new(@viewport1))
  205.     @actor_sprites.push(Sprite_Battler.new(@viewport1))
  206.     @actor_sprites.push(Sprite_Battler.new(@viewport1))
  207.     @actor_sprites.push(Sprite_Battler.new(@viewport1))
  208.     # 生成天候
  209.     @weather = RPG::Weather.new(@viewport1)
  210.     # 生成图片活动块
  211.     @picture_sprites = []
  212.     for i in 51..100
  213.       @picture_sprites.push(Sprite_Picture.new(@viewport3,
  214.         $game_screen.pictures[i]))
  215.     end
  216.     # 生成计时器块
  217.     @timer_sprite = Sprite_Timer.new
  218.     # 刷新画面
  219.     update
  220.   end
  221.   #--------------------------------------------------------------------------
  222.   def update
  223.     # 刷新角色的活动块 (对应角色的替换)
  224.     @actor_sprites[0].battler = $game_party.actors[0]
  225.     @actor_sprites[1].battler = $game_party.actors[1]
  226.     @actor_sprites[2].battler = $game_party.actors[2]
  227.     @actor_sprites[3].battler = $game_party.actors[3]
  228.     # 战斗背景的文件名与现在情况有差异的情况下
  229.     if @battleback_name != $game_temp.battleback_name
  230.       @battleback_name = $game_temp.battleback_name
  231.       if @battleback_sprite.bitmap != nil
  232.         @battleback_sprite.bitmap.dispose
  233.       end
  234.       @battleback_sprite.bitmap = RPG::Cache.battleback(@battleback_name)
  235.       @battleback_sprite.src_rect.set(0, 0, 640, 480)
  236.     end
  237.     # 刷新战斗者的活动块
  238.     for sprite in @enemy_sprites + @actor_sprites
  239.       sprite.update
  240.     end
  241.     # 刷新天气图形
  242.     @weather.type = $game_screen.weather_type
  243.     @weather.max = $game_screen.weather_max
  244.     @weather.update
  245.     # 刷新图片活动块
  246.     for sprite in @picture_sprites
  247.       sprite.update
  248.     end
  249.     # 刷新计时器活动块
  250.     @timer_sprite.update
  251.     # 设置画面的色调与震动位置
  252.     @viewport1.tone = $game_screen.tone
  253.     @viewport1.ox = $game_screen.shake
  254.     # 设置画面的闪烁色
  255.     @viewport4.color = $game_screen.flash_color
  256.     # 刷新显示端口
  257.     @viewport1.update
  258.     @viewport2.update
  259.     @viewport4.update
  260.   end
  261. end
  262. class Scene_Battle
  263.   #--------------------------------------------------------------------------
  264.   # ● 刷新画面 (主回合)
  265.   #--------------------------------------------------------------------------
  266.   def update_phase4
  267.     case @phase4_step
  268.     when 1
  269.       update_phase4_step1
  270.     when 2
  271.       update_phase4_step2
  272.     when 3
  273.       update_phase4_step3
  274.     when 4
  275.       update_phase4_step4
  276.     when 5
  277.       update_phase4_step5
  278.     when 6
  279.       update_phase4_step6
  280.     when 7
  281.       update_phase4_step7
  282.     end
  283.   end
  284.   #--------------------------------------------------------------------------
  285.   # ● 刷新画面 (主回合步骤 2 : 开始行动)
  286.   #--------------------------------------------------------------------------
  287.   def update_phase4_step2
  288.     # 如果不是强制行动
  289.     unless @active_battler.current_action.forcing
  290.       # 限制为 [敌人为普通攻击] 或 [我方为普通攻击] 的情况下
  291.       if @active_battler.restriction == 2 or @active_battler.restriction == 3
  292.         # 设置行动为攻击
  293.         @active_battler.current_action.kind = 0
  294.         @active_battler.current_action.basic = 0
  295.       end
  296.       # 限制为 [不能行动] 的情况下
  297.       if @active_battler.restriction == 4
  298.         # 清除行动强制对像的战斗者
  299.         $game_temp.forcing_battler = nil
  300.         # 移至步骤 1
  301.         @phase4_step = 1
  302.         return
  303.       end
  304.     end
  305.     @active_battler.targets = []
  306.     @set_action = false
  307.     # 行动种类分支
  308.     case @active_battler.current_action.kind
  309.     when 0  # 基本
  310.       make_basic_action_result
  311.     when 1  # 特技
  312.       make_skill_action_result
  313.     when 2  # 物品
  314.       make_item_action_result
  315.     end
  316.     # 移至步骤 3
  317.     if @phase4_step == 2
  318.       @phase4_step = 3
  319.     end
  320.   end
  321.   #--------------------------------------------------------------------------
  322.   def make_basic_action_result
  323.     # 攻击的情况下
  324.     if @active_battler.current_action.basic == 0
  325.       # 设置攻击 ID
  326.       @animation1_id = @active_battler.animation1_id
  327.       @animation2_id = @active_battler.animation2_id
  328.       # 行动方的战斗者是敌人的情况下
  329.       if @active_battler.is_a?(Game_Enemy)
  330.         if @active_battler.restriction == 3
  331.           target = $game_troop.random_target_enemy
  332.         elsif @active_battler.restriction == 2
  333.           target = $game_party.random_target_actor
  334.         else
  335.           index = @active_battler.current_action.target_index
  336.           target = $game_party.smooth_target_actor(index)
  337.         end
  338.       end
  339.       # 行动方的战斗者是角色的情况下
  340.       if @active_battler.is_a?(Game_Actor)
  341.         if @active_battler.restriction == 3
  342.           target = $game_party.random_target_actor
  343.         elsif @active_battler.restriction == 2
  344.           target = $game_troop.random_target_enemy
  345.         else
  346.           index = @active_battler.current_action.target_index
  347.           target = $game_troop.smooth_target_enemy(index)
  348.         end
  349.       end
  350.       # 设置对像方的战斗者序列
  351.       @active_battler.targets = [target]
  352.       # 应用通常攻击效果
  353.       for target in @active_battler.targets
  354.         target.attack_effect(@active_battler)
  355.       end
  356.       return
  357.     end
  358.     # 防御的情况下
  359.     if @active_battler.current_action.basic == 1
  360.       # 帮助窗口显示"防御"
  361.       @help_window.set_text($data_system.words.guard, 1)
  362.       @phase4_step = 1
  363.       return
  364.     end
  365.     # 逃跑的情况下
  366.     if @active_battler.is_a?(Game_Enemy) and
  367.        @active_battler.current_action.basic == 2
  368.       #  帮助窗口显示"逃跑"
  369.       @help_window.set_text("逃跑", 1)
  370.       # 逃跑
  371.       @active_battler.escape
  372.       return
  373.     end
  374.     # 什么也不做的情况下
  375.     if @active_battler.current_action.basic == 3
  376.       # 清除强制行动对像的战斗者
  377.       $game_temp.forcing_battler = nil
  378.       # 移至步骤 1
  379.       @phase4_step = 1
  380.       return
  381.     end
  382.   end
  383.   #--------------------------------------------------------------------------
  384.   def set_target_battlers(scope)
  385.     # 行动方的战斗者是敌人的情况下
  386.     if @active_battler.is_a?(Game_Enemy)
  387.       # 效果范围分支
  388.       case scope
  389.       when 1  # 敌单体
  390.         index = @active_battler.current_action.target_index
  391.         @active_battler.targets.push($game_party.smooth_target_actor(index))
  392.       when 2  # 敌全体
  393.         for actor in $game_party.actors
  394.           if actor.exist?
  395.             @active_battler.targets.push(actor)
  396.           end
  397.         end
  398.       when 3  # 我方单体
  399.         index = @active_battler.current_action.target_index
  400.         @active_battler.targets.push($game_troop.smooth_target_enemy(index))
  401.       when 4  # 我方全体
  402.         for enemy in $game_troop.enemies
  403.           if enemy.exist?
  404.             @active_battler.targets.push(enemy)
  405.           end
  406.         end
  407.       when 5  # 我方单体 (HP 0)
  408.         index = @active_battler.current_action.target_index
  409.         enemy = $game_troop.enemies[index]
  410.         if enemy != nil and enemy.hp0?
  411.           @active_battler.targets.push(enemy)
  412.         end
  413.       when 6  # 我方全体 (HP 0)
  414.         for enemy in $game_troop.enemies
  415.           if enemy != nil and enemy.hp0?
  416.             @active_battler.targets.push(enemy)
  417.           end
  418.         end
  419.       when 7  # 使用者
  420.         @active_battler.targets.push(@active_battler)
  421.       end
  422.     else
  423.       # 效果范围分支
  424.       case scope
  425.       when 1  # 敌单体
  426.         index = @active_battler.current_action.target_index
  427.         @active_battler.targets.push($game_troop.smooth_target_enemy(index))
  428.       when 2  # 敌全体
  429.         for enemy in $game_troop.enemies
  430.           if enemy.exist?
  431.             @active_battler.targets.push(enemy)
  432.           end
  433.         end
  434.       when 3  # 我方单体
  435.         index = @active_battler.current_action.target_index
  436.         @active_battler.targets.push($game_party.smooth_target_actor(index))
  437.       when 4  # 我方全体
  438.         for actor in $game_party.actors
  439.           if actor.exist?
  440.             @active_battler.targets.push(actor)
  441.           end
  442.         end
  443.       when 5  # 我方单体 (HP 0)
  444.         index = @active_battler.current_action.target_index
  445.         actor = $game_party.actors[index]
  446.         if actor != nil and actor.hp0?
  447.           @active_battler.targets.push(actor)
  448.         end
  449.       when 6  # 我方全体 (HP 0)
  450.         for actor in $game_party.actors
  451.           if actor != nil and actor.hp0?
  452.             @active_battler.targets.push(actor)
  453.           end
  454.         end
  455.       when 7  # 使用者
  456.         @active_battler.targets.push(@active_battler)
  457.       end
  458.     end
  459.   end
  460.   #--------------------------------------------------------------------------
  461.   # ● 生成特技行动结果
  462.   #--------------------------------------------------------------------------
  463.   def make_skill_action_result
  464.     # 获取特技
  465.     @skill = $data_skills[@active_battler.current_action.skill_id]
  466.     # 如果不是强制行动
  467.     unless @active_battler.current_action.forcing
  468.       # 因为 SP 耗尽而无法使用的情况下
  469.       unless @active_battler.skill_can_use?(@skill.id)
  470.         # 清除强制行动对像的战斗者
  471.         $game_temp.forcing_battler = nil
  472.         # 移至步骤 1
  473.         @phase4_step = 1
  474.         return
  475.       end
  476.     end
  477.     # 消耗 SP
  478.     @active_battler.sp -= @skill.sp_cost
  479.     # 刷新状态窗口
  480.     @active_battler.tip_type = @skill.power > 0 ? 0 : 1
  481.     @active_battler.tip_message = @skill.name
  482.     # 设置动画 ID
  483.     @animation1_id = @skill.animation1_id
  484.     @animation2_id = @skill.animation2_id
  485.     # 设置公共事件 ID
  486.     @common_event_id = @skill.common_event_id
  487.     # 设置对像侧战斗者
  488.     set_target_battlers(@skill.scope)
  489.     # 应用特技效果
  490.     for target in @active_battler.targets
  491.       target.skill_effect(@active_battler, @skill)
  492.     end
  493.   end
  494.   #--------------------------------------------------------------------------
  495.   # ● 生成物品行动结果
  496.   #--------------------------------------------------------------------------
  497.   def make_item_action_result
  498.     # 获取物品
  499.     @item = $data_items[@active_battler.current_action.item_id]
  500.     # 因为物品耗尽而无法使用的情况下
  501.     unless $game_party.item_can_use?(@item.id)
  502.       # 移至步骤 1
  503.       @phase4_step = 1
  504.       return
  505.     end
  506.     # 消耗品的情况下
  507.     if @item.consumable
  508.       # 使用的物品减 1
  509.       $game_party.lose_item(@item.id, 1)
  510.     end
  511.     @active_battler.tip_type = [1,2].include?(@item.scope) ? 0 : 1
  512.     @active_battler.tip_message = @item.name
  513.     # 设置动画 ID
  514.     @animation1_id = @item.animation1_id
  515.     @animation2_id = @item.animation2_id
  516.     # 设置公共事件 ID
  517.     @common_event_id = @item.common_event_id
  518.     # 确定对像
  519.     index = @active_battler.current_action.target_index
  520.     target = $game_party.smooth_target_actor(index)
  521.     # 设置对像侧战斗者
  522.     set_target_battlers(@item.scope)
  523.     # 应用物品效果
  524.     for target in @active_battler.targets
  525.       target.item_effect(@item)
  526.     end
  527.   end
  528.   #--------------------------------------------------------------------------
  529.   # ● 刷新画面 (主回合步骤 3 : 行动方动画)
  530.   #--------------------------------------------------------------------------
  531.   def update_phase4_step3
  532.     unless @set_action
  533.       if @active_battler.current_action.kind == 0
  534.         @active_battler.moveto_pop = true if @active_battler.current_action.basic == 0
  535.       else
  536.         @active_battler.tip_pop = true
  537.         @active_battler.animation_id = @animation1_id if @animation1_id != 0
  538.       end
  539.       @set_action = true
  540.     end
  541.     if @active_battler.current_action.kind == 0
  542.       @phase4_step = 4 if @active_battler.atk_pop
  543.     elsif @active_battler.current_action.kind == 1
  544.       if @animation2_id != 0
  545.         for target in @active_battler.targets
  546.           target.animation_id = @animation2_id
  547.           target.animation_hit = (target.damage != "Miss")
  548.         end
  549.       end
  550.       @phase4_step = 6
  551.     else
  552.       @phase4_step = 5
  553.     end
  554.   end
  555.   #--------------------------------------------------------------------------
  556.   def update_phase4_step4
  557.     @active_battler.show_refresh = true
  558.     @phase4_step = 5
  559.   end
  560.   #--------------------------------------------------------------------------
  561.   # ● 刷新画面 (主回合步骤 5 : 对像方动画)
  562.   #--------------------------------------------------------------------------
  563.   def update_phase4_step5
  564.     if @animation2_id != 0
  565.       for target in @active_battler.targets
  566.         target.animation_id = @animation2_id
  567.         target.animation_hit = (target.damage != "Miss")
  568.       end
  569.     end
  570.     @phase4_step = 6
  571.   end
  572.   #--------------------------------------------------------------------------
  573.   # ● 刷新画面 (主回合步骤 6 : 显示伤害)
  574.   #--------------------------------------------------------------------------
  575.   def update_phase4_step6
  576.     # 隐藏帮助窗口
  577.     @help_window.visible = false
  578.     # 刷新状态窗口
  579.     for target in @active_battler.targets
  580.       if target.damage != nil and target.damage.is_a?(Numeric)
  581.         target.show_refresh = true if target.damage != 0
  582.         if target.damage > 0
  583.           if target.current_action.kind == 0 and
  584.            target.current_action.basic == 1
  585.             target.guard_pop = true
  586.           else
  587.             target.ad_pop = true
  588.           end
  589.         end
  590.       end
  591.     end
  592.     for target in @active_battler.targets
  593.       if target.damage != nil
  594.         target.damage_pop = true
  595.         if target.damage.is_a?(Numeric) and target.dead?
  596.           target.dead_pop = true
  597.         end
  598.       end
  599.     end
  600.     @status_window.refresh
  601.     # 移至步骤 6
  602.     @phase4_step = 7
  603.   end
  604.   #--------------------------------------------------------------------------
  605.   def update_phase4_step7
  606.     # 清除强制行动对像的战斗者
  607.     $game_temp.forcing_battler = nil
  608.     # 公共事件 ID 有效的情况下
  609.     if @common_event_id > 0
  610.       # 设置事件
  611.       common_event = $data_common_events[@common_event_id]
  612.       $game_system.battle_interpreter.setup(common_event.list, 0)
  613.     end
  614.     # 移至步骤 1
  615.     @phase4_step = 1
  616.   end
  617. end
  618. #-----------------------------------------------------------------------------
  619. class Game_Battler
  620.   #---------------------------------------------------------------------------
  621.   attr_accessor :dead_one               
  622.   attr_accessor :sp_damage_pop            
  623.   attr_accessor :sp_damage
  624.   attr_accessor :moveto_pop
  625.   attr_accessor :moveback_pop
  626.   attr_accessor :atk_pop
  627.   attr_accessor :int_pop
  628.   attr_accessor :dead_pop
  629.   attr_accessor :guard_pop
  630.   attr_accessor :ad_pop
  631.   attr_accessor :atk2_pop
  632.   attr_accessor :targets
  633.   attr_accessor :show_refresh
  634.   attr_accessor :tip_pop
  635.   attr_accessor :tip_type
  636.   attr_accessor :tip_message
  637.   attr_accessor :get_pop
  638.   attr_accessor :an2_pop
  639.   #--------------------------------------------------------------------------
  640.   def initialize
  641.     @battler_name = ""
  642.     @battler_hue = 0
  643.     @hp = 0
  644.     @sp = 0
  645.     @states = []
  646.     @states_turn = {}
  647.     @maxhp_plus = 0
  648.     @maxsp_plus = 0
  649.     @str_plus = 0
  650.     @dex_plus = 0
  651.     @agi_plus = 0
  652.     @int_plus = 0
  653.     @hidden = false
  654.     @immortal = false
  655.     @damage_pop = false
  656.     @damage = nil
  657.     @critical = false
  658.     @animation_id = 0
  659.     @animation_hit = false
  660.     @white_flash = false
  661.     @blink = false
  662.     @current_action = Game_BattleAction.new
  663.     @sp_damage = nil        
  664.     @dead_one = false
  665.     @show_refresh = true
  666.     @targets = []
  667.     @tip_pop = false
  668.     @get_pop = false
  669.     @tip_type = 0
  670.     @tip_message = ""
  671.     off_pop
  672.   end
  673.   #---------------------------------------------------------------------------
  674.   def off_pop
  675.     @atk_pop = false
  676.     @int_pop = false
  677.     @dead_pop = false
  678.     @guard_pop = false
  679.     @ad_pop = false
  680.     @moveto_pop = false
  681.     @moveback_pop = false
  682.     @atk2_pop = false
  683.   end
  684.   #---------------------------------------------------------------------------
  685.   def moving?
  686.     return true if @atk_pop or @atk2_pop or @moveto_pop or @moveback_pop
  687.     return false
  688.   end
  689.   #---------------------------------------------------------------------------
  690. end
  691. #===============================================================================
  692. class Sprite_Battler < RPG::Sprite
  693.   #--------------------------------------------------------------------------
  694.   def initialize(viewport, battler = nil)
  695.     super(viewport)
  696.     @battler = battler
  697.     if @battler != nil
  698.       @set = @battler.is_a?(Game_Enemy) ? 1 : 0
  699.     else
  700.       @set = 0
  701.     end
  702.     @battler_name = "00"
  703.     @battler_visible = false
  704.     @wait_time = @move_time = @atk_time = 0
  705.     @int_time = @ad_time = @dead_time = @win_time = 0
  706.     @show = Sprite.new(viewport)
  707.     @show.bitmap = Bitmap.new(96, 32)
  708.     @height = 0  
  709.     return if @battler.nil?
  710.     @show.bitmap.font.color.set(0, 0, 0)
  711.     @show.bitmap.fill_rect(0, 0, 62, 6, Color.new(0, 0, 0))
  712.     @show.bitmap.fill_rect(0, 7, 62, 6, Color.new(0, 0, 0))
  713.     w = 60 * @battler.hp / @battler.maxhp
  714.     for i in 1..w
  715.       @show.bitmap.fill_rect(i, 1, 1, 4, Color.new(255, 0, 255-i*4))
  716.     end
  717.     w = 60 * @battler.sp / @battler.maxsp
  718.     for i in 1..w
  719.       @show.bitmap.fill_rect(i, 8, 1, 4, Color.new(0, 255-i*4, 255))
  720.     end
  721.     @show.x = self.x-30
  722.     @show.y = self.y - @height - 20
  723.     @show.z = 490
  724.     @show.visible = @battler_visible
  725.   end
  726.   #--------------------------------------------------------------------------
  727.   #--------------------------------------------------------------------------
  728.   def dispose
  729.     @battler.show_refresh = true if battler != nil
  730.     @show.dispose
  731.     if self.bitmap != nil
  732.       self.bitmap.dispose
  733.     end
  734.     super
  735.   end
  736.   #--------------------------------------------------------------------------
  737.   def tuch_range(target)
  738.     bp = RPG::Cache.battler(@battler.name, "00", 0)
  739.     r1 = bp.width / 2
  740.     bp = RPG::Cache.battler(target.name, "01", 0)
  741.     r2 = bp.width / 2
  742.     return r1 + r2
  743.   end
  744.   #--------------------------------------------------------------------------
  745.   def update
  746.     super
  747.     if @battler == nil
  748.       self.bitmap = nil
  749.       loop_animation(nil)
  750.       return
  751.     end
  752.     @wait_time += 1
  753.     @wait_time = 0 if @wait_time >= 39
  754.     @battler
  755.     name = (0+@set).to_s + (@wait_time / 10).to_s
  756.     #----------------------------------------------------------------------
  757.     if @battler.moveto_pop
  758.       @move_time += 1
  759.       @move_time = 0 if @move_time >= 19
  760.       lx = @battler.targets.size == 1 ? @battler.targets[0].screen_x : 320
  761.       name = self.x > lx ? "2" : "3"
  762.       name += (@move_time / 5).to_s
  763.       if @battler.targets.size == 1
  764.         target = @battler.targets[0]
  765.         if @battler == target
  766.           @battler.current_action.kind == 0 ? @battler.atk_pop = true : @battler.atk2_pop = true
  767.           @battler.moveto_pop = false
  768.           @move_time = 0
  769.           return
  770.         end
  771.         tx = target.screen_x
  772.         tx += @battler.screen_x > target.screen_x ? (tuch_range(target)) : -(tuch_range(target))
  773.         ty = target.screen_y
  774.       else
  775.         tx = 320
  776.         ty = 280
  777.       end
  778.       if self.x == tx and self.y == ty
  779.         @battler.current_action.kind == 0 ? @battler.atk_pop = true : @battler.atk2_pop = true
  780.         @battler.moveto_pop = false
  781.         @move_time = 0
  782.         return
  783.       end
  784.       rx = (self.x - tx).abs
  785.       ry = (self.y - ty).abs
  786.       lx = [Integer(20.0*rx / (rx+ry)), rx].min
  787.       ly = [Integer(20.0*ry / (rx+ry)), ry].min
  788.       self.x += self.x > tx ? -lx : (self.x < tx ? lx : 0)
  789.       self.y += self.y > ty ? -ly : (self.y < ty ? ly : 0)
  790.     end
  791.     #---------------------------------------------------------------------
  792.     if @battler.atk_pop
  793.       n_time = [@atk_time, 39].min
  794.       if @battler.targets.size == 1
  795.         nx = self.x > @battler.targets[0].screen_x ? "4" : "5"
  796.         name = nx + (n_time / 10).to_s
  797.       else
  798.         name = (4+@set).to_s + (n_time / 10).to_s
  799.       end
  800.       @atk_time += 1
  801.       if @atk_time >= 39
  802.         @atk_time = 0
  803.         @battler.atk_pop = false
  804.         @battler.moveback_pop = true
  805.       end
  806.     end
  807.     #---------------------------------------------------------------------
  808.     if @battler.atk2_pop
  809.       n_time = [@atk_time, 39].min
  810.       if @battler.targets.size == 1
  811.         nx = self.x > @battler.targets[0].screen_x ? "6" : "7"
  812.         name = nx + (n_time / 10).to_s
  813.       else
  814.         name = (4+@set).to_s + (n_time / 10).to_s
  815.       end
  816.       @atk_time += 1
  817.       if @atk_time >= 49
  818.         @atk_time = 0
  819.         @battler.atk2_pop = false
  820.         @battler.moveback_pop = true
  821.       end
  822.     end
  823.     #----------------------------------------------------------------------
  824.     if @battler.moveback_pop
  825.       @move_time += 1
  826.       @move_time = 0 if @move_time >= 19
  827.       name = self.x > @battler.screen_x ? "2" : "3"
  828.       name += (@move_time / 5).to_s
  829.       tx = @battler.screen_x
  830.       ty = @battler.screen_y
  831.       if self.x == tx and self.y == ty
  832.         @battler.moveback_pop = false
  833.         @move_time = 0
  834.         return
  835.       end
  836.       rx = (self.x - tx).abs
  837.       ry = (self.y - ty).abs
  838.       lx = [Integer(20.0*rx / (rx+ry)), rx].min
  839.       ly = [Integer(20.0*ry / (rx+ry)), ry].min
  840.       self.x += self.x > tx ? -lx : (self.x < tx ? lx : 0)
  841.       self.y += self.y > ty ? -ly : (self.y < ty ? ly : 0)
  842.     end
  843.     #----------------------------------------------------------------------
  844.     if @battler.int_pop
  845.       if @battler.targets.size == 1 and @battler != @battler.targets[0]
  846.         nx = self.x > @battler.targets[0].screen_x ? "12" : "13"
  847.         name = nx + (@int_time / 10).to_s
  848.       else
  849.         name = (12+@set).to_s + (@int_time / 10).to_s
  850.       end
  851.       @int_time += 1
  852.       if @int_time >= 39
  853.         @int_time = 0
  854.         @battler.int_pop = false
  855.       end
  856.     end
  857.     #----------------------------------------------------------------------
  858.     if @battler.ad_pop
  859.       name = (10+@set).to_s + (@ad_time / 40).to_s
  860.       @ad_time += 1
  861.       if @ad_time >= 39
  862.         @ad_time = 0
  863.         @battler.ad_pop = false
  864.       end
  865.     end
  866.     #-----------------------------------------------------------------------
  867.     if @battler.guard_pop and not @battler.dead?
  868.       name = (8+@set).to_s + (@ad_time / 40).to_s
  869.       @ad_time += 1
  870.       if @ad_time >= 39
  871.         @ad_time = 0
  872.         @battler.guard_pop = false
  873.       end
  874.     end
  875.     #----------------------------------------------------------------------
  876.     if @battler.dead_pop
  877.       name = (14+@set).to_s + (@dead_time / 20).to_s
  878.       @dead_time += 1
  879.       if @dead_time >= 39
  880.         @dead_time = 0
  881.         @battler.dead_one = true
  882.         @battler.dead_pop = false
  883.       end
  884.     end
  885.     #-----------------------------------------------------------------------
  886.     if @battler.dead? and @battler.dead_one
  887.       name = (14+@set).to_s + "1"
  888.     end
  889.     if @battler_name != name
  890.       hue = @battler.battler_hue
  891.       # 获取、设置位图
  892.       @battler_name = name
  893.       self.bitmap = RPG::Cache.battler(@battler.name, name, hue)
  894.       @width = bitmap.width
  895.       @height = bitmap.height
  896.       self.ox = @width / 2
  897.       self.oy = @height
  898.       self.opacity = 0 if @battler.hidden
  899.     end
  900.     #-----------------------------------------------------------------------
  901.     if @battler != nil and @battler.show_refresh
  902.       @show.bitmap.clear
  903.       @show.bitmap.font.color.set(0, 0, 0)
  904.       @show.bitmap.fill_rect(0, 0, 62, 6, Color.new(0, 0, 0))
  905.       @show.bitmap.fill_rect(0, 7, 62, 6, Color.new(0, 0, 0))
  906.       w = 60 * @battler.hp / @battler.maxhp
  907.       for i in 1..w
  908.         @show.bitmap.fill_rect(i, 1, 1, 4, Color.new(255, 0, (255-i*4)))
  909.       end
  910.       w = 60 * @battler.sp / @battler.maxsp
  911.       for i in 1..w
  912.         @show.bitmap.fill_rect(i, 8, 1, 4, Color.new(0, (255-i*4), 255))
  913.       end
  914.       @battler.show_refresh = false
  915.     end
  916.     @show.x = self.x-30
  917.     @show.y = self.y - @height - 20
  918.     @show.z = 490
  919.     if @battler_visible
  920.       @show.visible = @battler.dead_one ? false : true
  921.     else
  922.       @show.visible = @battler_visible
  923.     end
  924.     #-----------------------------------------------------------------------
  925.     # 动画 ID 与当前的情况有差异的情况下
  926.     if @battler.damage == nil and
  927.        @battler.state_animation_id != @state_animation_id
  928.       @state_animation_id = @battler.state_animation_id
  929.       loop_animation($data_animations[@state_animation_id])
  930.     end
  931.     # 明灭
  932.     if @battler.blink
  933.       blink_on
  934.     else
  935.       blink_off
  936.     end
  937.     # 不可见的情况下
  938.     unless @battler_visible
  939.       # 出现
  940.       unless @battler.hidden
  941.         appear
  942.         @battler_visible = true
  943.       end
  944.     end
  945.     # 可见的情况下
  946.     if @battler_visible
  947.       # 逃跑
  948.       if @battler.hidden
  949.         $game_system.se_play($data_system.escape_se)
  950.         escape
  951.         @battler_visible = false
  952.       end
  953.       # 白色闪烁
  954.       if @battler.white_flash
  955.         whiten
  956.         @battler.white_flash = false
  957.       end
  958.       # 动画
  959.       if @battler.animation_id != 0
  960.         animation = $data_animations[@battler.animation_id]
  961.         animation(animation, @battler.animation_hit)
  962.         @battler.animation_id = 0
  963.       end
  964.       # 伤害
  965.       if @battler.damage_pop
  966.         damage(@battler.damage, @battler.critical)
  967.         @battler.damage = nil
  968.         @battler.critical = false
  969.         @battler.damage_pop = false
  970.       end
  971.       if @battler.tip_pop and @battler.tip_message != ""
  972.         tip(@battler.tip_message, @battler.tip_type)
  973.         @battler.tip_message = ""
  974.         @battler.tip_pop = false
  975.       end
  976.       if @battler.sp_damage_pop
  977.         sp_damage(@battler.sp_damage)
  978.         @battler.sp_damage = nil
  979.         @battler.sp_damage_pop = false
  980.       end
  981.     end
  982.     unless @battler.moving?
  983.       # 设置活动块的坐标
  984.       self.x = @battler.screen_x
  985.       self.y = @battler.screen_y
  986.       self.z = self.y
  987.     end
  988.     self.z = self.y
  989.   end
  990. end
  991. #==============================================================================
  992. class Game_Battler
  993.   #--------------------------------------------------------------------------
  994.   def remove_state(state_id, force = false)
  995.     # 无法附加本状态的情况下
  996.     if state?(state_id)
  997.       # 被强制附加的状态、并不是强制解除的情况下
  998.       if @states_turn[state_id] == -1 and not force
  999.         # 过程结束
  1000.         return
  1001.       end
  1002.       # 现在的 HP 为 0 当作选项 [当作 HP 0 的状态]有效的场合
  1003.       if @hp == 0 and $data_states[state_id].zero_hp
  1004.         # 判断是否有另外的 [当作 HP 0 的状态]状态
  1005.         zero_hp = false
  1006.         for i in @states
  1007.           if i != state_id and $data_states[i].zero_hp
  1008.             zero_hp = true
  1009.           end
  1010.         end
  1011.         # 如果可以解除战斗不能、将 HP 更改为 1
  1012.         if zero_hp == false
  1013.           @hp = 1
  1014.           self.dead_one = false
  1015.         end
  1016.       end
  1017.       # 将状态 ID 从 @states 队列和 @states_turn hash 中删除
  1018.       @states.delete(state_id)
  1019.       @states_turn.delete(state_id)
  1020.     end
  1021.     # 检查 HP 及 SP 的最大值
  1022.     @hp = [@hp, self.maxhp].min
  1023.     @sp = [@sp, self.maxsp].min
  1024.   end
  1025. end
  1026. #==============================================================================
  1027. class Game_Actor < Game_Battler
  1028.   #--------------------------------------------------------------------------
  1029.   # ● # 调 X 坐标。
  1030.   #--------------------------------------------------------------------------
  1031.   def screen_x
  1032.     if self.index != nil
  1033.       case self.index
  1034.       when 0         
  1035.         return 480
  1036.       when 1
  1037.         return 500
  1038.       when 2
  1039.         return 520
  1040.       when 3
  1041.         return 540
  1042.       end
  1043.     else
  1044.       return 0
  1045.     end
  1046.   end
  1047.   #--------------------------------------------------------------------------
  1048.   # ● # 调 Y 坐标。
  1049.   #--------------------------------------------------------------------------
  1050.   def screen_y
  1051.     if self.index != nil
  1052.       case self.index
  1053.       when 0           
  1054.         return 200
  1055.       when 1
  1056.         return 240
  1057.       when 2
  1058.         return 280
  1059.       when 3
  1060.         return 320
  1061.       end
  1062.     else
  1063.       return 0
  1064.     end
  1065.   end
  1066.   #--------------------------------------------------------------------------
  1067.   # ● 取得战斗画面的 Z 坐标
  1068.   #--------------------------------------------------------------------------
  1069.   def screen_z
  1070.     if self.index != nil
  1071.       return screen_y
  1072.     else
  1073.       return 0
  1074.     end
  1075.   end
  1076. end
  1077. ###############################################################################
  1078. #==============================================================================




这是图片轮播式战斗,就是每一个动作都是一张单独的图片。这样的战斗系统,素材的活动空间很大,而且人与人之间也不会出现空白,十分实用。


这应该是原帖,不过我的这个脚本已经有其他朋友修改过了。
https://rpg.blue/forum.php?mod=viewthread&tid=323432

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

本版积分规则

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

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

GMT+8, 2024-5-5 02:41

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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