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

Project1

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

[已经解决] 求CP式战斗新算法

 关闭 [复制链接]

Lv1.梦旅人

梦石
0
星屑
142
在线时间
70 小时
注册时间
2006-5-14
帖子
882
跳转到指定楼层
1
发表于 2009-10-5 13:04:10 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
本帖最后由 悠哈悠哈 于 2009-10-8 19:00 编辑

66上有个成熟的CP式战斗脚本,我从绯月心二开始就一直使用这种脚本.但他有个问题,那就是速度对战斗的影响太大.因为他是1:1式的,即如果你的速度是怪的两倍就可二次行动,三倍的话就可三次行动......这就造成一个后果:只要HP多到不会被怪秒就行,剩下的就是速度王道了.......(这对有分配能力点的系统来说非常头痛,平衡性非常难调整).
所以我想到一种算法:随着双方速度差的放大,速度对CP的影响不断减少.简单的说就是,当双方速度值一样时CP增长一样,双方行动速度一样.但当一方的速度是另一方的两倍时(例一个是100,一个是200)这时实际CP增长只有50%,也就是说只是比对方多了0.5次行动,想要达到二次行动速度要达到对方的4倍,也就是说对方速度值是100,我方是400,这样才能实现现两次行动.(这样做的目的我想大家也明白吧,当然有更好的算法的话,你说话)
我是脚本盲,当年我问禾西时,禾西说这个理论上是可行的,可是在脚本上和如何描述他就不知道了.全二中我虽然减少了速度的其他性能,但还是太强,所以不得想决心改变CP的算法.请各位脚本高手帮一下我.谢谢.
附上我用的CP脚本:
  1. if Control[:CPS]

  2. class Scene_Battle_CP
  3.   Speed = 1.0
  4.   Initial_Percent = 0
  5. end

  6. class Scene_Battle
  7.   CPcost = {}
  8.   # 滿CP時響起的音效,可以自己添加
  9.   CP_SE = ""
  10.   CPcost[:basic]  = 0 # 基础共同
  11.   CPcost[:skill]  = 65535 # 技能
  12.   CPcost[:item]   = 65535 # 物品
  13.   CPcost[:throw]  = 65535 # 投掷
  14.   CPcost[:attack] = 65535 # 攻撃
  15.   CPcost[:guard]  = 65535 # 防御
  16.   CPcost[:nothing]= 65535 # 不做任何事情
  17.   CPcost[:escpe]  = 65535 # 逃跑
  18. end
  19. #==============================================================================
  20. # ■ Scene_Battle (main)
  21. #------------------------------------------------------------------------------
  22. #  CPS系統
  23. #==============================================================================

  24. class Scene_Battle
  25.   attr_accessor :battle_sprite
  26.   #--------------------------------------------------------------------------
  27.   # ● 接口
  28.   #--------------------------------------------------------------------------
  29.   Import_01 = []
  30.   Import_02 = []
  31.   #--------------------------------------------------------------------------
  32.   # ● 主处理
  33.   #--------------------------------------------------------------------------
  34.   def main
  35.     prepare
  36.     # 执行过渡
  37.     if $data_system.battle_transition == ""
  38.       Graphics.transition(20)
  39.     else
  40.       Graphics.transition(40, "Graphics/Transitions/" +
  41.         $data_system.battle_transition)
  42.     end
  43.     setup_phase1
  44.     # 主循环
  45.     loop do
  46.       # 刷新游戏画面
  47.       Graphics.update
  48.       # 刷新输入信息
  49.       Input.update
  50.       # 刷新画面
  51.       update
  52.       # 如果画面切换的话就中断循环
  53.       break if $scene != self
  54.     end
  55.     # 刷新地图
  56.     $game_map.refresh
  57.     # 准备过渡
  58.     Graphics.freeze
  59.     terminate
  60.     # 标题画面切换中的情况
  61.     if $scene.is_a?(Scene_Title)
  62.       # 淡入淡出画面
  63.       Graphics.transition
  64.       Graphics.freeze
  65.     end
  66.     # 战斗测试或者游戏结束以外的画面切换中的情况
  67.     if $BTEST and not $scene.is_a?(Scene_Gameover)
  68.       $scene = nil
  69.     end
  70.   end
  71.   #--------------------------------------------------------------------------
  72.   # ● 准备
  73.   #--------------------------------------------------------------------------
  74.   def prepare
  75.     #-----------------------------------
  76.     # 初始化战斗用的各种暂时数据
  77.     #-----------------------------------
  78.     $game_temp.in_battle = true
  79.     $game_temp.battle_turn = 0
  80.     $game_temp.battle_event_flags.clear
  81.     $game_temp.battle_abort = false
  82.     $game_temp.battle_main_phase = false
  83.     $game_temp.battleback_name = $game_map.battleback_name
  84.     $game_temp.forcing_battler = nil
  85.     #-----------------------------------
  86.     # 初始化战斗用事件解释器
  87.     #-----------------------------------
  88.     $game_system.battle_interpreter.setup(nil, 0)
  89.     #-----------------------------------
  90.     # 准备敌人
  91.     #-----------------------------------
  92.     @troop_id = $game_temp.battle_troop_id
  93.     $game_troop.setup(@troop_id)
  94.     #-----------------------------------
  95.     # 基本战斗显示活动块(含地图、天气、战斗人员)
  96.     #-----------------------------------
  97.     @battle_sprite = Spriteset_Battle.new
  98.    
  99.     #-----------------------------------
  100.     # 帮助窗口
  101.     #-----------------------------------
  102.     @help_window = Window_Help.new
  103.     @help_window.back_opacity = 160
  104.     @help_window.visible = false
  105.     #-----------------------------------
  106.     # 信息栏窗口
  107.     #-----------------------------------
  108.     @message_window = Window_Message.new
  109.     #-----------------------------------
  110.     # 初始化等待计数
  111.     #-----------------------------------
  112.     @wait_count = 0
  113.    
  114.    
  115.     #-----------------------------------
  116.     # CP值加算建立
  117.     #-----------------------------------
  118.     @cp_thread = Scene_Battle_CP.new
  119.     #-----------------------------------
  120.     # 动作选择窗口
  121.     #-----------------------------------
  122.     @actor_command = Scene_Battle_Select.new(@battle_sprite.viewport1,@battle_sprite.viewport2)
  123.     #-----------------------------------
  124.     # ["战斗", "逃跑"]
  125.     #-----------------------------------
  126.     @party_command_window = Window_PartyCommand.new
  127.     #-----------------------------------
  128.     # 人物状态栏窗口
  129.     #-----------------------------------
  130.     @status_window = Window_BattleStatus.new
  131.   end
  132.   #--------------------------------------------------------------------------
  133.   # ● 终止
  134.   #--------------------------------------------------------------------------
  135.   def terminate
  136.     @result_window.dispose if @result_window != nil
  137.     @status_window.dispose
  138.     @actor_command.dispose
  139.     @party_command_window.dispose
  140.     @message_window.dispose
  141.     @help_window.dispose
  142.     @battle_sprite.dispose
  143.     RPG::Sprite.clear
  144.   end
  145.   
  146.   #--------------------------------------------------------------------------
  147.   # ● 開始
  148.   #--------------------------------------------------------------------------
  149.   def setup_phase1
  150.     # 回合数计数
  151.     $game_temp.battle_turn += 1
  152.     # 转移到回合 1
  153.     @phase = 1
  154.     # 清除全体同伴的行动
  155.     $game_party.clear_actions
  156.     # 设置战斗事件
  157.     setup_battle_event
  158.     @cp_thread.stop = false
  159.     ($game_party.actors + $game_troop.enemies).each do |b|
  160.       # 死亡後CP歸〇
  161.       if b.dead?
  162.         b.cp = 0
  163.       end
  164.     end
  165.     @status_window.refresh
  166.   end
  167.   def phase1
  168.     # 胜利或者失败的情况下 : 过程结束
  169.     return if judge
  170.     # 否則
  171.     # 開始更新 CP 計算
  172.     @cp_thread.update
  173.     # 移動 CP 條
  174.     @status_window.refresh_cp
  175.     # 畫面刷新
  176.     Graphics.frame_reset
  177.     # 尋找CP滿值的戰斗者
  178.     for index in 0...$game_party.actors.size
  179.       battler = $game_party.actors[index]
  180.       # 當前者不是就繼續尋找
  181.       next unless battler.cp >= 65535
  182.       # 找到就停止 CP 計算
  183.       @cp_thread.stop = true
  184.       # 効果音の再生
  185.       Audio.se_play(CP_SE) if CP_SE  != ""
  186.       @active_battler = battler
  187.       @actor_index = index
  188.       setup_phase2
  189.       return
  190.     end
  191.    
  192.     for index in 0...$game_troop.enemies.size
  193.       battler = $game_troop.enemies[index]
  194.       next unless battler.cp >= 65535
  195.       @cp_thread.stop = true
  196.       @active_battler = battler
  197.       @active_battler.make_action
  198.       setup_phase3
  199.       return
  200.     end
  201.   end
  202.   def setup_phase2
  203.     if @active_battler.inputable?
  204.       @phase = 2
  205.       @active_battler.blink = true
  206.       #......................................................................
  207.       Audio.se_play("Audio/SE/005-System05")#, se.volume, se.pitch)
  208.       #......................................................................
  209.       # 设置角色的命令窗口
  210.       @actor_command.show(@actor_index)
  211.     else
  212.       setup_phase3
  213.     end
  214.   end
  215.   def phase2
  216.     # 移動 CP 條
  217.     @status_window.refresh_cp
  218.     # 畫面刷新
  219.     Graphics.frame_reset
  220.     if @actor_command.update == false
  221.       @active_battler.blink = false
  222.       setup_phase3
  223.     end
  224.   end
  225.   def setup_phase3
  226.     @phase = 3
  227.    
  228.     # 搜索全页的战斗事件
  229.     for index in 0...$data_troops[@troop_id].pages.size
  230.       # 获取事件页
  231.       page = $data_troops[@troop_id].pages[index]
  232.       # 本页的范围是 [回合] 的情况下
  233.       if page.span == 1
  234.         # 设置已经执行标志
  235.         $game_temp.battle_event_flags[index] = false
  236.       end
  237.     end
  238.     # 初始化动画 ID 和公共事件 ID
  239.     @animation1_id = 0
  240.     @animation2_id = 0
  241.     @common_event_id = 0
  242.    
  243.     # 如果已经在战斗之外的情况下
  244.     if @active_battler.index == nil
  245.       return
  246.     end
  247.     #自动状态
  248.     auto_effect
  249.     # 自然解除状态
  250.     @active_battler.remove_states_auto
  251.     # 刷新状态窗口
  252.     @status_window.refresh
  253.     if @phase4_step != 2
  254.       # 刷新
  255.       @status_window.refresh
  256.       # 軽量化
  257.       Graphics.frame_reset
  258.     end
  259.   end
  260.   def phase3
  261.     # 清除對像戰鬥者
  262.     @target_battlers = []
  263.     # 行動種類分支
  264.     case @active_battler.current_action.kind
  265.     when 0  # 基本
  266.       @active_battler.cp -= CPcost[:basic]
  267.       case @active_battler.current_action.basic
  268.       when 0 #攻撃的場合
  269.         @active_battler.cp -= CPcost[:attack]
  270.         make_attack_result
  271.       when 1 #防禦的場合
  272.         @active_battler.cp -= CPcost[:guard]
  273.         make_guard_result
  274.       when 2 #逃跑的場合
  275.         @active_battler.cp -= CPcost[:escape]
  276.         make_escape_result
  277.       when 3 #甚麼也不做的場合
  278.         @active_battler.cp -= CPcost[:nothing]
  279.         make_nothing_result
  280.       end
  281.     when 1  # 特技
  282.       @target_back = Dxxxx[0][@active_battler.current_action.skill_id]
  283.       @close_up    = Bxxxx[0][@active_battler.current_action.skill_id]
  284.       @close_up_2  = Fxxxx[@active_battler.current_action.skill_id]
  285.       @active_battler.cp -= CPcost[:skill]
  286.       make_skill_result
  287.     when 2  # 物品
  288.       @target_back = Dxxxx[1][@active_battler.current_action.item_id]
  289.       @close_up    = Bxxxx[1][@active_battler.current_action.item_id]
  290.       @active_battler.cp -= CPcost[:item]
  291.       make_item_result
  292.     end
  293.     setup_phase4
  294.   end
  295.   def setup_phase4
  296.     (close_up(@close_up)  ;@close_up   = nil) if @close_up   != nil
  297.     (close_up_2(@close_up_2);@close_up_2 = nil) if @close_up_2 != nil
  298.     #-----------------------
  299.     # 原 update_phase4_step3
  300.     #-----------------------
  301.     # 行动方动画 (ID 为 0 的情况下是白色闪烁)
  302.     if @animation1_id == 0
  303.       @active_battler.white_flash = true
  304.     else
  305.       @active_battler.animation_id = @animation1_id
  306.       @active_battler.animation_hit = true
  307.     end
  308.     @phase = 4
  309.     @step = 4
  310.   end
  311.   def phase4
  312.     case @step
  313.     when 4;phase4_step4
  314.     when 5;phase4_step5
  315.     when 6;phase4_step6
  316.     end
  317.   end
  318.   def phase4_step4
  319.     #-----------------------
  320.     # 战斗背景図替换 p.1
  321.     #-----------------------
  322.     background_setting(1)
  323.     #-----------------------
  324.     # 原 update_phase4_step4
  325.     #-----------------------
  326.     # 对像方动画
  327.     for target in @target_battlers
  328.       target.animation_id = @animation2_id
  329.       target.animation_hit = (target.damage != "Miss")
  330.     end
  331.     # 限制动画长度、最低 8 帧
  332.     @wait_count = 8
  333.     @step = 5
  334.   end
  335.   def phase4_step5
  336.     #-----------------------
  337.     # 原 update_phase4_step5
  338.     #-----------------------
  339.     # 隐藏帮助窗口
  340.     @help_window.visible = false
  341.     # 刷新状态窗口
  342.     @status_window.refresh
  343.     for target in @target_battlers
  344.       if target.damage != nil
  345.         target.damage = nil
  346.       end
  347.     end
  348.     @step = 6
  349.   end

  350.   def phase4_step6
  351.     #-----------------------
  352.     # 战斗背景図替换 p.2
  353.     #-----------------------
  354.     background_setting(2)
  355.     #-----------------------
  356.     # 原 update_phase4_step6
  357.     #-----------------------
  358.     # 清除强制行动对像的战斗者
  359.     $game_temp.forcing_battler = nil
  360.     # 公共事件 ID 有效的情况下
  361.     if @common_event_id > 0
  362.       # 设置事件
  363.       common_event = $data_common_events[@common_event_id]
  364.       $game_system.battle_interpreter.setup(common_event.list, 0)
  365.     end
  366.     setup_phase1
  367.   end
  368.   def setup_phase5
  369.     # 转移到回合 5
  370.     @phase = 5
  371.     # 演奏战斗结束 ME
  372.     $game_system.me_play($game_system.battle_end_me)
  373.     # 还原为战斗开始前的 BGM
  374.     $game_system.bgm_play($game_temp.map_bgm)
  375.     # 初始化 EXP、金钱、宝物
  376.     exp = 0
  377.     gold = 0
  378.     treasures = []
  379.     # 循环
  380.     for enemy in $game_troop.enemies
  381.       # 敌人不是隐藏状态的情况下
  382.       unless enemy.hidden
  383.         # 获得 EXP、增加金钱
  384.         exp += enemy.exp
  385.         gold += enemy.gold
  386.         # 出现宝物判定
  387.         if rand(100) < enemy.treasure_prob
  388.           if enemy.item_id > 0
  389.             treasures.push($data_items[enemy.item_id])
  390.           end
  391.           if enemy.weapon_id > 0
  392.             treasures.push($data_weapons[enemy.weapon_id])
  393.           end
  394.           if enemy.armor_id > 0
  395.             treasures.push($data_armors[enemy.armor_id])
  396.           end
  397.         end
  398.       end
  399.     end
  400.     # 限制宝物数为 6 个
  401.     treasures = treasures[0..5]
  402.     # 获得 EXP
  403.     for i in 0...$game_party.actors.size
  404.       actor = $game_party.actors[i]
  405.       if actor.cant_get_exp? == false
  406.         last_level = actor.level
  407.         actor.exp += exp
  408.         if actor.level > last_level
  409.           @status_window.level_up(i)
  410.         end
  411.       end
  412.     end
  413.     # 获得金钱
  414.     $game_party.gain_gold(gold)
  415.     # 获得宝物
  416.     for item in treasures
  417.       case item
  418.       when RPG::Item
  419.         $game_party.gain_item(item.id, 1)
  420.       when RPG::Weapon
  421.         $game_party.gain_weapon(item.id, 1)
  422.       when RPG::Armor
  423.         $game_party.gain_armor(item.id, 1)
  424.       end
  425.     end
  426.     # 生成战斗结果窗口
  427.     @result_window = Window_BattleResult.new(exp, gold, treasures)
  428.     # 设置等待计数
  429.     @phase5_wait_count = 100
  430.   end
  431.   def phase5
  432.     # 等待计数大于 0 的情况下
  433.     if @phase5_wait_count > 0
  434.       # 减少等待计数
  435.       @phase5_wait_count -= 1
  436.       # 等待计数为 0 的情况下
  437.       if @phase5_wait_count == 0
  438.         # 显示结果窗口
  439.         @result_window.visible = true
  440.         # 清除主回合标志
  441.         $game_temp.battle_main_phase = false
  442.         # 刷新状态窗口
  443.         @status_window.refresh
  444.       end
  445.       return
  446.     end
  447.     # 按下 C 键的情况下
  448.     if Input.trigger?(Input::C)
  449.       # 战斗结束
  450.       battle_end(0)
  451.     end
  452.   end
  453.   
  454.   #--------------------------------------------------------------------------
  455.   # ● 刷新
  456.   #--------------------------------------------------------------------------
  457.   def update
  458.     # 执行战斗事件中的情况下
  459.     if $game_system.battle_interpreter.running?
  460.       # 刷新解释器
  461.       $game_system.battle_interpreter.update
  462.       # 强制行动的战斗者不存在的情况下
  463.       if $game_temp.forcing_battler == nil
  464.         # 执行战斗事件结束的情况下
  465.         unless $game_system.battle_interpreter.running?
  466.           # 继续战斗的情况下、再执行战斗事件的设置
  467.           unless judge
  468.             setup_battle_event
  469.           end
  470.         end
  471.         # 如果不是结束战斗回合的情况下
  472.         if @phase != 5
  473.           # 刷新状态窗口
  474.           @status_window.refresh
  475.         end
  476.       end
  477.     end
  478.     # 系统 (计时器)、刷新画面
  479.     $game_system.update
  480.     $game_screen.update
  481.     # 计时器为 0 的情况下
  482.     if $game_system.timer_working and $game_system.timer == 0
  483.       # 中断战斗
  484.       $game_temp.battle_abort = true
  485.     end
  486.     @status_window.update
  487.     @battle_sprite.update
  488.     # 处理过渡中的情况下
  489.     if $game_temp.transition_processing
  490.       # 清除处理过渡中标志
  491.       $game_temp.transition_processing = false
  492.       # 执行过渡
  493.       if $game_temp.transition_name == ""
  494.         Graphics.transition(20)
  495.       else
  496.         Graphics.transition(40, "Graphics/Transitions/" +
  497.           $game_temp.transition_name)
  498.       end
  499.     end
  500.     return if need_to_stop
  501.     case @phase
  502.     when 1;phase1
  503.     when 2;phase2
  504.     when 3;phase3
  505.     when 4;phase4
  506.     when 5;phase5
  507.     when 6
  508.     when 7
  509.     end
  510.   end
  511.   def need_to_stop
  512.     # 显示信息窗口中的情况下
  513.     if $game_temp.message_window_showing
  514.       return true
  515.     end
  516.     # 显示效果中的情况下
  517.     if @battle_sprite.effect?
  518.       return true
  519.     end
  520.     # 游戏结束的情况下
  521.     if $game_temp.gameover
  522.       # 切换到游戏结束画面
  523.       $scene = Scene_Gameover.new
  524.       return true
  525.     end
  526.     # 返回标题画面的情况下
  527.     if $game_temp.to_title
  528.       # 切换到标题画面
  529.       $scene = Scene_Title.new
  530.       return true
  531.     end
  532.     # 中断战斗的情况下
  533.     if $game_temp.battle_abort
  534.       # 还原为战斗前的 BGM
  535.       $game_system.bgm_play($game_temp.map_bgm)
  536.       # 战斗结束
  537.       battle_end(1)
  538.       return true
  539.     end
  540.     # 等待中的情况下
  541.     if @wait_count > 0
  542.       # 减少等待计数
  543.       @wait_count -= 1
  544.       return true
  545.     end
  546.     # 强制行动的角色存在、
  547.     # 并且战斗事件正在执行的情况下
  548.     if $game_temp.forcing_battler == nil and
  549.        $game_system.battle_interpreter.running?
  550.       return true
  551.     end
  552.     return false
  553.   end
  554.   #--------------------------------------------------------------------------
  555.   # ● 设置战斗事件
  556.   #--------------------------------------------------------------------------
  557.   def setup_battle_event
  558.     # 正在执行战斗事件的情况下
  559.     return if $game_system.battle_interpreter.running?
  560.     # 搜索全部页的战斗事件
  561.     for index in 0...$data_troops[@troop_id].pages.size
  562.       # 获取事件页
  563.       page = $data_troops[@troop_id].pages[index]
  564.       # 事件条件可以参考 c
  565.       c = page.condition
  566.       # 没有指定任何条件的情况下转到下一页
  567.       next unless c.turn_valid or c.enemy_valid or
  568.                   c.actor_valid or c.switch_valid
  569.       # 执行完毕的情况下转到下一页
  570.       next if $game_temp.battle_event_flags[index]
  571.       # 确认回合条件
  572.       if c.turn_valid
  573.         n = $game_temp.battle_turn
  574.         a = c.turn_a
  575.         b = c.turn_b
  576.         next if (b == 0 and n != a)
  577.         next if (b > 0 and (n < 1 or n < a or n % b != a % b))
  578.       end
  579.       # 确认敌人条件
  580.       if c.enemy_valid
  581.         enemy = $game_troop.enemies[c.enemy_index]
  582.         next if enemy == nil
  583.         next if enemy.hp * 100.0 / enemy.maxhp > c.enemy_hp
  584.       end
  585.       # 确认角色条件
  586.       if c.actor_valid
  587.         actor = $game_actors[c.actor_id]
  588.         next if actor == nil
  589.         next if (actor.hp * 100.0 / actor.maxhp > c.actor_hp)
  590.       end
  591.       # 确认开关条件
  592.       if c.switch_valid
  593.         next if $game_switches[c.switch_id] == false
  594.       end
  595.       # 设置事件
  596.       $game_system.battle_interpreter.setup(page.list, 0)
  597.       # 本页的范围是 [战斗] 或 [回合] 的情况下
  598.       if page.span <= 1
  599.         # 设置执行结束标志
  600.         $game_temp.battle_event_flags[index] = true
  601.       end
  602.       return
  603.     end
  604.   end
  605.   #--------------------------------------------------------------------------
  606.   # ● 胜负判定
  607.   #--------------------------------------------------------------------------
  608.   def judge
  609.     # 全灭判定是真、并且同伴人数为 0 的情况下
  610.     if $game_party.all_dead? or $game_party.actors.size == 0
  611.       # 允许失败的情况下
  612.       if $game_temp.battle_can_lose
  613.         # 还原为战斗开始前的 BGM
  614.         $game_system.bgm_play($game_temp.map_bgm)
  615.         # 战斗结束
  616.         battle_end(2)
  617.       else
  618.         # 设置游戏结束标志
  619.         $game_temp.gameover = true
  620.       end
  621.       # 返回 true
  622.       return true
  623.     end
  624.     # 如果存在任意 1 个敌人就返回 false
  625.     for enemy in $game_troop.enemies
  626.       if enemy.exist?
  627.         return false
  628.       end
  629.     end
  630.     # 开始结束战斗回合 (胜利)
  631.     setup_phase5
  632.     # 返回 true
  633.     return true
  634.   end
  635.   #--------------------------------------------------------------------------
  636.   # ● 战斗结束
  637.   #     result : 結果 (0:胜利 1:失败 2:逃跑)
  638.   #--------------------------------------------------------------------------
  639.   def battle_end(result)
  640.     # CP加算終止
  641.     @cp_thread.stop
  642.     # 清除战斗中标志
  643.     $game_temp.in_battle = false
  644.     # 清除全体同伴的行动
  645.     $game_party.clear_actions
  646.     # 解除战斗用状态
  647.     $game_party.actors.each do |actor| actor.remove_states_battle end
  648.     # 清除敌人
  649.     $game_troop.enemies.clear
  650.     # 调用战斗返回调用
  651.     if $game_temp.battle_proc != nil
  652.       $game_temp.battle_proc.call(result)
  653.       $game_temp.battle_proc = nil
  654.     end
  655.     # 切换到地图画面
  656.     $scene = Scene_Map.new
  657.   end
  658.   #--------------------------------------------------------------------------
  659.   # ● make_result
  660.   #--------------------------------------------------------------------------
  661.   def make_attack_result
  662.     # 设置攻击 ID
  663.     @animation1_id = @active_battler.animation1_id
  664.     @animation2_id = @active_battler.animation2_id
  665.     # 行动方的战斗者是敌人的情况下
  666.     case @active_battler
  667.     when (Game_Enemy)
  668.       case @active_battler.restriction
  669.       when 3
  670.         target = $game_troop.random_target_enemy
  671.       when 2
  672.         target = $game_party.random_target_actor
  673.       else
  674.         index = @active_battler.current_action.target_index
  675.         target = $game_party.smooth_target_actor(index)
  676.       end
  677.     # 行动方的战斗者是角色的情况下
  678.     when (Game_Actor)
  679.       case @active_battler.restriction
  680.       when 3
  681.         target = $game_party.random_target_actor
  682.       when 2
  683.         target = $game_troop.random_target_enemy
  684.       else
  685.         index = @active_battler.current_action.target_index
  686.         target = $game_troop.smooth_target_enemy(index)
  687.       end
  688.     end
  689.     @target_battlers = [target]
  690.     # 应用通常攻击效果
  691.     for target in @target_battlers
  692.       target.attack_effect(@active_battler)
  693.     end
  694.   end
  695.   def make_guard_result
  696.     @help_window.set_text($data_system.words.guard, 1)
  697.   end
  698.   def make_escape_result
  699.     if @active_battler.is_a?(Game_Enemy)
  700.       #  帮助窗口显示"逃跑"
  701.       @help_window.set_text("逃跑", 1)
  702.       # 逃跑
  703.       @active_battler.escape
  704.       return
  705.     end
  706.   end
  707.   def make_nothing_result
  708.     # 清除强制行动对像的战斗者
  709.     $game_temp.forcing_battler = nil
  710.     # 移至步骤 1
  711.     setup_phase1
  712.   end
  713.   #--------------------------------------------------------------------------
  714.   # ● 生成特技行动结果
  715.   #--------------------------------------------------------------------------
  716.   def make_skill_result
  717.     # 获取特技
  718.     @skill = $data_skills[@active_battler.current_action.skill_id]
  719.     # 如果不是强制行动
  720.     unless @active_battler.current_action.forcing
  721.       # 因为 SP 耗尽而无法使用的情况下
  722.       unless @active_battler.skill_can_use?(@skill.id)
  723.         # 清除强制行动对像的战斗者
  724.         $game_temp.forcing_battler = nil
  725.         # 移至步骤 1
  726.         setup_phase1
  727.         return
  728.       end
  729.     end
  730.     # 消耗 SP
  731.     @active_battler.sp -= @skill.sp_cost
  732.     # 刷新状态窗口
  733.     @status_window.refresh
  734.     # 在帮助窗口显示特技名
  735.     @help_window.set_text(@skill.name, 1)
  736.     # 设置动画 ID
  737.     @animation1_id = @skill.animation1_id
  738.     @animation2_id = @skill.animation2_id
  739.     # 设置公共事件 ID
  740.     @common_event_id = @skill.common_event_id
  741.     # 设置对像侧战斗者
  742.     set_target_battlers(@skill.scope)
  743.     # 应用特技效果
  744.     for target in @target_battlers
  745.       target.skill_effect(@active_battler, @skill)
  746.     end
  747.   end
  748.   #--------------------------------------------------------------------------
  749.   # ● 生成物品行动结果
  750.   #--------------------------------------------------------------------------
  751.   def make_item_result
  752.     # 获取物品
  753.     @item = $data_items[@active_battler.current_action.item_id]
  754.     # 因为物品耗尽而无法使用的情况下
  755.     unless $game_party.item_can_use?(@item.id)
  756.       # 移至步骤 1
  757.       setup_phase1
  758.       return
  759.     end
  760.     # 消耗品的情况下
  761.     if @item.consumable
  762.       # 使用的物品减 1
  763.       $game_party.lose_item(@item.id, 1)
  764.     end
  765.     # 在帮助窗口显示物品名
  766.     @help_window.set_text(@item.name, 1)
  767.     # 设置动画 ID
  768.     @animation1_id = @item.animation1_id
  769.     @animation2_id = @item.animation2_id
  770.     # 设置公共事件 ID
  771.     @common_event_id = @item.common_event_id
  772.     # 确定对像
  773.     index = @active_battler.current_action.target_index
  774.     target = $game_party.smooth_target_actor(index)
  775.     # 设置对像侧战斗者
  776.     set_target_battlers(@item.scope)
  777.     # 应用物品效果
  778.     for target in @target_battlers
  779.       target.item_effect(@item)
  780.     end
  781.   end
  782.   #--------------------------------------------------------------------------
  783.   # ● 设置物品或特技对像方的战斗者
  784.   #     scope : 特技或者是物品的范围
  785.   #--------------------------------------------------------------------------
  786.   def set_target_battlers(scope)
  787.     # 行动方的战斗者是敌人的情况下
  788.     case @active_battler
  789.     when (Game_Enemy)
  790.       # 效果范围分支
  791.       case scope
  792.       when 1  # 敌单体
  793.         index = @active_battler.current_action.target_index
  794.         @target_battlers.push($game_party.smooth_target_actor(index))
  795.       when 3  # 我方单体
  796.         index = @active_battler.current_action.target_index
  797.         @target_battlers.push($game_troop.smooth_target_enemy(index))
  798.       when 2  # 敌全体
  799.         $game_party.actors.each{|actor|
  800.           if actor.exist?
  801.             @target_battlers.push(actor)
  802.           end
  803.         }
  804.       when 4  # 我方全体
  805.         $game_troop.enemies.each{|enemy|
  806.           if enemy.exist?
  807.             @target_battlers.push(enemy)
  808.           end
  809.         }
  810.       when 5  # 我方单体 (HP 0)
  811.         index = @active_battler.current_action.target_index
  812.         enemy = $game_troop.enemies[index]
  813.         if enemy != nil and enemy.hp0?
  814.           @target_battlers.push(enemy)
  815.         end
  816.       when 6  # 我方全体 (HP 0)
  817.         for enemy in $game_troop.enemies
  818.           if enemy != nil and enemy.hp0?
  819.             @target_battlers.push(enemy)
  820.           end
  821.         end
  822.       when 7  # 使用者
  823.         @target_battlers.push(@active_battler)
  824.       end
  825.     # 行动方的战斗者是角色的情况下
  826.     when (Game_Actor)
  827.       # 效果范围分支
  828.       case scope
  829.       when 1  # 敌单体
  830.         index = @active_battler.current_action.target_index
  831.         @target_battlers.push($game_troop.smooth_target_enemy(index))
  832.       when 3  # 我方单体
  833.         index = @active_battler.current_action.target_index
  834.         @target_battlers.push($game_party.smooth_target_actor(index))
  835.       when 2  # 敌全体
  836.         $game_troop.enemies.each{|enemy|
  837.           if enemy.exist?
  838.             @target_battlers.push(enemy)
  839.           end
  840.         }
  841.       when 4  # 我方全体
  842.         $game_party.actors.each{|actor|
  843.           if actor.exist?
  844.             @target_battlers.push(actor)
  845.           end
  846.         }
  847.       when 5  # 我方单体 (HP 0)
  848.         index = @active_battler.current_action.target_index
  849.         actor = $game_party.actors[index]
  850.         if actor != nil and actor.hp0?
  851.           @target_battlers.push(actor)
  852.         end
  853.       when 6  # 我方全体 (HP 0)
  854.         for actor in $game_party.actors
  855.           if actor != nil and actor.hp0?
  856.             @target_battlers.push(actor)
  857.           end
  858.         end
  859.       when 7  # 使用者
  860.         @target_battlers.push(@active_battler)
  861.       end
  862.     end
  863.   end
  864.   #--------------------------------------------------------------------------
  865.   # ● 背景轉換預留接口 p.1 & 2
  866.   #--------------------------------------------------------------------------
  867.   def background_setting(part)
  868.   end
  869. end
  870. class Scene_Battle_CP
  871.   attr_accessor :stop #CP加算停止開關
  872.   
  873.   #----------------------------------------------------------------------------
  874.   # ○ 初期化
  875.   #----------------------------------------------------------------------------
  876.   def initialize
  877.     @stop = false
  878.     @total_agi = 0
  879.     count_battlers = ($game_troop.enemies + $game_party.actors)
  880.     count_battlers.each do |b| @total_agi += b.agi end
  881.     count_battlers.each do |b|
  882.       #CP值初期化
  883.       b.cp =65535 * Initial_Percent * (rand(15) + 85) * 4 * (b.agi/1.5) / @total_agi / 10000
  884.       if b.cp < 0     then b.cp = 0     end
  885.       if b.cp > 65535 then b.cp = 65535 end
  886.     end
  887.   end
  888.   #----------------------------------------------------------------------------
  889.   # ○ 加算
  890.   #----------------------------------------------------------------------------
  891.   def update
  892.     return if @stop
  893.     ($game_troop.enemies + $game_party.actors).each do |b|
  894.       #已亡者無視
  895.       next if b.dead?
  896.       b.cp +=Speed * 4096 * b.agi/1.5 / @total_agi
  897.       if b.cp < 0       then b.cp = 0 end
  898.       if b.cp > 65535 then b.cp = 65535 end
  899.     end
  900.   end
  901. end

  902. #==============================================================================
  903. # ■ Game_Battler
  904. #==============================================================================
  905. class Game_Battler
  906. attr_accessor :now_guarding # 現在防御中判定
  907. attr_accessor :cp # 現在CP
  908. #--------------------------------------------------------------------------
  909. # ○ CP 変更
  910. #--------------------------------------------------------------------------
  911. def cp=(cp)
  912.   if cp < 0     then cp = 0     end
  913.   if cp > 65535 then cp = 65535 end
  914.   @cp = cp
  915. end
  916. #--------------------------------------------------------------------------
  917. # ● 防御中判定 [ 再定義 ]
  918. #--------------------------------------------------------------------------
  919. def guarding?
  920.   return @now_guarding
  921. end
  922. #--------------------------------------------------------------------------
  923. # ● 入力可能判定
  924. #--------------------------------------------------------------------------
  925. alias CPS_inputable? inputable?
  926. def inputable?
  927.   bool = CPS_inputable?
  928.   return (bool and (@cp >= 65535))
  929. end
  930. end
  931. #==============================================================================
  932. # ■ Game_Actor
  933. #==============================================================================
  934. class Game_Actor < Game_Battler
  935. #--------------------------------------------------------------------------
  936. # ● 初期化
  937. #--------------------------------------------------------------------------
  938. alias CPS_setup setup
  939. def setup(actor_id)
  940.   CPS_setup(actor_id)
  941.   @cp = 0
  942.   @now_guarding = false
  943. end
  944. end
  945. #==============================================================================
  946. # ■ Game_Enemy
  947. #==============================================================================
  948. class Game_Enemy < Game_Battler
  949. #--------------------------------------------------------------------------
  950. # ● 初期化
  951. #--------------------------------------------------------------------------
  952. alias CPS_initialize initialize
  953. def initialize(troop_id, member_index)
  954.   CPS_initialize(troop_id, member_index)
  955.   @cp = 0
  956.   @now_guarding = false
  957. end
  958. end

  959. end
复制代码

Lv1.梦旅人

真实之终章

梦石
0
星屑
60
在线时间
48 小时
注册时间
2008-8-7
帖子
281
2
发表于 2009-10-5 13:07:44 | 只看该作者
本帖最后由 胖达达人 于 2009-10-5 13:22 编辑

新论坛下,发代码请用[code】【/code]
Orz……应该可以找出一个数学函数模型实现的吧……去试试看
不是关键脚本?= =
玫瑰绽放,彼岸流殇。
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
142
在线时间
70 小时
注册时间
2006-5-14
帖子
882
3
 楼主| 发表于 2009-10-5 13:11:57 | 只看该作者
本帖最后由 悠哈悠哈 于 2009-10-5 15:36 编辑

不好意思,我是脚本盲,可能是发错了脚本,重发一下,不知道这个是不是.如果再不是你们可直接去全二的贴子下补丁.那里有我的全套DATA,你们可以看一下.
回复 支持 反对

使用道具 举报

头像被屏蔽

Lv1.梦旅人 (禁止发言)

梦石
0
星屑
50
在线时间
0 小时
注册时间
2008-8-30
帖子
57
4
发表于 2009-10-5 18:23:39 | 只看该作者
提示: 作者被禁止或删除 内容自动屏蔽
签名被屏蔽
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
142
在线时间
70 小时
注册时间
2006-5-14
帖子
882
5
 楼主| 发表于 2009-10-5 19:00:46 | 只看该作者
本帖最后由 悠哈悠哈 于 2009-10-5 19:03 编辑

先吸一口冷气.........有点明白你的意思,但看看有点头大(我是脚本盲,不知道有没有更好的方法,等待中,同时再去问问那些会给我编脚本的人.......要知道能写出数学式不一定能用脚本写出来........)
这个好像有点像双曲线函数的特征........自己也好好想想..........
回复 支持 反对

使用道具 举报

Lv1.梦旅人

剑圣

梦石
0
星屑
50
在线时间
122 小时
注册时间
2008-8-31
帖子
778
6
发表于 2009-10-5 21:15:24 | 只看该作者
先吸一口冷气.........有点明白你的意思,但看看有点头大(我是脚本盲,不知道有没有更好的方法,等待中,同时再去问问那些会给我编脚本的人.......要知道能写出数学式不一定能用脚本写出来........)
这个好像有点像双曲 ...
悠哈悠哈 发表于 2009-10-5 19:00


设cp是速度agi的函数 f(aig)
你需要的是一个单调上升并且一阶导数单调减少的函数,即 f' >0 , f''<0
最简单的就是 f(x) = x^a , 0<a<1

这个想法很不错,借鉴了~

PC/IOS/Android共享的RM RPG:未名大学
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
77 小时
注册时间
2008-5-16
帖子
194
7
发表于 2009-10-6 03:31:04 | 只看该作者
887行。。。。。。
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
202
在线时间
498 小时
注册时间
2006-10-21
帖子
907
8
发表于 2009-10-6 07:24:41 | 只看该作者
单纯依靠对方速度来决定自己速度?
那应该是敌方速度平均值么?那么当敌方中减速状态时候你是不是也跟着减速呢……还是就是战斗初就跟据敌方确定一个基准值,但这样当敌人减少后呢?总之要考虑问题不少。

或者换个想法,就让cp随速度提升的速度随速度变大而减慢就行了吧…
回复 支持 反对

使用道具 举报

Lv3.寻梦者

孤独守望

梦石
0
星屑
3121
在线时间
1534 小时
注册时间
2006-10-16
帖子
4321

开拓者贵宾

9
发表于 2009-10-6 17:30:36 | 只看该作者
NC问题:按照您的算法
对于速度4:2:1的三个单位,
对照4和1,应该是2倍速
对照4和2,应该是2.25倍速

找个新的数学模型吧……= =或者给个标定数据值。
菩提本非树,明镜本非台。回头自望路漫漫。不求姻缘,但求再见。
本来无一物,何处惹尘埃。风打浪吹雨不来。荒庭遍野,扶摇难接。
不知道多久更新一次的博客
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
142
在线时间
70 小时
注册时间
2006-5-14
帖子
882
10
 楼主| 发表于 2009-10-8 09:37:33 | 只看该作者
...........你们说的都只是一个思路,我当时说的只是一个例子,并不是必须要是这个比例,只要是随着速度差的变大而CP变化减小就行,并没有说必须减少多少.还有用什么方式来实现(用CP为基本点还是以相对速度为基本点)没有规定.实在不行固定的也行,比如速度变为原来的1/2(原来是1:1).唉,实再不行的话我还是放弃这个算法算了,到时用其他方法来解决速度问题.
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-4-20 15:35

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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