RMRK is retiring.
Server is paid up for the rest of 2026, but the forum may go after that. See here for more information. Please archive or save anything you would like to keep before 2027.
Main Menu
  • Welcome to The RPG Maker Resource Kit.

Level Up Effects

Started by Cascading Dragon, September 04, 2009, 03:44:50 AM

0 Members and 1 Guest are viewing this topic.

Cascading Dragon

Ok, I have posted this elsewhere, but I have decided to stop being lazy and share this script of mine on here.


Version  1.6
Author  ~Redyugi~
Release Date  8-8-09



Introduction

Tired of not having your HP heal when you level up? Well this script will help fix that.  It has a feauture to manage how much HP and MP are healed as well as if and which states are removed.

Features

-Manage how HP and MP heals on level up
-Manage how states are healed on level up
-Give player items upon level up
-Allows for random sets of items to be given upon level up
-Turns on switch
-Adds to a variable
-Plays common event upon level up

Script


[spoiler]####################################
### -Redyugi's Level Up Effects- ###
###      -Version 1.6-           ###
####################################
class Game_Actor < Game_Battler
  #########
  # Set up
  #########
  #
  # Health
  RECOVER_ALL_HP = false # Recover all  HP when level up?
  RECOVER_HP = true # Recovers certain amount of HP
      # If above is true
  HP_SET = false # True = Set amount of HP, False = percentage of HP
  HP_RECOVER = 97 # Amount recovered by above
  #
  # MP
  RECOVER_ALL_MP = false # Recover all MP when level up?
  RECOVER_MP = true # Recovers certain amount of MP
      # If above is true
  MP_SET = false # True = Set amount of MP, False = percentage of MP
  MP_RECOVER = 93 # Amount recovered by above
  #
  # States
  REMOVE_STATES = false # Remove certain states when level up?
  STATES_TO_REMOVE = [1, 2, 3, 4, 5, 6]  # States to remove if above is true
  REMOVE_ALL_STATES = false  # Remove all states
  #
  # Items
  GAIN_ITEMS = true  # Gain items when level up?
  RANDOM_ON = true # Want to give random set of items when level up
  RANDOM = 100
  ITEMS_GAINED_1 = [1, 3] # Gives player items using Item ID
  ITEMS_NUM = 1 #Number of items you are giving the player - 1
  RANDOM_CHANCE_1 = 30
  ITEMS_GAINED_2 = [2, 4] #IF RANDOM
  RANDOM_CHANCE_2 = 60
  ITEMS_2_NUM = 1 #Number of items you are giving the player - 1, for use with Random
  ITEMS_GAINED_3 = [5, 6] #IF RANDOM
  RANDOM_CHANCE_3 = 90
  ITEMS_3_NUM = 1 #Number of items you are giving the player - 1, for use with Random
  #
  # Switches
  SWITCH_ON = false # Turn a switch on when level up?
  SWITCH_NUMBER = 1 # Switch number
  #
  # Variable
  VARIABLE_ON = false  # Add to a variable upon level up?
  VARIABLE_NUM = 1  # What variable
  VARIABLE_ADDITION = 5 # How much to add (subtract with a negitive number)
  #
  # Common Events
  COMMON_EVENT = false #Play a common event when level up?
  EVENT_NUMBER = 3  # Which common event
  #########
  # End Set Up
  #########

  alias redyugi_level_up level_up
  def level_up
    redyugi_level_up
    @hp = maxhp if RECOVER_ALL_HP
    if RECOVER_HP
      if HP_SET == true
        @hp += HP_RECOVER
      else
        recover = maxhp * (HP_RECOVER / 100.00)
        recover.to_s
        @hp += recover.to_i
      end
    end
    @mp = maxmp if RECOVER_ALL_MP
    if RECOVER_MP
      if MP_SET
        @mp += MP_RECOVER
      else
        recover = maxmp * (MP_RECOVER / 100.00)
        recover.to_s
        @mp += recover.to_i
      end
    end
    if REMOVE_STATES
      @states -= STATES_TO_REMOVE
    end
    if REMOVE_ALL_STATES
      @states.clone.each { |i| remove_state(i) }
    end
    if GAIN_ITEMS
      if RANDOM_ON == true
        r = rand(RANDOM)
        if r <= RANDOM_CHANCE_1
          for m in 0..ITEMS_NUM
            z = ITEMS_GAINED_1[m]
            $game_party.gain_item($data_items[z], 1)
          end
        elsif r > RANDOM_CHANCE_1 and r <= RANDOM_CHANCE_2
          for m in 0..ITEMS_2_NUM
            z = ITEMS_GAINED_2[m]
            $game_party.gain_item($data_items[z], 1)
          end
        elsif r > RANDOM_CHANCE_2 and r <= RANDOM_CHANCE_3
          for m in 0..ITEMS_3_NUM
            z = ITEMS_GAINED_3[m]
            $game_party.gain_item($data_items[z], 1)
          end
        else
          w = 1+1
        end
      else
        for x in 0..ITEMS_NUM
          y = ITEMS_GAINED_1[x]
          $game_party.gain_item($data_items[y], 1)
        end
      end
    end
    if SWITCH_ON
      $game_switches[SWITCH_NUMBER] = true
    end
    if VARIABLE_ON
      $game_variables[VARIABLE_NUM] += VARIABLE_ADDITION
    end
    if COMMON_EVENT
      $game_temp.common_event_id = EVENT_NUMBER
    end
  end
end
[/spoiler]


Customization

Instructions in the script


Compatibility

It should be compatible with everything. I used an alias for it.


Screenshot

None needed


DEMO

None needed


Installation

Place above main

FAQ

Q: Is this your 1st script?

A: Yes it is. Thanks for asking.


Terms and Conditions

A thanks and credit me please

Grafikal

I really like that it plays a common event when level up and that you can give players items :)

Cascading Dragon

Thanks. I thought it'd be a good feature for some people.
I actually want to make it give random sets of items, with a chance for no items. However, the "rand()" function doesn't want to work for me  :( But I will find a way to do it, with or without the rand() function

Grafikal

I think random would be nice only if you can set which items would be randomly chosen and not just a random item from the database. Some things in the database could be quest items or really highlevel things, etc. But the idea is really nice.

Cascading Dragon

#4
That is what I meant. lol. I wasn't thinking. lol.
I am thinking 3 sets of (your choice of) random items, and then a 4th set that will give the player nothing. Does that sound like enough?

Edit:

Also, I am trying to make it so you can control the random chance.

modern algebra

Hmm, I don't know about the random items; it seems a little strange to get items because you levelled up.

But I don't see why rand () wouldn't work for you. What are the arguments you are trying to pass?


Anyway this seems like a pretty nice script. I will add it to the index.

dricc

Instead of playing a custom event , i think it is better to put a switch on . With this switch a common event can be played easily .
Or maybe both if you want .
You can use my scripts freely . but not for commercial use .
:ccbync:
Don't encrypt your game !!!
Want to give me credit ? Easy ,add me in your game :

Cascading Dragon

Quote from: dricc on September 04, 2009, 02:03:04 PM
Instead of playing a custom event , i think it is better to put a switch on . With this switch a common event can be played easily .
Or maybe both if you want .

Well technically, you can use the common event to turn on the switch to turn on another common event. However, I will put the ability to turn on a switch in the next version.

QuoteHmm, I don't know about the random items; it seems a little strange to get items because you levelled up.

But I don't see why rand () wouldn't work for you. What are the arguments you are trying to pass?

True, but someone will find a use for it. lol.

I just use "rand(100)", but it stays at 0 for some reason. Then I tried to plug in a variable that was equal to 100 ("rand(RANDOM_CHANCE)") but it still comes out 0.

Its funny, but I had this same problem with Python.

modern algebra


Cascading Dragon

#9
Its not the strangest thing that has happened to me. Once I had this cluster of "if"-"elsif"-"else" statements, and the "if" statement, and 2 of the "elsif" statements occured at the same time. It was quite strange.

Well, back to the script, I will have the updated script with the switch feature in a few mins

EDIT

**UPDATE**
Find the updated script in the orginal post

Cascading Dragon

Haha. Wow.
Nice job with that, btw

Thank you.

Now that I am done doing my little side project in Python, I am gonna work on some scripts again so this will get an update soon...ish

Cascading Dragon

UPDATE!

Now it can add to a variable, and it can give random sets of items upon level up.

Sorta off topic:

The reason I couldn't do the random items sooner, was because the project I was using was missing something or one of the data files was messed up. I plugged it into another project and it worked so....I am glad I figured out that its not just my bad luck

Sebastian Cool ^-^


darkjingle

Hi i have problem with the script. It happens with every script on this website actually, i copy the script and when i paste it, it all appears on one line. Plz help.

Cascading Dragon

Thats because you are using IE. Just paste it into Microsoft Word or Microsoft Works