赞 | 159 |
VIP | 0 |
好人卡 | 0 |
积分 | 262 |
经验 | 0 |
最后登录 | 2024-11-5 |
在线时间 | 5348 小时 |
Lv5.捕梦者
- 梦石
- 0
- 星屑
- 26204
- 在线时间
- 5348 小时
- 注册时间
- 2016-3-8
- 帖子
- 1655
|
本帖最后由 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>
#============================================================================== # ■ VXAce-RGSS3-6 撃破数カウンタ [Ver.1.0.0] by Claimh #------------------------------------------------------------------------------ # 各アクターが倒したエネミーの数をカウントします。 #------------------------------------------------------------------------------ #・ウィンドウ上に表示させる #Widow_Statusなどに追記してください。 #<記述> # draw_defeat_count(actor_id, enemy_id, x, y) # actor_id :対象アクターID(0を指定すると全アクター) # enemy_id :対象エネミーID(0を指定すると全エネミー) # x :横方向の表示位置 # y :縦方向の表示位置 #------------------------------------------------------------------------------ #・変数に入れる #イベントのスクリプト上に記述してください。 #<記述> # input_defeat_count(actor_id, enemy_id, variable_id) # actor_id :対象アクターID(0を指定すると全アクター) # enemy_id :対象エネミーID(0を指定すると全エネミー) # variable_id :撃破数を入れる変数 #============================================================================== module DefeatCounter ## 他スクリプトとの併用のために残す #-------------------------------------------------------------------------- # ● 指定アクターの撃破数 # actor_id :対象アクターID(0を指定すると全アクター) # enemy_id :対象エネミーID(0を指定すると全エネミー) #-------------------------------------------------------------------------- def self.defeat_count(actor_id=0, enemy_id=0) return $game_actors.defeat(enemy_id, actor_id) end end class Game_Actor < Game_Battler #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- alias initialize_defeat_count initialize def initialize(actor_id) initialize_defeat_count(actor_id) @defeat = {} end #-------------------------------------------------------------------------- # ● 撃破数取得 #-------------------------------------------------------------------------- def defeat(enemy_id=0) return defeat_all if enemy_id == 0 @defeat[enemy_id] = 0 unless @defeat.keys.include?(enemy_id) return @defeat[enemy_id] end #-------------------------------------------------------------------------- # ● 撃破数取得 #-------------------------------------------------------------------------- def defeat_all @defeat.keys.inject(0) { |n, id| n += @defeat[id] } end #-------------------------------------------------------------------------- # ● 撃破数カウント #-------------------------------------------------------------------------- def defeat_cnt(enemy_id) return if enemy_id == 0 @defeat[enemy_id] = 0 unless @defeat.keys.include?(enemy_id) @defeat[enemy_id] += 1 end end class Game_Actors #-------------------------------------------------------------------------- # ● 撃破数取得 #-------------------------------------------------------------------------- def defeat(enemy_id=0, actor_id=0) return defeat_all(enemy_id) if actor_id == 0 return self.[](actor_id).defeat(enemy_id) end #-------------------------------------------------------------------------- # ● 撃破数取得 #-------------------------------------------------------------------------- def defeat_all(enemy_id=0) @data.inject(0) { |n, actor| n += (actor.nil? ? 0 : actor.defeat(enemy_id)) } end end #============================================================================== # ■ Game_Battler #============================================================================== class Game_Battler < Game_BattlerBase #-------------------------------------------------------------------------- # ● ダメージの処理 # 呼び出し前に @result.hp_damage @result.mp_damage @result.hp_drain # @result.mp_drain が設定されていること。 #-------------------------------------------------------------------------- alias execute_damage_defeat execute_damage def execute_damage(user) execute_damage_defeat(user) return if actor? or !dead? or user.enemy? return if $game_troop.enable_dead_count?(self.index) $game_troop.defeat_dead_count(self.index) user.defeat_cnt(self.enemy_id) end end #============================================================================== # ■ Game_Troop #============================================================================== class Game_Troop < Game_Unit #-------------------------------------------------------------------------- # ● セットアップ #-------------------------------------------------------------------------- alias setup_defeat setup def setup(troop_id) setup_defeat(troop_id) @enemy_defeat = [] end #-------------------------------------------------------------------------- # ● 撃破時のカウント #-------------------------------------------------------------------------- def defeat_dead_count(index) @enemy_defeat[index] = true end #-------------------------------------------------------------------------- # ● 既にカウント済み? #-------------------------------------------------------------------------- def enable_dead_count?(index) @enemy_defeat[index] || false end end class Game_Interpreter #-------------------------------------------------------------------------- # ● 指定した変数にアクターの撃破数を格納する # actor_id :対象アクター(0を指定すると全アクター) # enemy_id :対象エネミー(0を指定すると全エネミー) # variable_id :撃破数を格納する変数 #-------------------------------------------------------------------------- def input_defeat_count(actor_id, enemy_id, variable_id) $game_variables[variable_id] = $game_actors.defeat(enemy_id, actor_id) return true end end class Window_Base < Window #-------------------------------------------------------------------------- # ● 指定した変数にアクターの撃破数を表示する # actor_id :対象アクター(0を指定すると全アクター) # enemy_id :対象エネミー(0を指定すると全エネミー) # x :横方向の表示位置 # y :縦方向の表示位置 #-------------------------------------------------------------------------- def draw_defeat_count(actor_id, enemy_id, x, y) draw_text(x, y, 200, line_height, $game_actors.defeat(enemy_id, actor_id), 2) end end
#==============================================================================
# ■ VXAce-RGSS3-6 撃破数カウンタ [Ver.1.0.0] by Claimh
#------------------------------------------------------------------------------
# 各アクターが倒したエネミーの数をカウントします。
#------------------------------------------------------------------------------
#・ウィンドウ上に表示させる
#Widow_Statusなどに追記してください。
#<記述>
# draw_defeat_count(actor_id, enemy_id, x, y)
# actor_id :対象アクターID(0を指定すると全アクター)
# enemy_id :対象エネミーID(0を指定すると全エネミー)
# x :横方向の表示位置
# y :縦方向の表示位置
#------------------------------------------------------------------------------
#・変数に入れる
#イベントのスクリプト上に記述してください。
#<記述>
# input_defeat_count(actor_id, enemy_id, variable_id)
# actor_id :対象アクターID(0を指定すると全アクター)
# enemy_id :対象エネミーID(0を指定すると全エネミー)
# variable_id :撃破数を入れる変数
#==============================================================================
module DefeatCounter ## 他スクリプトとの併用のために残す
#--------------------------------------------------------------------------
# ● 指定アクターの撃破数
# actor_id :対象アクターID(0を指定すると全アクター)
# enemy_id :対象エネミーID(0を指定すると全エネミー)
#--------------------------------------------------------------------------
def self.defeat_count(actor_id=0, enemy_id=0)
return $game_actors.defeat(enemy_id, actor_id)
end
end
class Game_Actor < Game_Battler
#--------------------------------------------------------------------------
# ● オブジェクト初期化
#--------------------------------------------------------------------------
alias initialize_defeat_count initialize
def initialize(actor_id)
initialize_defeat_count(actor_id)
@defeat = {}
end
#--------------------------------------------------------------------------
# ● 撃破数取得
#--------------------------------------------------------------------------
def defeat(enemy_id=0)
return defeat_all if enemy_id == 0
@defeat[enemy_id] = 0 unless @defeat.keys.include?(enemy_id)
return @defeat[enemy_id]
end
#--------------------------------------------------------------------------
# ● 撃破数取得
#--------------------------------------------------------------------------
def defeat_all
@defeat.keys.inject(0) { |n, id| n += @defeat[id] }
end
#--------------------------------------------------------------------------
# ● 撃破数カウント
#--------------------------------------------------------------------------
def defeat_cnt(enemy_id)
return if enemy_id == 0
@defeat[enemy_id] = 0 unless @defeat.keys.include?(enemy_id)
@defeat[enemy_id] += 1
end
end
class Game_Actors
#--------------------------------------------------------------------------
# ● 撃破数取得
#--------------------------------------------------------------------------
def defeat(enemy_id=0, actor_id=0)
return defeat_all(enemy_id) if actor_id == 0
return self.[](actor_id).defeat(enemy_id)
end
#--------------------------------------------------------------------------
# ● 撃破数取得
#--------------------------------------------------------------------------
def defeat_all(enemy_id=0)
@data.inject(0) { |n, actor| n += (actor.nil? ? 0 : actor.defeat(enemy_id)) }
end
end
#==============================================================================
# ■ Game_Battler
#==============================================================================
class Game_Battler < Game_BattlerBase
#--------------------------------------------------------------------------
# ● ダメージの処理
# 呼び出し前に @result.hp_damage @result.mp_damage @result.hp_drain
# @result.mp_drain が設定されていること。
#--------------------------------------------------------------------------
alias execute_damage_defeat execute_damage
def execute_damage(user)
execute_damage_defeat(user)
return if actor? or !dead? or user.enemy?
return if $game_troop.enable_dead_count?(self.index)
$game_troop.defeat_dead_count(self.index)
user.defeat_cnt(self.enemy_id)
end
end
#==============================================================================
# ■ Game_Troop
#==============================================================================
class Game_Troop < Game_Unit
#--------------------------------------------------------------------------
# ● セットアップ
#--------------------------------------------------------------------------
alias setup_defeat setup
def setup(troop_id)
setup_defeat(troop_id)
@enemy_defeat = []
end
#--------------------------------------------------------------------------
# ● 撃破時のカウント
#--------------------------------------------------------------------------
def defeat_dead_count(index)
@enemy_defeat[index] = true
end
#--------------------------------------------------------------------------
# ● 既にカウント済み?
#--------------------------------------------------------------------------
def enable_dead_count?(index)
@enemy_defeat[index] || false
end
end
class Game_Interpreter
#--------------------------------------------------------------------------
# ● 指定した変数にアクターの撃破数を格納する
# actor_id :対象アクター(0を指定すると全アクター)
# enemy_id :対象エネミー(0を指定すると全エネミー)
# variable_id :撃破数を格納する変数
#--------------------------------------------------------------------------
def input_defeat_count(actor_id, enemy_id, variable_id)
$game_variables[variable_id] = $game_actors.defeat(enemy_id, actor_id)
return true
end
end
class Window_Base < Window
#--------------------------------------------------------------------------
# ● 指定した変数にアクターの撃破数を表示する
# actor_id :対象アクター(0を指定すると全アクター)
# enemy_id :対象エネミー(0を指定すると全エネミー)
# x :横方向の表示位置
# y :縦方向の表示位置
#--------------------------------------------------------------------------
def draw_defeat_count(actor_id, enemy_id, x, y)
draw_text(x, y, 200, line_height, $game_actors.defeat(enemy_id, actor_id), 2)
end
end
=begin #=============================================================================== Title: Parameter Bonuses Author: Hime Date: Aug 1, 2014 URL: [url]http://himeworks.com/2013/12/09/parameter-bonuses/[/url] -------------------------------------------------------------------------------- ** Change log Aug 1, 2014 - added a reference to the tagged object Jul 24, 2014 - added support for class, armors, weapons, and states Dec 20, 2013 - added support for "recursive" references - added support for passing in the base parameter - added support for enemy parameter bonuses Dec 9, 2013 - initial release -------------------------------------------------------------------------------- ** Terms of Use * Free to use in non-commercial projects * Contact me for commercial use * No real support. The script is provided as-is * Will do bug fixes, but no compatibility patches * Features may be requested but no guarantees, especially if it is non-trivial * Credits to Hime Works in your project * Preserve this header -------------------------------------------------------------------------------- ** Description This script allows you to define "Parameter bonuses" for your actors and enemies. A paramter bonus is simply a bonus that will be added to your parameters based on a formula. The bonus itself could be an increase, or even a decrease in stats if you provide a negative value. For example, suppose you had custom parameters that allowed you to define stats like "strength" or "intelligence", where str increases your atk and max HP params while int increases magic attack and magic defense stats. You can use parameter bonuses to define formulas that will allow your str and int stats to contribute to the other parameters. Since the parameter bonus can be any formula, you can define bonuses based on anything. Parameter bonuses can be defined in actors, classes, weapons, armors, states, and enemies. Actors will inherit any bonuses defined in their class, equips, and states. Enemies will inherit any bonuses defined in their states. Because equips and states can be changed, you can use this to create unique effects. -------------------------------------------------------------------------------- ** Installation In the script editor, place this script below Materials and above Main -------------------------------------------------------------------------------- ** Usage To define a parameter bonus, note-tag actors with <param bonus: TYPE> FORMULA </param bonus> Where the TYPE is one of mhp - max HP mmp - max MP atk - attack def - defense mat - magic attack mdf - magic defense agi - agility luk - luck And the formula can be any valid ruby formula. The following formula variables are available a - the current battler (actor or enemy) obj - the tagged object p - game party t - game troop v - game variables s - game switches You can have a bonus reference itself. For example <param bonus: atk> a.atk * 1.5 </param bonus> Will increase the battler's atk value by 50%. This atk value does not include the bonus, but includes base params and extra params. You can define multiple parameter bonuses for an actor, and you can define multiple bonuses for the same stat; simply add more of the note-tag. == Object Reference == The `obj` variable is a special variable that you can use to refer to the object that the bonus is attached to. For example, suppose you notetagged a weapon with <param bonus: mhp> obj.params[2] * 10 </param bonus> This means that you receive an HP bonus equal to the weapon's atk times 10. All of the attributes that you can access in a weapon is available. If the bonus is attached to an armor, then `obj` references that armor, and so on. -------------------------------------------------------------------------------- ** Example Suppose we have a custom stat called "str", and for each point of str, it increases HP by 10 and atk by 2. You would use two parameter bonuses: <param bonus: mhp> a.str * 10 </param bonus> <param bonus: atk> a.str * 2 </param bonus> #=============================================================================== =end $imported = {} if $imported.nil? $imported["TH_ParameterBonus"] = true #=============================================================================== # ** Configuration #=============================================================================== module TH module Parameter_Bonuses Regex = /<param[-_ ]bonus:\s*(\w+)\s*>(.*?)<\/param[-_ ]bonus>/im #=============================================================================== # ** Rest of Script #=============================================================================== Table = { :mhp => 0, :mmp => 1, :atk => 2, :def => 3, :mat => 4, :mdf => 5, :agi => 6, :luk => 7 } end end module RPG class BaseItem def param_bonuses load_notetag_param_bonuses unless @param_bonuses return @param_bonuses end def load_notetag_param_bonuses @param_bonuses = [] results = self.note.scan(TH::Parameter_Bonuses::Regex) results.each do |res| param = res[0].downcase.to_sym formula = res[1].strip id = TH::Parameter_Bonuses::Table[param] data = Data_ParamBonus.new(id, formula, self) @param_bonuses << data end end end end class Data_ParamBonus attr_accessor :param_id attr_accessor :formula attr_accessor :obj def initialize(param_id, formula="0", obj) @param_id = param_id @formula = formula @obj = obj end def value(a, p=$game_party, t=$game_troop, s=$game_switches, v=$game_variables) eval(@formula) end end class Game_BattlerBase def param_bonus_objects states end alias :th_param_bonuses_param_plus :param_plus def param_plus(param_id) th_param_bonuses_param_plus(param_id) + param_bonus(param_id) end #----------------------------------------------------------------------------- # Calculates the bonus parameter. #----------------------------------------------------------------------------- def param_bonus(param_id) return 0 if @check_param_bonus @check_param_bonus = true val = param_bonus_objects.inject(0) do |r, bonus_obj| bonus_obj.param_bonuses.inject(r) do |r2, obj| obj.param_id == param_id ? r2 += obj.value(self) : r2 end end @check_param_bonus = false return val end end class Game_Actor < Game_Battler alias :th_parameter_bonuses_param_bonus_objects :param_bonus_objects def param_bonus_objects feature_objects end end class Game_Enemy < Game_Battler alias :th_parameter_bonuses_param_bonus_objects :param_bonus_objects def param_bonus_objects feature_objects end end
=begin
#===============================================================================
Title: Parameter Bonuses
Author: Hime
Date: Aug 1, 2014
URL: [url]http://himeworks.com/2013/12/09/parameter-bonuses/[/url]
--------------------------------------------------------------------------------
** Change log
Aug 1, 2014
- added a reference to the tagged object
Jul 24, 2014
- added support for class, armors, weapons, and states
Dec 20, 2013
- added support for "recursive" references
- added support for passing in the base parameter
- added support for enemy parameter bonuses
Dec 9, 2013
- initial release
--------------------------------------------------------------------------------
** Terms of Use
* Free to use in non-commercial projects
* Contact me for commercial use
* No real support. The script is provided as-is
* Will do bug fixes, but no compatibility patches
* Features may be requested but no guarantees, especially if it is non-trivial
* Credits to Hime Works in your project
* Preserve this header
--------------------------------------------------------------------------------
** Description
This script allows you to define "Parameter bonuses" for your actors and
enemies. A paramter bonus is simply a bonus that will be added to your
parameters based on a formula. The bonus itself could be an increase, or
even a decrease in stats if you provide a negative value.
For example, suppose you had custom parameters that allowed you to define
stats like "strength" or "intelligence", where str increases your atk and
max HP params while int increases magic attack and magic defense stats. You
can use parameter bonuses to define formulas that will allow your str and int
stats to contribute to the other parameters.
Since the parameter bonus can be any formula, you can define bonuses based
on anything.
Parameter bonuses can be defined in actors, classes, weapons, armors, states,
and enemies. Actors will inherit any bonuses defined in their class, equips,
and states. Enemies will inherit any bonuses defined in their states.
Because equips and states can be changed, you can use this to create unique
effects.
--------------------------------------------------------------------------------
** Installation
In the script editor, place this script below Materials and above Main
--------------------------------------------------------------------------------
** Usage
To define a parameter bonus, note-tag actors with
<param bonus: TYPE>
FORMULA
</param bonus>
Where the TYPE is one of
mhp - max HP
mmp - max MP
atk - attack
def - defense
mat - magic attack
mdf - magic defense
agi - agility
luk - luck
And the formula can be any valid ruby formula.
The following formula variables are available
a - the current battler (actor or enemy)
obj - the tagged object
p - game party
t - game troop
v - game variables
s - game switches
You can have a bonus reference itself. For example
<param bonus: atk>
a.atk * 1.5
</param bonus>
Will increase the battler's atk value by 50%. This atk value does not
include the bonus, but includes base params and extra params.
You can define multiple parameter bonuses for an actor, and you can define
multiple bonuses for the same stat; simply add more of the note-tag.
== Object Reference ==
The `obj` variable is a special variable that you can use to refer
to the object that the bonus is attached to. For example, suppose
you notetagged a weapon with
<param bonus: mhp>
obj.params[2] * 10
</param bonus>
This means that you receive an HP bonus equal to the weapon's atk times 10.
All of the attributes that you can access in a weapon is available.
If the bonus is attached to an armor, then `obj` references that armor, and
so on.
--------------------------------------------------------------------------------
** Example
Suppose we have a custom stat called "str", and for each point of str, it
increases HP by 10 and atk by 2. You would use two parameter bonuses:
<param bonus: mhp>
a.str * 10
</param bonus>
<param bonus: atk>
a.str * 2
</param bonus>
#===============================================================================
=end
$imported = {} if $imported.nil?
$imported["TH_ParameterBonus"] = true
#===============================================================================
# ** Configuration
#===============================================================================
module TH
module Parameter_Bonuses
Regex = /<param[-_ ]bonus:\s*(\w+)\s*>(.*?)<\/param[-_ ]bonus>/im
#===============================================================================
# ** Rest of Script
#===============================================================================
Table = {
:mhp => 0,
:mmp => 1,
:atk => 2,
:def => 3,
:mat => 4,
:mdf => 5,
:agi => 6,
:luk => 7
}
end
end
module RPG
class BaseItem
def param_bonuses
load_notetag_param_bonuses unless @param_bonuses
return @param_bonuses
end
def load_notetag_param_bonuses
@param_bonuses = []
results = self.note.scan(TH::Parameter_Bonuses::Regex)
results.each do |res|
param = res[0].downcase.to_sym
formula = res[1].strip
id = TH::Parameter_Bonuses::Table[param]
data = Data_ParamBonus.new(id, formula, self)
@param_bonuses << data
end
end
end
end
class Data_ParamBonus
attr_accessor :param_id
attr_accessor :formula
attr_accessor :obj
def initialize(param_id, formula="0", obj)
@param_id = param_id
@formula = formula
@obj = obj
end
def value(a, p=$game_party, t=$game_troop, s=$game_switches, v=$game_variables)
eval(@formula)
end
end
class Game_BattlerBase
def param_bonus_objects
states
end
alias :th_param_bonuses_param_plus :param_plus
def param_plus(param_id)
th_param_bonuses_param_plus(param_id) + param_bonus(param_id)
end
#-----------------------------------------------------------------------------
# Calculates the bonus parameter.
#-----------------------------------------------------------------------------
def param_bonus(param_id)
return 0 if @check_param_bonus
@check_param_bonus = true
val = param_bonus_objects.inject(0) do |r, bonus_obj|
bonus_obj.param_bonuses.inject(r) do |r2, obj|
obj.param_id == param_id ? r2 += obj.value(self) : r2
end
end
@check_param_bonus = false
return val
end
end
class Game_Actor < Game_Battler
alias :th_parameter_bonuses_param_bonus_objects :param_bonus_objects
def param_bonus_objects
feature_objects
end
end
class Game_Enemy < Game_Battler
alias :th_parameter_bonuses_param_bonus_objects :param_bonus_objects
def param_bonus_objects
feature_objects
end
end
|
|