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

Project1

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

[原创发布] 发一个自己做的脚本试一下

[复制链接]

Lv1.梦旅人

梦石
0
星屑
50
在线时间
87 小时
注册时间
2011-5-18
帖子
37
跳转到指定楼层
1
发表于 2013-10-25 00:21:50 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式

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

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

x


战场上的相机,因为到处都找不到独立可用的,我自己做了一个。

RUBY 代码复制
  1. #==============================================================================
  2. #
  3. # ◇ ◇ 尚未完成的 Flan系统(芙兰朵露·斯卡雷特)by =Lucifer·Heroin= ◇ ◇
  4. #
  5. # ◇ ◇ 战场上的相机
  6. #==============================================================================
  7. class Scene_Battle
  8.  
  9.   # ● 定义实例变量,相当于一个临时容器,传递战斗指令的状态
  10.  
  11.   attr_reader   :spriteset
  12.   # 为了别处能够调用战场背景的缩放,位移
  13.   # 但不能写入,以免影响 Spriteset_Battle 里卷动操作。
  14.  
  15.   attr_reader   :flan_speed
  16.   # 镜头变化的速度(方便控制战斗节奏)固定住,其他任何地方只能读取他。
  17.  
  18.  
  19.   # 一个初始化函数。没有任何别的作用。仅在开战时被调用一次。
  20.   def flan_start
  21.  
  22.     @flan_speed = 15
  23.  
  24.   end
  25.  
  26. # flan_start 初始化各种实变量
  27. # flan_battle 连接战场,刷新画面
  28. # flan_jud 得到敌人,角色的信息
  29. # @field_id 当前角色,或者指向敌人的 ID
  30. # 0,1,2,3 是角色。6..13 是敌人,所以敌人index默认 +6
  31. # 17 角色使用全体技能。
  32.  
  33.  
  34. #====◆=============================================================
  35.   def main
  36.     # 初始化战斗用的各种暂时数据
  37.     $game_temp.in_battle = true
  38.     $game_temp.battle_turn = 0
  39.     $game_temp.battle_event_flags.clear
  40.     $game_temp.battle_abort = false
  41.     $game_temp.battle_main_phase = false
  42.     $game_temp.battleback_name = $game_map.battleback_name
  43.     $game_temp.forcing_battler = nil
  44.     # 初始化战斗用事件解释器
  45.     $game_system.battle_interpreter.setup(nil, 0)
  46.     # 准备队伍
  47.     @troop_id = $game_temp.battle_troop_id
  48.     $game_troop.setup(@troop_id)
  49.  
  50.     #====◆=============================================================
  51.     flan_start
  52.     # 关键接入口,初始化各种实变量
  53.     #====  =============================================================
  54.  
  55.     # 生成角色命令窗口
  56.     s1 = $data_system.words.attack
  57.     s2 = $data_system.words.skill
  58.     s3 = $data_system.words.guard
  59.     s4 = $data_system.words.item
  60.     @actor_command_window = Window_Command.new(160, [s1, s2, s3, s4])
  61.     @actor_command_window.y = 160
  62.     @actor_command_window.back_opacity = 160
  63.     @actor_command_window.active = false
  64.     @actor_command_window.visible = false
  65.     # 生成其它窗口
  66.     @party_command_window = Window_PartyCommand.new
  67.     @help_window = Window_Help.new
  68.     @help_window.back_opacity = 160
  69.     @help_window.visible = false
  70.     @status_window = Window_BattleStatus.new
  71.     @message_window = Window_Message.new
  72.     # 生成活动块
  73.     @spriteset = Spriteset_Battle.new
  74.     # 初始化等待计数
  75.     @wait_count = 0
  76.     # 执行过渡
  77.     if $data_system.battle_transition == ""
  78.       Graphics.transition(20)
  79.     else
  80.       Graphics.transition(40, "Graphics/Transitions/" +
  81.         $data_system.battle_transition)
  82.     end
  83.     # 开始自由战斗回合
  84.     start_phase1
  85.     # 主循环
  86.     loop do
  87.       # 刷新游戏画面
  88.       Graphics.update
  89.       # 刷新输入信息
  90.       Input.update
  91.       # 刷新画面
  92.       update
  93.       # 如果画面切换的话就中断循环
  94.       if $scene != self
  95.         break
  96.       end
  97.     end
  98.     # 刷新地图
  99.     $game_map.refresh
  100.     # 准备过渡
  101.     Graphics.freeze
  102.     # 释放窗口
  103.     @actor_command_window.dispose
  104.     @party_command_window.dispose
  105.     @help_window.dispose
  106.     @status_window.dispose
  107.     @message_window.dispose
  108.     if @skill_window != nil
  109.       @skill_window.dispose
  110.     end
  111.     if @item_window != nil
  112.       @item_window.dispose
  113.     end
  114.     if @result_window != nil
  115.       @result_window.dispose
  116.     end
  117.     # 释放活动块
  118.     @spriteset.dispose
  119.     # 标题画面切换中的情况
  120.     if $scene.is_a?(Scene_Title)
  121.       # 淡入淡出画面
  122.       Graphics.transition
  123.       Graphics.freeze
  124.     end
  125.     # 战斗测试或者游戏结束以外的画面切换中的情况
  126.     if $BTEST and not $scene.is_a?(Scene_Gameover)
  127.       $scene = nil
  128.     end
  129.   end
  130. #====◆=============================================================
  131.   def update
  132.     # 执行战斗事件中的情况下
  133.     if $game_system.battle_interpreter.running?
  134.       # 刷新解释器
  135.       $game_system.battle_interpreter.update
  136.       # 强制行动的战斗者不存在的情况下
  137.       if $game_temp.forcing_battler == nil
  138.         # 执行战斗事件结束的情况下
  139.         unless $game_system.battle_interpreter.running?
  140.           # 继续战斗的情况下、再执行战斗事件的设置
  141.           unless judge
  142.             setup_battle_event
  143.           end
  144.         end
  145.         # 如果不是结束战斗回合的情况下
  146.         if @phase != 5
  147.           # 刷新状态窗口
  148.           @status_window.refresh
  149.         end
  150.       end
  151.     end
  152.     # 系统 (计时器)、刷新画面
  153.     $game_system.update
  154.     $game_screen.update
  155.     # 计时器为 0 的情况下
  156.     if $game_system.timer_working and $game_system.timer == 0
  157.       # 中断战斗
  158.       $game_temp.battle_abort = true
  159.     end
  160.     # 刷新窗口
  161.     @help_window.update
  162.     @party_command_window.update
  163.     @actor_command_window.update
  164.     @status_window.update
  165.     @message_window.update
  166.     # 刷新活动块
  167.  
  168.     #====◆=============================================================
  169.     # 这里必须有,用来刷新 flan_battle,实际改变背景
  170.     @spriteset.flan_battle
  171.     @spriteset.update
  172.     #====  =============================================================
  173.  
  174.     # 处理过渡中的情况下
  175.     if $game_temp.transition_processing
  176.       # 清除处理过渡中标志
  177.       $game_temp.transition_processing = false
  178.       # 执行过渡
  179.       if $game_temp.transition_name == ""
  180.         Graphics.transition(20)
  181.       else
  182.         Graphics.transition(40, "Graphics/Transitions/" +
  183.           $game_temp.transition_name)
  184.       end
  185.     end
  186.     # 显示信息窗口中的情况下
  187.     if $game_temp.message_window_showing
  188.       return
  189.     end
  190.     # 显示效果中的情况下
  191.     if @spriteset.effect?
  192.       return
  193.     end
  194.     # 游戏结束的情况下
  195.     if $game_temp.gameover
  196.       # 切换到游戏结束画面
  197.       $scene = Scene_Gameover.new
  198.       return
  199.     end
  200.     # 返回标题画面的情况下
  201.     if $game_temp.to_title
  202.       # 切换到标题画面
  203.       $scene = Scene_Title.new
  204.       return
  205.     end
  206.     # 中断战斗的情况下
  207.     if $game_temp.battle_abort
  208.       # 还原为战斗前的 BGM
  209.       $game_system.bgm_play($game_temp.map_bgm)
  210.       # 战斗结束
  211.       battle_end(1)
  212.       return
  213.     end
  214.     # 等待中的情况下
  215.     if @wait_count > 0
  216.       # 减少等待计数
  217.       @wait_count -= 1
  218.       return
  219.     end
  220.     # 强制行动的角色存在、
  221.     # 并且战斗事件正在执行的情况下
  222.     if $game_temp.forcing_battler == nil and
  223.        $game_system.battle_interpreter.running?
  224.       return
  225.     end
  226.     # 回合分支
  227.     case @phase
  228.     when 1  # 自由战斗回合
  229.       update_phase1
  230.     when 2  # 同伴命令回合
  231.       update_phase2
  232.     when 3  # 角色命令回合
  233.       update_phase3
  234.     when 4  # 主回合
  235.       update_phase4
  236.     when 5  # 战斗结束回合
  237.       update_phase5
  238.     end
  239.   end
  240. #====◆=============================================================
  241.   def phase3_setup_command_window
  242.     # 同伴指令窗口无效化
  243.     @party_command_window.active = false
  244.     @party_command_window.visible = false
  245.     # 角色指令窗口无效化
  246.     @actor_command_window.active = true
  247.     @actor_command_window.visible = true
  248.     # 设置角色指令窗口的位置
  249.     @actor_command_window.x = @actor_index * 160
  250.     # 设置索引为 0
  251.     @actor_command_window.index = 0
  252.  
  253.     #====◆=============================================================
  254.     a = @actor_index
  255.     $scene.spriteset.flan_jud(a)
  256.     # 包含了转向下一个,前一个
  257.     #====  =============================================================
  258.  
  259.   end
  260. #====◆=============================================================
  261.   def make_basic_action_result
  262.     # 攻击的情况下
  263.     if @active_battler.current_action.basic == 0
  264.       # 设置攻击 ID
  265.       @animation1_id = @active_battler.animation1_id
  266.       @animation2_id = @active_battler.animation2_id
  267.       # 行动方的战斗者是敌人的情况下
  268.       if @active_battler.is_a?(Game_Enemy)
  269.  
  270.         #====  =============================================================
  271.         # 完全OK,敌人普通攻击,行动方
  272.         #====  =============================================================
  273.  
  274.         if @active_battler.restriction == 3
  275.           target = $game_troop.random_target_enemy
  276.         elsif @active_battler.restriction == 2
  277.           target = $game_party.random_target_actor
  278.         else
  279.           index = @active_battler.current_action.target_index
  280.           target = $game_party.smooth_target_actor(index)
  281.         end
  282.       end
  283.       # 行动方的战斗者是角色的情况下
  284.       if @active_battler.is_a?(Game_Actor)
  285.         if @active_battler.restriction == 3
  286.           target = $game_party.random_target_actor
  287.         elsif @active_battler.restriction == 2
  288.  
  289.           #这个时候的 index 是 -1
  290.           target = $game_troop.random_target_enemy
  291.           #====◆ 1 ==========================================================
  292.  
  293.           a = target.index + 6
  294.           $scene.spriteset.flan_jud(a)
  295.           # 角色普通攻击,对随机,的敌人 ID
  296.           #====  =============================================================
  297.         else
  298.           index = @active_battler.current_action.target_index
  299.           target = $game_troop.smooth_target_enemy(index)
  300.  
  301.           #====◆ 2 ==========================================================
  302.           a = index + 6
  303.           $scene.spriteset.flan_jud(a)
  304.           # 角色普通攻击,对选择,的敌人 ID
  305.           #====  =============================================================
  306.  
  307.         end
  308.       end
  309.       # 设置对像方的战斗者序列
  310.       @target_battlers = [target]
  311.       # 应用通常攻击效果
  312.       for target in @target_battlers
  313.         target.attack_effect(@active_battler)
  314.       end
  315.       return
  316.     end
  317.  
  318.     # 防御的情况下
  319.     if @active_battler.current_action.basic == 1
  320.  
  321.       #====◆ 3 ==========================================================
  322.       # 区分敌人和角色,角色 ID
  323.       if @active_battler.is_a?(Game_Actor)
  324.  
  325.         # 行动方的 ID,角色 0,1,2,3 敌人 0,1,2...
  326.         a = @active_battler.index
  327.         $scene.spriteset.flan_jud(a)
  328.       end
  329.       #====  =============================================================
  330.  
  331.       # 帮助窗口显示"防御"
  332.       @help_window.set_text($data_system.words.guard, 1)
  333.       return
  334.     end
  335.     # 逃跑的情况下
  336.     if @active_battler.is_a?(Game_Enemy) and
  337.        @active_battler.current_action.basic == 2
  338.  
  339.        #====  =============================================================
  340.        # 敌人,完全OK
  341.        #====  =============================================================
  342.  
  343.       #  帮助窗口显示"逃跑"
  344.       @help_window.set_text("逃跑", 1)
  345.       # 逃跑
  346.       @active_battler.escape
  347.       return
  348.     end
  349.     # 什么也不做的情况下
  350.     if @active_battler.current_action.basic == 3
  351.  
  352.       #====  =============================================================
  353.       # 区分敌人和角色,完全OK
  354.       # 跳过速度过快,CP战的情况下,就不至于那么快
  355.       #====  =============================================================
  356.  
  357.       # 清除强制行动对像的战斗者
  358.       $game_temp.forcing_battler = nil
  359.       # 移至步骤 1
  360.       @phase4_step = 1
  361.       return
  362.     end
  363.   end
  364.  
  365.   #--------------------------------------------------------------------------
  366.   # ● 设置物品或特技对像方的战斗者
  367.   #     scope : 特技或者是物品的范围
  368.   #--------------------------------------------------------------------------
  369.   def set_target_battlers(scope)
  370.     # 行动方的战斗者是敌人的情况下
  371.     if @active_battler.is_a?(Game_Enemy)
  372.       # 效果范围分支
  373.       case scope
  374.       when 1  # 敌单体
  375.         index = @active_battler.current_action.target_index
  376.         @target_battlers.push($game_party.smooth_target_actor(index))
  377.       when 2  # 敌全体
  378.  
  379.         #====◆ 4 ==========================================================
  380.  
  381.         a = @active_battler.index + 6
  382.         $scene.spriteset.flan_jud(a)
  383.         # 使用技能对角色全体,的敌人 ID
  384.         #====  =============================================================
  385.  
  386.         for actor in $game_party.actors
  387.           if actor.exist?
  388.             @target_battlers.push(actor)
  389.           end
  390.         end
  391.       when 3  # 我方单体
  392.         index = @active_battler.current_action.target_index
  393.         @target_battlers.push($game_troop.smooth_target_enemy(index))
  394.       when 4  # 我方全体
  395.         for enemy in $game_troop.enemies
  396.           if enemy.exist?
  397.             @target_battlers.push(enemy)
  398.           end
  399.         end
  400.       when 5  # 我方单体 (HP 0)
  401.         index = @active_battler.current_action.target_index
  402.         enemy = $game_troop.enemies[index]
  403.         if enemy != nil and enemy.hp0?
  404.           @target_battlers.push(enemy)
  405.         end
  406.       when 6  # 我方全体 (HP 0)
  407.         for enemy in $game_troop.enemies
  408.           if enemy != nil and enemy.hp0?
  409.             @target_battlers.push(enemy)
  410.           end
  411.         end
  412.       when 7  # 使用者
  413.         @target_battlers.push(@active_battler)
  414.       end
  415.     end
  416.  
  417.     # 行动方的战斗者是角色的情况下
  418.     if @active_battler.is_a?(Game_Actor)
  419.       # 效果范围分支
  420.       case scope
  421.       when 1  # 敌单体
  422.         index = @active_battler.current_action.target_index
  423.         @target_battlers.push($game_troop.smooth_target_enemy(index))
  424.  
  425.         #====◆ 5 ==========================================================
  426.         a = index + 6
  427.         $scene.spriteset.flan_jud(a)
  428.         # 角色使用技能或物品,对敌方单体,目标敌人 ID
  429.         #====  =============================================================
  430.  
  431.       when 2  # 敌全体
  432.  
  433.         #====◆ 6 ==========================================================
  434.         $scene.spriteset.flan_jud(17)
  435.         # 完全OK,角色使用技能或物品对敌全
  436.         #====  =============================================================
  437.  
  438.         for enemy in $game_troop.enemies
  439.           if enemy.exist?
  440.             @target_battlers.push(enemy)
  441.           end
  442.         end
  443.       when 3  # 我方单体
  444.         index = @active_battler.current_action.target_index
  445.         @target_battlers.push($game_party.smooth_target_actor(index))
  446.       when 4  # 我方全体
  447.         for actor in $game_party.actors
  448.           if actor.exist?
  449.             @target_battlers.push(actor)
  450.           end
  451.         end
  452.       when 5  # 我方单体 (HP 0)
  453.         index = @active_battler.current_action.target_index
  454.         actor = $game_party.actors[index]
  455.         if actor != nil and actor.hp0?
  456.           @target_battlers.push(actor)
  457.         end
  458.       when 6  # 我方全体 (HP 0)
  459.         for actor in $game_party.actors
  460.           if actor != nil and actor.hp0?
  461.             @target_battlers.push(actor)
  462.           end
  463.         end
  464.       when 7  # 使用者
  465.         @target_battlers.push(@active_battler)
  466.       end
  467.     end
  468.   end
  469. #====◆=============================================================
  470. end
  471.  
  472.  
  473. #==============================================================================
  474.  
  475. #==============================================================================
  476. class Arrow_Enemy < Arrow_Base
  477.   def update
  478.     super
  479.     $game_troop.enemies.size.times do
  480.       break if self.enemy.exist?
  481.       [url=home.php?mod=space&uid=370741]@Index[/url] += 1
  482.       @index %= $game_troop.enemies.size
  483.     end
  484.     if Input.repeat?(Input::RIGHT)
  485.       $game_system.se_play($data_system.cursor_se)
  486.       $game_troop.enemies.size.times do
  487.         @index += 1
  488.         @index %= $game_troop.enemies.size
  489.         break if self.enemy.exist?
  490.       end
  491.  
  492.       #====◆=============================================================
  493.       a = @index + 6
  494.       $scene.spriteset.flan_jud(a)
  495.       # 这里任何操作,实际就是发出了信号
  496.       # 在这里可以知道现在选中的敌人,将信息传给战斗背景
  497.       #====  =============================================================
  498.     end
  499.     if Input.repeat?(Input::LEFT)
  500.       $game_system.se_play($data_system.cursor_se)
  501.       $game_troop.enemies.size.times do
  502.         @index += $game_troop.enemies.size - 1
  503.         @index %= $game_troop.enemies.size
  504.         break if self.enemy.exist?
  505.       end
  506.  
  507.       #====◆=============================================================
  508.       a = @index + 6
  509.       $scene.spriteset.flan_jud(a)
  510.       #====  =============================================================
  511.     end
  512.  
  513.     if self.enemy != nil
  514.       self.x = self.enemy.screen_x
  515.       self.y = self.enemy.screen_y
  516.     end
  517.   end
  518. end
  519. #==============================================================================
  520.  
  521.  
  522. #==============================================================================
  523. class Win_Test < Window_Base
  524.  
  525.  
  526.   attr_accessor :a_x
  527.   attr_accessor :a_y
  528.   attr_accessor :a_z
  529.  
  530.   attr_accessor :b_x
  531.   attr_accessor :b_y
  532.   attr_accessor :b_z
  533.  
  534.   def initialize  # 初始化窗口
  535.     super(300, 50, 300, 200)
  536.     self.contents = Bitmap.new(width - 32, height - 32)
  537.  
  538.     @a_x = 0
  539.     @a_y = 0
  540.     @a_z = 0
  541.  
  542.     @b_x = 0
  543.     @b_y = 0
  544.     @b_z = 0
  545.  
  546.     refresh
  547.   end
  548.  
  549.   def refresh  # 刷新显示
  550.     self.contents.clear
  551.  
  552.     text1="t_x "+@a_x.to_i.to_s+","+@a_y.to_i.to_s+","+(@a_z*100).to_i.to_s
  553.     text2="feild "+@b_x.to_i.to_s+","+@b_y.to_i.to_s+","+(@b_z*100).to_i.to_s
  554.  
  555.     self.contents.draw_text(0, 0, 300, 32, text1)
  556.     self.contents.draw_text(0, 32, 300, 32, text2)
  557.  
  558.     #-------------------------------------
  559.   end
  560. end
  561. #==============================================================================
  562.  
  563.  
  564. #==============================================================================
  565. class Spriteset_Battle
  566.  
  567.   attr_reader   :field_x
  568.   attr_reader   :field_y
  569.   attr_reader   :field_zoom
  570.   # 别处只可读取,不能写入影响背景。
  571.   # 当背景缩放时,告诉 Game_Enemy 同步要缩放多少
  572.   # 真正的当前背景缩放大小
  573.  
  574.   def initialize
  575.     @viewport1 = Viewport.new(0, 0, 640, 320)
  576.     @viewport2 = Viewport.new(0, 0, 640, 480)
  577.     @viewport3 = Viewport.new(0, 0, 640, 480)
  578.     @viewport4 = Viewport.new(0, 0, 640, 480)
  579.     @viewport2.z = 101
  580.     @viewport3.z = 200
  581.     @viewport4.z = 5000
  582.  
  583.     #====◆=============================================================
  584.     @field_x = 0
  585.     @field_y = 0
  586.     @field_zoom = 1.0
  587.  
  588.     # 以下仅在战场内部使用。win_tes 主动复制了这些数据
  589.     @g_x = 320 # 为了刚开战居中放大一次
  590.     @g_y = 80
  591.     @g_zm = 1.0 # gap_zoom,在卷动前临时存入当前缩放值
  592.  
  593.     @t_x = 320
  594.     @t_y = 80
  595.     @t_zm = 1.3 # target_zoom,在卷动前临时存入目标缩放值
  596.  
  597.     @field_id = 17
  598.     @flan_energy = $scene.flan_speed
  599.  
  600.     #====  =============================================================
  601.     @win_tes = Win_Test.new ##
  602.     @win_tes.opacity = 64
  603.  
  604.  
  605.     @battleback_sprite = Sprite.new(@viewport1)
  606.     @enemy_sprites = []
  607.     for enemy in $game_troop.enemies.reverse
  608.       @enemy_sprites.push(Sprite_Battler.new(@viewport1, enemy))
  609.     end
  610.     @actor_sprites = []
  611.     @actor_sprites.push(Sprite_Battler.new(@viewport2))
  612.     @actor_sprites.push(Sprite_Battler.new(@viewport2))
  613.     @actor_sprites.push(Sprite_Battler.new(@viewport2))
  614.     @actor_sprites.push(Sprite_Battler.new(@viewport2))
  615.     @weather = RPG::Weather.new(@viewport1)
  616.     @picture_sprites = []
  617.     for i in 51..100
  618.       @picture_sprites.push(Sprite_Picture.new(@viewport3,
  619.         $game_screen.pictures[i]))
  620.     end
  621.     @timer_sprite = Sprite_Timer.new
  622.     update
  623.   end
  624.   def dispose
  625.     if @battleback_sprite.bitmap != nil
  626.       @battleback_sprite.bitmap.dispose
  627.     end
  628.     @battleback_sprite.dispose
  629.     for sprite in @enemy_sprites + @actor_sprites
  630.       sprite.dispose
  631.     end
  632.     @weather.dispose
  633.     for sprite in @picture_sprites
  634.       sprite.dispose
  635.     end
  636.     @timer_sprite.dispose
  637.     @win_tes.dispose ##
  638.     #====  =============================================================
  639.  
  640.     @viewport1.dispose
  641.     @viewport2.dispose
  642.     @viewport3.dispose
  643.     @viewport4.dispose
  644.   end
  645.   def update
  646.     @actor_sprites[0].battler = $game_party.actors[0]
  647.     @actor_sprites[1].battler = $game_party.actors[1]
  648.     @actor_sprites[2].battler = $game_party.actors[2]
  649.     @actor_sprites[3].battler = $game_party.actors[3]
  650.     if @battleback_name != $game_temp.battleback_name
  651.       flan_battle
  652.       # ◇ ◆ ◇ ◇ ◇ ◇ ◇ ◇ ◇ ◇ ◇
  653.     end
  654.  
  655.     flan_text
  656.     flan_scroll
  657.  
  658.  
  659.  
  660.     # 修正,告诉 Game_Enemy 当前背景画面大小
  661.     # ◇ ↓ ◇ 敌人已经完全和背景黏住 ◇ ◆ ◇ 重点
  662. #=begin
  663.     for enemy in $game_troop.enemies
  664.       enemy.enemy_x = @field_x
  665.       enemy.enemy_y = @field_y
  666.       enemy.enemy_zoom = @field_zoom
  667.     end
  668. #=end
  669.  
  670.     @win_tes.a_x = @t_x
  671.     @win_tes.a_y = @t_y
  672.     @win_tes.a_z = @t_zm
  673.     @win_tes.b_x = @field_x
  674.     @win_tes.b_y = @field_y
  675.     @win_tes.b_z = @field_zoom
  676.  
  677.     # 将选中的目标,的屏幕 x,y 传给 win_tes
  678.     # 这个坐标是现在画面上怪的实际坐标,不是数据库里的
  679.     #====◆=============================================================
  680.     @win_tes.refresh ##
  681.  
  682.  
  683.     for sprite in @enemy_sprites + @actor_sprites
  684.       sprite.update
  685.     end
  686.     @weather.type = $game_screen.weather_type
  687.     @weather.max = $game_screen.weather_max
  688.     @weather.update
  689.     for sprite in @picture_sprites
  690.       sprite.update
  691.     end
  692.     @timer_sprite.update
  693.     @viewport1.tone = $game_screen.tone
  694.     @viewport1.ox = $game_screen.shake
  695.     @viewport4.color = $game_screen.flash_color
  696.     @viewport1.update
  697.     @viewport2.update
  698.     @viewport4.update
  699.   end
  700.   # #====  =============================================================
  701.  
  702.   def flan_battle # 因为这里也在刷新,所以不能有动态的东西
  703.     @battleback_name = $game_temp.battleback_name
  704.     if @battleback_sprite.bitmap != nil
  705.       @battleback_sprite.bitmap.dispose
  706.     end
  707.  
  708.     @battleback_sprite.bitmap = RPG::Cache.battleback(@battleback_name)
  709.     @battleback_sprite.src_rect.set(0, 0, 640, 320)
  710.  
  711.     @battleback_sprite.zoom_x = @field_zoom
  712.     @battleback_sprite.zoom_y = @field_zoom
  713.  
  714.     # ◇ ↓ ◇ 敌人已经完全和背景黏住 ◇ ◆ ◇ 重点
  715.     @battleback_sprite.ox = @field_x
  716.     @battleback_sprite.x = @field_x
  717.     @battleback_sprite.oy = @field_y
  718.     @battleback_sprite.y = @field_y
  719.  
  720.   end
  721.  
  722.   #------------------ #------------------ #------------------
  723.   def flan_text
  724.  
  725.     text1 = "成员 " + @field_id.to_s
  726.     text2 = "En " + @flan_energy.to_s
  727.  
  728.     @battleback_sprite.bitmap.font.size = 14
  729.     @battleback_sprite.bitmap.draw_text(250, 100, 120, 32, text1)
  730.     @battleback_sprite.bitmap.draw_text(250, 115, 120, 32, text2)
  731.  
  732.   end
  733.  
  734.   #------------------ #------------------ #------------------
  735.   def flan_jud(a)  # 仅在外部被启动
  736.  
  737.     @g_x =@field_x # 暂存现在的场景中心点
  738.     @g_y =@field_y
  739.     @g_zm =@field_zoom
  740.  
  741.     @field_id = a # 外部操作得到当前角色或敌人信息
  742.     # 根据 ID 来判断,并得出目标缩放的 中心点,大小
  743.  
  744.     case @field_id
  745.     when 17 # 全屏居中
  746.       @t_x = 320
  747.       @t_y = 160
  748.       @t_zm = 1.0
  749.  
  750.     when 0..3 # 角色行动
  751.       @t_x = 240 + 80 * a
  752.       @t_y = 80
  753.       @t_zm = 1.3
  754.  
  755.     when 6..13 # 聚焦敌人
  756.  
  757.       emx = $game_troop.enemies[a-6].or_x
  758.       emy = $game_troop.enemies[a-6].or_y
  759.       emz = $game_troop.enemies[a-6].or_z
  760.       @t_zm = (1 /emz)/2 + 1
  761.       @t_x = emx
  762.       @t_y = emy - 180 * emz
  763.  
  764.       # 对于缩放后的修,因为怪的位置太高,导致只看到脚
  765.       # 并且越是远的敌人修正越少。
  766.       # 判断是否会漏黑,重新设定 @t_
  767.       # if (320 - @t_x)
  768.  
  769.     end
  770.  
  771.     @flan_energy = $scene.flan_speed
  772.   end
  773.  
  774.   #------------------ #------------------ #------------------
  775.   def flan_scroll
  776.     # 卷动操作,也就是在有能量时,循环修正当前画面大小,t_,g_ 都不会自己改变
  777.  
  778.     if @flan_energy > 0
  779.  
  780.       e = $scene.flan_speed - @flan_energy + 1
  781.       #------------------
  782.       x = @t_x - @g_x
  783.       @field_x = @g_x + x * e**2 / $scene.flan_speed**2
  784.  
  785.       y = @t_y - @g_y
  786.       @field_y = @g_y + y * e**2 / $scene.flan_speed**2
  787.  
  788.       z = @t_zm - @g_zm  # 从原先 →到目标
  789.       @field_zoom = @g_zm + z * e**2 / $scene.flan_speed**2
  790.       #------------------
  791.  
  792.       @flan_energy -= 1
  793.     end
  794.  
  795.   end
  796.   #---------------------------------------------------
  797. end
  798. #==============================================================================
  799.  
  800.  
  801. #==============================================================================
  802. class Sprite_Battler < RPG::Sprite
  803.  
  804.   def update
  805.     super
  806.     if @battler == nil
  807.       self.bitmap = nil
  808.       loop_animation(nil)
  809.       return
  810.     end
  811.     if @battler.battler_name != @battler_name or
  812.        @battler.battler_hue != @battler_hue
  813.       @battler_name = @battler.battler_name
  814.       @battler_hue = @battler.battler_hue
  815.       self.bitmap = RPG::Cache.battler(@battler_name, @battler_hue)
  816.       @width = bitmap.width
  817.       @height = bitmap.height
  818.       self.ox = @width / 2
  819.       self.oy = @height
  820.       if @battler.dead? or @battler.hidden
  821.         self.opacity = 0
  822.       end
  823.     end
  824.     if @battler.damage == nil and
  825.        @battler.state_animation_id != @state_animation_id
  826.       @state_animation_id = @battler.state_animation_id
  827.       loop_animation($data_animations[@state_animation_id])
  828.     end
  829.     if @battler.is_a?(Game_Actor) and @battler_visible
  830.       if $game_temp.battle_main_phase
  831.         self.opacity += 3 if self.opacity < 255
  832.       else
  833.         self.opacity -= 3 if self.opacity > 207
  834.       end
  835.     end
  836.     if @battler.blink
  837.       blink_on
  838.     else
  839.       blink_off
  840.     end
  841.     unless @battler_visible
  842.       if not @battler.hidden and not @battler.dead? and
  843.          (@battler.damage == nil or @battler.damage_pop)
  844.         appear
  845.         @battler_visible = true
  846.       end
  847.     end
  848.     if @battler_visible
  849.       if @battler.hidden
  850.         $game_system.se_play($data_system.escape_se)
  851.         escape
  852.         @battler_visible = false
  853.       end
  854.       if @battler.white_flash
  855.         whiten
  856.         @battler.white_flash = false
  857.       end
  858.       if @battler.animation_id != 0
  859.         animation = $data_animations[@battler.animation_id]
  860.         animation(animation, @battler.animation_hit)
  861.         @battler.animation_id = 0
  862.       end
  863.       if @battler.damage_pop
  864.         damage(@battler.damage, @battler.critical)
  865.         @battler.damage = nil
  866.         @battler.critical = false
  867.         @battler.damage_pop = false
  868.       end
  869.       if @battler.damage == nil and @battler.dead?
  870.         if @battler.is_a?(Game_Enemy)
  871.           $game_system.se_play($data_system.enemy_collapse_se)
  872.         else
  873.           $game_system.se_play($data_system.actor_collapse_se)
  874.         end
  875.         collapse
  876.         @battler_visible = false
  877.       end
  878.     end
  879.     self.x = @battler.screen_x
  880.     self.y = @battler.screen_y
  881.     self.z = @battler.screen_z
  882.     #---------------------------------------------------
  883.     # 如果是敌人的话,读取敌人函数(传递过来的缩放值)并改变精灵大小
  884.  
  885.     if @battler.is_a?(Game_Enemy)
  886.       self.zoom_x = @battler.screen_zoom
  887.       self.zoom_y = @battler.screen_zoom
  888.  
  889.     end
  890.     # ◇ ◆ ◇ ◇ ◇ ◇ ◇ ◇ ◇ ◇ ◇
  891.  
  892.   end
  893. end
  894. #==============================================================================
  895.  
  896.  
  897. #==============================================================================
  898. class Game_Enemy < Game_Battler
  899.  
  900.   attr_accessor :enemy_x
  901.   attr_accessor :enemy_y
  902.   attr_accessor :enemy_zoom
  903.   # 可读可写被,背景缩放改变时,写入新值。
  904.   # Sprite_Battler 里需要时,读取这个值,改变画面上敌人缩放,位置
  905.  
  906.   #---------------------------------------------------
  907.   def initialize(troop_id, member_index)
  908.     super()
  909.     @troop_id = troop_id
  910.     @member_index = member_index
  911.     troop = $data_troops[@troop_id]
  912.     @enemy_id = troop.members[@member_index].enemy_id
  913.     enemy = $data_enemies[@enemy_id]
  914.     @battler_name = enemy.battler_name
  915.     @battler_hue = enemy.battler_hue
  916.     @hp = maxhp
  917.     @sp = maxsp
  918.  
  919.     #---------------------------------------------------
  920.     @size = troop.members.size
  921.     @enemy_x = 0
  922.     @enemy_y = 0
  923.     @enemy_zoom = 1.0
  924.  
  925.     @hidden = troop.members[@member_index].hidden
  926.     @immortal = troop.members[@member_index].immortal
  927.   end
  928.   #---------------------------------------------------
  929.   # 设计,重新摆放阵型,罗列敌人队伍从 1只怪,到 8只怪
  930.   # 缩放产生透视,最小 0.25,最大 1.0,中等 0.5。
  931.   def screen_x
  932.     case @size
  933.     # - - - - - - - - #
  934.     when 1
  935.       return 320
  936.     # - - - - - - - - #
  937.     when 2
  938.       case @member_index
  939.       when 0
  940.         return 200
  941.       when 1
  942.         return 440
  943.       end
  944.     # - - - - - - - - #
  945.     when 3
  946.       case @member_index
  947.       when 0
  948.         return 200
  949.       when 1
  950.         return 320
  951.       when 2
  952.         return 440
  953.       end
  954.     # - - - - - - - - #
  955.     when 5
  956.       case @member_index
  957.       when 0
  958.         return 160
  959.       when 1
  960.         return 240
  961.       when 2
  962.         return 320
  963.       when 3
  964.         return 400
  965.       when 4
  966.         return 480
  967.       end
  968.  
  969.  
  970.     else  # 防止出现没设计过的
  971.       return $data_troops[@troop_id].members[@member_index].x
  972.     end
  973.   end
  974.   #---------------------------------------------------
  975.  
  976.  
  977.   def screen_y
  978.     case @size
  979.     # - - - - - - - - #
  980.     when 1,2
  981.       return 240
  982.     # - - - - - - - - #
  983.     when 3
  984.       case @member_index
  985.       when 0
  986.         return 240
  987.       when 1
  988.         return 200
  989.       when 2
  990.         return 240
  991.       end
  992.     # - - - - - - - - #
  993.     when 5
  994.       case @member_index
  995.       when 0
  996.         return 240
  997.       when 1
  998.         return 160
  999.       when 2
  1000.         return 200
  1001.       when 3
  1002.         return 160
  1003.       when 4
  1004.         return 240
  1005.       end
  1006.  
  1007.  
  1008.  
  1009.     else
  1010.       return $data_troops[@troop_id].members[@member_index].y
  1011.     end
  1012.   end
  1013.   #---------------------------------------------------
  1014.  
  1015.  
  1016.   def screen_zoom
  1017.     case @size
  1018.     # - - - - - - - - #
  1019.     when 1,2
  1020.       return 0.75
  1021.     when 3
  1022.       case @member_index
  1023.       when 0
  1024.         return 0.75
  1025.       when 1
  1026.         return 0.5
  1027.       when 2
  1028.         return 0.75
  1029.       end
  1030.     # - - - - - - - - #
  1031.     when 5
  1032.       case @member_index
  1033.       when 0
  1034.         return 0.75
  1035.       when 1
  1036.         return 0.25
  1037.       when 2
  1038.         return 0.5
  1039.       when 3
  1040.         return 0.25
  1041.       when 4
  1042.         return 0.75
  1043.       end
  1044.  
  1045.  
  1046.     else # 没设计的怪都是“最大”
  1047.       return 0.75
  1048.     end
  1049.   end
  1050.  
  1051.  
  1052.  
  1053.   #---------------------------------------------------
  1054.   alias :or_x :screen_x # 给原始敌人的屏幕坐标起别名
  1055.   alias :or_y :screen_y # 从此,or_x 才是数据库里的,不会被修改
  1056.   alias :or_z :screen_zoom
  1057.  
  1058.   # 重新定义,经过缩放后怪物在屏幕上的位置,给 Sprite_Battler 调用
  1059.   def screen_x
  1060.     return @enemy_x - (@enemy_x - or_x) * @enemy_zoom
  1061.   end
  1062.  
  1063.   def screen_y
  1064.     return @enemy_y - (@enemy_y - or_y) * @enemy_zoom
  1065.   end
  1066.  
  1067.   def screen_zoom
  1068.     return @enemy_zoom * or_z
  1069.   end
  1070.  
  1071.   #---------------------------------------------------
  1072. end

评分

参与人数 1星屑 +400 收起 理由
怪蜀黍 + 400 奖励条例!

查看全部评分

踏上寻找灵魂归宿之旅。

Lv1.梦旅人

梦石
0
星屑
50
在线时间
87 小时
注册时间
2011-5-18
帖子
37
2
 楼主| 发表于 2013-10-25 09:52:14 | 只看该作者
更改一个地方
◆战场相机◆by =Luciferf·Heroin=.rar (235.83 KB, 下载次数: 48)

RUBY 代码复制
  1. # 设计,重新摆放阵型,罗列敌人队伍从 1只怪,到 8只怪
  2.   # 缩放产生透视,最小 0.25,最大 1.0,中等 0.5。
  3.   # 按照 F9 里怪物屏幕 Y,越高的自动摆在更远的位置。分3档
  4.  
  5.   def screen_y
  6.  
  7.     a = $data_troops[@troop_id].members[@member_index].y
  8.     case a
  9.     when 0..320/3
  10.       return 100
  11.  
  12.     when 320/3..320*2/3
  13.       return 140
  14.  
  15.     when 320*2/3..320
  16.       return 220
  17.  
  18.     else
  19.       return 10
  20.     end
  21.   end
  22.  
  23.  
  24.   #---------------------------------------------------
  25.   def screen_zoom
  26.  
  27.     a = $data_troops[@troop_id].members[@member_index].y
  28.     case a
  29.     when 0..320/3
  30.       return 0.35
  31.  
  32.     when 320/3..320*2/3
  33.       return 0.55
  34.  
  35.     when 320*2/3..320
  36.       return 0.75
  37.  
  38.     else
  39.       return 2
  40.     end
  41.   end
踏上寻找灵魂归宿之旅。
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
46
在线时间
1502 小时
注册时间
2010-8-27
帖子
392
3
发表于 2013-10-25 10:34:15 | 只看该作者
这个具体有啥用呢?
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
87 小时
注册时间
2011-5-18
帖子
37
4
 楼主| 发表于 2013-10-25 11:24:46 | 只看该作者
战场上的相机,聚焦被选中的敌人。是我参考了 RTAB后自己做的。可以完全外挂。
本来想好好介绍一下这个脚本,可是似乎发帖很不顺利,最后只能直接上代码。
踏上寻找灵魂归宿之旅。
回复 支持 反对

使用道具 举报

Lv4.逐梦者

梦石
0
星屑
9280
在线时间
2504 小时
注册时间
2011-5-20
帖子
15389

开拓者

5
发表于 2013-10-26 16:01:07 | 只看该作者
聚焦被选中的敌人···感觉意义不大···毕竟不是地图战斗啊···

点评

是很不錯的功能 只要FPS沒有因此減少就是好的  发表于 2013-10-27 02:52
[img]http://service.t.sina.com.cn/widget/qmd/5339802982/c02e16bd/7.png
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
87 小时
注册时间
2011-5-18
帖子
37
6
 楼主| 发表于 2013-10-27 10:59:26 | 只看该作者
原理并不难,只是将 Spriteset Battle 的战场背景 和 敌人的 sprite,关联起来,进行移动缩放,产生透视效果,所以 FPS绝对不会减少。反正你们下载了试用就知道。我也没必要多讲。
踏上寻找灵魂归宿之旅。
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-5-14 21:43

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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