| 赞 | 164 |
| VIP | |
| 好人卡 | |
| 积分 | 301 |
| 经验 | |
| 最后登录 | 2026-11-12 |
| 在线时间 | 5741 小时 |
- 梦石
- 0
- 星屑
- 30103
- 在线时间
- 5741 小时
- 注册时间
- 2016-3-8
- 回帖
- 1662
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有账号?注册会员
×
本帖最后由 alexncf125 于 2020-11-14 21:08 编辑
第一个能自动调整装备属性
第二个能手动调整装备属性
因为def params冲突了, 能整合一下么?
- =begin
- #===============================================================================
- Title: Equip Param Formulas
- Author: Hime
- Date: Mar 15, 2014
- URL: [url]http://www.himeworks.com/2014/03/15/equip-param-formulas/[/url]
- --------------------------------------------------------------------------------
- ** Change log
- Mar 15, 2014
- - 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 use formulas to define parameters for weapons and
- armors.
-
- For example, if you were using a script that provided equip levels, you can
- define a formula that uses the level to determine the weapon's parameters.
-
- All attributes that the equip holds can be referenced.
- Formula variables are also available to use.
-
- --------------------------------------------------------------------------------
- ** Installation
-
- Place this script below Materials and above Main
- --------------------------------------------------------------------------------
- ** Usage
-
- To specify a parameter formula, note-tag a weapon or armor with
-
- <param formula: TYPE>
- FORMULA
- </param formula>
-
- Where the TYPE is one of
-
- mhp - Max HP
- mmp - Max MP
- atk - Attack Power
- def - Defense Power
- mat - Magic Attack Power
- mdf - Magic Defense Power
- agi - Agility
- luk - Luck
- The formula can be any valid formula that returns a number
- The following formula variables are available
-
- p - game party
- t - game troop
- s - game switches
- v - game variables
-
- #===============================================================================
- =end
- $imported = {} if $imported.nil?
- $imported[:TH_EquipParamFormulas] = true
- #===============================================================================
- # ** Configuration
- #===============================================================================
- module TH
- module Equip_Param_Formulas
- Ext_Regex = /<param[-_ ]formula:\s*(\w+)\s*>(.*?)<\/param[-_ ]formula>/im
-
- Param_Table = {
- :mhp => 0,
- :mmp => 1,
- :atk => 2,
- :def => 3,
- :mat => 4,
- :mdf => 5,
- :agi => 6,
- :luk => 7
- }
- end
- end
- #===============================================================================
- # ** Rest of Script
- #===============================================================================
- module RPG
- class EquipItem
-
- #---------------------------------------------------------------------------
- # Not the most efficient way to do it but it preserves the interface
- #---------------------------------------------------------------------------
- def params
- load_notetag_param_formulas unless @param_formulas_checked
- return @param_formulas.collect {|f| eval_param_formula(f)}
- end
-
- def eval_param_formula(formula, p=$game_party, s=$game_switches, t=$game_troop, v=$game_variables)
- eval(formula)
- end
-
- def load_notetag_param_formulas
- @param_formulas_checked = true
- @param_formulas = @params.map {|val| val.to_s }
- results = self.note.scan(TH::Equip_Param_Formulas::Ext_Regex)
- results.each do |res|
- type = res[0].strip.downcase.to_sym
- id = TH::Equip_Param_Formulas::Param_Table[type]
- formula = res[1]
- @param_formulas[id] = formula
- end
- end
- end
- end
复制代码- #随意增减装备属性的小插件
- #
- # 脚本说明
- #
- # 属性ID介绍
- #0: 体力上限
- #1: 魔力上限
- #2: 物理攻击
- #3: 物理防御
- #4: 魔法攻击
- #5: 魔法防御
- #6: 敏捷值
- #7: 幸运值
- #
- #装备类型: 武器【:weapon】 护甲【:armor】
- #
- #$game_system.params(武器类型,道具ID,属性ID,属性增减数值)
- #脚本范例↓↓
- #$game_system.params(:weapon,1,3,100) #1号武器物理防御属性增加100点
- #$game_system.params(:armor,1,3,-100) #1号护甲物理防御属性降低100点
- #
- #顺便获取装备属性是可以直接调用系统默认方法 ↓
- #$data_armors[道具ID].params[属性ID] # 护甲
- #$data_weapons[道具ID].params[属性ID] # 武器
- #属性ID与上方脚本说明相同
- #==============================================================================
- # ■ Game_System
- #==============================================================================
- class Game_System
- alias new_initialize initialize
- def initialize
- new_initialize
- @weapon = Array.new($data_weapons.size) {[0]*8}
- @armor = Array.new($data_armors.size) {[0]*8}
- end
- #--------------------------------------------------------------------------
- # ● 额外属性获取方法
- #--------------------------------------------------------------------------
- def params(lei,id,params,par=0)
- return @weapon[id][params] = @weapon[id][params] + par if lei==:weapon
- return @armor[id][params] = @armor[id][params] + par if lei==:armor
- end
- end
- #==============================================================================
- # ■ RPG::EquipItem
- #==============================================================================
- class RPG::EquipItem < RPG::BaseItem
- #--------------------------------------------------------------------------
- # ● 获取武器与护甲的能力数组
- #--------------------------------------------------------------------------
- def params
- data=[]
- @params.size.times {|i| self.is_a?(RPG::Weapon) ?
- data.push(@params[i]+$game_system.params(:weapon,@id,i)) :
- data.push(@params[i]+$game_system.params(:armor,@id,i)) }
- return data
- end
- end
复制代码 |
|