查看: 5064|回复: 4

[原创发布] 2018回答小脚本汇总

[复制链接]
梦石
10
星屑
39550
在线时间
1919 小时
注册时间
2010-11-14
回帖
3214

R考场第七期纪念奖

发表于 2019-1-5 23:22:36 | 显示全部楼层 |阅读模式

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

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

×
本帖最后由 KB.Driver 于 2019-1-8 03:40 编辑

2018年下半年接触了RGSS3后在论坛回答了一些小问题,在这里汇个总,欢迎抱走(

20180630_备用队伍
演示效果.gif

20180630_备用队伍.zip (153 Bytes, 下载次数: 20)
之前发的代码有bug,新的代码请以工程内容为准。


20181021_升级随机习得技能
效果.gif
Data.zip (206.96 KB, 下载次数: 29)


20181030_计时收获
演示效果.gif
Data.zip (207.44 KB, 下载次数: 88)


20181122_零散图标合成
演示.gif
20181122_零散图标合成.zip (1.45 MB, 下载次数: 60)


20181128_XP图块转VA
演示.gif
20181128_XP图块转VA.zip (1.43 MB, 下载次数: 63)


20181129_角色入队到指定位置
演示.gif
  1. class Game_Party
  2.   #--------------------------------------------------------------------------
  3.   # ● 角色入队到指定位置
  4.   #--------------------------------------------------------------------------
  5.   #  使用方法:
  6.   #    事件脚本 $game_party.cld99_add_actor(id,pos)
  7.   #       id:角色的数据库id
  8.   #      pos:角色入队的位置 队首为0 其他依次递增 缺省值为队尾
  9.   #       例: $game_party.cld99_add_actor(1,0) #让数据库id为1的艾里克加入队首
  10.   #--------------------------------------------------------------------------
  11.   def cld99_add_actor(actor_id, position = @actors.length)
  12.     @actors.insert(position,actor_id) unless @actors.include?(actor_id)
  13.     $game_player.refresh
  14.     $game_map.need_refresh = true
  15.   end
  16. end
复制代码



20181204_空装备栏显示无装备
  1. class Window_EquipSlot < Window_Selectable
  2.   #--------------------------------------------------------------------------
  3.   # ● 绘制物品名称
  4.   #     enabled : 有效的标志。false 的时候使用半透明效果绘制
  5.   #--------------------------------------------------------------------------
  6.   alias :cld99_draw_item_name :draw_item_name
  7.   def draw_item_name(item, x, y, enabled = true, width = 172)
  8.     if item
  9.       cld99_draw_item_name(item, x, y, enabled, width)
  10.     else
  11.       change_color(normal_color, enabled)
  12.       draw_text(x + 24, y, width, line_height, "无装备")
  13.     end
  14.   end
  15. end
复制代码



20181206_地图不加载状态
ezgif.com-optimize.gif
  1. class Game_Actor
  2.   STATES_NOT_LOAD = [2]   
  3.   #不在地图上加载的状态(不起效也不解除)
  4. end

  5. class Game_Actor
  6.   #--------------------------------------------------------------------------
  7.   # ● 更新状态的步数计数
  8.   #--------------------------------------------------------------------------
  9.   def update_state_steps(state)
  10.     if state.remove_by_walking
  11.       @state_steps[state.id] -= 1 if @state_steps[state.id] > 0
  12.       remove_state(state.id) if @state_steps[state.id] == 0
  13.       #p state.name + "还剩余#{@state_steps[state.id].to_i}步解除"
  14.     end
  15.   end
  16.   #--------------------------------------------------------------------------
  17.   # ● 角色移动一步时的处理
  18.   #--------------------------------------------------------------------------
  19.   def on_player_walk
  20.     #puts "on_player_walk"
  21.     @result.clear
  22.     check_floor_effect
  23.     if $game_player.normal_walk?
  24.       turn_end_on_map
  25.       states.each {|state| update_state_steps(state) unless STATES_NOT_LOAD.include?(state.id)}
  26.       show_added_states
  27.       show_removed_states
  28.     end
  29.   end
  30.   #--------------------------------------------------------------------------
  31.   # ● 地图画面上回合结束的处理
  32.   #--------------------------------------------------------------------------
  33.   def turn_end_on_map
  34.     if $game_party.steps % steps_for_turn == 0
  35.       #puts "turn_end_on_map"
  36.       STATES_NOT_LOAD.each{|state_id| @not_load = true if state?(state_id)}
  37.       on_turn_end unless @not_load
  38.       @not_load = false
  39.       #puts ""
  40.       perform_map_damage_effect if @result.hp_damage > 0
  41.     end
  42.   end
  43.   
  44. end
复制代码



20181210_地图伤害闪烁修改
演示.gif
  1. module CLD99_SCREEN_FLASH
  2.   
  3.   COLOR = Color.new(255,0,0,64)
  4.   #在此设置闪烁的颜色 Color.new(R,G,B,A) 默认值:Color.new(255,0,0,128)
  5.   #R 红 G 绿 B 蓝 A 不透明度
  6.   #最小值0 最大值255 超出范围的值会自动修正
  7.   
  8.   DURATION = 8
  9.   #颜色闪烁所用的帧数(60帧=1秒) 默认值:8
  10.   
  11.   SWI = 1
  12.   #此开关开启时,伤害地形闪烁颜色随机化
  13.   
  14.   def self.random
  15.     Color.new(rand(255),rand(255),rand(255),128)
  16.   end
  17.   
  18. end

  19. class Game_Screen
  20.   #--------------------------------------------------------------------------
  21.   # ● 开始闪烁(慢性伤害和有害地形用)
  22.   #--------------------------------------------------------------------------
  23.   def start_flash_for_damage
  24.     flash_color = $game_switches[CLD99_SCREEN_FLASH::SWI] ? CLD99_SCREEN_FLASH.random : CLD99_SCREEN_FLASH::COLOR
  25.     start_flash(flash_color, CLD99_SCREEN_FLASH::DURATION)
  26.   end
  27. end
复制代码



20181211_01事件只在区域内活动
演示.gif
  1. class Game_CharacterBase
  2.   #--------------------------------------------------------------------------
  3.   # ● 限制事件活动范围
  4.   #
  5.   # 使用方法:在事件的移动路线中用自定义,选脚本,
  6.   #           添加一句 @region = n
  7.   #           则该事件只能在地图上区域n内移动
  8.   #--------------------------------------------------------------------------
  9.   alias :cld99_passable? :passable?
  10.   def passable?(x, y, d)
  11.     if self.is_a?(Game_Event)
  12.       x2 = $game_map.round_x_with_direction(x, d)
  13.       y2 = $game_map.round_y_with_direction(y, d)
  14.       return false if @region && $game_map.region_id(x2, y2) != @region
  15.     end
  16.     return cld99_passable?(x, y, d)
  17.   end
  18. end
复制代码



20181211_02战斗选项帮助
演示.gif
  1. module CLD99_ActorCommandHelp
  2.   
  3.   SWI = 1
  4.   #此开关开启时,启用战斗指令选择的帮助
  5.   
  6. end

  7. module Vocab
  8.   
  9.   # 战斗指令选择的帮助
  10.   AttackHelp = "普通攻击"                        #攻击 的帮助
  11.   
  12.   SkillHelp  = [nil,   #不要删除此行
  13.                 "用武力使出的特技",                    #技能 的帮助
  14.                 "魔法师通过咏唱咒语操纵元素之力的技能"  #魔法 的帮助
  15.   ]        
  16.   
  17.   GuardHelp  = "一回合内进行防御,受到的伤害减半"  #防御 的帮助
  18.   
  19.   ItemHelp   = "使用背包里的物品"                 #物品 的帮助
  20.   
  21.   
  22. end

  23. #◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆

  24. class Scene_Battle < Scene_Base
  25.   #--------------------------------------------------------------------------
  26.   # ● 生成所有窗口
  27.   #--------------------------------------------------------------------------
  28.   def create_all_windows
  29.     create_message_window
  30.     create_scroll_text_window
  31.     create_log_window
  32.     create_status_window
  33.     create_info_viewport
  34.     create_party_command_window
  35.     #create_actor_command_window 原来的位置
  36.     create_help_window
  37.     create_actor_command_window #现在的位置
  38.     create_skill_window
  39.     create_item_window
  40.     create_actor_window
  41.     create_enemy_window
  42.   end
  43.   #--------------------------------------------------------------------------
  44.   # ● 生成角色指令窗口
  45.   #--------------------------------------------------------------------------
  46.   def create_actor_command_window
  47.     @actor_command_window = Window_ActorCommand.new(@help_window, @info_viewport)
  48.     #加入了帮助窗口和viewport的初始化
  49.     @actor_command_window.viewport = @info_viewport
  50.     @actor_command_window.set_handler(:attack, method(:command_attack))
  51.     @actor_command_window.set_handler(:skill,  method(:command_skill))
  52.     @actor_command_window.set_handler(:guard,  method(:command_guard))
  53.     @actor_command_window.set_handler(:item,   method(:command_item))
  54.     @actor_command_window.set_handler(:cancel, method(:prior_command))
  55.     @actor_command_window.x = Graphics.width
  56.   end
  57.   #--------------------------------------------------------------------------
  58.   # ● 开始角色指令的选择
  59.   #--------------------------------------------------------------------------
  60.   def start_actor_command_selection
  61.     @status_window.select(BattleManager.actor.index)
  62.     @party_command_window.close
  63.     @actor_command_window.setup(BattleManager.actor)
  64.     @actor_command_window.show.active
  65.     #加入帮助窗口的显示
  66.   end
  67.   #--------------------------------------------------------------------------
  68.   # ● 开始队伍指令的选择
  69.   #--------------------------------------------------------------------------
  70.   def start_party_command_selection
  71.     unless scene_changing?
  72.       refresh_status
  73.       @status_window.unselect
  74.       @status_window.open
  75.       if BattleManager.input_start
  76.         @actor_command_window.hide    #加了这一句
  77.         @actor_command_window.close
  78.         @party_command_window.setup
  79.       else
  80.         @party_command_window.deactivate
  81.         turn_start
  82.       end
  83.     end
  84.   end
  85.   #--------------------------------------------------------------------------
  86.   # ● 技能“取消”
  87.   #--------------------------------------------------------------------------
  88.   def on_skill_cancel
  89.     @skill_window.hide
  90.     @actor_command_window.activate
  91.     @actor_command_window.show.active #加了这一句
  92.   end
  93.   #--------------------------------------------------------------------------
  94.   # ● 物品“取消”
  95.   #--------------------------------------------------------------------------
  96.   def on_item_cancel
  97.     @item_window.hide
  98.     @actor_command_window.activate
  99.     @actor_command_window.show.active #加了这一句
  100.   end
  101.   #--------------------------------------------------------------------------
  102.   # ● 指令“防御”
  103.   #--------------------------------------------------------------------------
  104.   def command_guard
  105.     BattleManager.actor.input.set_guard
  106.     @actor_command_window.hide    #加了这一句
  107.     next_command
  108.   end
  109. end

  110. class Window_Command < Window_Selectable
  111.   #--------------------------------------------------------------------------
  112.   # ● 添加指令
  113.   #     name    : 指令名称
  114.   #     symbol  : 对应的符号
  115.   #     enabled : 有效状态的标志
  116.   #     ext     : 任意的扩展数据
  117.   #     help    : 选项帮助
  118.   #--------------------------------------------------------------------------
  119.   def add_command(name, symbol, enabled = true, ext = nil, help = nil)
  120.     @list.push({:name=>name, :symbol=>symbol, :enabled=>enabled, :ext=>ext, :help=>help})
  121.   end
  122.   
  123.   #--------------------------------------------------------------------------
  124.   # ● 获取选项的帮助
  125.   #--------------------------------------------------------------------------
  126.   def current_help
  127.     current_data ? current_data[:help] : nil
  128.   end
  129. end
  130.   
  131. class Window_ActorCommand < Window_Command
  132.   #--------------------------------------------------------------------------
  133.   # ● 初始化对象
  134.   #--------------------------------------------------------------------------
  135.   alias :cld99_initialize :initialize
  136.   def initialize(help_window, info_viewport)
  137.     cld99_initialize
  138.     @help_window = help_window
  139.     @info_viewport = info_viewport
  140.   end
  141.   #--------------------------------------------------------------------------
  142.   # ● 显示窗口
  143.   #--------------------------------------------------------------------------
  144.   def show
  145.     return self unless show_help?
  146.     @help_window.show
  147.     super
  148.   end
  149.   #--------------------------------------------------------------------------
  150.   # ● 隐藏窗口
  151.   #--------------------------------------------------------------------------
  152.   def hide
  153.     return self unless show_help?
  154.     @help_window.hide
  155.     super
  156.   end
  157.   #--------------------------------------------------------------------------
  158.   # ● 更新帮助内容
  159.   #--------------------------------------------------------------------------
  160.   def update_help
  161.     return unless show_help?
  162.     @help_window.set_text(current_help)
  163.   end
  164.   #--------------------------------------------------------------------------
  165.   # ● 显示帮助内容
  166.   #--------------------------------------------------------------------------
  167.   def show_help?
  168.     #return true  ####
  169.     $game_switches[CLD99_ActorCommandHelp::SWI]
  170.   end
  171.   #--------------------------------------------------------------------------
  172.   # ● 添加攻击指令
  173.   #--------------------------------------------------------------------------
  174.   def add_attack_command
  175.      add_command(Vocab::attack, :attack, @actor.attack_usable?,nil, Vocab::AttackHelp)
  176.   end
  177.   #--------------------------------------------------------------------------
  178.   # ● 添加技能指令
  179.   #--------------------------------------------------------------------------
  180.   def add_skill_commands
  181.     @actor.added_skill_types.sort.each do |stype_id|
  182.       name = $data_system.skill_types[stype_id]
  183.         add_command(name, :skill, true, stype_id, Vocab::SkillHelp[stype_id])
  184.     end
  185.   end
  186.   #--------------------------------------------------------------------------
  187.   # ● 添加防御指令
  188.   #--------------------------------------------------------------------------
  189.   def add_guard_command
  190.     add_command(Vocab::guard, :guard, @actor.guard_usable?,nil,Vocab::GuardHelp)
  191.   end
  192.   #--------------------------------------------------------------------------
  193.   # ● 添加物品指令
  194.   #--------------------------------------------------------------------------
  195.   def add_item_command
  196.     add_command(Vocab::item, :item,true,nil,Vocab::ItemHelp)
  197.   end
  198. end
复制代码




20181211_03菜单技能类型帮助

  1. module CLD99_SkillCommandHelp
  2.   
  3.   SWI = 1
  4.   #此开关开启时,启用技能类型选择的帮助
  5.   
  6. end

  7. module Vocab

  8.   SkillHelp  = [nil,   #不要删除此行
  9.                 "用武力使出的特技",                    #技能 的帮助
  10.                 "魔法师通过咏唱咒语操纵元素之力的技能"  #魔法 的帮助
  11.   ]        

  12. end

  13. #◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆

  14. class Window_Command < Window_Selectable
  15.   #--------------------------------------------------------------------------
  16.   # ● 添加指令
  17.   #     name    : 指令名称
  18.   #     symbol  : 对应的符号
  19.   #     enabled : 有效状态的标志
  20.   #     ext     : 任意的扩展数据
  21.   #     help    : 选项帮助
  22.   #--------------------------------------------------------------------------
  23.   def add_command(name, symbol, enabled = true, ext = nil, help = nil)
  24.     @list.push({:name=>name, :symbol=>symbol, :enabled=>enabled, :ext=>ext, :help=>help})
  25.   end
  26.   
  27.   #--------------------------------------------------------------------------
  28.   # ● 获取选项的帮助
  29.   #--------------------------------------------------------------------------
  30.   def current_help
  31.     current_data ? current_data[:help] : nil
  32.   end
  33. end

  34. class Window_SkillCommand < Window_Command
  35.   #--------------------------------------------------------------------------
  36.   # ● 更新帮助内容
  37.   #--------------------------------------------------------------------------
  38.   def update_help
  39.     return unless show_help?
  40.     @help_window.set_text(current_help)
  41.   end
  42.   #--------------------------------------------------------------------------
  43.   # ● 显示帮助内容
  44.   #--------------------------------------------------------------------------
  45.   def show_help?
  46.     $game_switches[CLD99_SkillCommandHelp::SWI]
  47.   end
  48.   #--------------------------------------------------------------------------
  49.   # ● 生成指令列表
  50.   #--------------------------------------------------------------------------
  51.   def make_command_list
  52.     return unless @actor
  53.     @actor.added_skill_types.sort.each do |stype_id|
  54.       name = $data_system.skill_types[stype_id]
  55.       add_command(name, :skill, true, stype_id, Vocab::SkillHelp[stype_id]) #这里新增
  56.     end
  57.   end
  58.   
  59. end
复制代码



20181215_雾
演示.gif
20181215_雾.zip (1.5 MB, 下载次数: 25)



20181216_开关打开传送

  1. class Game_Map
  2.   #--------------------------------------------------------------------------
  3.   # ● 刷新
  4.   #--------------------------------------------------------------------------
  5.   alias cld99_refresh refresh
  6.   def refresh
  7.     extra_logic1
  8.     cld99_refresh
  9.   end  

  10.   def extra_logic1
  11.     return unless $game_switches[1]
  12.     map_id = 1
  13.     x = 12
  14.     y = 4
  15.     $game_player.reserve_transfer(map_id, x, y)
  16.     $game_temp.fade_type = 2   
  17.     $game_switches[1] = false
  18.   end
  19. end
复制代码



20181218_战斗保持原始色调
演示.gif
  1. class Game_Troop
  2.   #--------------------------------------------------------------------------
  3.   # ● 初始化画面的色调
  4.   #--------------------------------------------------------------------------
  5.   def init_screen_tone
  6.     $last_tone = $game_map.screen.tone
  7.     @screen.start_tone_change(Tone.new, 0) if $game_map
  8.   end
  9. end

  10. class Scene_Battle
  11.   #--------------------------------------------------------------------------
  12.   # ● 结束处理
  13.   #--------------------------------------------------------------------------
  14.   alias cld99_terminate terminate
  15.   def terminate
  16.     $game_map.screen.start_tone_change($last_tone,0) if $last_tone
  17.     $last_tone = nil
  18.     cld99_terminate
  19.   end
  20. end
复制代码



20181220_存档界面不显示部分人行走图

  1. class Game_Party
  2.   #--------------------------------------------------------------------------
  3.   # ● 存档文件显示用的角色图像信息
  4.   #--------------------------------------------------------------------------
  5.   def characters_for_savefile
  6.     new_members = battle_members.reject{|actor| actor.id > 9}
  7.     new_members.collect do |actor|
  8.       [actor.character_name, actor.character_index]
  9.     end
  10.   end
  11. end
复制代码



20181222_行走图循环动画
1.gif
20181222_行走图循环动画.zip (1.43 MB, 下载次数: 20)


20181222_大船水陆两用

  1. class Game_Player
  2.   #--------------------------------------------------------------------------
  3.   # ● 判定地图能否通行
  4.   #     d : 方向(2,4,6,8)
  5.   #--------------------------------------------------------------------------
  6.   alias :cld99_map_passable? :map_passable?
  7.   def map_passable?(x, y, d)
  8.     walk_passable = super
  9.     passable = cld99_map_passable?(x, y, d)
  10.     passable || ( @vehicle_type == :ship ? walk_passable : 0)
  11.   end
  12. end
复制代码



20181225_原地不动回血
  1. class Scene_Map
  2.   alias cld99_update update
  3.   def update
  4.     cld99_update
  5.     update_recover_hp
  6.   end
  7.   
  8.   def update_recover_hp
  9.     @time ||= 0
  10.     Input.dir4 == 0 ? @time += 1 : @time = 0
  11.     if @time == 300
  12.       #puts "5秒过去了"
  13.       $game_party.members.each do |actor|
  14.         actor.change_hp(actor.mhp / 5, true)
  15.         #puts "#{actor.name}回复了#{actor.mhp / 5}HP"
  16.       end
  17.       @time = 0
  18.     end      
  19.   end
  20. end
复制代码

20180630_备用队伍.zip

1.43 MB, 下载次数: 120

评分

参与人数 12星屑 +100 赞 +12 收起 理由
Morbie.WS + 1 精品文章
风缠云 + 1 认可答案
明净碎翼 + 1 精品文章
RMVXA + 1
garfeng + 1 塞糖
蹲厕所的女孩 + 1 塞糖
VIPArcher + 100 + 1 精品文章
plain666 + 1 塞糖
张咚咚 + 1 塞糖
Nil2018 + 1 醋虾

查看全部评分

用头画头像,用脚写脚本

老鹰

梦石
40
星屑
38044
在线时间
7127 小时
注册时间
2012-5-26
回帖
3306

极短24评委极短23参与极短22参与极短21评委老司机慢点开短篇十吟唱者组别冠军开拓者剧作品鉴家

发表于 2019-1-6 00:12:54 | 显示全部楼层
惊了 还有汇总的
不过这种帖子内的折叠在搜索里搜的到吗
回复

使用道具 举报

梦石
0
星屑
26338
在线时间
1602 小时
注册时间
2016-1-6
回帖
3444

超评测参与极短28参与极短27参与极短26参与极短25参与

发表于 2019-1-6 15:26:56 | 显示全部楼层
内容不少啊,挺实用的。
回复

使用道具 举报

梦石
0
星屑
955
在线时间
84 小时
注册时间
2018-12-18
回帖
83
发表于 2019-1-21 13:51:18 | 显示全部楼层
搜藏了哈哈
回复

使用道具 举报

梦石
0
星屑
15106
在线时间
2234 小时
注册时间
2019-1-24
回帖
964

R考场第七期纪念奖

发表于 2019-2-5 16:28:42 | 显示全部楼层
收藏了,好东西
回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部