查看: 3169|回复: 6

[已经解决] 如何让法师在战斗中击杀敌人时,永久增加最大法力值上限

[复制链接]
梦石
0
星屑
1696
在线时间
116 小时
注册时间
2020-6-12
回帖
20
发表于 2020-8-30 22:47:32 | 显示全部楼层 |阅读模式

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

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

×
如何让法师在战斗中击杀敌人时,永久增加最大法力值上限,
每击杀一个敌人最大法力值永久增加1点
法力值打到9000时,不再有效
求大佬指教
现在很迷没搞清楚,击杀判定,用事件试做了下感觉工作量很大,还很难判断是谁击杀的
梦石
0
星屑
30103
在线时间
5741 小时
注册时间
2016-3-8
回帖
1662
发表于 2020-8-31 00:06:35 | 显示全部楼层
本帖最后由 alexncf125 于 2020-8-31 00:21 编辑

input_defeat_count(法师角色的ID, 0, 183) #183号变量代入法师角色对全部敌人的击杀数
$game_variables[183] = 9000 if $game_variables[183] > 9000 #法力值打到9000时,不再有效

法师角色的备注栏写上
<param bonus: mmp>
  v[183]
</param bonus>

  1. #==============================================================================
  2. # ■ VXAce-RGSS3-6 撃破数カウンタ [Ver.1.0.0]         by Claimh
  3. #------------------------------------------------------------------------------
  4. # 各アクターが倒したエネミーの数をカウントします。
  5. #------------------------------------------------------------------------------
  6. #・ウィンドウ上に表示させる
  7. #Widow_Statusなどに追記してください。
  8. #<記述>
  9. # draw_defeat_count(actor_id, enemy_id, x, y)
  10. #   actor_id   :対象アクターID(0を指定すると全アクター)
  11. #   enemy_id   :対象エネミーID(0を指定すると全エネミー)
  12. #   x      :横方向の表示位置
  13. #   y      :縦方向の表示位置
  14. #------------------------------------------------------------------------------
  15. #・変数に入れる
  16. #イベントのスクリプト上に記述してください。
  17. #<記述>
  18. # input_defeat_count(actor_id, enemy_id, variable_id)
  19. #   actor_id   :対象アクターID(0を指定すると全アクター)
  20. #   enemy_id   :対象エネミーID(0を指定すると全エネミー)
  21. #   variable_id :撃破数を入れる変数
  22. #==============================================================================

  23. module DefeatCounter ## 他スクリプトとの併用のために残す
  24.   #--------------------------------------------------------------------------
  25.   # ● 指定アクターの撃破数
  26.   #       actor_id      :対象アクターID(0を指定すると全アクター)
  27.   #       enemy_id      :対象エネミーID(0を指定すると全エネミー)
  28.   #--------------------------------------------------------------------------
  29.   def self.defeat_count(actor_id=0, enemy_id=0)
  30.     return $game_actors.defeat(enemy_id, actor_id)
  31.   end
  32. end

  33. class Game_Actor < Game_Battler
  34.   #--------------------------------------------------------------------------
  35.   # ● オブジェクト初期化
  36.   #--------------------------------------------------------------------------
  37.   alias initialize_defeat_count initialize
  38.   def initialize(actor_id)
  39.     initialize_defeat_count(actor_id)
  40.     @defeat = {}
  41.   end
  42.   #--------------------------------------------------------------------------
  43.   # ● 撃破数取得
  44.   #--------------------------------------------------------------------------
  45.   def defeat(enemy_id=0)
  46.     return defeat_all if enemy_id == 0
  47.     @defeat[enemy_id] = 0 unless @defeat.keys.include?(enemy_id)
  48.     return @defeat[enemy_id]
  49.   end
  50.   #--------------------------------------------------------------------------
  51.   # ● 撃破数取得
  52.   #--------------------------------------------------------------------------
  53.   def defeat_all
  54.     @defeat.keys.inject(0) { |n, id| n += @defeat[id] }
  55.   end
  56.   #--------------------------------------------------------------------------
  57.   # ● 撃破数カウント
  58.   #--------------------------------------------------------------------------
  59.   def defeat_cnt(enemy_id)
  60.     return if enemy_id == 0
  61.     @defeat[enemy_id] = 0 unless @defeat.keys.include?(enemy_id)
  62.     @defeat[enemy_id] += 1
  63.   end
  64. end

  65. class Game_Actors
  66.   #--------------------------------------------------------------------------
  67.   # ● 撃破数取得
  68.   #--------------------------------------------------------------------------
  69.   def defeat(enemy_id=0, actor_id=0)
  70.     return defeat_all(enemy_id) if actor_id == 0
  71.     return self.[](actor_id).defeat(enemy_id)
  72.   end
  73.   #--------------------------------------------------------------------------
  74.   # ● 撃破数取得
  75.   #--------------------------------------------------------------------------
  76.   def defeat_all(enemy_id=0)
  77.     @data.inject(0) { |n, actor| n += (actor.nil? ? 0 : actor.defeat(enemy_id)) }
  78.   end
  79. end

  80. #==============================================================================
  81. # ■ Game_Battler
  82. #==============================================================================
  83. class Game_Battler < Game_BattlerBase
  84.   #--------------------------------------------------------------------------
  85.   # ● ダメージの処理
  86.   #    呼び出し前に @result.hp_damage @result.mp_damage @result.hp_drain
  87.   #    @result.mp_drain が設定されていること。
  88.   #--------------------------------------------------------------------------
  89.   alias execute_damage_defeat execute_damage
  90.   def execute_damage(user)
  91.     execute_damage_defeat(user)
  92.     return if actor? or !dead? or user.enemy?
  93.     return if $game_troop.enable_dead_count?(self.index)
  94.     $game_troop.defeat_dead_count(self.index)
  95.     user.defeat_cnt(self.enemy_id)
  96.   end
  97. end


  98. #==============================================================================
  99. # ■ Game_Troop
  100. #==============================================================================
  101. class Game_Troop < Game_Unit
  102.   #--------------------------------------------------------------------------
  103.   # ● セットアップ
  104.   #--------------------------------------------------------------------------
  105.   alias setup_defeat setup
  106.   def setup(troop_id)
  107.     setup_defeat(troop_id)
  108.     @enemy_defeat = []
  109.   end
  110.   #--------------------------------------------------------------------------
  111.   # ● 撃破時のカウント
  112.   #--------------------------------------------------------------------------
  113.   def defeat_dead_count(index)
  114.     @enemy_defeat[index] = true
  115.   end
  116.   #--------------------------------------------------------------------------
  117.   # ● 既にカウント済み?
  118.   #--------------------------------------------------------------------------
  119.   def enable_dead_count?(index)
  120.     @enemy_defeat[index] || false
  121.   end
  122. end


  123. class Game_Interpreter
  124.   #--------------------------------------------------------------------------
  125.   # ● 指定した変数にアクターの撃破数を格納する
  126.   #       actor_id      :対象アクター(0を指定すると全アクター)
  127.   #       enemy_id      :対象エネミー(0を指定すると全エネミー)
  128.   #       variable_id   :撃破数を格納する変数
  129.   #--------------------------------------------------------------------------
  130.   def input_defeat_count(actor_id, enemy_id, variable_id)
  131.     $game_variables[variable_id] = $game_actors.defeat(enemy_id, actor_id)
  132.     return true
  133.   end
  134. end

  135. class Window_Base < Window
  136.   #--------------------------------------------------------------------------
  137.   # ● 指定した変数にアクターの撃破数を表示する
  138.   #       actor_id      :対象アクター(0を指定すると全アクター)
  139.   #       enemy_id      :対象エネミー(0を指定すると全エネミー)
  140.   #       x             :横方向の表示位置
  141.   #       y             :縦方向の表示位置
  142.   #--------------------------------------------------------------------------
  143.   def draw_defeat_count(actor_id, enemy_id, x, y)
  144.     draw_text(x, y, 200, line_height, $game_actors.defeat(enemy_id, actor_id), 2)
  145.   end
  146. end
复制代码
  1. =begin
  2. #===============================================================================
  3. Title: Parameter Bonuses
  4. Author: Hime
  5. Date: Aug 1, 2014
  6. URL: [url]http://himeworks.com/2013/12/09/parameter-bonuses/[/url]
  7. --------------------------------------------------------------------------------
  8. ** Change log
  9. Aug 1, 2014
  10.    - added a reference to the tagged object
  11. Jul 24, 2014
  12.    - added support for class, armors, weapons, and states
  13. Dec 20, 2013
  14.    - added support for "recursive" references
  15.    - added support for passing in the base parameter
  16.    - added support for enemy parameter bonuses
  17. Dec 9, 2013
  18.    - initial release
  19. --------------------------------------------------------------------------------   
  20. ** Terms of Use
  21. * Free to use in non-commercial projects
  22. * Contact me for commercial use
  23. * No real support. The script is provided as-is
  24. * Will do bug fixes, but no compatibility patches
  25. * Features may be requested but no guarantees, especially if it is non-trivial
  26. * Credits to Hime Works in your project
  27. * Preserve this header
  28. --------------------------------------------------------------------------------
  29. ** Description

  30. This script allows you to define "Parameter bonuses" for your actors and
  31. enemies. A paramter bonus is simply a bonus that will be added to your
  32. parameters based on a formula. The bonus itself could be an increase, or
  33. even a decrease in stats if you provide a negative value.

  34. For example, suppose you had custom parameters that allowed you to define
  35. stats like "strength" or "intelligence", where str increases your atk and
  36. max HP params while int increases magic attack and magic defense stats. You
  37. can use parameter bonuses to define formulas that will allow your str and int
  38. stats to contribute to the other parameters.

  39. Since the parameter bonus can be any formula, you can define bonuses based
  40. on anything.

  41. Parameter bonuses can be defined in actors, classes, weapons, armors, states,
  42. and enemies. Actors will inherit any bonuses defined in their class, equips,
  43. and states. Enemies will inherit any bonuses defined in their states.

  44. Because equips and states can be changed, you can use this to create unique
  45. effects.

  46. --------------------------------------------------------------------------------
  47. ** Installation

  48. In the script editor, place this script below Materials and above Main

  49. --------------------------------------------------------------------------------
  50. ** Usage

  51. To define a parameter bonus, note-tag actors with

  52.    <param bonus: TYPE>
  53.      FORMULA
  54.    </param bonus>
  55.    
  56. Where the TYPE is one of

  57.    mhp - max HP
  58.    mmp - max MP
  59.    atk - attack
  60.    def - defense
  61.    mat - magic attack
  62.    mdf - magic defense
  63.    agi - agility
  64.    luk - luck
  65.    
  66. And the formula can be any valid ruby formula.
  67. The following formula variables are available

  68.    a - the current battler (actor or enemy)
  69. obj - the tagged object
  70.    p - game party
  71.    t - game troop
  72.    v - game variables
  73.    s - game switches
  74.    
  75. You can have a bonus reference itself. For example

  76.    <param bonus: atk>
  77.      a.atk * 1.5
  78.    </param bonus>
  79.    
  80. Will increase the battler's atk value by 50%. This atk value does not
  81. include the bonus, but includes base params and extra params.
  82.    
  83. You can define multiple parameter bonuses for an actor, and you can define
  84. multiple bonuses for the same stat; simply add more of the note-tag.

  85. == Object Reference ==

  86. The `obj` variable is a special variable that you can use to refer
  87. to the object that the bonus is attached to. For example, suppose
  88. you notetagged a weapon with

  89. <param bonus: mhp>
  90.     obj.params[2] * 10
  91. </param bonus>

  92. This means that you receive an HP bonus equal to the weapon's atk times 10.
  93. All of the attributes that you can access in a weapon is available.

  94. If the bonus is attached to an armor, then `obj` references that armor, and
  95. so on.

  96. --------------------------------------------------------------------------------
  97. ** Example

  98. Suppose we have a custom stat called "str", and for each point of str, it
  99. increases HP by 10 and atk by 2. You would use two parameter bonuses:

  100.    <param bonus: mhp>
  101.      a.str * 10
  102.    </param bonus>
  103.    
  104.    <param bonus: atk>
  105.      a.str * 2
  106.    </param bonus>

  107. #===============================================================================
  108. =end
  109. $imported = {} if $imported.nil?
  110. $imported["TH_ParameterBonus"] = true
  111. #===============================================================================
  112. # ** Configuration
  113. #===============================================================================
  114. module TH
  115.   module Parameter_Bonuses
  116.     Regex = /<param[-_ ]bonus:\s*(\w+)\s*>(.*?)<\/param[-_ ]bonus>/im

  117. #===============================================================================
  118. # ** Rest of Script
  119. #===============================================================================
  120.     Table = {
  121.       :mhp => 0,
  122.       :mmp => 1,
  123.       :atk => 2,
  124.       :def => 3,
  125.       :mat => 4,
  126.       :mdf => 5,
  127.       :agi => 6,
  128.       :luk => 7
  129.     }
  130.   end
  131. end

  132. module RPG
  133.   class BaseItem
  134.     def param_bonuses
  135.       load_notetag_param_bonuses unless @param_bonuses
  136.       return @param_bonuses
  137.     end
  138.    
  139.     def load_notetag_param_bonuses
  140.       @param_bonuses = []
  141.       results = self.note.scan(TH::Parameter_Bonuses::Regex)
  142.       results.each do |res|
  143.         param = res[0].downcase.to_sym
  144.         formula = res[1].strip
  145.         id = TH::Parameter_Bonuses::Table[param]
  146.         data = Data_ParamBonus.new(id, formula, self)
  147.         @param_bonuses << data
  148.       end
  149.     end
  150.   end
  151. end

  152. class Data_ParamBonus
  153.   
  154.   attr_accessor :param_id
  155.   attr_accessor :formula
  156.         attr_accessor :obj
  157.   
  158.   def initialize(param_id, formula="0", obj)
  159.     @param_id = param_id
  160.     @formula = formula
  161.                 @obj = obj
  162.   end
  163.   
  164.   def value(a, p=$game_party, t=$game_troop, s=$game_switches, v=$game_variables)
  165.     eval(@formula)
  166.   end
  167. end

  168. class Game_BattlerBase
  169.   
  170.   def param_bonus_objects
  171.     states
  172.   end
  173.   
  174.   alias :th_param_bonuses_param_plus :param_plus
  175.   def param_plus(param_id)
  176.     th_param_bonuses_param_plus(param_id) + param_bonus(param_id)
  177.   end
  178.   
  179.   #-----------------------------------------------------------------------------
  180.   # Calculates the bonus parameter.
  181.   #-----------------------------------------------------------------------------
  182.   def param_bonus(param_id)
  183.     return 0 if @check_param_bonus
  184.     @check_param_bonus = true
  185.     val = param_bonus_objects.inject(0) do |r, bonus_obj|
  186.       bonus_obj.param_bonuses.inject(r) do |r2, obj|
  187.         obj.param_id == param_id ? r2 += obj.value(self) : r2
  188.       end
  189.     end
  190.     @check_param_bonus = false
  191.     return val
  192.   end
  193. end

  194. class Game_Actor < Game_Battler
  195.   
  196.   alias :th_parameter_bonuses_param_bonus_objects :param_bonus_objects
  197.   def param_bonus_objects
  198.     feature_objects
  199.   end
  200. end

  201. class Game_Enemy < Game_Battler
  202.   
  203.   alias :th_parameter_bonuses_param_bonus_objects :param_bonus_objects
  204.   def param_bonus_objects
  205.     feature_objects
  206.   end
  207. end
复制代码
回复 1 0

使用道具 举报

梦石
0
星屑
1696
在线时间
116 小时
注册时间
2020-6-12
回帖
20
 楼主| 发表于 2020-8-31 22:35:07 | 显示全部楼层
alexncf125 发表于 2020-8-31 00:06
input_defeat_count(法师角色的ID, 0, 183) #183号变量代入法师角色对全部敌人的击杀数
$game_variables[18 ...

大佬,这两页代吗都要用还是只用其中一页
回复

使用道具 举报

梦石
0
星屑
1696
在线时间
116 小时
注册时间
2020-6-12
回帖
20
 楼主| 发表于 2020-9-1 21:30:30 | 显示全部楼层
alexncf125 发表于 2020-8-31 00:06
input_defeat_count(法师角色的ID, 0, 183) #183号变量代入法师角色对全部敌人的击杀数
$game_variables[18 ...

def input_defeat_count(1, 0, 183)
    $game_variables[183] = $game_actors.defeat(0, 1)
    $game_variables[183] = 9000 if $game_variables[183] > 9000 #大于9000无效
    return true
  end
大佬,击杀脚本有点懵,这个是用编号带入吗。
下面那个奖励机制的脚本好用
回复

使用道具 举报

梦石
0
星屑
30103
在线时间
5741 小时
注册时间
2016-3-8
回帖
1662
发表于 2020-9-1 22:22:45 | 显示全部楼层
慵懒的初学者 发表于 2020-9-1 21:30
def input_defeat_count(1, 0, 183)
    $game_variables[183] = $game_actors.defeat(0, 1)
    $game_v ...

def input_defeat_count(1, 0, 183)是什么鬼...

在那兩个脚本的下一页插入这段试试...
  1. class Game_Battler < Game_BattlerBase
  2.   #--------------------------------------------------------------------------
  3.   # ● 战斗行动结束时的处理
  4.   #--------------------------------------------------------------------------
  5.   alias old_on_action_end_old on_action_end
  6.   def on_action_end
  7.     old_on_action_end_old
  8.     $game_variables[183] = $game_actors.defeat(0, 法师角色的ID)
  9.     $game_variables[183] = 9000 if $game_variables[183] > 9000 #大于9000时固定为900
  10.   end
  11. end
复制代码
回复

使用道具 举报

梦石
0
星屑
1696
在线时间
116 小时
注册时间
2020-6-12
回帖
20
 楼主| 发表于 2020-9-2 21:37:28 | 显示全部楼层
alexncf125 发表于 2020-9-1 22:22
def input_defeat_count(1, 0, 183)是什么鬼...

在那兩个脚本的下一页插入这段试试...

加入这个代码就可以用了,多谢大佬
回复

使用道具 举报

梦石
0
星屑
1696
在线时间
116 小时
注册时间
2020-6-12
回帖
20
 楼主| 发表于 2020-9-2 21:39:23 | 显示全部楼层
alexncf125 发表于 2020-9-1 22:22
def input_defeat_count(1, 0, 183)是什么鬼...

在那兩个脚本的下一页插入这段试试...

上面这个1是职业编号,183是变量,我把它带入第一页代码的里面,没效果
回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部