查看: 4999|回复: 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
[pre lang="ruby"]class Game_Party
  #--------------------------------------------------------------------------
  # ● 角色入队到指定位置
  #--------------------------------------------------------------------------
  #  使用方法:
  #    事件脚本 $game_party.cld99_add_actor(id,pos)
  #       id:角色的数据库id
  #      pos:角色入队的位置 队首为0 其他依次递增 缺省值为队尾
  #       例: $game_party.cld99_add_actor(1,0) #让数据库id为1的艾里克加入队首
  #--------------------------------------------------------------------------
  def cld99_add_actor(actor_id, position = @actors.length)
    @actors.insert(position,actor_id) unless @actors.include?(actor_id)
    $game_player.refresh
    $game_map.need_refresh = true
  end
end[/pre]


20181204_空装备栏显示无装备
[pre lang="ruby"]class Window_EquipSlot < Window_Selectable
  #--------------------------------------------------------------------------
  # ● 绘制物品名称
  #     enabled : 有效的标志。false 的时候使用半透明效果绘制
  #--------------------------------------------------------------------------
  alias :cld99_draw_item_name :draw_item_name
  def draw_item_name(item, x, y, enabled = true, width = 172)
    if item
      cld99_draw_item_name(item, x, y, enabled, width)
    else
      change_color(normal_color, enabled)
      draw_text(x + 24, y, width, line_height, "无装备")
    end
  end
end
[/pre]


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

class Game_Actor
  #--------------------------------------------------------------------------
  # ● 更新状态的步数计数
  #--------------------------------------------------------------------------
  def update_state_steps(state)
    if state.remove_by_walking
      @state_steps[state.id] -= 1 if @state_steps[state.id] > 0
      remove_state(state.id) if @state_steps[state.id] == 0
      #p state.name + "还剩余#{@state_steps[state.id].to_i}步解除"
    end
  end
  #--------------------------------------------------------------------------
  # ● 角色移动一步时的处理
  #--------------------------------------------------------------------------
  def on_player_walk
    #puts "on_player_walk"
    @result.clear
    check_floor_effect
    if $game_player.normal_walk?
      turn_end_on_map
      states.each {|state| update_state_steps(state) unless STATES_NOT_LOAD.include?(state.id)}
      show_added_states
      show_removed_states
    end
  end
  #--------------------------------------------------------------------------
  # ● 地图画面上回合结束的处理
  #--------------------------------------------------------------------------
  def turn_end_on_map
    if $game_party.steps % steps_for_turn == 0
      #puts "turn_end_on_map"
      STATES_NOT_LOAD.each{|state_id| @not_load = true if state?(state_id)}
      on_turn_end unless @not_load
      @not_load = false
      #puts ""
      perform_map_damage_effect if @result.hp_damage > 0
    end
  end
  
end[/pre]


20181210_地图伤害闪烁修改
演示.gif
[pre lang="ruby"]module CLD99_SCREEN_FLASH
  
  COLOR = Color.new(255,0,0,64)
  #在此设置闪烁的颜色 Color.new(R,G,B,A) 默认值:Color.new(255,0,0,128)
  #R 红 G 绿 B 蓝 A 不透明度
  #最小值0 最大值255 超出范围的值会自动修正
  
  DURATION = 8
  #颜色闪烁所用的帧数(60帧=1秒) 默认值:8
  
  SWI = 1
  #此开关开启时,伤害地形闪烁颜色随机化
  
  def self.random
    Color.new(rand(255),rand(255),rand(255),128)
  end
  
end

class Game_Screen
  #--------------------------------------------------------------------------
  # ● 开始闪烁(慢性伤害和有害地形用)
  #--------------------------------------------------------------------------
  def start_flash_for_damage
    flash_color = $game_switches[CLD99_SCREEN_FLASH::SWI] ? CLD99_SCREEN_FLASH.random : CLD99_SCREEN_FLASH::COLOR
    start_flash(flash_color, CLD99_SCREEN_FLASH::DURATION)
  end
end
[/pre]


20181211_01事件只在区域内活动
演示.gif
[pre lang="ruby"]class Game_CharacterBase
  #--------------------------------------------------------------------------
  # ● 限制事件活动范围
  #
  # 使用方法:在事件的移动路线中用自定义,选脚本,
  #           添加一句 @region = n
  #           则该事件只能在地图上区域n内移动
  #--------------------------------------------------------------------------
  alias :cld99_passable? :passable?
  def passable?(x, y, d)
    if self.is_a?(Game_Event)
      x2 = $game_map.round_x_with_direction(x, d)
      y2 = $game_map.round_y_with_direction(y, d)
      return false if @region && $game_map.region_id(x2, y2) != @region
    end
    return cld99_passable?(x, y, d)
  end
end
[/pre]


20181211_02战斗选项帮助
演示.gif
[pre lang="ruby"]module CLD99_ActorCommandHelp
  
  SWI = 1
  #此开关开启时,启用战斗指令选择的帮助
  
end

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

#◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆

class Scene_Battle < Scene_Base
  #--------------------------------------------------------------------------
  # ● 生成所有窗口
  #--------------------------------------------------------------------------
  def create_all_windows
    create_message_window
    create_scroll_text_window
    create_log_window
    create_status_window
    create_info_viewport
    create_party_command_window
    #create_actor_command_window 原来的位置
    create_help_window
    create_actor_command_window #现在的位置
    create_skill_window
    create_item_window
    create_actor_window
    create_enemy_window
  end
  #--------------------------------------------------------------------------
  # ● 生成角色指令窗口
  #--------------------------------------------------------------------------
  def create_actor_command_window
    @actor_command_window = Window_ActorCommand.new(@help_window, @info_viewport)
    #加入了帮助窗口和viewport的初始化
    @actor_command_window.viewport = @info_viewport
    @actor_command_window.set_handler(:attack, method(:command_attack))
    @actor_command_window.set_handler(:skill,  method(:command_skill))
    @actor_command_window.set_handler(:guard,  method(:command_guard))
    @actor_command_window.set_handler(:item,   method(:command_item))
    @actor_command_window.set_handler(:cancel, method(:prior_command))
    @actor_command_window.x = Graphics.width
  end
  #--------------------------------------------------------------------------
  # ● 开始角色指令的选择
  #--------------------------------------------------------------------------
  def start_actor_command_selection
    @status_window.select(BattleManager.actor.index)
    @party_command_window.close
    @actor_command_window.setup(BattleManager.actor)
    @actor_command_window.show.active
    #加入帮助窗口的显示
  end
  #--------------------------------------------------------------------------
  # ● 开始队伍指令的选择
  #--------------------------------------------------------------------------
  def start_party_command_selection
    unless scene_changing?
      refresh_status
      @status_window.unselect
      @status_window.open
      if BattleManager.input_start
        @actor_command_window.hide    #加了这一句
        @actor_command_window.close
        @party_command_window.setup
      else
        @party_command_window.deactivate
        turn_start
      end
    end
  end
  #--------------------------------------------------------------------------
  # ● 技能“取消”
  #--------------------------------------------------------------------------
  def on_skill_cancel
    @skill_window.hide
    @actor_command_window.activate
    @actor_command_window.show.active #加了这一句
  end
  #--------------------------------------------------------------------------
  # ● 物品“取消”
  #--------------------------------------------------------------------------
  def on_item_cancel
    @item_window.hide
    @actor_command_window.activate
    @actor_command_window.show.active #加了这一句
  end
  #--------------------------------------------------------------------------
  # ● 指令“防御”
  #--------------------------------------------------------------------------
  def command_guard
    BattleManager.actor.input.set_guard
    @actor_command_window.hide    #加了这一句
    next_command
  end
end

class Window_Command < Window_Selectable
  #--------------------------------------------------------------------------
  # ● 添加指令
  #     name    : 指令名称
  #     symbol  : 对应的符号
  #     enabled : 有效状态的标志
  #     ext     : 任意的扩展数据
  #     help    : 选项帮助
  #--------------------------------------------------------------------------
  def add_command(name, symbol, enabled = true, ext = nil, help = nil)
    @list.push({:name=>name, :symbol=>symbol, :enabled=>enabled, :ext=>ext, :help=>help})
  end
  
  #--------------------------------------------------------------------------
  # ● 获取选项的帮助
  #--------------------------------------------------------------------------
  def current_help
    current_data ? current_data[:help] : nil
  end
end
  
class Window_ActorCommand < Window_Command
  #--------------------------------------------------------------------------
  # ● 初始化对象
  #--------------------------------------------------------------------------
  alias :cld99_initialize :initialize
  def initialize(help_window, info_viewport)
    cld99_initialize
    @help_window = help_window
    @info_viewport = info_viewport
  end
  #--------------------------------------------------------------------------
  # ● 显示窗口
  #--------------------------------------------------------------------------
  def show
    return self unless show_help?
    @help_window.show
    super
  end
  #--------------------------------------------------------------------------
  # ● 隐藏窗口
  #--------------------------------------------------------------------------
  def hide
    return self unless show_help?
    @help_window.hide
    super
  end
  #--------------------------------------------------------------------------
  # ● 更新帮助内容
  #--------------------------------------------------------------------------
  def update_help
    return unless show_help?
    @help_window.set_text(current_help)
  end
  #--------------------------------------------------------------------------
  # ● 显示帮助内容
  #--------------------------------------------------------------------------
  def show_help?
    #return true  ####
    $game_switches[CLD99_ActorCommandHelp::SWI]
  end
  #--------------------------------------------------------------------------
  # ● 添加攻击指令
  #--------------------------------------------------------------------------
  def add_attack_command
     add_command(Vocab::attack, :attack, @actor.attack_usable?,nil, Vocab::AttackHelp)
  end
  #--------------------------------------------------------------------------
  # ● 添加技能指令
  #--------------------------------------------------------------------------
  def add_skill_commands
    @actor.added_skill_types.sort.each do |stype_id|
      name = $data_system.skill_types[stype_id]
        add_command(name, :skill, true, stype_id, Vocab::SkillHelp[stype_id])
    end
  end
  #--------------------------------------------------------------------------
  # ● 添加防御指令
  #--------------------------------------------------------------------------
  def add_guard_command
    add_command(Vocab::guard, :guard, @actor.guard_usable?,nil,Vocab::GuardHelp)
  end
  #--------------------------------------------------------------------------
  # ● 添加物品指令
  #--------------------------------------------------------------------------
  def add_item_command
    add_command(Vocab::item, :item,true,nil,Vocab::ItemHelp)
  end
end
[/pre]



20181211_03菜单技能类型帮助

[pre lang="ruby"]module CLD99_SkillCommandHelp
  
  SWI = 1
  #此开关开启时,启用技能类型选择的帮助
  
end

module Vocab

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

end

#◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆

class Window_Command < Window_Selectable
  #--------------------------------------------------------------------------
  # ● 添加指令
  #     name    : 指令名称
  #     symbol  : 对应的符号
  #     enabled : 有效状态的标志
  #     ext     : 任意的扩展数据
  #     help    : 选项帮助
  #--------------------------------------------------------------------------
  def add_command(name, symbol, enabled = true, ext = nil, help = nil)
    @list.push({:name=>name, :symbol=>symbol, :enabled=>enabled, :ext=>ext, :help=>help})
  end
  
  #--------------------------------------------------------------------------
  # ● 获取选项的帮助
  #--------------------------------------------------------------------------
  def current_help
    current_data ? current_data[:help] : nil
  end
end

class Window_SkillCommand < Window_Command
  #--------------------------------------------------------------------------
  # ● 更新帮助内容
  #--------------------------------------------------------------------------
  def update_help
    return unless show_help?
    @help_window.set_text(current_help)
  end
  #--------------------------------------------------------------------------
  # ● 显示帮助内容
  #--------------------------------------------------------------------------
  def show_help?
    $game_switches[CLD99_SkillCommandHelp::SWI]
  end
  #--------------------------------------------------------------------------
  # ● 生成指令列表
  #--------------------------------------------------------------------------
  def make_command_list
    return unless @actor
    @actor.added_skill_types.sort.each do |stype_id|
      name = $data_system.skill_types[stype_id]
      add_command(name, :skill, true, stype_id, Vocab::SkillHelp[stype_id]) #这里新增
    end
  end
  
end[/pre]


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



20181216_开关打开传送

[pre lang="ruby"]class Game_Map
  #--------------------------------------------------------------------------
  # ● 刷新
  #--------------------------------------------------------------------------
  alias cld99_refresh refresh
  def refresh
    extra_logic1
    cld99_refresh
  end  

  def extra_logic1
    return unless $game_switches[1]
    map_id = 1
    x = 12
    y = 4
    $game_player.reserve_transfer(map_id, x, y)
    $game_temp.fade_type = 2   
    $game_switches[1] = false
  end
end[/pre]


20181218_战斗保持原始色调
演示.gif
[pre lang="ruby"]class Game_Troop
  #--------------------------------------------------------------------------
  # ● 初始化画面的色调
  #--------------------------------------------------------------------------
  def init_screen_tone
    $last_tone = $game_map.screen.tone
    @screen.start_tone_change(Tone.new, 0) if $game_map
  end
end

class Scene_Battle
  #--------------------------------------------------------------------------
  # ● 结束处理
  #--------------------------------------------------------------------------
  alias cld99_terminate terminate
  def terminate
    $game_map.screen.start_tone_change($last_tone,0) if $last_tone
    $last_tone = nil
    cld99_terminate
  end
end
[/pre]


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

[pre lang="ruby"]class Game_Party
  #--------------------------------------------------------------------------
  # ● 存档文件显示用的角色图像信息
  #--------------------------------------------------------------------------
  def characters_for_savefile
    new_members = battle_members.reject{|actor| actor.id > 9}
    new_members.collect do |actor|
      [actor.character_name, actor.character_index]
    end
  end
end[/pre]


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


20181222_大船水陆两用

[pre lang="ruby"]class Game_Player
  #--------------------------------------------------------------------------
  # ● 判定地图能否通行
  #     d : 方向(2,4,6,8)
  #--------------------------------------------------------------------------
  alias :cld99_map_passable? :map_passable?
  def map_passable?(x, y, d)
    walk_passable = super
    passable = cld99_map_passable?(x, y, d)
    passable || ( @vehicle_type == :ship ? walk_passable : 0)
  end
end[/pre]


20181225_原地不动回血
[pre lang="ruby"]class Scene_Map
  alias cld99_update update
  def update
    cld99_update
    update_recover_hp
  end
  
  def update_recover_hp
    @time ||= 0
    Input.dir4 == 0 ? @time += 1 : @time = 0
    if @time == 300
      #puts "5秒过去了"
      $game_party.members.each do |actor|
        actor.change_hp(actor.mhp / 5, true)
        #puts "#{actor.name}回复了#{actor.mhp / 5}HP"
      end
      @time = 0
    end      
  end
end[/pre]

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
星屑
37812
在线时间
7091 小时
注册时间
2012-5-26
回帖
3297

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

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

使用道具 举报

梦石
0
星屑
26092
在线时间
1595 小时
注册时间
2016-1-6
回帖
3441

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

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

使用道具 举报

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

使用道具 举报

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

R考场第七期纪念奖

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

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部