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

[转载发布] Apply Random States

[复制链接]
累计送礼:
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-1 11:28:24 | 显示全部楼层 |阅读模式

    Apply Random States
    by: Rinobi




            [Version History]


    • 1.00 [12/08/2015] Initial Release

    Introduction


            Allows states to be applied randomly to targets in battle.

    Features


    • Apply random states to targets in battle!

    Screenshots
    [/url][url=https://forums.rpgmakerweb.com/attachments/randomstates01-png.27096/]


    How to Use


            See script calls and examples within the script.

    Demo
            None necessary.

    Script

    SpoilerSpoiler




    #===============================================================================
    # Rinobi: Apply Random States
    #-------------------------------------------------------------------------------
    # Allows states to be applied to targets randomly in battle.
    #-------------------------------------------------------------------------------
    # Version History:
    #
    #  @ 1.0 [12/08/2015] Completed
    #-------------------------------------------------------------------------------
    # Instructions:
    #
    # Paste below Materials and above Main Process.
    #-------------------------------------------------------------------------------
    # Script Calls:
    #
    # state_apply_sing # Uses the default settings for applying a single state.
    # state_apply_sing(array) # Set own array, state turns set to default.
    # state_apply_sing(array, min_turn, max_turn) # Set the array and turns.
    #
    # state_apply_rsing # Uses the default settings for applying a single state.
    # state_apply_rsing(range) # Set own range, state turns set to default.
    # state_apply_rsing(range, min_turn, max_turn) # Set the range and turns.
    #
    # state_apply_mult # Uses the default settings for applying mutiple states.
    # state_apply_mult(array) # Set own array, state turns set to default.
    # state_apply_mult(array, min_turn, max_turn) # Set the array and turns.
    #
    # state_apply_rmult # Uses the default settings for applying mutiple states.
    # state_apply_rmult(range) # Set own range, state turns set to default.
    # state_apply_rmult(range, min_turn, max_turn) # Set the range and turns.
    #-------------------------------------------------------------------------------
    # Examples:
    #
    # b.state_apply_sing
    # (Adds a random state to the target based on the module settings below.)
    #
    # b.state_apply_sing([2, 5, 9])
    # (Adds state 2, 5, or 9 to the target randomly.)
    #
    # a.state_apply_rmult((2..5), 3, 3)
    # (Randomly adds a number of states between 2 and 5 that last 3 turns to user.)
    #
    # a.state_apply_rsing((1..25, 1, 10)
    # (Randomly adds a 1 state between 1 and 25 that lasts betwen 1 and 10 turns.)
    #-------------------------------------------------------------------------------
    # Compatibility:
    #
    # Modules:
    #  @ StateRand < RINOBI
    #
    # New Methods:
    #  @ state_apply_sing    in Game_Battler
    #  @ state_apply_mult    in Game_Battler
    #  @ state_apply_rsing   in Game_Battler
    #  @ state_apply_rmult   in Game_Battler
    #===============================================================================
    module RINOBI module StateRand # No Touchie!
    #===============================================================================
    # ** Settings Module
    #-------------------------------------------------------------------------------
    # States default behavior.
    #===============================================================================
      #-----------------------------------------------------------------------------
      # Number of turns the state lasts. Will return a number between the below
      # values. Set both values as the same number to cancel randomization.
      Turns_Default = {:Min => 1, :Max => 5}
      #-----------------------------------------------------------------------------
      # A selection of state IDs for applying a single random state. Add as many as
      # you like in any order. States are selected randomly.
      SArray_Default = [2, 3, 4, 5, 6, 7, 8]
      #-----------------------------------------------------------------------------
      # A selection of state IDs for applying a multiple random states. Add as many
      # as you like in any order. States are selected randomly.
      MArray_Default = [2, 3, 4, 5, 6, 7 ,8]
      #-----------------------------------------------------------------------------
      # A range of state IDs for applying a single random state. Set the beginning
      # and ending state values below.
      SRange_Default = (2..8)
      #-----------------------------------------------------------------------------
      # A range of state IDs for applying a mutiple random states. Set the beginning
      # and ending state values below.
      MRange_Default = (2..8)
    #===============================================================================
    # ** End of Settings
    #-------------------------------------------------------------------------------
    # Editing beyond this area may result in unfathomable terror.
    #===============================================================================
    end end # No Touchie!
    $imported = {} if $imported.nil?
    $imported[:RIN_StateRand] = true
    #===============================================================================
    # ** Class: Game_Battler < Game_BattlerBase
    #===============================================================================
    class Game_Battler < Game_BattlerBase
      #--------------------------------------------------------------------------
      # * New Method: rand_apply_sing
      #--------------------------------------------------------------------------
      def state_apply_sing(array = RINOBI::StateRand::SArray_Default,
        minturn = RINOBI::StateRand::Turns_Default[:Min],
        maxturn = RINOBI::StateRand::Turns_Default[:Max])
        rstate = array.sample ; add_state(rstate)
        @state_turns[rstate] = [(minturn..maxturn).to_a.sample, 0].max
      end # rand_apply_sing
      #--------------------------------------------------------------------------
      # * New Method: rand_apply_mult
      #--------------------------------------------------------------------------
      def state_apply_mult(array = RINOBI::StateRand::MArray_Default,
        minturn = RINOBI::StateRand::Turns_Default[:Min],
        maxturn = RINOBI::StateRand::Turns_Default[:Max])
        rstate = array.sample(1 + rand(array.count))
        rstate.each {|s| add_state(s)}
        rstate.each {|t| @state_turns[t] = [(minturn..maxturn).to_a.sample, 0].max}
      end # rand_apply_mult
      #--------------------------------------------------------------------------
      # * New Method: rand_apply_rsing
      #--------------------------------------------------------------------------
      def state_apply_rsing(range = RINOBI::StateRand::SRange_Default,
        minturn = RINOBI::StateRand::Turns_Default[:Min],
        maxturn = RINOBI::StateRand::Turns_Default[:Max])
        rstate = range.to_a.sample ; add_state(rstate)
        @state_turns[rstate] = [(minturn..maxturn).to_a.sample, 0].max
      end # rand_apply_rang
      #--------------------------------------------------------------------------
      # * New Method: rand_apply_rmult
      #--------------------------------------------------------------------------
      def state_apply_rmult(range = RINOBI::StateRand::MRange_Default,
        minturn = RINOBI::StateRand::Turns_Default[:Min],
        maxturn = RINOBI::StateRand::Turns_Default[:Max])
        rstate = range.to_a.sample(1 + rand(range.count))
        rstate.each {|s| add_state(s)}
        rstate.each {|t| @state_turns[t] = [(minturn..maxturn).to_a.sample, 0].max}
      end # rand_apply_rang
    end # Game_Battler < Game_BattlerBase




    ApplyRandomStates_1.txt


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

    本帖子中包含更多资源

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

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

    使用道具 举报

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

    本版积分规则

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

    幸运抽奖

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

    立即查看

    聊天机器人
    Loading...

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

    GMT+8, 2026-8-17 22:19 , Processed in 0.108344 second(s), 52 queries .

    Powered by Discuz! X3.4

    Copyright © 2001-2020, Tencent Cloud.

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