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

Project1

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

[已经解决] 怎么让技能装备脚本可以切换角色

[复制链接]

Lv4.逐梦者

梦石
0
星屑
5030
在线时间
1321 小时
注册时间
2018-1-16
帖子
383
跳转到指定楼层
1
发表于 2020-10-26 15:27:11 | 只看该作者 回帖奖励 |正序浏览 |阅读模式

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

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

x
如题,有没有大佬帮帮忙,可以让其他队友也可以使用技能装备,而不是只能1号角色使用


RUBY 代码复制
  1. #==============================================================================
  2. # ■ 技能装备系统 for RGSS1 by:VIPArcher
  3. #  -- 本脚本来自 [url]https://rpg.blue[/url] 使用或转载请保留以上信息。
  4. #==============================================================================
  5. #  让技能可以像装备一样装备到角色身上,战斗中仅可使用已经装备的技能,其他场景可
  6. #  以随意使用,技能装备场景技能槽栏激活状态下(如有队友)按左右键切换当前角色。
  7. #  $scene = Scene_SetEquipSkill.new(actor_index, skill_index)   呼出场景。
  8. #  actor_index : 该角色在队伍中的位置 ; skill_index : 技能槽光标的起始位置
  9. #==============================================================================
  10. $VIPArcherScript ||= {};$VIPArcherScript[:battle_skill] = 20150717
  11. #-------------------------------------------------------------------------------
  12. module VIPArcher end
  13. #==============================================================================
  14. # ★ 设定部分 ★
  15. #==============================================================================
  16. module VIPArcher::Battle_Skill
  17.   #技能槽名字
  18.   Skills_Slot_Name = ['技能槽一','技能槽二','技能槽三','技能槽四','技能槽五']
  19.   #可使用的场合名称
  20.   SKILL_OCCASION   = ['平时', '战斗中', '菜单中', '不能使用']
  21.   #效果范围名称
  22.   SKILL_SCOPE      = ['无', '敌单体', '敌全体', '己方单体', '己方全体',
  23.                     '己方单体(战斗不能)', '己方全体(战斗不能)', '使用者']
  24.   #未装备技能时技能槽显示内容
  25.   BLANK_TEXT   = '-  空技能槽  -'
  26.   #空技能槽帮助窗口文本
  27.   BLANK_HELP   = '空的技能槽,可以装备战斗技能。'
  28.   #"[卸下技能]"的图标文件名(不需要则设置为 nil 或 false)
  29.   RELEASE_ICON = '047-Skill04'
  30.   #"[卸下技能]"帮助窗口文本
  31.   RELEASE_HELP = '卸下已装备的技能。'
  32.   #"[卸下技能]"按钮名称
  33.   RELEASE_TEXT = '[卸下技能]'
  34. end
  35. #==============================================================================
  36. # ☆ 设定结束 ☆
  37. #==============================================================================
  38. class Symbol
  39.   def to_proc
  40.     Proc.new { |*args| args.shift.__send__(self, *args) }
  41.   end
  42. end
  43. class Game_Actor < Game_Battler
  44.   include VIPArcher::Battle_Skill
  45.   attr_reader :battle_skill #已装备技能
  46.   alias battle_skill_initialize initialize
  47.   def initialize(actor_id)
  48.     @battle_skill = Array.new(Skills_Slot_Name.size){ nil }
  49.     battle_skill_initialize(actor_id)
  50.   end
  51.   def add_battle_skill(skill,id)
  52.     @battle_skill[id] = nil if skill.zero?
  53.     return if @battle_skill.include?(skill)
  54.     @battle_skill[id] = skill if skills.include?(skill)
  55.   end
  56.   alias battle_skill_learn_skill learn_skill
  57.   def learn_skill(skill_id)
  58.     battle_skill_learn_skill(skill_id)
  59.     auto_add_battle_skill(skill_id) unless @battle_skill.include?(skill_id)
  60.   end
  61.   def auto_add_battle_skill(skill_id)
  62.     @battle_skill.each_index do |index|
  63.       return @battle_skill[index] = skill_id if @battle_skill[index].nil?
  64.     end
  65.   end
  66.   alias battle_skill_forget_skill forget_skill
  67.   def forget_skill(skill_id)
  68.     battle_skill_forget_skill(skill_id)
  69.     if @battle_skill.include?(skill_id)
  70.       @battle_skill[@battle_skill.index(skill_id)] = nil
  71.     end
  72.   end
  73. end
  74. class Window_Selectable < Window_Base
  75.   def create_contents
  76.     self.contents.dispose if self.contents
  77.     self.contents = Bitmap.new(width - 32, row_max * 32)
  78.   end
  79. end
  80. class Window_EquipSkillLeft < Window_Base
  81.   include VIPArcher::Battle_Skill
  82.   def initialize(actor, skill = nil)
  83.     super(0, 64, 272, 192)
  84.     self.contents = Bitmap.new(width - 32, height - 32)
  85.     @actor, [url=home.php?mod=space&uid=260100]@skill[/url] = actor, skill
  86.     refresh
  87.   end
  88.   def refresh
  89.     self.contents.clear
  90.     draw_actor_name(@actor, 4, 0)
  91.     draw_actor_level(@actor, 132, 0)
  92.     draw_skill_info unless @skill.nil?
  93.   end
  94.   def set_skill(skill)
  95.     @skill = skill
  96.     refresh
  97.   end
  98.   def draw_skill_info
  99.     self.contents.font.color = system_color
  100.     self.contents.draw_text(0,  32,  128, 32, '使用场合')
  101.     self.contents.font.color = normal_color
  102.     self.contents.draw_text(32, 64,  128, 32, SKILL_OCCASION[@skill.occasion])
  103.     self.contents.font.color = system_color
  104.     self.contents.draw_text(0,  96,  128, 32, '效果范围')
  105.     self.contents.font.color = normal_color
  106.     self.contents.draw_text(32, 128, 320, 32, SKILL_SCOPE[@skill.scope])
  107.   end
  108. end
  109. class Window_EquipSkillSlot < Window_Selectable
  110.   include VIPArcher::Battle_Skill
  111.   attr_writer   :skill_info_window
  112.   def initialize(actor, skill_index = 0)
  113.     super(272, 64, 368, 192)
  114.     @actor, self.index = actor, skill_index
  115.     refresh
  116.   end
  117.   def data
  118.     @actor.battle_skill
  119.   end
  120.   def item
  121.     data[self.index] ? $data_skills[data[self.index]] : nil
  122.   end
  123.   def refresh
  124.     @item_max = data.size
  125.     create_contents
  126.     self.contents.font.color = system_color
  127.     Skills_Slot_Name.each_with_index do |name,id|
  128.       self.contents.draw_text(4, 32 * id, 92, 32, name)
  129.     end
  130.     data.each_with_index do |skill_id,id|
  131.       if skill_id.nil?
  132.         self.contents.font.color = normal_color
  133.         self.contents.draw_text(128 , 32 * id,192, 32, BLANK_TEXT)
  134.       else
  135.         draw_item_name($data_skills[skill_id], 128, 32 * id)
  136.       end
  137.     end
  138.   end
  139.   def update_help
  140.     @help_window.set_text(item.nil? ? BLANK_HELP : item.description)
  141.     @skill_info_window.set_skill(item) if @skill_info_window
  142.   end
  143. end
  144. class Window_SkillItem < Window_Selectable
  145.   include VIPArcher::Battle_Skill
  146.   attr_writer   :skill_info_window
  147.   def initialize(actor)
  148.     super(0, 256, 640, 224)
  149.     @actor, @column_max, self.active, self.index = actor, 2, false, -1
  150.     refresh
  151.   end
  152.   def item
  153.     @data[self.index] ? $data_skills[@data[self.index]] : nil
  154.   end
  155.   def refresh
  156.     @data  = []
  157.     skills = @actor.skills.select{|skill| !@actor.battle_skill.include?(skill)}
  158.     skills.each{|skill| @data.push(skill) }
  159.     @data.push(nil) # 添加[卸下装备]
  160.     @item_max = @data.size
  161.     create_contents
  162.     @data.each_index{|index| draw_item(index)}
  163.   end
  164.   def draw_item(index)
  165.     x = 4 + index % 2 * (288 + 32)
  166.     y = index/ 2 * 32 #这残念的Sublime Text高亮=。=
  167.     self.contents.font.color = normal_color
  168.     if @data[index]
  169.       skill  = $data_skills[@data[index]]
  170.       bitmap = RPG::Cache.icon(skill.icon_name)
  171.       self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24))
  172.       self.contents.draw_text(x + 28, y, 212, 32, skill.name)
  173.     else
  174.       bitmap = RPG::Cache.icon(RELEASE_ICON) if RELEASE_ICON
  175.       self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24)) if bitmap
  176.       self.contents.draw_text(x + 28, y, 212, 32, RELEASE_TEXT)
  177.     end
  178.   end
  179.   def update_help
  180.     @help_window.set_text(item.nil? ? RELEASE_HELP : item.description)
  181.     @skill_info_window.set_skill(item) if @skill_info_window
  182.   end
  183. end
  184. class Window_Skill < Window_Selectable
  185.   def refresh
  186.     @data = []
  187.     if $scene.instance_of?(Scene_Battle)
  188.       @actor.battle_skill
  189.     else
  190.       @actor.skills
  191.     end.each do |skill|
  192.       @data.push($data_skills[skill]) unless skill.nil?
  193.     end
  194.     @item_max = @data.size
  195.     create_contents unless @item_max.zero?
  196.     @data.each_index{|index| draw_item(index) }
  197.   end
  198. end
  199. class Scene_SetEquipSkill
  200.   def initialize(actor_index = 0, skill_index = 0)
  201.     @actor_index, @skill_index = actor_index, skill_index
  202.   end
  203.   def main
  204.     @actor = $game_party.actors[@actor_index]
  205.     create_all_window
  206.     Graphics.transition
  207.    [Graphics,Input,self].map(&:update) while $scene.equal?(self)
  208.     Graphics.freeze
  209.     dispose_all_window
  210.   end
  211.   def create_all_window
  212.     @help_window      = Window_Help.new
  213.     @right_window     = Window_EquipSkillSlot.new(@actor,@skill_index)
  214.     @left_window      = Window_EquipSkillLeft.new(@actor,@right_window.item)
  215.     @skillitem_window = Window_SkillItem.new(@actor)
  216.     @right_window.help_window     = @help_window
  217.     @skillitem_window.help_window = @help_window
  218.     @right_window.skill_info_window     = @left_window
  219.     @skillitem_window.skill_info_window = @left_window
  220.   end
  221.   def update
  222.     update_all_windows
  223.     return update_right if @right_window.active
  224.     return update_item  if @skillitem_window.active
  225.   end
  226.   def update_right
  227.     return scene_return     if Input.trigger?(Input::B)
  228.     return on_slot_ok       if Input.trigger?(Input::C)
  229.     return process_pagedown if Input.trigger?(Input::RIGHT)
  230.     return process_pageup   if Input.trigger?(Input::LEFT)
  231.   end
  232.   def update_item
  233.     return on_item_cancel if Input.trigger?(Input::B)
  234.     return on_item_ok     if Input.trigger?(Input::C)
  235.   end
  236.   def on_item_ok
  237.     $game_system.se_play($data_system.equip_se)
  238.     skill = @skillitem_window.item
  239.     @actor.add_battle_skill(skill.nil? ? 0 : skill.id,@right_window.index)
  240.     @right_window.active     = true
  241.     @skillitem_window.active = false
  242.     @skillitem_window.index  = -1
  243.     @right_window.refresh
  244.     @skillitem_window.refresh
  245.   end
  246.   def on_item_cancel
  247.     $game_system.se_play($data_system.cancel_se)
  248.     @right_window.active     = true
  249.     @skillitem_window.active = false
  250.     @skillitem_window.index  = -1
  251.   end
  252.   def scene_return
  253.     $game_system.se_play($data_system.cancel_se)
  254.     $scene = Scene_Map.new
  255.   end
  256.   def on_slot_ok
  257.     $game_system.se_play($data_system.decision_se)
  258.     @equipskill_id           = @right_window.index
  259.     @right_window.active     = false
  260.     @skillitem_window.active = true
  261.     @skillitem_window.index  = 0
  262.   end
  263.   def process_pageup
  264.     $game_system.se_play($data_system.cursor_se)
  265.     @actor_index += $game_party.actors.size - 1
  266.     @actor_index %= $game_party.actors.size
  267.     $scene = Scene_SetEquipSkill.new(@actor_index, @right_window.index)
  268.   end
  269.   def process_pagedown
  270.     $game_system.se_play($data_system.cursor_se)
  271.     @actor_index += 1
  272.     @actor_index %= $game_party.actors.size
  273.     $scene = Scene_SetEquipSkill.new(@actor_index, @right_window.index)
  274.   end
  275.   def update_all_windows
  276.     instance_variables.each do |varname|
  277.       ivar = instance_variable_get(varname)
  278.       ivar.update if ivar.is_a?(Window)
  279.     end
  280.   end
  281.   def dispose_all_window
  282.     instance_variables.each do |varname|
  283.       ivar = instance_variable_get(varname)
  284.       ivar.dispose if ivar.is_a?(Window)
  285.     end
  286.   end
  287. end
  288. class Interpreter
  289.   #--------------------------------------------------------------------------
  290.   # ● 条件分支
  291.   #--------------------------------------------------------------------------
  292.   alias battle_skill_command_111 command_111
  293.   def command_111
  294.     result = false
  295.     # 条件判定
  296.     if [@parameters[0],@parameters[2]] == [4,2]
  297.       actor = $game_actors[@parameters[1]]
  298.       if actor != nil
  299.         if $scene.instance_of?(Scene_Battle)
  300.           result = (actor.battle_skill.include?(@parameters[3]))
  301.         else
  302.           result = (actor.skill_learn?(@parameters[3]))
  303.         end
  304.       end
  305.       # 判断结果保存在 hash 中
  306.       @branch[@list[@index].indent] = result
  307.       # 判断结果为真的情况下
  308.       if @branch[@list[@index].indent] == true
  309.         # 删除分支数据
  310.         @branch.delete(@list[@index].indent)
  311.         # 继续
  312.         return true
  313.       end
  314.       # 不符合条件的情况下 : 指令跳转
  315.       return command_skip
  316.     else
  317.       battle_skill_command_111
  318.     end
  319.   end
  320. end

Lv4.逐梦者

梦石
0
星屑
6483
在线时间
119 小时
注册时间
2020-1-8
帖子
234
2
发表于 2020-10-26 16:26:48 | 只看该作者
用这脚本新开工程能切换其他角色啊 你怎么用的……
修改处有明显标志 你可以打开看看
不过85行报错
改为@actor,@skill = actor, skill

1111.zip

203.23 KB, 下载次数: 59

点评

咳咳咳,谢了,我没注意看脚本,已经修改了按键  发表于 2020-10-26 16:36
咦,那为什么,我每个键都按了一遍,发现都没有切换,,,,  发表于 2020-10-26 16:34

评分

参与人数 2星屑 +50 +1 收起 理由
RyanBern + 50 认可答案
l734273398 + 1 认可答案

查看全部评分

回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-9-20 20:26

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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