Help in improving script

Hello, Once again I'm asking for your help, I've been using a script to reduce party XP when fleeing a battle but I want it to prevent player going down a level when going to 1xp of that level. Example: Player is lvl4 has 69/420xp, he flees and losses xp and now is 1/420 instead going lvl3 369/420xp. The issue occurs when you lose skills and in game you can upgrade it and it costs a lot of skill points to get lvl 1 to lvl 3 skill.
What is the best option in your opinion to implement this? I've got few ideas but don't know if hung-up would work.

TL😀R: I want to prevent player dropping lvl and stopping at 1xp before going down a lvl making game not force you lose lvl skills and stats no mater how many times you flee a battle and lose xp.

$imported = {} if $imported.nil?
$imported["Sprawl_Escape"] = true

module BattleManager
def self.process_abort
replay_bgm_and_bgs
SceneManager.return
battle_end(1)

$game_party.all_members.each do |actor|
@exp_loss = -1 * actor.exp * 0.40;
actor.gain_exp(@exp_loss)
end

@xp_loss_str = @exp_loss * -1

text = "You lose " + @xp_loss_str.to_i.to_s
text = text + " experience points for fleeing."
$game_message.add('\.' + text)
wait_for_message
return true
end
end
I suspect you wanted to do it yourself but it caught my curiosity and I ended up crafting this script. Yet, it has not been approved by a moderator as of yet. (I posted it like a few seconds ago. 😛 )
I suspect you wanted to do it yourself but it caught my curiosity and I ended up crafting this script. Yet, it has not been approved by a moderator as of yet. (I posted it like a few seconds ago. 😛 )
Hey thanks for the fast reply. I took a look on your modyfied script and I like it. Also I think I didnt explain it properly, probably since it was 6in the morning and I have a lot of drinks last night, but, I want to edit the script to prevent people from going down a level, meaning, that if you escape you lose xp but will not lose more than 0, so that you don't go from lvl 3 to lvl 2, instead you stay lvl 3 but have 1xp left, the issue occurs when you go down a level and then up you get stats which means that if you keep going from level 3 then escape and go level 2 and then level up 3 again you get points meaning that it can be easily abused to get imposible stats if you just keep runing away getting xp needed to lvl up and then repeating it again. I took a look of your script and it looks great, but, I dont think it would work with my game since I use scripts that give you skill points based on hits, spells and kills and when you level up you get +5 skill points so in theory peopel can just abuse it.
Is there another way than the edited script you made to make it to check if xp= > 0 then you don't lose xp to prevent the possible abuse?
=_= Bummer. Players love such "bugs" and yet, here you are trying to take the fun part away from them. Repent. 😛

I'd consider it for some time first.
=_= Bummer. Players love such "bugs" and yet, here you are trying to take the fun part away from them. Repent. 😛

I'd consider it for some time first.
Well, as a player I would also love to exploit it, but, as a maker it would bum me out to see a player getting skill points over and over again killing the point of gaming. Let me know if you change your mind and help me out with it, since I understand from your script skill will remain after going down a level where I would love to prevent player going down level as a whole

Original thread: https://forums.rpgmakerweb.com/threads/help-in-improving-script.159164/