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

Project1

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

[已经过期] 能不能设计一个再商店买卖画面中能看到的负重脚本

[复制链接]

Lv3.寻梦者

梦石
0
星屑
1085
在线时间
326 小时
注册时间
2012-8-18
帖子
27
跳转到指定楼层
1
发表于 2021-4-21 06:53:16 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
角色有多少空间每种商品个占多少空间

Lv4.逐梦者

梦石
2
星屑
13088
在线时间
2273 小时
注册时间
2011-6-4
帖子
613
2
发表于 2021-4-21 08:28:51 | 只看该作者
首先得有个负重脚本,再谈结合负重的商店设计。
BUG反馈请加QQ 529283039
水友群 917854767

回复 支持 反对

使用道具 举报

Lv3.寻梦者

梦石
0
星屑
1085
在线时间
326 小时
注册时间
2012-8-18
帖子
27
3
 楼主| 发表于 2021-4-21 10:15:26 | 只看该作者
真·可乐 发表于 2021-4-21 08:28
首先得有个负重脚本,再谈结合负重的商店设计。

#===================================
# ○ 使用方法
#-----------------------------------
# 事件中使用【脚本】功能输入以下功能执行相关操作:
#·set_burden_max(max)
#  设置新的最大负重值(初始默认10),括弧里填新的最大值数字
#·refresh_burden
#  刷新总负重值,本方法在获得/失去物品时会自动执行,大概不会在事件中用到。
#
# 宝箱事件中使用条件分歧的【脚本】功能输入:
#·burden_max?
#  判定目前是否已经满负重
#·burden_max?(type, id)
#  判定加上指定类型和ID的项目的负重后是否满负重
#  type:类型(可填的类型有  :item/:weapon/:armor)
#  id  :项目的ID
#
# ※注意:事件中增加物品如果不加满负重判定的话会直接加进去。
#===================================


# 一些事件脚本用的便捷方法
class Interpreter
  def set_burden_max(max)
    $game_party.set_burden_max(max)
  end
  
  def refresh_burden
    $game_party.refresh_burden
  end
  
  def burden_max?(type = nil, id = nil)
    return $game_party.burden_max? unless (type and id)
    return $game_party.test_burden_max?(type, id)
  end
  
end



class Window_Burden < Window_Base
  #-----------------------------------
  # ○ 初始化
  #-----------------------------------
  def initialize
    super(640 - 160, 480 - 64, 160, 64)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.z = 99
    refresh
  end
  #-----------------------------------
  # ○ 刷新
  #-----------------------------------
  def refresh
    return if (@burden == $game_party.burden and @burden_max == $game_party.burden_max)
    @burden = $game_party.burden
    @burden_max = $game_party.burden_max
    self.contents.clear
    self.contents.font.color = system_color
    self.contents.draw_text(0, 0, contents.width, 32, "负重:")
   
    color = @burden >= @burden_max ? Color.new(255, 0, 0) : normal_color
    self.contents.font.color = color
    text = sprintf("%s/%s", @burden, @burden_max)
    self.contents.draw_text(0, 0, contents.width, 32, text, 2)
  end
end


class Scene_Item
  alias sny46_161016_main main
  def main
    @burden_window = Window_Burden.new
    sny46_161016_main
    @burden_window.dispose
  end
  
  alias sny46_161016_update update
  def update
    @burden_window.refresh
    sny46_161016_update
  end
end








# 一些数据扩展
module RPG
  
  # 在物品/武器/防具的说明栏最后面加上“♂重量数值”设置单个项目的重量
  # 不设定的话会使用下面的默认值作为项目的重量
  
  # 默认物品的重量值
  DefaultBurden = 5
  
  class Weapon
    def burden
      num = (@description.split(/♂/)[1] || DefaultBurden)
      return num.to_i
    end
    def description
      return (@description.split(/♂/)[0] || @description)
    end
  end
  class Armor
    def burden
      num = (@description.split(/♂/)[1] || DefaultBurden)
      return num.to_i
    end
    def description
      return (@description.split(/♂/)[0] || @description)
    end
  end
  class Item
    def burden
      num = (@description.split(/♂/)[1] || DefaultBurden)
      return num.to_i
    end
    def description
      return (@description.split(/♂/)[0] || @description)
    end
  end
  
end



class Game_Party
  
  #-----------------------------------
  # ○ 定义俩变量
  #-----------------------------------
  attr_reader :burden
  attr_reader :burden_max
  
  #-----------------------------------
  # ○ 初始化
  #-----------------------------------
  alias sny46_161016_init initialize
  def initialize
    sny46_161016_init
    @burden = 0      # 初始负重值
    @burden_max = 10 # 初始最大负重值
    refresh_burden
  end
  
  #-----------------------------------
  # ○ 增加物品 (减少)
  #-----------------------------------
  alias sny46_161016_gain_item gain_item
  def gain_item(item_id, n)
    sny46_161016_gain_item(item_id, n)
    refresh_burden
  end
  #-----------------------------------
  # ○ 增加武器 (减少)
  #-----------------------------------
  alias sny46_161016_gain_weapon gain_weapon
  def gain_weapon(weapon_id, n)
    sny46_161016_gain_weapon(weapon_id, n)
    refresh_burden
  end
  #-----------------------------------
  # ○ 增加防具 (减少)
  #-----------------------------------
  alias sny46_161016_gain_armor gain_armor
  def gain_armor(armor_id, n)
    sny46_161016_gain_armor(armor_id, n)
    refresh_burden
  end
  
  
  #-----------------------------------
  # ○ 整体刷新当前总负重
  #-----------------------------------
  def refresh_burden
    @burden = 0
    @items.each{|id, num| num.times{@burden += $data_items[id].burden}}
    @weapons.each{|id, num| num.times{@burden += $data_weapons[id].burden}}
    @armors.each{|id, num| num.times{@burden += $data_armors[id].burden}}
  end
  
  #-----------------------------------
  # ○ 设置新的最大负重值
  #-----------------------------------
  def set_burden_max(n)
    @burden_max = n
  end
  
  #-----------------------------------
  # ○ 判定当前是否满负重
  #-----------------------------------
  def burden_max?
    return @burden >= @burden_max
  end
  
  #-----------------------------------
  # ○ 判定加上某个值是否满负重
  #-----------------------------------
  def test_burden_max?(type, id)
    return true if burden_max?
    case type
    when :item
      n = $data_items[id].burden
    when :armor
      n = $data_armors[id].burden
    when :weapon
      n = $data_weapons[id].burden
    else
      n = 0
    end
    return (@burden + n >= @burden_max)
  end
  
end
复制代码
回复 支持 反对

使用道具 举报

Lv3.寻梦者

梦石
0
星屑
1085
在线时间
326 小时
注册时间
2012-8-18
帖子
27
4
 楼主| 发表于 2021-4-21 10:17:32 | 只看该作者
niuyi119 发表于 2021-4-21 10:15
#===================================
# ○ 使用方法
#-----------------------------------

希望能用这个脚本,实现商店买卖时也能有负重系统
回复 支持 反对

使用道具 举报

Lv3.寻梦者

梦石
0
星屑
1085
在线时间
326 小时
注册时间
2012-8-18
帖子
27
5
 楼主| 发表于 2021-4-21 10:20:28 | 只看该作者
真·可乐 发表于 2021-4-21 08:28
首先得有个负重脚本,再谈结合负重的商店设计。

希望用这个脚本实现商店买卖中有负重系统
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-4-20 04:26

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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