Project1

标题: 技能說明顯示特殊變數? [打印本页]

作者: jeff13579    时间: 2014-1-24 21:57
标题: 技能說明顯示特殊變數?
我的技能說明是
"造成(攻擊X0.5+2)點物理傷害"
假設我人物攻擊是60
有辦法讓說明直接顯示
"造成(32)點物理傷害"嗎?
說明文要隨能力提升而變動
作者: 喵呜喵5    时间: 2014-1-25 02:10
先加入这段脚本
  1. =begin
  2. #===============================================================================
  3. Title: Convert Code: Eval
  4. Author: Tsukihime
  5. Date: Nov 25, 2013
  6. URL: http://himeworks.wordpress.com/2013/09/17/battle-reactions/
  7. --------------------------------------------------------------------------------
  8. ** Change log
  9. Nov 25, 2013
  10.    - Initial release
  11. --------------------------------------------------------------------------------   
  12. ** Terms of Use
  13. * Free to use in non-commercial projects
  14. * Contact me for commercial use
  15. * No real support. The script is provided as-is
  16. * Will do bug fixes, but no compatibility patches
  17. * Features may be requested but no guarantees, especially if it is non-trivial
  18. * Credits to Tsukihime in your project
  19. * Preserve this header
  20. --------------------------------------------------------------------------------
  21. ** Description

  22. This script adds a new convert code to your project called "eval".

  23. You can use this to evaluate arbitrary formulas inside your show text
  24. commands.

  25. --------------------------------------------------------------------------------
  26. ** Installation

  27. In the script editor, place this script below Materials and above Main

  28. --------------------------------------------------------------------------------
  29. ** Usage

  30. In your show text command, use the convert code

  31.     \eval[FORMULA}

  32. The formula will be evaluated when the message is being processed and the
  33. appropriate value will be displayed.

  34. The following formula variables are available

  35.    p - game party
  36.    t - game troop
  37.    s - game switches
  38.    v - game variables

  39. Note that the text is not automatically re-positioned to fill in the gaps.
  40.   
  41. #===============================================================================
  42. =end
  43. $imported = {} if $imported.nil?
  44. $imported["TH_ConvertCodeEval"] = true
  45. #===============================================================================
  46. # ** Rest of Script
  47. #===============================================================================
  48. class Window_Base < Window
  49.   
  50.   alias :th_convert_code_eval_convert_escape_characters :convert_escape_characters
  51.   def convert_escape_characters(text)
  52.     result = th_convert_code_eval_convert_escape_characters(text)
  53.     result.gsub!(/\eEVAL\[(.*)\]/i) { eval_convert_code($1) }
  54.     result
  55.   end
  56.   
  57.   def eval_convert_code(formula, p=$game_party, t=$game_troop, s=$game_switches, v=$game_variables)
  58.     eval(formula)
  59.   end
  60. end
复制代码
然后技能说明这么写即可:
造成\eval[(p.leader.atk * 0.5 +2).to_i]點物理傷害


作者: jeff13579    时间: 2014-1-31 01:49
喵呜喵5 发表于 2014-1-25 02:10
先加入这段脚本然后技能说明这么写即可:
造成\eval[(p.leader.atk * 0.5 +2).to_i]點物理傷害

leader的話 應該是指隊長吧
可是如果技能是其他隊員的話 怎麼辦呢?
作者: 喵呜喵5    时间: 2014-1-31 16:12
把p.leader改成p.members[n]:第n+1名队伍成员
改成$game_actors[n]:数据库中第n名角色




欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X3.1