赞 | 0 |
VIP | 0 |
好人卡 | 0 |
积分 | 3 |
经验 | 0 |
最后登录 | 2021-6-20 |
在线时间 | 49 小时 |
Lv2.观梦者
- 梦石
- 0
- 星屑
- 328
- 在线时间
- 49 小时
- 注册时间
- 2021-3-27
- 帖子
- 18
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有帐号?注册会员
x
最近刚刚开始学脚本,用了Hime大神的Equip Param Formulas,想要做一个防具,增加防御力=人物等级*2
脚本(By: Hime)
=begin
#===============================================================================
Title: Equip Param Formulas
Author: Hime
Date: Mar 15, 2014
URL: http://www.himeworks.com/2014/03/15/equip-param-formulas/
--------------------------------------------------------------------------------
** 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
但在公式中写上
<param formula: TYPE>
self.level * 2
</param formula>
后,一接触到这件装备,就
undefined method 'level' for # <RPG::Armor:0x10627964>
试着在后面加入:
def a
SceneManager.scene.is_a?(Scene_Battle) ? BattleManager.actor : $game_party.menu_actor
end
后,将公式改为 a.level * 2,这样在菜单里没有问题,也正是想要的东西,但一进入战斗就又
undefined method 'level' for nil:Nilclass 了。
害怕是因为和以前的脚本冲突,所以试着新开了一个Project,但还是老问题。
新人实在是没办法了,希望有大神能指点一下。如果不行的话,有没有类似效果的脚本? |
|