Increase a parameter of an enemy by percent using a variable?

TenebrisCrow

Regular
Regular
Joined
Oct 19, 2015
Messages
119
Reaction score
13
First Language
English
Primarily Uses
RMMZ
Which is why I said in post #13 they should create an event that would reset the exp value after each fight...

Am I being stupid and missing it somehow?

And how exactly would I reset it? Haha sorry. Your script worked perfectly, but yes you were right. I do need to reset it.
 

ATT_Turan

Forewarner of the Black Wind
Regular
Joined
Jul 2, 2014
Messages
12,788
Reaction score
11,437
First Language
English
Primarily Uses
RMMV
And how exactly would I reset it?
Exactly as I said in post 13 - make an autorun event.

You already have the code for setting the experience:
$dataEnemies[Id of the enemy here].exp= whatever the original value is

Then you Erase Event so it won't run again until the next time you appear on the map.

(I think Erased events reload after a battle. If that doesn't work and it only runs once, you'll need to do something fancier with a switch)
 

Trihan

Speedy Scripter
Regular
Joined
Apr 12, 2012
Messages
6,883
Reaction score
7,990
First Language
English
Primarily Uses
RMMZ
Exactly as I said in post 13 - make an autorun event.

You already have the code for setting the experience:
$dataEnemies[Id of the enemy here].exp= whatever the original value is

Then you Erase Event so it won't run again until the next time you appear on the map.

(I think Erased events reload after a battle. If that doesn't work and it only runs once, you'll need to do something fancier with a switch)
Here's the thing, buddy...where are you getting the original value from when you've modified the original value? ;)
 

ATT_Turan

Forewarner of the Black Wind
Regular
Joined
Jul 2, 2014
Messages
12,788
Reaction score
11,437
First Language
English
Primarily Uses
RMMV
Here's the thing, buddy...where are you getting the original value from when you've modified the original value? ;)
Your brain? :guffaw: I don't see any reason for this to be dynamic, the OP is making the game, they know what they want the exp to be. I don't super understand your question.

If they typed in the database entry for the enemy that the EXP given is 230, then they type that also into their event $dataEnemies[Id of the enemy here].exp=230

If they change it in the database later for balancing or something, they'll simply alter the value in the event also.
 

Trihan

Speedy Scripter
Regular
Joined
Apr 12, 2012
Messages
6,883
Reaction score
7,990
First Language
English
Primarily Uses
RMMZ
Your brain? :guffaw: I don't see any reason for this to be dynamic, the OP is making the game, they know what they want the exp to be. I don't super understand your question.

If they typed in the database entry for the enemy that the EXP given is 230, then they type that also into their event $dataEnemies[Id of the enemy here].exp=230

If they change it in the database later for balancing or something, they'll simply alter the value in the event also.
Fair enough. I wasn't sure if you'd intended for OP to hardcode it, but that works as long as he remembers he's done this if the value does change. :p
 

caethyril

^_^
Global Mod
Joined
Feb 21, 2018
Messages
5,273
Reaction score
4,759
First Language
EN
Primarily Uses
RMMZ
Re editing $dataStuff: these arrays are loaded once per session. So, as well as not being recorded in save files, modifications will affect all gameplay, including new and continued playthroughs, until the game is closed. That's usually not a good idea. :kaoslp:

Resetting the value is a good idea, but remember that battles can end without returning to the map, e.g. defeat -> game over. I'm not sure if that situation applies in this case. Regardless, I notice VisuStella Battle Core has a <JS Post-End Battle> tag, so you could probably use that for the reset? (endBattle happens after makeRewards.)

As an alternative (untested):
JavaScript:
/*:
 * @target MZ
 * @plugindesc Define custom enemy EXP formulae with notetags.
 * @url https://forums.rpgmakerweb.com/index.php?threads/151540/
 * @help Enemy notetag:
 *    <exp formula: code>
 * Replace "code" with an eval, where "this" is the Game_Enemy instance.
 * Example - increase enemy EXP by +20% for every +1 to variable ID 123:
 *    <exp formula: this.enemy().exp * (1 + $gameVariables.value(123) / 5)>
 * 
 * Free to use and/or modify for any project, no credit required.
 */
void (alias => {
  const TAG_NAME = "exp formula";
  Game_Enemy.prototype.exp = function() {
    const value = eval(this.enemy().meta[TAG_NAME]);
    if (!isNaN(value)) return parseInt(value, 10);
    return alias.apply(this, arguments);
  };
})(Game_Enemy.prototype.exp);
The example in this plugin's help is additive, here's a multiplicative version:

<exp formula: this.enemy().exp * 1.2 ** $gameVariables.value(123)>
In case it's relevant, there are Game_Enemy methods for the other rewards: gold and makeDropItems.

Make a state, and from VisuStella Core give it the notetag:
Code:
<JS MaxHP Plus: user.mhp * (.2 * $gameVariables.value(ID))>
I think this fails because it creates a loop: user.mhp asks for the total value, which includes the plus formula. Might work if you use user.paramBase(0) instead, i.e. the database value, no traits or anything.
 

ATT_Turan

Forewarner of the Black Wind
Regular
Joined
Jul 2, 2014
Messages
12,788
Reaction score
11,437
First Language
English
Primarily Uses
RMMV
I think this fails because it creates a loop: user.mhp asks for the total value, which includes the plus formula.
Where's the loop? Granted, I don't/can't know how the VisuStella tag works, but I assume it's referenced once when the state is applied. I didn't see any indication that it's a dynamic thing.
 

caethyril

^_^
Global Mod
Joined
Feb 21, 2018
Messages
5,273
Reaction score
4,759
First Language
EN
Primarily Uses
RMMZ
Where's the loop? Granted, I don't/can't know how the VisuStella tag works, but I assume it's referenced once when the state is applied. I didn't see any indication that it's a dynamic thing.
Here's the documentation on that tag from the Yanfly wiki (link):

<JS param Plus: code> - Used for: Actor, Class, Weapon, Armor, Enemy, State Notetags - Runs 'code' to change the 'param' plus value. - Replace 'param' with 'MaxHP', 'MaxMP', 'ATK', 'DEF', 'MAT', 'MDF', 'AGI', or 'LUK' to determine which parameter to modify. - Replace 'code' with JavaScript code to determine how much to change the plus amount for the parameter's total calculation. - This is used to calculate the 'plus' portion in the Parameter Settings => Basic Parameter => Formula.
The last point strongly suggests to me that this is incorporated as part of the param formula. Haven't tested it, though; was just a suggestion. :kaohi:
 

ATT_Turan

Forewarner of the Black Wind
Regular
Joined
Jul 2, 2014
Messages
12,788
Reaction score
11,437
First Language
English
Primarily Uses
RMMV
The last point strongly suggests to me that this is incorporated as part of the param formula. Haven't tested it, though; was just a suggestion. :kaohi:
I see what you mean there.
 

Latest Threads

Latest Posts

Latest Profile Posts

Reworked a bit on the UI. I'm pretty happy with how the status window turned out!
Rafael_UI.png
Be sure to check @casper667's page full of RM stuff as we are collabing together to bring out custom assets :kaohi:
4 more hours til I give my last final. And I couldn't bring my laptop to pass time this time due to the finals taking up all the space in my backpack.

Send help. Or a Steam Deck.
Thanks to my last two calendar days, the goddess can now join your heroes' party and whack your enemies with the power of love!
1702314770604.png
How are you gonna use all those new resources from the calendars?
I hate driving in games. Imagine your character profile being an exceptional individual, yet when they drive, it makes them look dumb.

Forum statistics

Threads
136,919
Messages
1,271,488
Members
180,711
Latest member
drlheureuxem
Top