设为首页收藏本站同能贴吧 切换语言 繁体中文
开启辅助访问 切换到窄版
扫描二维码关注官方公众号
返回列表
+ 发新帖
查看: 112|回复: 0

[转载发布] KWeatherArea ACE

[复制链接]
累计送礼:
0 个
累计收礼:
1 个
  • TA的每日心情
    开心
    2026-7-12 04:10
  • 签到天数: 209 天

    连续签到: 2 天

    [LV.7]常住居民III

    9071

    主题

    864

    回帖

    6万

    积分

    管理员

    Rank: 9Rank: 9Rank: 9

    VIP
    7
    卡币
    58883
    OK点
    16
    推广点
    0
    同能卷
    50
    积分
    68848

    灌水之王

    发表于 2026-8-3 12:50:46 | 显示全部楼层 |阅读模式
    KWeatherArea ACE

    by Kyonides


    Introduction

    Did you ever want to set a custom weather effect depending on a given area on the current map?
    Now you can do it in RMVX ACE!


    NOTES

    • This scriptlet uses script calls to make that happen.

    • Here an area is synonymous with a rectangle.
    • You can add and remove areas.
    • These custom areas are NOT related to VX ACE's map areas.
    • Removing an active weather area reverts the effects to the last effect you've set via Set Weather Effects event command.
    • If you change the weather in battle, it will revert it to the current area's weather, if any.
    • Please read the embedded notes to learn how to use it properly.

    The Script

                    Ruby:       
    1. # * KWeatherArea ACE * #
    2. #   Scripter : Kyonides
    3. #   v1.2.0 - 2025-03-23
    4. # This scriptlet allows you to set regional weather effects on the current map.
    5. # It works as usual. If you enter an area, the rain or snow will soon appear.
    6. # Obviously, it will quickly vanish once you leave that area.
    7. # If you ever remove an active weather area, it will revert the weather to
    8. # the last effect set via weather effects event command if any.
    9. # * Script Call * #
    10. # - Add a Regional Weather Area
    11. # - Step #1
    12. #   Create 1 local variable: Use integers only, i.e. 1, 16 or 25.
    13. #   W stands for Width or how wide this rectangle is supposed to be.
    14. #   H stands for Height or how tall this rectangle is supposed to be.
    15. # area = [X, Y, W, H]
    16. #   Example:
    17. # area = [7, 10, 4, 6]
    18. # - Step #2
    19. #   Use this call now:
    20. #   - AreaID is an integer, 1+.
    21. #   - Type is one of the RM's weather types: :none, :rain, :storm & :snow
    22. # $game_map.add_weather_area(AreaID, Type, area)
    23. #   Example:
    24. # $game_map.add_weather_area(1, :rain, area)
    25. # - Remove a Regional Weather Area (Temporarily?)
    26. #   - AreaID is an integer, 1+.
    27. # $game_map.remove_weather_area(AreaID)
    28. class WeatherArea
    29.   def initialize
    30.     @id = 0
    31.     @type = 0
    32.     @area = Rect.new(0, 0, 0, 0)
    33.   end
    34.   def set_rect(*coords)
    35.     coords = coords.flatten
    36.     @area.x = coords.shift
    37.     @area.y = coords.shift
    38.     @area.width = coords.shift
    39.     @area.height = coords.shift
    40.   end
    41.   def inside?(px, py)
    42.     w = @area.x + @area.width - 1
    43.     h = @area.y + @area.height - 1
    44.     px.between?(@area.x, w) and py.between?(@area.y, h)
    45.   end
    46.   attr_accessor :id, :type, :area
    47. end
    48. class << BattleManager
    49.   alias :kyon_weather_area_scn_btl_end :battle_end
    50.   def battle_end(result)
    51.     $game_map.aftermath_weather_area
    52.     kyon_weather_area_scn_btl_end(result)
    53.   end
    54. end
    55. class Game_Screen
    56.   alias :kyon_weather_area_gm_scr_chng_wthr :change_weather
    57.   def change_weather(type, power, duration)
    58.     kyon_weather_area_gm_scr_chng_wthr(type, power, duration)
    59.     @old_weather_type = @weather_type
    60.   end
    61.   def modify_weather(type, max)
    62.     @weather_type = type
    63.     @weather_power = max
    64.     @weather_duration = 0
    65.   end
    66.   def previous_weather
    67.     @weather_type = @old_weather_type || :none
    68.     @weather_power_target = 0.0 if @weather_type == :none
    69.     @weather_power = @weather_power_target
    70.     @weather_duration = 0
    71.   end
    72. end
    73. class Game_Map
    74.   alias :kyon_weather_area_gm_map_init :initialize
    75.   alias :kyon_weather_area_gm_map_stp :setup
    76.   alias :kyon_weather_area_gm_map_up :update
    77.   def initialize
    78.     kyon_weather_area_gm_map_init
    79.     init_weather
    80.   end
    81.   def init_weather
    82.     @weather_map_areas = {}
    83.     @weather_area_id = 0
    84.   end
    85.   def setup(map_id)
    86.     kyon_weather_area_gm_map_stp(map_id)
    87.     load_weather_areas
    88.   end
    89.   def load_weather_areas
    90.     @weather_areas = @weather_map_areas[@map_id] || {}
    91.   end
    92.   def add_weather_area(area_id, new_type, *coords)
    93.     area = WeatherArea.new
    94.     area.id = area_id
    95.     area.type = new_type
    96.     area.set_rect(*coords)
    97.     areas = @weather_map_areas[@map_id] ||= {}
    98.     areas[area_id] = area
    99.     @weather_areas = areas
    100.   end
    101.   def remove_weather_area(area_id)
    102.     @weather_areas.delete(area_id)
    103.     return if @weather_area_id != area_id
    104.     reset_weather
    105.   end
    106.   def reset_weather
    107.     @screen.previous_weather
    108.     @weather_area_id = 0
    109.   end
    110.   def update(main=false)
    111.     kyon_weather_area_gm_map_up(main)
    112.     update_weather_areas
    113.   end
    114.   def update_weather_areas
    115.     return if @weather_areas.empty?
    116.     px, py = $game_player.xy
    117.     return if @weather_x == px and @weather_y == py
    118.     @weather_x = px
    119.     @weather_y = py
    120.     new_area = @weather_areas.find {|key, val| val.inside?(px, py) }
    121.     unless new_area
    122.       reset_weather
    123.       return
    124.     end
    125.     return if @weather_area_id == new_area[0]
    126.     @weather_area_id, area = new_area
    127.     @screen.modify_weather(area.type, 9)
    128.   end
    129.   def aftermath_weather_area
    130.     if @weather_area_id == 0
    131.       reset_weather
    132.     else
    133.       area = @weather_areas[@weather_area_id]
    134.       @screen.modify_weather(area.type, 9)
    135.     end
    136.   end
    137. end
    138. class Game_Player
    139.   def xy
    140.     [@x, @y]
    141.   end
    142. end
    143. class Spriteset_Battle
    144.   alias :kyon_weather_area_sprtst_btl_crt_pix :create_pictures
    145.   alias :kyon_weather_area_sprtst_btl_up_pix :update_pictures
    146.   alias :kyon_weather_area_sprtst_btl_disp :dispose
    147.   def create_pictures
    148.     create_weather
    149.     kyon_weather_area_sprtst_btl_crt_pix
    150.   end
    151.   def create_weather
    152.     @weather = Spriteset_Weather.new(@viewport2)
    153.     update_weather
    154.   end
    155.   def update_weather
    156.     @weather.type = $game_map.screen.weather_type
    157.     @weather.power = $game_map.screen.weather_power
    158.     @weather.ox = $game_map.display_x * 32
    159.     @weather.oy = $game_map.display_y * 32
    160.     @weather.update
    161.   end
    162.   def update_pictures
    163.     kyon_weather_area_sprtst_btl_up_pix
    164.     update_weather
    165.   end
    166.   def dispose
    167.     @weather.dispose
    168.     kyon_weather_area_sprtst_btl_disp
    169.   end
    170. end
    复制代码




    Terms & Conditions

    Free for use in ANY game.
    Please include my nickname in your game credits.
    Also mention the forum where you found it.

    That's it!



    本贴来自国际rpgmaker官方论坛作者:kyonides处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址:https://forums.rpgmakerweb.com/threads/kweatherarea-ace.176511/

    本帖子中包含更多资源

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

    x
    天天去同能,天天有童年!
    回复 送礼论坛版权

    使用道具 举报

    文明发言,和谐互动
    文明发言,和谐互动
    高级模式
    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    简体中文
    繁體中文
    English(英语)
    日本語(日语)
    Deutsch(德语)
    Русский язык(俄语)
    بالعربية(阿拉伯语)
    Türkçe(土耳其语)
    Português(葡萄牙语)
    ภาษาไทย(泰国语)
    한어(朝鲜语/韩语)
    Français(法语)
    关闭

    幸运抽奖

    社区每日抽奖来袭,快来试试你是欧皇还是非酋~

    立即查看

    聊天机器人
    Loading...

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

    GMT+8, 2026-8-17 06:15 , Processed in 0.141304 second(s), 55 queries .

    Powered by Discuz! X3.4

    Copyright © 2001-2020, Tencent Cloud.

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