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

Project1

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

[有事请教] 怎把这天气系统RPGXP加效果功能?下雨时地上会湿

[复制链接]

Lv3.寻梦者

梦石
0
星屑
1113
在线时间
143 小时
注册时间
2008-7-1
帖子
150
跳转到指定楼层
1
发表于 5 小时前 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
1星屑
# 自动天气系统
# 用法: 直接插入脚本编辑器,通过开关控制(默认开关15)
module AutoWeather
  # 配置
  SWITCH_ID = 15       # 控制开关ID
  MIN_DURATION = 300   # 最小持续时间(帧)
  MAX_DURATION = 600   # 最大持续时间(帧)
  WEATHER_CHANCES = [  # 天气概率(总和100)
    50,  # 晴天
    20,  # 雨天
    15,  # 雪天
    15   # 雾天
  ]
  
  # 初始化
  def self.init
    @active = false
    @timer = 0
    @current_weather = 0
    @duration = 0
  end
  
  # 更新天气
  def self.update
    return unless $game_switches[SWITCH_ID]
   
    if @timer <= 0
      set_new_weather
    else
      @timer -= 1
    end
  end
  
  # 设置新天气
  def self.set_new_weather
    # 修正随机持续时间写法,适配RPGXP的Ruby版本
    @duration = MIN_DURATION + rand(MAX_DURATION - MIN_DURATION + 1)
    @timer = @duration
   
    # 随机天气类型
    rand_val = rand(100)
    total = 0
    new_weather = 0
   
    WEATHER_CHANCES.each_with_index do |chance, i|
      total += chance
      if rand_val < total
        new_weather = i
        break
      end
    end
   
    # 应用天气
    if new_weather != @current_weather
      @current_weather = new_weather
      case new_weather
      when 0 then $game_screen.weather(0, 0, 0)  # 晴天
      when 1 then $game_screen.weather(1, 8, 15) # 雨天
      when 2 then $game_screen.weather(2, 8, 15) # 雪天
      when 3 then $game_screen.weather(3, 6, 20) # 雾天
      end
    end
  end
end

# 初始化
AutoWeather.init

# 集成到主循环
class Scene_Map
  alias auto_weather_update update
  def update
    auto_weather_update
    AutoWeather.update
  end
end
怎把这天气系统RPGXP加效果功能?下雨时地上会湿,下雪地上一层雪,不同的天气会有不同环境和地理效果

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

本版积分规则

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

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

GMT+8, 2025-9-19 17:57

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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