搜索附件  

Data (1).zip

 

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

20180630_备用队伍




20181021_升级随机习得技能




20181030_计时收获




20181122_零散图标合成




20181128_XP图块转VA



20181129_角色入队到指定位置


[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




20181204_空装备栏显示无装备
[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




20181206_地图不加载状态

[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

20181210_地图伤害闪烁修改


[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


20181211_01事件只在区域内活动


[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


20181211_02战斗选项帮助

[Python] 纯文本查看 复制代码
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


20181211_03菜单技能类型帮助
[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


20181215_雾




20181216_开关打开传送
[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


20181218_战斗保持原始色调


[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


20181220_存档界面不显示部分人行走图
[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


20181222_行走图循环动画



20181222_大船水陆两用
[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


20181225_原地不动回血
[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


备用队伍


             本帖来自P1论坛作者KB.Driver,因Project1站服务器在国外有时候访问缓慢不方便作者交流学习,经联系P1站长fux2同意署名转载一起分享游戏制作经验,共同为国内独立游戏作者共同创造良好交流环境,原文地址:https://rpg. blue/forum.php?mod=viewthread&tid=411455  若有侵权,发帖作者可联系底部站长QQ在线咨询功能删除,谢谢。
Loading...

QQ|Archiver|手机版|小黑屋|同能RPG制作大师 ( 沪ICP备12027754号-3 )

GMT+8, 2024-11-22 00:34 , Processed in 0.042591 second(s), 22 queries .

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

返回顶部