kdrk

Villager
Member
Joined
Mar 10, 2022
Messages
20
Reaction score
9
First Language
English
Primarily Uses
RMMZ
Hi guys, I want to change the element of the Current Actor Dynamically via Plugins (Javascript)

I change the Class via
$gameActors.actor(1).changeClass(X);

but how can I change the element trait of the said actor?
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
36,686
Reaction score
9,861
First Language
German
Primarily Uses
RMMV
that depends on how you apply the trait in the first case.
by default actors have no element trait - it is supposed to come from equipment like a fire sword or ice spear or whatever.

if you apply it directly then there is no way to remove or change a fixed trait to class or actor in default, but there are plugins that give dynamic trait functions.
but even with dynamic traits it is usually better to handle element rates by equipment, unless you make them completely dynamic and apply even the first one only after the game is initialised (not in the database itself)
 

kdrk

Villager
Member
Joined
Mar 10, 2022
Messages
20
Reaction score
9
First Language
English
Primarily Uses
RMMZ
that depends on how you apply the trait in the first case.
by default actors have no element trait - it is supposed to come from equipment like a fire sword or ice spear or whatever.

if you apply it directly then there is no way to remove or change a fixed trait to class or actor in default, but there are plugins that give dynamic trait functions.
but even with dynamic traits it is usually better to handle element rates by equipment, unless you make them completely dynamic and apply even the first one only after the game is initialised (not in the database itself)
What plugin have dynamic Trait functions? :o
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
36,686
Reaction score
9,861
First Language
German
Primarily Uses
RMMV
What plugin have dynamic Trait functions?
I don't know about MZ, but for VXA and MV there were scripts and plugins called "dynamic trait" that did exactly that. Try to search for these words for MZ, or see if the MV plugin works with FOSSIL.
 

coyotecraft

Mythographer
Veteran
Joined
Mar 13, 2012
Messages
319
Reaction score
183
First Language
English
Primarily Uses
N/A
To be fair you can change it but...
I mean, it's a simple thing to do a script call
$dataActors[1].traits[0].dataId = 1
Pretending the first trait was an Attack Element, I just set it to "Physical"
This might work for you depending on how temporary the change is.

But this is the $dataActors not the $gameActors. The change won't be saved when you leave the game. And a bigger concern might be that the trait change would be present when starting a new game or loading a different save file.

Then again, if this trait is something you're regularly checking or changing then maybe it won't be a big deal.
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
36,686
Reaction score
9,861
First Language
German
Primarily Uses
RMMV
But this is the $dataActors not the $gameActors.
and that is why I pointed to a plugin.

those plugins for dynamic traits handle the saving on changes to gameActor, preventing all the problems that come from changing dataActors.
 

coyotecraft

Mythographer
Veteran
Joined
Mar 13, 2012
Messages
319
Reaction score
183
First Language
English
Primarily Uses
N/A
I don't know. Attack Elements don't make a difference if the Enemy doesn't have an Elemental Rating in the first place. I think the only way you could exploit this is if there was a very gimmicky boss that was immune to everything but a rare element you're meant to jump through hoops to get. And even then, the player would need to already have that element prepared on a different save. Like a speedrun strategy.
Hardly game breaking. In fact, you could make it a feature of a "rare element only" challenge run. If maintaining the element from the very beginning of the game was easier said than done.
 

kdrk

Villager
Member
Joined
Mar 10, 2022
Messages
20
Reaction score
9
First Language
English
Primarily Uses
RMMZ
To be fair you can change it but...
I mean, it's a simple thing to do a script call
$dataActors[1].traits[0].dataId = 1
Pretending the first trait was an Attack Element, I just set it to "Physical"
This might work for you depending on how temporary the change is.

But this is the $dataActors not the $gameActors. The change won't be saved when you leave the game. And a bigger concern might be that the trait change would be present when starting a new game or loading a different save file.

Then again, if this trait is something you're regularly checking or changing then maybe it won't be a big deal.
Hmm, how come we can't do this with $gameActors?

Like for example, what I want to achieve is something like this.

Actor1 -> Change Class from Swordsman to Archer

Swordsman is Fire Element Trait, Archer is Water Element Trait.

But when I use
$gameActors.actor(1).changeClass(X);

It doesn't change the element as well, so I'll be needing to add something in my plugin that will make it so.
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
4,939
Reaction score
3,139
First Language
English
Primarily Uses
RMMV
Hmm, how come we can't do this with $gameActors?

Like for example, what I want to achieve is something like this.

Actor1 -> Change Class from Swordsman to Archer

Swordsman is Fire Element Trait, Archer is Water Element Trait.

But when I use
$gameActors.actor(1).changeClass(X);

It doesn't change the element as well, so I'll be needing to add something in my plugin that will make it so.
I'm confused by what you're asking here. When you change class, the actor will have all of the traits on that class.

That's how you change class and use different skills or can equip different kinds of items.

Are you claiming that your Archer has, in your database in the editor, traits related to water element that are not getting applied when you change class in the game?
 

coyotecraft

Mythographer
Veteran
Joined
Mar 13, 2012
Messages
319
Reaction score
183
First Language
English
Primarily Uses
N/A
$gameActors don't have a ._trait property to store changes to.
If we were to give it one, you'd have to change a number of things to make it work.

Classes, like equipment, have their own set of traits that the actor will inherit. So if Swordsman has a Fire Attack element, the Actor with that Class will too. They'll lose that trait on a class change, and assume the traits of another class. The only reason it wouldn't is if you didn't give the class an element trait. Or because the element you're seeing is attributed by something else carrying that trait; equipment or a state.

Am I reading "Change Element" too literal? Actually remove or replace the trait itself? Without removing or replacing the State, Equipment, Class ect...
You could have duplicate Swordsman classes, but with a different element for each. Behind the scenes, changing an element means changing the class.
 

kdrk

Villager
Member
Joined
Mar 10, 2022
Messages
20
Reaction score
9
First Language
English
Primarily Uses
RMMZ
$gameActors don't have a ._trait property to store changes to.
If we were to give it one, you'd have to change a number of things to make it work.

Classes, like equipment, have their own set of traits that the actor will inherit. So if Swordsman has a Fire Attack element, the Actor with that Class will too. They'll lose that trait on a class change, and assume the traits of another class. The only reason it wouldn't is if you didn't give the class an element trait. Or because the element you're seeing is attributed by something else carrying that trait; equipment or a state.

Am I reading "Change Element" too literal? Actually remove or replace the trait itself? Without removing or replacing the State, Equipment, Class ect...
You could have duplicate Swordsman classes, but with a different element for each. Behind the scenes, changing an element means changing the class.
How to add traits on classes? Like Fire Element on Swordsman Class, Water Element on Archer class
 

caethyril

^_^
Global Mod
Joined
Feb 21, 2018
Messages
3,803
Reaction score
2,865
First Language
EN
Primarily Uses
RMMZ
As others have mentioned, you should just be able to put traits on the class.

To make sure we're on the same page:
  1. Element Rate trait - multiplies incoming damage of that element;
  2. Attack Element trait - applies to outgoing damage of skills with "Element: Normal Attack".
What sort of thing do you expect to happen when an actor "has" Water element or Fire element?
 

coyotecraft

Mythographer
Veteran
Joined
Mar 13, 2012
Messages
319
Reaction score
183
First Language
English
Primarily Uses
N/A
Like this?
1dywB7T.png

Otherwise, changing the $dataClasses is like changing the $dataActors.

Maybe if you set up your classes in a particular order like

1 Swordsman (no element)
2 Swordsman (fire)
3 Swordsman (water)
.
.

8 Archer (no element)
9 Archer (fire)
10 Archer (water)
.
.
.

So when you use a class change script call, the ID for the fire class will be the base class ID+1.
Where "+1" is a variable.
Of course this setup assumes the elements are mutually exclusive. Creating classes for every elemental combo would be a pain.
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
36,686
Reaction score
9,861
First Language
German
Primarily Uses
RMMV
How to add traits on classes?
exactly like you add any other trait: select it in the trait window.
in the database, most of the different tabs have a trait section and anything assigned there is assigned to that database object, no matter if weapon, armor, class, state or whatever.

the traits on the actor will always be based on what is currently equipped or assigned to that actor
 

kdrk

Villager
Member
Joined
Mar 10, 2022
Messages
20
Reaction score
9
First Language
English
Primarily Uses
RMMZ
As others have mentioned, you should just be able to put traits on the class.

To make sure we're on the same page:
  1. Element Rate trait - multiplies incoming damage of that element;
  2. Attack Element trait - applies to outgoing damage of skills with "Element: Normal Attack".
What sort of thing do you expect to happen when an actor "has" Water element or Fire element?
When a Class is Fire, he hits higher on Earth Enemies, so like +20% or more damage so basically Swordsman class hits higher when its attacking Brawler Class For example

And Archer is Water class so when its being attacked by Swordsman Class, then Archer receives -20% damage, while deals 20% damage to swordsman
 

kdrk

Villager
Member
Joined
Mar 10, 2022
Messages
20
Reaction score
9
First Language
English
Primarily Uses
RMMZ
Like this?
1dywB7T.png

Otherwise, changing the $dataClasses is like changing the $dataActors.

Maybe if you set up your classes in a particular order like

1 Swordsman (no element)
2 Swordsman (fire)
3 Swordsman (water)
.
.

8 Archer (no element)
9 Archer (fire)
10 Archer (water)
.
.
.

So when you use a class change script call, the ID for the fire class will be the base class ID+1.
Where "+1" is a variable.
Of course this setup assumes the elements are mutually exclusive. Creating classes for every elemental combo would be a pain.
Thanks for this! Another question though, how can I adjust the Damage/Damage Taken % based on the Elemental Strengths/Weaknesses?


Like Water Deals 20% more damage to Fire, and reduces incoming Fire Attacks by 20%
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
36,686
Reaction score
9,861
First Language
German
Primarily Uses
RMMV
Like Water Deals 20% more damage to Fire, and reduces incoming Fire Attacks by 20%
first thing to keep in mind is that the elemental damage rates are always damage received

so each class would have traits for every element, stating how the percentages would be.
so the fireclass would have an elemental rate of 120% water to indicate that it takes 20% additional damage when attacked by a water element.
 

coyotecraft

Mythographer
Veteran
Joined
Mar 13, 2012
Messages
319
Reaction score
183
First Language
English
Primarily Uses
N/A
It's tricky, you can have multiple Elemental Rates Traits that change the damage multiplier.
like 1000% followed by 2%
So that's (Damage * 10 * .02) which would be the same as (Damage * .2) or 20%.
But that across 2 traits, and you can have element traits on Actors, Classes, Equipment, and States.

So "How" to do this, with a script call, is a great question. Because you might change individual traits, or push a new trait.
A more pertinent question is "why" is it changing? Perhaps the class' element rate goes up by with the character level?
 

Latest Threads

Latest Posts

Latest Profile Posts

I just got all of my wisdom teeth out today, thankfully I have the rest of the week off.
Man I am learning I am bad at naming armor lmao.
The game's opening, now fully polished! :LZScheeze:





Aaand, here's me working on it in today's "Game Making Every Day" video! :LZSooo:

Hello! Can anyone help me? I followed making cooking tutorial for RPG Maker MV. But for some reason buff state that food gives doesn't work in overworld. It disappears. What am I supposed to do?
A shotgun is not a rifle. Huh.

Forum statistics

Threads
124,404
Messages
1,163,369
Members
163,201
Latest member
YoBa
Top