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 example
returns "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
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
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/