查看: 1831|回复: 3

[已经解决] 武器备注栏如何使用变量

[复制链接]
梦石
0
星屑
1081
在线时间
105 小时
注册时间
2023-5-3
回帖
2
发表于 2023-5-20 00:04:32 | 显示全部楼层 |阅读模式

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

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

×
如题.请教各位大佬
现在是<atk:+000>这种我试过替换变量\v[00]不可行
我主要是想把一个武器攻击力设置为一个数值加变量的攻击力.要在游戏中能随变量变化
梦石
0
星屑
29896
在线时间
5733 小时
注册时间
2016-3-8
回帖
1653
发表于 2023-5-20 01:04:19 | 显示全部楼层
本帖最后由 alexncf125 于 2023-5-20 20:03 编辑

找个说明书有写可以用变量的脚本
[fold=https://himeworks.com/2014/03/equip-param-formulas/][pre lang="ruby"]=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[/pre][/fold]


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
回复 1 0

使用道具 举报

梦石
0
星屑
1081
在线时间
105 小时
注册时间
2023-5-3
回帖
2
 楼主| 发表于 2023-5-20 18:57:42 | 显示全部楼层
alexncf125 发表于 2023-5-20 01:04
找个说明书有写可以用变量的脚本
https://himeworks.com/2014/03/equip-param-formulas/

谢谢.可是打不开,可能要加速器吧

点评

已编辑  发表于 2023-5-20 20:04
回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部