设为首页收藏本站同能贴吧 切换语言 繁体中文
开启辅助访问 切换到窄版
返回列表
+ 发新帖
查看: 238|回复: 0

[转载发布] Data File Save - Change database parameters mid-game

[复制链接]
累计送礼:
0 个
累计收礼:
1 个
  • TA的每日心情
    开心
    3 天前
  • 签到天数: 221 天

    连续签到: 1 天

    [LV.7]常住居民III

    9100

    主题

    890

    回帖

    7万

    积分

    管理员

    Rank: 9Rank: 9Rank: 9

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

    灌水之王

    发表于 2026-7-11 21:25:22 | 显示全部楼层 |阅读模式
    I shall warn this will be a long presentation, this system has a lot going on, and in fact I'll divide it into multiple posts. That's because it's a bit of a "scripters tool" so it can be used in many cases.

    Introduction
    To explain what this script does, first I have to talk very briefly about how the Database parameters are stored by default.

    RMXP saves the data on files in the Data folder of the project, for example items data is stored in Data/Items.rxdata.
    Then, it loads that when the Scene Title starts, with the method load_data through an internal module that stores the parameters (RPG::Item) and into a global ($data_items), where you can get those by ID.
    For examplereturns "Potion".

    By default, you can change parameters mid-game, with something like, and from then on that item will have that name, but with two important issues:

    1. You can't get the "default" parameter back, nor check if it has been changed. The only way would be loading the whole file again with load_data, and that's a slow process.

    2. Changes aren't saved when you save your game.

    This script solves both issues. It may seem like a big rewrite, but it's fairly simple after all.

    Terms
    - Giving credits (Wecoc) is optional.
    - You can use this script both in commercial and non-commercial RMXP games.
    - You can share this and make addons too. If you do, you can post them here as well if you want.
    - Those terms also apply to the addons I include in this topic if I don't say otherwise.

    Spoiler: Code
                    Ruby:        


    Instructions
    The script works with all the data globals except $data_system and Game_Map:map, which wouldn't make much sense. I'll keep using $data_items[1] (Potion) as an example so it's easier to understand.

    Spoiler: Script calls
    Get a parameter
    $data_items[1].name # Returns "Potion". Works as default.

    Set a parameter
    $data_items[1].name = "HP Potion"

    Get the default value for that parameter
    $data_items[1].default.name

    Check if the current parameter has the default value
    $data_items[1].name == $data_items[1].default.name

    Check if all the parameters of the item are default
    $data_items[1].is_default?

    Make all the parameters of the item back to default
    $data_items[1].reset
    Spoiler: How to define new parameters
    To create a new dynamic parameter, create a new script below Data Save File, and apply this structure:

                    Ruby:        

    The class name can be Actor, Class, Skill, Item, Weapon, Armor, Enemy, Troop, State.
    The name of the parameter, in this case agi_plus, can be whatever you want. You'll have to check the guide to know which ones are currently used. Finally, the default value can be an integer like in this case or something else. In the following example, a new parameter description_b is defined, which by default is exactly the same as the description of the item.

    You can define custom values for each item on those new parameters when starting a new game.

                    Ruby:        


    Compatibility
    This script overwrites:

    - Scene_Title :main
    - Scene_Save :write_save_file (alias)
    - Scene_Load :read_save_data (alias)

    The ones using alias won't cause any trouble if you put this script below others that change them, and the title one should be easy to solve, it only changes the lines with "load_data".

    Game savefiles made before implementing this script may stop working after this. You can update them with this.

    Tags System (AddOn)

    This AddOn allows to group anything by tags, so then it's more easily accessible by script call. Since it uses Data File Save it's dynamic, you can change it wherever you want through the game.

    Spoiler: Script calls
    For example, you can define some tags to a certain enemy like this:
    $data_enemies[1].set_tags("Fire", "Dragon", "Fly")

    And then check if it's a Dragon with:
    $data_enemies[1].has_tag?("Dragon")
    Spoiler: Tags System
                    Ruby:        


    Usage examples
    You may still be wondering what's all this for. I made some very short scripts that use this system, you have to place them below the Data File Save script. They're meant to be adapted, so I recomment to play with the IDs, the formulas used, the effects, etc.

    Spoiler: Usage Examples
    Spoiler: Molten Giant
    Skill with variable SP cost depending on current actor's parameters, in the example it depends on the HP / Max HP ratio.

                    Ruby:        

    Spoiler: Chicken knife[quote]Weapon which attack increases each time you escape from battle (it must be equipped).

                    Ruby:        


    Spoiler: Hestia knife
    Weapon which strength increases proportionally to the strength of its wearer.

                    Ruby:        

    It only updates when equipped, so you may want to change it when the actors strength changes (on level up) as well.
    Spoiler: Mejai's Soulstealer
    Each actor has a glory score that increases when they win a battle, but decreases when they lose (or are dead when battle ends). That's the first part, the second is a weapon which strength uses that variable.

                    Ruby:        


    Spoiler: Roaming Mend
    This state increases the resistance to physical damage, but when attacked it deactivates, and reactivates into a random ally. It can do this up to three times if there are more alive allies available.

    I recommend deactivating it after battle as well. The script has two parts, first one to make the state "jump" through the party, and the second one to apply the damage reduction.

                    Ruby:        


    Spoiler: Judgement
    Skill that changes its element based on the current accessory equipped.

                    Ruby:        


    Spoiler: Heighten Magic
    State increases the SP cost of certain skills, but it also increases their power.

                    Ruby:        


    Spoiler: Adapting Armor
    Armor that when attacked with an element becomes of that element, which means it temporarily becomes more resistant to that element. It resets when battle ends.

                    Ruby:        


    Spoiler: Map States
    Certain actors or enemies can have a permanent state based on the current map.

                    Ruby:        


    Spoiler: Walk Armor
    Armor which physical defense increases when increasing your step count.
    There are multiple ways to approach this, I'll try to cover the main two.

    The first one would be making its pdef depend on the total step count.

                    Ruby:        

    The second one increasing only when equipped.

                    Ruby:        


    Spoiler: Upgrading Shield
    Shield which defense increases when you're attacked and it's equipped. You can optionally make it increase only when guarding.

                    Ruby:        


    Spoiler: Learning Heal
    Skill that each time you use it, its SP cost decreases slightly (with a minumum cost).

                    Ruby:        
    [/quote]




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

    帖子地址: 

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

    使用道具 举报

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

    本版积分规则

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

    幸运抽奖

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

    立即查看

    聊天机器人
    Loading...

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

    GMT+8, 2026-10-20 01:13 , Processed in 0.144011 second(s), 55 queries .

    Powered by Discuz! X3.4

    Copyright © 2001-2020, Tencent Cloud.

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