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

Project1

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

[已经解决] 詢問在事件腳本中更改屬性抗性以及攻擊次數

[复制链接]

Lv2.观梦者

梦石
0
星屑
312
在线时间
67 小时
注册时间
2014-4-17
帖子
20
跳转到指定楼层
1
发表于 2020-8-17 02:41:52 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
想要透過事件中的腳本,更改屬性抗性以及攻擊次數,不過翻不到相關的代碼。

假設希望角色ID1的

屬性ID3的抗性增加10%,以及攻擊次數增加1次,,請問各位大佬這該如何呼叫呢?

Lv5.捕梦者

梦石
0
星屑
26098
在线时间
5260 小时
注册时间
2016-3-8
帖子
1652
2
发表于 2020-8-17 10:39:38 | 只看该作者
本帖最后由 alexncf125 于 2020-8-17 10:43 编辑

http://himeworks.com/2013/07/feature-conditions/

脚本的简介与使用方法请自行翻译,我就不误作说明了

RUBY 代码复制
  1. =begin
  2. #===============================================================================
  3.  Title: Feature Conditions
  4.  Author: Hime
  5.  Date: Nov 22, 2014
  6. --------------------------------------------------------------------------------
  7.  ** Change log
  8.  Nov 22, 2014
  9.    - fixed bug where conditions were always false
  10.  Nov 14, 2014
  11.    - added checks to prevent recursive calls
  12.  Jul 10, 2014
  13.    - added support for tagging multiple features in one note-tag
  14.  Jul 9, 2014
  15.    - added support for individual features
  16.  Jul 16, 2013
  17.    - Initial release
  18. --------------------------------------------------------------------------------   
  19.  ** Terms of Use
  20.  * Free to use in non-commercial projects
  21.  * Contact me for commercial use
  22.  * No real support. The script is provided as-is
  23.  * Will do bug fixes, but no compatibility patches
  24.  * Features may be requested but no guarantees, especially if it is non-trivial
  25.  * Credits to Hime Works in your project
  26.  * Preserve this header
  27. --------------------------------------------------------------------------------
  28.  ** Description
  29.  
  30.  This script allows you to add "feature conditions" to any objects that hold
  31.  features. These conditions are used to control whether the features from an
  32.  object are applied to your actor or not.
  33.  
  34.  For example, suppose you have shield equips that have special elemental
  35.  immunities when the "guard" state is applied. You can add these features to
  36.  the shield and then use feature conditions to indicate that the "guard" state
  37.  must be applied before the features are transferred.
  38.  
  39.  Feature conditions can be applied at the object level, which means all
  40.  conditions must be met for any features to be applied.
  41.  
  42.  Feature conditions can also be applied at the feature level, which provides
  43.  finer control over when specific features can be applied.
  44.  
  45. --------------------------------------------------------------------------------
  46.  ** Installation
  47.  
  48.  Place this script below Materials and above Main
  49.  
  50. --------------------------------------------------------------------------------
  51.  ** Usage
  52.  
  53.  To add a feature conditions, use the notetag for any objects with features,
  54.  such as Actors, Classes, Weapons, Armors, Enemies, or States. If you are using
  55.  the Feature Manager, then it will be applied to skills and items as well.
  56.  
  57.  == Object-level feature conditions ==
  58.  
  59.  For object-level conditions, use the note-tag of the form
  60.  
  61.    <feature condition>
  62.       FORMULA
  63.    </feature condition>
  64.    
  65.  For any valid ruby formula that returns true or false.
  66.  Three variables are available for your convenience:
  67.  
  68.    a - subject the feature applies to
  69.    s - game switches
  70.    v - game variables
  71.    
  72.  By "subject" I refer to "actor" or "enemy". For example, a state can be applied
  73.  to both actors or enemies, so if the enemy has the state, then that enemy is
  74.  the subject. If the actor has the state, then that actor is the subject. Be
  75.  careful when writing your formulas.
  76.  
  77.  == Feature-level conditions ==
  78.  
  79.  Applying conditions to individual features is the same as object-level
  80.  conditions, except in the note-tag you specify which feature it applies to
  81.  
  82.    <feature condition: x>
  83.      FORMULA
  84.    </feature condition>
  85.  
  86.    <feature condition: x, y, ... >
  87.      FORMULA
  88.    </feature condition>
  89.    
  90.  Where x and y are the ID's of the features. The ID of the feature is based on
  91.  its position in the list, so the feature at the top of the list has ID 1, the
  92.  next one has ID 2, and so on.
  93.  
  94.  You can specify multiple ID's by separating them with commas.
  95.    
  96. --------------------------------------------------------------------------------
  97.  ** Examples
  98.  
  99.  Here are some quick examples of some conditions you might have
  100.  
  101.  * Feature 2 and 3 are applied only if the party has more than 5000 gold
  102.  
  103.    <feature condition: 2,3 >
  104.      $game_party.gold > 5000
  105.    </feature condition>
  106.     
  107.  * Features of the object are only applied if state 23 is applied
  108.  
  109.    <feature condition>
  110.      a.state?(23)
  111.    </feature condition>
  112.  
  113. #===============================================================================
  114. =end
  115. $imported = {} if $imported.nil?
  116. $imported["TH_FeatureConditions"] = true
  117. #===============================================================================
  118. # ** Configuration
  119. #===============================================================================
  120. module TH
  121.   module Feature_Conditions
  122.     Regex = /<feature[-_ ]condition>(.*?)<\/feature[-_ ]condition>/im
  123.     Ft_Regex = /<feature[-_ ]condition:\s*(.*?)\s*>(.*?)<\/feature[-_ ]condition>/im
  124.   end
  125. end
  126. #===============================================================================
  127. # ** Rest of Script
  128. #===============================================================================
  129. module RPG
  130.   class BaseItem
  131.     def feature_conditions_met?(subject)
  132.       load_notetag_feature_conditions unless @feature_conditions_loaded
  133.       return eval_feature_conditions(subject)
  134.     end
  135.  
  136.     def load_notetag_feature_conditions
  137.       @feature_conditions_loaded = true
  138.       conditions = "true"
  139.       res = self.note.scan(TH::Feature_Conditions::Regex)
  140.       res.each_with_index do |cond, i|
  141.         conditions << " && " if i > 0
  142.         conditions << cond[0]
  143.       end
  144.       build_condition_method(conditions.empty? ? "true" : conditions)      
  145.       load_notetag_individual_feature_conditions
  146.     end
  147.  
  148.     def load_notetag_individual_feature_conditions
  149.       results = self.note.scan(TH::Feature_Conditions::Ft_Regex)
  150.       results.each do |res|
  151.         ids = res[0].strip.split(",")
  152.         ids.each do |id|
  153.           id = id.to_i - 1
  154.           @features[id].feature_condition = res[1]
  155.         end
  156.       end
  157.     end
  158.  
  159.     #---------------------------------------------------------------------------
  160.     # Builds the condition-checking method. This is done for performance
  161.     # reasons since features are checked several hundred times very frequently.
  162.     # It assumes the conditions do not change dynamically once they have been
  163.     # loaded.
  164.     #---------------------------------------------------------------------------
  165.     def build_condition_method(conditions)
  166.       eval(
  167.         "def eval_feature_conditions(a, v=$game_variables, s=$game_switches)
  168.            #{conditions}
  169.          end"
  170.       )
  171.     end
  172.   end
  173.  
  174.   class BaseItem::Feature
  175.     attr_accessor :feature_condition
  176.  
  177.     def feature_condition_met?(subject)
  178.       return true unless @feature_condition
  179.       eval_feature_condition(subject)
  180.     end
  181.  
  182.     def eval_feature_condition(a, v=$game_variables, s=$game_switches)
  183.       eval(@feature_condition)
  184.     end
  185.   end
  186. end
  187.  
  188. class Game_BattlerBase
  189.  
  190.   def feature_conditions_met?(obj, subject)
  191.     obj.feature_conditions_met?(subject)
  192.   end
  193.  
  194.   alias :th_feature_conditions_all_features :all_features
  195.   def all_features   
  196.     return [] if @feature_eval_checking
  197.     @feature_eval_checking = true
  198.     fts = th_feature_conditions_all_features.select {|ft| ft.feature_condition_met?(self)}
  199.     @feature_eval_checking = false
  200.     return fts
  201.   end
  202. end
  203.  
  204. class Game_Actor < Game_Battler
  205.  
  206.   alias :th_feature_conditions_feature_objects :feature_objects
  207.   def feature_objects
  208.     fts = th_feature_conditions_feature_objects.select {|obj|
  209.       feature_conditions_met?(obj, self)
  210.     }
  211.     return fts
  212.   end
  213. end
  214.  
  215. class Game_Enemy < Game_Battler
  216.  
  217.   alias :th_feature_conditions_feature_objects :feature_objects
  218.   def feature_objects
  219.     fts = th_feature_conditions_feature_objects.select {|obj|
  220.       feature_conditions_met?(obj, self)
  221.     }
  222.     return fts   
  223.   end
  224. end

点评

我研究看看 不過目前只看出他好像是標住在備註欄裡面的形式..  发表于 2020-8-18 01:16
回复 支持 1 反对 0

使用道具 举报

Lv5.捕梦者

梦石
0
星屑
26098
在线时间
5260 小时
注册时间
2016-3-8
帖子
1652
3
发表于 2020-8-18 02:25:15 | 只看该作者
啊这...在角色ID1的特性加上"攻击次数增加1次",备注栏里面备注
<feature condition: 1 >
  s[13] == true
</feature condition>
之后在地图上透过事件中的脚本,把某开关例如13号开关打开关闭.你会发现,
13号开关打开时,角色ID1的攻击次数增加至2次,13号开关关闭时,会变回1次
这不就搖身一变,成了你说的"透過事件中的脚本"么??
回复 支持 1 反对 0

使用道具 举报

Lv2.观梦者

梦石
0
星屑
312
在线时间
67 小时
注册时间
2014-4-17
帖子
20
4
 楼主| 发表于 2020-8-18 09:38:21 | 只看该作者
alexncf125 发表于 2020-8-18 02:25
啊这...在角色ID1的特性加上"攻击次数增加1次",备注栏里面备注

  s[13] == true

對自己的笨感到無地自容
我完全沒轉過來,完全沒這樣想..(一直想著往code的方式去加)
非常感恩大佬
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2025-6-3 03:23

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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