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

[转载发布] [CloudTheWolf] Persistent Armor Type Unlocker

[复制链接]
累计送礼:
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 13:41:14 | 显示全部楼层 |阅读模式
    Something I wanted to do was allow the player to unlock Armor types using items through their play-though, however I couldn't find a way to do it.

    So I present the following script allows you to use a switch to Unlock Armor types using Switches (Which can be called with item use with Common Events)

    (Probs not the best, but worked for me so others may find useful)

                    Ruby:       
    1. #==============================================================================
    2. # CloudTheWolf Persistent Armor Type Unlocker
    3. # Author: CloudTheWolf
    4. # Date 16/07/2025
    5. # Version: 1.0.0
    6. #===============================================================================
    7. #
    8. # To use, just add/update the patches set in TRAIT_PATECHS
    9. # then turn ON the specified switch in an event.
    10. # Currently this only supports Armor, and not Weapons.
    11. # Also Note, this currently only supports Adding but not removing.
    12. #
    13. #===============================================================================
    14. module PersistentTraitPatcher
    15.   # Each patch unlocks an armor type (armor_type_id) for a specific actor,
    16.   # if a given switch is ON.
    17.   TRAIT_PATCHES = [
    18.     {
    19.       actor_id: 1,
    20.       armor_type_id: 2,
    21.       switch_id: 91
    22.     },
    23.     {
    24.       actor_id: 2,
    25.       armor_type_id: 4,
    26.       switch_id: 92
    27.     },
    28.     # Add more here as needed
    29.   ]
    30.   def self.apply_all
    31.     TRAIT_PATCHES.each do |patch|
    32.       next unless $game_switches[patch[:switch_id]]
    33.       actor = $game_actors[patch[:actor_id]]
    34.       actor.grant_armor_type(patch[:armor_type_id])
    35.     end
    36.   end
    37. end
    38. # Extend Game_Actor to store dynamic armor type unlocks
    39. class Game_Actor < Game_Battler
    40.   alias_method :setup_original, :setup
    41.   def setup(actor_id)
    42.     setup_original(actor_id)
    43.     @unlocked_armor_types = []
    44.   end
    45.   def grant_armor_type(armor_type_id)
    46.     @unlocked_armor_types ||= []
    47.     return if @unlocked_armor_types.include?(armor_type_id)
    48.     @unlocked_armor_types << armor_type_id
    49.     p "[TraitPatch] Actor #{self.id} unlocked Armor Type #{armor_type_id}"
    50.   end
    51.   alias_method :features_original, :features
    52.   def features(code = nil)
    53.     all = features_original(code)
    54.     return all unless @unlocked_armor_types
    55.     extra = @unlocked_armor_types.map do |armor_type_id|
    56.       f = RPG::BaseItem::Feature.new
    57.       f.code = 52  # 52 = FEATURE_EQUIP_ARMOR
    58.       f.data_id = armor_type_id
    59.       f.value = 0
    60.       f
    61.     end
    62.     all + (code ? extra.select { |f| f.code == code } : extra)
    63.   end
    64. end
    65. # Apply patcher on load and map enter
    66. class Scene_Map < Scene_Base
    67.   alias start_with_trait_patch start
    68.   def start
    69.     start_with_trait_patch
    70.     PersistentTraitPatcher.apply_all
    71.   end
    72. end
    73. class Scene_Load < Scene_File
    74.   alias on_load_success_with_trait_patch on_load_success
    75.   def on_load_success
    76.     on_load_success_with_trait_patch
    77.     PersistentTraitPatcher.apply_all
    78.   end
    79. end
    复制代码




    本贴来自国际rpgmaker官方论坛作者:CloudTheWolf处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址:https://forums.rpgmakerweb.com/threads/cloudthewolf-persistent-armor-type-unlocker.178972/
    天天去同能,天天有童年!
    回复 送礼论坛版权

    使用道具 举报

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

    本版积分规则

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

    幸运抽奖

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

    立即查看

    聊天机器人
    Loading...

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

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

    Powered by Discuz! X3.4

    Copyright © 2001-2020, Tencent Cloud.

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