查看: 2912|回复: 3

[已经解决] [已解决]难度脚本问题

[复制链接]
梦石
0
星屑
7650
在线时间
1162 小时
注册时间
2016-9-10
回帖
145

开拓者

发表于 2017-4-5 20:19:43 | 显示全部楼层 |阅读模式

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

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

×
本帖最后由 devil033 于 2017-4-5 21:31 编辑

这是一个难度脚本
脚本中前面还有定义不同难度下敌人的 maxhp, atk, def 等属性分别是基本难度的多少倍
  }
  DIFFICULTY << {               # Difficulty Level: 2
        :name  => "困难",
        :maxhp => 150,   #150
        :maxmp => 130,
        :atk   => 120,
        :mat   => 120,
        :mdf   => 120,
        :agi   => 105,
        :luk   => 110,
        :exp   => 150,
        :drop  => 150,
  }



可是后面却定义了所有param_base 都是由 前面设置的 maxhp 的倍数来决定的
也就是不同难度下 maxhp 是基本难度的多少倍,atk, def 等其它属性 也跟着是多少倍
  alias :th_kgc_difficulty_param_base :param_base
  def param_base(i)
    th_kgc_difficulty_param_base(i) * KGC::BattleDifficulty.get[:maxhp] / 100
  end


如果我要改成每种属性在不同难度下的倍数是前面那个难度定义中设置的那个倍数  要怎么改?谢谢

以下是脚本:



  1. #_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
  2. #_/     ◆                Battle Difficulty - KGC_BattleDifficulty Ace
  3. #_/     ◇                                Last Update: 2008/05/09                              ◇
  4. #_/     ◇                                Converted: 2012/09/06
  5. #_/     ◆                          Translation by Mr. Anonymous                            ◆
  6. #_/     ◇                          Converted by Tsukihime
  7. #_/----------------------------------------------------------------------------
  8. #_/  This script adds battle difficulty settings to your game.
  9. #_/============================================================================
  10. #_/  Installation: Insert below KGC_ExtraDropItem and KGC_CustomMenuCommand.
  11. #_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/

  12. #==============================================================================#
  13. #                                                       ★ Customization ★                                                                #
  14. #==============================================================================#

  15. module KGC
  16. module BattleDifficulty
  17.   #                                        ◆ Difficulty Variable ◆
  18.   #  Change the variable the difficulty setting is stored in.
  19.   DIFFICULTY_VARIABLE = 944
  20.   
  21.   #                              ◆ Add Difficulty Command to Main Menu ◆
  22.   #  This toggle enables/disables the difficulty command selection to be added
  23.   #   to the main command menu.
  24.   USE_MENU_DIFFICULTY_COMMAND = true
  25.   
  26.   #                                       ◆ Difficulty Initialization ◆
  27.   #  DIFFICULTY Index
  28.   #  By default, 1 = Normal
  29.   INITIAL_DIFFICULTY = 1

  30.   #                                                ◆ Difficulty ◆
  31.   #  Difficulty Format:
  32.   #   DIFFICULTY << {
  33.   #      :name  => "Difficulty Name",
  34.   #      :maxhp => MaxHP,
  35.   #      :maxmp => MaxMP,
  36.   #      :atk   => Attack,
  37.   #      :def   => Defense,
  38.   #      :mat   => Magic Attack,
  39.   #      :mdf   => Magic Defense,
  40.   #      :agi   => Agility,
  41.   #      :luk   => Luck
  42.   #      :param => Attack ・ Defense ・ Mat, Mdf ・ Agility, Luck (Batch Specification),
  43.   #      :exp   => Experience,
  44.   #      :gold  => Gold,
  45.   #      :drop  => Item Drop Rate,
  46.   #   }
  47.   #  Create by the format
  48.   #  (:atk, :def, :spi, :agi (The :param field takes highest priority)
  49.   #  The unit is a percentile of a each item.
  50.   #  :name is not optional
  51.   #  An omitted item is treated as a default of 100
  52.   DIFFICULTY = [] # Do not remove or modify this line!
  53.   # 〜 Custom Difficulty Settings Inserted Below Here 〜
  54.   DIFFICULTY << {               # Difficulty Level: 0
  55.         :name  => "简单",
  56.         :maxhp => 80,
  57.         :maxmp => 80,
  58.         :param => 80,
  59.         :cri   => 50,
  60.         :drop  => 80,
  61.   }  # ← Do not remove!
  62.   DIFFICULTY << {               # Difficulty Level: 1
  63.         :name  => "普通",
  64.   }
  65.   DIFFICULTY << {               # Difficulty Level: 2
  66.         :name  => "困难",
  67.         :maxhp => 150,   #150
  68.         :maxmp => 130,
  69.         :atk   => 120,
  70.         :mat   => 120,
  71.         :mdf   => 120,
  72.         :agi   => 105,
  73.         :luk   => 110,
  74.         :exp   => 150,
  75.         :drop  => 150,
  76.   }
  77.   
  78. end
  79. end

  80. #------------------------------------------------------------------------------#

  81. $imported = {} if $imported == nil
  82. $imported["BattleDifficulty"] = true

  83. module KGC::BattleDifficulty
  84.   # Parameters
  85.   PARAMS = [
  86.         :maxhp, :maxmp, :atk, :def, :mat, :mdf, :agi, :luk,
  87.         :exp, :gold, :drop
  88.   ]

  89.   module_function
  90.   #--------------------------------------------------------------------------
  91.   # ○ 難易度補正値作成
  92.   #--------------------------------------------------------------------------
  93.   def create_param_revs
  94.         @@param_revs = []
  95.         DIFFICULTY.each { |d|
  96.           rev = {}
  97.           rev[:name] = d[:name]
  98.           # 一括指定を適用
  99.           if d[:param] != nil
  100.                 rev[:atk] = rev[:def] = rev[:mat] = rev[:mdf] = rev[:agi] = rev[:luk] = d[:param]
  101.           end
  102.           # パラメータ指定を適用
  103.           PARAMS.each { |par|
  104.                 if d[par] != nil
  105.                   rev[par] = d[par]
  106.                 else
  107.                   rev[par] = 100 if rev[par] == nil
  108.                 end
  109.           }
  110.           # リストに追加
  111.           @@param_revs << rev
  112.         }
  113.   end
  114.   #--------------------------------------------------------------------------
  115.   # ○ 難易度補正値取得
  116.   #--------------------------------------------------------------------------
  117.   def param_revs
  118.         return @@param_revs
  119.   end
  120.   #--------------------------------------------------------------------------
  121.   # ○ 難易度インデックス取得
  122.   #--------------------------------------------------------------------------
  123.   def get_index
  124.         vid = DIFFICULTY_VARIABLE
  125.         if $game_variables[vid] < 0 || DIFFICULTY.size <= $game_variables[vid]
  126.           $game_variables[vid] = INITIAL_DIFFICULTY
  127.         end
  128.         return $game_variables[vid]
  129.   end
  130.   #--------------------------------------------------------------------------
  131.   # ○ 難易度取得
  132.   #--------------------------------------------------------------------------
  133.   def get
  134.         return @@param_revs[get_index]
  135.   end
  136.   #--------------------------------------------------------------------------
  137.   # ○ 難易度変更
  138.   #      index : 難易度インデックス
  139.   #--------------------------------------------------------------------------
  140.   def set(index)
  141.         index = [[index, DIFFICULTY.size - 1].min, 0].max
  142.         $game_variables[DIFFICULTY_VARIABLE] = index
  143.   end

  144.   create_param_revs
  145. end

  146. #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★

  147. #==============================================================================
  148. # ■ RPG::Enemy::DropItem
  149. #==============================================================================

  150. unless $@
  151. class RPG::Enemy::DropItem
  152.   #--------------------------------------------------------------------------
  153.   # ● 出現率 1/N の分母 N
  154.   #--------------------------------------------------------------------------
  155.   alias denominator_KGC_BattleDifficulty denominator
  156.   def denominator
  157.     n = @denominator
  158.     if n > 1
  159.       n = [n * 100 / KGC::BattleDifficulty.get[:drop], 1].max
  160.     end
  161.     return n
  162.   end

  163. end  # class
  164. end  # unless $@

  165. #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★

  166. #==============================================================================
  167. # ■ Game_Enemy
  168. #==============================================================================

  169. class Game_Enemy < Game_Battler
  170.   
  171.   
  172.   # Ace defines one method for accessing all basic parameters
  173.   alias :th_kgc_difficulty_param_base :param_base
  174.   def param_base(i)
  175.     th_kgc_difficulty_param_base(i) * KGC::BattleDifficulty.get[:maxhp] / 100
  176.   end
  177.   
  178.   
  179.   #--------------------------------------------------------------------------
  180.   # ● 経験値の取得
  181.   #--------------------------------------------------------------------------
  182.   alias :th_KGC_BattleDifficulty_exp :exp
  183.   def exp
  184.     th_KGC_BattleDifficulty_exp * KGC::BattleDifficulty.get[:exp] / 100
  185.   end
  186.   #--------------------------------------------------------------------------
  187.   # ● お金の取得
  188.   #--------------------------------------------------------------------------
  189.   alias :th_KGC_BattleDifficulty_gold :gold
  190.   def gold
  191.     th_KGC_BattleDifficulty_gold * KGC::BattleDifficulty.get[:gold] / 100
  192.   end
  193. end

  194. #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★

  195. #==============================================================================
  196. # ■ Scene_Title
  197. #==============================================================================

  198. module DataManager
  199.   
  200.   class << self
  201.     alias :th_KGC_BattleDifficulty_create_game :create_game_objects
  202.   end
  203.   
  204.   def self.create_game_objects
  205.     th_KGC_BattleDifficulty_create_game
  206.     variable_id = KGC::BattleDifficulty::DIFFICULTY_VARIABLE
  207.     p variable_id
  208.     $game_variables[variable_id] = KGC::BattleDifficulty::INITIAL_DIFFICULTY
  209.   end
  210. end





  211. =begin



  212. #==============================================================================
  213. # ■ Scene_Menu
  214. #==============================================================================


  215. # new window for Ace, moving it out of Scene_Menu
  216. class Window_BattleDifficulty < Window_Command
  217.   
  218.   def make_command_list
  219.     KGC::BattleDifficulty::param_revs.each { |d|
  220.       add_command(d[:name], d[:name].to_sym)
  221.     }
  222.   end
  223. end

  224. class Window_MenuCommand
  225.   
  226.   alias :th_kgc_battle_difficulty_add_main_commands :add_main_commands
  227.   def add_main_commands
  228.     th_kgc_battle_difficulty_add_main_commands
  229.     if KGC::BattleDifficulty::USE_MENU_DIFFICULTY_COMMAND
  230.       add_command("Difficulty", :difficulty, main_commands_enabled)
  231.     end
  232.   end
  233. end

  234. class Scene_Menu
  235.   
  236.   # add new menu to the scene
  237.   
  238.   alias :th_kgc_battle_difficulty_start :start
  239.   def start
  240.     th_kgc_battle_difficulty_start
  241.     create_difficulty_window
  242.   end
  243.   
  244.   alias :th_kgc_battle_difficulty_cmd_window :create_command_window
  245.   def create_command_window
  246.     th_kgc_battle_difficulty_cmd_window
  247.     @command_window.set_handler(:difficulty,      method(:command_difficulty))
  248.   end
  249.   
  250.   def create_difficulty_window
  251.     @difficulty_window = Window_BattleDifficulty.new(80, 100)
  252.     @difficulty_window.set_handler(:ok, method(:on_difficulty_ok))
  253.     @difficulty_window.set_handler(:cancel, method(:on_difficulty_cancel))
  254.     @difficulty_window.hide.deactivate
  255.   end
  256.   
  257.   def command_difficulty
  258.     @difficulty_window.show.open.activate
  259.   end
  260.   
  261.   def on_difficulty_ok
  262.     KGC::BattleDifficulty.set(@difficulty_window.index)
  263.     end_difficulty_selection
  264.   end
  265.   
  266.   def on_difficulty_cancel
  267.     end_difficulty_selection
  268.   end
  269.   
  270.   def end_difficulty_selection
  271.     @difficulty_window.close
  272.     @command_window.activate
  273.   end
  274. end


  275. =end

复制代码

老鹰

梦石
40
星屑
38049
在线时间
7128 小时
注册时间
2012-5-26
回帖
3306

极短24评委极短23参与极短22参与极短21评委老司机慢点开短篇十吟唱者组别冠军开拓者剧作品鉴家

发表于 2017-4-5 21:05:42 | 显示全部楼层
你不是都找到问题关键了么
改成这样
  1. alias :th_kgc_difficulty_param_base :param_base
  2. def param_base(i)
  3.   sym = KGC::BattleDifficulty::PARAMS[i]
  4.   th_kgc_difficulty_param_base(i) * KGC::BattleDifficulty.get[sym] / 100
  5. end
复制代码

点评

目前只能稍微看得懂一点脚本,但还不能改,还在学习中,谢谢哈  发表于 2017-4-5 21:31
成功了,太好用了,感谢!  发表于 2017-4-5 21:30

评分

参与人数 1星屑 +150 收起 理由
RaidenInfinity + 150 认可答案

查看全部评分

回复

使用道具 举报

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

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部