Character penalty, exp Loss. without the loss of Level.

Status
Not open for further replies.

Etarxer

Veteran
Veteran
Joined
Sep 14, 2020
Messages
38
Reaction score
5
First Language
English
Primarily Uses
RMMZ
*Solved*
In the process of working this out, I realized it did not need to be a script. So this is in the wrong part of the forum. Sorry Mods!

So first I put a Variable in a blank event that runs parallel, and named it Temporary Level(pic1). Then activated a Self Switch. Next there is a Parallel Common Event that keeps tabs on another Variable named Player Level. Within the events that give the Player EXP(pic2) or take the Player's EXP, it calls another common event(not parallel or autorun). This one checks IF the Player Level > Temporary Level, update Temp level to be set to player level, increase another Variable named Level Tracker by 1 and end the event. It also has another conditional branch that says IF Player Level < Temporary Level, Change player level +1(pic 3). Finally every time you use the SKILL Level UP, it checks if Level Tracker is > 0 , runs the code for level up(in my case the custom stat increases) and removes 1 from Level Tracker.
Project2 - RPG Maker MZ 9_17_2021 12_16_46 AM.png
Project2 - RPG Maker MZ 9_17_2021 12_15_14 AM.png

Project2 - RPG Maker MZ 9_17_2021 12_13_20 AM.png
Original Post:

Hey guys I'm back again.

I'm trying to create a EXP penalty for dying. It's easy enough honestly, but if the player loses to much Exp they go down a Level.
How would I go about setting up a script to prevent the player from Deleveling?

Why this is important, after every 4 levels in game you gain a stat point. This stat point is used to permanently increase a "SKILL" that greatly improves users Stats. Also upon every Level up you can choose 1 stat to get a small boost. If the players find out about the deleveling situation it could have people spamming death as a way to increase stats, and would break the balance of the game.

I have Level UP and Skill UP tied to the "skills" in the database. So upon every level the player learns these, and when they use them they forget them. I also have a Variable that increases by 1 for every level. and everytime one of those skills are used it decreases the variable by 1. and if its 0 then it wont allow the player to use the skill again.
 
Last edited:

HexMozart88

The Master of Random Garbage
Veteran
Joined
May 15, 2016
Messages
2,100
Reaction score
3,871
First Language
English
Primarily Uses
RMVXA
Not sure what the exact syntax for this is, but what I'd do is make sure the player's XP is x amount above the base XP for that level.
 

Etarxer

Veteran
Veteran
Joined
Sep 14, 2020
Messages
38
Reaction score
5
First Language
English
Primarily Uses
RMMZ
Not sure what the exact syntax for this is, but what I'd do is make sure the player's XP is x amount above the base XP for that level.

yea I thought of trying something that tracked the XP or level or something, but it doesnt help when you relevel and the condition is true again.
 

Nolonar

Veteran
Veteran
Joined
Feb 18, 2018
Messages
276
Reaction score
377
First Language
French, German
Primarily Uses
RMMZ
I think you're looking for this:
JavaScript:
const actor = $gameActors.actor(ACTOR_ID);
const losableExp = actor.currentExp() - actor.currentLevelExp();
const expToLose = Math.min(losableExp, EXP_PENALTY);
$gameVariables.setValue(VARIABLE_ID, expToLose);

ACTOR_ID must be the ID of the actor whose exp you want to reduce, for example 3 for actor #0003.
EXP_PENALTY must be a positive number describing how much exp the actor must lose, for example 100 to lose 100 exp. If you use a negative number, the actor will gain exp instead.
VARIABLE_ID must be the ID of a variable in which to store the amount of exp to lose, for example 2 for variable #0002. You can then use that variable in the Change EXP event command. Don't forget to set the Operation to Decrease.


If you prefer to choose your actor based on their position within the party, simply replace $gameActors.actor(ACTOR_ID); with $gameParty.members()[POSITION];

POSITION refers to the actor's position in the party, for example 0 for the first member in the party. Note that POSITION is 0-based, so the first member is 0, the second member is 1, etc. Also note that there can only be 4 members in battle (from 0 to 3), but there can be more than 4 members outside of battle.
 

Etarxer

Veteran
Veteran
Joined
Sep 14, 2020
Messages
38
Reaction score
5
First Language
English
Primarily Uses
RMMZ
I think you're looking for this:
JavaScript:
const actor = $gameActors.actor(ACTOR_ID);
const losableExp = actor.currentExp() - actor.currentLevelExp();
const expToLose = Math.min(losableExp, EXP_PENALTY);
$gameVariables.setValue(VARIABLE_ID, expToLose);

ACTOR_ID must be the ID of the actor whose exp you want to reduce, for example 3 for actor #0003.
EXP_PENALTY must be a positive number describing how much exp the actor must lose, for example 100 to lose 100 exp. If you use a negative number, the actor will gain exp instead.
VARIABLE_ID must be the ID of a variable in which to store the amount of exp to lose, for example 2 for variable #0002. You can then use that variable in the Change EXP event command. Don't forget to set the Operation to Decrease.


If you prefer to choose your actor based on their position within the party, simply replace $gameActors.actor(ACTOR_ID); with $gameParty.members()[POSITION];

POSITION refers to the actor's position in the party, for example 0 for the first member in the party. Note that POSITION is 0-based, so the first member is 0, the second member is 1, etc. Also note that there can only be 4 members in battle (from 0 to 3), but there can be more than 4 members outside of battle.

I just tried this out and its still doing the same thing where if the player loses enough EXP they go down a level.
 

Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
43,742
Reaction score
15,312
First Language
English
Primarily Uses
RMMV
No worries.

Moved, and Closed

 
Status
Not open for further replies.

Latest Threads

Latest Posts

Latest Profile Posts

Can't believe my code from four years ago is still working! Did some expansions, and...
1635194553179.png
In related news, I may have an update for my old Extra status window plugin ready. That is, once I manage to sit down and update the documentation... and the demo project... :kaoswt:
How does one pronounce Godot? I've heard it pronounced a couple of different ways, and I genuinely don't know the proper way.
March 2020 ...
1635188823939.jpeg
... vs October 2021
You look like you had a rough day...Here, have a Baby Panda!

7 years of trying to plan this project... and it got an official plotline today. 7 years. I really just have no concept of order huh GHJGSJHGVGHASFH.

Forum statistics

Threads
116,074
Messages
1,095,523
Members
151,436
Latest member
ChrisSteven
Top