Holzfalter

Warper
Member
Joined
May 18, 2021
Messages
3
Reaction score
0
First Language
german
Primarily Uses
RMMZ
Hi,

I'm looking for a way to add static values to parameters temporarily. For example -> ATK + 5 and not ATK * 5
There are already ways to add static values, but these changes are permanent.

I have already searched various forums, but mostly only external plugins are recommended. Unfortunately, I don't use any external plugins and am therefore looking for a way to solve this myself. Via events or script commands.

Do you know a way how I can temporarily change parameters (ATK, DEF..) with static values?

Thanks!
 

Aerosys

Veteran
Veteran
Joined
Apr 23, 2019
Messages
771
Reaction score
736
First Language
german
Primarily Uses
RMMZ
I cannot follow what you are looking for.

For example -> ATK + 5 and not ATK * 5
In a damage formula? Character parameters? Enemy parameters?

Also, I don't know what you mean by "static". In programming, "static" is a well-defined keyword. In RPG Maker, however, it's not. Do you want to alter something with e.g. exactly 5?
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
6,165
Reaction score
4,134
First Language
English
Primarily Uses
RMMV
Do you want to alter something with e.g. exactly 5?
That's my understanding of the request.

Unfortunately, I don't use any external plugins and am therefore looking for a way to solve this myself. Via events or script commands.
I don't know if you understand that these are the same things. Plugins are simply text files of code - the same text that would get stored in MZ's JSON files if you entered a script command, and the same text that you're already using "externally" via the source code files in your js folder.

I can't think of a reason to not use plugins.
 

caethyril

^_^
Global Mod
Joined
Feb 21, 2018
Messages
4,105
Reaction score
3,164
First Language
EN
Primarily Uses
RMMZ
Can you just use the Change Parameter event command? If you do +5 then you can do -5 later on, making it temporary.

Do you want the extra value to be removed "automatically" at some point? If so, when?

Why are you avoiding "external plugins"? It'd be good to know so that people don't waste time providing a solution that you might reject.
 

Holzfalter

Warper
Member
Joined
May 18, 2021
Messages
3
Reaction score
0
First Language
german
Primarily Uses
RMMZ
Thank you all for your answer. I'm sorry if I didn't write clearly. As an an example:
Actor 1 casts a spell, which increases the ATK from Actor 2 for 3 turns (Or until the state is removed). With 30 ATK points for example. With states i can only add percentage-based boosts like +30%. I want to add the value 30 (or the value from a variable) to the ATK of Actor 2.

With states i get: 200 * 1.30 = 260
I need: 200 + 30 = 230

I can use the event command to add the 30 points, but i have to remove the 30 points manually. It's difficult to do with multiple states that may be cast multiple times. That's why I'm hoping for a simple solution, which probably doesn't exist. For example a script command (?) in rpg maker mz.

@ExternalPlugins:
I don't want any rights issues. Here I am very anxious. ;-) Also, I don't want to be to dependent on other programmers/scripters.
For example, I implemented passive abilities in my game such as fixed poison damage or mirror, which shoots back some of the damage an actor receives. If I wish for changes here - for example that values such as LUK changes the probability the passive skill to trigger, I can add the changes independently.

Thank you for your time.
 

caethyril

^_^
Global Mod
Joined
Feb 21, 2018
Messages
4,105
Reaction score
3,164
First Language
EN
Primarily Uses
RMMZ
I can use the event command to add the 30 points, but i have to remove the 30 points manually. It's difficult to do with multiple states that may be cast multiple times. That's why I'm hoping for a simple solution, which probably doesn't exist. For example a script command (?) in rpg maker mz.
Yep, that'll need a plugin.
ExternalPlugins:
I don't want any rights issues.
Obey the terms of use? Copyright applies to all original content unless the creator explicitly forfeits that right. But even if the content is copyrighted, the terms may allow derivative works or edits. The MIT license is a common example of this:
Also, I don't want to be to dependent on other programmers/scripters.
For example, I implemented passive abilities in my game such as fixed poison damage or mirror, which shoots back some of the damage an actor receives. If I wish for changes here - for example that values such as LUK changes the probability the passive skill to trigger, I can add the changes independently.
So you just need to know how to edit it (and have permission to do so), then it's all good?

I wrote a plugin (attached). Terms of use are my usual for little things like this:
Free to use and/or modify for any project, no credit required.
Here's the code, for reference:
JavaScript:
/*:
 * @target MZ
 * @plugindesc Add flat values for basic params from states.
 * @author Caethyril
 * @url https://forums.rpgmakerweb.com/index.php?threads/152847/
 * @help State notetag:
 *    <add param X: Y>
 *   - replace X with the param ID (see below);
 *   - replace Y with the flat bonus to add when affected by this state.
 *   - e.g. <add param 2: 5>     =  +5 ATK
 *     e.g. <add param 6: -10>   = -10 AGI
 * 
 * Basic param IDs:
 *   0 - Max HP      4 - MAT
 *   1 - Max MP      5 - MDF
 *   2 - ATK         6 - AGI
 *   3 - DEF         7 - LUK
 * 
 * Free to use and/or modify for any project, no credit required.
 */

void (() => {
'use strict';

    const getBonus = function(obj, paramId) {
        const tagName = 'add param %1'.format(paramId);
        return parseInt(obj.meta?.[tagName] || 0, 10);
    };

    const alias = Game_BattlerBase.prototype.paramPlus;
    Game_BattlerBase.prototype.paramPlus = function(paramId) {
        const bonus = this.states().reduce(
            (a, c) => a + getBonus(c, paramId)
        , 0);
        return alias.apply(this, arguments) + bonus;
    };

})();
This adds an extra value to a battler's paramPlus value, based on the notetags on the states that are currently affecting that battler. paramPlus is used by the core scripts to determine a basic parameter's current value: (base + plus) * rate * buffRate.

(Notetags are entered as text in the Note field of a database record.)
 

Attachments

  • paramPlusState.js
    1.1 KB · Views: 1

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
6,165
Reaction score
4,134
First Language
English
Primarily Uses
RMMV
I don't want any rights issues. Here I am very anxious.
The terms of use for basically any plugin I've seen are extremely straightforward. They're either usable in commercial projects or not (only in free). If it's a language issue, I'm sure you can get some help with translating and reading the terms of use, but almost no one makes anything with complicated language. If you got the plugin, you can use it.


Also, I don't want to be to dependent on other programmers/scripters.
Well...
1 - If that's the case, do JavaScript tutorials, learn how to read RPG Maker's code, and you'll be able to understand it and change whatever you like.

2 - I don't think that's realistic. I know of...I think no one who only uses their own work. There are probably a few people who are super hardcore and do everything through events just for the fun of figuring it out. But even people who can code will use plugins written by other people because it's silly to waste time writing it yourself when other people have already done it.

For example, I implemented...If I wish for changes here...I can add the changes independently.
I haven't seen any plugin author that tries to say you can't edit the plugin for your personal use.

I believe you're making life harder on yourself than you need to :stickytongue:

Good luck with your project!
 
Last edited:

Holzfalter

Warper
Member
Joined
May 18, 2021
Messages
3
Reaction score
0
First Language
german
Primarily Uses
RMMZ
@caethyril
Wow. I wasn't expecting such a helpful answer!
I would be ok if someone had confirmed to me that there is no script command in RPG Maker MZ for my request. That you quickly wrote a plugin for me to help me is really awesome.. really thank you for your work! I think other people here in the forum can also benefit from it. Did it long for you, to write that?

Additional (stupid) question to your plugin, if you have time to answer:
Can I also use variables in the notefield instead of the numbers?

Example: <add param 6: \v[x]> = -10 AGI

@ATT_Turan
I think you're right that I'm making my life here more difficult than necessary. ;-) It just has to do with my experiences in life. I was already having problems because I assumed something would be okay. That's why I like to play it safe when it comes to legal matters. But that's definitely my problem.

I also agree with you that it would probably be best if I learned Javascript. So far I've managed everything with Events and the Script Commands, so I haven't really had a need until now. I programmed with Java 10 years ago and also wrote small programs, but sadly today I remember little about it. ;-(
 

caethyril

^_^
Global Mod
Joined
Feb 21, 2018
Messages
4,105
Reaction score
3,164
First Language
EN
Primarily Uses
RMMZ
That you quickly wrote a plugin for me to help me is really awesome.. really thank you for your work! I think other people here in the forum can also benefit from it. Did it long for you, to write that?
You're welcome! I didn't time it, probably about 10~15 mins including design & tests.

Can I also use variables in the notefield instead of the numbers?

Example: <add param 6: \v[x]> = -10 AGI
Not as it is: you would need to edit the code to allow for that. E.g. add a check to the getBonus function (untested):
JavaScript:
    const getBonus = function(obj, paramId) {
        const tagName = 'add param %1'.format(paramId);
        const value   = obj.meta?.[tagName];
        // match "v[x]" values using a regular expression
        const match   = parseInt(/\s*v\[(\d+)\]\s*/.exec(value)?.[1], 10);
        if (match)
            return $gameVariables.value(match);
        // otherwise return integer
        return parseInt(value || 0, 10);
    };
Then in theory you can also use something like this:

<add param 6: v[123]>
...meaning "add a flat AGI bonus equal to the current value of variable ID 123".

I programmed with Java 10 years ago
Note that Java and JavaScript (formally ECMAScript) are completely different languages.
 

Latest Threads

Latest Posts

Latest Profile Posts

Bex
Finally upgraded to RMMZ.
ScreenShot_11_28_2022_7_52_34.png
FINALLY, I figured out how to get the "tail" to appear IN the window and not directly below it lol. now it looks like it's part of the window and not hanging from the bottom of it.
Twitch! Stream is about to go live with some Dark Souls 2! Feel free to drop by!
Has anyone ever wanted to choose how they play? I've been working on Black Moon, a project where you can fight against ancient beasts by commanding an army of former gods and goddesses. But what makes it different is that there are different ways to give your choice heroes either Red, Green, or Blue weapons/armor, and each grants different abilities. More coming soon!
Can Elon crash Twitter faster? I want something as big to replace it so I can promote my game there. I also need to actually do promotion this time, heh.

Forum statistics

Threads
126,916
Messages
1,182,341
Members
166,747
Latest member
wakkywack
Top