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

Project1

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

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

[复制链接]

Lv3.寻梦者

梦石
0
星屑
1651
在线时间
112 小时
注册时间
2020-6-12
帖子
31
跳转到指定楼层
1
发表于 2020-8-30 22:47:32 | 只看该作者 回帖奖励 |正序浏览 |阅读模式

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

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

x
如何让法师在战斗中击杀敌人时,永久增加最大法力值上限,
每击杀一个敌人最大法力值永久增加1点
法力值打到9000时,不再有效
求大佬指教
现在很迷没搞清楚,击杀判定,用事件试做了下感觉工作量很大,还很难判断是谁击杀的

Lv3.寻梦者

梦石
0
星屑
1651
在线时间
112 小时
注册时间
2020-6-12
帖子
31
7
 楼主| 发表于 2020-9-2 21:39:23 | 只看该作者
alexncf125 发表于 2020-9-1 22:22
def input_defeat_count(1, 0, 183)是什么鬼...

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

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

使用道具 举报

Lv3.寻梦者

梦石
0
星屑
1651
在线时间
112 小时
注册时间
2020-6-12
帖子
31
6
 楼主| 发表于 2020-9-2 21:37:28 | 只看该作者
alexncf125 发表于 2020-9-1 22:22
def input_defeat_count(1, 0, 183)是什么鬼...

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

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

使用道具 举报

Lv5.捕梦者

梦石
0
星屑
26204
在线时间
5348 小时
注册时间
2016-3-8
帖子
1655
5
发表于 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
复制代码
回复 支持 反对

使用道具 举报

Lv3.寻梦者

梦石
0
星屑
1651
在线时间
112 小时
注册时间
2020-6-12
帖子
31
4
 楼主| 发表于 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
大佬,击杀脚本有点懵,这个是用编号带入吗。
下面那个奖励机制的脚本好用
回复 支持 反对

使用道具 举报

Lv3.寻梦者

梦石
0
星屑
1651
在线时间
112 小时
注册时间
2020-6-12
帖子
31
3
 楼主| 发表于 2020-8-31 22:35:07 | 只看该作者
alexncf125 发表于 2020-8-31 00:06
input_defeat_count(法师角色的ID, 0, 183) #183号变量代入法师角色对全部敌人的击杀数
$game_variables[18 ...

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

使用道具 举报

Lv5.捕梦者

梦石
0
星屑
26204
在线时间
5348 小时
注册时间
2016-3-8
帖子
1655
2
发表于 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>

RUBY 代码复制
  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.  
  24. module DefeatCounter ## 他スクリプトとの併用のために残す
  25.   #--------------------------------------------------------------------------
  26.   # ● 指定アクターの撃破数
  27.   #       actor_id      :対象アクターID(0を指定すると全アクター)
  28.   #       enemy_id      :対象エネミーID(0を指定すると全エネミー)
  29.   #--------------------------------------------------------------------------
  30.   def self.defeat_count(actor_id=0, enemy_id=0)
  31.     return $game_actors.defeat(enemy_id, actor_id)
  32.   end
  33. end
  34.  
  35. class Game_Actor < Game_Battler
  36.   #--------------------------------------------------------------------------
  37.   # ● オブジェクト初期化
  38.   #--------------------------------------------------------------------------
  39.   alias initialize_defeat_count initialize
  40.   def initialize(actor_id)
  41.     initialize_defeat_count(actor_id)
  42.     @defeat = {}
  43.   end
  44.   #--------------------------------------------------------------------------
  45.   # ● 撃破数取得
  46.   #--------------------------------------------------------------------------
  47.   def defeat(enemy_id=0)
  48.     return defeat_all if enemy_id == 0
  49.     @defeat[enemy_id] = 0 unless @defeat.keys.include?(enemy_id)
  50.     return @defeat[enemy_id]
  51.   end
  52.   #--------------------------------------------------------------------------
  53.   # ● 撃破数取得
  54.   #--------------------------------------------------------------------------
  55.   def defeat_all
  56.     @defeat.keys.inject(0) { |n, id| n += @defeat[id] }
  57.   end
  58.   #--------------------------------------------------------------------------
  59.   # ● 撃破数カウント
  60.   #--------------------------------------------------------------------------
  61.   def defeat_cnt(enemy_id)
  62.     return if enemy_id == 0
  63.     @defeat[enemy_id] = 0 unless @defeat.keys.include?(enemy_id)
  64.     @defeat[enemy_id] += 1
  65.   end
  66. end
  67.  
  68. class Game_Actors
  69.   #--------------------------------------------------------------------------
  70.   # ● 撃破数取得
  71.   #--------------------------------------------------------------------------
  72.   def defeat(enemy_id=0, actor_id=0)
  73.     return defeat_all(enemy_id) if actor_id == 0
  74.     return self.[](actor_id).defeat(enemy_id)
  75.   end
  76.   #--------------------------------------------------------------------------
  77.   # ● 撃破数取得
  78.   #--------------------------------------------------------------------------
  79.   def defeat_all(enemy_id=0)
  80.     @data.inject(0) { |n, actor| n += (actor.nil? ? 0 : actor.defeat(enemy_id)) }
  81.   end
  82. end
  83.  
  84. #==============================================================================
  85. # ■ Game_Battler
  86. #==============================================================================
  87. class Game_Battler < Game_BattlerBase
  88.   #--------------------------------------------------------------------------
  89.   # ● ダメージの処理
  90.   #    呼び出し前に @result.hp_damage @result.mp_damage @result.hp_drain
  91.   #    @result.mp_drain が設定されていること。
  92.   #--------------------------------------------------------------------------
  93.   alias execute_damage_defeat execute_damage
  94.   def execute_damage(user)
  95.     execute_damage_defeat(user)
  96.     return if actor? or !dead? or user.enemy?
  97.     return if $game_troop.enable_dead_count?(self.index)
  98.     $game_troop.defeat_dead_count(self.index)
  99.     user.defeat_cnt(self.enemy_id)
  100.   end
  101. end
  102.  
  103.  
  104. #==============================================================================
  105. # ■ Game_Troop
  106. #==============================================================================
  107. class Game_Troop < Game_Unit
  108.   #--------------------------------------------------------------------------
  109.   # ● セットアップ
  110.   #--------------------------------------------------------------------------
  111.   alias setup_defeat setup
  112.   def setup(troop_id)
  113.     setup_defeat(troop_id)
  114.     @enemy_defeat = []
  115.   end
  116.   #--------------------------------------------------------------------------
  117.   # ● 撃破時のカウント
  118.   #--------------------------------------------------------------------------
  119.   def defeat_dead_count(index)
  120.     @enemy_defeat[index] = true
  121.   end
  122.   #--------------------------------------------------------------------------
  123.   # ● 既にカウント済み?
  124.   #--------------------------------------------------------------------------
  125.   def enable_dead_count?(index)
  126.     @enemy_defeat[index] || false
  127.   end
  128. end
  129.  
  130.  
  131. class Game_Interpreter
  132.   #--------------------------------------------------------------------------
  133.   # ● 指定した変数にアクターの撃破数を格納する
  134.   #       actor_id      :対象アクター(0を指定すると全アクター)
  135.   #       enemy_id      :対象エネミー(0を指定すると全エネミー)
  136.   #       variable_id   :撃破数を格納する変数
  137.   #--------------------------------------------------------------------------
  138.   def input_defeat_count(actor_id, enemy_id, variable_id)
  139.     $game_variables[variable_id] = $game_actors.defeat(enemy_id, actor_id)
  140.     return true
  141.   end
  142. end
  143.  
  144. class Window_Base < Window
  145.   #--------------------------------------------------------------------------
  146.   # ● 指定した変数にアクターの撃破数を表示する
  147.   #       actor_id      :対象アクター(0を指定すると全アクター)
  148.   #       enemy_id      :対象エネミー(0を指定すると全エネミー)
  149.   #       x             :横方向の表示位置
  150.   #       y             :縦方向の表示位置
  151.   #--------------------------------------------------------------------------
  152.   def draw_defeat_count(actor_id, enemy_id, x, y)
  153.     draw_text(x, y, 200, line_height, $game_actors.defeat(enemy_id, actor_id), 2)
  154.   end
  155. end

RUBY 代码复制
  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.  
  31.  This script allows you to define "Parameter bonuses" for your actors and
  32.  enemies. A paramter bonus is simply a bonus that will be added to your
  33.  parameters based on a formula. The bonus itself could be an increase, or
  34.  even a decrease in stats if you provide a negative value.
  35.  
  36.  For example, suppose you had custom parameters that allowed you to define
  37.  stats like "strength" or "intelligence", where str increases your atk and
  38.  max HP params while int increases magic attack and magic defense stats. You
  39.  can use parameter bonuses to define formulas that will allow your str and int
  40.  stats to contribute to the other parameters.
  41.  
  42.  Since the parameter bonus can be any formula, you can define bonuses based
  43.  on anything.
  44.  
  45.  Parameter bonuses can be defined in actors, classes, weapons, armors, states,
  46.  and enemies. Actors will inherit any bonuses defined in their class, equips,
  47.  and states. Enemies will inherit any bonuses defined in their states.
  48.  
  49.  Because equips and states can be changed, you can use this to create unique
  50.  effects.
  51.  
  52. --------------------------------------------------------------------------------
  53.  ** Installation
  54.  
  55.  In the script editor, place this script below Materials and above Main
  56.  
  57. --------------------------------------------------------------------------------
  58.  ** Usage
  59.  
  60.  To define a parameter bonus, note-tag actors with
  61.  
  62.    <param bonus: TYPE>
  63.      FORMULA
  64.    </param bonus>
  65.    
  66.  Where the TYPE is one of
  67.  
  68.    mhp - max HP
  69.    mmp - max MP
  70.    atk - attack
  71.    def - defense
  72.    mat - magic attack
  73.    mdf - magic defense
  74.    agi - agility
  75.    luk - luck
  76.    
  77.  And the formula can be any valid ruby formula.
  78.  The following formula variables are available
  79.  
  80.    a - the current battler (actor or enemy)
  81.  obj - the tagged object
  82.    p - game party
  83.    t - game troop
  84.    v - game variables
  85.    s - game switches
  86.    
  87.  You can have a bonus reference itself. For example
  88.  
  89.    <param bonus: atk>
  90.      a.atk * 1.5
  91.    </param bonus>
  92.    
  93.  Will increase the battler's atk value by 50%. This atk value does not
  94.  include the bonus, but includes base params and extra params.
  95.    
  96.  You can define multiple parameter bonuses for an actor, and you can define
  97.  multiple bonuses for the same stat; simply add more of the note-tag.
  98.  
  99.  == Object Reference ==
  100.  
  101.  The `obj` variable is a special variable that you can use to refer
  102.  to the object that the bonus is attached to. For example, suppose
  103.  you notetagged a weapon with
  104.  
  105.  <param bonus: mhp>
  106.     obj.params[2] * 10
  107.  </param bonus>
  108.  
  109.  This means that you receive an HP bonus equal to the weapon's atk times 10.
  110.  All of the attributes that you can access in a weapon is available.
  111.  
  112.  If the bonus is attached to an armor, then `obj` references that armor, and
  113.  so on.
  114.  
  115. --------------------------------------------------------------------------------
  116.  ** Example
  117.  
  118.  Suppose we have a custom stat called "str", and for each point of str, it
  119.  increases HP by 10 and atk by 2. You would use two parameter bonuses:
  120.  
  121.    <param bonus: mhp>
  122.      a.str * 10
  123.    </param bonus>
  124.    
  125.    <param bonus: atk>
  126.      a.str * 2
  127.    </param bonus>
  128.  
  129. #===============================================================================
  130. =end
  131. $imported = {} if $imported.nil?
  132. $imported["TH_ParameterBonus"] = true
  133. #===============================================================================
  134. # ** Configuration
  135. #===============================================================================
  136. module TH
  137.   module Parameter_Bonuses
  138.     Regex = /<param[-_ ]bonus:\s*(\w+)\s*>(.*?)<\/param[-_ ]bonus>/im
  139.  
  140. #===============================================================================
  141. # ** Rest of Script
  142. #===============================================================================
  143.     Table = {
  144.       :mhp => 0,
  145.       :mmp => 1,
  146.       :atk => 2,
  147.       :def => 3,
  148.       :mat => 4,
  149.       :mdf => 5,
  150.       :agi => 6,
  151.       :luk => 7
  152.     }
  153.   end
  154. end
  155.  
  156. module RPG
  157.   class BaseItem
  158.     def param_bonuses
  159.       load_notetag_param_bonuses unless @param_bonuses
  160.       return @param_bonuses
  161.     end
  162.  
  163.     def load_notetag_param_bonuses
  164.       @param_bonuses = []
  165.       results = self.note.scan(TH::Parameter_Bonuses::Regex)
  166.       results.each do |res|
  167.         param = res[0].downcase.to_sym
  168.         formula = res[1].strip
  169.         id = TH::Parameter_Bonuses::Table[param]
  170.         data = Data_ParamBonus.new(id, formula, self)
  171.         @param_bonuses << data
  172.       end
  173.     end
  174.   end
  175. end
  176.  
  177. class Data_ParamBonus
  178.  
  179.   attr_accessor :param_id
  180.   attr_accessor :formula
  181.         attr_accessor :obj
  182.  
  183.   def initialize(param_id, formula="0", obj)
  184.     @param_id = param_id
  185.     @formula = formula
  186.                 @obj = obj
  187.   end
  188.  
  189.   def value(a, p=$game_party, t=$game_troop, s=$game_switches, v=$game_variables)
  190.     eval(@formula)
  191.   end
  192. end
  193.  
  194. class Game_BattlerBase
  195.  
  196.   def param_bonus_objects
  197.     states
  198.   end
  199.  
  200.   alias :th_param_bonuses_param_plus :param_plus
  201.   def param_plus(param_id)
  202.     th_param_bonuses_param_plus(param_id) + param_bonus(param_id)
  203.   end
  204.  
  205.   #-----------------------------------------------------------------------------
  206.   # Calculates the bonus parameter.
  207.   #-----------------------------------------------------------------------------
  208.   def param_bonus(param_id)
  209.     return 0 if @check_param_bonus
  210.     @check_param_bonus = true
  211.     val = param_bonus_objects.inject(0) do |r, bonus_obj|
  212.       bonus_obj.param_bonuses.inject(r) do |r2, obj|
  213.         obj.param_id == param_id ? r2 += obj.value(self) : r2
  214.       end
  215.     end
  216.     @check_param_bonus = false
  217.     return val
  218.   end
  219. end
  220.  
  221. class Game_Actor < Game_Battler
  222.  
  223.   alias :th_parameter_bonuses_param_bonus_objects :param_bonus_objects
  224.   def param_bonus_objects
  225.     feature_objects
  226.   end
  227. end
  228.  
  229. class Game_Enemy < Game_Battler
  230.  
  231.   alias :th_parameter_bonuses_param_bonus_objects :param_bonus_objects
  232.   def param_bonus_objects
  233.     feature_objects
  234.   end
  235. end
回复 支持 1 反对 0

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-11-6 00:41

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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