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

Project1

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

[已经过期] 萌新求教这脚本是怎样使用的

[复制链接]

Lv1.梦旅人

梦石
0
星屑
20
在线时间
7 小时
注册时间
2021-11-7
帖子
6
跳转到指定楼层
1
发表于 2021-11-7 11:11:17 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
本帖最后由 va萌新 于 2021-11-7 11:18 编辑

尝试了一会没弄懂, 有大佬能帮忙做个示例么
原址: https://www.rpgmakercentral.com/topic/18039-class-switch-system/
RUBY 代码复制
  1. #==============================================================================
  2. # Class Switch System
  3. # Version 1.10
  4. # By Szyu
  5. #
  6. # About:
  7. # Classify and divide your classes into several levels (tier).
  8. # Actors can switch their class when they match the requirements for "higher
  9. # classes". You can also disable classes for actors.
  10. #
  11. # Instructions:
  12. # - Place below "▼ Materials" but above "▼ Main Process".
  13. # - Classes without the NoteTag ">Tier x" won't be shown in any list
  14. #
  15. # How to Use:
  16. # - ">Tier x" tags a class as "switchable class" that can be accessed through
  17. #     the Class Switch System
  18. # - ">Pre: x, y, z" tags a class with the required Class IDs, that must have
  19. #     reached a certain level
  20. # - ">Disabled Actors: x, y, z" tags a class with Actor IDs that are not
  21. #     allowed to switch to the class
  22. #
  23. # Requires:
  24. # - RPG Maker VX Ace
  25. #
  26. # Terms of Use:
  27. # - Free for commercal and non-commercial use. Please list me
  28. #   in the credits to support my work.
  29. #
  30. # Pastebin:
  31. # http://adf.ly/UMYEB
  32. #
  33. #==============================================================
  34. #   * Configuration
  35. #==============================================================
  36.  
  37. # Term shown as entry in Menu
  38. CLASS_SWITCH_TERM = "Class Switch"
  39.  
  40. # Access menu in GameMenu
  41. SCENE_MENU_CSS_ACCESS = true
  42.  
  43. # Categories
  44. CLASS_TIERS = {
  45.         "Warrior"  => [1,5,6],                 # Path 1
  46.         "Cleric"     => [2,7,8],    # Path 2
  47.         "Archer"      => [3,9,10],    # Path 3
  48.         "Novice"       => [4,11,12],  # Path 4
  49. }
  50.  
  51. # Levels at which you can access new Tier
  52. TIER_SWITCH_LEVEL = [9, 15, 30, 50]
  53.  
  54. # At Tier Switch the actors Level will be reset to 1
  55. SWITCH_LEVEL_RESET = true
  56.  
  57. # Keeps all skill when switching class
  58. KEEP_SKILLS = false
  59.  
  60. # Different colors for tier levels
  61. COLORED_TIER_LEVELS = true
  62. #=====================================================================
  63. # Don't edit below this line
  64. #=====================================================================
  65.  
  66. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  67. #==============================================================
  68. #   * Scene_ClassSwitch
  69. #==============================================================
  70. class Scene_ClassSwitch < Scene_MenuBase
  71.  
  72.   def start
  73.     super
  74.     create_actor_status
  75.     create_tier_selection
  76.     create_class_window
  77.   end
  78.  
  79.   def create_actor_status
  80.     @cstatus_window = Window_ClassStatus.new(@actor)
  81.   end
  82.  
  83.   def create_tier_selection
  84.     @command_window = Window_ClassTier.new(0,@cstatus_window.height)#,Graphics.width/2,Graphics.height-@cstatus_window.height)
  85.     @command_window.actor = @actor
  86.     @command_window.set_handler(:class,    method(:command_class))
  87.     @command_window.set_handler(:cancel,   method(:return_scene))
  88.     @command_window.set_handler(:pagedown, method(:next_actor))
  89.     @command_window.set_handler(:pageup,   method(:prev_actor))
  90.   end
  91.  
  92.   def create_class_window
  93.     wx = @command_window.width
  94.     wy = @cstatus_window.height
  95.     ww = Graphics.width - @command_window.width
  96.     wh = Graphics.height - wy
  97.     @item_window = Window_ClassSwitch.new(wx, wy, ww, wh)
  98.     @item_window.actor = @actor
  99.     @item_window.viewport = @viewport
  100.     @item_window.set_handler(:ok,     method(:on_class_ok))
  101.     @item_window.set_handler(:cancel, method(:on_class_cancel))
  102.     @command_window.class_window = @item_window
  103.   end
  104.  
  105.   def command_class
  106.     if @item_window.item_max > 0
  107.       @item_window.activate
  108.       @item_window.select(0)
  109.     else
  110.       @command_window.activate
  111.     end
  112.   end
  113.  
  114.   def on_class_ok
  115.     #switch class
  116.     @actor.change_class(@item_window.item)
  117.     @cstatus_window.refresh
  118.     @item_window.refresh
  119.     @item_window.unselect
  120.     @command_window.activate
  121.   end
  122.  
  123.   def on_class_cancel
  124.     @item_window.unselect
  125.     @command_window.activate
  126.   end
  127.  
  128.   def on_actor_change
  129.     @cstatus_window.actor = @actor
  130.     @item_window.actor = @actor
  131.     @cstatus_window.activate
  132.   end
  133.  
  134. end
  135.  
  136. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  137. #==============================================================
  138. #   * Window_ClassTier
  139. #==============================================================
  140. class Window_ClassTier < Window_Command
  141.  
  142.   attr_reader   :skill_window
  143.  
  144.   def initialize(x, y)
  145.     super(x, y)
  146.     @actor = nil
  147.   end
  148.  
  149.   def window_width
  150.     return 160
  151.   end
  152.  
  153.   def actor=(actor)
  154.     return if @actor == actor
  155.     @actor = actor
  156.     refresh
  157.   end
  158.  
  159.   def visible_line_number
  160.     return 6
  161.   end
  162.  
  163.   def make_command_list
  164.     return unless @actor
  165.     CLASS_TIERS.each_key do |key|
  166.       add_command(key, :class, true, key)
  167.     end
  168.   end
  169.  
  170.   def update
  171.     super
  172.     @class_window.tclass_id = current_ext if @class_window
  173.   end
  174.  
  175.   def class_window=(class_window)
  176.     @class_window = class_window
  177.     update
  178.   end
  179.  
  180. end
  181.  
  182. #==============================================================
  183. #   * Window_ClassSwitch
  184. #==============================================================
  185. class Window_ClassSwitch < Window_Selectable
  186.  
  187.   def initialize(x, y, width, height)
  188.     super
  189.     @actor = nil
  190.     @tclass_id = nil
  191.     @data = []
  192.   end
  193.  
  194.   def actor=(actor)
  195.     return if @actor == actor
  196.     @actor = actor
  197.     refresh
  198.     self.oy = 0
  199.   end
  200.  
  201.   def tclass_id=(tclass_id)
  202.     return if @tclass_id == tclass_id
  203.     @tclass_id = tclass_id
  204.     refresh
  205.     self.oy = 0
  206.   end
  207.  
  208.   def col_max
  209.     return 1
  210.   end
  211.  
  212.   def item_max
  213.     @data ? @data.size : 1
  214.   end
  215.  
  216.   def item
  217.     @data && index >= 0 ? @data[index] : nil
  218.   end
  219.  
  220.   def current_item_enabled?
  221.     return @data[index] > 0 && @actor.class_id != @data[index]
  222.   end
  223.  
  224.   def make_item_list
  225.     @data = @tclass_id  ? CLASS_TIERS[@tclass_id].select {|cl|
  226.       cl != 0 && $data_classes[cl].tier && !actor_disabled_for_class(cl) && class_matches_requirements?(cl)
  227.       } : []
  228.   end
  229.  
  230.   def actor_disabled_for_class(id)
  231.     return false if !$data_classes[id].disabled_actors
  232.     return true if $data_classes[id].disabled_actors.include?(@actor.id.to_s)
  233.   end
  234.  
  235.   def class_matches_requirements?(id)
  236.     return true if @actor.class_exp(id) && @actor.class_exp(id) > 0
  237.     return true if not $data_classes[id].predecessors
  238.     $data_classes[id].predecessors.each do |cl|
  239.       tier = $data_classes[id].tier
  240.       return false if !@actor.class_exp(cl.to_i) ||
  241.       @actor.class_exp(cl.to_i) < $data_classes[cl.to_i].exp_for_level(TIER_SWITCH_LEVEL[(tier <= TIER_SWITCH_LEVEL.size ? tier : TIER_SWITCH_LEVEL.size) - 1])
  242.     end
  243.     return true
  244.   end
  245.  
  246.   def draw_item(index)
  247.     cl = @data[index]
  248.     if cl
  249.       rect = item_rect(index)
  250.       rect.width -= 4
  251.       if COLORED_TIER_LEVELS && $data_classes[@actor.class_id].tier
  252.         change_color(normal_color) if $data_classes[cl].tier == $data_classes[@actor.class_id].tier
  253.         change_color(hp_gauge_color2) if $data_classes[cl].tier < $data_classes[@actor.class_id].tier
  254.         change_color(tp_gauge_color2) if $data_classes[cl].tier == $data_classes[@actor.class_id].tier+1
  255.         change_color(crisis_color) if $data_classes[cl].tier > $data_classes[@actor.class_id].tier+1
  256.       end
  257.       draw_text(rect,$data_classes[cl].name)
  258.     end
  259.   end
  260.  
  261.   def refresh
  262.     make_item_list
  263.     create_contents
  264.     draw_all_items
  265.   end
  266. end
  267.  
  268. #==============================================================
  269. #   * Window_ClassStatus
  270. #==============================================================
  271. class Window_ClassStatus < Window_Selectable
  272.  
  273.   def initialize(actor)
  274.     super(0, 0, Graphics.width, line_height * 10+8)
  275.     @actor = actor
  276.     refresh
  277.     activate
  278.   end
  279.  
  280.   def actor=(actor)
  281.     return if @actor == actor
  282.     @actor = actor
  283.     refresh
  284.   end
  285.  
  286.   def refresh
  287.     contents.clear
  288.     draw_block1   (line_height * 0)
  289.     draw_horz_line(line_height * 1)
  290.     draw_block2   (line_height * 2)
  291.     draw_horz_line(line_height * 6)
  292.     draw_block3   (line_height * 7)
  293.   end
  294.  
  295.   def draw_block1(y)
  296.     draw_actor_name(@actor, 4, y)
  297.     draw_actor_class(@actor, 128, y)
  298.     draw_actor_nickname(@actor, 288, y)
  299.   end
  300.  
  301.   def draw_block2(y)
  302.     draw_actor_face(@actor, 8, y)
  303.     draw_basic_info(136, y)
  304.     draw_exp_info(304, y)
  305.   end
  306.  
  307.   def draw_block3(y)
  308.     draw_description(4, y)
  309.   end
  310.  
  311.   def draw_horz_line(y)
  312.     line_y = y + line_height / 2 - 1
  313.     contents.fill_rect(0, line_y, contents_width, 2, line_color)
  314.   end
  315.  
  316.   def line_color
  317.     color = normal_color
  318.     color.alpha = 48
  319.     color
  320.   end
  321.  
  322.   def draw_basic_info(x, y)
  323.     draw_actor_level(@actor, x, y + line_height * 0)
  324.     draw_actor_icons(@actor, x, y + line_height * 1)
  325.     draw_actor_hp(@actor, x, y + line_height * 2)
  326.     draw_actor_mp(@actor, x, y + line_height * 3)
  327.   end
  328.  
  329.   def draw_exp_info(x, y)
  330.     s1 = @actor.max_level? ? "-------" : @actor.exp
  331.     s2 = @actor.max_level? ? "-------" : @actor.next_level_exp - @actor.exp
  332.     s_next = sprintf(Vocab::ExpNext, Vocab::level)
  333.     change_color(system_color)
  334.     draw_text(x, y + line_height * 0, 180, line_height, Vocab::ExpTotal)
  335.     draw_text(x, y + line_height * 2, 180, line_height, s_next)
  336.     change_color(normal_color)
  337.     draw_text(x, y + line_height * 1, 180, line_height, s1, 2)
  338.     draw_text(x, y + line_height * 3, 180, line_height, s2, 2)
  339.   end
  340.  
  341.   def draw_description(x, y)
  342.     draw_text_ex(x, y, @actor.description)
  343.   end
  344. end
  345.  
  346. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  347. #==============================================================
  348. #   * Actor's Class Levels
  349. #==============================================================
  350. class Game_Actor < Game_Battler
  351.   alias :store_class_level :change_class
  352.  
  353.   def change_class(class_id, keep_exp = false)
  354.     if !KEEP_SKILLS
  355.       self.skills.each do|sk|
  356.         forget_skill(sk.id)
  357.       end
  358.     end
  359.     store_class_level(class_id, !SWITCH_LEVEL_RESET)
  360.  
  361.     self.class.learnings.each do |learning|
  362.       learn_skill(learning.skill_id) if learning.level == @level
  363.     end
  364.   end
  365.  
  366.   def class_exp(class_id)
  367.     return @exp[class_id]
  368.   end
  369.  
  370. end
  371.  
  372. #==============================================================
  373. #   * Add Entry to Menu
  374. #==============================================================
  375. class Scene_Menu < Scene_MenuBase
  376.   alias :command_class_switch :create_command_window
  377.   alias :on_personal_ok_class_switch :on_personal_ok
  378.  
  379.   def create_command_window
  380.     command_class_switch
  381.     @command_window.set_handler(:swclass, method(:command_personal)) if SCENE_MENU_CSS_ACCESS
  382.   end
  383.  
  384.   def on_personal_ok
  385.     on_personal_ok_class_switch
  386.     if SCENE_MENU_CSS_ACCESS
  387.       case @command_window.current_symbol
  388.       when :swclass
  389.         SceneManager.call(Scene_ClassSwitch)
  390.       end
  391.     end
  392.   end
  393.  
  394. end
  395.  
  396. #==============================================================
  397. #   * Add Entry to Menu
  398. #==============================================================
  399. class Window_MenuCommand < Window_Command
  400.   alias :command_class_switch :add_main_commands
  401.  
  402.   def add_main_commands
  403.     command_class_switch
  404.     add_command(CLASS_SWITCH_TERM, :swclass, main_commands_enabled) if SCENE_MENU_CSS_ACCESS
  405.   end
  406. end
  407.  
  408. #==============================================================
  409. #   * RPG Class Availability Extension
  410. #==============================================================
  411. module RPG
  412.   class Class < BaseItem
  413.  
  414.     def tier
  415.       self.note.each_line do |line|
  416.         return line.downcase.gsub(/\d+/).to_a[0].to_i if line.downcase.include?(">tier")
  417.       end
  418.       return nil
  419.     end
  420.  
  421.     def predecessors
  422.       self.note.each_line do |line|
  423.         return line.downcase.gsub(/\d+/).to_a if line.downcase.include?(">pre:")
  424.       end
  425.       return nil
  426.     end
  427.  
  428.     def disabled_actors
  429.       self.note.each_line do |line|
  430.         return line.downcase.gsub(/\d+/).to_a if line.downcase.include?(">disabled actors:")
  431.       end
  432.       return nil
  433.     end
  434.   end
  435. end

评分

参与人数 1+1 收起 理由
哇哇哇啊叭叭 + 1 塞糖

查看全部评分

Lv1.梦旅人

梦石
0
星屑
20
在线时间
7 小时
注册时间
2021-11-7
帖子
6
2
 楼主| 发表于 2021-11-12 14:35:14 | 只看该作者
好心的大佬们能协助一下萌新么
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-11-16 02:19

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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