jerdz

Villager
Member
Joined
Jul 31, 2022
Messages
10
Reaction score
2
First Language
French
Primarily Uses
RMMV
Dear RPG Maker MV community,

I have a game with custom stats and in my game the "Magic Attack" (which I called the Knowledge) is supposed to decrease the Elemental Rate set by your hat by a.mat percent.

I tried to achieve that, and even with all the plugins that I could find I did not manage to find a way to make it work.

So basically what I would like is to be able to have a Hat that have for example "Elemental Rate Fire : 100-a.mat%"

Thank you fellow Makers !
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
5,459
Reaction score
3,536
First Language
English
Primarily Uses
RMMV
The trick is that you're talking about two different things - a parameter and a trait.

To make this work, you need a plugin that can dynamically modify traits during gameplay. Galv has one you can check out.
 

woootbm

Super Sand Legend
Veteran
Joined
Apr 26, 2014
Messages
335
Reaction score
289
First Language
English
Primarily Uses
RMMV
A simple way to cover this would be to make sure all your magic attacks check for this stat like a percent. So an attack formula would look like this:

[damage] * (1 - b.mat * 0.01)

Then on your items, having higher mat increases your elemental rate. I think you can also have minus stats on items.

Edit: Changed from a.mat to b.mat, since an attack I assume should check the target's stat for their resistance.
 
Last edited:

jerdz

Villager
Member
Joined
Jul 31, 2022
Messages
10
Reaction score
2
First Language
French
Primarily Uses
RMMV
@ATT_Turan I know that I am minxing Parameters (here the mat) and traits (here the Elements). And that is exactly my point. I have tried different plugins that dynamically modify traits (Galv and Shaz) but it does not really do what I want. I even created a script that does kinda the same as the plugins but I still have problems.

Each time I call the script, a new trait is push to the Actor, multiplying its effect. Moreover everytime the Actor changes Hat, he keeps the value of the previous hat he wear. I need to remove all the traits and then calculate the new element rate to push it.

I originally thought of a Commun Event that would calculate parallely the right Element Rate according to the actor's hat and its m. atk, the problem is that running that would probably lead to unnecessary performance issues.

I am not sure how I could make a script like that that would only call when gear is changed or something like that.


@woootbm It's not a possible solution as I need to check if the target wear the same elemental hat as the spell. Otherwise there is no reduction of damage.
 
Last edited:

jerdz

Villager
Member
Joined
Jul 31, 2022
Messages
10
Reaction score
2
First Language
French
Primarily Uses
RMMV
Sorry for the double post,

So basically what I did is to run that script at the beginning of every battle of my game.

Code:
var offsetElemHat = 23;
var hatId = 0;
for (let i = 1; i <= $gameParty._actors.length; i++) {
  var actorI = $gameActors.actor(i);
  actorI.actor().traits.splice({code: 11});
  hatId = actorI._equips[2]._itemId;
  if (hatId === 0) {
    continue;
  } else {
    var elemId = hatId - offsetElemHat;
    console.log(i + " " + actorI.name() + " ElemId:" + elemId + " = " + (100-actorI.mat/2)/100)
    actorI.actor().traits.push({code: 11, dataId: elemId, value: (100-actorI.mat/2)/100})
  }
}

It works, but I also wanted to have a way to change equipments during fight (which is possible with YEP plugin) but then I'll need to call the script again. Also I am showing Elemental Weaknesses in the Status Window and it would be nice to have it updated as soon as you equip the Hat, instead of having to start a fight first.

It would be nice if I could write a plugin that would do that. I know how to code but I have very poor knowledge on the RPG MV library and how to actually code stuff.

If that plugin could also prevent me from copying that script on every battle it would be nice.

Actually the best would be to call that script everytime the player closes equip scene. (I might need to move the topic to JS plugin request)
 
Last edited:

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
5,459
Reaction score
3,536
First Language
English
Primarily Uses
RMMV
You can search for plugins that run code when you equip/unequip items.

waynee95 has one (On Equip Eval or something similar).
 

jerdz

Villager
Member
Joined
Jul 31, 2022
Messages
10
Reaction score
2
First Language
French
Primarily Uses
RMMV
@ATT_Turan That's awesome !!! Thank you so much for your tremendous help.

Now I guess I can make the code looks much nicer and easier (I guess) I'll do some more research to see if i can attach the trait to the Hat and change it every time I equip it, instead of attaching the trait to the user and having to have 2 codes, one to add the trait when equip and another to remove the trait when unequip.

(do you know every MV scripts by heart?)
 

Latest Threads

Latest Posts

Latest Profile Posts


Clarn Hold
(No storylines)
There was a tutorial on how to draw anime eyes. Just draw Among Us. So I tried.
Screenshot_107.jpg
DamageActor3_7.png added!
index.php

Making a "characters first appearance" drawing for my game. Now I just have to finish the sprite art animation for her grand entrance.​
ScreenShot_9_24_2022_7_56_24.png
New area being started today. It leads to one of the games 2 optional bosses.

Forum statistics

Threads
125,540
Messages
1,171,816
Members
164,613
Latest member
dulichvungtaudl3m
Top